define("utils", ["exports", "underscore"], function (_exports, _underscore) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _underscore = _interopRequireDefault(_underscore);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  const IS_MAC = /Mac/.test(navigator.userAgent);

  /**
   * Utility functions.
   */
  const Utils = {
    /**
     * Handle a click event action.
     *
     * @param view A view.
     * @param event An event.
     * @param element An  element.
     * @param actionData Data. If an action is not specified, it will be fetched from a target element.
     * @return True if handled.
     */
    handleAction: function (view, event, element, actionData) {
      actionData = actionData || {};
      const $target = $(element);
      const action = actionData.action || element.dataset.action || null;
      const name = element.dataset.name || action;
      let method = null;
      let handler = null;
      if (name && actionData.actionItems && (!actionData.className || element.classList.contains(actionData.className))) {
        const data = actionData.actionItems.find(item => {
          return item && (item.name === name || item.action === name);
        });
        if (data && data.onClick) {
          data.onClick();
          return true;
        }
        if (data) {
          handler = data.handler ?? null;
          method = data.actionFunction ?? null;
        }
      }
      if (!action && !actionData.actionFunction && !method) {
        return false;
      }
      if (event.ctrlKey || event.metaKey || event.shiftKey) {
        const href = element.getAttribute('href');
        if (href && href !== 'javascript:') {
          return false;
        }
      }
      const data = $target.data();
      method = actionData.actionFunction ?? method ?? null;
      if (!method) {
        if (!action) {
          throw new Error(`No action.`);
        }
        method = 'action' + Utils.upperCaseFirst(action);
      }

      // @todo Drop `data.handler` support in v10.1.
      handler = actionData.handler ?? handler ?? data.handler ?? null;
      let fired = false;
      if (handler) {
        event.preventDefault();
        event.stopPropagation();
        fired = true;
        Espo.loader.require(handler, Handler => {
          const handler = new Handler(view);
          handler[method].call(handler, data, event);
        });
      } else if (
      // @ts-ignore
      typeof view[method] === 'function') {
        // @ts-ignore
        if (view !== null && view !== void 0 && view.events[`click [data-action="${action}"]`]) {
          // Prevents from firing if a handler is already assigned. Important.
          // Does not prevent if handled from a nested view. @todo
          return false;
        }

        // @ts-ignore
        view[method].call(view, data, event);
        event.preventDefault();
        event.stopPropagation();
        fired = true;
      }
      if (!fired) {
        return false;
      }
      _processAfterActionDropdown($target);
      return true;
    },
    /**
     * Check action availability.
     *
     * @param helper A view helper.
     * @param item Definitions.
     */
    checkActionAvailability: function (helper, item) {
      const config = helper.config;
      if (item.configCheck) {
        let configCheck = item.configCheck;
        let opposite = false;
        if (configCheck.substring(0, 1) === '!') {
          opposite = true;
          configCheck = configCheck.substring(1);
        }
        let configCheckResult = config.getByPath(configCheck.split('.'));
        if (opposite) {
          configCheckResult = !configCheckResult;
        }
        if (!configCheckResult) {
          return false;
        }
      }
      return true;
    },
    /**
     * Check access to an action.
     *
     * @param acl An ACL manager.
     * @param [obj] A scope or a model.
     * @param item Definitions.
     * @param [isPrecise=false] To return `null` if not enough data is set in a model.
     *   E.g. the `teams` field is not yet loaded.
     */
    checkActionAccess: function (acl, obj, item) {
      let isPrecise = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
      let hasAccess = true;
      if (item.acl) {
        if (!item.aclScope) {
          if (obj) {
            if (typeof obj === 'string' || obj instanceof String) {
              hasAccess = acl.check(obj, item.acl);
            } else {
              hasAccess = acl.checkModel(obj, item.acl, isPrecise);
            }
          } else {
            hasAccess = acl.check(item.scope, item.acl);
          }
        } else {
          hasAccess = acl.check(item.aclScope, item.acl);
        }
      } else if (item.aclScope) {
        hasAccess = acl.checkScope(item.aclScope);
      }
      return hasAccess;
    },
    /**
     * Check access to an action.
     *
     * @param dataList List of definitions.
     * @param acl An ACL manager.
     * @param user A user.
     * @param [entity] A model.
     * @param [allowAllForAdmin=false] Allow all for an admin.
     */
    checkAccessDataList: function (dataList, acl, user) {
      let entity = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
      let allowAllForAdmin = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
      if (!dataList || !dataList.length) {
        return true;
      }
      for (const i in dataList) {
        const item = dataList[i];
        if (item.scope) {
          if (item.action) {
            if (!acl.check(item.scope, item.action)) {
              return false;
            }
          } else if (!acl.checkScope(item.scope)) {
            return false;
          }
        } else if (item.action && entity && !acl.check(entity, item.action)) {
          return false;
        }
        if (item.teamIdList && user && !(allowAllForAdmin && user.isAdmin())) {
          let inTeam = false;
          user.getLinkMultipleIdList('teams').forEach(teamId => {
            var _item$teamIdList;
            if ((_item$teamIdList = item.teamIdList) !== null && _item$teamIdList !== void 0 && _item$teamIdList.includes(teamId)) {
              inTeam = true;
            }
          });
          if (!inTeam) {
            return false;
          }
        }
        if (item.portalIdList) {
          if (user && !(allowAllForAdmin && user.isAdmin())) {
            let inPortal = false;
            user.getLinkMultipleIdList('portals').forEach(portalId => {
              var _item$portalIdList;
              if ((_item$portalIdList = item.portalIdList) !== null && _item$portalIdList !== void 0 && _item$portalIdList.includes(portalId)) {
                inPortal = true;
              }
            });
            if (!inPortal) {
              return false;
            }
          }
        }
        if (item.isPortalOnly) {
          if (user && !(allowAllForAdmin && user.isAdmin())) {
            if (!user.isPortal()) {
              return false;
            }
          }
        } else if (item.inPortalDisabled) {
          if (user && !(allowAllForAdmin && user.isAdmin())) {
            if (user.isPortal()) {
              return false;
            }
          }
        }
        if (item.isAdminOnly) {
          if (user) {
            if (!user.isAdmin()) {
              return false;
            }
          }
        }
      }
      return true;
    },
    /**
     * @internal
     */
    convert: function (string, p) {
      if (string === null) {
        return string;
      }
      let result = string;
      switch (p) {
        case 'c-h':
        case 'C-h':
          result = Utils.camelCaseToHyphen(string);
          break;
        case 'h-c':
          result = Utils.hyphenToCamelCase(string);
          break;
        case 'h-C':
          result = Utils.hyphenToUpperCamelCase(string);
          break;
      }
      return result;
    },
    /**
     * Is object.
     *
     * @param obj What to check.
     */
    isObject: function (obj) {
      if (obj === null) {
        return false;
      }
      return typeof obj === 'object';
    },
    /**
     * A shallow clone.
     *
     * @param obj What to clone.
     * @returns A clone.
     */
    clone: function (obj) {
      if (!Utils.isObject(obj)) {
        return obj;
      }
      return _underscore.default.isArray(obj) ? obj.slice() : _underscore.default.extend({}, obj);
    },
    /**
     * A deep clone.
     *
     * @param data What to clone.
     * @return A clone.
     */
    cloneDeep: function (data) {
      data = Utils.clone(data);
      if (Utils.isObject(data) || _underscore.default.isArray(data)) {
        for (const i in data) {
          data[i] = this.cloneDeep(data[i]);
        }
      }
      return data;
    },
    /**
     * Deep comparison.
     *
     * @param a1 An argument 1.
     * @param a2 An argument 2.
     */
    areEqual: function (a1, a2) {
      return _underscore.default.isEqual(a1, a2);
    },
    /**
     * Compose a class name.
     *
     * @param module A module.
     * @param name A name.
     * @param location A location.
     * @return
     */
    composeClassName: function (module, name) {
      let location = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
      if (module) {
        module = this.camelCaseToHyphen(module);
        name = this.camelCaseToHyphen(name).split('.').join('/');
        location = this.camelCaseToHyphen(location || '');
        return module + ':' + location + '/' + name;
      }
      name = this.camelCaseToHyphen(name).split('.').join('/');
      return location + '/' + name;
    },
    /**
     * Compose a view class name.
     *
     * @param name A name.
     */
    composeViewClassName: function (name) {
      if (name && name[0] === name[0].toLowerCase()) {
        return name;
      }
      if (name.indexOf(':') !== -1) {
        const arr = name.split(':');
        let modPart = arr[0];
        let namePart = arr[1];
        modPart = this.camelCaseToHyphen(modPart);
        namePart = this.camelCaseToHyphen(namePart).split('.').join('/');
        return `${modPart}:views/${namePart}`;
      }
      name = this.camelCaseToHyphen(name).split('.').join('/');
      return `views/${name}`;
    },
    /**
     * Convert a string from camelCase to hyphen and replace dots with hyphens.
     * Useful for setting to DOM attributes.
     *
     * @param string A string.
     */
    toDom: function (string) {
      return Utils.convert(string, 'c-h').split('.').join('-');
    },
    /**
     * Lower-case a first character.
     *
     * @param string A string.
     */
    lowerCaseFirst: function (string) {
      if (string === null) {
        return string;
      }
      return string.charAt(0).toLowerCase() + string.slice(1);
    },
    /**
     * Upper-case a first character.
     *
     * @param string A string.
     */
    upperCaseFirst: function (string) {
      if (string === null) {
        return string;
      }
      return string.charAt(0).toUpperCase() + string.slice(1);
    },
    /**
     * Hyphen to UpperCamelCase.
     *
     * @param string A string.
     */
    hyphenToUpperCamelCase: function (string) {
      if (string === null) {
        return string;
      }
      return this.upperCaseFirst(string.replace(/-([a-z])/g, function (g) {
        return g[1].toUpperCase();
      }));
    },
    /**
     * Hyphen to camelCase.
     *
     * @param string A string.
     */
    hyphenToCamelCase: function (string) {
      if (string === null) {
        return string;
      }
      return string.replace(/-([a-z])/g, function (g) {
        return g[1].toUpperCase();
      });
    },
    /**
     * CamelCase to hyphen.
     *
     * @param string A string.
     */
    camelCaseToHyphen: function (string) {
      if (string === null) {
        return string;
      }
      return string.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
    },
    /**
     * Trim an ending slash.
     *
     * @param string A string.
     */
    trimSlash: function (string) {
      if (string.slice(-1) === '/') {
        return string.slice(0, -1);
      }
      return string;
    },
    /**
     * Parse params in string URL options.
     *
     * @param string An URL part.
     */
    parseUrlOptionsParam: function (string) {
      if (!string) {
        return {};
      }
      if (string.indexOf('&') === -1 && string.indexOf('=') === -1) {
        return {};
      }
      const options = {};
      if (typeof string !== 'undefined') {
        string.split('&').forEach(item => {
          const p = item.split('=');
          options[p[0]] = true;
          if (p.length > 1) {
            options[p[0]] = p[1];
          }
        });
      }
      return options;
    },
    /**
     * Key a key from a key-event.
     *
     * @param event A key event.
     * @return {string}
     */
    getKeyFromKeyEvent: function (event) {
      let key = event.code;
      key = keyMap[key] ?? key;
      if (event.shiftKey) {
        key = 'Shift+' + key;
      }
      if (event.altKey) {
        key = 'Alt+' + key;
      }
      if (IS_MAC ? event.metaKey : event.ctrlKey) {
        key = 'Control+' + key;
      }
      return key;
    },
    /**
     * Check whether the pressed key is in a text input.
     *
     * @param event A key event.
     * @since 9.2.0
     */
    isKeyEventInTextInput: function (event) {
      if (!(event.target instanceof HTMLElement)) {
        return false;
      }
      if (event.target.tagName === 'TEXTAREA') {
        return true;
      }
      if (event.target instanceof HTMLInputElement) {
        if (event.target.type === 'radio' || event.target.type === 'checkbox') {
          return false;
        }
        return true;
      }
      if (event.target.classList.contains('note-editable')) {
        return true;
      }
      return false;
    },
    /**
     * Generate an ID. Not to be used by 3rd party code.
     *
     * @internal
     */
    generateId: function () {
      return Math.floor(Math.random() * 10000001).toString();
    },
    /**
     * Not to be used in custom code. Can be removed in future versions.
     *
     * @internal
     */
    obtainBaseUrl: function () {
      let baseUrl = window.location.origin + window.location.pathname;
      if (baseUrl.slice(-1) !== '/') {
        baseUrl = window.location.pathname.includes('.') ? baseUrl.slice(0, baseUrl.lastIndexOf('/')) + '/' : baseUrl + '/';
      }
      return baseUrl;
    }
  };
  const keyMap = {
    'NumpadEnter': 'Enter'
  };
  Espo.Utils = Utils;
  var _default = _exports.default = Utils;
  function _processAfterActionDropdown($target) {
    const $dropdown = $target.closest('.dropdown-menu');
    if (!$dropdown.length) {
      return;
    }
    const $dropdownToggle = $dropdown.parent().find('[data-toggle="dropdown"]');
    if (!$dropdownToggle.length) {
      return;
    }
    let isDisabled = false;
    if ($dropdownToggle.attr('disabled')) {
      isDisabled = true;
      $dropdownToggle.removeAttr('disabled').removeClass('disabled');
    }

    // noinspection JSUnresolvedReference
    // @ts-ignore
    $dropdownToggle.dropdown('toggle');
    $dropdownToggle.trigger('focus');
    if (isDisabled) {
      $dropdownToggle.attr('disabled', 'disabled').addClass('disabled');
    }
  }
});

define("language", ["exports", "bullbone"], function (_exports, _bullbone) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module language */

  /**
   * A language.
   *
   * @mixes Bull.Events
   */
  class Language {
    /** @private */
    url = 'I18n';

    /**
     * @class
     * @param {module:cache} [cache] A cache.
     */
    constructor(cache) {
      /**
       * @private
       * @type {module:cache|null}
       */
      this.cache = cache || null;

      /**
       * @private
       * @type {Object}
       */
      this.data = {};

      /**
       * A name.
       *
       * @type {string}
       */
      this.name = 'default';
    }

    /**
     * Whether an item is set in language data.
     *
     * @param {string} scope A scope.
     * @param {string} category A category.
     * @param {string} name An item name.
     * @returns {boolean}
     */
    has(name, category, scope) {
      if (scope in this.data) {
        if (category in this.data[scope]) {
          if (name in this.data[scope][category]) {
            return true;
          }
        }
      }
      return false;
    }

    /**
     * Get a value set in language data.
     *
     * @param {string} scope A scope.
     * @param {string} category A category.
     * @param {string} name An item name.
     * @returns {*}
     */
    get(scope, category, name) {
      if (scope in this.data) {
        if (category in this.data[scope]) {
          if (name in this.data[scope][category]) {
            return this.data[scope][category][name];
          }
        }
      }
      if (scope === 'Global') {
        return name;
      }
      return false;
    }

    /**
     * Translate a label.
     *
     * @param {string} name An item name.
     * @param {string|'messages'|'labels'|'fields'|'links'|'scopeNames'|'scopeNamesPlural'} [category='labels'] A category.
     * @param {string|null} [scope='Global'] A scope.
     * @returns {string}
     */
    translate(name, category, scope) {
      scope = scope || 'Global';
      category = category || 'labels';
      let res = this.get(scope, category, name);
      if (res === false && scope !== 'Global') {
        res = this.get('Global', category, name);
      }
      return res;
    }

    /**
     * Translation an option item value.
     *
     * @param {string} value An option value.
     * @param {string} field A field name.
     * @param {string|null} [scope='Global'] A scope.
     * @returns {string}
     */
    translateOption(value, field, scope) {
      const map = this.translate(field, 'options', scope) ?? {};
      return map[value] || value;
    }

    /**
     * @private
     */
    loadFromCache(loadDefault) {
      let name = this.name;
      if (loadDefault) {
        name = 'default';
      }
      if (this.cache) {
        const cached = this.cache.get('app', 'language-' + name);
        if (cached) {
          this.data = cached;
          return true;
        }
      }
      return null;
    }

    /**
     * Clear a language cache.
     */
    clearCache() {
      if (this.cache) {
        this.cache.clear('app', 'language-' + this.name);
      }
    }

    /**
     * @private
     */
    storeToCache(loadDefault) {
      let name = this.name;
      if (loadDefault) {
        name = 'default';
      }
      if (this.cache) {
        this.cache.set('app', 'language-' + name, this.data);
      }
    }

    /**
     * Load data from cache or backend (if not yet cached).
     *
     * @returns {Promise}
     */
    load() {
      return this._loadInternal();
    }

    /**
     * @private
     * @param {boolean} [disableCache=false]
     * @param {boolean} [loadDefault=false].
     * @returns {Promise}
     */
    _loadInternal(disableCache, loadDefault) {
      if (!disableCache && this.loadFromCache(loadDefault)) {
        this.trigger('sync');
        return Promise.resolve();
      }
      return this.fetch(loadDefault);
    }

    /**
     * Load default-language data from the backend.
     *
     * @returns {Promise}
     */
    loadDefault() {
      return this._loadInternal(false, true);
    }

    /**
     * Load data from the backend.
     *
     * @returns {Promise}
     */
    loadSkipCache() {
      return this._loadInternal(true);
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * Load default-language data from the backend.
     *
     * @returns {Promise}
     */
    loadDefaultSkipCache() {
      return this._loadInternal(true, true);
    }

    /**
     * @private
     * @param {boolean} loadDefault
     * @returns {Promise}
     */
    fetch(loadDefault) {
      return Espo.Ajax.getRequest(this.url, {
        default: loadDefault
      }).then(data => {
        this.data = data;
        this.storeToCache(loadDefault);
        this.trigger('sync');
      });
    }

    /**
     * Sort a field list by a translated name.
     *
     * @param {string} scope An entity type.
     * @param {string[]} fieldList A field list.
     * @returns {string[]}
     */
    sortFieldList(scope, fieldList) {
      return fieldList.sort((v1, v2) => {
        return this.translate(v1, 'fields', scope).localeCompare(this.translate(v2, 'fields', scope));
      });
    }

    /**
     * Sort an entity type list by a translated name.
     *
     * @param {string[]} entityList An entity type list.
     * @param {boolean} [plural=false] Use a plural label.
     * @returns {string[]}
     */
    sortEntityList(entityList, plural) {
      let category = 'scopeNames';
      if (plural) {
        category += 'Plural';
      }
      return entityList.sort((v1, v2) => {
        return this.translate(v1, category).localeCompare(this.translate(v2, category));
      });
    }

    /**
     * Get a value by a path.
     *
     * @param {string[]|string} path A path.
     * @returns {*}
     */
    translatePath(path) {
      if (typeof path === 'string' || path instanceof String) {
        path = path.split('.');
      }
      let pointer = this.data;
      path.forEach(key => {
        if (key in pointer) {
          pointer = pointer[key];
        }
      });
      return pointer;
    }

    /**
     * Do not use.
     *
     * @param {string} [scope]
     * @param {Record} [data]
     * @internal
     */
    setScopeData(scope, data) {
      this.data[scope] = data;
    }
  }
  Object.assign(Language.prototype, _bullbone.Events);
  var _default = _exports.default = Language;
});

define("di", ["exports"], function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.container = void 0;
  _exports.inject = inject;
  _exports.register = register;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  const registry = new Map();
  const container = _exports.container = new Map();

  /**
   * A DI container.
   */

  /**
   * A 'register' decorator.
   *
   * @param {*[]} argumentList Arguments.
   * @return {function(typeof Object)}
   */
  function register() {
    let argumentList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
    return function (classObject) {
      registry.set(classObject, argumentList);
    };
  }

  /**
   * An 'inject' decorator.
   *
   * @param {any} classObject A class.
   * @return {(function(*, Object): void)}
   */
  function inject(classObject) {
    /**
     * @param {{addInitializer: function(function())}} context
     */
    return function (value, context) {
      context.addInitializer(function () {
        let instance = container.get(classObject);
        if (!instance) {
          instance = Reflect.construct(classObject, registry.get(classObject));
          container.set(classObject, instance);
        }
        this[context.name] = instance;
      });
    };
  }
});

define("date-time", ["exports", "moment"], function (_exports, _moment) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _moment = _interopRequireDefault(_moment);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module date-time */

  /**
   * A date-time util.
   */
  class DateTime {
    constructor() {}

    /**
     * A system date format.
     *
     * @type {string}
     */
    internalDateFormat = 'YYYY-MM-DD';

    /**
     * A system date-time format.
     *
     * @type {string}
     */
    internalDateTimeFormat = 'YYYY-MM-DD HH:mm';

    /**
     * A system date-time format including seconds.
     *
     * @type {string}
     */
    internalDateTimeFullFormat = 'YYYY-MM-DD HH:mm:ss';

    /**
     * A date format for a current user.
     *
     * @type {string}
     */
    dateFormat = 'MM/DD/YYYY';

    /**
     * A time format for a current user.
     *
     * @type {string}
     */
    timeFormat = 'HH:mm';

    /**
     * A time zone for a current user.
     *
     * @type {string|null}
     */
    timeZone = null;

    /**
     * A system time zone.
     *
     * @type {string}
     */
    systemTimeZone;

    /**
     * A week start for a current user.
     *
     * @type {Number}
     */
    weekStart = 1;

    /** @private */
    readableDateFormatMap = {
      'DD.MM.YYYY': 'DD MMM',
      'DD/MM/YYYY': 'DD MMM'
    };

    /** @private */
    readableShortDateFormatMap = {
      'DD.MM.YYYY': 'D MMM',
      'DD/MM/YYYY': 'D MMM'
    };

    /**
     * Whether a time format has a meridian (am/pm).
     *
     * @returns {boolean}
     */
    hasMeridian() {
      return new RegExp('A', 'i').test(this.timeFormat);
    }

    /**
     * Get a date format.
     *
     * @returns {string}
     */
    getDateFormat() {
      return this.dateFormat;
    }

    /**
     * Get a time format.
     *
     * @returns {string}
     */
    getTimeFormat() {
      return this.timeFormat;
    }

    /**
     * Get a date-time format.
     *
     * @returns {string}
     */
    getDateTimeFormat() {
      return this.dateFormat + ' ' + this.timeFormat;
    }

    /**
     * Get a readable date format.
     *
     * @returns {string}
     */
    getReadableDateFormat() {
      return this.readableDateFormatMap[this.getDateFormat()] || 'MMM DD';
    }

    /**
     * Get a readable short date format.
     *
     * @returns {string}
     */
    getReadableShortDateFormat() {
      return this.readableShortDateFormatMap[this.getDateFormat()] || 'MMM D';
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * Get a readable date-time format.
     *
     * @returns {string}
     */
    getReadableDateTimeFormat() {
      return this.getReadableDateFormat() + ' ' + this.timeFormat;
    }

    /**
     * Get a readable short date-time format.
     *
     * @returns {string}
     */
    getReadableShortDateTimeFormat() {
      return this.getReadableShortDateFormat() + ' ' + this.timeFormat;
    }

    /**
     * Convert a date from a display representation to system.
     *
     * @param {string} string A date value.
     * @returns {string|-1} A system date value.
     */
    fromDisplayDate(string) {
      const m = (0, _moment.default)(string, this.dateFormat);
      if (!m.isValid()) {
        return -1;
      }
      return m.format(this.internalDateFormat);
    }

    /**
     * Get a time-zone.
     *
     * @returns {string}
     */
    getTimeZone() {
      return this.timeZone ? this.timeZone : 'UTC';
    }

    /**
     * Convert a date from system to a display representation.
     *
     * @param {string} string A system date value.
     * @returns {string} A display date value.
     */
    toDisplayDate(string) {
      if (!string || typeof string !== 'string') {
        return '';
      }
      const m = (0, _moment.default)(string, this.internalDateFormat);
      if (!m.isValid()) {
        return '';
      }
      return m.format(this.dateFormat);
    }

    /**
     * Convert a date-time from system to a display representation.
     *
     * @param {string} string A system date-time value.
     * @returns {string|-1} A display date-time value.
     */
    fromDisplay(string) {
      let m;
      if (this.timeZone) {
        m = _moment.default.tz(string, this.getDateTimeFormat(), this.timeZone).utc();
      } else {
        m = _moment.default.utc(string, this.getDateTimeFormat());
      }
      if (!m.isValid()) {
        return -1;
      }
      return m.format(this.internalDateTimeFormat) + ':00';
    }

    /**
     * Convert a date-time from system to a display representation.
     *
     * @param {string} string A system date value.
     * @returns {string} A display date-time value.
     */
    toDisplay(string) {
      if (!string) {
        return '';
      }
      return this.toMoment(string).format(this.getDateTimeFormat());
    }

    /**
     * Get a now moment.
     *
     * @returns {moment.Moment}
     */
    getNowMoment() {
      return (0, _moment.default)().tz(this.getTimeZone());
    }

    /**
     * Convert a system-formatted date to a moment.
     *
     * @param {string} string A date value in a system representation.
     * @returns {moment.Moment}
     * @internal
     */
    toMomentDate(string) {
      return _moment.default.tz(string, this.internalDateFormat, this.systemTimeZone);
    }

    /**
     * Convert a system-formatted date-time to a moment.
     *
     * @param {string} string A date-time value in a system representation.
     * @returns {moment.Moment}
     * @internal
     */
    toMoment(string) {
      let m = _moment.default.utc(string, this.internalDateTimeFullFormat);
      if (this.timeZone) {
        // noinspection JSUnresolvedReference
        m = m.tz(this.timeZone);
      }
      return m;
    }

    /**
     * Convert a date-time value from ISO to a system representation.
     *
     * @param {string} string
     * @returns {string} A date-time value in a system representation.
     */
    fromIso(string) {
      if (!string) {
        return '';
      }
      const m = (0, _moment.default)(string).utc();
      return m.format(this.internalDateTimeFormat);
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * Convert a date-time value from system to an ISO representation.
     *
     * @param string A date-time value in a system representation.
     * @returns {string} An ISO date-time value.
     */
    toIso(string) {
      return this.toMoment(string).format();
    }

    /**
     * Get a today date value in a system representation.
     *
     * @returns {string}
     */
    getToday() {
      return (0, _moment.default)().tz(this.getTimeZone()).format(this.internalDateFormat);
    }

    /**
     * Get a date-time value in a system representation, shifted from now.
     *
     * @param {Number} shift A number to shift by.
     * @param {'minutes'|'hours'|'days'|'weeks'|'months'|'years'} type A shift unit.
     * @param {Number} [multiplicity] A number of minutes a value will be aliquot to.
     * @returns {string} A date-time value in a system representation
     */
    getDateTimeShiftedFromNow(shift, type, multiplicity) {
      if (!multiplicity) {
        return _moment.default.utc().add(shift, type).format(this.internalDateTimeFormat);
      }
      let unix = (0, _moment.default)().unix();
      unix = unix - unix % (multiplicity * 60);
      return _moment.default.unix(unix).utc().add(shift, type).format(this.internalDateTimeFormat);
    }

    /**
     * Get a date value in a system representation, shifted from today.
     *
     * @param {Number} shift A number to shift by.
     * @param {'days'|'weeks'|'months'|'years'} type A shift unit.
     * @returns {string} A date value in a system representation
     */
    getDateShiftedFromToday(shift, type) {
      return _moment.default.tz(this.getTimeZone()).add(shift, type).format(this.internalDateFormat);
    }

    /**
     * Get a now date-time value in a system representation.
     *
     * @param {Number} [multiplicity] A number of minutes a value will be aliquot to.
     * @returns {string}
     */
    getNow(multiplicity) {
      if (!multiplicity) {
        return _moment.default.utc().format(this.internalDateTimeFormat);
      }
      let unix = (0, _moment.default)().unix();
      unix = unix - unix % (multiplicity * 60);
      return _moment.default.unix(unix).utc().format(this.internalDateTimeFormat);
    }

    /**
     * Set settings and preferences.
     *
     * @param {module:models/settings} settings Settings.
     * @param {module:models/preferences} preferences Preferences.
     * @internal
     */
    setSettingsAndPreferences(settings, preferences) {
      if (settings.has('dateFormat')) {
        this.dateFormat = settings.get('dateFormat');
      }
      if (settings.has('timeFormat')) {
        this.timeFormat = settings.get('timeFormat');
      }
      if (settings.has('timeZone')) {
        this.timeZone = settings.get('timeZone') || null;
        this.systemTimeZone = this.timeZone || 'UTC';
        if (this.timeZone === 'UTC') {
          this.timeZone = null;
        }
      }
      if (settings.has('weekStart')) {
        this.weekStart = settings.get('weekStart');
      }
      preferences.on('change', model => {
        if (model.has('dateFormat') && model.get('dateFormat')) {
          this.dateFormat = model.get('dateFormat');
        }
        if (model.has('timeFormat') && model.get('timeFormat')) {
          this.timeFormat = model.get('timeFormat');
        }
        if (model.has('timeZone') && model.get('timeZone')) {
          this.timeZone = model.get('timeZone');
        }
        if (model.has('weekStart') && model.get('weekStart') !== -1) {
          this.weekStart = model.get('weekStart');
        }
        if (this.timeZone === 'UTC') {
          this.timeZone = null;
        }
      });
    }

    /**
     * Set a language.
     *
     * @param {module:language} language A language.
     * @internal
     */
    setLanguage(language) {
      _moment.default.updateLocale('en', {
        months: language.translatePath(['Global', 'lists', 'monthNames']),
        monthsShort: language.translatePath(['Global', 'lists', 'monthNamesShort']),
        weekdays: language.translatePath(['Global', 'lists', 'dayNames']),
        weekdaysShort: language.translatePath(['Global', 'lists', 'dayNamesShort']),
        weekdaysMin: language.translatePath(['Global', 'lists', 'dayNamesMin'])
      });
      _moment.default.locale('en');
    }
  }
  var _default = _exports.default = DateTime;
});

define("util/ajax", ["exports"], function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.Xhr = _exports.AjaxPromise = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class AjaxPromise extends Promise {
    /**
     * @type {XMLHttpRequest|null}
     * @internal
     */
    xhr = null;
    isAborted = false;

    /**
     * Abort the request.
     */
    abort() {
      this.isAborted = true;
      if (this.xhr) {
        this.xhr.abort();
      }
    }

    /**
     * Get a ready state.
     *
     */
    getReadyState() {
      if (!this.xhr) {
        return 0;
      }
      return this.xhr.readyState || 0;
    }

    /**
     * Get a status code
     *
     * @return {Number}
     */
    getStatus() {
      if (!this.xhr) {
        return 0;
      }
      return this.xhr.status;
    }
  }
  _exports.AjaxPromise = AjaxPromise;
  class Xhr extends XMLHttpRequest {
    /**
     * To be set in an error handler to bypass default handling.
     */
    errorIsHandled = false;
  }
  _exports.Xhr = Xhr;
});

define("ajax", ["exports", "jquery", "utils", "util/ajax"], function (_exports, _jquery, _utils, _ajax) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _jquery = _interopRequireDefault(_jquery);
  _utils = _interopRequireDefault(_utils);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module ajax */

  let isConfigured = false;
  let defaultTimeout;
  let apiUrl;
  let beforeSend;
  let onSuccess;
  let onError;
  let onTimeout;
  let onOffline;

  /**
   * Options.
   */

  const baseUrl = _utils.default.obtainBaseUrl();

  // noinspection JSUnusedGlobalSymbols
  /**
   * Functions for API HTTP requests.
   */
  const Ajax = {
    /**
     * Request.
     *
     * @param url An URL.
     * @param method An HTTP method.
     * @param {*} [data] Data.
     * @param [options] Options.
     * @returns {AjaxPromise<any>}
     */
    request: function (url, method) {
      let data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
      let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
      const timeout = 'timeout' in options ? options.timeout : defaultTimeout;
      const contentType = options.contentType || 'application/json';
      let body;
      if (options.data && !data) {
        data = options.data;
      }
      if (apiUrl) {
        url = _utils.default.trimSlash(apiUrl) + '/' + url;
      }
      if (!['GET', 'OPTIONS'].includes(method) && data) {
        body = data;
        if (contentType === 'application/json' && typeof data !== 'string') {
          body = JSON.stringify(data);
        }
      }
      if (method === 'GET' && data) {
        const part = _jquery.default.param(data);
        url.includes('?') ? url += '&' : url += '?';
        url += part;
      }
      const urlObj = new URL(baseUrl + url);
      const xhr = new _ajax.Xhr();
      if (timeout != null) {
        xhr.timeout = timeout;
      }
      xhr.open(method, urlObj);
      xhr.setRequestHeader('Content-Type', contentType);
      if (options.headers) {
        for (const key in options.headers) {
          xhr.setRequestHeader(key, options.headers[key]);
        }
      }
      if (beforeSend) {
        beforeSend(xhr, options);
      }
      const promiseWrapper = {};
      const promise = new _ajax.AjaxPromise((resolve, reject) => {
        const onErrorGeneral = function () {
          let isTimeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
          if (options.error) {
            options.error(xhr, options);
          }

          // @ts-ignore
          reject(xhr, options);
          if (isTimeout) {
            if (onTimeout) {
              onTimeout(xhr, options);
            }
            return;
          }
          if (xhr.status === 0 && !navigator.onLine && onOffline) {
            onOffline();
            return;
          }
          if (onError) {
            onError(xhr, options);
          }
        };
        xhr.ontimeout = () => onErrorGeneral(true);
        xhr.onerror = () => onErrorGeneral();
        xhr.onload = () => {
          if (xhr.status >= 400) {
            onErrorGeneral();
            return;
          }
          let response = xhr.responseText;
          if ((options.dataType || 'json') === 'json') {
            try {
              response = JSON.parse(xhr.responseText);
            } catch (e) {
              console.error('Could not parse API response.');
              onErrorGeneral();
            }
          }
          if (options.success) {
            options.success(response);
          }
          onSuccess(xhr, options);
          if (options.resolveWithXhr) {
            response = xhr;
          }
          resolve(response);
        };
        xhr.send(body);
        if (promiseWrapper.promise) {
          promiseWrapper.promise.xhr = xhr;
          return;
        }
        promiseWrapper.xhr = xhr;
      });
      promiseWrapper.promise = promise;
      promise.xhr = promise.xhr ?? promiseWrapper.xhr ?? null;
      return promise;
    },
    /**
     * POST request.
     *
     * @param {string} url An URL.
     * @param [data] Data.
     * @param [options] Options.
     */
    postRequest: function (url, data, options) {
      if (data) {
        data = JSON.stringify(data);
      }
      return Ajax.request(url, 'POST', data, options);
    },
    /**
     * PATCH request.
     *
     * @param url An URL.
     * @param [data] Data.
     * @param [options] Options.
     */
    patchRequest: function (url) {
      let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
      let options = arguments.length > 2 ? arguments[2] : undefined;
      if (data) {
        data = JSON.stringify(data);
      }
      return Ajax.request(url, 'PATCH', data, options);
    },
    /**
     * PUT request.
     *
     * @param url An URL.
     * @param [data] Data.
     * @param [options] Options.
     */
    putRequest: function (url) {
      let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
      let options = arguments.length > 2 ? arguments[2] : undefined;
      if (data) {
        data = JSON.stringify(data);
      }
      return Ajax.request(url, 'PUT', data, options);
    },
    /**
     * DELETE request.
     *
     * @param url An URL.
     * @param [data] Data.
     * @param [options] Options.
     */
    deleteRequest: function (url, data, options) {
      if (data) {
        data = JSON.stringify(data);
      }
      return Ajax.request(url, 'DELETE', data, options);
    },
    /**
     * GET request.
     *
     * @param url An URL.
     * @param [data] Data.
     * @param [options] Options.
     */
    getRequest: function (url) {
      let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
      let options = arguments.length > 2 ? arguments[2] : undefined;
      return Ajax.request(url, 'GET', data, options);
    },
    /**
     * @internal
     * @param options Options.
     */
    configure: function (options) {
      if (isConfigured) {
        throw new Error("Ajax is already configured.");
      }
      apiUrl = options.apiUrl;
      defaultTimeout = options.timeout;
      beforeSend = options.beforeSend;
      onSuccess = options.onSuccess;
      onError = options.onError;
      onTimeout = options.onTimeout;
      onOffline = options.onOffline;
      isConfigured = true;
    }
  };

  // @ts-ignore
  Espo.Ajax = Ajax;
  var _default = _exports.default = Ajax;
});

define("util/event", ["exports"], function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.onModelChange = onModelChange;
  _exports.onSync = onSync;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * @internal
   * Listen to model attribute change.
   *
   * @param {{
   *     owner: import('view').default | import('model').default | import('collection').default,
   *     target: import('model').default,
   *     attributes?: string[],
   *     once?: boolean,
   *     callback: function({
   *         ui: boolean|null,
   *         action: string|'ui'|'save'|'fetch'|'cancel-edit'|null,
   *         fromView: import('views/fields/base').default,
   *     }),
   * }} params
   * @return {{stop: function()}}
   * @since 10.0.0
   */
  function onModelChange(params) {
    const owner = params.owner;
    const target = params.target;
    const callback = params.callback;
    let event = 'change';
    if (params.attributes) {
      event = params.attributes.map(it => `change:${it}`).join(' ');
    }

    /**
     * @param {Record} o
     */
    function callCallback(o) {
      callback({
        ui: o.ui ?? null,
        action: o.action ?? null,
        fromView: o.fromView ?? null
      });
    }
    const wrappedCallback = params.attributes ? (m, v, o) => callCallback(o) : (m, o) => callCallback(o);
    function stop() {
      owner.stopListening(target, event, wrappedCallback);
    }
    const output = {
      stop
    };
    if (params.once) {
      owner.listenToOnce(target, event, wrappedCallback);
      return output;
    }
    owner.listenTo(target, event, wrappedCallback);
    return output;
  }

  /**
   * @internal
   * Listen to sync.
   *
   * @param {{
   *     owner: import('view').default | import('model').default | import('collection').default,
   *     target: import('model').default | import('collection').default,
   *     once?: boolean,
   *     callback: function({
   *         action: 'fetch'|'save'|'destroy'|null,
   *         response: *,
   *     }),
   * }} params
   * @return {{stop: function()}}
   * @since 10.0.0
   */
  function onSync(params) {
    const owner = params.owner;
    const target = params.target;
    const callback = params.callback;
    const event = 'sync';

    /**
     * @param {Record} o
     * @param {*} response
     */
    function wrappedCallback(o, response) {
      callback({
        action: o.action ?? null,
        response: response
      });
    }
    function stop() {
      owner.stopListening(target, event, wrappedCallback);
    }
    const output = {
      stop
    };
    if (params.once) {
      owner.listenToOnce(target, event, wrappedCallback);
      return output;
    }
    owner.listenTo(target, event, wrappedCallback);
    return output;
  }
});

define("helpers/model/default-value-provider", ["exports", "date-time", "di"], function (_exports, _dateTime, _di) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _dateTime = _interopRequireDefault(_dateTime);
  var _staticBlock;
  let _init_dateTime, _init_extra_dateTime;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  const nowExpression = /return this\.dateTime\.getNow\(([0-9]+)\);/;
  const shiftTodayExpression = /return this\.dateTime\.getDateShiftedFromToday\(([0-9]+), '([a-z]+)'\);/;
  const shiftNowExpression = /return this\.dateTime\.getDateTimeShiftedFromNow\(([0-9]+), '([a-z]+)', ([0-9]+)\);/;
  class DefaultValueProvider {
    constructor() {
      _init_extra_dateTime(this);
    }
    /**
     * @type {DateTime}
     */
    dateTime = _init_dateTime(this);

    /**
     * Get a value.
     *
     * @param {string} key
     * @return {*}
     */
    get(key) {
      if (key === "return this.dateTime.getToday();") {
        return this.dateTime.getToday();
      }
      const matchNow = key.match(nowExpression);
      if (matchNow) {
        const multiplicity = parseInt(matchNow[1]);
        return this.dateTime.getNow(multiplicity);
      }
      const matchTodayShift = key.match(shiftTodayExpression);
      if (matchTodayShift) {
        const shift = parseInt(matchTodayShift[1]);
        const unit = matchTodayShift[2];
        return this.dateTime.getDateShiftedFromToday(shift, unit);
      }
      const matchNowShift = key.match(shiftNowExpression);
      if (matchNowShift) {
        const shift = parseInt(matchNowShift[1]);
        const unit = matchNowShift[2];
        const multiplicity = parseInt(matchNowShift[3]);
        return this.dateTime.getDateTimeShiftedFromNow(shift, unit, multiplicity);
      }
      return undefined;
    }
    static #_ = _staticBlock = () => [_init_dateTime, _init_extra_dateTime] = _applyDecs(this, [], [[(0, _di.inject)(_dateTime.default), 0, "dateTime"]]).e;
  }
  _exports.default = DefaultValueProvider;
  _staticBlock();
});

define("components/controls", ["exports", "language", "di", "bullbone"], function (_exports, _language, _di, _bullbone) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.DropdownItemComponent = _exports.ButtonComponent = void 0;
  _language = _interopRequireDefault(_language);
  var _staticBlock, _staticBlock2;
  let _init_language, _init_extra_language, _init_language2, _init_extra_language2;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  /**
   * @internal
   * @experimental
   * @since 10.0.0
   */
  class ButtonComponent {
    language = _init_language(this);
    constructor(options) {
      _init_extra_language(this);
      this.options = options;
    }
    node() {
      const classes = {
        'btn': true,
        'disabled': this.options.disabled === true,
        'hidden': this.options.hidden === true,
        'action': this.options.action != null
      };
      const style = this.options.style ?? 'default';
      classes['btn-' + style] = true;
      if (this.options.className) {
        this.options.className.split(' ').forEach(it => classes[it.trim()] = true);
      }
      const tag = this.options.link ? 'a' : 'button';
      const attrs = {};
      if (this.options.link) {
        attrs.href = this.options.link;
      } else {
        attrs.type = 'button';
      }
      if (this.options.disabled) {
        attrs.disabled = 'disabled';
      }
      if (this.options.title) {
        attrs.title = this.options.title;
      }
      if (!this.options.title && this.options.titleTranslation) {
        attrs.title = this.language.translatePath(this.options.titleTranslation);
      }
      const {
        content,
        props
      } = prepareItemContent(this.options, this.language);
      const on = {};
      if (this.options.onClick) {
        on.click = event => this.options.onClick(event);
      }
      return (0, _bullbone.h)(tag, {
        key: this.options.name ?? undefined,
        class: classes,
        attrs: attrs,
        dataset: {
          ...this.options.data,
          name: this.options.name ?? undefined,
          action: this.options.action ?? undefined
        },
        props,
        on: on
      }, content);
    }
    static #_ = _staticBlock = () => [_init_language, _init_extra_language] = _applyDecs(this, [], [[(0, _di.inject)(_language.default), 0, "language"]]).e;
  }

  /**
   * @internal
   * @experimental
   * @since 10.0.0
   */
  _exports.ButtonComponent = ButtonComponent;
  _staticBlock();
  class DropdownItemComponent {
    language = _init_language2(this);
    constructor(options) {
      _init_extra_language2(this);
      this.options = options;
    }
    node() {
      const classes = {
        'disabled': this.options.disabled === true,
        'hidden': this.options.hidden === true,
        'action': this.options.action != null
      };
      if (this.options.className) {
        this.options.className.split(' ').forEach(it => classes[it.trim()] = true);
      }
      const attrs = {
        tabindex: 0
      };
      if (this.options.link) {
        attrs.href = this.options.link;
      }
      if (this.options.disabled) {
        attrs.disabled = 'disabled';
      }
      if (this.options.title) {
        attrs.title = this.options.title;
      }
      if (!this.options.title && this.options.titleTranslation) {
        attrs.title = this.language.translatePath(this.options.titleTranslation);
      }
      const {
        content,
        props
      } = prepareItemContent(this.options, this.language, true);
      if (!this.options.link) {
        attrs.role = 'button';
      }
      const on = {};
      if (this.options.onClick) {
        on.click = event => this.options.onClick(event);
      }
      const a = (0, _bullbone.h)('a', {
        class: classes,
        attrs: attrs,
        dataset: {
          ...this.options.data,
          name: this.options.name ?? undefined,
          action: this.options.action ?? undefined
        },
        props: props,
        on: on
      }, content);
      return (0, _bullbone.h)('li', {
        key: this.options.name ?? undefined,
        class: {
          'disabled': this.options.disabled === true,
          'hidden': this.options.hidden === true
        }
      }, a);
    }
    static #_ = _staticBlock2 = () => [_init_language2, _init_extra_language2] = _applyDecs(this, [], [[(0, _di.inject)(_language.default), 0, "language"]]).e;
  }
  _exports.DropdownItemComponent = DropdownItemComponent;
  _staticBlock2();
  function prepareItemContent(options, language) {
    let isDropdownItem = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
    let content = null;
    const props = {};
    if (options.html) {
      props.innerHTML = options.html;
      if (options.iconHtml) {
        props.innerHTML = options.iconHtml + props.innerHTML;
      }
    } else {
      const label = options.label;
      let text = options.text ?? (options.labelTranslation ? language.translatePath(options.labelTranslation) : language.translate(label ?? '', 'labels', options.scope));
      let icon = null;
      if (options.iconHtml) {
        const div = document.createElement('div');
        div.innerHTML = options.iconHtml;
        icon = div.firstElementChild ? (0, _bullbone.toVNode)(div.firstElementChild) : null;
      } else if (options.iconClass) {
        icon = (0, _bullbone.h)('span', {
          props: {
            className: options.iconClass + ' item-icon'
          }
        });
      }
      if (isDropdownItem) {
        text = (0, _bullbone.h)('span', {
          props: {
            className: 'item-text'
          }
        }, text);
      } else {
        if (icon && text) {
          text = (0, _bullbone.h)('span', text);
        }
      }
      content = icon ? [icon, text] : text;
    }
    return {
      content,
      props
    };
  }
});

define("model", ["exports", "bullbone", "underscore", "helpers/model/default-value-provider", "util/event", "util/ajax", "ajax"], function (_exports, _bullbone, _underscore, _defaultValueProvider, _event, _ajax, _ajax2) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _underscore = _interopRequireDefault(_underscore);
  _defaultValueProvider = _interopRequireDefault(_defaultValueProvider);
  _ajax2 = _interopRequireDefault(_ajax2);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module model */

  /**
   * When attributes have changed.
   *
   * @event Model#change
   * @param {Model} model A model.
   * @param {Record.<string, *> & {action?: string|'ui'|'save'|'fetch'|'cancel-edit'}} o Options.
   */

  /**
   * On sync with backend.
   *
   * @event Model#sync
   * @param {Model} model A model.
   * @param {Object} response Response from backend.
   * @param {Record.<string, *> & {action?: 'fetch'|'save'|'destroy'}} o Options.
   */

  /**
   * @property link A link.
   * @property model A model.
   */

  /**
   * Definitions.
   */

  /**
   * Field definitions.
   */

  /**
   * A model.
   */
  class Model {
    /**
     * A root URL. An ID will be appended. Used for syncing with backend.
     */
    urlRoot = null;

    /**
     * A URL. If not empty, then will be used for syncing instead of `urlRoot`.
     */
    url = null;

    /**
     * A name.
     */
    name = null;

    /**
     * An entity type.
     */
    entityType = null;

    /**
     * A last request promise.
     */
    lastSyncPromise = null;

    /**
     * An ID attribute.
     */

    /**
     * A record ID.
     */

    /**
     * An instance ID.
     */

    /**
     * Attribute values.
     */

    /**
     * A parent collection the model belongs to.
     */

    /**
     * Definitions.
     * @internal
     */

    constructor(attributes, options) {
      options = options || {};
      this.idAttribute = 'id';
      this.id = null;
      this.cid = _underscore.default.uniqueId('c');
      this.attributes = {};
      if (options.collection) {
        this.collection = options.collection;
      }
      attributes = attributes ?? {};
      this.setMultiple(attributes);
      this.defs = options.defs || {};
      if (!this.defs.fields) {
        this.defs.fields = {};
      }
      if (options.entityType) {
        this.entityType = options.entityType;
        this.name = options.entityType;
        this.urlRoot = options.entityType;
      }
      this.urlRoot = options.urlRoot || this.urlRoot;
      this.url = options.url || this.url;
      this.changed = {};
      this._previousAttributes = null;
    }

    /**
     * @param [method] HTTP method.
     * @param {Model} model
     * @param [options] Options.
     */
    sync(method, model, options) {
      const methodMap = {
        'create': 'POST',
        'update': 'PUT',
        'patch': 'PUT',
        'delete': 'DELETE',
        'read': 'GET'
      };
      if (!(method in methodMap)) {
        throw new Error(`Bad request method '${method}'.`);
      }
      const httpMethod = methodMap[method];
      options = options || {};
      const url = this.composeSyncUrl();
      if (!url) {
        throw new Error(`No 'url'.`);
      }
      const data = model && ['create', 'update', 'patch'].includes(method) ? options.attributes || model.getClonedAttributes() : null;
      const error = options.error;
      options.error = (xhr, textStatus, errorThrown) => {
        options.textStatus = textStatus;
        options.errorThrown = errorThrown;
        if (error) {
          error.call(options.context, xhr, textStatus, errorThrown);
        }
      };
      const stringData = data ? JSON.stringify(data) : null;
      const ajaxPromise = !options.bypassRequest ? _ajax2.default.request(url, httpMethod, stringData, options) : Promise.resolve();
      if (ajaxPromise instanceof _ajax.AjaxPromise) {
        options.xhr = ajaxPromise.xhr;
      }
      model.trigger('request', url, httpMethod, data, ajaxPromise, options);
      return ajaxPromise;
    }

    // noinspection JSValidateJSDoc
    /**
     * Set an attribute value.
     *
     * @param attribute An attribute name or a {key => value} object.
     * @param {*} [value] A value or options if the first argument is an object.
     * @param [options] Options. `silent` won't trigger a `change` event.
     * @returns {this}
     * @fires Model#change Unless `{silent: true}`.
     */
    set(attribute, value, options) {
      if (attribute == null) {
        return this;
      }
      let attributes;
      if (typeof attribute === 'object') {
        return this.setMultiple(attribute, value);
      }
      attributes = {};
      attributes[attribute] = value;
      return this.setMultiple(attributes, options);
    }

    // noinspection JSValidateJSDoc
    /**
     * Set attributes values.
     *
     * @param attributes
     * @param [options] Options. `silent` won't trigger a `change` event.
     *     `sync` can be used to emulate syncing.
     * @fires Model#change Unless `{silent: true}`.
     */
    setMultiple(attributes, options) {
      return this._setMultipleInternal(attributes, options);
    }

    // noinspection JSValidateJSDoc
    /**
     * Set attributes values.
     *
     * @param attributes
     * @param [options]
     * @fires Model#change Unless `{silent: true}`.
     * @copyright Credits to Backbone.js.
     */
    _setMultipleInternal(attributes, options) {
      if (this.idAttribute in attributes) {
        this.id = attributes[this.idAttribute];
      }
      options = options || {};
      if (options.ui && !options.action) {
        options.action = 'ui';
      }
      if (!options.ui && options.action === 'ui') {
        options.ui = true;
      }
      const changes = [];
      const changing = this._changing;
      this._changing = true;
      if (!changing) {
        this._previousAttributes = _underscore.default.clone(this.attributes);
        this.changed = {};
      }
      const current = this.attributes;
      const changed = this.changed;
      const previous = this._previousAttributes;
      for (const attribute in attributes) {
        const value = attributes[attribute];
        if (!_underscore.default.isEqual(current[attribute], value)) {
          changes.push(attribute);
        }
        if (!_underscore.default.isEqual(previous[attribute], value)) {
          changed[attribute] = value;
        } else {
          delete changed[attribute];
        }
        options.unset ? delete current[attribute] : current[attribute] = value;
      }
      if (!options.silent) {
        if (changes.length) {
          this._pending = options;
        }
        for (let i = 0; i < changes.length; i++) {
          this.trigger('change:' + changes[i], this, current[changes[i]], options);
        }
      }
      if (options.sync) {
        if (this.collection) {
          const modelSyncOptions = {
            ...options,
            action: 'set'
          };
          this.collection.trigger('model-sync', this, modelSyncOptions);
        }
      }
      if (changing) {
        return this;
      }
      if (!options.silent) {
        // Changes can be recursively nested within `change` events.
        while (this._pending) {
          options = this._pending;
          this._pending = false;
          this.trigger('change', this, options);
        }
      }
      this._pending = false;
      this._changing = false;
      return this;
    }

    /**
     * Unset an attribute.
     *
     * @param attribute An attribute.
     * @param [options] Options.
     * @return {Model}
     */
    unset(attribute, options) {
      options = {
        ...options,
        unset: true
      };
      const attributes = {};
      attributes[attribute] = null;
      return this._setMultipleInternal(attributes, options);
    }

    /**
     * Get an attribute value.
     *
     * @param attribute An attribute name.
     */
    get(attribute) {
      if (attribute === this.idAttribute && this.id) {
        return this.id;
      }
      return this.attributes[attribute];
    }

    /**
     * Whether attribute is set.
     *
     * @param {string} attribute An attribute name.
     * @returns {boolean}
     */
    has(attribute) {
      const value = this.get(attribute);
      return typeof value !== 'undefined';
    }

    /**
     * Removes all attributes from the model.
     * Fires a `change` event unless `silent` is passed as an option.
     *
     * @param {{silent?: boolean} & Object.<string, *>} [options] Options.
     */
    clear(options) {
      const attributes = {};
      for (const key in this.attributes) {
        attributes[key] = void 0;
      }
      options = {
        ...options,
        unset: true
      };
      return this.setMultiple(attributes, options);
    }

    /**
     * Whether is new.
     */
    isNew() {
      return !this.id;
    }

    /**
     * Whether an attribute changed. To be called only within a 'change' event handler.
     *
     * @param [attribute]
     */
    hasChanged(attribute) {
      if (!attribute) {
        return !_underscore.default.isEmpty(this.changed);
      }
      return _underscore.default.has(this.changed, attribute);
    }

    /**
     * Get changed attribute values. To be called only within a 'change' event handler.
     */
    changedAttributes() {
      return this.hasChanged() ? _underscore.default.clone(this.changed) : {};
    }

    /**
     * Get previous attributes. To be called only within a 'change' event handler.
     */
    previousAttributes() {
      return _underscore.default.clone(this._previousAttributes ?? {});
    }

    /**
     * Get a previous attribute value. To be called only within a 'change' event handler.
     *
     * @param attribute
     * @return {*}
     */
    previous(attribute) {
      if (!this._previousAttributes) {
        return null;
      }
      return this._previousAttributes[attribute];
    }

    // noinspection JSValidateJSDoc
    /**
     * Fetch values from the backend.
     *
     * @param [options] Options.
     * @fires Model#sync
     */
    fetch(options) {
      options = {
        ...options
      };
      options.action = 'fetch';

      // For bc.
      const success = options.success;
      options.success = response => {
        const serverAttributes = this.prepareAttributes(response, options);
        this.setMultiple(serverAttributes, options);
        if (success) {
          success.call(options.context, this, response, options);
        }
        this.trigger('sync', this, response, options);
        if (this.collection) {
          this.collection.trigger('model-sync', this, options);
        }
      };
      this.lastSyncPromise = this.sync('read', this, options);
      return this.lastSyncPromise;
    }

    // noinspection JSValidateJSDoc
    /**
     * Save values to the backend.
     *
     * @param [attributes] Attribute values.
     * @param [options] Options. Use `patch` to send a PATCH request. If `wait`, attributes will be
     *     set only after the request is completed.
     * @fires Model#sync
     * @copyright Credits to Backbone.js.
     */
    save(attributes, options) {
      options = {
        ...options
      };
      if (attributes && !options.wait) {
        this.setMultiple(attributes, options);
      }
      const success = options.success;
      const setAttributes = this.attributes;
      options.success = response => {
        this.attributes = setAttributes;
        let responseAttributes = this.prepareAttributes(response, options);
        if (options.wait) {
          responseAttributes = {
            ...setAttributes,
            ...responseAttributes
          };
        }
        options.action = 'save';
        if (responseAttributes) {
          this.setMultiple(responseAttributes, options);
        }
        if (success) {
          success.call(options.context, this, response, options);
        }
        this.trigger('sync', this, response, options);
        if (this.collection) {
          this.collection.trigger('model-sync', this, options);
        }
      };
      const error = options.error;
      options.error = response => {
        if (error) {
          error.call(options.context, this, response, options);
        }
        this.trigger('error', this, response, options);
      };
      if (attributes && options.wait) {
        // Set temporary attributes to properly find new IDs.
        this.attributes = {
          ...setAttributes,
          ...attributes
        };
      }
      const method = this.isNew() ? 'create' : options.patch ? 'patch' : 'update';
      if (method === 'patch') {
        options.attributes = attributes;
      }
      const result = this.sync(method, this, options);
      this.attributes = setAttributes;
      return result;
    }

    // noinspection JSValidateJSDoc
    /**
     * Delete the record in the backend.
     *
     * @param [options] Options. If `wait`, unsubscribing and
     *     removal from the collection will wait for a successful response.
     * @fires Model#sync
     * @copyright Credits to Backbone.js.
     */
    destroy() {
      let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      options = {
        ...options
      };
      const success = options.success;
      const collection = this.collection;
      const destroy = () => {
        this.stopListening();
        this.trigger('destroy', this, collection, options);
      };
      options.success = response => {
        if (options.wait) {
          destroy();
        }
        if (success) {
          success.call(options.context, this, response, options);
        }
        if (!this.isNew()) {
          const syncOptions = {
            ...options
          };
          syncOptions.action = 'destroy';
          this.trigger('sync', this, response, syncOptions);
          if (collection) {
            collection.trigger('model-sync', this, syncOptions);
          }
        }
      };
      if (this.isNew()) {
        _underscore.default.defer(options.success);
        if (!options.wait) {
          destroy();
        }
        return Promise.resolve();
      }
      const error = options.error;
      options.error = response => {
        if (error) {
          error.call(options.context, this, response, options);
        }
        this.trigger('error', this, response, options);
      };
      const result = this.sync('delete', this, options);
      if (!options.wait) {
        destroy();
      }
      return result;
    }

    /**
     * Compose a URL for syncing.
     */
    composeSyncUrl() {
      if (this.url) {
        return this.url;
      }
      let urlRoot = this.urlRoot;
      if (!urlRoot && this.collection) {
        urlRoot = this.collection.urlRoot;
      }
      if (!urlRoot) {
        throw new Error("No urlRoot.");
      }
      if (this.isNew()) {
        return urlRoot;
      }
      const id = this.get(this.idAttribute);
      return urlRoot.replace(/[^\/]$/, '$&/') + encodeURIComponent(id);
    }

    // noinspection JSUnusedLocalSymbols
    /**
     * Prepare attributes.
     *
     * @param {*} response A response from the backend.
     * @param {Object.<string, *>} options Options.
     * @return {*} Attributes.
     * @internal
     */
    prepareAttributes(response, options) {
      // noinspection BadExpressionStatementJS
      options;
      return response;
    }

    /**
     * Clone.
     *
     * @return {Model}
     */
    clone() {
      // @todo Revise.
      // @ts-ignore
      return new this.constructor(Espo.Utils.cloneDeep(this.attributes), {
        entityType: this.entityType,
        urlRoot: this.urlRoot,
        url: this.url,
        defs: this.defs
      });
    }

    /**
     * Set defs.
     *
     * @param defs Definitions.
     */
    setDefs(defs) {
      this.defs = defs || {};
      if (!this.defs.fields) {
        this.defs.fields = {};
      }
    }

    /**
     * Get cloned attribute values.
     */
    getClonedAttributes() {
      return Espo.Utils.cloneDeep(this.attributes);
    }

    /**
     * Populate default values.
     */
    populateDefaults() {
      let defaultHash = {};
      const fieldDefs = this.defs.fields;
      for (const field in fieldDefs) {
        if (this.hasFieldParam(field, 'default')) {
          try {
            defaultHash[field] = this.parseDefaultValue(this.getFieldParam(field, 'default'));
          } catch (e) {
            console.error(e);
          }
        }
        const defaultAttributes = this.getFieldParam(field, 'defaultAttributes');
        if (defaultAttributes) {
          for (const attribute in defaultAttributes) {
            defaultHash[attribute] = defaultAttributes[attribute];
          }
        }
      }
      defaultHash = Espo.Utils.cloneDeep(defaultHash);
      for (const attr in defaultHash) {
        if (this.has(attr)) {
          delete defaultHash[attr];
        }
      }
      this.setMultiple(defaultHash, {
        silent: true
      });
    }

    /**
     * @private
     * @param {*} defaultValue
     * @returns {*}
     */
    parseDefaultValue(defaultValue) {
      if (typeof defaultValue === 'string' && defaultValue.indexOf('javascript:') === 0) {
        const code = defaultValue.substring(11).trim();
        const provider = new _defaultValueProvider.default();
        defaultValue = provider.get(code);
      }
      return defaultValue;
    }

    /**
     * Get a link multiple column value.
     *
     * @param {string} field
     * @param {string} column
     * @param {string} id
     * @returns {*}
     */
    getLinkMultipleColumn(field, column, id) {
      return ((this.get(field + 'Columns') || {})[id] || {})[column];
    }

    /**
     * Set relate data (when creating a related record).
     */
    setRelate(data) {
      const setRelate = options => {
        var _this$defs$links;
        const link = options.link;
        const model = /** @type {Model} */options.model;
        if (!link || !model) {
          throw new Error('Bad related options');
        }
        if (!model.id) {
          throw new Error('Bad related model. No ID.');
        }
        const type = (_this$defs$links = this.defs.links) === null || _this$defs$links === void 0 || (_this$defs$links = _this$defs$links[link]) === null || _this$defs$links === void 0 ? void 0 : _this$defs$links.type;
        switch (type) {
          case 'belongsToParent':
            this.set(link + 'Id', model.id);
            this.set(link + 'Type', model.entityType);
            this.set(link + 'Name', model.get('name'));
            break;
          case 'belongsTo':
            this.set(link + 'Id', model.id);
            this.set(link + 'Name', model.get('name'));
            break;
          case 'hasMany':
            const ids = [];
            ids.push(model.id);
            const names = {};
            names[model.id] = model.get('name');
            this.set(link + 'Ids', ids);
            this.set(link + 'Names', names);
            break;
        }
      };
      if (Array.isArray(data)) {
        data.forEach(options => setRelate(options));
        return;
      }
      setRelate(data);
    }

    /**
     * Get a field list.
     */
    getFieldList() {
      if (!this.defs || !this.defs.fields) {
        return [];
      }
      return Object.keys(this.defs.fields);
    }

    /**
     * Get a field type.
     *
     * @param {string} field
     * @returns {string|null}
     */
    getFieldType(field) {
      if (!this.defs || !this.defs.fields) {
        return null;
      }
      if (field in this.defs.fields) {
        return this.defs.fields[field].type || null;
      }
      return null;
    }

    /**
     * Get a field param.
     *
     * @param {string} field
     * @param {string} param
     * @returns {*}
     */
    getFieldParam(field, param) {
      if (!this.defs || !this.defs.fields) {
        return null;
      }
      if (field in this.defs.fields) {
        if (param in this.defs.fields[field]) {
          return this.defs.fields[field][param];
        }
      }
      return null;
    }
    hasFieldParam(field, param) {
      if (!this.defs || !this.defs.fields) {
        return false;
      }
      if (field in this.defs.fields) {
        if (param in this.defs.fields[field]) {
          return true;
        }
      }
      return false;
    }

    /**
     * Get the link type.
     *
     * @param link A link name.
     */
    getLinkType(link) {
      if (!this.defs || !this.defs.links) {
        return null;
      }
      if (link in this.defs.links) {
        return this.defs.links[link].type || null;
      }
      return null;
    }

    /**
     * Get the link parameter value.
     *
     * @param link A link name.
     * @param param A parameter.
     */
    getLinkParam(link, param) {
      if (!this.defs || !this.defs.links) {
        return null;
      }
      if (link in this.defs.links) {
        if (param in this.defs.links[link]) {
          return this.defs.links[link][param];
        }
      }
      return null;
    }

    /**
     * Is the field read-only.
     *
     * @param field A field name.
     */
    isFieldReadOnly(field) {
      return this.getFieldParam(field, 'readOnly') || false;
    }

    /**
     * If the field required.
     *
     * @param field A field name.
     */
    isRequired(field) {
      return this.getFieldParam(field, 'required') || false;
    }

    /**
     * Get IDs of a link-multiple field.
     *
     * @param field A link-multiple field name.
     */
    getLinkMultipleIdList(field) {
      return this.get(field + 'Ids') ?? [];
    }

    /**
     * Get team IDs.
     */
    getTeamIdList() {
      return this.get('teamsIds') ?? [];
    }

    /**
     * Whether it has a field.
     *
     * @param {string} field A field name.
     */
    hasField(field) {
      return 'fields' in this.defs && field in this.defs.fields;
    }

    /**
     * Has a link.
     *
     * @param {string} link A link name.
     */
    hasLink(link) {
      return 'links' in this.defs && link in this.defs.links;
    }

    /**
     * Is editable.
     */
    isEditable() {
      return true;
    }

    /**
     * Is removable.
     */
    isRemovable() {
      return true;
    }

    /**
     * Get an entity type.
     */
    getEntityType() {
      return this.entityType;
    }

    /**
     * Abort the last fetch.
     */
    abortLastFetch() {
      if (this.lastSyncPromise && this.lastSyncPromise.getReadyState() < 4) {
        this.lastSyncPromise.abort();
      }
    }

    /**
     * Listen to attribute change.
     *
     * Important. Owner must be specified.
     *
     * @param params Parameters
     * @return {{stop: function()}}
     * @since 10.0.0
     */
    onChange(params) {
      return (0, _event.onModelChange)({
        owner: params.owner,
        once: params.once,
        target: this,
        attributes: params.attributes,
        callback: params.callback
      });
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * Listen to sync.
     *
     * Important. Owner must be specified.
     *
     * @param {{
     *     owner: import('view').default | import('model').default | import('collection').default,
     *     once?: boolean,
     *     callback: function({
     *         action: 'fetch'|'save'|'destroy'|null,
     *         response: *,
     *     }),
     * }} params
     * @return {{stop: function()}}
     * @since 10.0.0
     */
    onSync(params) {
      return (0, _event.onSync)({
        owner: params.owner,
        once: params.once,
        target: this,
        callback: params.callback
      });
    }

    /**
     * Subscribe to an event.
     *
     * @param {string} name An event.
     * @param {function(...any)} callback A callback.
     */
    on(name, callback) {
      // The context argument is needed.
      _bullbone.Events.on.call(this, name, callback, arguments[2]);
      return this;
    }

    /**
     * Subscribe to an event. Fired once.
     *
     * @param {string} name An event.
     * @param {function(...any)} callback A callback.
     */
    once(name, callback) {
      // The context argument is needed.
      _bullbone.Events.once.call(this, name, callback, arguments[2]);
      return this;
    }

    /**
     * Unsubscribe from an event or all events.
     *
     * @param {string} [name] From a specific event.
     * @param {function()} [callback] From a specific callback.
     */
    off(name, callback) {
      // The context argument is needed.
      _bullbone.Events.off.call(this, name, callback, arguments[2]);
      return this;
    }

    /**
     * Subscribe to an event of other object.
     *
     * @param {Object} other What to listen.
     * @param {string} name An event.
     * @param callback A callback.
     */
    listenTo(other, name, callback) {
      _bullbone.Events.listenTo.call(this, other, name, callback);
      return this;
    }

    /**
     * Subscribe to an event of other object. Fired once. Will be automatically unsubscribed on view removal.
     *
     * @param {Object} other What to listen.
     * @param {string} name An event.
     * @param {function()} callback A callback.
     */
    listenToOnce(other, name, callback) {
      _bullbone.Events.listenToOnce.call(this, other, name, callback);
      return this;
    }

    /**
     * Stop listening to other object. No arguments will remove all listeners.
     *
     * @param {Object} [other] To remove listeners to a specific object.
     * @param {string} [name] To remove listeners to a specific event.
     * @param {function()} [callback] To remove listeners to a specific callback.
     */
    stopListening(other, name, callback) {
      _bullbone.Events.stopListening.call(this, other, name, callback);
      return this;
    }

    /**
     * Trigger an event.
     *
     * @param {string} name An event.
     * @param {...*} parameters Arguments.
     */
    trigger(name) {
      for (var _len = arguments.length, parameters = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
        parameters[_key - 1] = arguments[_key];
      }
      _bullbone.Events.trigger.call(this, name, ...parameters);
      return this;
    }
  }

  // @ts-ignore
  _exports.default = Model;
  Model.extend = _bullbone.View.extend;
});

define("ui/dialog", ["exports", "bullbone", "components/controls"], function (_exports, _bullbone, _controls) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  const shownDialogList = [];

  /**
   * Dialog parameters.
   */

  /**
   * A button or dropdown action item.
   */

  /**
   * A dialog.
   *
   * @since 10.0.0
   */
  class Dialog {
    removeOnClose = true;
    className = 'dialog-confirm';
    backdrop = 'static';
    maximizeButton = false;
    closeButton = true;
    collapseButton = false;
    header = null;
    body = '';
    width = null;
    onCloseIsCalled = false;
    draggable = false;
    container = 'body';
    keyboard = true;
    skipRemove = false;
    footerElement = null;
    footerVNode = null;

    /**
     * @param options Options.
     */
    constructor(options) {
      options = options ?? {};
      this.buttonList = [];
      this.dropdownItemList = [];
      this.options = options;
      this.activeElement = document.activeElement;
      const params = ['className', 'backdrop', 'keyboard', 'closeButton', 'collapseButton', 'header', 'body', 'width', 'height', 'fitHeight', 'buttons', 'buttonList', 'dropdownItemList', 'removeOnClose', 'draggable', 'container', 'onRemove', 'onClose', 'onBackdropClick', 'maximizeButton', 'backdropClassName'];
      params.forEach(param => {
        if (!(param in options)) {
          return;
        }
        this[param] = options[param];
      });
      if (options.onMaximize) {
        this.onMaximize = options.onMaximize;
      }
      if (options.onMinimize) {
        this.onMinimize = options.onMinimize;
      }
      if (options.buttons) {
        this.buttonList = options.buttons;
      }
      this.id = 'dialog-' + Math.floor(Math.random() * 100000);
      if (typeof this.backdrop === 'undefined') {
        this.backdrop = 'static';
      }
      const hasFooter = !!(this.buttonList.length || this.dropdownItemList.length);
      this.footerComponent = new FooterComponent({
        dataProvider: () => ({
          buttonList: this.buttonList,
          dropdownItemList: this.dropdownItemList
        })
      }, this);
      if (hasFooter) {
        this.footerElement = document.createElement('footer');
        this.footerVNode = (0, _bullbone.patch)(this.footerElement, this.footerComponent.node());
      }
      const $header = this.getHeader();
      const $body = $('<div>').addClass('modal-body body').html(this.body);
      const $content = $('<div>').addClass('modal-content');
      if ($header) {
        $content.append($header);
      }
      if (this.footerElement && this.options.footerAtTheTop) {
        $content.append(this.footerElement);
      }
      $content.append($body);
      if (this.footerElement && !this.options.footerAtTheTop) {
        $content.append(this.footerElement);
      }
      const $dialog = $('<div>').addClass('modal-dialog').append($content);
      const $container = $(this.container);
      $('<div>').attr('id', this.id).attr('class', this.className + ' modal').attr('role', 'dialog').attr('tabindex', '-1').append($dialog).appendTo($container);
      this.$el = $('#' + this.id);
      this.el = this.$el.get(0);
      if (this.draggable) {
        this.$el.find('header').css('cursor', 'pointer');

        // noinspection JSUnresolvedReference
        // @ts-ignore
        this.$el.draggable({
          handle: 'header'
        });
      }
      const modalContentEl = this.$el.find('.modal-content');
      if (this.width) {
        modalContentEl.css('width', this.width);
        modalContentEl.css('margin-left', '-' + parseInt(this.width.replace('px', '')) / 5 + 'px');
      }
      if (this.removeOnClose) {
        this.$el.on('hidden.bs.modal', e => {
          if (this.$el.get(0) === e.target) {
            if (!this.onCloseIsCalled) {
              this.close();
            }
            if (this.skipRemove) {
              return;
            }
            this.remove();
          }
        });
      }
      const $window = $(window);
      this.$el.on('shown.bs.modal', () => {
        $('.modal-backdrop').not('.stacked').addClass('stacked');
        const headerHeight = this.$el.find('.modal-header').outerHeight() || 0;
        const footerHeight = this.$el.find('.modal-footer').outerHeight() || 0;
        let diffHeight = headerHeight + footerHeight;
        if (!options.fullHeight && options.bodyDiffHeight != null) {
          diffHeight = diffHeight + options.bodyDiffHeight;
        }
        if (this.fitHeight || options.fullHeight) {
          const processResize = () => {
            const windowHeight = window.innerHeight;
            const windowWidth = $window.width();
            if (!options.fullHeight && windowHeight < 512) {
              this.$el.find('div.modal-body').css({
                maxHeight: 'none',
                overflow: 'auto',
                height: 'none'
              });
              return;
            }
            const cssParams = {
              overflow: 'auto'
            };
            if (options.fullHeight) {
              cssParams.height = windowHeight - diffHeight + 'px';
              this.$el.css('paddingRight', 0);
            } else {
              if (options.screenWidthXs != null && windowWidth <= options.screenWidthXs) {
                cssParams.maxHeight = 'none';
              } else {
                cssParams.maxHeight = windowHeight - diffHeight + 'px';
              }
            }
            this.$el.find('div.modal-body').css(cssParams);
          };
          $window.off('resize.modal-height');
          $window.on('resize.modal-height', processResize);
          processResize();
        }
      });
      const $documentBody = $(document.body);
      this.$el.on('hidden.bs.modal', () => {
        if ($('.modal:visible').length > 0) {
          $documentBody.addClass('modal-open');
        }
      });
    }

    /**
     * Get a general container element.
     * @since 9.1.0
     */
    getElement() {
      return this.el;
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * Update the header text.
     *
     * @param {string} text
     * @since 9.1.0
     */
    setHeaderText(text) {
      const element = this.el.querySelector('.modal-header .modal-title');
      if (!element) {
        return;
      }
      element.textContent = text;
    }
    callOnClose() {
      if (this.onClose) {
        this.onClose();
      }
    }
    callOnBackdropClick() {
      if (this.onBackdropClick) {
        this.onBackdropClick();
      }
    }
    callOnRemove() {
      if (this.onRemove) {
        this.onRemove();
      }
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * Set action items.
     *
     * @param buttonList Buttons
     * @param dropdownItemList Dropdown items.
     */
    setActionItems(buttonList, dropdownItemList) {
      this.buttonList = buttonList;
      this.dropdownItemList = dropdownItemList;
    }
    getHeader() {
      if (!this.header) {
        return null;
      }
      const $header = $('<header />').addClass('modal-header').addClass(this.options.fixedHeaderHeight ? 'fixed-height' : '').append($('<h4 />').addClass('modal-title').append($('<span />').addClass('modal-title-text').html(this.header)));
      if (this.collapseButton) {
        $header.prepend($('<a>').addClass('collapse-button').attr('role', 'button').attr('tabindex', '-1').attr('data-action', 'collapseModal').append($('<span />').addClass('fas fa-minus')));
      }
      if (this.maximizeButton) {
        {
          const a = document.createElement('a');
          a.classList.add('maximize-button');
          a.role = 'button';
          a.tabIndex = -1;
          a.setAttribute('data-action', 'maximizeModal');
          const icon = document.createElement('span');
          icon.classList.add('far', 'fa-window-maximize');
          a.append(icon);
          $header.prepend(a);
          this.maximizeButtonElement = a;
          a.addEventListener('click', () => {
            var _this$el$querySelecto;
            this.maximizeButtonElement.classList.add('hidden');
            this.minimizeButtonElement.classList.remove('hidden');
            (_this$el$querySelecto = this.el.querySelector('.modal-dialog')) === null || _this$el$querySelecto === void 0 || _this$el$querySelecto.classList.add('maximized');
            if (this.onMaximize) {
              this.onMaximize();
            }
            this.getElement().focus();
          });
        }
        {
          const a = document.createElement('a');
          a.classList.add('minimize-button', 'hidden');
          a.role = 'button';
          a.tabIndex = -1;
          a.setAttribute('data-action', 'minimizeModal');
          const icon = document.createElement('span');
          icon.classList.add('far', 'fa-window-minimize');
          a.append(icon);
          $header.prepend(a);
          this.minimizeButtonElement = a;
          a.addEventListener('click', () => {
            var _this$el$querySelecto2;
            this.minimizeButtonElement.classList.add('hidden');
            this.maximizeButtonElement.classList.remove('hidden');
            (_this$el$querySelecto2 = this.el.querySelector('.modal-dialog')) === null || _this$el$querySelecto2 === void 0 || _this$el$querySelecto2.classList.remove('maximized');
            if (this.onMinimize) {
              this.onMinimize();
            }
            this.getElement().focus();
          });
        }
      }
      if (this.closeButton) {
        $header.prepend($('<a>').addClass('close').attr('data-dismiss', 'modal').attr('role', 'button').attr('tabindex', '-1').append($('<span />').attr('aria-hidden', 'true').html('&times;')));
      }
      return $header;
    }

    /**
     * @internal
     */
    reRenderFooter() {
      if (!this.footerElement) {
        return;
      }
      this.footerVNode = (0, _bullbone.patch)(this.footerVNode ?? this.footerElement, this.footerComponent.node());
    }

    /**
     * Show.
     */
    show() {
      shownDialogList.push(this);

      // noinspection JSUnresolvedReference,JSUnusedGlobalSymbols
      // @ts-ignore
      // noinspection JSUnusedGlobalSymbols
      this.$el.modal({
        backdrop: this.backdrop,
        keyboard: this.keyboard,
        onBackdropCreate: element => {
          this._backdropElement = element;
          if (this.backdropClassName) {
            this._backdropElement.classList.add(this.backdropClassName);
          }
        }
      });
      this.$el.find('.modal-content').removeClass('hidden');
      for (const [i, dialog] of shownDialogList.entries()) {
        if (i < shownDialogList.length - 1 && dialog.getElement() && dialog.getElement().parentElement) {
          var _dialog$getElement$pa;
          if (dialog._backdropElement) {
            dialog._backdropElement.classList.add('hidden');
          }
          (_dialog$getElement$pa = dialog.getElement().parentElement) === null || _dialog$getElement$pa === void 0 || _dialog$getElement$pa.classList.add('overlaid');
        }
      }
      this.$el.off('click.dismiss.bs.modal');
      this.$el.on('click.dismiss.bs.modal', '> div.modal-dialog > div.modal-content > header [data-dismiss="modal"]', () => this.close());
      this.$el.on('mousedown', e => {
        this.$mouseDownTarget = $(e.target);
      });
      this.$el.on('click.dismiss.bs.modal', e => {
        if (e.target !== e.currentTarget) {
          return;
        }
        if (this.$mouseDownTarget && this.$mouseDownTarget.closest('.modal-content').length) {
          return;
        }
        this.callOnBackdropClick();
        if (this.backdrop === 'static') {
          return;
        }
        this.close();
      });
      $('body > .popover').addClass('hidden');
    }

    /**
     * Hide.
     *
     * @todo Check usage. Deprecate?
     */
    hide() {
      this.$el.find('.modal-content').addClass('hidden');
    }

    /**
     * Hide with a backdrop.
     */
    hideWithBackdrop() {
      if (this._backdropElement) {
        this._backdropElement.classList.add('hidden');
      }
      this._hideInternal();
      this.skipRemove = true;
      setTimeout(() => this.skipRemove = false, 50);

      // noinspection JSUnresolvedReference
      // @ts-ignore
      this.$el.modal('hide');
      this.$el.find('.modal-content').addClass('hidden');
    }

    /**
     * @private
     */
    _hideInternal() {
      const findIndex = shownDialogList.findIndex(it => it === this);
      if (findIndex >= 0) {
        shownDialogList.splice(findIndex, 1);
      }
      const last = shownDialogList[shownDialogList.length - 1];
      if (last && last._backdropElement) {
        last._backdropElement.classList.remove('hidden');
      }
      if (last && last.getElement() && last.getElement().parentElement) {
        var _last$getElement$pare;
        (_last$getElement$pare = last.getElement().parentElement) === null || _last$getElement$pare === void 0 || _last$getElement$pare.classList.remove('overlaid');
      }
    }

    /**
     * @private
     */
    _close() {
      this._hideInternal();
    }
    _findClosestFocusableElement(element) {
      // noinspection JSUnresolvedReference
      const isVisible = !!(element instanceof HTMLElement && element.offsetWidth || element instanceof HTMLElement && element.offsetHeight || element.getClientRects().length);
      if (isVisible && element instanceof HTMLElement) {
        // noinspection JSUnresolvedReference
        element.focus({
          preventScroll: true
        });
        return element;
      }
      const $element = $(element);
      if ($element.closest('.dropdown-menu').length) {
        const $button = $element.closest('.btn-group').find(`[data-toggle="dropdown"]`);
        if ($button.length) {
          // noinspection JSUnresolvedReference
          $button.get(0).focus({
            preventScroll: true
          });
          return $button.get(0);
        }
      }
      return null;
    }

    /**
     * Close.
     */
    close() {
      if (!this.onCloseIsCalled) {
        this.callOnClose();
        this.onCloseIsCalled = true;
        if (this.activeElement) {
          setTimeout(() => {
            const activeElement = this.activeElement;
            if (!(activeElement instanceof HTMLElement)) {
              return;
            }
            const element = this._findClosestFocusableElement(activeElement);
            if (element && element instanceof HTMLElement) {
              // noinspection JSUnresolvedReference
              element.focus({
                preventScroll: true
              });
            }
          }, 50);
        }
      }
      this._close();
      // noinspection JSUnresolvedReference
      // @ts-ignore
      this.$el.modal('hide');
      $(this).trigger('dialog:close');
    }

    /**
     * Remove.
     */
    remove() {
      this.callOnRemove();

      // Hack allowing multiple backdrops.
      // `close` function may be called twice.
      this._close();
      this.$el.remove();
      $(this).off();
      $(window).off('resize.modal-height');
    }
  }
  var _default = _exports.default = Dialog;
  class FooterComponent {
    constructor(options, dialog) {
      this.options = options;
      this.dialog = dialog;
    }
    getPreparedData() {
      const data = this.options.dataProvider();
      const buttonList = data.buttonList.filter(it => !it.hidden);
      const dropdownItemList = data.dropdownItemList.filter(it => it === false || !it.hidden).filter((it, i, list) => {
        if (it === false && (i === 0 || i === list.length - 1)) {
          return false;
        }
        if (it === false && list[i - 1] === false) {
          return false;
        }
        return true;
      });
      return {
        buttonList,
        dropdownItemList
      };
    }
    node() {
      const data = this.getPreparedData();
      const elements = [];
      const left = [];
      const right = [];
      const lis = [];
      const leftButtonList = [];
      const rightButtonList = [];
      data.buttonList.forEach(it => {
        it.pullLeft || it.position === 'right' ? rightButtonList.push(it) : leftButtonList.push(it);
      });
      const prepareButton = it => {
        return new _controls.ButtonComponent({
          name: it.name,
          className: it.className ?? 'btn-xs-wide',
          style: it.style,
          title: it.title,
          hidden: it.hidden,
          disabled: it.disabled,
          text: it.text,
          html: it.html,
          iconClass: it.iconClass,
          onClick: event => {
            if (it.onClick) {
              it.onClick(this.dialog, event);
            }
          }
        }).node();
      };
      const prepareButtons = (buttonList, output) => {
        buttonList.forEach(it => {
          output.push(prepareButton(it));
        });
      };
      prepareButtons(leftButtonList, left);
      prepareButtons(rightButtonList, right);
      data.dropdownItemList.forEach(it => {
        if (it === false) {
          lis.push((0, _bullbone.h)('li', {
            class: {
              'divider': true
            }
          }));
          return;
        }
        lis.push(new _controls.DropdownItemComponent({
          name: it.name,
          title: it.title,
          hidden: it.hidden,
          disabled: it.disabled,
          text: it.text,
          html: it.html,
          iconClass: it.iconClass,
          onClick: event => {
            if (it.onClick) {
              it.onClick(this.dialog, event);
            }
          }
        }).node());
      });
      if (lis.length) {
        left.push((0, _bullbone.h)('button', {
          key: '_menu-dropdown-button',
          attrs: {
            type: 'button'
          },
          props: {
            className: 'btn btn-default dropdown-toggle'
          },
          dataset: {
            toggle: 'dropdown'
          }
        }, (0, _bullbone.h)('span', {
          props: {
            className: 'fas fa-ellipsis-h'
          }
        })), (0, _bullbone.h)('ul', {
          props: {
            className: 'dropdown-menu pull-right'
          }
        }, lis));
      }
      elements.push((0, _bullbone.h)('div', {
        props: {
          className: 'btn-group main-btn-group'
        }
      }, left));
      elements.push((0, _bullbone.h)('div', {
        props: {
          className: 'btn-group additional-btn-group'
        }
      }, right));
      return (0, _bullbone.h)('footer', {
        props: {
          className: 'modal-footer'
        }
      }, elements);
    }
  }
});

define("ui", ["exports", "marked", "dompurify", "jquery", "ui/dialog"], function (_exports, _marked, _dompurify, _jquery, _dialog) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _dompurify = _interopRequireDefault(_dompurify);
  _jquery = _interopRequireDefault(_jquery);
  _dialog = _interopRequireDefault(_dialog);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module ui */

  const $ = _jquery.default;

  /**
   * Popover options.
   */

  /**
   * Notify options.
   */

  /**
   * UI utils.
   */
  const Ui = {
    Dialog: _dialog.default,
    /**
     * Show a confirmation dialog.
     *
     * @param message A message.
     * @param options Options.
     * @param [callback] Deprecated. Use a promise.
     * @param [context] Deprecated.
     * @returns Resolves if confirmed.
     */
    confirm: function (message, options, callback, context) {
      options = {
        ...options
      };
      const confirmText = options.confirmText;
      const cancelText = options.cancelText;
      const confirmStyle = options.confirmStyle || 'danger';
      let backdrop = options.backdrop;
      if (typeof backdrop === 'undefined') {
        backdrop = false;
      }
      let isResolved = false;
      const processCancel = () => {
        if (!options.cancelCallback) {
          return;
        }
        if (context) {
          options.cancelCallback.call(context);
          return;
        }
        options.cancelCallback();
      };
      if (!options.isHtml) {
        message = Handlebars.Utils.escapeExpression(message);
      }
      confirmCount++;
      return new Promise(resolve => {
        const dialog = new _dialog.default({
          backdrop: backdrop,
          header: null,
          className: 'dialog-confirm',
          backdropClassName: 'backdrop-confirm',
          body: `<span class="confirm-message">${message}</a>`,
          buttonList: [{
            text: ` ${confirmText} `,
            name: 'confirm',
            className: 'btn-s-wide',
            onClick: () => {
              isResolved = true;
              if (callback) {
                if (context) {
                  callback.call(context);
                } else {
                  callback();
                }
              }
              resolve();
              dialog.close();
            },
            style: confirmStyle,
            position: 'right'
          }, {
            text: cancelText,
            name: 'cancel',
            className: 'btn-s-wide',
            onClick: () => {
              isResolved = true;
              dialog.close();
              processCancel();
            },
            position: 'left'
          }],
          onClose: () => {
            confirmCount--;
            if (isResolved) {
              return;
            }
            processCancel();
          }
        });
        dialog.show();
        $(dialog.getElement()).find('button[data-name="confirm"]').trigger('focus');
      });
    },
    /**
     * Create a dialog.
     *
     * @param options Options.
     * @returns A dialog instance.
     */
    dialog: function (options) {
      return new _dialog.default(options);
    },
    /**
     * Init a popover.
     *
     * @param element An element.
     * @param options Options.
     * @param [view] A view.
     * @return Manipulator object.
     */
    popover: function (element, options, view) {
      const $el = $(element);
      const $body = $('body');
      const content = options.content || Handlebars.Utils.escapeExpression(options.text || '');
      let isShown = false;
      let container = options.container;
      if (!container) {
        const $modalBody = $el.closest('.modal-body');
        container = $modalBody.length ? $modalBody : 'body';
      }

      // noinspection JSUnresolvedReference
      // @ts-ignore
      $el.popover({
        placement: options.placement || 'bottom',
        container: container,
        viewport: container,
        html: true,
        content: content,
        trigger: options.trigger || 'manual',
        title: options.title,
        keepElementTitle: options.keepElementTitle
      }).on('shown.bs.popover', () => {
        isShown = true;
        if (!view) {
          return;
        }
        if (view && !options.noHideOnOutsideClick) {
          $body.off(`click.popover-${view.cid}`);
          $body.on(`click.popover-${view.cid}`, e => {
            if ($(e.target).closest('.popover').get(0)) {
              return;
            }
            if ($.contains($el.get(0), e.target)) {
              return;
            }
            if ($el.get(0) === e.target) {
              return;
            }
            $body.off(`click.popover-${view.cid}`);
            // noinspection JSUnresolvedReference
            // @ts-ignore
            $el.popover('hide');
          });
        }
        if (options.onShow) {
          options.onShow();
        }
      }).on('hidden.bs.popover', () => {
        isShown = false;
        if (options.onHide) {
          options.onHide();
        }
      });
      if (!options.noToggleInit) {
        $el.on('click', () => {
          // noinspection JSUnresolvedReference
          // @ts-ignore
          $el.popover('toggle');
        });
      }
      let isDetached = false;
      const detach = () => {
        if (view) {
          $body.off(`click.popover-${view.cid}`);
          view.off('remove', destroy);
          view.off('render', destroy);
          view.off('render', hide);
        }
        isDetached = true;
      };
      const destroy = () => {
        if (isDetached) {
          return;
        }

        // noinspection JSUnresolvedReference
        // @ts-ignore
        $el.popover('destroy');
        detach();
      };
      const hide = () => {
        if (!isShown) {
          return;
        }

        // noinspection JSUnresolvedReference
        // @ts-ignore
        $el.popover('hide');
      };
      const show = () => {
        // noinspection JSUnresolvedReference
        // @ts-ignore
        $el.popover('show');
        return $el.attr('aria-describedby');
      };
      if (view) {
        view.once('remove', destroy);
        if (!options.preventDestroyOnRender) {
          view.once('render', destroy);
        }
        if (options.preventDestroyOnRender) {
          view.on('render', hide);
        }
      }
      return {
        hide: () => hide(),
        destroy: () => destroy(),
        show: () => show(),
        detach: () => detach()
      };
    },
    /**
     * Show the spinner.
     *
     * @since 9.1.0
     */
    notifyWait: function () {
      Ui.notify(' ... ');
    },
    /**
     * Show a notify-message.
     *
     * @param [message] A message. False removes an already displayed message.
     * @param [type='warning'] A type.
     * @param [timeout] Microseconds. If empty, then won't be hidden.
     *   Should be hidden manually or by displaying another message.
     * @param [options] Options.
     */
    notify: function () {
      let message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
      let type = arguments.length > 1 ? arguments[1] : undefined;
      let timeout = arguments.length > 2 ? arguments[2] : undefined;
      let options = arguments.length > 3 ? arguments[3] : undefined;
      type = type ?? 'warning';
      options = {
        ...options
      };
      if (type === 'warning' && notifySuppressed) {
        return;
      }
      $('#notification').remove();
      if (!message) {
        return;
      }
      if (options.suppress && timeout) {
        notifySuppressed = true;
        setTimeout(() => notifySuppressed = false, timeout);
      }
      const parsedMessage = message.indexOf('\n') !== -1 ? _marked.marked.parse(message) : _marked.marked.parseInline(message);
      let sanitizedMessage = _dompurify.default.sanitize(parsedMessage, {}).toString();
      const closeButton = options.closeButton || false;

      // @ts-ignore
      if (type === 'error') {
        // For bc.
        type = 'danger';
      }
      if (sanitizedMessage === ' ... ') {
        sanitizedMessage = ' <span class="fas fa-spinner fa-spin"> ';
      }
      const additionalClassName = closeButton ? ' alert-closable' : '';
      const $el = $('<div>').addClass('alert alert-' + type + additionalClassName + ' fade in').attr('id', 'notification').css({
        'position': 'fixed',
        'top': '0',
        'left': '50vw',
        'transform': 'translate(-50%, 0)',
        'z-index': 2000
      }).append($('<div>').addClass('message').html(sanitizedMessage));
      if (closeButton) {
        const $close = $('<button>').attr('type', 'button').attr('data-dismiss', 'modal').attr('aria-hidden', 'true').addClass('close').html(`<span class="fas fa-times"></span>`);
        $el.append($('<div>').addClass('close-container').append($close));

        // @ts-ignore
        $close.on('click', () => $el.alert('close'));
      }
      if (timeout) {
        // @ts-ignore
        setTimeout(() => $el.alert('close'), timeout);
      }
      $el.appendTo('body');
    },
    /**
     * Show a warning message.
     *
     * @param message message.
     * @param [options] Options.
     */
    warning: function (message, options) {
      Ui.notify(message, 'warning', 2000, options);
    },
    /**
     * Show a success message.
     *
     * @param message A message.
     * @param [options] Options.
     */
    success: function (message, options) {
      Ui.notify(message, 'success', 2000, options);
    },
    /**
     * Show an error message.
     *
     * @param message A message.
     * @param [options] Options. If true, then only closeButton option will be applied.
     */
    error: function (message, options) {
      options = typeof options === 'boolean' ? {
        closeButton: options
      } : {
        ...options
      };
      const timeout = options.closeButton ? 0 : 4000;
      Ui.notify(message, 'danger', timeout, options);
    },
    /**
     * Show an info message.
     *
     * @param message A message.
     * @param [options] Options.
     */
    info: function (message, options) {
      Ui.notify(message, 'info', 2000, options);
    },
    /**
     * Get the number of opened confirmation dialogues.
     * @internal
     */
    getConfirmCount() {
      return confirmCount;
    }
  };
  let confirmCount = 0;
  let notifySuppressed = false;
  Espo.Ui = Ui;
  var _default = _exports.default = Ui;
});

define("metadata", ["exports", "bullbone"], function (_exports, _bullbone) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module metadata */

  /**
   * Application metadata.
   *
   * @mixes Bull.Events
   */
  class Metadata {
    /**
     * Application metadata.
     *
     * @param {module:cache} [cache] A cache.
     */
    constructor(cache) {
      /**
       * @private
       * @type {module:cache|null}
       */
      this.cache = cache || null;

      /**
       * @private
       * @type {Object}
       */
      this.data = {};
    }

    /** @private */
    url = 'Metadata';

    /**
     * Load from cache or the backend (if not yet cached).
     *
     * @param {Function|null} [callback] Deprecated. Use a promise.
     * @param {boolean} [disableCache=false] Deprecated.
     * @returns {Promise}
     */
    load(callback, disableCache) {
      if (!disableCache) {
        if (this.loadFromCache()) {
          this.trigger('sync');
          if (callback) {
            callback();
          }
          return Promise.resolve();
        }
      }
      return this.fetch().then(() => {
        if (callback) {
          callback();
        }
      });
    }

    /**
     * Load from the server.
     *
     * @returns {Promise}
     */
    loadSkipCache() {
      return this.load(null, true);
    }

    /**
     * @private
     * @returns {Promise}
     */
    fetch() {
      return Espo.Ajax.getRequest(this.url).then(data => {
        this.data = data;
        this.storeToCache();
        this.trigger('sync');
      });
    }

    /**
     * Get a value.
     *
     * @param {string[]|string} path A key path.
     * @param {*} [defaultValue] A value to return if not set.
     * @returns {*} Null if not set.
     */
    get(path, defaultValue) {
      defaultValue = defaultValue || null;
      let arr;
      if (Array && Array.isArray && Array.isArray(path)) {
        arr = path;
      } else {
        arr = path.split('.');
      }
      let pointer = this.data;
      let result = defaultValue;
      for (let i = 0; i < arr.length; i++) {
        const key = arr[i];
        if (pointer == null || !(key in pointer)) {
          result = defaultValue;
          break;
        }
        if (arr.length - 1 === i) {
          result = pointer[key];
        }
        pointer = pointer[key];
      }
      return result;
    }

    /**
     * @private
     * @returns {boolean|null} True if success.
     */
    loadFromCache() {
      if (this.cache) {
        const cached = this.cache.get('app', 'metadata');
        if (cached) {
          this.data = cached;
          return true;
        }
      }
      return null;
    }

    /** @private */
    storeToCache() {
      if (this.cache) {
        this.cache.set('app', 'metadata', this.data);
      }
    }

    /**
     * Clear cache.
     */
    clearCache() {
      if (!this.cache) {
        return;
      }
      this.cache.clear('app', 'metadata');
    }

    /**
     * Get a scope list.
     *
     * @returns {string[]}
     */
    getScopeList() {
      const scopes = this.get('scopes') || {};
      const scopeList = [];
      for (const scope in scopes) {
        const d = scopes[scope];
        if (d.disabled) {
          continue;
        }
        scopeList.push(scope);
      }
      return scopeList;
    }

    /**
     * Get an object-scope list. An object-scope represents a business entity.
     *
     * @returns {string[]}
     */
    getScopeObjectList() {
      const scopes = this.get('scopes') || {};
      const scopeList = [];
      for (const scope in scopes) {
        const d = scopes[scope];
        if (d.disabled) {
          continue;
        }
        if (!d.object) {
          continue;
        }
        scopeList.push(scope);
      }
      return scopeList;
    }

    /**
     * Get an entity-scope list. Scopes that represents entities.
     *
     * @returns {string[]}
     */
    getScopeEntityList() {
      const scopes = this.get('scopes') || {};
      const scopeList = [];
      for (const scope in scopes) {
        const d = scopes[scope];
        if (d.disabled) {
          continue;
        }
        if (!d.entity) {
          continue;
        }
        scopeList.push(scope);
      }
      return scopeList;
    }

    /**
     * Do not use.
     *
     * @internal
     * @param {Record} data
     */
    setData(data) {
      this.data = data;
    }
  }
  Object.assign(Metadata.prototype, _bullbone.Events);
  var _default = _exports.default = Metadata;
});

define("collection", ["exports", "model", "bullbone", "underscore", "util/event"], function (_exports, _model, _bullbone, _underscore, _event) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _model = _interopRequireDefault(_model);
  _underscore = _interopRequireDefault(_underscore);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module collection */

  /**
   * On sync with backend.
   *
   * @event Collection#sync
   * @param {Collection} collection A collection.
   * @param {Object} response Response from backend.
   * @param {Object} o Options.
   */

  /**
   * Any number of models have been added, removed or changed.
   *
   * @event Collection#update
   * @param {Collection} collection A collection.
   * @param {Object} o Options.
   */

  /**
   * On reset.
   *
   * @event Collection#reset
   * @param {Collection} collection A collection.
   * @param {Object} o Options.
   */

  /**
   * On model sync.
   *
   * @event Collection#model-sync
   * @param {Model} model A model.
   * @param {Record & {action?: 'fetch'|'save'|'destroy'}} o Options.
   * @since 9.1.0
   */

  /**
   * A where item. Sent to the backend.
   */

  /**
   * Search data.
   */

  class Collection {
    /**
     * An entity type.
     */
    entityType = null;

    /**
     * A total number of records.
     */
    total = 0;

    /**
     * A current offset (for pagination).
     */
    offset = 0;

    /**
     * A max size (for pagination).
     */
    maxSize = 20;

    /**
     * A number of records.
     */

    /**
     * An order.
     */
    order = null;

    /**
     * An order-by field.
     */
    orderBy = null;

    /**
     * A default order.
     */
    defaultOrder = null;

    /**
     * A default order-by field.
     */
    defaultOrderBy = null;

    /**
     * A where clause.
     */
    where = null;

    /**
     * @deprecated
     */
    whereAdditional = null;

    /**
     * A length correction.
     */
    lengthCorrection = 0;

    /**
     * A max max-size.
     */
    maxMaxSize = 0;

    /**
     * A where function.
     */
    whereFunction = null;

    /**
     * A last sync request promise.
     */
    lastSyncPromise = null;

    /**
     * A parent model. To be used for own purposes. E.g. to have access to a parent from related models.
     */

    /**
     * A root URL.
     */

    /**
     * A URL.
     */

    /**
     * Model definitions.
     */

    /**
     * A model type.
     */

    /**
     * Search data.
     */

    /**
     * Models. Do not write, do not mutate.
     */

    /**
     * @internal
     * @todo Revise.
     */

    /**
     * @param {Model[]|Record<string, *>[]|null} [models] Models.
     * @param [options] Options.
     */
    constructor() {
      let models = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
      let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
      options = {
        ...options
      };
      if (options.model) {
        this.model = options.model;
      }
      if (options.maxSize !== undefined) {
        this.maxSize = options.maxSize;
      }
      this._reset();
      if (options.entityType) {
        this.entityType = options.entityType;
        // @ts-ignore
        this.name = this.entityType;
      }
      this.urlRoot = options.urlRoot || this.urlRoot || this.entityType || null;
      this.url = options.url || this.url || this.urlRoot;
      this.orderBy = options.orderBy || this.orderBy;
      this.order = options.order || this.order;
      this.defaultOrder = this.order;
      this.defaultOrderBy = this.orderBy;
      this.defs = options.defs ?? {};
      this.data = {};
      this.model = options.model || _model.default;
      if (models) {
        this.reset(models, {
          silent: true,
          ...options
        });
      }
      this._onModelEventBind = this._onModelEvent.bind(this);
    }

    // noinspection JSValidateJSDoc
    /**
     * Add models or a model.
     *
     * @param models Models ar a model.
     * @param [options] Options. `at` – position; `merge` – merge existing models, otherwise, they are ignored.
     * @fires Collection#update
     */
    add(models, options) {
      this.set(models, {
        merge: false,
        ...options,
        ...addOptions
      });
      return this;
    }

    // noinspection JSValidateJSDoc
    /**
     * Remove models or a model.
     *
     * @param models Models, a model or a model ID.
     * @param [options] Options.
     * @fires Collection#update
     */
    remove(models, options) {
      options = {
        ...options
      };
      models = Array.isArray(models) ? models.slice() : [models];
      const removed = this._removeModels(models, options);
      if (!options.silent && removed.length) {
        options.changes = {
          added: [],
          merged: [],
          removed: removed
        };
        this.trigger('update', this, options);
      }
      return this;
    }

    /**
     * @protected
     * @param {Model[]|Model|Record[]} models Models or a model.
     * @param {{
     *     silent?: boolean,
     *     at?: number,
     *     prepare?: boolean,
     *     add?: boolean,
     *     merge?: boolean,
     *     remove?: boolean,
     *     index?: number,
     * } & Object.<string, *>} [options]
     * @return {Model[]}
     */
    set(models, options) {
      if (models == null) {
        return [];
      }
      options = {
        ...setOptions,
        ...options
      };
      if (options.prepare && !this._isModel(models)) {
        models = this.prepareAttributes(models, options) || [];
      }
      models = Array.isArray(models) ? models.slice() : [models];

      // Should not undefined if not set.
      let at = options.at;
      if (at != null && at > this.length) {
        at = this.length;
      }
      if (at != null && at < 0) {
        at += this.length + 1;
      }
      const set = [];
      const toAdd = [];
      const toMerge = [];
      const toRemove = [];
      const modelMap = {};
      const add = options.add;
      const merge = options.merge;
      const remove = options.remove;
      let model;
      for (let i = 0; i < models.length; i++) {
        // @ts-ignore
        model = models[i];
        const existing = this._get(model);
        if (existing) {
          if (merge && model !== existing) {
            let attributes = this._isModel(model) ? model.attributes : model;
            if (options.prepare) {
              attributes = existing.prepareAttributes(attributes, options);
            }
            existing.setMultiple(attributes, options);
            toMerge.push(existing);
          }
          if (!modelMap[existing.cid]) {
            modelMap[existing.cid] = true;
            set.push(existing);
          }

          // @ts-ignore
          models[i] = existing;
        } else if (add) {
          // @ts-ignore
          model = models[i] = this._prepareModel(model);
          if (model && model instanceof _model.default) {
            toAdd.push(model);
            this._addReference(model);
            modelMap[model.cid] = true;
            set.push(model);
          }
        }
      }

      // Remove stale models.
      if (remove) {
        for (let i = 0; i < this.length; i++) {
          model = this.models[i];
          if (!modelMap[model.cid]) {
            toRemove.push(model);
          }
        }
        if (toRemove.length) {
          this._removeModels(toRemove, options);
        }
      }
      let orderChanged = false;
      const replace = add && remove;
      if (set.length && replace) {
        orderChanged = this.length !== set.length || _underscore.default.some(this.models, (m, index) => {
          // @ts-ignore
          return m !== set[index];
        });
        this.models.length = 0;
        splice(this.models, set, 0);
        this.length = this.models.length;
      } else if (toAdd.length) {
        splice(this.models, toAdd, at == null ? this.length : at);
        this.length = this.models.length;
      }
      if (!options.silent) {
        for (let i = 0; i < toAdd.length; i++) {
          if (at != null) {
            options.index = at + i;
          }
          model = toAdd[i];
          model.trigger('add', model, this, options);
        }
        if (orderChanged) {
          this.trigger('sort', this, options);
        }
        if (toAdd.length || toRemove.length || toMerge.length) {
          options.changes = {
            added: toAdd,
            removed: toRemove,
            merged: toMerge
          };
          this.trigger('update', this, options);
        }
      }
      return models;
    }

    // noinspection JSValidateJSDoc
    /**
     * Reset.
     *
     * @param [models] Models to replace the collection with.
     * @param [options]
     * @return {this}
     * @fires Collection#reset
     */
    reset(models, options) {
      this.lengthCorrection = 0;
      options = options ? _underscore.default.clone(options) : {};
      for (let i = 0; i < this.models.length; i++) {
        this._removeReference(this.models[i]);
      }
      options.previousModels = this.models;
      this._reset();
      if (models) {
        this.add(models, {
          silent: true,
          ...options
        });
      }
      if (!options.silent) {
        this.trigger('reset', this, options);
      }
      return this;
    }

    /**
     * Add a model at the end.
     *
     * @param model A model.
     * @param [options] Options
     * @return {this}
     */
    push(model, options) {
      this.add(model, {
        at: this.length,
        ...options
      });
      return this;
    }

    /**
     * Remove and return the last model.
     *
     * @param [options] Options
     */
    pop(options) {
      const model = this.at(this.length - 1);
      if (!model) {
        return null;
      }
      this.remove(model, options);
      return model;
    }

    /**
     * Add a model to the beginning.
     *
     * @param {Model} model A model.
     * @param {{
     *     silent?: boolean,
     * }} [options] Options
     * @return {this}
     */
    unshift(model, options) {
      this.add(model, {
        at: 0,
        ...options
      });
      return this;
    }

    /**
     * Remove and return the first model.
     *
     * @param [options] Options
     * @return {Model|null}
     */
    shift(options) {
      const model = this.at(0);
      if (!model) {
        return null;
      }
      this.remove(model, options);
      return model;
    }

    /**
     * Get a model by an ID.
     *
     * @todo Usage to _get.
     * @param id An ID.
     */
    get(id) {
      return this._get(id);
    }

    /**
     * Whether a model in the collection.
     *
     * @todo Usage to _has.
     * @param id An ID.
     */
    has(id) {
      return this._has(id);
    }

    /**
     * Get a model by index.
     *
     * @param index An index. Can be negative, then counted from the end.
     */
    at(index) {
      if (index < 0) {
        index += this.length;
      }
      return this.models[index];
    }

    /**
     * Iterates through a collection.
     *
     * @param {function(Model)} callback A function.
     */
    forEach(callback) {
      this.models.forEach(callback, arguments[1]);
      return this;
    }

    /**
     * Get an index of a model. Returns -1 if not found.
     *
     * @param model A model
     */
    indexOf(model) {
      return this.models.indexOf(model);
    }
    _has(obj) {
      return !!this._get(obj);
    }
    _get(obj) {
      if (obj == null) {
        return void 0;
      }

      // @ts-ignore
      return this._byId[obj] || this._byId[this.modelId(obj.attributes || obj)] || obj.cid && this._byId[obj.cid];
    }
    modelId(attributes) {
      return attributes['id'];
    }
    _reset() {
      this.length = 0;
      this.models = [];
      this._byId = {};
    }

    /**
     * @param orderBy An order field.
     * @param [order] True for desc.
     */
    sort(orderBy, order) {
      this.orderBy = orderBy;
      if (order === true) {
        order = 'desc';
      } else if (order === false) {
        order = 'asc';
      }
      this.order = order || 'asc';
      return this.fetch();
    }

    /**
     * Has previous page.
     */
    hasPreviousPage() {
      return this.offset > 0;
    }

    /**
     * Has next page.
     */
    hasNextPage() {
      return this.total - this.offset > this.length || this.total === -1;
    }

    /**
     * Next page.
     */
    nextPage() {
      return this.setOffset(this.offset + this.length);
    }

    /**
     * Previous page.
     */
    previousPage() {
      return this.setOffset(Math.max(0, this.offset - this.maxSize));
    }

    /**
     * First page.
     */
    firstPage() {
      return this.setOffset(0);
    }

    /**
     * Last page.
     */
    lastPage() {
      let offset = this.total - this.total % this.maxSize;
      if (offset === this.total) {
        offset = this.total - this.maxSize;
      }
      return this.setOffset(offset);
    }

    /**
     * Set an offset.
     *
     * @param offset Offset.
     */
    setOffset(offset) {
      if (offset < 0) {
        throw new RangeError('offset can not be less than 0');
      }
      if (offset > this.total && this.total !== -1 && this.total !== -2 && offset > 0) {
        throw new RangeError('offset can not be larger than total count');
      }
      this.offset = offset;
      return this.fetch({
        maxSize: this.maxSize
      });
    }

    /**
     * Has more.
     */
    hasMore() {
      return this.total > this.length + this.offset + this.lengthCorrection || this.total === -1;
    }

    /**
     * Prepare attributes.
     *
     * @param response A response from the backend.
     * @param options Options.
     */
    prepareAttributes(response, options) {
      if (Array.isArray(response)) {
        return response;
      }

      // noinspection BadExpressionStatementJS
      options;
      this.total = response.total;
      return response.list ?? [];
    }

    // noinspection JSValidateJSDoc
    /**
     * Fetch from the backend.
     *
     * @param {{
     *     remove?: boolean,
     *     more?: boolean,
     *     offset?: number,
     *     maxSize?: number,
     *     orderBy?: string,
     *     order?: 'asc'|'desc',
     * } & Object.<string, *>} [options] Options.
     * @returns {Promise}
     * @fires Collection#sync Unless `{silent: true}`.
     */
    fetch(options) {
      options = {
        ...options
      };
      options.data = {
        ...options.data,
        ...this.data
      };
      this.offset = options.offset || this.offset;
      this.orderBy = options.orderBy || this.orderBy;
      this.order = options.order || this.order;
      this.where = options.where || this.where;
      const length = this.length + this.lengthCorrection;
      if ('maxSize' in options) {
        options.data.maxSize = options.maxSize;
      } else {
        options.data.maxSize = options.more ? this.maxSize : Math.max(length, this.maxSize);
        if (this.maxMaxSize && options.data.maxSize > this.maxMaxSize) {
          options.data.maxSize = this.maxMaxSize;
        }
      }
      options.data.offset = options.more ? this.offset + length : this.offset;
      options.data.orderBy = this.orderBy;
      options.data.order = this.order;
      options.data.whereGroup = this.getWhere();
      if (options.data.select) {
        options.data.attributeSelect = options.data.select;
        delete options.data.select;
      }
      options = {
        prepare: true,
        ...options
      };
      const success = options.success;
      options.success = response => {
        options.reset ? this.reset(response, options) : this.set(response, options);
        if (success) {
          success.call(options.context, this, response, options);
        }
        this.trigger('sync', this, response, options);
      };
      const error = options.error;
      options.error = response => {
        if (error) {
          error.call(options.context, this, response, options);
        }
        this.trigger('error', this, response, options);
      };

      // @ts-ignore
      this.lastSyncPromise = _model.default.prototype.sync.call(this, 'read', this, options);
      return this.lastSyncPromise;
    }

    /**
     * Is being fetched.
     *
     * @return {boolean}
     */
    isBeingFetched() {
      var _this$lastSyncPromise;
      return Boolean(this.lastSyncPromise && ((_this$lastSyncPromise = this.lastSyncPromise) === null || _this$lastSyncPromise === void 0 ? void 0 : _this$lastSyncPromise.getReadyState()) < 4);
    }

    /**
     * Abort the last fetch.
     */
    abortLastFetch() {
      if (this.isBeingFetched()) {
        var _this$lastSyncPromise2;
        (_this$lastSyncPromise2 = this.lastSyncPromise) === null || _this$lastSyncPromise2 === void 0 || _this$lastSyncPromise2.abort();
      }
    }

    /**
     * Get a where clause.
     */
    getWhere() {
      let where = (this.where ?? []).concat(this.whereAdditional || []);
      if (this.whereFunction) {
        where = where.concat(this.whereFunction() || []);
      }
      return where;
    }

    /**
     * Get an entity type.
     *
     * @returns {string}
     */
    getEntityType() {
      // @ts-ignore
      return this.entityType || this.name;
    }

    /**
     * Reset the order to default.
     */
    resetOrderToDefault() {
      this.orderBy = this.defaultOrderBy;
      this.order = this.defaultOrder;
    }

    /**
     * Set an order.
     *
     * @param orderBy
     * @param [order]
     * @param [setDefault]
     */
    setOrder(orderBy, order, setDefault) {
      this.orderBy = orderBy;
      this.order = order;
      if (setDefault) {
        this.defaultOrderBy = orderBy;
        this.defaultOrder = order;
      }
    }

    /**
     * Clone.
     *
     * @param {{withModels?: boolean}} [options]
     */
    clone() {
      let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      let models = this.models;
      if (options.withModels) {
        models = this.models.map(m => m.clone());
      }

      // @ts-ignore
      const collection = new this.constructor(models, {
        model: this.model,
        entityType: this.entityType,
        defs: this.defs,
        orderBy: this.orderBy,
        order: this.order
      });

      // @ts-ignore
      collection.name = this.name;
      collection.urlRoot = this.urlRoot;
      collection.url = this.url;
      collection.defaultOrder = this.defaultOrder;
      collection.defaultOrderBy = this.defaultOrderBy;
      collection.data = Espo.Utils.cloneDeep(this.data);
      collection.where = Espo.Utils.cloneDeep(this.where);
      // noinspection JSDeprecatedSymbols
      // @ts-ignore
      collection.whereAdditional = Espo.Utils.cloneDeep(this.whereAdditional);
      collection.total = this.total;
      collection.offset = this.offset;
      collection.maxSize = this.maxSize;
      collection.maxMaxSize = this.maxMaxSize;
      collection.whereFunction = this.whereFunction;
      collection.parentModel = this.parentModel;
      return collection;
    }

    /**
     * Prepare an empty model instance.
     *
     * @return {Model}
     */
    prepareModel() {
      return this._prepareModel({});
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * Compose a URL for syncing. Called from Model.sync.
     *
     * @internal
     */
    composeSyncUrl() {
      return this.url;
    }

    /**
     * Listen to sync.
     *
     * Important. Owner must be specified.
     *
     * @param {{
     *     owner: import('view').default | import('model').default | import('collection').default,
     *     once?: boolean,
     *     callback: function({
     *         action: 'fetch'|'save'|'destroy'|null,
     *         response: *,
     *     }),
     * }} params
     * @return {{stop: function()}}
     * @since 10.0.0
     */
    onSync(params) {
      return (0, _event.onSync)({
        owner: params.owner,
        once: params.once,
        target: this,
        callback: params.callback
      });
    }
    _isModel(object) {
      return object instanceof _model.default;
    }
    _removeModels(models, options) {
      const removed = [];
      for (let i = 0; i < models.length; i++) {
        const model = this.get(models[i]);
        if (!model) {
          continue;
        }
        const index = this.models.indexOf(model);
        this.models.splice(index, 1);
        this.length--;
        delete this._byId[model.cid];
        const id = this.modelId(model.attributes);
        if (id != null) {
          delete this._byId[id];
        }
        if (!options.silent) {
          options.index = index;
          model.trigger('remove', model, this, options);
        }
        removed.push(model);
        this._removeReference(model);
      }
      return removed;
    }
    _addReference(model) {
      this._byId[model.cid] = model;
      const id = this.modelId(model.attributes);
      if (id != null) {
        this._byId[id] = model;
      }
      model.on('all', this._onModelEventBind);
    }
    _removeReference(model) {
      delete this._byId[model.cid];
      const id = this.modelId(model.attributes);
      if (id != null) {
        delete this._byId[id];
      }
      if (this === model.collection) {
        delete model.collection;
      }
      model.off('all', this._onModelEventBind);
    }
    _onModelEvent(event, model, collection, options) {
      // @todo Revise. Never triggerred? Remove?
      if (event === 'sync' && collection !== this) {
        return;
      }
      if (!model) {
        // @ts-ignore
        this.trigger.apply(this, arguments);
        return;
      }
      if ((event === 'add' || event === 'remove') && collection !== this) {
        return;
      }
      if (event === 'destroy') {
        this.remove(model, options);
      }
      if (event === 'change') {
        const prevId = this.modelId(model.previousAttributes());
        const id = this.modelId(model.attributes);
        if (prevId !== id) {
          if (prevId != null) {
            delete this._byId[prevId];
          }
          if (id != null) {
            this._byId[id] = model;
          }
        }
      }

      // @ts-ignore
      this.trigger.apply(this, arguments);
    }

    // noinspection JSDeprecatedSymbols
    _prepareModel(attributes) {
      if (this._isModel(attributes)) {
        if (!attributes.collection) {
          attributes.collection = this;
        }
        return attributes;
      }
      const ModelClass = this.model;

      // @ts-ignore
      return new ModelClass(attributes, {
        collection: this,
        // @ts-ignore
        entityType: this.entityType ?? this.name ?? undefined,
        defs: this.defs ?? undefined
      });
    }

    /**
     * Subscribe to an event.
     *
     * @param {string} name An event.
     * @param {function(...any)} callback A callback.
     */
    on(name, callback) {
      // The context argument is needed.
      _bullbone.Events.on.call(this, name, callback, arguments[2]);
      return this;
    }

    /**
     * Subscribe to an event. Fired once.
     *
     * @param {string} name An event.
     * @param {function(...any)} callback A callback.
     */
    once(name, callback) {
      // The context argument is needed.
      _bullbone.Events.once.call(this, name, callback, arguments[2]);
      return this;
    }

    /**
     * Unsubscribe from an event or all events.
     *
     * @param {string} [name] From a specific event.
     * @param {function()} [callback] From a specific callback.
     */
    off(name, callback) {
      // The context argument is needed.
      _bullbone.Events.off.call(this, name, callback, arguments[2]);
      return this;
    }

    /**
     * Subscribe to an event of other object.
     *
     * @param {Object} other What to listen.
     * @param {string} name An event.
     * @param callback A callback.
     */
    listenTo(other, name, callback) {
      _bullbone.Events.listenTo.call(this, other, name, callback);
      return this;
    }

    /**
     * Subscribe to an event of other object. Fired once. Will be automatically unsubscribed on view removal.
     *
     * @param {Object} other What to listen.
     * @param {string} name An event.
     * @param {function()} callback A callback.
     */
    listenToOnce(other, name, callback) {
      _bullbone.Events.listenToOnce.call(this, other, name, callback);
      return this;
    }

    /**
     * Stop listening to other object. No arguments will remove all listeners.
     *
     * @param {Object} [other] To remove listeners to a specific object.
     * @param {string} [name] To remove listeners to a specific event.
     * @param {function()} [callback] To remove listeners to a specific callback.
     */
    stopListening(other, name, callback) {
      _bullbone.Events.stopListening.call(this, other, name, callback);
      return this;
    }

    /**
     * Trigger an event.
     *
     * @param {string} name An event.
     * @param {...*} parameters Arguments.
     */
    trigger(name) {
      for (var _len = arguments.length, parameters = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
        parameters[_key - 1] = arguments[_key];
      }
      _bullbone.Events.trigger.call(this, name, ...parameters);
      return this;
    }
  }

  // @ts-ignore
  _exports.default = Collection;
  Collection.extend = _bullbone.View.extend;
  const setOptions = {
    add: true,
    remove: true,
    merge: true
  };
  const addOptions = {
    add: true,
    remove: false
  };
  const splice = (array, insert, at) => {
    at = Math.min(Math.max(at, 0), array.length);
    const tail = Array(array.length - at);
    const length = insert.length;
    for (let i = 0; i < tail.length; i++) {
      tail[i] = array[i + at];
    }
    for (let i = 0; i < length; i++) {
      array[i + at] = insert[i];
    }
    for (let i = 0; i < tail.length; i++) {
      array[i + length + at] = tail[i];
    }
  };
});

define("app-params", ["exports"], function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * Application parameters.
   *
   * @since 9.0.0
   */
  class AppParams {
    /**
     * @param {Record} params
     */
    constructor() {
      let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      /** @private */
      this.params = params;
    }

    /**
     * Get a parameter.
     *
     * @param {string} name A parameter.
     * @return {*}
     */
    get(name) {
      return this.params[name];
    }

    /**
     * Set all parameters.
     *
     * @internal
     * @param {Record} params
     */
    setAll(params) {
      this.params = params;
    }

    /**
     * Reload params from the backend.
     */
    async load() {
      /** @type {module:app~UserData} */
      const data = await Espo.Ajax.getRequest('App/appParams');
      this.params = data;
    }
  }
  _exports.default = AppParams;
});

define("acl", ["exports", "bullbone"], function (_exports, _bullbone) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module acl */

  /**
   * Internal class for access checking. Can be extended to customize access checking
   * for a specific scope.
   */
  class Acl {
    /**
     * @param {module:models/user} user A user.
     * @param {string} scope A scope.
     * @param {Object} params Parameters.
     * @param {import('acl-manager').default} aclManager
     */
    constructor(user, scope, params, aclManager) {
      /**
       * A user.
       *
       * @type {module:models/user|null}
       * @protected
       */
      this.user = user || null;
      this.scope = scope;
      params = params || {};
      this.aclAllowDeleteCreated = params.aclAllowDeleteCreated;
      this.teamsFieldIsForbidden = params.teamsFieldIsForbidden;

      /**
       * @type {string[]}
       */
      this.forbiddenFieldList = params.forbiddenFieldList || [];

      /**
       * @protected
       * @type {boolean}
       */
      this.collaboratorsFieldIsForbidden = this.forbiddenFieldList.includes('collaborators');

      /**
       * @type {import('acl-manager').default}
       * @private
       */
      this._aclManager = aclManager;
    }

    /**
     * Get a user.
     *
     * @returns {module:models/user}
     * @protected
     */
    getUser() {
      return this.user;
    }

    /**
     * Check access to a scope.
     *
     * @param {string|boolean|Object.<string, string>} data Access data.
     * @param {module:acl-manager~action|null} [action=null] An action.
     * @param {boolean} [precise=false] To return `null` if `inTeam == null`.
     * @param {Record.<string, boolean|null>|null} [entityAccessData=null] Entity access data. `inTeam`, `isOwner`.
     * @returns {boolean|null} True if access allowed.
     */
    checkScope(data, action, precise, entityAccessData) {
      entityAccessData = entityAccessData || {};
      const inTeam = entityAccessData.inTeam;
      const isOwner = entityAccessData.isOwner;
      const isShared = entityAccessData.isShared;
      if (this.getUser().isAdmin()) {
        if (data === false) {
          return false;
        }
        return true;
      }
      if (data === false) {
        return false;
      }
      if (data === true) {
        return true;
      }
      if (typeof data === 'string') {
        return true;
      }
      if (data === null) {
        return false;
      }
      action = action || null;
      if (action === null) {
        return true;
      }
      if (!(action in data)) {
        return false;
      }
      const value = data[action];
      if (value === 'all') {
        return true;
      }
      if (value === 'yes') {
        return true;
      }
      if (value === 'no') {
        return false;
      }
      if (isOwner === undefined) {
        return true;
      }
      if (isOwner) {
        if (value === 'own' || value === 'team') {
          return true;
        }
      }
      if (isShared) {
        return true;
      }
      if (inTeam) {
        if (value === 'team') {
          return true;
        }
      }
      let result = false;
      if (value === 'team') {
        if (inTeam === null && precise) {
          result = null;
        }
      }
      if (isOwner === null && precise) {
        result = null;
      }
      if (isShared === null) {
        result = null;
      }
      return result;
    }

    /**
     * Check access to model (entity).
     *
     * @param {module:model} model A model.
     * @param {Object.<string, string>|string|null} data Access data.
     * @param {module:acl-manager~action|null} [action=null] Action to check.
     * @param {boolean} [precise=false] To return `null` if not enough data is set in a model.
     *   E.g. the `teams` field is not yet loaded.
     * @returns {boolean|null} True if access allowed, null if not enough data to determine.
     */
    checkModel(model, data, action, precise) {
      if (this.getUser().isAdmin()) {
        return true;
      }
      let isShared = false;
      if (action === 'read' || action === 'stream') {
        isShared = this.checkIsShared(model);
      }
      const entityAccessData = {
        isOwner: this.checkIsOwner(model),
        inTeam: this.checkInTeam(model),
        isShared: isShared
      };
      return this.checkScope(data, action, precise, entityAccessData);
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * Check `delete` access to model.
     *
     * @param {module:model} model A model.
     * @param {Object.<string, string>|string|null} data Access data.
     * @param {boolean} [precise=false] To return `null` if not enough data is set in a model.
     *   E.g. the `teams` field is not yet loaded.
     * @returns {boolean} True if access allowed.
     */
    checkModelDelete(model, data, precise) {
      const result = this.checkModel(model, data, 'delete', precise);
      if (result) {
        return true;
      }
      if (data === false) {
        return false;
      }
      const d = data || {};
      if (d.read === 'no') {
        return false;
      }
      if (model.has('createdById') && model.get('createdById') === this.getUser().id && this.aclAllowDeleteCreated) {
        if (!model.has('assignedUserId')) {
          return true;
        }
        if (!model.get('assignedUserId')) {
          return true;
        }
        if (model.get('assignedUserId') === this.getUser().id) {
          return true;
        }
      }
      return result;
    }

    /**
     * Check if a user is owner to a model.
     *
     * @param {module:model} model A model.
     * @returns {boolean|null} True if owner. Null if not clear.
     */
    checkIsOwner(model) {
      let result = false;
      if (model.hasField('assignedUser')) {
        if (this.getUser().id === model.get('assignedUserId')) {
          return true;
        }
        if (!model.has('assignedUserId')) {
          result = null;
        }
      } else if (model.hasField('createdBy')) {
        if (this.getUser().id === model.get('createdById')) {
          return true;
        }
        if (!model.has('createdById')) {
          result = null;
        }
      }
      if (model.hasField('assignedUsers')) {
        if (!model.has('assignedUsersIds')) {
          return null;
        }
        if ((model.get('assignedUsersIds') || []).includes(this.getUser().id)) {
          return true;
        }
        result = false;
      }
      return result;
    }

    /**
     * Check if a user in a team of a model.
     *
     * @param {module:model} model A model.
     * @returns {boolean|null} True if in a team. Null if not enough data to determine.
     */
    checkInTeam(model) {
      const userTeamIdList = this.getUser().getTeamIdList();
      if (!model.has('teamsIds')) {
        if (this.teamsFieldIsForbidden) {
          return true;
        }
        if (!model.hasField('teams')) {
          return false;
        }
        return null;
      }
      const teamIdList = model.getTeamIdList();
      let inTeam = false;
      userTeamIdList.forEach(id => {
        if (teamIdList.includes(id)) {
          inTeam = true;
        }
      });
      return inTeam;
    }

    /**
     * Check if a record is shared with the user.
     *
     * @param {module:model} model A model.
     * @returns {boolean|null} True if shared. Null if not enough data to determine.
     */
    checkIsShared(model) {
      if (!model.has('collaboratorsIds')) {
        if (this.collaboratorsFieldIsForbidden) {
          return true;
        }
        if (!model.hasField('collaborators')) {
          return false;
        }
        return null;
      }
      const collaboratorsIds = model.getLinkMultipleIdList('collaborators');
      return collaboratorsIds.includes(this.user.id);
    }

    /**
     * Get a permission level.
     *
     * @protected
     * @param {string} permission A permission name.
     * @returns {'yes'|'all'|'team'|'no'}
     */
    getPermissionLevel(permission) {
      return this._aclManager.getPermissionLevel(permission);
    }
  }
  Acl.extend = _bullbone.View.extend;
  var _default = _exports.default = Acl;
});

define("view", ["exports", "bullbone", "ui"], function (_exports, _bullbone, _ui) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _ui = _interopRequireDefault(_ui);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * @param {MouseEvent} event DOM event.
   * @param {HTMLElement} includeInactive A target element.
   */

  /**
   * A base view. All views should extend this class.
   *
   * @see https://docs.espocrm.com/development/view/
   */
  class View extends _bullbone.View {
    /**
     * A model.
     */

    /**
     * A collection.
     */

    /**
     * Options.
     */

    /**
     * @param options Options.
     */
    constructor() {
      let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      super(options);
      if (options.model) {
        this.model = options.model;
      }
      if (options.collection) {
        this.collection = options.collection;
      }
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * When the view is ready. Can be useful to prevent race condition when re-initialization is needed
     * in-between initialization and render.
     *
     * @todo Move to Bull.View.
     */
    whenReady() {
      if (this.isReady) {
        return Promise.resolve();
      }
      return new Promise(resolve => {
        this.once('ready', () => resolve());
      });
    }

    /**
     * Add a DOM click event handler for a target defined by `data-action="{name}"` attribute.
     *
     * @param action An action name.
     * @param handler A handler.
     */
    addActionHandler(action, handler) {
      // The key should be in sync with one in Utils.handleAction.
      const fullAction = `click [data-action="${action}"]`;
      this.events[fullAction] = e => {
        // noinspection JSUnresolvedReference
        handler.call(this, e.originalEvent, e.currentTarget);
      };
    }

    /**
     * Escape a string.
     */
    escapeString(string) {
      return Handlebars.Utils.escapeExpression(string);
    }

    /**
     * Show a notify-message.
     *
     * @deprecated Use `Espo.Ui.notify`.
     * @param {string|false} label
     * @param {string} [type]
     * @param {number} [timeout]
     * @param {string} [scope]
     */
    notify(label, type, timeout, scope) {
      if (!label) {
        // @ts-ignore
        _ui.default.notify(false);
        return;
      }
      let timeoutInternal = timeout || 2000;
      if (!type) {
        timeoutInternal = undefined;
      }
      const text = this.getLanguage().translate(label, 'labels', scope || undefined);

      // @ts-ignore
      _ui.default.notify(text, type, timeoutInternal);
    }

    /**
     * Get a view-helper.
     */
    getHelper() {
      return this._helper;
    }

    /**
     * Get a current user.
     */
    getUser() {
      // @ts-ignore
      return this._helper.user;
    }

    /**
     * Get the preferences.
     */
    getPreferences() {
      // @ts-ignore
      return this._helper.preferences;
    }

    /**
     * Get the config.
     */
    getConfig() {
      // @ts-ignore
      return this._helper.settings;
    }

    /**
     * Get the ACL.
     */
    getAcl() {
      // @ts-ignore
      return this._helper.acl;
    }

    /**
     * Get the model factory.
     */
    getModelFactory() {
      // @ts-ignore
      return this._helper.modelFactory;
    }

    /**
     * Get the collection factory.
     */
    getCollectionFactory() {
      // @ts-ignore
      return this._helper.collectionFactory;
    }

    /**
     * Get the router.
     */
    getRouter() {
      // @ts-ignore
      return this._helper.router;
    }

    /**
     * Get the storage-util.
     */
    getStorage() {
      // @ts-ignore
      return this._helper.storage;
    }

    /**
     * Get the session-storage-util.
     */
    getSessionStorage() {
      // @ts-ignore
      return this._helper.sessionStorage;
    }

    /**
     * Get the language-util.
     */
    getLanguage() {
      // @ts-ignore
      return this._helper.language;
    }

    /**
     * Get metadata.
     */
    getMetadata() {
      // @ts-ignore
      return this._helper.metadata;
    }

    /**
     * Get the cache-util.
     */
    getCache() {
      // @ts-ignore
      return this._helper.cache;
    }

    /**
     * Get the date-time util.
     */
    getDateTime() {
      // @ts-ignore
      return this._helper.dateTime;
    }

    /**
     * Get the number-util.
     */
    getNumberUtil() {
      // @ts-ignore
      return this._helper.numberUtil;
    }

    /**
     * Get the field manager.
     */
    getFieldManager() {
      // @ts-ignore
      return this._helper.fieldManager;
    }

    /**
     * Get the base-controller.
     *
     * @internal
     */
    getBaseController() {
      // @ts-ignore
      return this._helper.baseController;
    }

    /**
     * Get the theme manager.
     */
    getThemeManager() {
      // @ts-ignore
      return this._helper.themeManager;
    }

    /**
     * Update a page title. Supposed to be overridden if needed.
     */
    updatePageTitle() {
      const title = this.getConfig().get('applicationName') || 'EspoCRM';
      this.setPageTitle(title);
    }

    /**
     * Set a page title.
     *
     * @param title A title.
     */
    setPageTitle(title) {
      this.getHelper().pageTitle.setTitle(title);
    }

    /**
     * Translate a label.
     *
     * @param label Label.
     * @param [category='labels'] Category.
     * @param [scope='Global'] Scope.
     * @returns {string}
     */
    translate(label, category, scope) {
      return this.getLanguage().translate(label, category, scope);
    }

    /**
     * Get a base path.
     */
    getBasePath() {
      // @ts-ignore
      return this._helper.basePath || '';
    }

    /**
     * Show a confirmation dialog.
     *
     * @param options A message or options.
     * @param [callback] A callback. Deprecated, use a promise.
     * @param [context] A context. Deprecated.
     * @returns {Promise} To be resolved if confirmed.
     */
    confirm(options) {
      let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
      let context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
      let message;
      let o;
      if (typeof options === 'string' || options instanceof String) {
        message = options.toString();
        o = {};
      } else {
        o = options ?? {};
        message = options.message;
      }
      if (message) {
        message = this.getHelper().transformMarkdownText(message, {
          linksInNewTab: true
        }).toString();
      }
      const confirmText = options.confirmText || this.translate('Yes');
      const confirmStyle = options.confirmStyle || null;
      const cancelText = options.cancelText || this.translate('Cancel');
      return _ui.default.confirm(message, {
        confirmText: confirmText,
        cancelText: cancelText,
        confirmStyle: confirmStyle ?? undefined,
        backdrop: 'backdrop' in o ? o.backdrop : true,
        isHtml: true,
        cancelCallback: options.cancelCallback
      }, callback, context);
    }
  }
  _exports.default = View;
});

define("view-helper", ["exports", "marked", "dompurify", "handlebars"], function (_exports, _marked, _dompurify, _handlebars) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _dompurify = _interopRequireDefault(_dompurify);
  _handlebars = _interopRequireDefault(_handlebars);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module view-helper */

  /**
   * A view helper.
   */
  class ViewHelper {
    constructor() {
      this._registerHandlebarsHelpers();

      /** @private */
      this.mdBeforeList = [
      /*{
          regex: /```\n?([\s\S]*?)```/g,
          value: (s, string) => {
              return '```\n' + string.replace(/\\\>/g, '>') + '```';
          },
      },*/
      {
        // Also covers triple-backtick blocks.
        regex: /`([\s\S]*?)`/g,
        value: (s, string) => {
          // noinspection RegExpRedundantEscape
          return '`' + string.replace(/\\\</g, '<') + '`';
        }
      }];
      _marked.marked.setOptions({
        breaks: true,
        tables: false,
        headerIds: false
      });

      // @todo Review after updating the marked library.
      _marked.marked.use({
        tokenizer: {
          tag(src) {
            const cap = _marked.Lexer.rules.inline.tag.exec(src);
            if (!cap) {
              return;
            }
            return {
              type: 'text',
              raw: cap[0],
              inLink: this.lexer.state.inLink,
              inRawBlock: this.lexer.state.inRawBlock,
              text: _handlebars.default.Utils.escapeExpression(cap[0])
            };
          },
          html(src) {
            const cap = _marked.Lexer.rules.block.html.exec(src);
            if (!cap) {
              return;
            }
            const token = {
              type: 'paragraph',
              raw: cap[0],
              pre: cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style',
              text: _handlebars.default.Utils.escapeExpression(cap[0])
            };
            token.tokens = [];
            this.lexer.inline(token.text, token.tokens);
            return token;
          }
        }
      });
      _dompurify.default.addHook('beforeSanitizeAttributes', function (node) {
        if (node instanceof HTMLAnchorElement) {
          if (node.getAttribute('target')) {
            node.targetBlank = true;
          } else {
            node.targetBlank = false;
          }
        }
        if (node instanceof HTMLOListElement && node.start && node.start > 99) {
          node.removeAttribute('start');
        }
        if (node instanceof HTMLFormElement) {
          if (node.action) {
            node.removeAttribute('action');
          }
          if (node.hasAttribute('method')) {
            node.removeAttribute('method');
          }
        }
        if (node instanceof HTMLButtonElement) {
          if (node.type === 'submit') {
            node.type = 'button';
          }
        }
      });
      _dompurify.default.addHook('afterSanitizeAttributes', function (node) {
        if (node instanceof HTMLAnchorElement) {
          const href = node.getAttribute('href');
          if (href && !href.startsWith('#')) {
            node.setAttribute('rel', 'noopener noreferrer');
          }
          if (node.targetBlank) {
            node.setAttribute('target', '_blank');
            node.setAttribute('rel', 'noopener noreferrer');
          }
        }
      });
      _dompurify.default.addHook('uponSanitizeAttribute', (node, data) => {
        if (data.attrName === 'style') {
          const style = data.attrValue.split(';').map(s => s.trim()).filter(rule => {
            const [property, value] = rule.split(':').map(s => s.trim().toLowerCase());
            if (property === 'position' && ['absolute', 'fixed', 'sticky'].includes(value)) {
              return false;
            }
            return true;
          });
          data.attrValue = style.join('; ');
        }
      });
    }

    /**
     * A layout manager.
     *
     * @type {module:layout-manager}
     */
    layoutManager = null;

    /**
     * A config.
     *
     * @type {module:models/settings}
     */
    settings = null;

    /**
     * A config.
     *
     * @type {module:models/settings}
     */
    config = null;

    /**
     * A current user.
     *
     * @type {module:models/user}
     */
    user = null;

    /**
     * A preferences.
     *
     * @type {module:models/preferences}
     */
    preferences = null;

    /**
     * An ACL manager.
     *
     * @type {module:acl-manager}
     */
    acl = null;

    /**
     * A model factory.
     *
     * @type {module:model-factory}
     */
    modelFactory = null;

    /**
     * A collection factory.
     *
     * @type {module:collection-factory}
     */
    collectionFactory = null;

    /**
     * A router.
     *
     * @type {import('router').default}
     */
    router = null;

    /**
     * A storage.
     *
     * @type {import('storage').default}
     */
    storage = null;

    /**
     * A session storage.
     *
     * @type {module:session-storage}
     */
    sessionStorage = null;

    /**
     * A date-time util.
     *
     * @type {module:date-time}
     */
    dateTime = null;

    /**
     * A language.
     *
     * @type {module:language}
     */
    language = null;

    /**
     * A metadata.
     *
     * @type {module:metadata}
     */
    metadata = null;

    /**
     * A field-manager util.
     *
     * @type {module:field-manager}
     */
    fieldManager = null;

    /**
     * A cache.
     *
     * @type {module:cache}
     */
    cache = null;

    /**
     * A theme manager.
     *
     * @type {module:theme-manager}
     */
    themeManager = null;

    /**
     * A web-socket manager. Null if not enabled.
     *
     * @type {module:web-socket-manager|null}
     */
    webSocketManager = null;

    /**
     * A number util.
     *
     * @type {module:num-util}
     */
    numberUtil = null;

    /**
     * A page-title util.
     *
     * @type {module:page-title}
     */
    pageTitle = null;

    /**
     * A broadcast channel.
     *
     * @type {?module:broadcast-channel}
     */
    broadcastChannel = null;

    /**
     * A base path.
     *
     * @type {string}
     */
    basePath = '';

    /**
     * Application parameters.
     *
     * @type {import('app-params').default|null}
     */
    appParams = null;

    /**
     * @private
     */
    _registerHandlebarsHelpers() {
      _handlebars.default.registerHelper('img', img => {
        return new _handlebars.default.SafeString(`<img src="img/${img}" alt="img">`);
      });
      _handlebars.default.registerHelper('prop', (object, name) => {
        if (object === undefined) {
          console.warn(`Undefined value passed to 'prop' helper.`);
          return undefined;
        }
        if (name in object) {
          return object[name];
        }
        return undefined;
      });
      _handlebars.default.registerHelper('var', (name, context, options) => {
        if (typeof context === 'undefined') {
          return null;
        }
        let contents = context[name];
        if (options.hash.trim) {
          contents = contents.trim();
        }
        return new _handlebars.default.SafeString(contents);
      });
      _handlebars.default.registerHelper('concat', function (left, right) {
        return left + right;
      });
      _handlebars.default.registerHelper('ifEqual', function (left, right, options) {
        // noinspection EqualityComparisonWithCoercionJS
        if (left == right) {
          return options.fn(this);
        }
        return options.inverse(this);
      });
      _handlebars.default.registerHelper('ifNotEqual', function (left, right, options) {
        // noinspection EqualityComparisonWithCoercionJS
        if (left != right) {
          return options.fn(this);
        }
        return options.inverse(this);
      });
      _handlebars.default.registerHelper('ifPropEquals', function (object, property, value, options) {
        // noinspection EqualityComparisonWithCoercionJS
        if (object[property] == value) {
          return options.fn(this);
        }
        return options.inverse(this);
      });
      _handlebars.default.registerHelper('ifAttrEquals', function (model, attr, value, options) {
        // noinspection EqualityComparisonWithCoercionJS
        if (model.get(attr) == value) {
          return options.fn(this);
        }
        return options.inverse(this);
      });
      _handlebars.default.registerHelper('ifAttrNotEmpty', function (model, attr, options) {
        const value = model.get(attr);
        if (value !== null && typeof value !== 'undefined') {
          return options.fn(this);
        }
        return options.inverse(this);
      });
      _handlebars.default.registerHelper('get', (model, name) => model.get(name));
      _handlebars.default.registerHelper('length', arr => arr.length);
      _handlebars.default.registerHelper('translate', (name, options) => {
        const scope = options.hash.scope || null;
        const category = options.hash.category || null;
        if (name === 'null') {
          return '';
        }
        return this.language.translate(name, category, scope);
      });
      _handlebars.default.registerHelper('dropdownItem', (name, options) => {
        const scope = options.hash.scope || null;
        const label = options.hash.label;
        const labelTranslation = options.hash.labelTranslation;
        const data = options.hash.data;
        const hidden = options.hash.hidden;
        const disabled = options.hash.disabled;
        const title = options.hash.title;
        const link = options.hash.link;
        const action = options.hash.action || name;
        const iconHtml = options.hash.iconHtml;
        const iconClass = options.hash.iconClass;
        let html = options.hash.html || options.hash.text || (labelTranslation ? this.language.translatePath(labelTranslation) : this.language.translate(label, 'labels', scope));
        if (!options.hash.html) {
          html = this.escapeString(html);
        }
        if (iconHtml) {
          html = iconHtml + '' + html;
        } else if (iconClass) {
          const iconHtml = $('<span>').addClass(iconClass).addClass('item-icon').get(0).outerHTML;
          html = '<span class="item-text">' + html + '</span>';
          html = iconHtml + html;
        } else {
          if (!options.hash.html) {
            html = '<span class="item-text">' + html + '</span>';
          }
        }
        const $li = $('<li>').addClass(hidden ? 'hidden' : '').addClass(disabled ? 'disabled' : '');
        const $a = $('<a>').attr('role', 'button').attr('tabindex', '0').attr('data-name', name).addClass(options.hash.className || '').addClass('action').html(html);
        if (action) {
          $a.attr('data-action', action);
        }
        $li.append($a);
        link ? $a.attr('href', link) : $a.attr('role', 'button');
        if (data) {
          for (const key in data) {
            $a.attr('data-' + Espo.Utils.camelCaseToHyphen(key), data[key]);
          }
        }
        if (disabled) {
          $li.attr('disabled', 'disabled');
        }
        if (title) {
          $a.attr('title', title);
        }
        return new _handlebars.default.SafeString($li.get(0).outerHTML);
      });
      _handlebars.default.registerHelper('button', (name, options) => {
        const style = options.hash.style || 'default';
        const scope = options.hash.scope || null;
        const label = options.hash.label || name;
        const labelTranslation = options.hash.labelTranslation;
        const link = options.hash.link;
        const iconHtml = options.hash.iconHtml;
        const iconClass = options.hash.iconClass;
        let html = options.hash.html || options.hash.text || (labelTranslation ? this.language.translatePath(labelTranslation) : this.language.translate(label, 'labels', scope));
        if (!options.hash.html) {
          html = this.escapeString(html);
        }
        if (iconHtml) {
          html = iconHtml + ' ' + '<span>' + html + '</span>';
        } else if (iconClass) {
          const iconHtml = $('<span>').addClass(iconClass).get(0).outerHTML;
          html = iconHtml + ' ' + '<span>' + html + '</span>';
        }
        const tag = link ? '<a>' : '<button>';
        const $button = $(tag).addClass('btn action').addClass(options.hash.className || '').addClass(options.hash.hidden ? 'hidden' : '').addClass(options.hash.disabled ? 'disabled' : '').attr('data-action', name).attr('data-name', name).addClass('btn-' + style).html(html);
        link ? $button.href(link) : $button.attr('type', 'button');
        if (options.hash.disabled) {
          $button.attr('disabled', 'disabled');
        }
        if (options.hash.title) {
          $button.attr('title', options.hash.title);
        }
        return new _handlebars.default.SafeString($button.get(0).outerHTML);
      });
      _handlebars.default.registerHelper('hyphen', string => {
        return Espo.Utils.convert(string, 'c-h');
      });
      _handlebars.default.registerHelper('toDom', string => {
        return Espo.Utils.toDom(string);
      });

      // noinspection SpellCheckingInspection
      _handlebars.default.registerHelper('breaklines', text => {
        text = _handlebars.default.Utils.escapeExpression(text || '');
        text = text.replace(/(\r\n|\n|\r)/gm, '<br>');
        return new _handlebars.default.SafeString(text);
      });
      _handlebars.default.registerHelper('complexText', (text, options) => {
        if (typeof text !== 'string' && !(text instanceof String)) {
          return '';
        }
        return this.transformMarkdownText(text, options.hash);
      });
      _handlebars.default.registerHelper('translateOption', (name, options) => {
        const scope = options.hash.scope || null;
        const field = options.hash.field || null;
        if (!field) {
          return '';
        }
        let translationHash = options.hash.translatedOptions || null;
        if (translationHash === null) {
          translationHash = this.language.translate(/** @type {string} */field, 'options', scope) || {};
          if (typeof translationHash !== 'object') {
            translationHash = {};
          }
        }
        if (name === null) {
          name = '';
        }
        return translationHash[name] || name;
      });
      _handlebars.default.registerHelper('options', (/** any[] */list, value, options) => {
        if (typeof value === 'undefined') {
          value = false;
        }
        list = list || [];
        let html = '';
        const multiple = Object.prototype.toString.call(value) === '[object Array]';
        const checkOption = name => {
          if (multiple) {
            return value.indexOf(name) !== -1;
          }
          return value === name || !value && !name && name !== 0;
        };
        options.hash = /** @type {Record} */options.hash || {};
        const scope = options.hash.scope || false;
        const category = options.hash.category || false;
        const field = options.hash.field || false;
        const styleMap = options.hash.styleMap || {};
        if (!multiple && options.hash.includeMissingOption && (value || value === '')) {
          if (!list.includes(value)) {
            list = Espo.Utils.clone(list);
            list.push(value);
          }
        }
        let translationHash = options.hash.translationHash || options.hash.translatedOptions || null;
        if (translationHash === null) {
          translationHash = {};
          if (!category && field) {
            translationHash = this.language.translate(/** @type {string} */field, 'options', /** @type {string} */scope) || {};
            if (typeof translationHash !== 'object') {
              translationHash = {};
            }
          }
        }
        const translate = name => {
          if (!category) {
            return translationHash[name] || name;
          }
          return this.language.translate(name, category, /** @type {string} */scope);
        };
        for (const key in list) {
          const value = list[key];
          const label = translate(value);
          const $option = $('<option>').attr('value', value).addClass(styleMap[value] ? 'text-' + styleMap[value] : '').text(label);
          if (checkOption(list[key])) {
            $option.attr('selected', 'selected');
          }
          html += $option.get(0).outerHTML;
        }
        return new _handlebars.default.SafeString(html);
      });
      _handlebars.default.registerHelper('basePath', () => {
        return this.basePath || '';
      });
    }

    /**
     * Get an application parameter.
     *
     * @param {string} name
     * @returns {*}
     */
    getAppParam(name) {
      if (!this.appParams) {
        return undefined;
      }
      return this.appParams.get(name);
    }

    /**
     * Escape a string.
     *
     * @param {string} text A string.
     * @returns {string}
     */
    escapeString(text) {
      return _handlebars.default.Utils.escapeExpression(text);
    }

    /**
     * Get a user avatar HTML.
     *
     * @param {string} id A user ID.
     * @param {'small'|'medium'|'large'} [size='small'] A size.
     * @param {int} [width=16]
     * @param {string} [additionalClassName]  An additional class-name.
     * @returns {string}
     */
    getAvatarHtml(id, size, width, additionalClassName) {
      if (this.config.get('avatarsDisabled')) {
        return '';
      }
      const t = this.cache ? this.cache.get('app', 'timestamp') : this.settings.get('cacheTimestamp');
      const basePath = this.basePath || '';
      size = size || 'small';
      width = width || 16;
      let className = 'avatar';
      if (additionalClassName) {
        className += ' ' + additionalClassName;
      }

      // noinspection RequiredAttributes,HtmlRequiredAltAttribute
      return $(`<img>`).attr('src', `${basePath}?entryPoint=avatar&size=${size}&id=${id}&t=${t}`).attr('alt', 'avatar').addClass(className).attr('data-width', width.toString()).css('width', `var(--${width.toString()}px)`).attr('draggable', 'false').get(0).outerHTML;
    }

    /**
     * A Markdown text to HTML (one-line).
     *
     * @param {string} text A text.
     * @returns {Handlebars.SafeString} HTML.
     */
    transformMarkdownInlineText(text) {
      return this.transformMarkdownText(text, {
        inline: true
      });
    }

    /**
     * A Markdown text to HTML.
     *
     * @param {string} text A text.
     * @param {{inline?: boolean, linksInNewTab?: boolean}} [options] Options.
     * @returns {Handlebars.SafeString} HTML.
     */
    transformMarkdownText(text, options) {
      text = text || '';
      this.mdBeforeList.forEach(item => {
        text = text.replace(item.regex, item.value);
      });
      options = options || {};
      text = options.inline ? _marked.marked.parseInline(text) : _marked.marked.parse(text);
      text = _dompurify.default.sanitize(text, {}).toString();
      if (options.linksInNewTab) {
        text = text.replace(/<a href=/gm, '<a target="_blank" rel="noopener noreferrer" href=');
      }
      text = text.replace(/<a href="mailto:([^"]*)"/gm, '<a role="button" class="selectable" data-email-address="$1" data-action="mailTo"');
      return new _handlebars.default.SafeString(text);
    }

    /**
     * Get a color-icon HTML for a scope.
     *
     * @param {string} scope A scope.
     * @param {boolean} [noWhiteSpace=false] No white space.
     * @param {string} [additionalClassName] An additional class-name.
     * @returns {string}
     */
    getScopeColorIconHtml(scope, noWhiteSpace, additionalClassName) {
      if (this.config.get('scopeColorsDisabled') || this.preferences.get('scopeColorsDisabled')) {
        return '';
      }
      const color = this.metadata.get(['clientDefs', scope, 'color']);
      let html = '';
      if (color) {
        const $span = $('<span class="color-icon fas fa-square">');
        $span.css('color', color);
        if (additionalClassName) {
          $span.addClass(additionalClassName);
        }
        html = $span.get(0).outerHTML;
      }
      if (!noWhiteSpace && html) {
        html += `<span style="user-select: none;">&nbsp;</span>`;
      }
      return html;
    }

    /**
     * Sanitize HTML.
     *
     * @param {string} text An HTML.
     * @returns {string}
     */
    sanitizeHtml(text) {
      return _dompurify.default.sanitize(text).toString();
    }

    /**
     * Moderately sanitize HTML.
     *
     * @param {string} value An HTML.
     * @returns {string}
     */
    moderateSanitizeHtml(value) {
      const params = {
        ADD_ATTR: ['x-if', 'iterate'],
        ADD_TAGS: ['#comment']
      };
      return _dompurify.default.sanitize(value || '', params).toString();
    }

    /**
     * Calculate a content container height.
     *
     * @param {HTMLElement|JQuery} element An element.
     * @returns {number}
     */
    calculateContentContainerHeight(element) {
      const smallScreenWidth = this.themeManager.getParam('screenWidthXs');
      const $window = $(window);
      const footerHeight = $('#footer').height() || 26;
      let top = 0;
      element = $(element).get(0);
      if (element) {
        top = element.getBoundingClientRect().top;
        if ($window.width() < smallScreenWidth) {
          const $navbarCollapse = $('#navbar .navbar-body');
          if ($navbarCollapse.hasClass('in') || $navbarCollapse.hasClass('collapsing')) {
            top -= $navbarCollapse.height();
          }
        }
      }
      const spaceHeight = top + footerHeight;
      return $window.height() - spaceHeight - 20;
    }

    /**
     * Process view-setup-handlers.
     *
     * @param {import('view').default<any>} view A view.
     * @param {string} type A view-setup-handler type.
     * @param {string} [scope] A scope.
     * @return Promise
     */
    processSetupHandlers(view, type, scope) {
      // noinspection JSUnresolvedReference
      scope = scope || view.scope || view.entityType;
      let handlerIdList = this.metadata.get(['clientDefs', 'Global', 'viewSetupHandlers', type]) || [];
      if (scope) {
        handlerIdList = handlerIdList.concat(this.metadata.get(['clientDefs', scope, 'viewSetupHandlers', type]) || []);
      }
      if (handlerIdList.length === 0) {
        return Promise.resolve();
      }

      /**
       * @interface
       * @name ViewHelper~Handler
       */

      /**
       * @function
       * @name ViewHelper~Handler#process
       * @param {import('view').default} [view] Deprecated.
       */
      const promiseList = [];
      for (const id of handlerIdList) {
        const promise = new Promise(resolve => {
          Espo.loader.require(id, /** typeof ViewHelper~Handler */Handler => {
            const result = new Handler(view).process(view);
            if (result && Object.prototype.toString.call(result) === '[object Promise]') {
              result.then(() => resolve());
              return;
            }
            resolve();
          });
        });
        promiseList.push(promise);
      }
      return Promise.all(promiseList);
    }

    /** @private */
    _isXsScreen;

    /**
     * Is xs screen width.
     *
     * @return {boolean}
     */
    isXsScreen() {
      if (this._isXsScreen == null) {
        this._isXsScreen = window.innerWidth < this.themeManager.getParam('screenWidthXs');
      }
      return this._isXsScreen;
    }
  }
  var _default = _exports.default = ViewHelper;
});

define("acl-manager", ["exports", "acl", "utils", "bullbone"], function (_exports, _acl, _utils, _bullbone) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _acl = _interopRequireDefault(_acl);
  _utils = _interopRequireDefault(_utils);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module acl-manager */

  /**
   * An action.
   *
   * @typedef {'create'|'read'|'edit'|'delete'|'stream'} module:acl-manager~action
   */

  /**
   * An access checking class for a specific scope.
   */
  class AclManager {
    /** @protected */
    data = null;
    fieldLevelList = ['yes', 'no'];

    /**
     * @param {module:models/user} user A user.
     * @param {Object} implementationClassMap `acl` implementations.
     * @param {boolean} aclAllowDeleteCreated Allow a user to delete records they created regardless a
     *   role access level.
     */
    constructor(user, implementationClassMap, aclAllowDeleteCreated) {
      this.setEmpty();

      /** @protected */
      this.user = user || null;
      this.implementationClassMap = implementationClassMap || {};
      this.aclAllowDeleteCreated = aclAllowDeleteCreated;
    }

    /**
     * @protected
     */
    setEmpty() {
      this.data = {
        table: {},
        fieldTable: {},
        fieldTableQuickAccess: {}
      };
      this.implementationHash = {};
      this.forbiddenFieldsCache = {};
      this.implementationClassMap = {};
      this.forbiddenAttributesCache = {};
    }

    /**
     * Get an `acl` implementation.
     *
     * @protected
     * @param {string} scope A scope.
     * @returns {module:acl}
     */
    getImplementation(scope) {
      if (!(scope in this.implementationHash)) {
        let implementationClass = _acl.default;
        if (scope in this.implementationClassMap) {
          implementationClass = this.implementationClassMap[scope];
        }
        const forbiddenFieldList = this.getScopeForbiddenFieldList(scope);
        const params = {
          aclAllowDeleteCreated: this.aclAllowDeleteCreated,
          teamsFieldIsForbidden: forbiddenFieldList.includes('teams'),
          forbiddenFieldList: forbiddenFieldList
        };
        this.implementationHash[scope] = new implementationClass(this.getUser(), scope, params, this);
      }
      return this.implementationHash[scope];
    }

    /**
     * @return {import('models/user').default}
     * @protected
     */
    getUser() {
      return this.user;
    }

    /**
     * @internal
     */
    set(data) {
      data = data || {};
      this.data = data;
      this.data.table = this.data.table || {};
      this.data.fieldTable = this.data.fieldTable || {};
      this.data.attributeTable = this.data.attributeTable || {};
    }

    /**
     * @deprecated Use `getPermissionLevel`.
     *
     * @returns {string|null}
     */
    get(name) {
      return this.data[name] || null;
    }

    /**
     * Get a permission level.
     *
     * @param {string} permission A permission name.
     * @returns {'yes'|'all'|'team'|'no'}
     */
    getPermissionLevel(permission) {
      let permissionKey = permission;
      if (permission.slice(-10) !== 'Permission') {
        permissionKey = permission + 'Permission';
      }
      return this.data[permissionKey] || 'no';
    }

    /**
     * Get access level to a scope action.
     *
     * @param {string} scope A scope.
     * @param {module:acl-manager~action} action An action.
     * @returns {'yes'|'all'|'team'|'own'|'no'|null}
     */
    getLevel(scope, action) {
      if (!(scope in this.data.table)) {
        return null;
      }
      const scopeItem = this.data.table[scope];
      if (typeof scopeItem !== 'object' || !(action in scopeItem)) {
        return null;
      }
      return scopeItem[action];
    }

    /**
     * Clear access data.
     *
     * @internal
     */
    clear() {
      this.setEmpty();
    }

    /**
     * Check whether a scope has ACL.
     *
     * @param {string} scope A scope.
     * @returns {boolean}
     */
    checkScopeHasAcl(scope) {
      const data = (this.data.table || {})[scope];
      if (typeof data === 'undefined') {
        return false;
      }
      return true;
    }

    /**
     * Check access to a scope.
     *
     * @param {string} scope A scope.
     * @param {module:acl-manager~action|null} [action=null] An action.
     * @param {boolean} [precise=false] Deprecated. Not used.
     * @returns {boolean} True if access allowed.
     */
    checkScope(scope, action, precise) {
      let data = (this.data.table || {})[scope];
      if (typeof data === 'undefined') {
        data = null;
      }
      return this.getImplementation(scope).checkScope(data, action, precise);
    }

    /**
     * Check access to a model.
     *
     * @param {module:model} model A model.
     * @param {module:acl-manager~action|null} [action=null] An action.
     * @param {boolean} [precise=false] To return `null` if not enough data is set in a model.
     *   E.g. the `teams` field is not yet loaded.
     * @returns {boolean|null} True if access allowed, null if not enough data to determine.
     */
    checkModel(model, action, precise) {
      const scope = model.entityType;

      // todo move this to custom acl
      if (action === 'edit') {
        if (!model.isEditable()) {
          return false;
        }
      }
      if (action === 'delete') {
        if (!model.isRemovable()) {
          return false;
        }
      }
      let data = (this.data.table || {})[scope];
      if (typeof data === 'undefined') {
        data = null;
      }
      const impl = this.getImplementation(scope);
      if (action) {
        const methodName = 'checkModel' + _utils.default.upperCaseFirst(action);
        if (methodName in impl) {
          return impl[methodName](model, data, precise);
        }
      }
      return impl.checkModel(model, data, action, precise);
    }

    /**
     * Check access to a scope or a model.
     *
     * @param {string|module:model} subject What to check. A scope or a model.
     * @param {module:acl-manager~action|null} [action=null] An action.
     * @param {boolean} [precise=false]  To return `null` if not enough data is set in a model.
     *   E.g. the `teams` field is not yet loaded.
     * @returns {boolean|null} True if access allowed, null if not enough data to determine.
     */
    check(subject, action, precise) {
      if (typeof subject === 'string') {
        return this.checkScope(subject, action, precise);
      }
      if (!subject) {
        throw new Error("No model.");
      }
      return this.checkModel(subject, action, precise);
    }

    /**
     * Check if a user is owner to a model.
     *
     * @param {module:model} model A model.
     * @returns {boolean|null} True if owner, null if not clear.
     */
    checkIsOwner(model) {
      return this.getImplementation(model.entityType).checkIsOwner(model);
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * Check if a user in a team of a model.
     *
     * @param {module:model} model A model.
     * @returns {boolean|null} True if in a team, null if not clear.
     */
    checkInTeam(model) {
      return this.getImplementation(model.entityType).checkInTeam(model);
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * Check if a record is shared with the user.
     *
     * @param {module:model} model A model.
     * @returns {boolean|null} True if shared, null if not clear.
     */
    checkIsShared(model) {
      return this.getImplementation(model.entityType).checkIsShared(model);
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * Check an assignment permission to a user.
     *
     * @param {module:models/user} user A user.
     * @returns {boolean} True if access allowed.
     */
    checkAssignmentPermission(user) {
      return this.checkPermission('assignmentPermission', user);
    }

    /**
     * Check a user permission to a user.
     *
     * @param {module:models/user} user A user.
     * @returns {boolean} True if access allowed.
     */
    checkUserPermission(user) {
      return this.checkPermission('userPermission', user);
    }

    /**
     * Check a specific permission to a user.
     *
     * @param {string} permission A permission name.
     * @param {module:models/user} user A user.
     * @returns {boolean|null} True if access allowed. Null if not enough data loaded to know for sure.
     */
    checkPermission(permission, user) {
      if (this.getUser().isAdmin()) {
        return true;
      }
      const level = this.getPermissionLevel(permission);
      if (level === 'no') {
        if (user.id === this.getUser().id) {
          return true;
        }
        return false;
      }
      if (level === 'team') {
        if (!user.has('teamsIds')) {
          return null;
        }
        let result = false;
        const teamsIds = user.get('teamsIds') || [];
        teamsIds.forEach(id => {
          if ((this.getUser().get('teamsIds') || []).includes(id)) {
            result = true;
          }
        });
        return result;
      }
      if (level === 'all') {
        return true;
      }
      if (level === 'yes') {
        return true;
      }
      return false;
    }

    /**
     * Get a list of forbidden fields for an entity type.
     *
     * @param {string} scope An entity type.
     * @param {'read'|'edit'} [action='read'] An action.
     * @param {'yes'|'no'} [thresholdLevel='no'] A threshold level.
     * @returns {string[]} A forbidden field list.
     */
    getScopeForbiddenFieldList(scope, action, thresholdLevel) {
      action = action || 'read';
      thresholdLevel = thresholdLevel || 'no';
      const key = scope + '_' + action + '_' + thresholdLevel;
      if (key in this.forbiddenFieldsCache) {
        return _utils.default.clone(this.forbiddenFieldsCache[key]);
      }
      const levelList = this.fieldLevelList.slice(this.fieldLevelList.indexOf(thresholdLevel));
      const fieldTableQuickAccess = this.data.fieldTableQuickAccess || {};
      const scopeData = fieldTableQuickAccess[scope] || {};
      const fieldsData = scopeData.fields || {};
      const actionData = fieldsData[action] || {};
      const fieldList = [];
      levelList.forEach(level => {
        const list = actionData[level] || [];
        list.forEach(field => {
          if (fieldList.includes(field)) {
            return;
          }
          fieldList.push(field);
        });
      });
      this.forbiddenFieldsCache[key] = fieldList;
      return _utils.default.clone(fieldList);
    }

    /**
     * Get a list of forbidden attributes for an entity type.
     *
     * @param {string} scope An entity type.
     * @param {'read'|'edit'} [action='read'] An action.
     * @param {'yes'|'no'} [thresholdLevel='no'] A threshold level.
     * @returns {string[]} A forbidden attribute list.
     */
    getScopeForbiddenAttributeList(scope, action, thresholdLevel) {
      action = action || 'read';
      thresholdLevel = thresholdLevel || 'no';
      const key = scope + '_' + action + '_' + thresholdLevel;
      if (key in this.forbiddenAttributesCache) {
        return _utils.default.clone(this.forbiddenAttributesCache[key]);
      }
      const levelList = this.fieldLevelList.slice(this.fieldLevelList.indexOf(thresholdLevel));
      const fieldTableQuickAccess = this.data.fieldTableQuickAccess || {};
      const scopeData = fieldTableQuickAccess[scope] || {};
      const attributesData = scopeData.attributes || {};
      const actionData = attributesData[action] || {};
      const attributeList = [];
      levelList.forEach(level => {
        const list = actionData[level] || [];
        list.forEach(attribute => {
          if (attributeList.includes(attribute)) {
            return;
          }
          attributeList.push(attribute);
        });
      });
      this.forbiddenAttributesCache[key] = attributeList;
      return _utils.default.clone(attributeList);
    }

    /**
     * Check an assignment permission to a team.
     *
     * @param {string} teamId A team ID.
     * @returns {boolean} True if access allowed.
     */
    checkTeamAssignmentPermission(teamId) {
      if (this.getPermissionLevel('assignmentPermission') === 'all') {
        return true;
      }
      return this.getUser().getLinkMultipleIdList('teams').includes(teamId);
    }

    /**
     * Check access to a field.
     * @param {string} scope An entity type.
     * @param {string} field A field.
     * @param {'read'|'edit'} [action='read'] An action.
     * @returns {boolean} True if access allowed.
     */
    checkField(scope, field, action) {
      return !this.getScopeForbiddenFieldList(scope, action).includes(field);
    }
  }
  AclManager.extend = _bullbone.View.extend;
  var _default = _exports.default = AclManager;
});

define("models/user", ["exports", "model"], function (_exports, _model) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _model = _interopRequireDefault(_model);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module models/user */

  /**
   * A user.
   */
  class User extends _model.default {
    name = 'User';
    entityType = 'User';
    urlRoot = 'User';

    /**
     * Is admin.
     *
     * @returns {boolean}
     */
    isAdmin() {
      return this.get('type') === 'admin' || this.isSuperAdmin();
    }

    /**
     * Is portal.
     *
     * @returns {boolean}
     */
    isPortal() {
      return this.get('type') === 'portal';
    }

    /**
     * Is API.
     *
     * @returns {boolean}
     */
    isApi() {
      return this.get('type') === 'api';
    }

    /**
     * Is regular.
     *
     * @returns {boolean}
     */
    isRegular() {
      return this.get('type') === 'regular';
    }

    /**
     * Is system.
     *
     * @returns {boolean}
     */
    isSystem() {
      return this.get('type') === 'system';
    }

    /**
     * Is super-admin.
     *
     * @returns {boolean}
     */
    isSuperAdmin() {
      return this.get('type') === 'super-admin';
    }
  }
  var _default = _exports.default = User;
});

define("models/settings", ["exports", "model"], function (_exports, _model) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _model = _interopRequireDefault(_model);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module models/settings */

  /**
   * A config.
   */
  class Settings extends _model.default {
    name = 'Settings';
    entityType = 'Settings';
    urlRoot = 'Settings';

    /**
     * Load.
     *
     * @returns {Promise}
     */
    load() {
      return new Promise(resolve => {
        this.fetch().then(() => resolve());
      });
    }

    /**
     * Get a value by a path.
     *
     * @param {string[]} path A path.
     * @returns {*} Null if not set.
     */
    getByPath(path) {
      if (!path.length) {
        return null;
      }
      let p;
      for (let i = 0; i < path.length; i++) {
        const item = path[i];
        if (i === 0) {
          p = this.get(item);
        } else {
          if (item in p) {
            p = p[item];
          } else {
            return null;
          }
        }
        if (i === path.length - 1) {
          return p;
        }
        if (p === null || typeof p !== 'object') {
          return null;
        }
      }
    }
  }
  var _default = _exports.default = Settings;
});

define("models/preferences", ["exports", "model"], function (_exports, _model) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _model = _interopRequireDefault(_model);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module models/preferences */

  /**
   * User preferences.
   */
  class Preferences extends _model.default {
    name = 'Preferences';
    entityType = 'Preferences';
    urlRoot = 'Preferences';

    /**
     * @private
     * @type {import('models/settings').default}
     */
    settings;

    /**
     * Get dashlet options.
     *
     * @param {string} id A dashlet ID.
     * @returns {Object|null}
     */
    getDashletOptions(id) {
      const value = this.get('dashletsOptions') || {};
      return value[id] || null;
    }

    /**
     * Whether a user is portal.
     *
     * @returns {boolean}
     */
    isPortal() {
      return this.get('isPortalUser');
    }

    /**
     * @internal
     * @param {import('models/settings').default} settings
     */
    setSettings(settings) {
      this.settings = settings;
    }
  }
  var _default = _exports.default = Preferences;
});

define("helpers/site/shortcut-manager", ["exports", "di", "ui"], function (_exports, _di, _ui) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _ui = _interopRequireDefault(_ui);
  var _staticBlock;
  let _initClass;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  /** @typedef {import('view').default} View */
  /** @typedef {string|function(KeyboardEvent): void} Key */
  let _ShortcutManager = _exports.default = void 0;
  class ShortcutManager {
    /**
     * @private
     * @type {number}
     */
    level = 0;

    /**
     * @private
     * @type {{
     *     view: View[],
     *     keys: Record.<string, Key>,
     *     level: number,
     * }[]}
     */
    items;
    constructor() {
      this.items = [];
      document.addEventListener('keydown', event => this.handle(event), {
        capture: true
      });
    }

    /**
     * Add a view and keys.
     *
     * @param {import('view').default<any>} view
     * @param {Record.<string, Key>} keys
     * @param {{stack: boolean}} [options]
     */
    add(view, keys) {
      let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
      if (this.items.find(it => it.view === view)) {
        return;
      }
      if (options.stack) {
        this.level++;
      }
      this.items.push({
        view: view,
        keys: keys,
        level: this.level
      });
    }

    /**
     * Remove a view.
     *
     * @param {import('view').default<any>} view
     */
    remove(view) {
      const index = this.items.findIndex(it => it.view === view);
      if (index < 0) {
        return;
      }
      this.items.splice(index, 1);
      let maxLevel = 0;
      for (const item of this.items) {
        if (item.level > maxLevel) {
          maxLevel = item.level;
        }
      }
      this.level = maxLevel;
    }

    /**
     * Handle.
     *
     * @param {KeyboardEvent} event
     */
    handle(event) {
      const items = this.items.filter(it => it.level === this.level);
      if (items.length === 0) {
        return;
      }
      if (_ui.default.getConfirmCount()) {
        return;
      }
      const key = Espo.Utils.getKeyFromKeyEvent(event);
      for (const item of items) {
        const subject = item.keys[key];
        if (!subject) {
          continue;
        }
        if (typeof subject === 'function') {
          subject.call(item.view, event);
          break;
        }
        event.preventDefault();
        event.stopPropagation();
        const methodName = 'action' + Espo.Utils.upperCaseFirst(subject);
        if (typeof item.view[methodName] === 'function') {
          item.view[methodName]();
          break;
        }
      }
    }
    static #_ = _staticBlock = () => ([_ShortcutManager, _initClass] = _applyDecs(this, [(0, _di.register)()], []).c, _exports.default = _ShortcutManager, _initClass());
  }
  _staticBlock();
});

define("helpers/site/modal-bar-provider", ["exports", "di"], function (_exports, _di) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  var _staticBlock;
  let _initClass;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  /**
   * @internal
   */
  let _ModalBarProvider = _exports.default = void 0;
  class ModalBarProvider {
    /**
     * @private
     * @type {import('views/collapsed-modal-bar').default|null}
     */
    view = null;

    /**
     * @internal
     * @return {import('views/collapsed-modal-bar').default|null}
     */
    get() {
      return this.view;
    }

    /**
     * @internal
     * @param {import('views/collapsed-modal-bar').default|null} view
     */
    set(view) {
      this.view = view;
    }
    static #_ = _staticBlock = () => ([_ModalBarProvider, _initClass] = _applyDecs(this, [(0, _di.register)()], []).c, _exports.default = _ModalBarProvider, _initClass());
  }
  _staticBlock();
});

define("helpers/misc/pipelines", ["exports", "di", "app-params", "metadata"], function (_exports, _di, _appParams, _metadata) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _appParams = _interopRequireDefault(_appParams);
  _metadata = _interopRequireDefault(_metadata);
  var _staticBlock;
  let _init_appParams, _init_extra_appParams, _init_metadata, _init_extra_metadata;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  /**
   * @since 10.0.0
   */
  class PipelinesHelper {
    constructor() {
      _init_extra_metadata(this);
    }
    /**
     * @private
     * @type {AppParams}
     */
    appParams = _init_appParams(this);

    /**
     * @private
     * @type {Metadata}
     */
    metadata = (_init_extra_appParams(this), _init_metadata(this));

    /**
     * @param {string} entityType
     * @return {{
     *     id: string,
     *     name: string,
     *     stages: {
     *         id: string,
     *         name: string,
     *         style: string|null,
     *     }[],
     *     color: number|null,
     * }[]}
     */
    get(entityType) {
      return (this.appParams.get('pipelines') ?? {})[entityType] ?? [];
    }

    /**
     * @param {string} entityType
     * @return {boolean}
     */
    isEnabled(entityType) {
      return this.metadata.get(`scopes.${entityType}.pipelines`) === true;
    }
    static #_ = _staticBlock = () => [_init_appParams, _init_extra_appParams, _init_metadata, _init_extra_metadata] = _applyDecs(this, [], [[(0, _di.inject)(_appParams.default), 0, "appParams"], [(0, _di.inject)(_metadata.default), 0, "metadata"]]).e;
  }
  _exports.default = PipelinesHelper;
  _staticBlock();
});

define("views/modal", ["exports", "view", "di", "helpers/site/modal-bar-provider", "helpers/site/shortcut-manager", "jquery", "ui", "utils"], function (_exports, _view, _di, _modalBarProvider, _shortcutManager, _jquery, _ui, _utils) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  _modalBarProvider = _interopRequireDefault(_modalBarProvider);
  _shortcutManager = _interopRequireDefault(_shortcutManager);
  _jquery = _interopRequireDefault(_jquery);
  _ui = _interopRequireDefault(_ui);
  _utils = _interopRequireDefault(_utils);
  var _staticBlock;
  let _init_modalBarProvider, _init_extra_modalBarProvider, _init_shortcutManager, _init_extra_shortcutManager;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  /** @module views/modal */
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  const $ = _jquery.default;

  /**
   * A button or dropdown action item.
   */

  // noinspection JSUnusedGlobalSymbols

  /**
   * A base modal view. Can be extended or used directly.
   *
   * @see https://docs.espocrm.com/development/modal/
   */
  class ModalView extends _view.default {
    modalBarProvider = _init_modalBarProvider(this);
    shortcutManager = (_init_extra_modalBarProvider(this), _init_shortcutManager(this));

    /**
     * A CSS name.
     */
    cssName = (_init_extra_shortcutManager(this), 'modal-dialog');

    /**
     * A class-name. Use `'dialog dialog-record'` for modals containing a record form.
     */
    className = 'dialog';

    /**
     * A header HTML. Beware of XSS.
     */
    headerHtml = null;

    /**
     * A header JQuery instance.
     * @deprecated
     * @todo Remove in 11.0.
     */

    /**
     * A header element.
     */

    /**
     * A header text.
     */
    headerText = null;

    /**
     * A dialog instance.
     */

    /**
     * A container selector.
     */
    containerSelector = '';

    /**
     * A scope name. Used when translating button labels.
     */
    scope = null;

    /**
     * A backdrop.
     */
    backdrop = 'static';

    /**
     * Buttons.
     */
    buttonList = [];

    /**
     * Dropdown action items.
     */
    dropdownItemList = [];

    /**
     * Not used.
     */
    fitHeight = false;

    /**
     * To disable fitting to a window height.
     */
    noFullHeight = false;

    /**
     * Disable the ability to close by pressing the `Esc` key.
     */
    escapeDisabled = false;

    /**
     * Is draggable.
     */
    isDraggable = false;

    /**
     * Is collapsable.
     */
    isCollapsible = false;

    /**
     * Is maximizable.
     *
     * @since 9.1.0
     */
    isMaximizable = false;

    /**
     * Is collapsed. Do not change value. Only for reading.
     *
     * @since 9.1.0
     */
    isCollapsed = false;

    /**
     * Body element.
     */

    /**
     * @internal
     */
    footerAtTheTop = null;

    /**
     * A shortcut-key => action map.
     */
    shortcutKeys = null;

    /**
     * Use a fixed header height.
     */
    fixedHeaderHeight = false;

    /**
     * Disable the close button.
     */
    noCloseButton = false;

    /**
     * Container element.
     *
     * @since 9.0.0
     */

    /**
     * Use a flexible header font size.
     */

    footerReRenderPromise = null;
    init() {
      this.addHandler('click', '.action', (e, target) => {
        _utils.default.handleAction(this, e, target);
      });
      const id = this.cssName + '-container-' + Math.floor(Math.random() * 10000 + 1).toString();
      this.containerSelector = '#' + id;
      this.headerHtml = this.options.headerHtml || this.headerHtml;
      this.headerElement = this.options.headerElement || this.headerElement;
      this.headerText = this.options.headerText || this.headerText;
      this.backdrop = this.options.backdrop || this.backdrop;
      this.setSelector(this.containerSelector);
      this.buttonList = this.options.buttonList || this.buttonList;
      this.dropdownItemList = this.options.dropdownItemList || this.dropdownItemList;
      this.buttonList = _utils.default.cloneDeep(this.buttonList);
      this.dropdownItemList = _utils.default.cloneDeep(this.dropdownItemList);
      if (this.shortcutKeys) {
        this.shortcutKeys = _utils.default.cloneDeep(this.shortcutKeys);
      }
      if (this.options.collapseDisabled) {
        this.isCollapsible = false;
      }
      this.on('render', () => {
        if (this.dialog) {
          this.dialog.close();
        }

        // Otherwise, re-render won't work.
        // @ts-ignore
        this.element = undefined;
        this.isCollapsed = false;
        $(this.containerSelector).remove();
        $('<div />').css('display', 'none').attr('id', id).addClass('modal-container').appendTo('body');
        let modalBodyDiffHeight = 92;
        if (this.getThemeManager().getParam('modalBodyDiffHeight') !== null) {
          modalBodyDiffHeight = this.getThemeManager().getParam('modalBodyDiffHeight');
        }
        let headerHtml = this.headerHtml;
        if (this.$header && this.$header.length) {
          var _this$$header$get;
          headerHtml = (_this$$header$get = this.$header.get(0)) === null || _this$$header$get === void 0 ? void 0 : _this$$header$get.outerHTML;
        }
        if (this.headerElement) {
          headerHtml = this.headerElement.outerHTML;
        }
        if (this.headerText) {
          headerHtml = Handlebars.Utils.escapeExpression(this.headerText);
        }
        const footerAtTheTop = this.footerAtTheTop !== null ? this.footerAtTheTop : this.getThemeManager().getParam('modalFooterAtTheTop');
        this.dialog = new _ui.default.Dialog({
          backdrop: this.backdrop,
          header: headerHtml,
          container: this.containerSelector,
          body: '',
          buttonList: this.getDialogButtonList(),
          dropdownItemList: this.getDialogDropdownItemList(),
          keyboard: !this.escapeDisabled,
          fitHeight: this.fitHeight,
          draggable: this.isDraggable,
          className: this.className,
          bodyDiffHeight: modalBodyDiffHeight,
          footerAtTheTop: footerAtTheTop,
          fullHeight: !this.noFullHeight && this.getThemeManager().getParam('modalFullHeight'),
          screenWidthXs: this.getThemeManager().getParam('screenWidthXs'),
          fixedHeaderHeight: this.fixedHeaderHeight,
          closeButton: !this.noCloseButton,
          collapseButton: this.isCollapsible,
          maximizeButton: this.isMaximizable && !this.getHelper().isXsScreen(),
          onRemove: () => this.onDialogClose(),
          onBackdropClick: () => this.onBackdropClick(),
          onMaximize: () => this.onMaximize(),
          onMinimize: () => this.onMinimize()
        });
        this.containerElement = document.querySelector(this.containerSelector);
        this.setElement(this.containerSelector + ' .body');
        this.bodyElement = this.element;

        // @todo Review that the element is set back to the container afterwards.
        //     Force keeping set to the body?
      });
      this.on('after:render', () => {
        // Trick to delegate events for the whole modal.
        // @ts-ignore
        this.element = undefined;
        this.setElement(this.containerSelector);
        $(this.containerSelector).show();
        this.dialog.show();
        if (this.fixedHeaderHeight && this.flexibleHeaderFontSize) {
          this.adjustHeaderFontSize();
        }
        if (!this.noFullHeight) {
          this.initBodyScrollListener();
        }
        if (this.getParentView()) {
          this.getParentView().trigger('modal-shown');
        }
        this.initShortcuts();
      });
      this.once('remove', () => {
        if (this.dialog) {
          this.dialog.close();
        }
        $(this.containerSelector).remove();
      });
      if (this.isCollapsible) {
        this.addActionHandler('collapseModal', () => this.collapse());
      }
      this.on('after:expand', () => this.afterExpand());
    }
    initShortcuts() {
      // Shortcuts to be added even if there's no keys set – to suppress current shortcuts.
      this.shortcutManager.add(this, this.shortcutKeys ?? {}, {
        stack: true
      });
      this.once('remove', () => {
        this.shortcutManager.remove(this);
      });
    }
    setupFinal() {
      this.initShortcuts();
    }

    /**
     * Get a button list for a dialog.
     */
    getDialogButtonList() {
      const buttonListExt = [];
      this.buttonList.forEach(item => {
        let o = {};
        if (typeof item === 'string') {
          o.name = item;
        } else if (typeof item === 'object') {
          o = item;
        } else {
          return;
        }
        if (!o.text) {
          if (o.labelTranslation) {
            o.text = this.getLanguage().translatePath(o.labelTranslation);
          } else if ('label' in o) {
            o.text = this.translate(o.label, 'labels', this.scope);
          }
        }
        if (!o.title && o.titleTranslation) {
          o.title = this.getLanguage().translatePath(o.titleTranslation);
        }
        if (o.iconHtml && !o.html) {
          o.html = o.iconHtml + '<span>' + this.getHelper().escapeString(o.text) + '</span>';
        } else if (o.iconClass && !o.html) {
          if (o.text) {
            o.html = `<span class="${o.iconClass}"></span>` + '<span>' + this.getHelper().escapeString(o.text) + '</span>';
          } else {
            o.html = `<span class="${o.iconClass}"></span>`;
            o.className = 'btn-icon';
          }
        }
        o.onClick = o.onClick ?? ((_d, event) => {
          const handler = o.handler || (o.data || {}).handler;
          _utils.default.handleAction(this, event, event.target, {
            action: o.name,
            handler: handler,
            actionFunction: o.actionFunction
          });
        });
        buttonListExt.push(o);
      });
      return buttonListExt;
    }

    /**
     * Get a dropdown item list for a dialog.
     */
    getDialogDropdownItemList() {
      const dropdownItemListExt = [];
      this.dropdownItemList.forEach(item => {
        let o = {};
        if (typeof item === 'string') {
          o.name = item;
        } else if (typeof item === 'object') {
          o = item;
        } else {
          return;
        }
        if (!o.text) {
          if (o.labelTranslation) {
            o.text = this.getLanguage().translatePath(o.labelTranslation);
          } else if ('label' in o) {
            o.text = this.translate(o.label, 'labels', this.scope);
          }
        }
        o.iconCLass = item.iconClass;
        o.onClick = o.onClick ?? ((_d, e) => {
          // noinspection ES6ConvertLetToConst
          let handler = o.handler || (o.data || {}).handler;
          _utils.default.handleAction(this, e, e.target, {
            action: o.name,
            handler: handler,
            actionFunction: o.actionFunction
          });
        });
        dropdownItemListExt.push(o);
      });
      const dropdownGroups = [];
      dropdownItemListExt.forEach(item => {
        // For bc.
        if (item === false) {
          return;
        }
        const index = (item.groupIndex === undefined ? 9999 : item.groupIndex) + 100;
        if (dropdownGroups[index] === undefined) {
          dropdownGroups[index] = [];
        }
        dropdownGroups[index].push(item);
      });
      const dropdownItemList = [];
      dropdownGroups.forEach(list => {
        list.forEach(it => dropdownItemList.push(it));
        dropdownItemList.push(false);
      });
      return dropdownItemList;
    }
    updateDialog() {
      if (!this.dialog) {
        return;
      }
      this.dialog.setActionItems(this.getDialogButtonList(), this.getDialogDropdownItemList());
    }
    onDialogClose() {
      if (!this.isBeingRendered() && !this.isCollapsed) {
        this.trigger('close');
        this.remove();
      }
      this.shortcutManager.remove(this);
    }
    onBackdropClick() {}

    /**
     * A `cancel` action.
     */
    actionCancel() {
      this.trigger('cancel');
      this.close();
    }

    /**
     * A `close` action.
     */
    actionClose() {
      this.actionCancel();
    }

    /**
     * Close the dialog.
     */
    close() {
      this.dialog.close();
      if (!this.getParentView()) {
        return;
      }
      const key = this.getParentView().getViewKey(this);
      if (key) {
        this.getParentView().clearView(key);
      }
    }

    /**
     * Disable a button.
     *
     * @param name A button name.
     */
    async disableButton(name) {
      let changed = false;
      this.buttonList.forEach(item => {
        if (item.name !== name) {
          return;
        }
        changed ||= !item.disabled;
        item.disabled = true;
      });
      if (!changed) {
        return;
      }
      if (!this.isRendered()) {
        return;
      }
      await this.reRenderFooter();
    }

    /**
     * Enable a button.
     *
     * @param name A button name.
     */
    async enableButton(name) {
      let changed = false;
      this.buttonList.forEach(item => {
        if (item.name !== name) {
          return;
        }
        changed ||= item.disabled;
        item.disabled = false;
      });
      if (!changed) {
        return;
      }
      if (!this.isRendered()) {
        return;
      }
      await this.reRenderFooter();
    }

    /**
     * Add a button.
     *
     * @param o Button definitions.
     * @param [position=false] True prepends, false appends. If a string
     *   then will be added after a button with a corresponding name.
     * @param [doNotReRender=false] Do not re-render.
     */
    addButton(o) {
      let position = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
      let doNotReRender = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
      let index = -1;
      this.buttonList.forEach((item, i) => {
        if (item.name === o.name) {
          index = i;
        }
      });
      if (~index) {
        return;
      }
      if (position === true) {
        this.buttonList.unshift(o);
      } else if (typeof position === 'string') {
        index = -1;
        this.buttonList.forEach((item, i) => {
          if (item.name === position) {
            index = i;
          }
        });
        if (~index) {
          this.buttonList.splice(index, 0, o);
        } else {
          this.buttonList.push(o);
        }
      } else {
        this.buttonList.push(o);
      }
      if (!doNotReRender && this.isRendered()) {
        this.reRenderFooter();
      }
    }

    /**
     * Add a dropdown item.
     *
     * @param o Button definitions.
     * @param [toBeginning=false] To prepend.
     * @param [doNotReRender=false] Do not re-render.
     */
    addDropdownItem(o) {
      let toBeginning = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
      let doNotReRender = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
      if (!o) {
        // For bc.
        return;
      }
      const name = o.name;
      if (!name) {
        return;
      }
      for (const item of this.dropdownItemList) {
        if (item && item.name === name) {
          return;
        }
      }
      toBeginning ? this.dropdownItemList.unshift(o) : this.dropdownItemList.push(o);
      if (!doNotReRender && this.isRendered()) {
        this.reRenderFooter();
      }
    }
    async reRenderFooter() {
      if (!this.dialog) {
        return;
      }
      if (this.footerReRenderPromise) {
        return this.footerReRenderPromise;
      }
      let resolvePromise;
      const promise = new Promise(resolve => resolvePromise = resolve);
      this.footerReRenderPromise = promise;
      queueMicrotask(() => {
        this.updateDialog();
        this.dialog.reRenderFooter();
        //this.dialog.initButtonEvents();

        this.footerReRenderPromise = null;
        resolvePromise();
      });
      return promise;
    }

    /**
     * Remove a button or a dropdown action item.
     *
     * @param name A name.
     * @param [doNotReRender=false] Do not re-render.
     */
    removeButton(name) {
      let doNotReRender = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
      let index = -1;
      for (const [i, item] of this.buttonList.entries()) {
        if (item.name === name) {
          index = i;
          break;
        }
      }
      if (~index) {
        this.buttonList.splice(index, 1);
      }
      for (const [i, item] of this.dropdownItemList.entries()) {
        if (item && item.name === name) {
          this.dropdownItemList.splice(i, 1);
          break;
        }
      }
      if (this.isRendered()) {
        $(this.containerElement).find(`.modal-footer [data-name="${name}"]`).remove();
      }
      if (!doNotReRender && this.isRendered()) {
        this.reRender();
      }
    }

    /**
     * @deprecated Use `showActionItem`.
     *
     * @todo Remove in 11.0.
     */
    async showButton(name) {
      for (const item of this.buttonList) {
        if (item.name === name) {
          item.hidden = false;
          break;
        }
      }
      if (!this.isRendered()) {
        return;
      }
      await this.reRenderFooter();
    }

    /**
     * @deprecated Use `hideActionItem`.
     *
     * @todo Remove in 11.0.
     */
    async hideButton(name) {
      for (const item of this.buttonList) {
        if (item.name === name) {
          item.hidden = true;
          break;
        }
      }
      if (!this.isRendered()) {
        return;
      }
      await this.reRenderFooter();
    }

    /**
     * Show an action item (button or dropdown item).
     *
     * @param name A name.
     */
    async showActionItem(name) {
      let changed = false;
      for (const item of this.buttonList) {
        if (item.name === name) {
          changed ||= item.hidden;
          item.hidden = false;
          break;
        }
      }
      for (const item of this.dropdownItemList) {
        if (item && item.name === name) {
          changed ||= item.hidden;
          item.hidden = false;
          break;
        }
      }
      if (!changed) {
        return;
      }
      if (!this.isRendered()) {
        return;
      }
      await this.reRenderFooter();
    }

    /**
     * Update action item.
     *
     * @param name A name.
     * @param item Values to update.     *
     * @since 10.0.0
     */
    async updateActionItem(name, item) {
      const found = [...this.buttonList, ...this.dropdownItemList].find(it => it && it.name === name);
      if (!found) {
        return;
      }
      Object.assign(found, item);
      if (!this.isRendered()) {
        return;
      }
      await this.reRenderFooter();
    }

    /**
     * Hide an action item (button or dropdown item).
     *
     * @param name A name.
     */
    async hideActionItem(name) {
      let changed = false;
      for (const item of this.buttonList) {
        if (item.name === name) {
          changed ||= !item.hidden;
          item.hidden = true;
          break;
        }
      }
      for (const item of this.dropdownItemList) {
        if (item && item.name === name) {
          changed ||= !item.hidden;
          item.hidden = true;
          break;
        }
      }
      if (changed) {
        return;
      }
      if (!this.isRendered()) {
        return;
      }
      await this.reRenderFooter();
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * Whether an action item exists (hidden, disabled or not).
     *
     * @param name An action item name.
     */
    hasActionItem(name) {
      const hasButton = this.buttonList.findIndex(item => item.name === name) !== -1;
      if (hasButton) {
        return true;
      }
      return this.dropdownItemList.findIndex(item => item && item.name === name) !== -1;
    }

    /**
     * Whether an action item is visible and not disabled.
     *
     * @param name An action item name.
     */
    hasAvailableActionItem(name) {
      const hasButton = this.buttonList.findIndex(item => item.name === name && !item.disabled && !item.hidden) !== -1;
      if (hasButton) {
        return true;
      }
      return this.dropdownItemList.findIndex(item => item && item.name === name && !item.disabled && !item.hidden) !== -1;
    }
    adjustHeaderFontSize() {
      let step = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
      step = step || 0;
      if (!step) {
        this.fontSizePercentage = 100;
      }
      if (!this.containerElement) {
        return;
      }
      const $titleText = $(this.containerElement).find('.modal-title > .modal-title-text');
      const containerWidth = $titleText.parent().width();
      let textWidth = 0;
      $titleText.children().each((_i, el) => {
        textWidth += $(el).outerWidth(true);
      });
      if (containerWidth < textWidth) {
        if (step > 5) {
          const $title = $(this.containerElement).find('.modal-title');
          $title.attr('title', $titleText.text());
          $title.addClass('overlapped');
          $titleText.children().each((_i, el) => {
            $(el).removeAttr('title');
          });
          return;
        }
        this.fontSizePercentage -= 4;
        $(this.containerElement).find('.modal-title .font-size-flexible').css('font-size', this.fontSizePercentage + '%');
        this.adjustHeaderFontSize(step + 1);
      }
    }

    /**
     * Collapse.
     */
    async collapse() {
      let data = await this.beforeCollapse();
      if (!this.getParentView()) {
        throw new Error("Can't collapse w/o parent view.");
      }
      this.isCollapsed = true;
      data = data ?? {};
      let title = null;
      if (data.title) {
        title = data.title;
      } else {
        const titleElement = this.containerElement.querySelector('.modal-header .modal-title .modal-title-text');
        if (titleElement) {
          title = titleElement.textContent;
        }
      }
      this.dialog.close();
      let masterView = this;
      while (masterView.getParentView()) {
        masterView = masterView.getParentView();
      }
      this.unchainFromParent();
      const barView = this.modalBarProvider.get();
      if (!barView) {
        return;
      }
      await barView.addModalView(this, {
        title: title ?? null
      });
    }
    unchainFromParent() {
      const key = this.getParentView().getViewKey(this);
      if (!key) {
        return;
      }
      this.getParentView().unchainView(key);
    }

    /**
     * Called before collapse. Can be extended to execute some logic, e.g. save form data.
     */
    beforeCollapse() {
      return new Promise(resolve => resolve(undefined));
    }

    /**
     * Called after expanding.
     *
     * @since 9.1.0
     */
    afterExpand() {}
    initBodyScrollListener() {
      const $body = $(this.containerElement).find('> .dialog > .modal-dialog > .modal-content > .modal-body');
      const $footer = $body.parent().find('> .modal-footer');
      if (!$footer.length) {
        return;
      }
      $body.off('scroll.footer-shadow');
      $body.on('scroll.footer-shadow', () => {
        if ($body.scrollTop()) {
          $footer.addClass('shadowed');
          return;
        }
        $footer.removeClass('shadowed');
      });
    }

    /**
     * @since 9.1.0
     */
    onMaximize() {}

    /**
     * @since 9.1.0
     */
    onMinimize() {}
    static #_ = _staticBlock = () => [_init_modalBarProvider, _init_extra_modalBarProvider, _init_shortcutManager, _init_extra_shortcutManager] = _applyDecs(this, [], [[(0, _di.inject)(_modalBarProvider.default), 0, "modalBarProvider"], [(0, _di.inject)(_shortcutManager.default), 0, "shortcutManager"]], 0, void 0, _view.default).e;
  }
  _staticBlock();
  var _default = _exports.default = ModalView;
});

define("helpers/action-item-setup", ["exports", "di", "metadata", "view-helper", "acl-manager", "language"], function (_exports, _di, _metadata, _viewHelper, _aclManager, _language) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _metadata = _interopRequireDefault(_metadata);
  _viewHelper = _interopRequireDefault(_viewHelper);
  _aclManager = _interopRequireDefault(_aclManager);
  _language = _interopRequireDefault(_language);
  var _staticBlock;
  let _init_metadata, _init_extra_metadata, _init_viewHelper, _init_extra_viewHelper, _init_acl, _init_extra_acl, _init_language, _init_extra_language;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  /** @module helpers/action-item-setup */

  /**
   * @internal
   */
  class ActionItemSetupHelper {
    constructor() {
      _init_extra_language(this);
    }
    /**
     * @private
     * @type {Metadata}
     */
    metadata = _init_metadata(this);

    /**
     * @private
     * @type {ViewHelper}
     */
    viewHelper = (_init_extra_metadata(this), _init_viewHelper(this));

    /**
     * @private
     * @type {AclManager}
     */
    acl = (_init_extra_viewHelper(this), _init_acl(this));

    /**
     * @private
     * @type {Language}
     */
    language = (_init_extra_acl(this), _init_language(this));

    /**
     * @param {{
     *     view: import('view').default<any>,
     *     type: string,
     *     waitFunc: (Promise) => void,
     *     addFunc: (
     *          item: import('views/record/detail').DropdownItem |
     *              import('views/record/detail').Button
    *         ) => void,
     *     showFunc: (string) => void,
     *     hideFunc: (string) => void,
     *     enableFunc?: (string) => void,
     *     disableFunc?: (string) => void,
     *     listenToViewModelSync?: boolean,
     *     syncEvent?: 'sync'|'change',
     * }} options
     */
    setup(options) {
      const view = options.view;
      const type = options.type;
      const waitFunc = options.waitFunc;
      const addFunc = options.addFunc;
      const showFunc = options.showFunc;
      const hideFunc = options.hideFunc;
      const enableFunc = options.enableFunc ?? (() => {});
      const disableFunc = options.disableFunc ?? (() => {});

      /** @type {Record[]} */
      const actionList = [];

      // noinspection JSUnresolvedReference
      const scope = view.scope || view.model.entityType;
      if (!scope) {
        throw new Error();
      }
      const path = type.split('.');

      /** @type {({name?: string} & Record | string)[]} */
      const actionDefsListOriginal = [...this.metadata.get(['clientDefs', 'Global', ...path], []), ...this.metadata.get(['clientDefs', scope, ...path], [])];

      /** @type {({name?: string} & Record<string, any>)[]} */
      let actionDefsList = actionDefsListOriginal.map(item => {
        if (typeof item === 'string') {
          return {
            name: item
          };
        }
        return Espo.Utils.cloneDeep(item);
      });
      actionDefsList.reverse();
      actionDefsList = actionDefsList.filter((it, i, self) => {
        return self.findIndex(sIt => sIt.name === it.name) === i;
      });
      actionDefsList.reverse();
      actionDefsList.forEach(item => {
        const name = item.name;
        if (!item.label && !item.labelTranslation && !item.iconClass) {
          item.text = this.language.translate(name, 'actions', scope);
        }
        item.data = item.data || {};
        const handlerName = item.handler || item.data.handler;
        if (handlerName && !item.data.handler) {
          item.data.handler = handlerName;
        }
        if (!Espo.Utils.checkActionAvailability(this.viewHelper, item)) {
          return;
        }
        addFunc(item);
        if (!Espo.Utils.checkActionAccess(this.acl, view.model, item, true)) {
          item.hidden = true;
        }
        actionList.push(item);
        if (!handlerName) {
          return;
        }
        if (!item.initFunction && !item.checkVisibilityFunction && !item.checkAvailabilityFunction) {
          return;
        }
        waitFunc(new Promise(resolve => {
          Espo.loader.require(handlerName, Handler => {
            const handler = new Handler(view);
            if (item.initFunction) {
              handler[item.initFunction].call(handler);
            }
            if (item.checkVisibilityFunction) {
              const isNotVisible = !handler[item.checkVisibilityFunction].call(handler);
              if (isNotVisible) {
                hideFunc(item.name);
              }
            }
            if (item !== null && item !== void 0 && item.checkAvailabilityFunction) {
              const isNotAvailable = !handler[item.checkAvailabilityFunction].call(handler);
              if (isNotAvailable) {
                disableFunc(item.name);
              }
            }
            item.handlerInstance = handler;
            resolve();
          });
        }));
      });
      if (!actionList.length) {
        return;
      }
      const onChange = () => {
        actionList.forEach(item => {
          const handler = item.handlerInstance;
          if (!handler || !item.checkAvailabilityFunction) {
            return;
          }
          const isAvailable = handler[item.checkAvailabilityFunction].call(handler);
          isAvailable ? enableFunc(item.name) : disableFunc(item.name);
        });
      };
      const onSync = () => {
        actionList.forEach(item => {
          const handler = item.handlerInstance;
          if (handler && item.checkVisibilityFunction) {
            const isNotVisible = !handler[item.checkVisibilityFunction].call(handler);
            if (isNotVisible) {
              hideFunc(item.name);
              return;
            }
          }
          if (Espo.Utils.checkActionAccess(this.acl, view.model, item, true)) {
            showFunc(item.name);
            return;
          }
          hideFunc(item.name);
        });
      };
      if (options.listenToViewModelSync) {
        view.listenTo(view, 'model-sync', () => onSync());
        return;
      }
      view.listenTo(view.model, 'change', () => onChange());
      view.listenTo(view.model, options.syncEvent ?? 'sync', () => onSync());
    }
    static #_ = _staticBlock = () => [_init_metadata, _init_extra_metadata, _init_viewHelper, _init_extra_viewHelper, _init_acl, _init_extra_acl, _init_language, _init_extra_language] = _applyDecs(this, [], [[(0, _di.inject)(_metadata.default), 0, "metadata"], [(0, _di.inject)(_viewHelper.default), 0, "viewHelper"], [(0, _di.inject)(_aclManager.default), 0, "acl"], [(0, _di.inject)(_language.default), 0, "language"]]).e;
  }
  _staticBlock();
  var _default = _exports.default = ActionItemSetupHelper;
});

define("helpers/model/defaults-populator", ["exports", "di", "metadata", "view-helper", "models/settings", "models/user", "acl-manager", "models/preferences", "helpers/misc/pipelines"], function (_exports, _di, _metadata, _viewHelper, _settings, _user, _aclManager, _preferences, _pipelines) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _metadata = _interopRequireDefault(_metadata);
  _viewHelper = _interopRequireDefault(_viewHelper);
  _settings = _interopRequireDefault(_settings);
  _user = _interopRequireDefault(_user);
  _aclManager = _interopRequireDefault(_aclManager);
  _preferences = _interopRequireDefault(_preferences);
  _pipelines = _interopRequireDefault(_pipelines);
  var _staticBlock;
  let _init_metadata, _init_extra_metadata, _init_viewHelper, _init_extra_viewHelper, _init_config, _init_extra_config, _init_user, _init_extra_user, _init_preferences, _init_extra_preferences, _init_acl, _init_extra_acl;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  /**
   * Defaults populator.
   */
  class DefaultsPopulator {
    constructor() {
      _init_extra_acl(this);
    }
    /**
     * @private
     * @type {Metadata}
     */
    metadata = _init_metadata(this);

    /**
     * @private
     * @type {ViewHelper}
     */
    viewHelper = (_init_extra_metadata(this), _init_viewHelper(this));

    /**
     * @private
     * @type {Settings}
     */
    config = (_init_extra_viewHelper(this), _init_config(this));

    /**
     * @private
     * @type {User}
     */
    user = (_init_extra_config(this), _init_user(this));

    /**
     * @private
     * @type {Preferences}
     */
    preferences = (_init_extra_user(this), _init_preferences(this));

    /**
     * @private
     * @type {AclManager}
     */
    acl = (_init_extra_preferences(this), _init_acl(this));

    /**
     * Populate default values.
     *
     * @param {module:model} model A model.
     * @return {Promise}
     */
    populate(model) {
      model.populateDefaults();
      const defaultHash = {};
      if (!this.user.isPortal()) {
        this.prepare(model, defaultHash);
      }
      if (this.user.isPortal()) {
        this.prepareForPortal(model, defaultHash);
      }
      this.prepareFields(model, defaultHash);
      for (const attr in defaultHash) {
        if (model.has(attr)) {
          delete defaultHash[attr];
        }
      }
      model.set(defaultHash, {
        silent: true
      });
      const preparatorClass = this.metadata.get(`clientDefs.${model.entityType}.modelDefaultsPreparator`);
      if (!preparatorClass) {
        return Promise.resolve();
      }
      return Espo.loader.requirePromise(preparatorClass).then(Class => {
        /** @type {import('handlers/model/defaults-preparator').default} */
        const preparator = new Class(this.viewHelper);
        return preparator.prepare(model);
      }).then(attributes => {
        model.set(attributes, {
          silent: true
        });
      });
    }

    /**
     * @param {module:model} model
     * @param {Object.<string, *>} defaultHash
     * @private
     */
    prepare(model, defaultHash) {
      const hasAssignedUsers = model.hasField('assignedUsers') && model.getLinkParam('assignedUsers', 'entity') === 'User';
      if (model.hasField('assignedUser') || hasAssignedUsers) {
        let assignedUserField = 'assignedUser';
        if (hasAssignedUsers) {
          assignedUserField = 'assignedUsers';
        }
        if (this.toFillAssignedUser(model, assignedUserField)) {
          if (hasAssignedUsers) {
            defaultHash['assignedUsersIds'] = [this.user.id];
            defaultHash['assignedUsersNames'] = {};
            defaultHash['assignedUsersNames'][this.user.id] = this.user.get('name');
          } else {
            defaultHash['assignedUserId'] = this.user.id;
            defaultHash['assignedUserName'] = this.user.get('name');
          }
        }
      }
      const defaultTeamId = this.user.get('defaultTeamId');
      if (defaultTeamId) {
        if (model.hasField('teams') && !model.getFieldParam('teams', 'default') && Espo.Utils.lowerCaseFirst(model.getLinkParam('teams', 'relationName') || '') === 'entityTeam') {
          defaultHash['teamsIds'] = [defaultTeamId];
          defaultHash['teamsNames'] = {};
          defaultHash['teamsNames'][defaultTeamId] = this.user.get('defaultTeamName');
        }
      }
      const hasCollaborators = model.hasField('collaborators') && model.getLinkParam('collaborators', 'entity') === 'User' && this.metadata.get(`scopes.${model.entityType}.collaborators`);
      if (hasCollaborators) {
        defaultHash.collaboratorsIds = [this.user.id];
        defaultHash.collaboratorsNames = {
          [this.user.id]: this.user.attributes.name
        };
      }
      if (this.metadata.get(`scopes.${model.entityType}.pipelines`)) {
        const firstPipeline = new _pipelines.default().get(model.entityType)[0] ?? null;
        if (firstPipeline) {
          var _firstPipeline$stages, _firstPipeline$stages2;
          defaultHash.pipelineId = firstPipeline.id;
          defaultHash.pipelineName = firstPipeline.name;
          defaultHash.pipelineStageId = ((_firstPipeline$stages = firstPipeline.stages[0]) === null || _firstPipeline$stages === void 0 ? void 0 : _firstPipeline$stages.id) ?? null;
          defaultHash.pipelineStageName = ((_firstPipeline$stages2 = firstPipeline.stages[0]) === null || _firstPipeline$stages2 === void 0 ? void 0 : _firstPipeline$stages2.name) ?? null;
        }
      }
    }

    /**
     *
     * @param {import('model').default} model
     * @param {string} assignedUserField
     */
    toFillAssignedUser(model, assignedUserField) {
      if (!this.preferences.get('doNotFillAssignedUserIfNotRequired')) {
        return true;
      }
      if (model.getFieldParam(assignedUserField, 'required')) {
        return true;
      }
      if (this.acl.getPermissionLevel('assignmentPermission') === 'no') {
        return true;
      }
      if (this.acl.getPermissionLevel('assignmentPermission') === 'team' && !this.user.get('defaultTeamId')) {
        return true;
      }
      if (this.acl.getLevel(model.entityType, 'read') === 'own') {
        return true;
      }
      if (!this.acl.checkField(model.entityType, assignedUserField, 'edit')) {
        return true;
      }
      return false;
    }

    /**
     * @param {module:model} model
     * @param {Object.<string, *>} defaultHash
     * @private
     */
    prepareForPortal(model, defaultHash) {
      const accountLink = this.metadata.get(`aclDefs.${model.entityType}.accountLink`);
      const contactLink = this.metadata.get(`aclDefs.${model.entityType}.contactLink`);
      if (accountLink && model.hasField(accountLink) && ['belongsTo', 'hasOne'].includes(model.getLinkType(accountLink)) && model.getLinkParam(accountLink, 'entity') === 'Account') {
        if (this.user.attributes.accountId) {
          defaultHash[accountLink + 'Id'] = this.user.attributes.accountId;
          defaultHash[accountLink + 'Name'] = this.user.attributes.accuntName;
        }
      }
      if (contactLink && model.hasField(contactLink) && ['belongsTo', 'hasOne'].includes(model.getLinkType(contactLink)) && model.getLinkParam(contactLink, 'entity') === 'Contact') {
        if (this.user.attributes.contactId) {
          defaultHash[contactLink + 'Id'] = this.user.attributes.contactId;
          defaultHash[contactLink + 'Name'] = this.user.attributes.contactName;
        }
      }
      if (accountLink && model.hasField(accountLink) && model.getLinkType(accountLink) === 'hasMany' && model.getLinkParam(accountLink, 'entity') === 'Account') {
        if (this.user.attributes.accountsIds) {
          defaultHash['accountsIds'] = [...this.user.attributes.accountsIds];
          defaultHash['accountsNames'] = {
            ...this.user.attributes.accountsNames
          };
        }
      }
      if (contactLink && model.hasField(contactLink) && model.getLinkType(contactLink) === 'hasMany' && model.getLinkParam(contactLink, 'entity') === 'Contact') {
        if (this.user.attributes.contactId) {
          defaultHash['contactsIds'] = [this.user.attributes.contactId];
          defaultHash['contactsNames'] = {
            [this.user.attributes.contactId]: this.user.attributes.contactName
          };
        }
      }
      if (model.hasField('parent') && model.getLinkType('parent') === 'belongsToParent') {
        if (!this.config.get('b2cMode')) {
          if (this.user.attributes.accountId && (model.getFieldParam('parent', 'entityList') || []).includes('Account')) {
            defaultHash['parentId'] = this.user.attributes.accountId;
            defaultHash['parentName'] = this.user.attributes.accountName;
            defaultHash['parentType'] = 'Account';
          }
        } else {
          if (this.user.attributes.contactId && (model.getFieldParam('parent', 'entityList') || []).includes('Contact')) {
            defaultHash['parentId'] = this.user.attributes.contactId;
            defaultHash['parentName'] = this.user.attributes.contactName;
            defaultHash['parentType'] = 'Contact';
          }
        }
      }
    }

    /**
     * @param {module:model} model
     * @param {Object.<string, *>} defaultHash
     * @private
     */
    prepareFields(model, defaultHash) {
      const set = (attribute, value) => {
        if (attribute in defaultHash || model.has(attribute)) {
          return;
        }
        defaultHash[attribute] = value;
      };
      model.getFieldList().forEach(field => {
        const type = model.getFieldType(field);
        if (!type) {
          return;
        }
        if (model.getFieldParam(field, 'disabled') || model.getFieldParam(field, 'utility')) {
          return;
        }
        if (type === 'enum') {
          /** @type {string[]} */
          const options = model.getFieldParam(field, 'options') || [];
          let value = options[0] || '';
          value = value !== '' ? value : null;
          if (value) {
            set(field, value);
          }
        }
      });
    }
    static #_ = _staticBlock = () => [_init_metadata, _init_extra_metadata, _init_viewHelper, _init_extra_viewHelper, _init_config, _init_extra_config, _init_user, _init_extra_user, _init_preferences, _init_extra_preferences, _init_acl, _init_extra_acl] = _applyDecs(this, [], [[(0, _di.inject)(_metadata.default), 0, "metadata"], [(0, _di.inject)(_viewHelper.default), 0, "viewHelper"], [(0, _di.inject)(_settings.default), 0, "config"], [(0, _di.inject)(_user.default), 0, "user"], [(0, _di.inject)(_preferences.default), 0, "preferences"], [(0, _di.inject)(_aclManager.default), 0, "acl"]]).e;
  }
  _staticBlock();
  var _default = _exports.default = DefaultsPopulator;
});

define("storage", ["exports"], function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module storage */

  /**
   * A storage. Data is saved across browser sessions, has no expiration time.
   */
  class Storage {
    constructor() {}

    /** @protected */
    prefix = 'espo';

    /** @protected */
    storageObject = localStorage;

    /**
     * @private
     * @param {string} type
     * @returns {string}
     */
    composeFullPrefix(type) {
      return this.prefix + '-' + type;
    }

    /**
     * @private
     * @param {string} type
     * @param {string} name
     * @returns {string}
     */
    composeKey(type, name) {
      return this.composeFullPrefix(type) + '-' + name;
    }

    /**
     * @private
     * @param {string} type
     */
    checkType(type) {
      if (typeof type === 'undefined' && toString.call(type) !== '[object String]' || type === 'cache') {
        throw new TypeError("Bad type \"" + type + "\" passed to Espo.Storage.");
      }
    }

    /**
     * Has a value.
     *
     * @param {string} type A type (category).
     * @param {string} name A name.
     * @returns {boolean}
     */
    has(type, name) {
      this.checkType(type);
      const key = this.composeKey(type, name);
      return this.storageObject.getItem(key) !== null;
    }

    /**
     * Get a value.
     *
     * @param {string} type A type (category).
     * @param {string} name A name.
     * @returns {*} Null if not stored.
     */
    get(type, name) {
      this.checkType(type);
      const key = this.composeKey(type, name);
      let stored;
      try {
        stored = this.storageObject.getItem(key);
      } catch (error) {
        console.error(error);
        return null;
      }
      if (stored) {
        let result = stored;
        if (stored.length > 9 && stored.substring(0, 9) === '__JSON__:') {
          const jsonString = stored.slice(9);
          try {
            result = JSON.parse(jsonString);
          } catch (error) {
            result = stored;
          }
        } else if (stored[0] === "{" || stored[0] === "[") {
          // for backward compatibility
          try {
            result = JSON.parse(stored);
          } catch (error) {
            result = stored;
          }
        }
        return result;
      }
      return null;
    }

    /**
     * Set (store) a value.
     *
     * @param {string} type A type (category).
     * @param {string} name A name.
     * @param {*} value A value.
     */
    set(type, name, value) {
      this.checkType(type);
      if (value === null) {
        this.clear(type, name);
        return;
      }
      const key = this.composeKey(type, name);
      if (value instanceof Object || Array.isArray(value) || value === true || value === false || typeof value === 'number') {
        value = '__JSON__:' + JSON.stringify(value);
      }
      try {
        this.storageObject.setItem(key, value);
      } catch (error) {
        console.error(error);
        return null;
      }
    }

    /**
     * Clear a value.
     *
     * @param {string} type A type (category).
     * @param {string} name A name.
     */
    clear(type, name) {
      let reText;
      if (typeof type !== 'undefined') {
        if (typeof name === 'undefined') {
          reText = '^' + this.composeFullPrefix(type);
        } else {
          reText = '^' + this.composeKey(type, name);
        }
      } else {
        reText = '^' + this.prefix + '-';
      }
      const re = new RegExp(reText);
      for (const i in this.storageObject) {
        if (re.test(i)) {
          delete this.storageObject[i];
        }
      }
    }
  }
  var _default = _exports.default = Storage;
});

define("router", ["exports", "backbone", "bullbone", "underscore", "ui"], function (_exports, _backbone, _bullbone, _underscore, _ui) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _backbone = _interopRequireDefault(_backbone);
  _underscore = _interopRequireDefault(_underscore);
  _ui = _interopRequireDefault(_ui);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * On route.
   *
   * @event Router#route
   * @param {string} name A route name.
   * @param {any[]} args Arguments.
   */

  /**
   * After dispatch.
   *
   * @event Router#routed
   * @param {{
   *   controller: string,
   *   action:string,
   *   options: Object.<string,*>,
   * }} data A route data.
   */

  /**
   * Subscribe.
   *
   * @function on
   * @memberof Router#
   * @param {string} event An event.
   * @param {function(*): void} callback A callback.
   */

  /**
   * Subscribe once.
   *
   * @function once
   * @memberof Router#
   * @param {string} event An event.
   * @param {function(): void} callback A callback.
   */

  /**
   * Unsubscribe.
   *
   * @function off
   * @memberof Router#
   * @param {string} event An event.
   */

  /**
   * Trigger an event.
   *
   * @function trigger
   * @memberof Router#
   * @param {string} event An event.
   */

  const optionalParam = /\((.*?)\)/g;
  const namedParam = /(\(\?)?:\w+/g;
  const splatParam = /\*\w+/g;
  // noinspection RegExpRedundantEscape
  const escapeRegExp = /[\-{}\[\]+?.,\\\^$|#\s]/g;

  /**
   * A router.
   *
   * Based on the Backbone.js router.
   */
  class Router {
    /**
     * @private
     */
    routeList = [{
      route: "clearCache",
      resolution: "clearCache"
    }, {
      route: ":controller/view/:id/:options",
      resolution: "view"
    }, {
      route: ":controller/view/:id",
      resolution: "view"
    }, {
      route: ":controller/edit/:id/:options",
      resolution: "edit"
    }, {
      route: ":controller/edit/:id",
      resolution: "edit"
    }, {
      route: ":controller/create",
      resolution: "create"
    }, {
      route: ":controller/related/:id/:link",
      resolution: "related"
    }, {
      route: ":controller/:action/:options",
      resolution: "action",
      order: 100
    }, {
      route: ":controller/:action",
      resolution: "action",
      order: 200
    }, {
      route: ":controller",
      resolution: "defaultAction",
      order: 300
    }, {
      route: "*actions",
      resolution: "home",
      order: 500
    }];
    constructor(options) {
      options || (options = {});
      if (options.routes) {
        this.routes = options.routes;
      }
      this.initialize(options);
    }

    /**
     * @private
     * @param route
     * @return {RegExp}
     */
    _routeToRegExp(route) {
      route = route.replace(escapeRegExp, '\\$&').replace(optionalParam, '(?:$1)?').replace(namedParam, (match, optional) => optional ? match : '([^/?]+)').replace(splatParam, '([^?]*?)');
      return new RegExp('^' + route + '(?:\\?([\\s\\S]*))?$');
    }

    /**
     * @param route
     * @param fragment
     * @return {*}
     * @private
     */
    _extractParameters(route, fragment) {
      const params = route.exec(fragment).slice(1);
      return _underscore.default.map(params, (param, i) => {
        if (i === params.length - 1) {
          return param || null;
        }
        return param ? decodeURIComponent(param) : null;
      });
    }

    /**
     * @private
     */
    setupRoutes() {
      this.routeParams = {};
      if (this.options.routes) {
        const routeList = [];
        Object.keys(this.options.routes).forEach(route => {
          const item = this.options.routes[route];
          routeList.push({
            route: route,
            resolution: item.resolution || 'defaultRoute',
            order: item.order || 0
          });
          this.routeParams[route] = item.params || {};
        });
        this.routeList = Espo.Utils.clone(this.routeList);
        routeList.forEach(item => {
          this.routeList.push(item);
        });
        this.routeList = this.routeList.sort((v1, v2) => {
          return (v1.order || 0) - (v2.order || 0);
        });
      }
      this.routeList.reverse().forEach(item => {
        this.route(item.route, item.resolution);
      });
    }

    /**
     * @private
     */
    _last = null;

    /**
     * Whether a confirm-leave-out was set.
     *
     * @public
     * @type {boolean}
     */
    confirmLeaveOut = false;

    /**
     * Whether back has been processed.
     *
     * @public
     * @type {boolean}
     */
    backProcessed = false;

    /**
     * @type {string}
     * @internal
     */
    confirmLeaveOutMessage = 'Are you sure?';

    /**
     * @type {string}
     * @internal
     */
    confirmLeaveOutConfirmText = 'Yes';

    /**
     * @type {string}
     * @internal
     */
    confirmLeaveOutCancelText = 'No';

    /**
     * @private
     */
    initialize(options) {
      this.options = options || {};
      this.setupRoutes();
      this._isReturn = false;
      this.history = [];
      let hashHistory = [window.location.hash];
      window.addEventListener('hashchange', () => {
        const hash = window.location.hash;
        if (hashHistory.length > 1 && hashHistory[hashHistory.length - 2] === hash) {
          hashHistory = hashHistory.slice(0, -1);
          this.backProcessed = true;
          setTimeout(() => this.backProcessed = false, 50);
          return;
        }
        hashHistory.push(hash);
      });
      this.on('route', () => {
        this.history.push(_backbone.default.history.fragment);
      });
      window.addEventListener('beforeunload', event => {
        event = event || window.event;
        if (this.confirmLeaveOut || this._leaveOutMap.size || this._windowLeaveOutMap.size) {
          event.preventDefault();
          event.returnValue = this.confirmLeaveOutMessage;
          return this.confirmLeaveOutMessage;
        }
      });

      /**
       * @private
       * @type {Map<Object, true>}
       */
      this._leaveOutMap = new Map();

      /**
       * @private
       * @type {Map<Object, true>}
       */
      this._windowLeaveOutMap = new Map();
    }

    /**
     * Get a current URL.
     *
     * @returns {string}
     */
    getCurrentUrl() {
      return '#' + _backbone.default.history.fragment;
    }

    /**
     * Whether there's any confirm-leave-out.
     *
     * @since 9.1.0
     * @return {boolean}
     */
    hasConfirmLeaveOut() {
      return this.confirmLeaveOut || this._leaveOutMap.size || this._windowLeaveOutMap.size;
    }

    /**
     * Refer an object (usually a view). Page won't be possible to close or change if there's at least one object.
     *
     * @param {Object} object
     * @since 9.1.0
     * @internal
     */
    addLeaveOutObject(object) {
      this._leaveOutMap.set(object, true);
    }

    /**
     * Un-refer an object.
     *
     * @param {Object} object
     * @since 9.1.0
     * @internal
     */
    removeLeaveOutObject(object) {
      this._leaveOutMap.delete(object);
    }

    /**
     * Refer an object (usually a view). Window won't be possible to close if there's at least one object.
     *
     * @param {Object} object
     * @since 9.1.0
     * @internal
     */
    addWindowLeaveOutObject(object) {
      this._windowLeaveOutMap.set(object, true);
    }

    /**
     * Un-refer an object.
     *
     * @param {Object} object
     * @since 9.1.0
     * @internal
     */
    removeWindowLeaveOutObject(object) {
      this._windowLeaveOutMap.delete(object);
    }

    /**
     * @callback Router~checkConfirmLeaveOutCallback
     */

    /**
     * Process confirm-leave-out.
     *
     * @param {Router~checkConfirmLeaveOutCallback} callback Proceed if confirmed.
     * @param {Object|null} [context] A context.
     * @param {boolean} [navigateBack] To navigate back if not confirmed.
     */
    checkConfirmLeaveOut(callback, context, navigateBack) {
      if (this.confirmLeaveOutDisplayed) {
        this.navigateBack({
          trigger: false
        });
        this.confirmLeaveOutCanceled = true;
        return;
      }
      context = context || this;
      if (this.confirmLeaveOut || this._leaveOutMap.size) {
        this.confirmLeaveOutDisplayed = true;
        this.confirmLeaveOutCanceled = false;
        _ui.default.confirm(this.confirmLeaveOutMessage, {
          confirmText: this.confirmLeaveOutConfirmText,
          cancelText: this.confirmLeaveOutCancelText,
          backdrop: true,
          cancelCallback: () => {
            this.confirmLeaveOutDisplayed = false;
            if (navigateBack) {
              this.navigateBack({
                trigger: false
              });
            }
          }
        }, () => {
          this.confirmLeaveOutDisplayed = false;
          this.confirmLeaveOut = false;
          this._leaveOutMap.clear();
          if (!this.confirmLeaveOutCanceled) {
            callback.call(context);
          }
        });
        return;
      }
      callback.call(context);
    }

    /**
     * @private
     */
    route(route, name) {
      const routeOriginal = route;
      if (!_underscore.default.isRegExp(route)) {
        route = this._routeToRegExp(route);
      }
      let callback;
      callback = this['_' + name];
      const router = this;
      _backbone.default.history.route(route, fragment => {
        const args = router._extractParameters(route, fragment);
        const options = {};
        if (name === 'defaultRoute') {
          const keyList = [];
          routeOriginal.split('/').forEach(key => {
            if (key && key.indexOf(':') === 0) {
              keyList.push(key.substr(1));
            }
          });
          keyList.forEach((key, i) => {
            options[key] = args[i];
          });
        }
        router.execute(callback, args, name, routeOriginal, options);
        router.trigger.apply(router, ['route:' + name].concat(args));
        router.trigger('route', name, args);
        _backbone.default.history.trigger('route', router, name, args);
      });
      return this;
    }

    /**
     * @private
     */
    execute(callback, args, name, routeOriginal, options) {
      this.checkConfirmLeaveOut(() => {
        if (name === 'defaultRoute') {
          this._defaultRoute(this.routeParams[routeOriginal], options);
          return;
        }
        if (callback) {
          callback.apply(this, args);
        }
      }, null, true);
    }

    /**
     * Navigate.
     *
     * @param {string} fragment An URL fragment.
     * @param {{
     *     trigger?: boolean,
     *     replace?: boolean,
     *     isReturn?: boolean,
     * }} [options] Options.
     */
    navigate(fragment) {
      let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
      if (!options.trigger) {
        this.history.push(fragment);
      }
      if (options.isReturn) {
        this._isReturn = true;
      }
      _backbone.default.history.navigate(fragment, options);
      return this;
    }

    /**
     * Navigate back.
     *
     * @param {Object} [options] Options: trigger, replace.
     */
    navigateBack(options) {
      let url;
      url = this.history.length > 1 ? this.history[this.history.length - 2] : this.history[0];
      this.navigate(url, options);
    }

    /**
     * @private
     */
    _parseOptionsParams(string) {
      if (!string) {
        return {};
      }
      if (string.indexOf('&') === -1 && string.indexOf('=') === -1) {
        return {
          [string]: true
        };
      }
      const options = {};
      if (typeof string !== 'undefined') {
        string.split('&').forEach(item => {
          const p = item.split('=');
          options[p[0]] = true;
          if (p.length > 1) {
            options[p[0]] = decodeURIComponent(p[1]);
          }
        });
      }
      return options;
    }

    /**
     * @private
     */
    _defaultRoute(params, options) {
      const controller = params.controller || options.controller;
      const action = params.action || options.action;
      this.dispatch(controller, action, options);
    }

    /**
     * @private
     */
    _record(controller, action, id, options) {
      options = this._parseOptionsParams(options);
      options.id = id;
      this.dispatch(controller, action, options);
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * @private
     */
    _view(controller, id, options) {
      this._record(controller, 'view', id, options);
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * @private
     */
    _edit(controller, id, options) {
      this._record(controller, 'edit', id, options);
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * @private
     */
    _related(controller, id, link, options) {
      options = this._parseOptionsParams(options);
      options.id = id;
      options.link = link;
      this.dispatch(controller, 'related', options);
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * @private
     */
    _create(controller, options) {
      this._record(controller, 'create', null, options);
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * @private
     */
    _action(controller, action, options) {
      this.dispatch(controller, action, this._parseOptionsParams(options));
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * @private
     */
    _defaultAction(controller) {
      this.dispatch(controller, null);
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * @private
     */
    _home() {
      this.dispatch('Home', null);
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * @private
     */
    _clearCache() {
      this.dispatch(null, 'clearCache');
    }

    /**
     * Process `logout` route.
     */
    logout() {
      this.dispatch(null, 'logout');
      this.navigate('', {
        trigger: false
      });
    }

    /**
     * Dispatch a controller action.
     *
     * @param {string|null} [controller] A controller.
     * @param {string|null} [action] An action.
     * @param {Object} [options] Options.
     * @fires Router#routed
     */
    dispatch(controller, action, options) {
      if (this._isReturn) {
        options = {
          ...options
        };
        options.isReturn = true;
        this._isReturn = false;
      }
      const o = {
        controller: controller,
        action: action,
        options: options
      };
      if (controller && /[a-z]/.test(controller[0])) {
        o.controllerClassName = controller;
        delete o.controller;
      }
      this._last = o;
      this.trigger('routed', o);
    }

    /**
     * Get the last route data.
     *
     * @returns {Object}
     */
    getLast() {
      return this._last;
    }
  }
  _exports.default = Router;
  Object.assign(Router.prototype, _bullbone.Events);
  function isIOS9UIWebView() {
    const userAgent = window.navigator.userAgent;
    return /(iPhone|iPad|iPod).* OS 9_\d/.test(userAgent) && !/Version\/9\./.test(userAgent);
  }

  // Fixes issue that navigate with {trigger: false} fired
  // route change if there's a whitespace character.
  _backbone.default.history.getHash = function (window) {
    const match = (window || this).location.href.match(/#(.*)$/);
    return match ? this.decodeFragment(match[1]) : '';
  };

  // Override `backbone.history.loadUrl()` and `backbone.history.navigate()`
  // to fix the navigation issue (`location.hash` not changed immediately) on iOS9.
  if (isIOS9UIWebView()) {
    _backbone.default.history.loadUrl = function (fragment, oldHash) {
      fragment = this.fragment = this.getFragment(fragment);
      return _underscore.default.any(this.handlers, function (handler) {
        if (handler.route.test(fragment)) {
          function runCallback() {
            handler.callback(fragment);
          }
          function wait() {
            if (oldHash === location.hash) {
              window.setTimeout(wait, 50);
            } else {
              runCallback();
            }
          }
          wait();
          return true;
        }
      });
    };
    _backbone.default.history.navigate = function (fragment, options) {
      const pathStripper = /#.*$/;
      if (!_backbone.default.History.started) {
        return false;
      }
      if (!options || options === true) {
        options = {
          trigger: !!options
        };
      }
      let url = this.root + '#' + (fragment = this.getFragment(fragment || ''));
      fragment = fragment.replace(pathStripper, '');
      if (this.fragment === fragment) {
        return;
      }
      this.fragment = fragment;
      if (fragment === '' && url !== '/') {
        url = url.slice(0, -1);
      }
      const oldHash = location.hash;
      if (this._hasPushState) {
        this.history[options.replace ? 'replaceState' : 'pushState']({}, document.title, url);
      } else if (this._wantsHashChange) {
        this._updateHash(this.location, fragment, options.replace);
        if (this.iframe && fragment !== this.getFragment(this.getHash(this.iframe))) {
          if (!options.replace) {
            this.iframe.document.open().close();
          }
          this._updateHash(this.iframe.location, fragment, options.replace);
        }
      } else {
        return this.location.assign(url);
      }
      if (options.trigger) {
        return this.loadUrl(fragment, oldHash);
      }
    };
  }
});

define("views/modals/edit", ["exports", "views/modal", "backbone", "helpers/model/defaults-populator", "helpers/action-item-setup"], function (_exports, _modal, _backbone, _defaultsPopulator, _actionItemSetup) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  _backbone = _interopRequireDefault(_backbone);
  _defaultsPopulator = _interopRequireDefault(_defaultsPopulator);
  _actionItemSetup = _interopRequireDefault(_actionItemSetup);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/modals/edit */

  /**
   * A quick edit modal.
   */
  class EditModalView extends _modal.default {
    template = 'modals/edit';
    cssName = 'edit-modal';
    /** @protected */
    saveDisabled = false;
    /** @protected */
    fullFormDisabled = false;
    /** @protected */
    editView = null;
    escapeDisabled = true;
    className = 'dialog dialog-record';
    /** @protected */
    sideDisabled = false;
    /** @protected */
    bottomDisabled = false;
    isCollapsible = true;

    /**
     * @private
     * @type {boolean}
     */
    wasModified = false;

    /**
     * @private
     * @type {string}
     */
    nameAttribute;
    shortcutKeys = {
      /** @this EditModalView */
      'Control+Enter': function (e) {
        if (this.saveDisabled) {
          return;
        }
        if (this.buttonList.findIndex(item => item.name === 'save' && !item.hidden && !item.disabled) === -1) {
          return;
        }
        e.preventDefault();
        e.stopPropagation();
        if (document.activeElement instanceof HTMLInputElement) {
          // Fields may need to fetch data first.
          document.activeElement.dispatchEvent(new Event('change', {
            bubbles: true
          }));
        }
        this.actionSave();
      },
      /** @this EditModalView */
      'Control+KeyS': function (e) {
        if (this.saveDisabled) {
          return;
        }
        if (this.buttonList.findIndex(item => item.name === 'save' && !item.hidden && !item.disabled) === -1) {
          return;
        }
        e.preventDefault();
        e.stopPropagation();
        this.actionSaveAndContinueEditing();
      },
      /** @this EditModalView */
      'Escape': async function (e) {
        if (this.saveDisabled) {
          return;
        }
        e.stopPropagation();
        e.preventDefault();

        // Refactor the following code so that it can be easily re-used in other edit modals.

        const focusedFieldView = this.getRecordView().getFocusedFieldView();
        if (focusedFieldView) {
          this.model.set(focusedFieldView.fetch(), {
            skipReRender: true
          });
        }
        if (!this.getRecordView().hasChanged()) {
          this.actionClose();
          return;
        }
        await this.confirm(this.translate('confirmLeaveOutMessage', 'messages'));
        this.actionClose();
      },
      /** @this EditModalView */
      'Control+Backslash': function (e) {
        this.getRecordView().handleShortcutKeyControlBackslash(e);
      }
    };

    /**
     * @typedef {Record} module:views/modals/edit~options
     *
     * @property {string} entityType An entity type.
     * @property {string} [id] An ID.
     * @property {string} [layoutName] A layout name.
     * @property {Record} [attributes] Attributes.
     * @property {import('model').SetRelateItem | import('model').SetRelateItem[]} [relate] A relate data.
     * @property {import('view-record-helper')} [recordHelper] A record helper.
     * @property {boolean} [saveDisabled] Disable save.
     * @property {boolean} [fullFormDisabled] Disable full-form.
     * @property {string} [headerText] A header text.
     * @property {boolean} [focusForCreate] Focus for create.
     * @property {string} [rootUrl] A root URL.
     * @property {string} [returnUrl] A return URL.
     * @property {{
     *     controller: string,
     *     action: string|null,
     *     options: {isReturn?: boolean} & Record,
     * }} [returnDispatchParams] Return dispatch params.
     * @property {string} [fullFormUrl] A full-form URL. As of v9.0.
     */

    /**
     * @param {module:views/modals/edit~options} options
     */
    constructor(options) {
      super(options);
    }
    setup() {
      this.buttonList = [];
      if ('saveDisabled' in this.options) {
        this.saveDisabled = this.options.saveDisabled;
      }
      if (!this.saveDisabled) {
        this.buttonList.push({
          name: 'save',
          label: 'Save',
          style: 'primary',
          title: 'Ctrl+Enter',
          onClick: () => this.actionSave()
        });
      }
      this.fullFormDisabled = this.options.fullFormDisabled || this.fullFormDisabled;
      this.layoutName = this.options.layoutName || this.layoutName;
      if (!this.fullFormDisabled) {
        this.buttonList.push({
          name: 'fullForm',
          label: 'Full Form',
          onClick: () => this.actionFullForm()
        });
      }
      this.buttonList.push({
        name: 'cancel',
        label: 'Cancel',
        title: 'Esc'
      });
      this.scope = this.scope || this.options.scope || this.options.entityType;
      this.entityType = this.options.entityType || this.scope;
      this.id = this.options.id;
      this.nameAttribute = this.getMetadata().get(`clientDefs.${this.entityType}.nameAttribute`) || 'name';
      if (this.options.headerText !== undefined) {
        this.headerHtml = undefined;
        this.headerText = this.options.headerText;
      }
      this.sourceModel = this.model;
      this.waitForView('edit');
      this.getModelFactory().create(this.entityType, async model => {
        if (this.id) {
          if (this.sourceModel) {
            model = this.model = this.sourceModel.clone();
          } else {
            this.model = model;
            model.id = this.id;
          }
          await this.setupLate();
          await model.fetch();
          if (!this.headerText) {
            this.headerHtml = this.composeHeaderHtml();
          }
          this.setupActionItems();
          this.createRecordView(model);
          return;
        }
        this.model = model;
        await new _defaultsPopulator.default().populate(model);
        if (this.options.relate) {
          model.setRelate(this.options.relate);
        }
        if (this.options.attributes) {
          model.set(this.options.attributes);
        }
        await this.setupLate();
        if (!this.headerText) {
          this.headerHtml = this.composeHeaderHtml();
        }
        this.setupActionItems();
        this.createRecordView(model);
      });
      this.listenTo(this.model, 'change', (m, o) => {
        if (o.ui) {
          this.wasModified = true;
        }
      });
    }

    /**
     * Additional setup with the model ready.
     *
     * @protected
     * @since 9.3.0
     */
    async setupLate() {}

    /**
     * @param {module:model} model
     * @param {function} [callback]
     */
    createRecordView(model, callback) {
      const viewName = this.editView || this.getMetadata().get(['clientDefs', model.entityType, 'recordViews', 'editSmall']) || this.getMetadata().get(['clientDefs', model.entityType, 'recordViews', 'editQuick']) || 'views/record/edit-small';
      const options = {
        model: model,
        fullSelector: this.containerSelector + ' .edit-container',
        type: 'editSmall',
        layoutName: this.layoutName || 'detailSmall',
        buttonsDisabled: true,
        sideDisabled: this.sideDisabled,
        bottomDisabled: this.bottomDisabled,
        focusForCreate: this.options.focusForCreate,
        recordHelper: this.options.recordHelper,
        webSocketDisabled: true,
        exit: () => {}
      };
      this.handleRecordViewOptions(options);
      this.createView('edit', viewName, options, callback).then(/** import('views/fields/base').default */view => {
        this.listenTo(view, 'before:save', () => this.trigger('before:save', model));
        if (this.options.relate && 'link' in this.options.relate) {
          const link = this.options.relate.link;
          if (model.hasField(link) && ['link'].includes(model.getFieldType(link))) {
            view.setFieldReadOnly(link);
          }
        }
      });
    }
    handleRecordViewOptions(options) {}

    /**
     * @return {import('views/record/edit').default}
     */
    getRecordView() {
      return /** @type {import('views/record/edit').default} */this.getView('edit');
    }
    onBackdropClick() {
      if (this.getRecordView().hasChanged()) {
        return;
      }
      this.close();
    }

    /**
     * @protected
     * @return {string}
     */
    composeHeaderHtml() {
      let html;
      if (!this.id) {
        html = $('<span>').text(this.getLanguage().translate('Create ' + this.scope, 'labels', this.scope)).get(0).outerHTML;
      } else {
        const wrapper = document.createElement('span');
        const scope = document.createElement('span');
        scope.textContent = this.getLanguage().translate(this.scope, 'scopeNames');
        const separator = document.createElement('span');
        separator.classList.add('chevron-right');
        const name = this.model.attributes[this.nameAttribute];
        wrapper.append(document.createTextNode(this.getLanguage().translate('Edit') + ' · '), scope);
        if (name) {
          wrapper.append(' ', separator, ' ', name);
        }
        html = wrapper.outerHTML;
      }
      if (!this.fullFormDisabled) {
        const url = this.id ? '#' + this.scope + '/edit/' + this.id : '#' + this.scope + '/create';
        html = $('<a>').attr('href', url).addClass('action').attr('title', this.translate('Full Form')).attr('data-action', 'fullForm').append(html).get(0).outerHTML;
      }
      html = this.getHelper().getScopeColorIconHtml(this.scope) + html;
      return html;
    }

    /**
     * @protected
     * @param {{bypassClose?: boolean}} [data]
     */
    async actionSave() {
      let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      const editView = this.getRecordView();
      const model = editView.model;
      const disabledButtons = [];
      this.buttonList.forEach(it => {
        if (!it.name || it.disabled) {
          return;
        }
        this.disableButton(it.name);
        disabledButtons.push(it.name);
      });
      try {
        await editView.save();
      } catch (e) {
        disabledButtons.forEach(it => this.enableButton(it));
        return;
      }
      const wasNew = !this.id;
      if (wasNew) {
        this.id = model.id;
      }
      this.trigger('after:save', model, {
        bypassClose: data.bypassClose
      });
      if (!data.bypassClose) {
        this.dialog.close();
        if (wasNew) {
          const url = `#${this.scope}/view/${model.id}`;
          let name = model.attributes[this.nameAttribute];
          if (name === undefined) {
            name = this.translate(this.scope, 'scopeNames');
          }
          const msg = this.translate('Created') + '\n' + `[${name}](${url})`;
          Espo.Ui.notify(msg, 'success', 4000, {
            suppress: true
          });
        }
        return;
      }
      $(this.containerElement).find('.modal-header .modal-title-text').html(this.composeHeaderHtml());
      disabledButtons.forEach(it => this.enableButton(it));
    }
    actionSaveAndContinueEditing() {
      this.actionSave({
        bypassClose: true
      });
    }
    actionFullForm() {
      let url;
      const router = this.getRouter();
      let attributes;
      let model;
      let options;
      if (!this.id) {
        url = this.options.fullFormUrl || `#${this.scope}/create`;
        attributes = this.getRecordView().fetch();
        model = this.getRecordView().model;
        attributes = {
          ...attributes,
          ...model.getClonedAttributes()
        };
        options = {
          attributes: attributes,
          relate: this.options.relate,
          returnUrl: this.options.returnUrl || _backbone.default.history.fragment,
          returnDispatchParams: this.options.returnDispatchParams || null
        };
        if (this.options.rootUrl) {
          options.rootUrl = this.options.rootUrl;
        }
        setTimeout(() => {
          router.dispatch(this.scope, 'create', options);
          router.navigate(url, {
            trigger: false
          });
        }, 10);
      } else {
        url = this.options.fullFormUrl || `#${this.scope}/edit/${this.id}`;
        attributes = this.getRecordView().fetch();
        model = this.getRecordView().model;
        attributes = {
          ...attributes,
          ...model.getClonedAttributes()
        };
        options = {
          attributes: attributes,
          returnUrl: this.options.returnUrl || _backbone.default.history.fragment,
          returnDispatchParams: this.options.returnDispatchParams || null,
          model: this.sourceModel,
          id: this.id
        };
        if (this.options.rootUrl) {
          options.rootUrl = this.options.rootUrl;
        }
        setTimeout(() => {
          router.dispatch(this.scope, 'edit', options);
          router.navigate(url, {
            trigger: false
          });
        }, 10);
      }
      this.trigger('leave');
      this.dialog.close();
    }
    async beforeCollapse() {
      if (this.wasModified) {
        this.getRecordView().setConfirmLeaveOut(false);
        this.getRouter().addWindowLeaveOutObject(this);
      }
    }
    afterExpand() {
      if (this.wasModified) {
        this.getRecordView().setConfirmLeaveOut(true);
      }
      this.getRouter().removeWindowLeaveOutObject(this);
    }

    /**
     * @protected
     * @internal
     */
    setupActionItems() {
      const actionItemSetup = new _actionItemSetup.default();
      actionItemSetup.setup({
        view: this,
        type: 'modalEditActionList',
        waitFunc: promise => this.wait(promise),
        addFunc: item => this.addDropdownItem(item),
        showFunc: name => this.showActionItem(name),
        hideFunc: name => this.hideActionItem(name)
      });
      actionItemSetup.setup({
        view: this,
        type: 'recordControls.modalEditSide.buttons',
        waitFunc: promise => this.wait(promise),
        addFunc: item => {
          this.addButton({
            ...item,
            position: 'right'
          });
        },
        showFunc: name => this.showActionItem(name),
        hideFunc: name => this.hideActionItem(name),
        enableFunc: name => this.enableButton(name),
        disableFunc: name => this.disableButton(name)
      });
    }
  }
  var _default = _exports.default = EditModalView;
});

define("search-manager", ["exports", "di", "date-time", "storage"], function (_exports, _di, _dateTime, _storage) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _dateTime = _interopRequireDefault(_dateTime);
  _storage = _interopRequireDefault(_storage);
  var _staticBlock;
  let _init_dateTime, _init_extra_dateTime, _init_storage, _init_extra_storage;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  /** @module search-manager */
  /**
   * A where item. Sent to the backend.
   */
  /**
   * Search data.
   */
  /**
   * An advanced filter
   */
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  /**
   * A search manager.
   */
  class SearchManager {
    dateTime = _init_dateTime(this);
    storage = (_init_extra_dateTime(this), _init_storage(this));
    timeZone = (_init_extra_storage(this), null);
    /**
     * @param collection A collection.
     * @param [options] Options. As of 9.1.
     */
    constructor(collection) {
      let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
      this.scope = options.scope ?? collection.entityType ?? null;
      this.storageKey = options.storageKey ?? null;
      this.useStorage = !!this.storageKey;
      this.emptyOnReset = options.emptyOnReset ?? false;
      this.emptyData = {
        textFilter: '',
        bool: {},
        advanced: {},
        primary: null
      };
      let defaultData = options.defaultData;
      if (!defaultData && arguments[4]) {
        // For bc.
        defaultData = arguments[4];
      }
      if (defaultData) {
        this.defaultData = defaultData;
        for (const key in this.emptyData) {
          if (!(key in defaultData)) {
            defaultData[key] = Espo.Utils.clone(this.emptyData[key]);
          }
        }
      }
      this.data = Espo.Utils.clone(defaultData) ?? this.emptyData;
      this.sanitizeData();
    }
    sanitizeData() {
      if (!('advanced' in this.data)) {
        this.data.advanced = {};
      }
      if (!('bool' in this.data)) {
        this.data.bool = {};
      }
      if (!('textFilter' in this.data)) {
        this.data.textFilter = '';
      }
    }

    /**
     * Get a where clause. The where clause to be sent to the backend.
     */
    getWhere() {
      const where = [];
      if (this.data.textFilter && this.data.textFilter !== '') {
        where.push({
          type: 'textFilter',
          value: this.data.textFilter
        });
      }
      if (this.data.bool) {
        const o = {
          type: 'bool',
          value: []
        };
        for (const name in this.data.bool) {
          if (this.data.bool[name]) {
            o.value.push(name);
          }
        }
        if (o.value.length) {
          where.push(o);
        }
      }
      if (this.data.primary) {
        const o = {
          type: 'primary',
          value: this.data.primary
        };
        if (o.value.length) {
          where.push(o);
        }
      }
      if (this.data.advanced) {
        for (const name in this.data.advanced) {
          const defs = this.data.advanced[name];
          if (!defs) {
            continue;
          }
          const part = this.getWherePart(name, defs);
          if (part === null) {
            continue;
          }
          where.push(part);
        }
      }
      return where;
    }
    getWherePart(name, defs) {
      let attribute = name;
      if (typeof defs !== 'object') {
        console.error('Bad where clause');
        return null;
      }
      if ('where' in defs) {
        return defs.where;
      }
      const type = defs.type;
      let value;
      if (type === 'or' || type === 'and') {
        const items = [];
        const value = defs.value || {};
        for (const field in value) {
          const part = this.getWherePart(field, value[field]);
          if (part === null) {
            continue;
          }
          items.push(part);
        }
        return {
          type: type,
          value: items
        };
      }
      if ('field' in defs) {
        // for backward compatibility
        attribute = defs.field;
      }
      if ('attribute' in defs) {
        attribute = defs.attribute;
      }
      if (defs.dateTime || defs.date) {
        const timeZone = this.timeZone !== undefined ? this.timeZone : this.dateTime.getTimeZone();
        const data = {
          type: type,
          attribute: attribute,
          value: defs.value
        };
        if (defs.dateTime) {
          data.dateTime = true;
        }

        // @todo Revise.
        // @ts-ignore
        if (defs.date) {
          // @ts-ignore
          data.date = true;
        }
        if (timeZone) {
          data.timeZone = timeZone;
        }
        return data;
      }
      value = defs.value;
      return {
        type: type,
        attribute: attribute,
        value: value
      };
    }

    /**
     * Load stored data.
     */
    loadStored() {
      this.data = this.getFromStorageIfEnabled() || Espo.Utils.clone(this.defaultData) || Espo.Utils.clone(this.emptyData);
      this.sanitizeData();
      return this;
    }
    getFromStorageIfEnabled() {
      if (!this.useStorage || !this.scope) {
        return null;
      }
      return this.storage.get(`${this.storageKey}Search`, this.scope);
    }

    /**
     * Get data.
     */
    get() {
      return this.data;
    }

    /**
     * Set advanced filters.
     *
     * @param advanced Advanced filters.
     *   Pairs of field => advancedFilter.
     */
    setAdvanced(advanced) {
      this.data = Espo.Utils.clone(this.data);
      this.data.advanced = advanced;
    }

    /**
     * Set bool filters.
     *
     * @param bool Bool filters.
     */
    setBool(bool) {
      if (Array.isArray(bool)) {
        const data = {};
        bool.forEach(it => data[it] = true);
        bool = data;
      }
      this.data = Espo.Utils.clone(this.data);
      this.data.bool = bool;
    }

    /**
     * Set a primary filter.
     *
     * primary A filter.
     */
    setPrimary(primary) {
      this.data = Espo.Utils.clone(this.data);
      this.data.primary = primary;
    }

    /**
     * Set data.
     *
     * @param data Data.
     */
    set(data) {
      this.data = data;
      if (this.useStorage && this.scope) {
        data = Espo.Utils.clone(data);
        delete data['textFilter'];
        this.storage.set(this.storageKey + 'Search', this.scope, data);
      }
    }
    clearPreset() {
      delete this.data.presetName;
    }

    /**
     * Empty data.
     */
    empty() {
      this.data = Espo.Utils.clone(this.emptyData);
      if (this.useStorage && this.scope) {
        this.storage.clear(this.storageKey + 'Search', this.scope);
      }
    }

    /**
     * Reset.
     */
    reset() {
      if (this.emptyOnReset) {
        this.empty();
        return;
      }
      this.data = Espo.Utils.clone(this.defaultData) || Espo.Utils.clone(this.emptyData);
      if (this.useStorage && this.scope) {
        this.storage.clear(this.storageKey + 'Search', this.scope);
      }
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * Set a time zone. Null will not add a time zone.
     *
     * @internal Is used. Do not remove.
     */
    setTimeZone(timeZone) {
      this.timeZone = timeZone;
    }
    static #_ = _staticBlock = () => [_init_dateTime, _init_extra_dateTime, _init_storage, _init_extra_storage] = _applyDecs(this, [], [[(0, _di.inject)(_dateTime.default), 0, "dateTime"], [(0, _di.inject)(_storage.default), 0, "storage"]]).e;
  }
  _staticBlock();
  var _default = _exports.default = SearchManager;
});

define("field-manager", ["exports"], function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module field-manager */

  /**
   * Utility for getting field related meta information.
   */
  class FieldManager {
    /**
     * Utility for getting field related meta information.
     *
     * @param {Object} [defs] Field type definitions (metadata > fields).
     * @param {module:metadata} [metadata] Metadata.
     * @param {module:acl-manager} [acl] An ACL.
     */
    constructor(defs, metadata, acl) {
      /**
       * @typedef {Object} FieldManager~defs
       * @property {string[]} [actualFields]
       * @property {string[]} [notActualFields]
       * @property {'suffix'|'prefix'} [naming]
       * @property {Object.<string, Object.<string, *>>} [params]
       * @property {boolean} [filter]
       * @property {boolean} [notMergeable]
       * @property {string} [view]
       */

      /**
       * @public
       * @internal
       * @type {FieldManager~defs}
       */
      this.defs = defs || /** @type {FieldManager~defs} */{};

      /**
       * @public
       * @internal
       * @type {module:metadata}
       */
      this.metadata = metadata;

      /**
       * @public
       * @internal
       * @type {module:acl-manager}
       */
      this.acl = acl;
    }

    /**
     * Get a list of parameters for a specific field type.
     *
     * @param {string} fieldType A field type.
     * @returns {Object.<string, *>[]}
     */
    getParamList(fieldType) {
      if (fieldType in this.defs) {
        return this.defs[fieldType].params || [];
      }
      return [];
    }

    /**
     * Whether search filters are allowed for a field type.
     *
     * @param {string} fieldType A field type.
     * @returns {boolean}
     */
    checkFilter(fieldType) {
      if (fieldType in this.defs) {
        if ('filter' in this.defs[fieldType]) {
          return this.defs[fieldType].filter;
        }
        return false;
      }
      return false;
    }

    /**
     * Whether a merge operation is allowed for a field type.
     *
     * @param {string} fieldType A field type.
     * @returns {boolean}
     */
    isMergeable(fieldType) {
      if (fieldType in this.defs) {
        return !this.defs[fieldType].notMergeable;
      }
      return false;
    }

    /**
     * Get a list of attributes of an entity type.
     *
     * @param {string} entityType An entity type.
     * @param {module:field-manager~FieldFilters} [options] Filters.
     * @returns {string[]}
     */
    getEntityTypeAttributeList(entityType, options) {
      const list = [];
      const defs = this.metadata.get(`entityDefs.${entityType}.fields`) || {};
      this.getEntityTypeFieldList(entityType, options).forEach(field => {
        const fieldDefs = /** @type {Record} */defs[field] || {};
        this.getAttributeList(fieldDefs.type, field).forEach(attr => {
          if (!list.includes(attr)) {
            list.push(attr);
          }
        });
      });
      return list;
    }

    /**
     * Get a list of actual attributes by a given field type and field name.
     * Non-actual attributes contains data that for a representation-only purpose.
     * E.g. `accountId` is actual, `accountName` is non-actual.
     *
     * @param {string} fieldType A field type.
     * @param {string} fieldName A field name.
     * @returns {string[]}
     */
    getActualAttributeList(fieldType, fieldName) {
      const output = [];
      if (!(fieldType in this.defs)) {
        return [];
      }
      if ('actualFields' in this.defs[fieldType]) {
        const actualFields = this.defs[fieldType].actualFields;
        let naming = 'suffix';
        if ('naming' in this.defs[fieldType]) {
          naming = this.defs[fieldType].naming;
        }
        if (naming === 'prefix') {
          actualFields.forEach(it => output.push(it + Espo.Utils.upperCaseFirst(fieldName)));
        } else {
          actualFields.forEach(it => output.push(fieldName + Espo.Utils.upperCaseFirst(it)));
        }
      } else {
        output.push(fieldName);
      }
      return output;
    }

    /**
     * Get a list of non-actual attributes by a given field type and field name.
     * Non-actual attributes contains data that for a representation-only purpose.
     * E.g. `accountId` is actual, `accountName` is non-actual.
     *
     * @param {string} fieldType A field type.
     * @param {string} fieldName A field name.
     * @returns {string[]}
     */
    getNotActualAttributeList(fieldType, fieldName) {
      if (!(fieldType in this.defs)) {
        return [];
      }
      if (!('notActualFields' in this.defs[fieldType])) {
        return [];
      }
      const notActualFields = this.defs[fieldType].notActualFields;
      let naming = 'suffix';
      if ('naming' in this.defs[fieldType]) {
        naming = this.defs[fieldType].naming;
      }
      const output = [];
      if (naming === 'prefix') {
        notActualFields.forEach(it => {
          if (it === '') {
            output.push(fieldName);
          } else {
            output.push(it + Espo.Utils.upperCaseFirst(fieldName));
          }
        });
      } else {
        notActualFields.forEach(it => output.push(fieldName + Espo.Utils.upperCaseFirst(it)));
      }
      return output;
    }

    /**
     * Get an attribute list of a specific field.
     *
     * @param {string} entityType An entity type.
     * @param {string} field A field.
     * @returns {string[]}
     */
    getEntityTypeFieldAttributeList(entityType, field) {
      const type = this.metadata.get(['entityDefs', entityType, 'fields', field, 'type']);
      if (!type) {
        return [];
      }
      return _.union(this.getAttributeList(type, field), this._getEntityTypeFieldAdditionalAttributeList(entityType, field), this._getEntityTypeFieldFullNameAdditionalAttributeList(entityType, field));
    }

    /**
     * Get an actual attribute list of a specific field.
     *
     * @param {string} entityType An entity type.
     * @param {string} field A field.
     * @returns {string[]}
     */
    getEntityTypeFieldActualAttributeList(entityType, field) {
      const type = this.metadata.get(['entityDefs', entityType, 'fields', field, 'type']);
      if (!type) {
        return [];
      }
      return _.union(this.getActualAttributeList(type, field), this._getEntityTypeFieldAdditionalAttributeList(entityType, field), this._getEntityTypeFieldFullNameAdditionalAttributeList(entityType, field));
    }

    /**
     * @private
     */
    _getEntityTypeFieldAdditionalAttributeList(entityType, field) {
      const type = this.metadata.get(['entityDefs', entityType, 'fields', field, 'type']);
      if (!type) {
        return [];
      }
      const partList = this.metadata.get(['entityDefs', entityType, 'fields', field, 'additionalAttributeList']) || [];
      if (partList.length === 0) {
        return [];
      }
      const isPrefix = (this.defs[type] || {}).naming === 'prefix';
      const list = [];
      partList.forEach(item => {
        if (isPrefix) {
          list.push(item + Espo.Utils.upperCaseFirst(field));
          return;
        }
        list.push(field + Espo.Utils.upperCaseFirst(item));
      });
      return list;
    }

    /**
     * Get a list of attributes by a given field type and field name.
     *
     * @param {string} fieldType A field type.
     * @param {string} fieldName A field name.
     * @returns {string[]}
     */
    getAttributeList(fieldType, fieldName) {
      return _.union(this.getActualAttributeList(fieldType, fieldName), this.getNotActualAttributeList(fieldType, fieldName));
    }

    /**
     * @typedef {Object} module:field-manager~FieldFilters
     *
     * @property {string} [type] Only of a specific field type.
     * @property {string[]} [typeList] Only of a specific field types.
     * @property {string[]} [ignoreTypeList] Ignore field types.
     * @property {boolean} [onlyAvailable] To exclude disabled, admin-only, internal, forbidden fields.
     * @property {'read'|'edit'} [acl] To exclude fields not accessible for a current user over
     *   a specified access level.
     */

    /**
     * Get a list of fields of a specific entity type.
     *
     * @param {string} entityType An entity type.
     * @param {module:field-manager~FieldFilters} [options] Filters.
     * @returns {string[]}
     */
    getEntityTypeFieldList(entityType, options) {
      /** @type {Record} */
      const fieldDefs = this.metadata.get(['entityDefs', entityType, 'fields']) || {};
      let list = Object.keys(fieldDefs);
      options = options || {};
      let typeList = options.typeList;
      if (!typeList && options.type) {
        typeList = [options.type];
      }
      if (typeList) {
        list = list.filter(item => {
          const type = this.metadata.get(['entityDefs', entityType, 'fields', item, 'type']);
          return typeList.includes(type);
        });
      }
      if (options.ignoreTypeList) {
        list = list.filter(field => {
          const type = (fieldDefs[field] || {}).type;
          return !options.ignoreTypeList.includes(type);
        });
      }
      if (options.onlyAvailable || options.acl) {
        list = list.filter(item => {
          return this.isEntityTypeFieldAvailable(entityType, item);
        });
      }
      if (options.acl) {
        const level = options.acl || 'read';
        const forbiddenEditFieldList = this.acl.getScopeForbiddenFieldList(entityType, level);
        list = list.filter(item => {
          return !forbiddenEditFieldList.includes(item);
        });
      }
      return list;
    }

    /**
     * Get a field parameter value.
     *
     * @param {string} entityType An entity type.
     * @param {string} field A field name.
     * @param {string} param A parameter name.
     * @returns {*}
     */
    getEntityTypeFieldParam(entityType, field, param) {
      return this.metadata.get(['entityDefs', entityType, 'fields', field, param]);
    }

    /**
     * Get a view name/path for a specific field type.
     *
     * @param {string} fieldType A field type.
     * @returns {string}
     */
    getViewName(fieldType) {
      if (fieldType in this.defs) {
        if ('view' in this.defs[fieldType]) {
          return this.defs[fieldType].view;
        }
      }
      return 'views/fields/' + Espo.Utils.camelCaseToHyphen(fieldType);
    }

    /**
     * Check whether a field is not disabled, not utility, not only-admin, not forbidden and not internal.
     *
     * @param {string} entityType An entity type.
     * @param {string} field A field name.
     * @returns {boolean}
     */
    isEntityTypeFieldAvailable(entityType, field) {
      /** @type {Record} */
      const defs = this.metadata.get(['entityDefs', entityType, 'fields', field]) || {};
      if (defs.disabled || defs.utility) {
        return false;
      }

      /** @type {Record} */
      const aclDefs = this.metadata.get(['entityAcl', entityType, 'fields', field]) || {};
      if (aclDefs.onlyAdmin || aclDefs.forbidden || aclDefs.internal) {
        return false;
      }
      return true;
    }

    /**
     * @param {string} entityType
     * @param {string} field
     * @return {string[]}
     * @private
     */
    _getEntityTypeFieldFullNameAdditionalAttributeList(entityType, field) {
      return this.metadata.get(`entityDefs.${entityType}.fields.${field}.fullNameAdditionalAttributeList`) ?? [];
    }
  }
  var _default = _exports.default = FieldManager;
});

define("ui/select", ["exports", "lib!selectize"], function (_exports, _libSelectize) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _libSelectize = _interopRequireDefault(_libSelectize);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module module:ui/select */

  /**
   * @typedef module:ui/select~Options
   * @type {Object}
   * @property {boolean} [selectOnTab=false] To select on tab.
   * @property {boolean} [matchAnyWord=false] To match any word when searching.
   * @property {function(string, module:ui/select~OptionItemsCallback): void} [load] Loads additional items
   *   when typing in search.
   * @property {function(string, module:ui/select~OptionItemFull): Number} [score] A score function scoring
   *   searched items.
   * @property {'value'|'text'|'$order'|'$score'} [sortBy='$order'] Item sorting.
   * @property {'asc'|'desc'} [sortDirection='asc'] Sort direction.
   * @property {function()} [onFocus] On-focus callback.
   * @property {
   *     function({value: string}): {
   *         text?: string,
   *         style?: 'default'|'danger'|'success'|'warning'|'info'|null,
   *         color?: string|null,
   *     }
   * } [itemHandler] Handles an item to override the label or add a style. As of v10.0.0.
   */

  /**
   * @callback  module:ui/select~OptionItemsCallback
   * @param {module:ui/select~OptionItem[]} list An option item list.
   */

  /**
   * @typedef module:ui/select~OptionItem
   * @type {Object}
   * @property {string} value A value.
   * @property {string} text A label.
   */

  /**
   * @typedef module:ui/select~OptionItemFull
   * @type {Object}
   * @property {string} value A value.
   * @property {string} text A label.
   * @property {Number} $order An order index.
   */

  /**
   * @module ui/select
   *
   * Important. The Selectize library is heavily customized to fix multitude of UIX issues.
   * Upgrading is not advisable. Consider forking.
   */
  const Select = {
    /**
     * @param {Element|JQuery} element An element.
     * @param {module:ui/select~Options} [options] Options.
     */
    init: function (element) {
      let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
      const score = options.score;
      const $el = $(element);
      options = Select.applyDefaultOptions(options || {});
      const plugins = [];
      Select.loadEspoSelectPlugin();
      plugins.push('espo_select');
      const itemClasses = {};
      const allowedValues = $el.children().toArray().map(item => {
        const value = item.getAttributeNode('value').value;
        if (item.classList) {
          itemClasses[value] = item.classList.toString();
        }
        return value;
      });
      let $relativeParent = null;
      const $modalBody = $el.closest('.modal-body');
      if ($modalBody.length) {
        $relativeParent = $modalBody;
      }

      /**
       *
       * @param {{value: string, text: string}} item
       * @return {{
       *     className: string,
       *     text: string,
       *     prefixElement?: HTMLElement,
       * }}
       */
      const prepareItem = item => {
        let className = itemClasses[item.value] ?? '';
        let text = item.text;
        let prefixElement;
        if (options.itemHandler) {
          const result = options.itemHandler({
            value: item.value
          });
          if (result.style) {
            className = 'text-' + result.style;
          }
          if (result.text != null) {
            text = result.text;
          }
          if (result.color !== undefined) {
            prefixElement = document.createElement('span');
            prefixElement.className = 'color-icon fas fa-square text-soft';
            if (result.color) {
              prefixElement.style.color = result.color;
            }
          }
        }
        return {
          className,
          text,
          prefixElement
        };
      };

      // noinspection JSUnusedGlobalSymbols
      const selectizeOptions = {
        sortField: [{
          field: options.sortBy,
          direction: options.sortDirection
        }],
        load: options.load,
        loadThrottle: 1,
        plugins: plugins,
        highlight: false,
        selectOnTab: options.selectOnTab,
        copyClassesToDropdown: false,
        allowEmptyOption: allowedValues.includes(''),
        showEmptyOptionInDropdown: true,
        $relativeParent: $relativeParent,
        render: {
          item: function (data) {
            const item = prepareItem(data);
            const div = document.createElement('div');
            div.className = item.className;
            div.classList.add('item');
            div.textContent = item.text;
            if (item.prefixElement && data.text !== '') {
              div.prepend(item.prefixElement);
            }
            return div.outerHTML;
          },
          option: function (data) {
            const item = prepareItem(data);
            const div = document.createElement('div');
            div.className = item.className;
            div.classList.add('option');
            div.textContent = item.text;
            div.setAttribute('data-value', data.value);
            if (data.value === '') {
              div.classList.add('selectize-dropdown-emptyoptionlabel');
            }
            if (data.text === '') {
              div.innerHTML = '&nbsp;';
            }
            if (item.prefixElement && data.text !== '') {
              div.prepend(item.prefixElement);
            }
            return div.outerHTML;
          }
        },
        onDelete: function (values) {
          while (values.length) {
            this.removeItem(values.pop(), true);
          }

          // noinspection JSUnresolvedReference
          this.showInput();
          this.positionDropdown();
          this.refreshOptions(true);
        }
      };
      if (options.onFocus) {
        selectizeOptions.onFocus = function () {
          options.onFocus();
        };
      }
      if (!options.matchAnyWord) {
        /** @this Selectize */
        selectizeOptions.score = function (search) {
          // noinspection JSUnresolvedReference
          const score = this.getScoreFunction(search);
          search = search.toLowerCase();
          return function (item) {
            if (item.text.toLowerCase().indexOf(search) === 0) {
              return score(item);
            }
            return 0;
          };
        };
      }
      if (options.matchAnyWord) {
        /** @this Selectize */
        selectizeOptions.score = function (search) {
          // noinspection JSUnresolvedReference
          const score = this.getScoreFunction(search);
          search = search.toLowerCase();
          return function (item) {
            const text = item.text.toLowerCase();
            if (!text.split(' ').find(item => item.startsWith(search)) && !text.startsWith(search)) {
              return 0;
            }
            return score(item);
          };
        };
      }
      if (options.score) {
        selectizeOptions.score = function (search) {
          return function (item) {
            return score(search, item);
          };
        };
      }
      $el.selectize(selectizeOptions);
    },
    /**
     * Focus.
     *
     * @param {Element|JQuery} element An element.
     * @param {{noTrigger?: boolean}} [options] Options.
     */
    focus: function (element, options) {
      const $el = $(element);
      options = options || {};
      if (!$el[0] || !$el[0].selectize) {
        return;
      }
      const selectize = $el[0].selectize;
      if (options.noTrigger) {
        selectize.focusNoTrigger = true;
      }
      selectize.focus();
      if (options.noTrigger) {
        setTimeout(() => selectize.focusNoTrigger = false, 100);
      }
    },
    /**
     * Set options.
     * @todo Side effects may occur if called multiple times. Workaround is to clone and re-initialize. To be fixed.
     *
     * @param {Element|JQuery} element An element.
     * @param {{value: string, text: string}[]} options Options.
     */
    setOptions: function (element, options) {
      const $el = $(element);
      const selectize = $el.get(0).selectize;
      selectize.clearOptions(true);
      selectize.load(callback => {
        callback(options.map(item => {
          return {
            value: item.value,
            text: item.text || item.label
          };
        }));
      });
    },
    /**
     * Set value.
     *
     * @param {HTMLElement|JQuery} element An element.
     * @param {string} value A value.
     */
    setValue: function (element, value) {
      if (!(element instanceof HTMLElement)) {
        element = $(element).get(0);
      }
      const selectize = element.selectize;
      selectize.setValue(value, true);
    },
    /**
     * Destroy.
     *
     * @param {HTMLElement|JQuery} element An element.
     */
    destroy: function (element) {
      if (!element) {
        return;
      }
      if (!(element instanceof HTMLElement)) {
        element = $(element).get(0);
      }
      if (!element || !element.selectize) {
        return;
      }
      element.selectize.destroy();
    },
    /**
     * @private
     * @param {module:ui/select~Options} options
     * @return {module:ui/select~Options}
     */
    applyDefaultOptions: function (options) {
      options = Espo.Utils.clone(options);
      const defaults = {
        selectOnTab: false,
        matchAnyWord: false,
        sortBy: '$order',
        sortDirection: 'asc'
      };
      for (const key in defaults) {
        if (key in options) {
          continue;
        }
        options[key] = defaults[key];
      }
      return options;
    },
    /**
     * @private
     */
    loadEspoSelectPlugin: function () {
      if ('espo_select' in _libSelectize.default.plugins) {
        return;
      }
      const IS_MAC = /Mac/.test(navigator.userAgent);
      const KEY_BACKSPACE = 8;
      _libSelectize.default.define('espo_select', function () {
        const self = this;
        this.setup = function () {
          const original = self.setup;
          return function () {
            original.apply(this, arguments);
            self.selectedValue = self.items[0];
            self.$dropdown.on('mouseup', '[data-selectable]', function () {
              $(document).off('mouseup.select');
              return self.onOptionSelect.apply(self, arguments);
            });
            self.$dropdown.on('mousedown', '[data-selectable]', function () {
              // Prevent issue when down inside, up outside.
              $(document).one('mouseup.select', function () {
                self.focusOnControlSilently();
              });
            });
            self.$control_input.css({
              'width': '4px'
            });
          };
        }();
        this.focusOnControlSilently = function () {
          self.preventReOpenOnFocus = true;
          self.$control_input[0].focus();
          self.preventReOpenOnFocus = false;
        };

        /*this.positionDropdown = (function () {
            let original = self.positionDropdown;
              return function () {
                original.apply(this, arguments);
                  this.$dropdown.css({margin: 'unset'});
            };
        })();*/

        this.refreshOptions = function () {
          const original = self.refreshOptions;
          return function () {
            if (self.focusNoTrigger) {
              original.apply(this, [false]);
              return;
            }
            original.apply(this, arguments);
          };
        }();
        this.blur = function () {
          const original = self.blur;
          return function () {
            // Prevent closing on mouse down.
            if (self.preventClose) {
              return;
            }
            original.apply(this, arguments);
          };
        }();
        this.close = function () {
          const original = self.close;
          return function () {
            if (self.preventClose) {
              return;
            }
            original.apply(this, arguments);
          };
        }();
        this.onOptionSelect = function () {
          const original = self.onOptionSelect;
          return function (e) {
            if (e.type === 'mousedown' || e.type === 'click') {
              self.preventClose = true;
              setTimeout(() => self.preventClose = false, 100);
              return;
            }
            self.preventClose = false;
            if (e.type === 'mouseup') {
              setTimeout(() => self.focusOnControlSilently(), 50);
            }
            original.apply(this, arguments);
            self.selectedValue = $(e.currentTarget).attr('data-value');
          };
        }();
        this.open = function () {
          const original = self.open;
          return function () {
            const toProcess = !(self.isLocked || self.isOpen);
            original.apply(this, arguments);
            if (!toProcess) {
              return;
            }
            const $dropdownContent = self.$dropdown.children().first();
            const $selected = $dropdownContent.find('.selected');
            if (!$selected.length) {
              return;
            }
            let scrollTo = $selected.get(0).offsetTop - $dropdownContent.get(0).clientHeight;
            scrollTo = scrollTo >= 0 ? scrollTo : 0;
            $dropdownContent.find('.selectize-dropdown-content').scrollTop(scrollTo);
          };
        }();
        this.onMouseDown = function () {
          const original = self.onMouseDown;
          return function (e) {
            // Prevent flicking when clicking on input.
            if (!self.isOpen && !self.isInputHidden && self.$control_input.val()) {
              return;
            }
            if (self.isOpen) {
              self.closedByMouseDown = true;
            }
            return original.apply(this, arguments);
          };
        }();
        this.onFocus = function () {
          const original = self.onFocus;
          return function (e) {
            if (self.preventReOpenOnFocus) {
              return;
            }
            if (self.closedByMouseDown) {
              self.closedByMouseDown = false;
              return;
            }
            self.closedByMouseDown = false;
            return original.apply(this, arguments);
          };
        }();
        this.restoreSelectedValue = function () {
          if (this.preventRevertLoop) {
            return;
          }
          this.preventRevertLoop = true;
          setTimeout(() => this.preventRevertLoop = false, 10);
          this.setValue(this.selectedValue, true);
        };
        this.onBlur = function () {
          const original = self.onBlur;
          return function () {
            // Prevent closing on mouse down.
            if (self.preventClose) {
              return;
            }
            self.restoreSelectedValue();
            self.$control_input.css({
              width: '4px'
            });
            return original.apply(this, arguments);
          };
        }();
        this.onKeyDown = function () {
          const original = self.onKeyDown;
          return function (e) {
            if (IS_MAC ? e.metaKey : e.ctrlKey) {
              if (!self.items.length) {
                self.restoreSelectedValue();
                self.focus();
              }
              return;
            }
            if (e.code === 'Escape') {
              if (self.isOpen || !self.isInputHidden) {
                e.stopPropagation();
              }
              if (self.isOpen) {
                self.close();
              }
              if (!self.isInputHidden) {
                self.hideInput();
              }
              self.addItem(this.selectedValue, true);
            }
            if (self.isFull() || self.isInputHidden) {
              if (e.key.length === 1 && (e.code.match(/Key[A-Z]/i) || e.key.match(/[0-9]/) || RegExp(/^\p{L}/, 'u').test(e.key) // is letter
              )) {
                const keyCode = e.keyCode;
                e.keyCode = KEY_BACKSPACE;
                self.deleteSelection(e);
                e.keyCode = keyCode;
                self.$control_input.width(15);
              }
            }
            return original.apply(this, arguments);
          };
        }();
        this.positionDropdown = function () {
          const POSITION = {
            top: 'top',
            bottom: 'bottom'
          };
          return function () {
            const $control = self.$control;
            const offset = this.settings.dropdownParent === 'body' ? $control.offset() : $control.position();
            offset.top += $control.outerHeight(true);
            const dropdownHeight = self.$dropdown.prop('scrollHeight') + 5;
            const controlPosTop = self.$control.get(0).getBoundingClientRect().top;
            const wrapperHeight = self.$wrapper.height();
            const controlPosBottom = self.$control.get(0).getBoundingClientRect().bottom;
            const boundaryTop = !this.settings.$relativeParent ? 0 : this.settings.$relativeParent.get(0).getBoundingClientRect().top;
            const position = controlPosTop + dropdownHeight + wrapperHeight > window.innerHeight && controlPosBottom - dropdownHeight - wrapperHeight >= boundaryTop ? POSITION.top : POSITION.bottom;
            const styles = {
              width: $control.outerWidth(),
              left: offset.left
            };
            if (position === POSITION.top) {
              Object.assign(styles, {
                bottom: offset.top,
                top: 'unset',
                margin: '0 0 0 0'
              });
              self.$dropdown.addClass('selectize-position-top');
            } else {
              Object.assign(styles, {
                top: offset.top,
                bottom: 'unset',
                margin: '0 0 0 0'
              });
              self.$dropdown.removeClass('selectize-position-top');
            }
            self.$dropdown.css(styles);
          };
        }();
      });
    }
  };
  var _default = _exports.default = Select;
});

define("helpers/record-modal", ["exports", "di", "metadata", "acl-manager", "router", "helpers/site/modal-bar-provider", "views/modals/edit", "language"], function (_exports, _di, _metadata, _aclManager, _router, _modalBarProvider, _edit, _language) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _metadata = _interopRequireDefault(_metadata);
  _aclManager = _interopRequireDefault(_aclManager);
  _router = _interopRequireDefault(_router);
  _modalBarProvider = _interopRequireDefault(_modalBarProvider);
  _edit = _interopRequireDefault(_edit);
  _language = _interopRequireDefault(_language);
  var _staticBlock;
  let _init_metadata, _init_extra_metadata, _init_acl, _init_extra_acl, _init_router, _init_extra_router, _init_language, _init_extra_language, _init_modalBarProvider, _init_extra_modalBarProvider;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  /**
   * A record-modal helper. Use to render the quick view and quick edit modals.
   */
  class RecordModalHelper {
    constructor() {
      _init_extra_modalBarProvider(this);
    }
    /**
     * @private
     * @type {Metadata}
     */
    metadata = _init_metadata(this);

    /**
     * @private
     * @type {AclManager}
     */
    acl = (_init_extra_metadata(this), _init_acl(this));

    /**
     * @private
     * @type {Router}
     */
    router = (_init_extra_acl(this), _init_router(this));

    /**
     * @private
     * @type {Language}
     */
    language = (_init_extra_router(this), _init_language(this));

    /**
     * @private
     * @type {ModalBarProvider}
     */
    modalBarProvider = (_init_extra_language(this), _init_modalBarProvider(this));

    /**
     * Show the 'detail' modal.
     *
     * @param {import('view').default<any>} view
     * @param {{
     *   id: string,
     *   entityType: string,
     *   model?: import('model').default | null,
     *   editDisabled?: boolean,
     *   removeDisabled?: boolean,
     *   fullFormDisabled?: boolean,
     *   rootUrl?: string,
     *   fullFormUrl?: string,
     *   layoutName?: string,
     *   beforeSave?: function(import('model').default, Record),
     *   afterSave?: function(import('model').default, {bypassClose: boolean} & Record),
     *   beforeDestroy?: function(import('model').default),
     *   afterDestroy?: function(import('model').default),
     *   beforeRender?: function(import('views/modals/detail').default),
     *   onClose?: function(),
     *   collapseDisabled?: boolean,
     * }} params
     * @return {Promise<import('views/modals/detail').default>}
     */
    async showDetail(view, params) {
      const id = params.id;
      // noinspection JSUnresolvedReference
      const entityType = params.entityType || params.scope;
      const model = params.model;
      if (!id || !entityType) {
        console.error("Bad data.");
        return Promise.reject();
      }
      if (model && !this.acl.checkScope(model.entityType, 'read')) {
        return Promise.reject();
      }
      const viewName = this.metadata.get(`clientDefs.${entityType}.modalViews.detail`) || 'views/modals/detail';
      Espo.Ui.notifyWait();

      /** @type {module:views/modals/detail~options & module:views/modal~Options} */
      const options = {
        entityType: entityType,
        model: model,
        id: id,
        quickEditDisabled: params.editDisabled,
        rootUrl: params.rootUrl,
        removeDisabled: params.removeDisabled,
        layoutName: params.layoutName,
        fullFormDisabled: params.fullFormDisabled,
        fullFormUrl: params.fullFormUrl,
        collapseDisabled: params.collapseDisabled
      };
      Espo.Ui.notifyWait();
      const modalView = /** @type {import('views/modals/detail').default} */
      await view.createView('modal', viewName, options);

      // @todo Revise.
      view.listenToOnce(modalView, 'remove', () => view.clearView('modal'));
      if (params.beforeSave) {
        modalView.listenTo(modalView, 'before:save', (model, o) => {
          params.beforeSave(model, o);
        });
      }
      if (params.afterSave) {
        modalView.listenTo(modalView, 'after:save', (model, /** Record */o) => {
          params.afterSave(model, {
            ...o
          });
        });
      }
      if (params.beforeDestroy) {
        modalView.listenToOnce(modalView, 'before:delete', model => params.beforeDestroy(model));
      }
      if (params.afterDestroy) {
        modalView.listenToOnce(modalView, 'after:delete', model => params.afterDestroy(model));
      }
      if (params.beforeRender) {
        params.beforeRender(modalView);
      }
      if (params.onClose) {
        view.listenToOnce(modalView, 'close', () => params.onClose());
      }
      await modalView.render();
      Espo.Ui.notify();
      return modalView;
    }

    /**
     * Show the 'edit' modal.
     *
     * @param {import('view').default} view
     * @param {{
     *   entityType: string,
     *   id?: string,
     *   model?: import('model').default | null,
     *   rootUrl?: string,
     *   fullFormDisabled?: boolean,
     *   fullFormUrl?: string,
     *   returnUrl?: string,
     *   layoutName?: string,
     *   beforeSave?: function(import('model').default, Record),
     *   afterSave?: function(import('model').default, {bypassClose: boolean} & Record),
     *   beforeRender?: function(import('views/modals/edit').default),
     *   onClose?: function(),
     *   returnDispatchParams?: {
     *       controller: string,
     *       action: string|null,
     *       options: {isReturn?: boolean} & Record,
     *   },
     *   collapseDisabled?: boolean,
     * }} params
     * @return {Promise<import('views/modals/edit').default>}
     * @since 9.1.0
     */
    async showEdit(view, params) {
      const id = params.id;
      const entityType = params.entityType;
      const model = params.model;
      if (this.modalBarProvider.get()) {
        const barView = this.modalBarProvider.get();
        const foundModalView = barView.getModalViewList().find(view => {
          return view instanceof _edit.default && view.id === id && view.entityType === entityType;
        });
        if (foundModalView) {
          const message = this.language.translate('sameRecordIsAlreadyBeingEdited', 'messages');
          Espo.Ui.warning(message);
          throw new Error();
        }
      }
      const viewName = this.metadata.get(`clientDefs.${entityType}.modalViews.edit`) || 'views/modals/edit';

      /** @type {module:views/modals/edit~options & module:views/modal~Options} */
      const options = {
        entityType: entityType,
        id: id,
        model: model,
        fullFormDisabled: params.fullFormDisabled,
        returnUrl: params.returnUrl || this.router.getCurrentUrl(),
        returnDispatchParams: params.returnDispatchParams,
        layoutName: params.layoutName,
        fullFormUrl: params.fullFormUrl,
        collapseDisabled: params.collapseDisabled
      };
      if (params.rootUrl) {
        options.rootUrl = params.rootUrl;
      }
      Espo.Ui.notifyWait();
      const modalView = /** @type {import('views/modals/edit').default} */
      await view.createView('modal', viewName, options);

      // @todo Revise.
      modalView.listenToOnce(modalView, 'remove', () => view.clearView('modal'));
      if (params.beforeSave) {
        modalView.listenTo(modalView, 'before:save', (model, o) => {
          params.beforeSave(model, o);
        });
      }
      if (params.afterSave) {
        modalView.listenTo(modalView, 'after:save', (model, /** Record */o) => {
          params.afterSave(model, {
            ...o
          });
        });
      }
      if (params.beforeRender) {
        params.beforeRender(modalView);
      }
      if (params.onClose) {
        view.listenToOnce(modalView, 'close', () => params.onClose());
      }
      await modalView.render();
      Espo.Ui.notify();
      return modalView;
    }

    /**
     * Show the 'create' modal.
     *
     * @param {import('view').default<any>} view
     * @param {{
     *   entityType: string,
     *   rootUrl?: string,
     *   fullFormDisabled?: boolean,
     *   fullFormUrl?: string,
     *   returnUrl?: string,
     *   relate?: import('model').SetRelateItem | import('model').SetRelateItem[],
     *   attributes?: Record.<string, *>,
     *   afterSave?: function(import('model').default, {bypassClose: boolean} & Record),
     *   beforeRender?: function(import('views/modals/edit').default),
     *   onClose?: function(),
     *   focusForCreate?: boolean,
     *   layoutName?: string,
     *   returnDispatchParams?: {
     *       controller: string,
     *       action: string|null,
     *       options: {isReturn?: boolean} & Record,
     *   },
     *   collapseDisabled?: boolean,
     * }} params
     * @return {Promise<import('views/modals/edit').default>}
     * @since 9.1.0
     */
    async showCreate(view, params) {
      const entityType = params.entityType;
      const viewName = this.metadata.get(`clientDefs.${entityType}.modalViews.edit`) || 'views/modals/edit';

      /** @type {module:views/modals/edit~options & module:views/modal~Options} */
      const options = {
        entityType: entityType,
        fullFormDisabled: params.fullFormDisabled,
        returnUrl: params.returnUrl || this.router.getCurrentUrl(),
        returnDispatchParams: params.returnDispatchParams,
        relate: params.relate,
        attributes: params.attributes,
        focusForCreate: params.focusForCreate,
        layoutName: params.layoutName,
        fullFormUrl: params.fullFormUrl,
        collapseDisabled: params.collapseDisabled
      };
      if (params.rootUrl) {
        options.rootUrl = params.rootUrl;
      }
      Espo.Ui.notifyWait();
      const modalView = /** @type {import('views/modals/edit').default} */
      await view.createView('modal', viewName, options);

      // @todo Revise.
      modalView.listenToOnce(modalView, 'remove', () => view.clearView('modal'));
      if (params.afterSave) {
        modalView.listenTo(modalView, 'after:save', (model, /** Record */o) => {
          params.afterSave(model, {
            ...o
          });
        });
      }
      if (params.beforeRender) {
        params.beforeRender(modalView);
      }
      if (params.onClose) {
        view.listenToOnce(modalView, 'close', () => params.onClose());
      }
      await modalView.render();
      Espo.Ui.notify();
      return modalView;
    }
    static #_ = _staticBlock = () => [_init_metadata, _init_extra_metadata, _init_acl, _init_extra_acl, _init_router, _init_extra_router, _init_language, _init_extra_language, _init_modalBarProvider, _init_extra_modalBarProvider] = _applyDecs(this, [], [[(0, _di.inject)(_metadata.default), 0, "metadata"], [(0, _di.inject)(_aclManager.default), 0, "acl"], [(0, _di.inject)(_router.default), 0, "router"], [(0, _di.inject)(_language.default), 0, "language"], [(0, _di.inject)(_modalBarProvider.default), 0, "modalBarProvider"]]).e;
  }
  _staticBlock();
  var _default = _exports.default = RecordModalHelper;
});

define("view-record-helper", ["exports", "bullbone"], function (_exports, _bullbone) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module view-record-helper */

  class ViewRecordHelper {
    /**
     * @param [defaultFieldStates] Default field states.
     * @param [defaultPanelStates] Default panel states.
     */
    constructor() {
      let defaultFieldStates = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      let defaultPanelStates = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
      this.defaultFieldStates = defaultFieldStates;
      this.defaultPanelStates = defaultPanelStates;
      this.fieldStateMap = {};
      this.panelStateMap = {};
      this.hiddenFields = {};
      this.hiddenPanels = {};
      this.fieldOptionListMap = {};
      this.state = {
        isChanged: false
      };
    }

    /**
     * Get hidden fields.
     */
    getHiddenFields() {
      return this.hiddenFields;
    }

    /**
     * Get hidden panels.
     */
    getHiddenPanels() {
      return this.hiddenPanels;
    }

    /**
     * Set a field-state parameter.
     *
     * @param field A field name.
     * @param name A parameter.
     * @param value A value.
     */
    setFieldStateParam(field, name, value) {
      switch (name) {
        case 'hidden':
          if (value) {
            this.hiddenFields[field] = true;
          } else {
            delete this.hiddenFields[field];
          }
          break;
      }
      this.fieldStateMap[field] = this.fieldStateMap[field] || {};
      this.fieldStateMap[field][name] = value;
      this.trigger('field-change');
    }

    /**
     * Get a field-state parameter.
     *
     * @param field A field name.
     * @param name A parameter.
     * @returns A value.
     */
    getFieldStateParam(field, name) {
      if (field in this.fieldStateMap) {
        if (name in this.fieldStateMap[field]) {
          return this.fieldStateMap[field][name];
        }
      }
      if (name in this.defaultFieldStates) {
        return this.defaultFieldStates[name];
      }
      return null;
    }

    /**
     * Set a panel-state parameter.
     *
     * @param {string} panel A panel name.
     * @param {string|'hidden'} name A parameter.
     * @param {*} value A value.
     */
    setPanelStateParam(panel, name, value) {
      switch (name) {
        case 'hidden':
          if (value) {
            this.hiddenPanels[panel] = true;
          } else {
            delete this.hiddenPanels[panel];
          }
          break;
      }
      this.panelStateMap[panel] = this.panelStateMap[panel] || {};
      this.panelStateMap[panel][name] = value;
    }

    /**
     * Get a panel-state parameter.
     *
     * @param panel A panel name.
     * @param name A parameter.
     * @returns A value.
     */
    getPanelStateParam(panel, name) {
      if (panel in this.panelStateMap) {
        if (name in this.panelStateMap[panel]) {
          return this.panelStateMap[panel][name];
        }
      }
      if (name in this.defaultPanelStates) {
        return this.defaultPanelStates[name];
      }
      return null;
    }

    /**
     * Set a field option list.
     *
     * @param field A field name.
     * @param list An option list.
     */
    setFieldOptionList(field, list) {
      this.fieldOptionListMap[field] = list;
    }

    /**
     * Clear a field option list.
     *
     * @param field A field name.
     */
    clearFieldOptionList(field) {
      delete this.fieldOptionListMap[field];
    }

    /**
     * Get a field option list.
     *
     * @param field A field name.
     * @returns Null if not set.
     */
    getFieldOptionList(field) {
      return this.fieldOptionListMap[field] ?? null;
    }

    /**
     * Whether a field option list is set.
     *
     * @param field A field name.
     */
    hasFieldOptionList(field) {
      return field in this.fieldOptionListMap;
    }

    /**
     * Is changed.
     *
     * @since 9.2.0
     */
    isChanged() {
      return this.state.isChanged;
    }

    /**
     * Set is changed.
     *
     * @param isChanged
     * @since 9.2.0
     */
    setIsChanged(isChanged) {
      this.state.isChanged = isChanged;
    }

    /**
     * Subscribe to an event.
     *
     * @param {string} name An event.
     * @param {function(...any)} callback A callback.
     */
    on(name, callback) {
      _bullbone.Events.on.call(this, name, callback, arguments[2]);
      return this;
    }

    /**
     * Subscribe to an event. Fired once.
     *
     * @param {string} name An event.
     * @param {function(...any)} callback A callback.
     */
    once(name, callback) {
      _bullbone.Events.once.call(this, name, callback, arguments[2]);
      return this;
    }

    /**
     * Unsubscribe from an event or all events.
     *
     * @param {string} [name] From a specific event.
     * @param {function()} [callback] From a specific callback.
     */
    off(name, callback) {
      _bullbone.Events.off.call(this, name, callback, arguments[2]);
      return this;
    }

    /**
     * Subscribe to an event of other object.
     *
     * @param {Object} other What to listen.
     * @param {string} name An event.
     * @param callback A callback.
     */
    listenTo(other, name, callback) {
      _bullbone.Events.listenTo.call(this, other, name, callback);
      return this;
    }

    /**
     * Subscribe to an event of other object. Fired once. Will be automatically unsubscribed on view removal.
     *
     * @param {Object} other What to listen.
     * @param {string} name An event.
     * @param {function()} callback A callback.
     */
    listenToOnce(other, name, callback) {
      _bullbone.Events.listenToOnce.call(this, other, name, callback);
      return this;
    }

    /**
     * Stop listening to other object. No arguments will remove all listeners.
     *
     * @param {Object} [other] To remove listeners to a specific object.
     * @param {string} [name] To remove listeners to a specific event.
     * @param {function()} [callback] To remove listeners to a specific callback.
     */
    stopListening(other, name, callback) {
      _bullbone.Events.stopListening.call(this, other, name, callback);
      return this;
    }

    /**
     * Trigger an event.
     *
     * @param {string} name An event.
     * @param {...*} parameters Arguments.
     */
    trigger(name) {
      for (var _len = arguments.length, parameters = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
        parameters[_key - 1] = arguments[_key];
      }
      _bullbone.Events.trigger.call(this, name, ...parameters);
      return this;
    }
  }
  _exports.default = ViewRecordHelper;
});

define("dynamic-logic", ["exports", "di", "field-manager"], function (_exports, _di, _fieldManager) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _fieldManager = _interopRequireDefault(_fieldManager);
  var _staticBlock;
  let _init_fieldManager, _init_extra_fieldManager;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  /**
   * Definitions.
   */
  /**
   * Field definitions.
   */
  /**
   * Panel definitions.
   */
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  /**
   * Dynamic logic. Handles form appearance and behavior depending on conditions.
   *
   * @internal Instantiated in advanced-pack.
   */
  class DynamicLogic {
    fieldTypeList = ['visible', 'required', 'readOnlySaved', 'readOnly'];
    panelTypeList = ['visible', 'styled'];
    fieldManager = _init_fieldManager(this);

    /**
     * @param  defs Definitions.
     * @param  recordView A record view.
     */
    constructor(defs, recordView) {
      _init_extra_fieldManager(this);
      this.defs = defs ?? {};
      this.recordView = recordView;
      this.cascadingClearDefs = this.buildCascadingClearDefs();
    }

    /**
     * Process.
     *
     * @param options Options.
     */
    process() {
      let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      const fields = this.defs.fields ?? {};
      Object.keys(fields).forEach(field => {
        const item = fields[field] || {};
        let readOnlyIsProcessed = false;
        this.fieldTypeList.forEach(type => {
          if (!(type in item) || !item[type]) {
            return;
          }
          const typeItem = item[type] || {};
          if (!typeItem.conditionGroup) {
            return;
          }
          if (type === 'readOnlySaved') {
            if (this.recordView.model.isNew()) {
              return;
            }
            if (this.checkConditionGroupInternal(typeItem.conditionGroup, 'and', true)) {
              this.makeFieldReadOnlyTrue(field);
              readOnlyIsProcessed = true;
            } else {
              this.makeFieldReadOnlyFalse(field);
            }
            return;
          }
          const result = this.checkConditionGroupInternal(typeItem.conditionGroup);
          if (type === 'required' && !readOnlyIsProcessed) {
            result ? this.makeFieldRequiredTrue(field) : this.makeFieldRequiredFalse(field);
            return;
          }
          if (type === 'readOnly') {
            result ? this.makeFieldReadOnlyTrue(field) : this.makeFieldReadOnlyFalse(field);
            return;
          }
          if (type === 'visible') {
            result ? this.makeFieldVisibleTrue(field) : this.makeFieldVisibleFalse(field);
          }
        });
      });
      const panels = this.defs.panels ?? {};
      Object.keys(panels).forEach(panel => {
        this.panelTypeList.forEach(type => {
          this.processPanel(panel, type);
        });
      });
      const optionsDefs = this.defs.options ?? {};
      Object.keys(optionsDefs).forEach(field => {
        const itemList = optionsDefs[field];
        if (!optionsDefs[field]) {
          return;
        }
        let isMet = false;
        for (const item of itemList) {
          if (this.checkConditionGroupInternal(item.conditionGroup)) {
            this.setOptionList(field, item.optionList || []);
            isMet = true;
            break;
          }
        }
        if (!isMet) {
          this.resetOptionList(field);
        }
      });
      if (options.action === 'ui') {
        this.processCascadingClear();
      }
    }
    buildCascadingClearDefs() {
      const fields = this.defs.cascadingFields ?? null;
      if (!fields || Object.keys(fields).length === 0) {
        return {};
      }
      const model = this.recordView.model;
      const map = {};
      for (const [field, defs] of Object.entries(fields)) {
        const items = defs === null || defs === void 0 ? void 0 : defs.items;
        if (!items || !items.length) {
          continue;
        }
        for (const item of items) {
          if (!item.matchRequired) {
            continue;
          }
          const type = model.getFieldType(item.localField);
          const idAttribute = type === 'linkMultiple' ? item.localField + 'Ids' : item.localField + 'Id';
          map[idAttribute] ??= [];
          const attributeList = model.entityType ? this.fieldManager.getEntityTypeFieldAttributeList(model.entityType, field) : [];
          map[idAttribute].push(...attributeList);
        }
      }
      for (const [attribute, a] of Object.entries(map)) {
        map[attribute] = a.filter((it, i) => a.indexOf(it) === i);
      }
      return map;
    }
    processCascadingClear() {
      const attributeList = Object.keys(this.cascadingClearDefs);
      const model = this.recordView.model;
      const fieldsToUnset = [];
      for (const attribute of attributeList) {
        if (model.hasChanged(attribute)) {
          fieldsToUnset.push(...this.cascadingClearDefs[attribute]);
        }
      }
      if (!fieldsToUnset.length) {
        return;
      }
      const map = fieldsToUnset.reduce((p, it) => {
        p[it] = null;
        return p;
      }, {});
      setTimeout(() => {
        model.setMultiple(map);
      }, 0);
    }

    /**
     * @param panel A panel name.
     * @param type A type.
     */
    processPanel(panel, type) {
      const panels = this.defs.panels ?? {};
      const item = panels[panel] || {};
      if (!(type in item)) {
        return;
      }
      const typeItem = item[type] ?? {};
      if (!typeItem.conditionGroup) {
        return;
      }
      const result = this.checkConditionGroupInternal(typeItem.conditionGroup);
      if (type === 'visible') {
        result ? this.makePanelVisibleTrue(panel) : this.makePanelVisibleFalse(panel);
      }
      if (type === 'styled') {
        result ? this.makePanelStyledTrue(panel) : this.makePanelStyledFalse(panel);
      }
    }

    /**
     * Check a condition group.
     *
     * @param data A condition group.
     * @returns {boolean}
     */
    checkConditionGroup(data) {
      return this.checkConditionGroupInternal(data);
    }
    checkConditionGroupInternal(data) {
      let type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'and';
      let preSave = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
      type = type || 'and';
      let list;
      let result = false;
      if (type === 'and') {
        list = data || [];
        result = true;
        for (const it of list) {
          if (!this.checkCondition(it, preSave)) {
            result = false;
            break;
          }
        }
      } else if (type === 'or') {
        list = data || [];
        for (const it of list) {
          if (this.checkCondition(it, preSave)) {
            result = true;
            break;
          }
        }
      } else if (type === 'not') {
        if (data) {
          result = !this.checkCondition(data, preSave);
        }
      }
      return result;
    }
    getAttributeValue(attribute, preSave) {
      if (attribute.startsWith('$')) {
        if (attribute === '$user.id') {
          return this.recordView.getUser().id;
        }
        if (attribute === '$user.teamsIds') {
          return this.recordView.getUser().getTeamIdList();
        }
      }
      if (preSave) {
        return this.recordView.getPreSaveAttributes()[attribute];
      }
      if (!this.recordView.model.has(attribute)) {
        return undefined;
      }
      return this.recordView.model.get(attribute);
    }
    checkCondition(defs, preSave) {
      defs = defs || {};
      const type = defs.type || 'equals';
      if (['or', 'and', 'not'].includes(type)) {
        return this.checkConditionGroupInternal(defs.value, type, preSave);
      }
      const attribute = defs.attribute;
      const value = defs.value;
      if (!attribute) {
        return false;
      }
      const setValue = this.getAttributeValue(attribute, preSave);
      if (type === 'equals') {
        return setValue === value;
      }
      if (type === 'notEquals') {
        return setValue !== value;
      }
      if (type === 'isEmpty') {
        if (Array.isArray(setValue)) {
          return !setValue.length;
        }
        return setValue === null || setValue === '' || typeof setValue === 'undefined';
      }
      if (type === 'isNotEmpty') {
        if (Array.isArray(setValue)) {
          return !!setValue.length;
        }
        return setValue !== null && setValue !== '' && typeof setValue !== 'undefined';
      }
      if (type === 'isTrue') {
        return !!setValue;
      }
      if (type === 'isFalse') {
        return !setValue;
      }
      if (type === 'contains' || type === 'has') {
        if (!setValue || !hasIncludes(setValue)) {
          return false;
        }
        return setValue.includes(value);
      }
      if (type === 'notContains' || type === 'notHas') {
        if (!setValue || !hasIncludes(setValue)) {
          return true;
        }
        return !setValue.includes(value);
      }
      if (type === 'startsWith') {
        if (!setValue || !hasIndexOf(setValue)) {
          return false;
        }
        return setValue.indexOf(value) === 0;
      }
      if (type === 'endsWith') {
        if (!setValue || !hasIndexOf(setValue)) {
          return false;
        }
        return setValue.indexOf(value) === setValue.length - value.length;
      }
      if (type === 'matches') {
        if (!setValue || typeof setValue !== 'string') {
          return false;
        }
        const match = /^\/(.*)\/([a-z]*)$/.exec(value);
        if (!match || match.length < 2) {
          return false;
        }
        return new RegExp(match[1], match[2]).test(setValue);
      }
      if (type === 'greaterThan') {
        return setValue > value;
      }
      if (type === 'lessThan') {
        return setValue < value;
      }
      if (type === 'greaterThanOrEquals') {
        return setValue >= value;
      }
      if (type === 'lessThanOrEquals') {
        return setValue <= value;
      }
      if (type === 'in') {
        return !!~value.indexOf(setValue);
      }
      if (type === 'notIn') {
        return !~value.indexOf(setValue);
      }
      if (type === 'isToday') {
        const dateTime = this.recordView.getDateTime();
        if (!setValue || typeof setValue !== 'string') {
          return false;
        }
        if (setValue.length > 10) {
          return dateTime.toMoment(setValue).isSame(dateTime.getNowMoment(), 'day');
        }
        return dateTime.toMomentDate(setValue).isSame(dateTime.getNowMoment(), 'day');
      }
      if (type === 'inFuture') {
        const dateTime = this.recordView.getDateTime();
        if (!setValue || typeof setValue !== 'string') {
          return false;
        }
        if (setValue.length > 10) {
          return dateTime.toMoment(setValue).isAfter(dateTime.getNowMoment(), 'second');
        }
        return dateTime.toMomentDate(setValue).isAfter(dateTime.getNowMoment(), 'day');
      }
      if (type === 'inPast') {
        const dateTime = this.recordView.getDateTime();
        if (!setValue || typeof setValue !== 'string') {
          return false;
        }
        if (setValue.length > 10) {
          return dateTime.toMoment(setValue).isBefore(dateTime.getNowMoment(), 'second');
        }
        return dateTime.toMomentDate(setValue).isBefore(dateTime.getNowMoment(), 'day');
      }
      return false;
    }
    setOptionList(field, optionList) {
      this.recordView.setFieldOptionList(field, optionList);
    }
    resetOptionList(field) {
      this.recordView.resetFieldOptionList(field);
    }
    makeFieldVisibleTrue(field) {
      this.recordView.showField(field);
    }
    makeFieldVisibleFalse(field) {
      this.recordView.hideField(field);
    }
    makeFieldRequiredTrue(field) {
      this.recordView.setFieldRequired(field);
    }
    makeFieldRequiredFalse(field) {
      this.recordView.setFieldNotRequired(field);
    }
    makeFieldReadOnlyTrue(field) {
      this.recordView.setFieldReadOnly(field);
    }
    makeFieldReadOnlyFalse(field) {
      this.recordView.setFieldNotReadOnly(field);
    }
    makePanelVisibleTrue(panel) {
      this.recordView.showPanel(panel, 'dynamicLogic');
    }
    makePanelVisibleFalse(panel) {
      this.recordView.hidePanel(panel, false, 'dynamicLogic');
    }
    makePanelStyledTrue(panel) {
      this.recordView.stylePanel(panel);
    }
    makePanelStyledFalse(panel) {
      this.recordView.unstylePanel(panel);
    }

    /**
     * Add a panel-visible condition.
     *
     * @param name A panel name.
     * @param item Condition definitions.
     */
    addPanelVisibleCondition(name, item) {
      this.defs.panels = this.defs.panels ?? {};
      this.defs.panels[name] = this.defs.panels[name] ?? {};
      this.defs.panels[name].visible = item;
      this.processPanel(name, 'visible');
    }

    /**
     * Add a panel-styled condition.
     *
     * @param name A panel name.
     * @param item Condition definitions.
     */
    addPanelStyledCondition(name, item) {
      this.defs.panels = this.defs.panels ?? {};
      this.defs.panels[name] = this.defs.panels[name] ?? {};
      this.defs.panels[name].styled = item;
      this.processPanel(name, 'styled');
    }
    static #_ = _staticBlock = () => [_init_fieldManager, _init_extra_fieldManager] = _applyDecs(this, [], [[(0, _di.inject)(_fieldManager.default), 0, "fieldManager"]]).e;
  }
  _staticBlock();
  var _default = _exports.default = DynamicLogic;
  function hasIncludes(item) {
    return typeof (item === null || item === void 0 ? void 0 : item.includes) === 'function';
  }
  function hasIndexOf(item) {
    return typeof (item === null || item === void 0 ? void 0 : item.indexOf) === 'function';
  }
});

define("views/modals/select-records", ["exports", "views/modal", "search-manager", "helpers/record-modal"], function (_exports, _modal, _searchManager, _recordModal) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  _searchManager = _interopRequireDefault(_searchManager);
  _recordModal = _interopRequireDefault(_recordModal);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/modals/select-records */

  /**
   * A select-records modal.
   */
  class SelectRecordsModalView extends _modal.default {
    template = 'modals/select-records';
    cssName = 'select-modal';
    className = 'dialog dialog-record';
    multiple = false;
    createButton = true;
    searchPanel = true;
    scope = '';
    noCreateScopeList = ['User', 'Team', 'Role', 'Portal'];
    layoutName = 'listSmall';

    /** @inheritDoc */
    shortcutKeys = {
      /** @this SelectRecordsModalView */
      'Control+Enter': function (e) {
        this.handleShortcutKeyCtrlEnter(e);
      },
      /** @this SelectRecordsModalView */
      'Control+Space': function (e) {
        this.handleShortcutKeyCtrlSpace(e);
      },
      /** @this SelectRecordsModalView */
      'Control+Slash': function (e) {
        this.handleShortcutKeyCtrlSlash(e);
      },
      /** @this SelectRecordsModalView */
      'Control+Comma': function (e) {
        this.handleShortcutKeyCtrlComma(e);
      },
      /** @this SelectRecordsModalView */
      'Control+Period': function (e) {
        this.handleShortcutKeyCtrlPeriod(e);
      }
    };
    events = {
      /** @this SelectRecordsModalView */
      'click button[data-action="create"]': function () {
        this.create();
      },
      /** @this SelectRecordsModalView */
      'click .list a': function (e) {
        e.preventDefault();
      }
    };

    /**
     * @typedef {Object} module:views/modals/select-records~Options
     * @property {string} entityType An entity type.
     * @property {Object.<string, import('search-manager').AdvancedFilter>} [filters] Filters.
     * @property {string[]} [boolFilterList] Bool filters.
     * @property {string} [primaryFilterName] A primary filter.
     * @property {string[]} [filterList] A filter list.
     * @property {string} [layoutName] A layout name.
     * @property {boolean} [multiple] Allow select multiple.
     * @property {boolean} [createButton] A create button.
     * @property {boolean} [massRelateEnabled] Mass-relate.
     * @property {string} [orderBy] An order-by.
     * @property {'asc'|'desc'} [orderDirection] An order direction.
     * @property {boolean} [forceSelectAllAttributes] Force select all attributes.
     * @property {string[]} [mandatorySelectAttributeList] Mandatory attributes to select.
     * @property {function(): Promise<Record>} [createAttributesProvider] Create-attributes provider.
     * @property {Record} [createAttributes] Create-attributes.
     * @property {function(import('model').default[])} [onSelect] On record select. As of 9.0.0.
     * @property {function({where: Record[], searchParams: import('collection').SearchData})} [onMassSelect]
     *     On record select. As of 9.1.0.
     * @property {function()} [onCreate] On create click. As of 9.0.5.
     * @property {boolean} [searchPanelDisabled] Disable the search panel.
     */

    /**
     *
     * @param {module:views/modals/select-records~Options | module:views/modal~Options} options
     */
    constructor(options) {
      super(options);
      if (options.onSelect) {
        /** @private */
        this.onSelect = options.onSelect;
      }
      if (options.onMassSelect) {
        /** @private */
        this.onMassSelect = options.onMassSelect;
      }
      if (options.onCreate) {
        /** @private */
        this.onCreate = options.onCreate;
      }

      /** @private */
      this.createAttributesProvider = options.createAttributesProvider;
      this.options = options;
    }
    data() {
      return {
        createButton: this.createButton,
        createText: this.translate('Create ' + this.scope, 'labels', this.scope)
      };
    }
    setup() {
      this.filters = this.options.filters || {};
      this.boolFilterList = this.options.boolFilterList;
      this.primaryFilterName = this.options.primaryFilterName || null;
      this.filterList = this.options.filterList || this.filterList || null;
      this.layoutName = this.options.layoutName || this.layoutName;
      if ('multiple' in this.options) {
        this.multiple = this.options.multiple;
      }
      if ('createButton' in this.options) {
        this.createButton = this.options.createButton;
      }
      this.massRelateEnabled = this.options.massRelateEnabled;
      this.buttonList = [{
        name: 'cancel',
        label: 'Cancel'
      }];
      if (this.multiple) {
        this.buttonList.unshift({
          name: 'select',
          style: 'danger',
          label: 'Select',
          disabled: true,
          title: 'Ctrl+Enter'
        });
      }

      // noinspection JSUnresolvedReference
      this.scope = this.entityType = this.options.scope || this.scope || this.options.entityType;
      const orderBy = this.options.orderBy || this.getMetadata().get(['clientDefs', this.scope, 'selectRecords', 'orderBy']);
      const order = this.options.orderDirection || this.getMetadata().get(['clientDefs', this.scope, 'selectRecords', 'order']);
      if (orderBy) {
        this.defaultOrderBy = orderBy;
        this.defaultOrder = order || false;
      }
      if (this.noCreateScopeList.indexOf(this.scope) !== -1) {
        this.createButton = false;
      }
      if (this.createButton) {
        if (!this.getAcl().check(this.scope, 'create') || this.getMetadata().get(['clientDefs', this.scope, 'createDisabled'])) {
          this.createButton = false;
        }
      }
      if (this.createButton) {
        this.addButton({
          name: 'create',
          position: 'right',
          onClick: () => this.create(),
          iconClass: 'fas fa-plus fa-sm',
          label: 'Create'
        });
      }
      if (this.getMetadata().get(['clientDefs', this.scope, 'searchPanelDisabled'])) {
        this.searchPanel = false;
      }
      if (this.getUser().isPortal()) {
        if (this.getMetadata().get(['clientDefs', this.scope, 'searchPanelInPortalDisabled'])) {
          this.searchPanel = false;
        }
      }
      if (this.options.searchPanelDisabled) {
        this.searchPanel = false;
      }
      if (!this.options.headerText) {
        this.$header = $('<span>');
        this.$header.append($('<span>').text(this.translate('Select') + ' · ' + this.getLanguage().translate(this.scope, 'scopeNamesPlural')));
        this.$header.prepend(this.getHelper().getScopeColorIconHtml(this.scope));
      }
      this.waitForView('list');
      if (this.searchPanel) {
        this.waitForView('search');
      }
      this.getCollectionFactory().create(this.scope, collection => {
        collection.maxSize = this.getConfig().get('recordsPerPageSelect') || 5;
        this.collection = collection;
        if (this.defaultOrderBy) {
          this.collection.setOrder(this.defaultOrderBy, this.defaultOrder || 'asc', true);
        }
        this.setupSearch();
        this.setupList();
      });

      // If the list not yet loaded.
      this.once('close', () => {
        if (this.collection.lastSyncPromise && this.collection.lastSyncPromise.getStatus() < 4) {
          Espo.Ui.notify(false);
        }
        this.collection.abortLastFetch();
      });
    }
    setupSearch() {
      this.searchManager = new _searchManager.default(this.collection, {
        emptyOnReset: true
      });
      if (this.filters) {
        this.searchManager.setAdvanced(this.filters);
      }
      const boolFilterList = this.boolFilterList || this.getMetadata().get(`clientDefs.${this.scope}.selectDefaultFilters.boolFilterList`);
      if (boolFilterList) {
        this.searchManager.setBool(boolFilterList);
      }
      const primaryFilterName = this.primaryFilterName || this.getMetadata().get(`clientDefs.${this.scope}.selectDefaultFilters.filter`);
      if (primaryFilterName) {
        this.searchManager.setPrimary(primaryFilterName);
      }
      this.collection.where = this.searchManager.getWhere();
      if (this.searchPanel) {
        this.createView('search', 'views/record/search', {
          collection: this.collection,
          fullSelector: this.containerSelector + ' .search-container',
          searchManager: this.searchManager,
          disableSavePreset: true,
          filterList: this.filterList
        }, view => {
          this.listenTo(view, 'reset', () => {});
        });
      }
    }
    setupList() {
      const viewName = this.getMetadata().get(`clientDefs.${this.scope}.recordViews.listSelect`) || this.getMetadata().get(`clientDefs.${this.scope}.recordViews.list`) || 'views/record/list';

      /** @type {module:views/record/list~options} */
      const options = {
        collection: this.collection,
        fullSelector: this.containerSelector + ' .list-container',
        selectable: true,
        checkboxes: this.multiple,
        massActionsDisabled: true,
        rowActionsView: null,
        layoutName: this.layoutName,
        checkAllResultDisabled: !this.massRelateEnabled,
        buttonsDisabled: true,
        skipBuildRows: true,
        pagination: this.getMetadata().get(['clientDefs', this.scope, 'listPagination']) || null
      };
      const promise = this.createView('list', viewName, options, view => {
        this.listenToOnce(view, 'select', models => {
          this.trigger('select', models);
          if (this.onSelect) {
            if (!Array.isArray(models)) {
              models = [models];
            }
            this.onSelect(models);
          }
          this.close();
        });
        if (this.multiple) {
          this.listenTo(view, 'check', () => {
            if (view.checkedList.length) {
              this.enableButton('select');
            } else {
              this.disableButton('select');
            }
          });
          this.listenTo(view, 'select-all-results', () => {
            this.enableButton('select');
          });
        }
        const fetch = () => {
          this.whenRendered().then(() => {
            Espo.Ui.notifyWait();
            this.collection.fetch().then(() => Espo.Ui.notify(false));
          });
          // Timeout to make notify work.
          /*setTimeout(() => {
              Espo.Ui.notifyWait();
                this.collection.fetch()
                  .then(() => Espo.Ui.notify(false));
          }, 1);*/
        };
        if (this.options.forceSelectAllAttributes || this.forceSelectAllAttributes) {
          fetch();
          return;
        }
        view.getSelectAttributeList(selectAttributeList => {
          if (!~selectAttributeList.indexOf('name')) {
            selectAttributeList.push('name');
          }
          const mandatorySelectAttributeList = this.options.mandatorySelectAttributeList || this.mandatorySelectAttributeList || [];
          mandatorySelectAttributeList.forEach(attribute => {
            if (!~selectAttributeList.indexOf(attribute)) {
              selectAttributeList.push(attribute);
            }
          });
          if (selectAttributeList) {
            this.collection.data.select = selectAttributeList.join(',');
          }
          fetch();
        });
      });
      this.wait(promise);
    }
    async create() {
      if (this.onCreate) {
        this.onCreate();
        return;
      }
      let attributes;
      if (this.options.createAttributesProvider) {
        attributes = await this.createAttributesProvider();
      } else {
        attributes = this.options.createAttributes || {};
      }
      const helper = new _recordModal.default();
      await helper.showCreate(this, {
        entityType: this.entityType,
        fullFormDisabled: true,
        attributes: attributes,
        afterSave: model => {
          this.trigger('select', model);
          if (this.onSelect) {
            this.onSelect([model]);
          }
          setTimeout(() => this.close(), 10);
        },
        beforeRender: view => {
          this.listenToOnce(view, 'leave', () => {
            view.close();
            this.close();
          });
        }
      });
    }
    actionSelect() {
      if (!this.multiple) {
        return;
      }
      const listView = this.getRecordView();
      if (listView.allResultIsChecked) {
        const data = {
          massRelate: true,
          where: listView.getWhereForAllResult(),
          searchParams: this.collection.data
        };
        this.trigger('select', data);
        if (this.onMassSelect) {
          this.onMassSelect(data);
        }
        this.close();
        return;
      }
      const list = listView.getSelected();
      if (list.length) {
        this.trigger('select', list);
        if (this.onSelect) {
          this.onSelect(list);
        }
      }
      this.close();
    }

    /**
     * @protected
     * @return {import('views/record/search').default}
     */
    getSearchView() {
      return this.getView('search');
    }

    /**
     * @protected
     * @return {module:views/record/list}
     */
    getRecordView() {
      return this.getView('list');
    }

    /**
     * @protected
     * @param {KeyboardEvent} e
     */
    handleShortcutKeyCtrlSlash(e) {
      if (!this.searchPanel) {
        return;
      }
      const $search = this.$el.find('input.text-filter').first();
      if (!$search.length) {
        return;
      }
      e.preventDefault();
      e.stopPropagation();
      $search.focus();
    }

    /**
     * @protected
     * @param {KeyboardEvent} e
     */
    handleShortcutKeyCtrlEnter(e) {
      if (!this.multiple) {
        return;
      }
      if (!this.hasAvailableActionItem('select')) {
        return;
      }
      e.stopPropagation();
      e.preventDefault();
      this.actionSelect();
    }

    /**
     * @protected
     * @param {KeyboardEvent} e
     */
    handleShortcutKeyCtrlSpace(e) {
      if (!this.createButton) {
        return;
      }
      e.preventDefault();
      e.stopPropagation();
      this.create();
    }

    /**
     * @protected
     */
    handleShortcutKeyCtrlComma() {
      if (!this.getSearchView()) {
        return;
      }
      this.getSearchView().selectPreviousPreset();
    }

    /**
     * @protected
     */
    handleShortcutKeyCtrlPeriod() {
      if (!this.getSearchView()) {
        return;
      }
      this.getSearchView().selectNextPreset();
    }
  }
  var _default = _exports.default = SelectRecordsModalView;
});

define("views/fields/base", ["exports", "view", "ui/select", "ui", "underscore", "jquery"], function (_exports, _view, _select, _ui, _underscore, _jquery) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  _select = _interopRequireDefault(_select);
  _ui = _interopRequireDefault(_ui);
  _underscore = _interopRequireDefault(_underscore);
  _jquery = _interopRequireDefault(_jquery);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/fields/base */

  const $ = _jquery.default;

  /**
   * Options.
   */

  /**
   * Base parameters.
   *
   * @property inlineEditDisabled Disable inline edit.
   * @property readOnly Is read-only.
   */

  /**
   * @internal
   */

  /**
   * A base field view. Can be in different modes. Each mode uses a separate template.
   *
   * @todo Document events.
   */
  class BaseFieldView extends _view.default {
    /**
     * @param options Options.
     */
    constructor(options) {
      super(options);
      this.name = options.name;
      if (options.labelText != null) {
        this.labelText = options.labelText;
      }
    }

    /**
     * A field type.
     */
    type = 'base';

    /**
     * List mode template.
     */
    listTemplate = 'fields/base/list';

    // noinspection JSUnusedGlobalSymbols
    /**
     * List-link mode template.
     */
    listLinkTemplate = 'fields/base/list-link';

    /**
     * Detail mode template.
     */
    detailTemplate = 'fields/base/detail';

    /**
     * Edit mode template.
     */
    editTemplate = 'fields/base/edit';

    /**
     * Search mode template.
     */
    searchTemplate = 'fields/base/search';

    // noinspection JSUnusedGlobalSymbols
    /**
     * List template content.
     */

    // noinspection JSUnusedGlobalSymbols
    /**
     * Detail template content.
     */

    // noinspection JSUnusedGlobalSymbols
    /**
     * Edit template content.
     */

    /**
     * A validation list. A function returning true if non-valid, or a name.
     * For the latter, there should be a `validate{Name}` method in the class.
     *
     * Functions are supported as of v8.3.
     */
    validations = ['required'];

    /**
     * List mode.
     */
    MODE_LIST = 'list';

    /**
     * List-link mode.
     */
    MODE_LIST_LINK = 'listLink';

    /**
     * Detail mode.
     */
    MODE_DETAIL = 'detail';

    /**
     * Edit mode.
     */
    MODE_EDIT = 'edit';

    /**
     * Search mode.
     */
    MODE_SEARCH = 'search';

    /**
     * A field name.
     */

    /**
     * A field parameter list. To be used for custom fields not defined in metadata > fields.
     *
     * @since 9.0.0
     */

    /**
     * Definitions.
     */

    /**
     * Field parameters.
     */

    /**
     * A mode.
     */
    mode = 'detail';

    /**
     * Search params.
     */
    searchParams = null;

    /**
     * Inline edit disabled.
     */
    inlineEditDisabled = false;

    /**
     * Field is disabled.
     */
    disabled = false;

    /**
     * Field is read-only.
     */
    readOnly = false;

    /**
     * Read-only locked.
     */
    readOnlyLocked = false;

    /**
     * A label text.
     */

    /**
     * @internal
     */
    attributeList = null;

    /**
     * Attribute values before edit.
     *
     * @internal
     */
    initialAttributes = null;

    /**
     * Validation popover timeout.
     */
    VALIDATION_POPOVER_TIMEOUT = 3000;

    /**
     * @internal
     */

    /**
     * An element selector to point validation popovers to.
     */

    /**
     * A view-record helper.
     */
    recordHelper = null;

    /**
     * @internal
     */
    $label = null;

    /**
     * A main form element. Use `mainInputElement` instead.
     *
     * @internal
     */
    $element = null;

    /**
     * A main form element.
     * @since 9.2.0
     */
    mainInputElement = null;

    /**
     * Is searchable once a search filter is added (no need to type or selecting anything).
     * Actual for search mode.
     *
     * @internal
     */
    initialSearchIsNotIdle = false;

    /**
     * An entity type.
     */
    entityType = null;

    /**
     * A last validation message.
     *
     * @internal
     */
    lastValidationMessage = null;

    /**
     * Additional data.
     */

    _isInlineEditMode = false;

    /**
     * @internal
     */
    disabledLocked = false;
    /**
     * Is the field required.
     */
    isRequired() {
      return this.params.required ?? false;
    }

    /**
     * Get a cell element. Available only after the view is  rendered.
     */
    get$cell() {
      return this.$el.parent();
    }
    getCellElement() {
      return this.get$cell().get(0) ?? null;
    }

    /**
     * Is in inline-edit mode.
     */
    isInlineEditMode() {
      return this._isInlineEditMode;
    }

    /**
     * Set disabled.
     *
     * @param [locked] Won't be able to set back.
     */
    setDisabled() {
      let locked = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
      this.disabled = true;
      if (locked) {
        this.disabledLocked = true;
      }
    }

    /**
     * Set not-disabled.
     */
    setNotDisabled() {
      if (this.disabledLocked) {
        return;
      }
      this.disabled = false;
    }

    /**
     * Set required.
     */
    setRequired() {
      this.params.required = true;
      if (this.isEditMode()) {
        if (this.isRendered()) {
          this.showRequiredSign();
        } else {
          this.once('after:render', () => {
            this.showRequiredSign();
          });
        }
      }
    }

    /**
     * Set not required.
     */
    setNotRequired() {
      this.params.required = false;
      this.get$cell().removeClass('has-error');
      if (this.isEditMode()) {
        if (this.isRendered()) {
          this.hideRequiredSign();
        } else {
          this.once('after:render', () => {
            this.hideRequiredSign();
          });
        }
      }
    }

    /**
     * Set read-only.
     *
     * @param [locked] Won't be able to set back.
     */
    async setReadOnly(locked) {
      if (this.readOnlyLocked) {
        return Promise.reject();
      }
      this.readOnly = true;
      if (locked) {
        this.readOnlyLocked = true;
      }
      if (!this.isReady) {
        if (!this.mode || !this._initCalled) {
          this.mode = 'detail';
          return Promise.resolve();
        }
        return this.setDetailMode();
      }
      if (this.isEditMode()) {
        if (this.isInlineEditMode()) {
          return this.inlineEditClose();
        }
        await this.setDetailMode();
        return await this.reRender();
      }
      return Promise.resolve();
    }

    /**
     * Set not read only.
     */
    setNotReadOnly() {
      if (this.readOnlyLocked) {
        return;
      }
      this.readOnly = false;
    }

    /**
     * Get a label element. Available only after the view is rendered.
     *
     * @internal
     */
    getLabelElement() {
      if (this.$label && this.$label.get(0) && !document.contains(this.$label.get(0))) {
        this.$label = null;
      }
      if (!this.$label || !this.$label.length) {
        this.$label = this.$el.parent().children('label');
      }
      return this.$label ?? null;
    }

    /**
     * Hide field and label. Available only after the view is rendered.
     */
    hide() {
      this.$el.addClass('hidden');
      const $cell = this.get$cell();
      $cell.children('label').addClass('hidden');
      $cell.addClass('hidden-cell');
    }

    /**
     * Show field and label. Available only after the view is rendered.
     */
    show() {
      this.$el.removeClass('hidden');
      const $cell = this.get$cell();
      $cell.children('label').removeClass('hidden');
      $cell.removeClass('hidden-cell');
    }

    /**
     * @inheritDoc
     */
    data() {
      const data = {
        scope: this.model.entityType || this.model.name,
        name: this.name,
        defs: this.defs,
        params: this.params,
        value: this.getValueForDisplay()
      };
      if (this.isSearchMode()) {
        data.searchParams = this.searchParams;
        data.searchData = this.searchData;
        data.searchValues = this.getSearchValues();
        data.searchType = this.getSearchType();
        data.searchTypeList = this.getSearchTypeList();
      }
      return data;
    }

    /**
     * Get a value for display. Is available by using a `{value}` placeholder in templates.
     */
    getValueForDisplay() {
      return this.model.get(this.name);
    }

    /**
     * Is in list, detail or list-link mode.
     */
    isReadMode() {
      return this.mode === this.MODE_LIST || this.mode === this.MODE_DETAIL || this.mode === this.MODE_LIST_LINK;
    }

    /**
     * Is in list or list-link mode.
     */
    isListMode() {
      return this.mode === this.MODE_LIST || this.mode === this.MODE_LIST_LINK;
    }

    /**
     * Is in detail mode.
     */
    isDetailMode() {
      return this.mode === this.MODE_DETAIL;
    }

    /**
     * Is in edit mode.
     */
    isEditMode() {
      return this.mode === this.MODE_EDIT;
    }

    /**
     * Is in search mode.
     */
    isSearchMode() {
      return this.mode === this.MODE_SEARCH;
    }

    /**
     * Set detail mode.
     */
    setDetailMode() {
      return this.setMode(this.MODE_DETAIL) || Promise.resolve();
    }

    /**
     * Set edit mode.
     */
    setEditMode() {
      return this.setMode(this.MODE_EDIT) || Promise.resolve();
    }

    /**
     * Set a mode.
     *
     * @internal
     */
    setMode(mode) {
      const modeIsChanged = this.mode !== mode && this.mode;
      const modeBefore = this.mode;
      this.mode = mode;
      const property = mode + 'Template';
      const self = this;
      if (!(property in this)) {
        self[property] = 'fields/' + Espo.Utils.camelCaseToHyphen(this.type) + '/' + this.mode;
      }
      if (!this._hasTemplateContent) {
        this.setTemplate(self[property]);
      }
      const contentProperty = mode + 'TemplateContent';
      if (!this._hasTemplateContent) {
        if (contentProperty in self && self[contentProperty] != null) {
          this.setTemplateContent(self[contentProperty]);
        }
      }
      if (modeIsChanged) {
        if (modeBefore) {
          this.trigger('mode-changed');
        }
        return this._onModeSet();
      }
      return Promise.resolve();
    }

    /**
     * Called on mode change and on value change before re-rendering.
     * To be used for additional initialization that depends on field
     * values or mode.
     */
    prepare() {
      return undefined;
    }
    _onModeSet() {
      if (this.isListMode()) {
        return this.onListModeSet() || Promise.resolve();
      }
      if (this.isDetailMode()) {
        return this.onDetailModeSet() || Promise.resolve();
      }
      if (this.isEditMode()) {
        return this.onEditModeSet() || Promise.resolve();
      }
      return Promise.resolve();
    }

    /**
     * Additional initialization for the detail mode.
     */
    onDetailModeSet() {
      return this.prepare();
    }

    /**
     * Additional initialization for the edit mode.
     */
    onEditModeSet() {
      return this.prepare();
    }

    /**
     * Additional initialization for the list mode.
     *
     * @protected
     * @returns {Promise|undefined}
     */
    onListModeSet() {
      return this.prepare();
    }
    _initCalled = false;

    /**
     * @internal
     */
    init() {
      this.validations = Espo.Utils.clone(this.validations);
      this.searchTypeList = Espo.Utils.clone(this.searchTypeList);
      this._hasTemplateContent = !!this.templateContent;
      this.defs = this.options.defs || {};
      this.name = this.options.name || this.defs.name;
      this.params = this.options.params ?? this.defs.params ?? {};
      this.validateCallback = this.options.validateCallback;
      this.fieldType = this.model.getFieldParam(this.name, 'type') || this.type;
      this.entityType = this.model.entityType || this.model.name;
      this.recordHelper = this.options.recordHelper ?? null;
      this.dataObject = Espo.Utils.clone(this.options.dataObject || {});
      if (!this.labelText) {
        this.labelText = this.translate(this.name, 'fields', this.entityType ?? undefined);
      }
      const paramList = this.paramList || this.getFieldManager().getParamList(this.type).map(it => it.name);
      paramList.forEach(name => {
        if (name in this.params) {
          return;
        }
        this.params[name] = this.model.getFieldParam(this.name, name);
        if (typeof this.params[name] === 'undefined') {
          this.params[name] = null;
        }
      });
      const additionalParamList = ['inlineEditDisabled'];
      additionalParamList.forEach(item => {
        this.params[item] = this.model.getFieldParam(this.name, item) || null;
      });
      this.readOnly = this.readOnly || this.params.readOnly || this.model.getFieldParam(this.name, 'readOnly') || this.model.getFieldParam(this.name, 'clientReadOnly');
      if (!this.model.isNew() && this.model.getFieldParam(this.name, 'readOnlyAfterCreate')) {
        this.readOnly = true;
      }
      this.readOnlyLocked = this.options.readOnlyLocked || this.readOnly;
      this.inlineEditDisabled = this.options.inlineEditDisabled || this.params.inlineEditDisabled || this.inlineEditDisabled;
      this.readOnly = this.readOnlyLocked || this.options.readOnly || false;
      this.tooltip = this.options.tooltip || this.params.tooltip || this.model.getFieldParam(this.name, 'tooltip') || this.tooltip;
      if (this.options.readOnlyDisabled) {
        this.readOnly = false;
      }
      this.disabledLocked = this.options.disabledLocked || false;
      this.disabled = this.disabledLocked || this.options.disabled || this.disabled;
      let mode = this.options.mode || this.mode || this.MODE_DETAIL;
      if (mode === this.MODE_EDIT && this.readOnly) {
        mode = this.MODE_DETAIL;
      }
      this.mode = undefined;
      this._initCalled = true;
      this.wait(this.setMode(mode));
      if (this.isSearchMode()) {
        this.searchParams = _underscore.default.clone(this.options.searchParams || {});
        this.searchData = {};
        this.setupSearch();
        this.events['keydown.' + this.cid] = e => {
          if (Espo.Utils.getKeyFromKeyEvent(e.originalEvent) === 'Control+Enter') {
            this.trigger('search');
          }
        };
      }
      this.on('highlight', () => {
        const $cell = this.get$cell();
        $cell.addClass('highlighted');
        $cell.addClass('transition');
        setTimeout(() => {
          $cell.removeClass('highlighted');
        }, 3000);
        setTimeout(() => {
          $cell.removeClass('transition');
        }, 3000 + 2000);
      });
      this.on('invalid', () => {
        const $cell = this.get$cell();
        $cell.addClass('has-error');
        this.$el.one('click', () => {
          $cell.removeClass('has-error');
        });
        this.once('render', () => {
          $cell.removeClass('has-error');
        });
      });
      this.on('after:render', () => {
        if (this.isEditMode()) {
          if (this.hasRequiredMarker()) {
            this.showRequiredSign();
            return;
          }
          this.hideRequiredSign();
          return;
        }
        if (this.hasRequiredMarker()) {
          this.hideRequiredSign();
        }
        if (this.isSearchMode()) {
          const $searchType = this.$el.find('select.search-type');
          if ($searchType.length) {
            _select.default.init($searchType, {
              matchAnyWord: true
            });
          }
        }
      });
      if ((this.isDetailMode() || this.isEditMode()) && this.tooltip) {
        this.initTooltip();
      }
      if (this.isDetailMode()) {
        if (!this.inlineEditDisabled) {
          this.listenToOnce(this, 'after:render', () => this.initInlineEdit());
        }
      }
      if (!this.isSearchMode()) {
        this.attributeList = this.getAttributeList(); // for backward compatibility, to be removed

        this.listenTo(this.model, 'change', (model, options) => {
          if (options.ui && (!options.fromField || options.fromField === this.name)) {
            return;
          }
          let changed = false;
          for (const attribute of this.getAttributeList()) {
            if (model.hasChanged(attribute)) {
              changed = true;
              break;
            }
          }
          if (!changed) {
            return;
          }
          if (options.fromField === this.name) {
            return;
          }
          if (options.skipReRenderInEditMode && this.isEditMode()) {
            return;
          }
          if (options.skipReRender) {
            return;
          }
          if (this.isEditMode() && this.toSkipReRenderOnChange()) {
            return;
          }
          const reRender = () => {
            if (!this.isRendered() && !this.isBeingRendered()) {
              return;
            }
            this.reRender();
            if (options.highlight) {
              this.trigger('highlight');
            }
          };
          if (!this.isReady) {
            this.once('ready', () => {
              const promise = this.prepare();
              if (promise) {
                promise.then(() => reRender());
              }
            });
            return;
          }
          const promise = this.prepare();
          if (promise) {
            promise.then(() => reRender());
            return;
          }
          reRender();
        });
        this.listenTo(this, 'change', () => {
          const attributes = this.fetch();
          this.model.setMultiple(attributes, {
            ui: true,
            fromView: this,
            fromField: this.name,
            action: 'ui'
          });
        });
      }
    }
    highlight() {
      const $cell = this.get$cell();
      $cell.addClass('highlighted');
    }

    /** @inheritDoc */
    setupFinal() {
      this.wait(this._onModeSet());
    }

    /**
     * @internal
     */
    initTooltip() {
      let $a;
      this.once('after:render', () => {
        var _this$getLabelElement;
        $a = $('<a>').attr('role', 'button').attr('tabindex', '-1').addClass('text-muted field-info').append($('<span>').addClass('fas fa-info-circle'));
        const $label = this.getLabelElement();
        $label === null || $label === void 0 || $label.append(' ');
        (_this$getLabelElement = this.getLabelElement()) === null || _this$getLabelElement === void 0 || _this$getLabelElement.append($a);
        let tooltipText = this.options.tooltipText || this.tooltipText;
        if (!tooltipText && typeof this.tooltip === 'string') {
          const [scope, field] = this.tooltip.includes('.') ? this.tooltip.split('.') : [this.entityType, this.tooltip];
          tooltipText = this.translate(field, 'tooltips', scope ?? undefined);
        }
        tooltipText = tooltipText || this.translate(this.name, 'tooltips', this.entityType ?? undefined) || '';
        tooltipText = this.getHelper().transformMarkdownText(tooltipText, {
          linksInNewTab: true
        }).toString();
        _ui.default.popover($a.get(0), {
          placement: 'bottom',
          content: tooltipText,
          preventDestroyOnRender: true
        }, this);
      });
    }

    /**
     * Show a required-field sign.
     */
    showRequiredSign() {
      const $label = this.getLabelElement();
      if (!$label) {
        return;
      }
      let $sign = $label.find('span.required-sign');
      if ($label.length && !$sign.length) {
        const $text = $label.find('span.label-text');
        $('<span class="required-sign"> *</span>').insertAfter($text);
        $sign = $label.find('span.required-sign');
      }
      $sign.show();
    }

    /**
     * Hide a required-field sign.
     */
    hideRequiredSign() {
      const $label = this.getLabelElement();
      const $sign = $label === null || $label === void 0 ? void 0 : $label.find('span.required-sign');
      $sign === null || $sign === void 0 || $sign.hide();
    }

    /**
     * Get search-params data.
     */
    getSearchParamsData() {
      var _this$searchParams;
      return ((_this$searchParams = this.searchParams) === null || _this$searchParams === void 0 ? void 0 : _this$searchParams.data) || {};
    }

    /**
     * Get search values.
     */
    getSearchValues() {
      return this.getSearchParamsData().values || {};
    }

    /**
     * Get a current search type.
     */
    getSearchType() {
      var _this$searchParams2;
      return this.getSearchParamsData().type ?? ((_this$searchParams2 = this.searchParams) === null || _this$searchParams2 === void 0 ? void 0 : _this$searchParams2.type) ?? null;
    }

    /**
     * Get the search type list.
     */
    getSearchTypeList() {
      return this.searchTypeList;
    }

    /**
     * @internal
     */
    initInlineEdit() {
      const cell = this.getCellElement();
      const edit = document.createElement('a');
      edit.role = 'button';
      edit.classList.add('pull-right', 'inline-edit-link', 'hidden');
      edit.append((() => {
        const span = document.createElement('span');
        span.classList.add('fas', 'fa-pencil-alt', 'fa-sm');
        return span;
      })());
      if (!cell) {
        this.listenToOnce(this, 'after:render', () => this.initInlineEdit());
        return;
      }
      cell.prepend(edit);
      edit.addEventListener('click', () => this.inlineEdit());
      cell.addEventListener('mouseenter', e => {
        e.stopPropagation();
        if (this.disabled || this.readOnly) {
          return;
        }
        if (this.isDetailMode()) {
          edit.classList.remove('hidden');
        }
      });
      cell.addEventListener('mouseleave', e => {
        e.stopPropagation();
        if (this.isDetailMode()) {
          edit.classList.add('hidden');
        }
      });
      this.on('after:render', () => {
        if (!this.isDetailMode()) {
          edit.classList.add('hidden');
        }
      });
    }

    /**
     * Initializes a form element reference.
     */
    initElement() {
      var _this$element, _this$element2, _this$element3;
      this.mainInputElement = ((_this$element = this.element) === null || _this$element === void 0 ? void 0 : _this$element.querySelector(`[data-name="${this.name}"]`)) ?? ((_this$element2 = this.element) === null || _this$element2 === void 0 ? void 0 : _this$element2.querySelector(`[name="${this.name}"]`)) ?? ((_this$element3 = this.element) === null || _this$element3 === void 0 ? void 0 : _this$element3.querySelector('.main-element'));
      this.$element = this.mainInputElement ? $(this.mainInputElement) : $();
      if (this.isEditMode()) {
        this.$element.on('change', () => {
          this.trigger('change');
        });
      }
    }
    afterRender() {
      if (this.isEditMode() || this.isSearchMode()) {
        this.initElement();
      }
      if (this.isReadMode()) {
        this.afterRenderRead();
      }
      if (this.isListMode()) {
        this.afterRenderList();
      }
      if (this.isDetailMode()) {
        this.afterRenderDetail();
      }
      if (this.isEditMode()) {
        this.afterRenderEdit();
      }
      if (this.isSearchMode()) {
        this.afterRenderSearch();
      }
    }

    /**
     * Called after the view is rendered in list or read mode.
     */
    afterRenderRead() {}

    /**
     * Called after the view is rendered in list mode.
     *
     * @protected
     */
    afterRenderList() {}

    /**
     * Called after the view is rendered in detail mode.
     *
     * @protected
     */
    afterRenderDetail() {}

    /**
     * Called after the view is rendered in edit mode.
     *
     * @protected
     */
    afterRenderEdit() {}

    /**
     * Called after the view is rendered in search mode.
     *
     * @protected
     */
    afterRenderSearch() {}

    /**
     * Initialization.
     */
    setup() {}

    /**
     * Initialization for search mode.
     */
    setupSearch() {}

    /**
     * Get list of model attributes that relate to the field.
     * Changing of any attributes makes the field to re-render.
     */
    getAttributeList() {
      return this.getFieldManager().getAttributeList(this.fieldType, this.name);
    }

    /**
     * Invoke inline-edit saving.
     *
     * @param options
     */
    inlineEditSave() {
      let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      options = options || {};
      if (this.recordHelper) {
        this.recordHelper.trigger('inline-edit-save', this.name, options);
        return;
      }

      // Code below supposed not to be executed.

      let data = this.fetch();
      const model = this.model;
      const prev = this.initialAttributes ?? {};
      model.setMultiple(data, {
        silent: true
      });
      data = model.attributes;
      let attrs = false;
      for (const attr in data) {
        if (_underscore.default.isEqual(prev[attr], data[attr])) {
          continue;
        }
        const itemAttrs = attrs || (attrs = {});
        itemAttrs[attr] = data[attr];
      }
      if (!attrs) {
        this.inlineEditClose();
      }
      const isInvalid = this.validateCallback ? this.validateCallback() : this.validate();
      if (isInvalid) {
        _ui.default.error(this.translate('Not valid'));

        // @todo Revise.
        model.setMultiple(prev, {
          silent: true
        });
        return;
      }
      _ui.default.notify(this.translate('saving', 'messages'));
      model.save(attrs, {
        patch: true
      }).then(() => {
        this.trigger('after:inline-save');
        this.trigger('after:save');
        model.trigger('after:save');
        _ui.default.success(this.translate('Saved'));
      }).catch(() => {
        _ui.default.error(this.translate('Error occurred'));

        // @todo Revise.
        model.setMultiple(prev, {
          silent: true
        });
        this.reRender();
      });
      if (!options.bypassClose) {
        this.inlineEditClose(true);
      }
    }
    removeInlineEditLinks() {
      const $cell = this.get$cell();
      $cell.find('.inline-save-link').remove();
      $cell.find('.inline-cancel-link').remove();
      $cell.find('.inline-edit-link').addClass('hidden');
    }
    addInlineEditLinks() {
      const $cell = this.get$cell();
      const saveLink = document.createElement('a');
      saveLink.role = 'button';
      saveLink.tabIndex = -1;
      saveLink.title = this.translate('Update') + ' · ' + 'Ctrl+Enter';
      saveLink.innerHTML = `<span class="fas fa-check"></span>`;
      saveLink.classList.add('inline-save-link');
      const cancelLink = document.createElement('a');
      cancelLink.role = 'button';
      cancelLink.tabIndex = -1;
      cancelLink.title = this.translate('Cancel') + ' · ' + 'Esc';
      cancelLink.innerHTML = `<span class="fas fa-arrow-right-to-bracket"></span>`;
      cancelLink.classList.add('inline-cancel-link');
      $cell.prepend(saveLink);
      $cell.prepend(cancelLink);
      $cell.find('.inline-edit-link').addClass('hidden');
      saveLink.onclick = () => this.inlineEditSave();
      cancelLink.onclick = () => this.inlineEditClose();
    }

    /**
     * @internal
     */
    setIsInlineEditMode(value) {
      this._isInlineEditMode = value;
    }

    /**
     * Exist inline-edit mode.
     *
     * @param noReset
     */
    inlineEditClose() {
      let noReset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
      this.trigger('inline-edit-off', {
        noReset: noReset
      });
      if (this.recordHelper) {
        this.recordHelper.off('continue-inline-edit');
      }
      this.$el.off('keydown.inline-edit');
      this._isInlineEditMode = false;
      if (!this.isEditMode()) {
        return Promise.resolve();
      }
      if (!noReset) {
        this.model.setMultiple(this.initialAttributes ?? {}, {
          skipReRenderInEditMode: true,
          action: 'cancel-edit'
        });
      }
      const promise = this.setDetailMode().then(() => this.reRender(true)).then(() => this.removeInlineEditLinks());
      this.trigger('after:inline-edit-off', {
        noReset: noReset
      });
      return promise;
    }

    /**
     * Switch to inline-edit mode.
     */
    async inlineEdit() {
      if (this.recordHelper && this.recordHelper.isChanged()) {
        await this.confirm({
          message: this.translate('changesLossConfirmation', 'messages'),
          cancelCallback: () => {
            var _this$recordHelper;
            return (_this$recordHelper = this.recordHelper) === null || _this$recordHelper === void 0 ? void 0 : _this$recordHelper.trigger('continue-inline-edit');
          }
        });
      }
      this.trigger('edit', this);
      this.initialAttributes = this.model.getClonedAttributes();
      this._isInlineEditMode = true;
      this.trigger('inline-edit-on');
      await this.setEditMode();
      await this.reRender(true);
      this.addInlineEditLinks();
      if (this.recordHelper) {
        this.recordHelper.on('continue-inline-edit', () => this.focusOnInlineEdit());
      }
      this.$el.on('keydown.inline-edit', e => {
        const key = Espo.Utils.getKeyFromKeyEvent(e);
        if (key === 'Control+Enter') {
          e.stopPropagation();
          if (document.activeElement instanceof HTMLInputElement) {
            // Fields may need to fetch data first.
            document.activeElement.dispatchEvent(new Event('change', {
              bubbles: true
            }));
          }
          this.fetchToModel();
          this.inlineEditSave();
          setTimeout(() => {
            this.get$cell().trigger('focus');
          }, 100);
          return;
        }
        if (key === 'Escape') {
          e.stopPropagation();
          this.inlineEditClose().then(() => {
            this.get$cell().trigger('focus');
          });
          return;
        }
        if (key === 'Control+KeyS') {
          e.preventDefault();
          e.stopPropagation();
          this.fetchToModel();
          this.inlineEditSave({
            bypassClose: true
          });
        }
      });
      setTimeout(() => this.focusOnInlineEdit(), 10);
    }
    focusOnInlineEdit() {
      const $element = this.$element && this.$element.length ? this.$element : this.$el.find('.form-control').first();
      if (!$element) {
        return;
      }
      $element.first().focus();
    }

    /**
     * Suspend a validation message.
     *
     * @internal
     */
    suspendValidationMessage(time) {
      this.validationMessageSuspended = true;
      setTimeout(() => this.validationMessageSuspended = false, time || 200);
    }

    /**
     * Show a validation message.
     *
     * @param {string} message A message.
     * @param {string|JQuery|Element} [target] A target element or selector.
     * @param {View} [view] A child view that contains the target. The closest view should to passed.
     *   Should be omitted if there is no child views or the target is not rendered by a child view.
     */
    showValidationMessage(message, target, view) {
      if (this.validationMessageSuspended) {
        return;
      }
      let $el;
      target = target || this.validationElementSelector || '.main-element';
      if (typeof target === 'string' || target instanceof String) {
        $el = this.$el.find(target);
      } else {
        $el = $(target);
      }
      if (!$el.length && this.$element) {
        $el = this.$element;
      }
      if (!$el.length) {
        $el = this.$el;
      }
      if ($el.length) {
        const rect = $el.get(0).getBoundingClientRect();
        this.lastValidationMessage = message;
        if (rect.top === 0 && rect.bottom === 0 && rect.left === 0) {
          return;
        }
      }
      this._popoverMap = this._popoverMap || new WeakMap();
      const element = $el.get(0);
      if (!element) {
        return;
      }
      if (this._popoverMap.has(element)) {
        try {
          this._popoverMap.get(element).detach();
        } catch (e) {}
      }
      const popover = _ui.default.popover($el, {
        placement: 'bottom',
        container: 'body',
        content: this.getHelper().transformMarkdownText(message).toString(),
        trigger: 'manual',
        noToggleInit: true,
        noHideOnOutsideClick: true
      }, view ?? this);
      popover.show();
      this._popoverMap.set(element, popover);
      $el.closest('.field').one('mousedown click', () => popover.destroy());
      this.once('render remove', () => popover.destroy());
      this._timeoutMap = this._timeoutMap || new WeakMap();
      if (this._timeoutMap.has(element)) {
        clearTimeout(this._timeoutMap.get(element));
      }
      const timeout = setTimeout(() => {
        popover.destroy();
      }, this.VALIDATION_POPOVER_TIMEOUT);
      this._timeoutMap.set(element, timeout);
    }

    /**
     * Validate field values.
     *
     * @return True if not valid.
     */
    validate() {
      this.lastValidationMessage = null;
      for (const item of this.validations) {
        let notValid = false;
        if (typeof item === 'function') {
          notValid = item();
        } else {
          const method = 'validate' + Espo.Utils.upperCaseFirst(item);
          const fn = this[method];
          if (typeof fn === 'function') {
            notValid = fn.call(this);
          } else {
            throw new Error(`No '${method}' method.`);
          }
        }
        if (notValid) {
          this.trigger('invalid');
          return true;
        }
      }
      return false;
    }

    /**
     * Get a label text.
     */
    getLabelText() {
      return this.labelText;
    }

    /**
     * Validate required.
     */
    validateRequired() {
      if (this.isRequired()) {
        if (this.model.get(this.name) === '' || this.model.get(this.name) === null) {
          const msg = this.translate('fieldIsRequired', 'messages').replace('{field}', this.getLabelText());
          this.showValidationMessage(msg);
          return true;
        }
      }
      return false;
    }

    /**
     * Defines whether the field should have a required-marker rendered.
     */
    hasRequiredMarker() {
      return this.isRequired();
    }

    /**
     * Fetch field values to the model.
     */
    fetchToModel() {
      this.model.setMultiple(this.fetch(), {
        silent: true
      });
    }

    /**
     * Fetch field values from DOM.
     */
    fetch() {
      var _this$$element, _this$$element2;
      if (!((_this$$element = this.$element) !== null && _this$$element !== void 0 && _this$$element.length)) {
        return {};
      }
      const data = {};
      data[this.name] = ((_this$$element2 = this.$element) === null || _this$$element2 === void 0 ? void 0 : _this$$element2.val()).trim();
      return data;
    }

    /**
     * Fetch search data from DOM.
     */
    fetchSearch() {
      var _this$$element3;
      const value = (_this$$element3 = this.$element) === null || _this$$element3 === void 0 || (_this$$element3 = _this$$element3.val()) === null || _this$$element3 === void 0 || (_this$$element3 = _this$$element3.toString()) === null || _this$$element3 === void 0 ? void 0 : _this$$element3.trim();
      if (value) {
        return {
          type: 'equals',
          value: value
        };
      }
      return null;
    }

    /**
     * Fetch a search type from DOM.
     */
    fetchSearchType() {
      return this.$el.find('select.search-type').val();
    }

    /**
     * To skip re-render on change in edit mode.
     * @since 9.1.2
     */
    toSkipReRenderOnChange() {
      return false;
    }

    /**
     * @internal
     * @since 10.0.0
     */
    setSearchParams(params) {
      this.searchParams = params;
    }
  }
  _exports.default = BaseFieldView;
});

define("web-socket-manager", ["exports", "js-base64"], function (_exports, _jsBase) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _jsBase = _interopRequireDefault(_jsBase);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module web-socket-manager */

  /**
   * A web-socket manager.
   */
  class WebSocketManager {
    /**
     * @private
     * @type {number}
     */
    pingInterval = 60;

    /**
     * @private
     * @type {number}
     */
    reconnectInterval = 3;

    /**
     * @private
     */
    pingTimeout;

    /**
     * @private
     * @type {boolean}
     */
    wasConnected = false;

    /**
     * @private
     * @type {boolean}
     */
    isConnecting = false;

    /**
     * @private
     * @type {number}
     */
    checkWakeInterval = 3;

    /**
     * @private
     * @type {number}
     */
    checkWakeThresholdInterval = 5;

    /**
     * @private
     * @type {boolean}
     */
    enabled = false;

    /**
     * @param {import('models/settings').default} config A config.
     */
    constructor(config) {
      /**
       * @private
       * @type {import('models/settings').default}
       */
      this.config = config;

      /**
       * @private
       * @type {Function[]}
       */
      this.subscribeToReconnectQueue = [];

      /**
       * @private
       * @type {{category: string, callback: Function}[]}
       */
      this.subscribeQueue = [];

      /**
       * @private
       * @type {{category: string, callback: Function}[]}
       */
      this.subscriptions = [];

      /**
       * @private
       * @type {boolean}
       */
      this.isConnected = false;

      /**
       * @private
       */
      this.connection = null;

      /**
       * @private
       * @type {string}
       */
      this.url = '';

      /**
       * @private
       * @type {string}
       */
      this.protocolPart = '';
      const url = this.config.get('webSocketUrl');
      if (url) {
        if (url.indexOf('wss://') === 0) {
          this.url = url.substring(6);
          this.protocolPart = 'wss://';
        } else {
          this.url = url.substring(5);
          this.protocolPart = 'ws://';
        }
      } else {
        const siteUrl = this.config.get('siteUrl') || '';
        if (siteUrl.indexOf('https://') === 0) {
          this.url = siteUrl.substring(8);
          this.protocolPart = 'wss://';
        } else {
          this.url = siteUrl.substring(7);
          this.protocolPart = 'ws://';
        }
        if (~this.url.indexOf('/')) {
          this.url = this.url.replace(/\/$/, '');
        }
        const port = this.protocolPart === 'wss://' ? 443 : 8080;
        const si = this.url.indexOf('/');
        if (~si) {
          this.url = this.url.substring(0, si) + ':' + port;
        } else {
          this.url += ':' + port;
        }
        if (this.protocolPart === 'wss://') {
          this.url += '/wss';
        }
      }
      {
        let lastTime = Date.now();
        const interval = this.checkWakeInterval * 1000;
        const thresholdInterval = this.checkWakeThresholdInterval * 1000;
        setInterval(() => {
          const timeDiff = Date.now() - lastTime;
          lastTime = Date.now();
          if (timeDiff <= interval + thresholdInterval) {
            return;
          }
          if (!this.isConnected || this.isConnecting) {
            return;
          }
          if (this.pingTimeout) {
            clearTimeout(this.pingTimeout);
          }
          this.connection.publish('', '');
          this.schedulePing();
        }, interval);
      }
    }

    /**
     * Connect.
     *
     * @param {string} auth An auth string.
     * @param {string} userId A user ID.
     */
    connect(auth, userId) {
      const authArray = _jsBase.default.decode(auth).split(':');
      const authToken = authArray[1];
      const url = `${this.protocolPart + this.url}?authToken=${authToken}&userId=${userId}`;
      try {
        this.connectInternal(auth, userId, url);
      } catch (e) {
        console.error(e.message);
        this.connection = null;
      }
    }

    /**
     * @private
     * @param {string} auth
     * @param {string} userId
     * @param {string} url
     */
    connectInternal(auth, userId, url) {
      this.isConnecting = true;
      this.connection = new ab.Session(url, () => {
        this.isConnecting = false;
        this.isConnected = true;
        this.subscribeQueue.forEach(item => {
          this.subscribe(item.category, item.callback);
        });
        this.subscribeQueue = [];
        if (this.wasConnected) {
          this.subscribeToReconnectQueue.forEach(callback => callback());
        }
        this.schedulePing();
        this.wasConnected = true;
      }, code => {
        this.isConnecting = false;
        if (code === ab.CONNECTION_LOST || code === ab.CONNECTION_UNREACHABLE) {
          if (this.isConnected) {
            this.subscribeQueue = this.subscriptions;
            this.subscriptions = [];
          }
          setTimeout(() => this.connect(auth, userId), this.reconnectInterval * 1000);
        } else if (code === ab.CONNECTION_CLOSED) {
          this.subscribeQueue = [];
        }
        this.isConnected = false;
      }, {
        skipSubprotocolCheck: true
      });
    }

    /**
     * Subscribe to reconnecting.
     *
     * @param {function(): void} callback A callback.
     * @since 9.1.1
     */
    subscribeToReconnect(callback) {
      this.subscribeToReconnectQueue.push(callback);
    }

    /**
     * Unsubscribe from reconnecting.
     *
     * @param {function(): void} callback A callback.
     * @since 9.1.1
     */
    unsubscribeFromReconnect(callback) {
      this.subscribeToReconnectQueue = this.subscribeToReconnectQueue.filter(it => it !== callback);
    }

    /**
     * Subscribe to a topic.
     *
     * @param {string} category A topic.
     * @param {function(string, *): void} callback A callback.
     */
    subscribe(category, callback) {
      if (!this.connection) {
        return;
      }
      if (!this.isConnected) {
        this.subscribeQueue.push({
          category: category,
          callback: callback
        });
        return;
      }
      try {
        this.connection.subscribe(category, callback);
        this.subscriptions.push({
          category: category,
          callback: callback
        });
      } catch (e) {
        if (e.message) {
          console.error(e.message);
        } else {
          console.error("WebSocket: Could not subscribe to " + category + ".");
        }
      }
    }

    /**
     * Unsubscribe.
     *
     * @param {string} category A topic.
     * @param {Function} [callback] A callback.
     */
    unsubscribe(category, callback) {
      if (!this.connection) {
        return;
      }
      this.subscribeQueue = this.subscribeQueue.filter(item => {
        if (callback === undefined) {
          return item.category !== category;
        }
        return item.category !== category || item.callback !== callback;
      });
      this.subscriptions = this.subscriptions.filter(item => {
        if (callback === undefined) {
          return item.category !== category;
        }
        return item.category !== category || item.callback !== callback;
      });
      try {
        this.connection.unsubscribe(category, callback);
      } catch (e) {
        if (e.message) {
          console.error(e.message);
        } else {
          console.error("WebSocket: Could not unsubscribe from " + category + ".");
        }
      }
    }

    /**
     * Close a connection.
     */
    close() {
      this.stopPing();
      if (!this.connection) {
        return;
      }
      this.subscribeQueue = [];
      this.subscriptions = [];
      try {
        this.connection.close();
      } catch (e) {
        console.error(e.message);
      }
      this.isConnected = false;
      this.wasConnected = true;
    }

    /**
     * @private
     */
    stopPing() {
      this.pingTimeout = undefined;
    }

    /**
     * @private
     */
    schedulePing() {
      //ab._debugws = true;

      if (!this.connection) {
        this.stopPing();
        return;
      }
      this.pingTimeout = setTimeout(() => {
        if (!this.connection) {
          return;
        }
        if (!this.isConnecting) {
          this.connection.publish('', '');
        }
        this.schedulePing();
      }, this.pingInterval * 1000);
    }

    /**
     * @internal
     * @since 9.2.0
     */
    setEnabled() {
      this.enabled = true;
    }

    /**
     * Is enabled.
     *
     * @return {boolean}
     * @since 9.2.0
     */
    isEnabled() {
      return this.enabled;
    }
  }
  var _default = _exports.default = WebSocketManager;
});

define("dynamic-handler", ["exports", "bullbone"], function (_exports, _bullbone) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module dynamic-handler */

  /**
   * A dynamic handler. To be extended by a specific handler.
   */
  class DynamicHandler {
    /**
     * @param {module:views/record/detail} recordView A record view.
     */
    constructor(recordView) {
      /**
       * A record view.
       *
       * @protected
       * @type {module:views/record/detail}
       */
      this.recordView = recordView;

      /**
       * A model.
       *
       * @protected
       * @type {module:model}
       */
      this.model = recordView.model;
    }

    /**
     * Initialization logic. To be extended.
     *
     * @protected
     */
    init() {}

    /**
     * Called on model change. To be extended.
     *
     * @protected
     * @param {module:views/record/detail} model A model.
     * @param {Object} o Options.
     */
    onChange(model, o) {}

    /**
     * Get a metadata.
     *
     * @protected
     * @returns {module:metadata}
     */
    getMetadata() {
      return this.recordView.getMetadata();
    }
  }
  DynamicHandler.extend = _bullbone.View.extend;

  // noinspection JSUnusedGlobalSymbols
  var _default = _exports.default = DynamicHandler;
});

define("views/record/base", ["exports", "view", "view-record-helper", "dynamic-logic", "underscore", "ui", "utils"], function (_exports, _view, _viewRecordHelper, _dynamicLogic, _underscore, _ui, _utils) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  _viewRecordHelper = _interopRequireDefault(_viewRecordHelper);
  _dynamicLogic = _interopRequireDefault(_dynamicLogic);
  _underscore = _interopRequireDefault(_underscore);
  _ui = _interopRequireDefault(_ui);
  _utils = _interopRequireDefault(_utils);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * Save options.
   */

  /**
   * A panel soft-locked type.
   */

  /**
   * A base record view. To be extended.
   *
   * @internal
   */
  class BaseRecordView extends _view.default {
    /**
     * A type.
     */
    type = 'edit';

    /**
     * An entity type.
     */
    entityType = null;

    /**
     * A scope.
     */
    scope = null;

    /**
     * Is new. Is set automatically.
     */
    isNew = false;

    /**
     * @deprecated
     * @todo Remove in v10.2.
     */
    dependencyDefs = {};

    /**
     * Dynamic logic.
     */
    dynamicLogicDefs = {};

    /**
     * A field list.
     */
    fieldList = null;

    /**
     * A mode.
     */
    mode = null;

    /**
     * A last save cancel reason.
     */
    lastSaveCancelReason = null;

    /**
     * Pre-save attribute values.
     *
     * @todo Use null?
     */

    /**
     * A record-helper.
     */

    /**
     * Read-only. Can be overridden by an option parameter.
     */
    readOnly = false;
    MODE_DETAIL = 'detail';
    MODE_EDIT = 'edit';
    TYPE_DETAIL = 'detail';
    TYPE_EDIT = 'edit';
    isChanged = false;

    /**
     * @internal
     */

    /**
     * @internal
     */

    /**
     * @internal
     */
    updatedAttributes = null;

    /**
     * @internal
     */

    constructor(options) {
      super(options);
    }

    /**
     * Get pre-save attributes.
     *
     * @since 10.0.0
     */
    getPreSaveAttributes() {
      return _utils.default.cloneDeep(this.attributes ?? {});
    }

    /**
     * Hide a field.
     *
     * @param name A field name.
     * @param [locked] To lock. Won't be able to un-hide.
     */
    hideField(name) {
      let locked = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
      this.recordHelper.setFieldStateParam(name, 'hidden', true);
      if (locked) {
        this.recordHelper.setFieldStateParam(name, 'hiddenLocked', true);
      }
      const processHtml = () => {
        const fieldView = this.getFieldView(name);
        if (fieldView) {
          const $field = fieldView.$el;
          const $cell = $field.closest('.cell[data-name="' + name + '"]');
          const $label = $cell.find('label.control-label[data-name="' + name + '"]');
          $field.addClass('hidden');
          $label.addClass('hidden');
          $cell.addClass('hidden-cell');
        } else {
          this.$el.find('.cell[data-name="' + name + '"]').addClass('hidden-cell');
          this.$el.find('.field[data-name="' + name + '"]').addClass('hidden');
          this.$el.find('label.control-label[data-name="' + name + '"]').addClass('hidden');
        }
      };
      if (this.isRendered()) {
        processHtml();
      } else {
        this.once('after:render', () => {
          processHtml();
        });
      }
      const view = this.getFieldView(name);
      if (view) {
        view.setDisabled(locked);
      }
    }

    /**
     * Show a field.
     *
     * @param name A field name.
     */
    showField(name) {
      if (this.recordHelper.getFieldStateParam(name, 'hiddenLocked')) {
        return;
      }
      this.recordHelper.setFieldStateParam(name, 'hidden', false);
      const processHtml = () => {
        const fieldView = this.getFieldView(name);
        if (fieldView) {
          const $field = fieldView.$el;
          const $cell = $field.closest('.cell[data-name="' + name + '"]');
          const $label = $cell.find('label.control-label[data-name="' + name + '"]');
          $field.removeClass('hidden');
          $label.removeClass('hidden');
          $cell.removeClass('hidden-cell');
          return;
        }
        this.$el.find('.cell[data-name="' + name + '"]').removeClass('hidden-cell');
        this.$el.find('.field[data-name="' + name + '"]').removeClass('hidden');
        this.$el.find('label.control-label[data-name="' + name + '"]').removeClass('hidden');
      };
      if (this.isRendered()) {
        processHtml();
      } else {
        this.once('after:render', () => {
          processHtml();
        });
      }
      const view = this.getFieldView(name);
      if (view && !view.disabledLocked) {
        view.setNotDisabled();
      }
    }

    /**
     * Set a field as read-only.
     *
     * @param name A field name.
     * @param [locked] To lock. Won't be able to un-set.
     */
    setFieldReadOnly(name) {
      let locked = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
      const previousValue = this.recordHelper.getFieldStateParam(name, 'readOnly');
      this.recordHelper.setFieldStateParam(name, 'readOnly', true);
      if (locked) {
        this.recordHelper.setFieldStateParam(name, 'readOnlyLocked', true);
      }
      const view = this.getFieldView(name);
      if (view) {
        view.setReadOnly(locked).catch(() => {});
      }
      if (!previousValue) {
        this.trigger('set-field-read-only', name);
      }

      /**
       * @todo
       *   Move to fields/base. Listen to recordHelper 'field-change' (if recordHelper is available).
       *   Same for set state methods.
       *   Issue is that sometimes state is changed in between view initialization (for bottom views with fields).
       */

      if (!view && !this.isReady) {
        this.once('ready', () => {
          const view = this.getFieldView(name);
          if (view && !view.readOnly && this.recordHelper.getFieldStateParam(name, 'readOnly')) {
            view.setReadOnly(locked);
          }
        });
      }
    }

    /**
     * Set a field as not read-only.
     *
     * @param name A field name.
     */
    setFieldNotReadOnly(name) {
      const previousValue = this.recordHelper.getFieldStateParam(name, 'readOnly');
      this.recordHelper.setFieldStateParam(name, 'readOnly', false);
      if (this.readOnly) {
        return;
      }
      const view = this.getFieldView(name);
      if (view && view.readOnly) {
        view.setNotReadOnly();
        if (this.mode === this.MODE_EDIT) {
          if (!view.readOnlyLocked && view.isDetailMode()) {
            view.setEditMode().then(() => view.reRender());
          }
        }
      }
      if (previousValue) {
        this.trigger('set-field-not-read-only', name);
      }
      if (!view && !this.isReady) {
        this.once('ready', () => {
          const view = this.getFieldView(name);
          if (view && view.readOnly && !this.recordHelper.getFieldStateParam(name, 'readOnly')) {
            view.setNotReadOnly();
          }
        });
      }
    }

    /**
     * Set a field as required.
     *
     * @param name A field name.
     */
    setFieldRequired(name) {
      const previousValue = this.recordHelper.getFieldStateParam(name, 'required');
      this.recordHelper.setFieldStateParam(name, 'required', true);
      const view = this.getFieldView(name);
      if (view) {
        view.setRequired();
      }
      if (!previousValue) {
        this.trigger('set-field-required', name);
      }
    }

    /**
     * Set a field as not required.
     *
     * @param name A field name.
     */
    setFieldNotRequired(name) {
      const previousValue = this.recordHelper.getFieldStateParam(name, 'required');
      this.recordHelper.setFieldStateParam(name, 'required', false);
      const view = this.getFieldView(name);
      if (view) {
        view.setNotRequired();
      }
      if (previousValue) {
        this.trigger('set-field-not-required', name);
      }
    }

    /**
     * Set an option list for a field.
     *
     * @param name A field name.
     * @param list Options.
     */
    setFieldOptionList(name, list) {
      const had = this.recordHelper.hasFieldOptionList(name);
      const previousList = this.recordHelper.getFieldOptionList(name);
      this.recordHelper.setFieldOptionList(name, list);
      const view = this.getFieldView(name);
      if (view && hasSetOptionList(view)) {
        view.setOptionList(list);
      }
      if (!had || !(0, _underscore.default)(previousList).isEqual(list)) {
        this.trigger('set-field-option-list', name, list);
      }
    }

    /**
     * Reset field options (revert to default).
     *
     * @param name A field name.
     */
    resetFieldOptionList(name) {
      const had = this.recordHelper.hasFieldOptionList(name);
      this.recordHelper.clearFieldOptionList(name);
      const view = this.getFieldView(name);
      if (view && hasResetOptionList(view)) {
        view.resetOptionList();
      }
      if (had) {
        this.trigger('reset-field-option-list', name);
      }
    }

    /**
     * Show a panel.
     *
     * @param name A panel name.
     * @param [softLockedType] Omitted.
     */
    showPanel(name, softLockedType) {
      // noinspection BadExpressionStatementJS
      softLockedType;
      this.recordHelper.setPanelStateParam(name, 'hidden', false);
      if (this.isRendered()) {
        this.$el.find('.panel[data-name="' + name + '"]').removeClass('hidden');
      }
    }

    /**
     * Hide a panel.
     *
     * @param name A panel name.
     * @param [locked=false] Won't be able to un-hide.
     * @param [softLockedType='default']
     */
    hidePanel(name) {
      let locked = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
      let softLockedType = arguments.length > 2 ? arguments[2] : undefined;
      // noinspection BadExpressionStatementJS
      locked;
      // noinspection BadExpressionStatementJS
      softLockedType;
      this.recordHelper.setPanelStateParam(name, 'hidden', true);
      if (this.isRendered()) {
        this.$el.find('.panel[data-name="' + name + '"]').addClass('hidden');
      }
    }

    /**
     * Style a panel. Style is set in the `data-style` DOM attribute.
     *
     * @param {string} name A panel name.
     */
    stylePanel(name) {
      this.recordHelper.setPanelStateParam(name, 'styled', true);
      const process = () => {
        const $panel = this.$el.find('.panel[data-name="' + name + '"]');
        const $btn = $panel.find('> .panel-heading .btn');
        const style = $panel.attr('data-style');
        if (!style) {
          return;
        }
        $panel.removeClass('panel-default');
        $panel.addClass('panel-' + style);
        $btn.removeClass('btn-default');
        $btn.addClass('btn-' + style);
      };
      if (this.isRendered()) {
        process();
        return;
      }
      this.once('after:render', () => {
        process();
      });
    }

    /**
     * Un-style a panel.
     *
     * @param name A panel name.
     */
    unstylePanel(name) {
      this.recordHelper.setPanelStateParam(name, 'styled', false);
      const process = () => {
        const $panel = this.$el.find('.panel[data-name="' + name + '"]');
        const $btn = $panel.find('> .panel-heading .btn');
        const style = $panel.attr('data-style');
        if (!style) {
          return;
        }
        $panel.removeClass('panel-' + style);
        $panel.addClass('panel-default');
        $btn.removeClass('btn-' + style);
        $btn.addClass('btn-default');
      };
      if (this.isRendered()) {
        process();
        return;
      }
      this.once('after:render', () => {
        process();
      });
    }

    /**
     * Set/unset a confirmation upon leaving the form.
     *
     * @param value True sets a required confirmation.
     */
    setConfirmLeaveOut(value) {
      if (!this.getRouter()) {
        return;
      }
      if (value) {
        this.getRouter().addLeaveOutObject(this);
      } else {
        this.getRouter().removeLeaveOutObject(this);
      }
    }

    /**
     * Get field views.
     *
     * @param [withHidden] With hidden.
     */
    getFieldViews() {
      var _this$fieldList;
      let withHidden = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
      // noinspection BadExpressionStatementJS
      withHidden;
      const fields = {};
      (_this$fieldList = this.fieldList) === null || _this$fieldList === void 0 || _this$fieldList.forEach(item => {
        const view = this.getFieldView(item);
        if (view) {
          fields[item] = view;
        }
      });
      return fields;
    }

    /**
     * Get a field view.
     *
     * @param name A field name.
     */
    getFieldView(name) {
      let view = this.getView(`${name}Field`) || null;

      // @todo Remove.
      if (!view) {
        view = this.getView(name) || null;
      }
      return view;
    }

    /**
     * @deprecated Use `getFieldView`.
     */
    getField(name) {
      return this.getFieldView(name);
    }

    /**
     * Get a field list.
     */
    getFieldList() {
      return Object.keys(this.getFieldViews());
    }

    /**
     * Get a field view list.
     */
    getFieldViewList() {
      return this.getFieldList().map(field => this.getFieldView(field)).filter(view => view !== null);
    }
    data() {
      return {
        scope: this.scope,
        entityType: this.entityType,
        hiddenPanels: this.recordHelper.getHiddenPanels(),
        hiddenFields: this.recordHelper.getHiddenFields()
      };
    }

    /**
     * @todo Remove.
     * @internal
     */
    handleDataBeforeRender(data) {
      this.getFieldList().forEach(field => {
        const viewKey = field + 'Field';
        data[field] = data[viewKey];
      });
    }

    /**
     * Warning. Is not called by record/detail.
     */
    setup() {
      if (typeof this.model === 'undefined') {
        throw new Error('Model has not been injected into record view.');
      }
      this.recordHelper = this.options.recordHelper || new _viewRecordHelper.default();
      this.dynamicLogicDefs = this.options.dynamicLogicDefs || this.dynamicLogicDefs;
      this.on('remove', () => {
        if (this.isChanged) {
          this.resetModelChanges();
        }
        this.setIsNotChanged();
      });
      this.entityType = this.model.entityType || this.model.name || 'Common';
      this.scope = this.options.scope || this.entityType;
      this.fieldList = this.options.fieldList || this.fieldList || [];
      this.numId = Math.floor(Math.random() * 10000 + 1).toString();
      this.id = _utils.default.toDom(this.entityType) + '-' + _utils.default.toDom(this.type) + '-' + this.numId;
      if (this.model.isNew()) {
        this.isNew = true;
      }
      this.setupBeforeFinal();
    }

    /**
     * Set up before final.
     */
    setupBeforeFinal() {
      this.attributes = this.model.getClonedAttributes();
      this.listenTo(this.model, 'change', (m, o) => {
        if (o.sync) {
          for (const attribute in m.attributes) {
            if (!m.hasChanged(attribute)) {
              continue;
            }
            if (this.attributes) {
              this.attributes[attribute] = _utils.default.cloneDeep(m.get(attribute));
            }
          }
          return;
        }
        if (this.mode === this.MODE_EDIT) {
          this.setIsChanged();
        }
      });
      if (this.options.attributes) {
        this.model.setMultiple(this.options.attributes);
      }
      this.listenTo(this.model, 'sync', () => {
        this.attributes = this.model.getClonedAttributes();
      });
      this.initDependency();
      this.initDynamicLogic();
    }

    /**
     * Set an initial attribute value.
     *
     * @param attribute An attribute name.
     * @param value A value.
     */
    setInitialAttributeValue(attribute, value) {
      if (!this.attributes) {
        this.attributes = {};
      }
      this.attributes[attribute] = value;
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * Check whether a current attribute value differs from initial.
     *
     * @param {string} name An attribute name.
     * @return {boolean}
     */
    checkAttributeIsChanged(name) {
      var _this$attributes;
      return !_underscore.default.isEqual((_this$attributes = this.attributes) === null || _this$attributes === void 0 ? void 0 : _this$attributes[name], this.model.get(name));
    }

    /**
     * Reset model changes.
     */
    resetModelChanges() {
      if (this.updatedAttributes) {
        this.attributes = this.updatedAttributes;
        this.updatedAttributes = null;
      }
      const attributes = this.model.attributes;
      const preSaveAttributes = this.attributes ?? {};
      for (const attr in attributes) {
        if (!(attr in preSaveAttributes)) {
          this.model.unset(attr);
        }
      }
      this.model.setMultiple(preSaveAttributes, {
        skipReRenderInEditMode: true
      });
    }

    /**
     * Init dynamic logic.
     */
    initDynamicLogic() {
      this.dynamicLogicDefs = _utils.default.clone(this.dynamicLogicDefs || {});
      this.dynamicLogicDefs.fields = _utils.default.clone(this.dynamicLogicDefs.fields);
      this.dynamicLogicDefs.panels = _utils.default.clone(this.dynamicLogicDefs.panels);
      this.dynamicLogic = new _dynamicLogic.default(this.dynamicLogicDefs, this);
      this.listenTo(this.model, 'sync', (_m, _a, o) => {
        if (o && o.action !== 'save' && o.action !== 'fetch') {
          return;
        }

        // Pre-save attributes not yet prepared.
        setTimeout(() => this.processDynamicLogic(), 0);
      });
      this.listenTo(this.model, 'change', (_m, o) => {
        if (o.action === 'save' || o.action === 'fetch') {
          // To be processed by the 'sync' handler.
          return;
        }
        this.processDynamicLogic({
          action: o.action
        });
      });
      this.processDynamicLogic();
    }

    /**
     * Process dynamic logic.
     *
     * @param [options] Options.
     */
    processDynamicLogic() {
      let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      this.dynamicLogic.process(options);
    }

    /**
     * @internal
     */
    initDependency() {
      Object.keys(this.dependencyDefs || {}).forEach(attr => {
        this.listenTo(this.model, 'change:' + attr, () => {
          this._handleDependencyAttribute(attr);
        });
      });
      this._handleDependencyAttributes();
    }

    /**
     * Set up a field level security.
     */
    setupFieldLevelSecurity() {
      if (!this.entityType) {
        return;
      }
      const forbiddenFieldList = this.getAcl().getScopeForbiddenFieldList(this.entityType, 'read');
      forbiddenFieldList.forEach(field => this.hideField(field, true));
      const readOnlyFieldList = this.getAcl().getScopeForbiddenFieldList(this.entityType, 'edit');
      readOnlyFieldList.forEach(field => this.setFieldReadOnly(field, true));
    }

    /**
     * Set is changed.
     */
    setIsChanged() {
      this.isChanged = true;
    }

    /**
     * Set is not changed.
     */
    setIsNotChanged() {
      this.isChanged = false;
    }

    /**
     * Validate.
     *
     * @return True if not valid.
     */
    validate() {
      const invalidFieldList = [];
      this.getFieldList().forEach(field => {
        const fieldIsInvalid = this.validateField(field);
        if (fieldIsInvalid) {
          invalidFieldList.push(field);
        }
      });
      if (invalidFieldList.length) {
        this.onInvalid(invalidFieldList);
      }
      return !!invalidFieldList.length;
    }

    /**
     * @param invalidFieldList Invalid fields.
     */
    onInvalid(invalidFieldList) {
      // noinspection BadExpressionStatementJS
      invalidFieldList;
    }

    /**
     * Validate a specific field.
     *
     * @param field A field name.
     * @return True if not valid.
     */
    validateField(field) {
      const msg = this.translate('fieldInvalid', 'messages').replace('{field}', this.translate(field, 'fields', this.entityType));
      const fieldView = this.getFieldView(field);
      if (!fieldView) {
        return false;
      }
      let notValid = false;
      if (fieldView.isEditMode() && !fieldView.disabled && !fieldView.readOnly) {
        notValid = fieldView.validate() || notValid;
      }
      if (notValid) {
        if (fieldView.$el) {
          const rect = fieldView.$el.get(0).getBoundingClientRect();
          if (rect.top === 0 && rect.bottom === 0 && rect.left === 0 && fieldView.$el.closest('.panel.hidden').length) {
            setTimeout(() => {
              const msg = this.translate('Not valid') + ': ' + (fieldView.lastValidationMessage || this.translate(field, 'fields', this.entityType));
              _ui.default.error(msg, true);
            }, 10);
          }
        }
        return true;
      }
      if (this.dynamicLogic && this.dynamicLogicDefs && this.dynamicLogicDefs.fields && this.dynamicLogicDefs.fields[field] && this.dynamicLogicDefs.fields[field].invalid && this.dynamicLogicDefs.fields[field].invalid.conditionGroup) {
        const invalidConditionGroup = this.dynamicLogicDefs.fields[field].invalid.conditionGroup;
        const fieldInvalid = this.dynamicLogic.checkConditionGroup(invalidConditionGroup);
        notValid = fieldInvalid || notValid;
        if (fieldInvalid) {
          fieldView.showValidationMessage(msg);
          fieldView.trigger('invalid');
        }
      }
      return notValid;
    }

    /**
     * Processed after save.
     */
    afterSave() {
      if (this.isNew) {
        _ui.default.success(this.translate('Created'));
      } else {
        _ui.default.success(this.translate('Saved'));
      }
      this.setIsNotChanged();
    }

    /**
     * Processed before before-save.
     */
    beforeBeforeSave() {}

    /**
     * Processed before save.
     */
    beforeSave() {
      _ui.default.notify(this.translate('saving', 'messages'));
    }

    /**
     * Processed after save error.
     */
    afterSaveError() {}

    /**
     * Processed after save a not modified record.
     */
    afterNotModified() {
      _ui.default.warning(this.translate('notModified', 'messages'));
      this.setIsNotChanged();
    }

    /**
     * Processed after save not valid.
     */
    afterNotValid() {
      _ui.default.error(this.translate('Not valid'));
    }

    /**
     * Get changed attribute values. For new record, returns all attributes.
     *
     * @param attributeList
     */
    getChangedAttributes() {
      let attributeList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
      const attributes = this.model.getClonedAttributes();
      if (this.model.isNew()) {
        return attributes;
      }
      const setAttributes = {};
      for (const attr in attributes) {
        var _this$attributes2;
        if (_utils.default.areEqual((_this$attributes2 = this.attributes) === null || _this$attributes2 === void 0 ? void 0 : _this$attributes2[attr], attributes[attr])) {
          continue;
        }
        setAttributes[attr] = attributes[attr];
      }
      const map = this.forcePatchAttributeDependencyMap ?? {};
      for (const attr in map) {
        if (attr in setAttributes) {
          continue;
        }
        if (attributeList && !attributeList.includes(attr)) {
          continue;
        }
        const depAttributes = map[attr];
        const treatAsChanged = !!depAttributes.find(attr => attr in setAttributes);
        if (treatAsChanged) {
          setAttributes[attr] = attributes[attr];
        }
      }
      return setAttributes;
    }

    /**
     * Save.
     *
     * @param [options] Options.
     */
    save(options) {
      options = options || {};
      const headers = options.headers || {};
      const model = this.model;
      this.lastSaveCancelReason = null;
      this.beforeBeforeSave();

      // A model is supposed to always contain actual values.
      // Fetch may not be needed, but some field views may not have data sync implemented.
      // We resort to fetching the entire form.

      const fetchedAttributes = this.fetch();
      this.model.setMultiple(fetchedAttributes, {
        silent: true
      });
      const setAttributes = this.getChangedAttributes(Object.keys(fetchedAttributes));
      if (Object.keys(setAttributes).length === 0) {
        if (!options.skipNotModifiedWarning) {
          this.afterNotModified();
        }
        this.lastSaveCancelReason = 'notModified';
        this.trigger('cancel:save', {
          reason: 'notModified'
        });
        return Promise.reject('notModified');
      }
      if (this.validate()) {
        this.afterNotValid();
        this.lastSaveCancelReason = 'invalid';
        this.trigger('cancel:save', {
          reason: 'invalid'
        });
        return Promise.reject('invalid');
      }
      if (options.afterValidate) {
        options.afterValidate();
      }
      const optimisticConcurrencyControl = this.entityType ? this.getMetadata().get(['entityDefs', this.entityType, 'optimisticConcurrencyControl']) : null;
      if (optimisticConcurrencyControl && this.model.get('versionNumber') !== null) {
        headers['X-Version-Number'] = this.model.get('versionNumber');
      }
      if (this.model.isNew() && this.options.duplicateSourceId) {
        headers['X-Duplicate-Source-Id'] = this.options.duplicateSourceId;
      }
      this.beforeSave();
      this.trigger('before:save');
      model.trigger('before:save');
      const initialAttributes = this.attributes;
      return new Promise((resolve, reject) => {
        const ajaxPromise = model.save(setAttributes, {
          patch: !model.isNew(),
          headers: headers
        });
        ajaxPromise.then(() => {
          var _ajaxPromise$xhr;
          this.trigger('save', initialAttributes, Object.keys(setAttributes));
          this.afterSave();
          if (this.isNew) {
            this.isNew = false;
          }
          this.trigger('after:save');
          model.trigger('after:save');
          if ((_ajaxPromise$xhr = ajaxPromise.xhr) !== null && _ajaxPromise$xhr !== void 0 && _ajaxPromise$xhr.getResponseHeader('X-Record-Link-Updated')) {
            model.trigger('update-all');
          }
          resolve();
        }).catch(xhr => {
          this.handleSaveError(xhr, options, resolve, reject).then(skipReject => {
            if (skipReject) {
              return;
            }
            reject('error');
          });
          this.afterSaveError();
          this.lastSaveCancelReason = 'error';
          this.trigger('error:save');
          this.trigger('cancel:save', {
            reason: 'error'
          });
        });
      });
    }

    /**
     * Handle a save error.
     *
     * @param xhr XHR.
     * @param [options] Options.
     * @param saveResolve Resolve the save promise.
     * @param saveReject Reject the same promise.
     */
    handleSaveError(xhr, options, saveResolve, saveReject) {
      let handlerData = null;
      if ([409, 500].includes(xhr.status)) {
        const statusReason = xhr.getResponseHeader('X-Status-Reason');
        if (!statusReason) {
          return Promise.resolve(false);
        }
        try {
          handlerData = JSON.parse(statusReason);
        } catch (e) {}
        if (!handlerData) {
          handlerData = {
            reason: statusReason.toString()
          };
          if (xhr.responseText) {
            let data;
            try {
              data = JSON.parse(xhr.responseText);
            } catch (e) {
              console.error('Could not parse error response body.');
              return Promise.resolve(false);
            }
            handlerData.data = data;
          }
        }
      }
      if (!handlerData || !handlerData.reason) {
        return Promise.resolve(false);
      }
      const reason = handlerData.reason;
      const handlerName = this.getMetadata().get(['clientDefs', this.scope, 'saveErrorHandlers', reason]) || this.getMetadata().get(['clientDefs', 'Global', 'saveErrorHandlers', reason]);
      return new Promise(resolve => {
        if (handlerName) {
          Espo.loader.require(handlerName, Handler => {
            const handler = new Handler(this);
            handler.process(handlerData.data, options);
            resolve(false);
          });
          xhr.errorIsHandled = true;
          return;
        }
        const methodName = 'errorHandler' + _utils.default.upperCaseFirst(reason);
        if (methodName in this) {
          xhr.errorIsHandled = true;

          // @ts-ignore
          const skipReject = this[methodName](handlerData.data, options, saveResolve, saveReject);
          resolve(skipReject || false);
          return;
        }
        resolve(false);
      });
    }

    /**
     * Fetch data from the form.
     */
    fetch() {
      let data = {};
      const fieldViews = this.getFieldViews();
      for (const i in fieldViews) {
        const view = fieldViews[i];
        if (!view.isEditMode()) {
          continue;
        }
        if (!view.disabled && !view.readOnly && view.isFullyRendered()) {
          data = {
            ...data,
            ...view.fetch()
          };
        }
      }
      return data;
    }

    /**
     * Process fetch. Returns null if not valid.
     */
    processFetch() {
      const data = this.fetch();
      this.model.setMultiple(data);
      if (this.validate()) {
        return null;
      }
      return data;
    }

    /**
     * @deprecated As of v9.3.0.
     * @todo Remove in v11.0.
     */
    populateDefaults() {
      return undefined;
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * @internal
     */
    errorHandlerDuplicate(duplicates, options, resolve, reject) {
      // noinspection BadExpressionStatementJS
      duplicates;
      // noinspection BadExpressionStatementJS
      options;
      // noinspection BadExpressionStatementJS
      resolve;
      // noinspection BadExpressionStatementJS
      reject;
    }
    _handleDependencyAttributes() {
      // noinspection JSDeprecatedSymbols
      Object.keys(this.dependencyDefs || {}).forEach(attr => {
        this._handleDependencyAttribute(attr);
      });
    }
    _handleDependencyAttribute(attr) {
      // noinspection JSDeprecatedSymbols
      const data = this.dependencyDefs[attr];
      const value = this.model.get(attr);
      if (value in (data.map || {})) {
        (data.map[value] || []).forEach(item => {
          this._doDependencyAction(item);
        });
        return;
      }
      if ('default' in data) {
        (data.default || []).forEach(item => {
          this._doDependencyAction(item);
        });
      }
    }

    /**
     * Legacy.
     */
    _doDependencyAction(data) {
      const action = data.action;
      const methodName = 'dependencyAction' + _utils.default.upperCaseFirst(action);

      // @ts-ignore
      if (methodName in this && typeof this.methodName === 'function') {
        // @ts-ignore
        this.methodName(data);
        return;
      }
      const fieldList = data.fieldList || data.fields || [];
      const panelList = data.panelList || data.panels || [];
      switch (action) {
        case 'hide':
          panelList.forEach(item => {
            this.hidePanel(item);
          });
          fieldList.forEach(item => {
            this.hideField(item);
          });
          break;
        case 'show':
          panelList.forEach(item => {
            this.showPanel(item);
          });
          fieldList.forEach(item => {
            this.showField(item);
          });
          break;
        case 'setRequired':
          fieldList.forEach(field => {
            this.setFieldRequired(field);
          });
          break;
        case 'setNotRequired':
          fieldList.forEach(field => {
            this.setFieldNotRequired(field);
          });
          break;
        case 'setReadOnly':
          fieldList.forEach(field => {
            this.setFieldReadOnly(field);
          });
          break;
        case 'setNotReadOnly':
          fieldList.forEach(field => {
            this.setFieldNotReadOnly(field);
          });
          break;
      }
    }

    /**
     * Create a field view.
     *
     * @protected
     * @param name A field name.
     * @param [view] A view name/path.
     * @param [params] Field params.
     * @param [mode='edit'] A mode.
     * @param [readOnly] Read-only.
     * @param [options] View options.
     *
     * @internal
     */
    createField(name) {
      let view = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
      let params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
      let mode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'edit';
      let readOnly = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
      let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
      const o = {
        model: this.model,
        mode: mode || 'edit',
        selector: '.field[data-name="' + name + '"]',
        defs: {
          name: name,
          params: params || {}
        }
      };
      if (readOnly) {
        o.readOnly = true;
      }
      view = view || this.model.getFieldParam(name, 'view');
      if (!view) {
        const type = this.model.getFieldType(name) || 'base';
        view = this.getFieldManager().getViewName(type);
      }
      if (options) {
        for (const param in options) {
          o[param] = options[param];
        }
      }
      if (this.recordHelper.getFieldStateParam(name, 'hidden')) {
        o.disabled = true;
      }
      if (this.recordHelper.getFieldStateParam(name, 'readOnly')) {
        o.readOnly = true;
      }
      if (this.recordHelper.getFieldStateParam(name, 'required') !== null) {
        o.defs.params.required = this.recordHelper.getFieldStateParam(name, 'required');
      }
      if (this.recordHelper.hasFieldOptionList(name)) {
        o.customOptionList = this.recordHelper.getFieldOptionList(name);
      }
      const viewKey = name + 'Field';
      this.createView(viewKey, view, o);
      if (this.fieldList && !this.fieldList.includes(name)) {
        this.fieldList.push(name);
      }
    }

    /**
     * Get a currently focused field view.
     */
    getFocusedFieldView() {
      const activeElement = window.document.activeElement;
      if (!activeElement) {
        return null;
      }
      const fieldElement = activeElement.closest('.field');
      if (!fieldElement) {
        return null;
      }
      const name = fieldElement.dataset.name;
      if (!name) {
        return null;
      }
      return this.getFieldView(name);
    }

    /**
     * Process exit.
     *
     * @param [after] An exit parameter.
     */
    exit(after) {
      // noinspection BadExpressionStatementJS
      after;
    }

    /**
     * Is changed.
     *
     * @since 10.0.0
     */
    hasChanged() {
      return this.isChanged;
    }
  }
  var _default = _exports.default = BaseRecordView;
  function hasSetOptionList(view) {
    return typeof (view === null || view === void 0 ? void 0 : view.setOptionList) === 'function';
  }
  function hasResetOptionList(view) {
    return typeof (view === null || view === void 0 ? void 0 : view.resetOptionList) === 'function';
  }
});

define("views/record/detail/buttons", ["exports", "view", "components/controls", "bullbone"], function (_exports, _view, _controls, _bullbone) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class DetailRecordButtonsView extends _view.default {
    useVirtualDom = true;
    content() {
      const data = this.data();
      const buttons = [];
      data.buttonList.forEach(it => {
        let className = this.options.actionClassName;
        if (it.iconClass && !(it.label || it.labelTranslation || it.text || it.html)) {
          className += ' btn-icon';
        } else {
          className += ' btn-xs-wide';
        }
        buttons.push(new _controls.ButtonComponent({
          name: it.name,
          action: it.name,
          scope: this.options.entityType,
          label: it.label,
          labelTranslation: it.labelTranslation,
          style: it.style,
          title: it.title,
          titleTranslation: it.titleTranslation,
          text: it.text,
          className: className,
          hidden: it.hidden,
          disabled: it.disabled || data.allDisabled,
          iconClass: it.iconClass,
          html: it.html
        }).node());
      });
      const elements = [...buttons];
      if (data.dropdownItemList.length) {
        const icon = (0, _bullbone.h)('span', {
          class: {
            'fas': true,
            'fa-ellipsis-h': true
          }
        });
        elements.push((0, _bullbone.h)('button', {
          key: '_dropdown-button',
          attrs: {
            type: 'button'
          },
          class: {
            'btn': true,
            'btn-default': true,
            'dropdown-toggle': true,
            'dropdown-item-list-button': true
          },
          dataset: {
            toggle: 'dropdown'
          }
        }, icon));
        const dropdownItems = [];
        data.dropdownItemList.forEach(it => {
          if (it === false) {
            dropdownItems.push((0, _bullbone.h)('li', {
              class: {
                'divider': true
              }
            }));
            return;
          }
          dropdownItems.push(new _controls.DropdownItemComponent({
            name: it.name,
            action: it.name,
            scope: this.options.entityType,
            label: it.label,
            labelTranslation: it.labelTranslation,
            title: it.title,
            titleTranslation: it.titleTranslation,
            text: it.text,
            className: data.actionClassName,
            hidden: it.hidden,
            disabled: it.disabled || data.allDisabled,
            html: it.html,
            iconClass: it.iconClass
          }).node());
        });
        elements.push((0, _bullbone.h)('ul', {
          class: {
            'dropdown-menu': true,
            'pull-left': true
          }
        }, dropdownItems));
      }
      return (0, _bullbone.fragment)(elements);
    }
    data() {
      const data = this.options.dataProvider();
      const dropdownEmpty = data.dropdownItemList.filter(it => it && !it.hidden).length === 0;
      const dropdownItemList = data.dropdownItemList.filter(it => it === false || !it.hidden).filter((it, i, list) => {
        if (it === false && (i === 0 || i === list.length - 1)) {
          return false;
        }
        if (it === false && list[i - 1] === false) {
          return false;
        }
        return true;
      });
      return {
        buttonList: data.buttonList.filter(it => !it.hidden),
        dropdownItemList: dropdownItemList,
        entityType: this.options.entityType,
        actionClassName: this.options.actionClassName,
        dropdownEmpty: dropdownEmpty,
        allDisabled: data.allDisabled
      };
    }
  }
  _exports.default = DetailRecordButtonsView;
});

define("views/modals/select-template", ["exports", "views/modals/select-records"], function (_exports, _selectRecords) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _selectRecords = _interopRequireDefault(_selectRecords);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class SelectTemplateModalView extends _selectRecords.default {
    multiple = false;
    createButton = false;
    searchPanel = false;
    scope = 'Template';
    backdrop = true;
    setupSearch() {
      super.setupSearch();
      this.searchManager.setAdvanced({
        entityType: {
          type: 'equals',
          value: this.options.entityType
        }
      });
      this.collection.where = this.searchManager.getWhere();
      this.collection.data.primaryFilter = 'active';
    }
    afterRender() {
      super.afterRender();
      const firstLinkElement = this.$el.find('a.link').first().get(0);
      if (firstLinkElement) {
        // noinspection JSUnresolvedReference
        setTimeout(() => firstLinkElement.focus({
          preventScroll: true
        }), 10);
      }
    }
  }
  var _default = _exports.default = SelectTemplateModalView;
});

define("helpers/util/debounce", ["exports"], function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * A debounce helper.
   *
   * @since 9.1.0
   */
  class DebounceHelper {
    /**
     * @type {boolean}
     * @private
     */
    blocked = false;

    /**
     * @type {boolean}
     * @private
     */
    blockedInProcess = false;

    /**
     * @type {boolean}
     * @private
     */
    calledWhenProcessBlocked = false;

    /**
     * @type {number}
     * @private
     */
    interval = 500;

    /**
     * @type {number}
     * @private
     */
    blockInterval = 1000;

    /**
     * @type {number}
     * @private
     */
    blockedCallCount = 0;

    /**
     * @type {number|null}
     * @private
     */
    blockTimeoutId = null;

    /**
     * @param {{
     *     handler: function(...*),
     *     interval?: number,
     *     blockInterval?: number,
     * }} options
     * @param options
     */
    constructor(options) {
      /**
       * @private
       * @type {function(...*)}
       */
      this.handler = options.handler;
      this.interval = options.interval ?? this.interval;
      this.blockInterval = options.blockInterval ?? this.blockInterval;
    }

    /**
     * Process.
     *
     * @param {...*} [arguments]
     */
    process() {
      const handle = () => {
        if (this.blocked) {
          this.blockedCallCount++;
          return;
        }
        if (this.blockedInProcess) {
          this.calledWhenProcessBlocked = true;
          return;
        }
        this.handler(arguments);
        this.blockedInProcess = true;
        setTimeout(() => {
          const reRun = this.calledWhenProcessBlocked;
          this.blockedInProcess = false;
          this.calledWhenProcessBlocked = false;
          if (reRun) {
            handle();
          }
        }, this.interval);
      };
      handle();
    }

    /**
     * Block for a while.
     *
     * @since 9.2.0
     */
    block() {
      this.blocked = true;
      if (this.blockTimeoutId) {
        clearTimeout(this.blockTimeoutId);
      }
      this.blockTimeoutId = setTimeout(() => {
        this.blocked = false;
        const toProcess = this.blockedCallCount > 1;
        this.blockedCallCount = 0;
        if (toProcess) {
          this.process();
        }
      }, this.blockInterval);
    }
  }
  _exports.default = DebounceHelper;
});

define("helpers/record/misc/sticky-bar", ["exports", "jquery"], function (_exports, _jquery) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _jquery = _interopRequireDefault(_jquery);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * @internal
   */
  class StickyBarHelper {
    /**
     * @param {import('views/record/detail').default} view
     * @param {string} stickButtonsFormBottomSelector
     * @param {boolean} stickButtonsContainerAllTheWay
     * @param {string} numId
     */
    constructor(view, stickButtonsFormBottomSelector, stickButtonsContainerAllTheWay, numId) {
      this.view = view;
      this.stickButtonsFormBottomSelector = stickButtonsFormBottomSelector;
      this.stickButtonsContainerAllTheWay = stickButtonsContainerAllTheWay;
      this.numId = numId;
      this.themeManager = view.getThemeManager();
      this.$el = view.$el;
    }
    init() {
      const $containers = this.$el.find('.detail-button-container');
      const $container = this.$el.find('.detail-button-container.record-buttons');
      if (!$container.length) {
        return;
      }
      const navbarHeight = this.themeManager.getParam('navbarHeight') * this.themeManager.getFontSizeFactor();
      const screenWidthXs = this.themeManager.getParam('screenWidthXs');
      const isSmallScreen = (0, _jquery.default)(window.document).width() < screenWidthXs;
      const getOffsetTop = (/** JQuery */$element) => {
        let element = /** @type {HTMLElement} */$element.get(0);
        let value = 0;
        while (element) {
          value += !isNaN(element.offsetTop) ? element.offsetTop : 0;
          element = element.offsetParent;
        }
        if (isSmallScreen) {
          return value;
        }
        return value - navbarHeight;
      };
      let stickTop = getOffsetTop($container);
      const blockHeight = $container.outerHeight();
      stickTop -= 5; // padding;

      const $block = (0, _jquery.default)('<div>').css('height', blockHeight + 'px').html('&nbsp;').hide().insertAfter($container);
      let $middle = this.view.getMiddleView().$el;
      const $window = (0, _jquery.default)(window);
      const $navbarRight = (0, _jquery.default)('#navbar .navbar-right');
      if (this.stickButtonsFormBottomSelector) {
        const $bottom = this.$el.find(this.stickButtonsFormBottomSelector);
        if ($bottom.length) {
          $middle = $bottom;
        }
      }
      $window.off('scroll.detail-' + this.numId);
      $window.on('scroll.detail-' + this.numId, () => {
        const edge = $middle.position().top + $middle.outerHeight(false) - blockHeight;
        const scrollTop = $window.scrollTop();
        if (scrollTop >= edge && !this.stickButtonsContainerAllTheWay) {
          $containers.hide();
          $navbarRight.removeClass('has-sticked-bar');
          $block.show();
          return;
        }
        if (isSmallScreen && (0, _jquery.default)('#navbar .navbar-body').hasClass('in')) {
          return;
        }
        if (scrollTop > stickTop) {
          if (!$containers.hasClass('stick-sub')) {
            $containers.addClass('stick-sub');
            $block.show();
          }
          $navbarRight.addClass('has-sticked-bar');
          $containers.show();
          return;
        }
        if ($containers.hasClass('stick-sub')) {
          $containers.removeClass('stick-sub');
          $navbarRight.removeClass('has-sticked-bar');
          $block.hide();
        }
        $containers.show();
      });
    }
  }
  var _default = _exports.default = StickyBarHelper;
});

define("helpers/record/detail/layout-converter", ["exports", "di", "language", "view-helper", "field-manager"], function (_exports, _di, _language, _viewHelper, _fieldManager) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _language = _interopRequireDefault(_language);
  _viewHelper = _interopRequireDefault(_viewHelper);
  _fieldManager = _interopRequireDefault(_fieldManager);
  var _staticBlock;
  let _init_language, _init_extra_language, _init_viewHelper, _init_extra_viewHelper, _init_fieldManager, _init_extra_fieldManager;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  /**
   * @internal
   */
  class LayoutConverter {
    constructor() {
      _init_extra_fieldManager(this);
    }
    /**
     * @type {Language}
     * @private
     */
    language = _init_language(this);

    /**
     * @type {ViewHelper}
     * @private
     */
    viewHelper = (_init_extra_language(this), _init_viewHelper(this));

    /**
     * @type {FieldManager}
     * @private
     */
    fieldManager = (_init_extra_viewHelper(this), _init_fieldManager(this));

    /**
     * Convert a detail layout to an internal layout.
     *
     * @param {import('views/record/detail').PanelDefs[]} simplifiedLayout A detail layout.
     * @param {{
     *     selector: string,
     *     id: string,
     *     entityType: string | null,
     *     model: import('model').default,
     *     panelFieldListMap: Record<string, string[]>,
     *     middlePanelDefs: Record<string, any>,
     *     middlePanelDefsList: Record<string, any>[],
     *     underShowMoreDetailPanelList: string[],
     *     dynamicLogic: import('dynamic-logic').default | null,
     *     dynamicLogicDefs: import('dynamic-logic').Defs | null,
     *     recordHelper: import('view-record-helper').default,
     *     hidePanel: (name: string) => void,
     *     validateField: (name: string) => boolean,
     *     readOnly: boolean,
     *     readOnlyLocked: boolean,
     *     inlineEditDisabled: boolean,
     *     dataObject: Record<string, any>,
     *     fieldsMode: 'detail' | 'edit' | 'list',
     * }} options
     * @return {Record<string, any>[]}
     */
    convert(simplifiedLayout, options) {
      const layout = [];
      const el = options.selector || '#' + options.id;
      const panelFieldListMap = options.panelFieldListMap;
      const middlePanelDefs = options.middlePanelDefs;
      const middlePanelDefsList = options.middlePanelDefsList;
      const underShowMoreDetailPanelList = options.underShowMoreDetailPanelList;
      const recordHelper = options.recordHelper;
      const dynamicLogic = options.dynamicLogic;
      const dynamicLogicDefs = options.dynamicLogicDefs;
      const entityType = options.entityType;
      let tabNumber = -1;
      for (let p = 0; p < simplifiedLayout.length; p++) {
        const item = simplifiedLayout[p];
        const panel = {};
        const tabBreak = item.tabBreak || p === 0;
        if (tabBreak) {
          tabNumber++;
        }
        if ('customLabel' in item) {
          panel.label = item.customLabel;
          if (panel.label) {
            panel.label = this.language.translate(panel.label, 'panelCustomLabels', entityType);
          }
        } else {
          panel.label = item.label || null;
          if (panel.label) {
            panel.label = panel.label[0] === '$' ? this.language.translate(panel.label.substring(1), 'panels', entityType) : this.language.translate(panel.label, 'labels', entityType);
          }
        }
        panel.name = item.name || 'panel-' + p.toString();
        panel.style = item.style || 'default';
        panel.rows = [];
        panel.tabNumber = tabNumber;
        panel.noteText = item.noteText;
        panel.noteStyle = item.noteStyle || 'info';
        if (panel.noteText) {
          if (panel.noteText.startsWith('$') && !panel.noteText.includes(' ')) {
            const label = panel.noteText.substring(1);
            panel.noteText = this.language.translate(label, 'panelNotes', entityType);
          }
          panel.noteText = this.viewHelper.transformMarkdownText(panel.noteText);
        }
        middlePanelDefs[panel.name] = {
          name: panel.name,
          style: panel.style,
          tabNumber: panel.tabNumber,
          tabBreak: tabBreak,
          tabLabel: item.tabLabel
        };
        middlePanelDefsList.push(middlePanelDefs[panel.name]);

        // noinspection JSUnresolvedReference
        if (item.dynamicLogicVisible && dynamicLogic) {
          dynamicLogic.addPanelVisibleCondition(panel.name, item.dynamicLogicVisible);
        }

        // noinspection JSUnresolvedReference
        if (item.dynamicLogicStyled && dynamicLogic) {
          dynamicLogic.addPanelStyledCondition(panel.name, item.dynamicLogicStyled);
        }

        // noinspection JSUnresolvedReference
        if (item.hidden && tabNumber === 0) {
          panel.hidden = true;
          options.hidePanel(panel.name);
          underShowMoreDetailPanelList.push(panel.name);
        }
        let lType = 'rows';
        if (item.columns) {
          lType = 'columns';
          panel.columns = [];
        }
        if (panel.name) {
          panelFieldListMap[panel.name] = [];
        }
        for (const [i, itemI] of item[lType].entries()) {
          const row = [];
          for (const cellDefs of itemI) {
            var _dynamicLogicDefs$cas;
            if (cellDefs === false) {
              row.push(false);
              continue;
            }
            let view = cellDefs.view;
            let name = cellDefs.name;
            if (!name && view && typeof view === 'object') {
              name = view.name;
            }
            if (!name) {
              console.warn(`No 'name' specified in detail layout cell.`);
              continue;
            }
            let selector;
            if (view && typeof view === 'object') {
              view.model = options.model;
              view.mode = options.fieldsMode;
              if (options.readOnly) {
                view.setReadOnly();
              }
              selector = `.field[data-name="${name}"]`;
            }
            if (panel.name) {
              panelFieldListMap[panel.name].push(name);
            }
            const type = cellDefs.type || options.model.getFieldType(name) || 'base';
            view = view || options.model.getFieldParam(name, 'view') || this.fieldManager.getViewName(type);
            const o = {
              fullSelector: `${el} .middle .field[data-name="${name}"]`,
              defs: {
                name: name,
                params: cellDefs.params || {}
              },
              mode: options.fieldsMode
            };
            if (options.readOnly) {
              o.readOnly = true;
            }
            if (cellDefs.readOnly) {
              o.readOnly = true;
              o.readOnlyLocked = true;
            }
            if (options.readOnlyLocked) {
              o.readOnlyLocked = true;
            }
            if (options.inlineEditDisabled || cellDefs.inlineEditDisabled) {
              o.inlineEditDisabled = true;
            }

            // noinspection JSUnresolvedReference
            let fullWidth = cellDefs.fullWidth || false;
            if (!fullWidth) {
              if (item[lType][i].length === 1) {
                fullWidth = true;
              }
            }
            if (recordHelper.getFieldStateParam(name, 'hidden')) {
              o.disabled = true;
            }
            if (recordHelper.getFieldStateParam(name, 'hiddenLocked')) {
              o.disabledLocked = true;
            }
            if (recordHelper.getFieldStateParam(name, 'readOnly')) {
              o.readOnly = true;
            }
            if (!o.readOnlyLocked && recordHelper.getFieldStateParam(name, 'readOnlyLocked')) {
              o.readOnlyLocked = true;
            }
            if (recordHelper.getFieldStateParam(name, 'required') !== null) {
              o.defs.params = o.defs.params || {};
              o.defs.params.required = recordHelper.getFieldStateParam(name, 'required');
            }
            if (recordHelper.hasFieldOptionList(name)) {
              o.customOptionList = recordHelper.getFieldOptionList(name);
            }
            o.validateCallback = () => options.validateField(name);
            o.recordHelper = recordHelper;
            o.dataObject = options.dataObject;
            if (cellDefs.options) {
              for (const optionName in cellDefs.options) {
                if (typeof o[optionName] !== 'undefined') {
                  continue;
                }
                o[optionName] = cellDefs.options[optionName];
              }
            }
            if (dynamicLogicDefs !== null && dynamicLogicDefs !== void 0 && (_dynamicLogicDefs$cas = dynamicLogicDefs.cascadingFields) !== null && _dynamicLogicDefs$cas !== void 0 && _dynamicLogicDefs$cas[name]) {
              var _dynamicLogicDefs$cas2;
              o.cascadingLogic = dynamicLogicDefs === null || dynamicLogicDefs === void 0 || (_dynamicLogicDefs$cas2 = dynamicLogicDefs.cascadingFields) === null || _dynamicLogicDefs$cas2 === void 0 ? void 0 : _dynamicLogicDefs$cas2[name];
            }
            const cell = {
              name: `${name}Field`,
              view: view,
              field: name,
              fullSelector: `${el} .middle .field[data-name="${name}"]`,
              fullWidth: fullWidth,
              options: o
            };
            if (selector) {
              cell.selector = selector;
            }
            if ('labelText' in cellDefs) {
              o.labelText = cellDefs.labelText;
              cell.customLabel = cellDefs.labelText;
            } else if (cellDefs.labelTranslation) {
              o.labelText = this.language.translatePath(cellDefs.labelTranslation);
              cell.customLabel = o.labelText;
            }
            if ('customLabel' in cellDefs) {
              cell.customLabel = cellDefs.customLabel;
            }
            if ('label' in cellDefs) {
              cell.label = cellDefs.label;
            }
            if (view && typeof view === 'object' && !cell.customLabel && !cell.label && view.getLabelText()) {
              cell.customLabel = view.getLabelText();
            }
            if ('customCode' in cellDefs) {
              cell.customCode = cellDefs.customCode;
            }
            if ('noLabel' in cellDefs) {
              cell.noLabel = cellDefs.noLabel;
            }
            if ('span' in cellDefs) {
              cell.span = cellDefs.span;
            }
            row.push(cell);
          }
          panel[lType].push(row);
        }
        layout.push(panel);
      }
      return layout;
    }
    static #_ = _staticBlock = () => [_init_language, _init_extra_language, _init_viewHelper, _init_extra_viewHelper, _init_fieldManager, _init_extra_fieldManager] = _applyDecs(this, [], [[(0, _di.inject)(_language.default), 0, "language"], [(0, _di.inject)(_viewHelper.default), 0, "viewHelper"], [(0, _di.inject)(_fieldManager.default), 0, "fieldManager"]]).e;
  }
  _staticBlock();
  var _default = _exports.default = LayoutConverter;
});

define("views/record/detail", ["exports", "views/record/base", "view-record-helper", "helpers/action-item-setup", "helpers/record/misc/sticky-bar", "views/modals/select-template", "helpers/util/debounce", "di", "helpers/site/shortcut-manager", "web-socket-manager", "utils", "helpers/record/detail/layout-converter", "underscore", "ui", "views/record/detail/buttons"], function (_exports, _base, _viewRecordHelper, _actionItemSetup, _stickyBar, _selectTemplate, _debounce, _di, _shortcutManager, _webSocketManager, _utils, _layoutConverter, _underscore, _ui, _buttons) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  _viewRecordHelper = _interopRequireDefault(_viewRecordHelper);
  _actionItemSetup = _interopRequireDefault(_actionItemSetup);
  _stickyBar = _interopRequireDefault(_stickyBar);
  _selectTemplate = _interopRequireDefault(_selectTemplate);
  _debounce = _interopRequireDefault(_debounce);
  _shortcutManager = _interopRequireDefault(_shortcutManager);
  _webSocketManager = _interopRequireDefault(_webSocketManager);
  _utils = _interopRequireDefault(_utils);
  _layoutConverter = _interopRequireDefault(_layoutConverter);
  _underscore = _interopRequireDefault(_underscore);
  _ui = _interopRequireDefault(_ui);
  _buttons = _interopRequireDefault(_buttons);
  var _staticBlock;
  let _init_shortcutManager, _init_extra_shortcutManager, _init_webSocketManager, _init_extra_webSocketManager;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  /**
   * A panel soft-locked type.
   */

  /**
   * A button. Handled by an `action{Name}` method, a click handler or a handler class.
   */

  /**
   * A dropdown item. Handled by an `action{Name}` method, a click handler or a handler class.
   */

  /**
   * A row.
   */

  /**
   * Cell definitions.
   */

  /**
   * Panel definitions.
   */

  /**
   * Options.
   */

  /**
   * A detail record view.
   */
  class DetailRecordView extends _base.default {
    shortcutManager = _init_shortcutManager(this);
    template = (_init_extra_shortcutManager(this), 'record/detail');
    type = 'detail';

    /**
     * A layout name. Can be overridden by an option parameter.
     */
    layoutName = 'detail';

    /**
     * A layout. If null, then will be loaded from the backend (using the `layoutName` value).
     * Can be overridden by an option parameter.
     */
    detailLayout = null;

    /**
     * A fields mode.
     */
    fieldsMode = 'detail';

    /**
     * A current mode. Only for reading.
     */
    mode = 'detail';
    gridLayout = null;

    /**
     * Disable buttons. Can be overridden by an option parameter.
     */
    buttonsDisabled = false;

    /**
     * Is record new. Only for reading.
     */
    isNew = false;

    /**
     * A button list.
     */
    buttonList = [{
      name: 'edit',
      label: 'Edit',
      title: 'Ctrl+Space'
    }];

    /**
     * A dropdown item list.
     */
    dropdownItemList = [{
      name: 'delete',
      label: 'Remove',
      groupIndex: 0,
      iconClass: 'fas fa-times'
    }];

    /**
     * A button list for edit mode.
     */
    buttonEditList = [{
      name: 'save',
      label: 'Save',
      style: 'primary',
      edit: true,
      title: 'Ctrl+Enter'
    }, {
      name: 'cancelEdit',
      label: 'Cancel',
      edit: true,
      title: 'Esc'
    }];

    /**
     * Side buttons for edit mode.
     *
     * @since 10.0.0
     */
    sideButtonList = [];

    /**
     * Side buttons for edit mode.
     *
     * @since 10.0.0
     */
    sideButtonEditList = [];

    /**
     * A dropdown item list for edit mode.
     */
    dropdownEditItemList = [];

    /**
     * All action items disabled;
     */
    allActionItemsDisabled = false;

    /**
     * A DOM element ID. Only for reading.
     *
     * @internal
     */

    /**
     * A return-URL. Can be overridden by an option parameter.
     */
    returnUrl = null;

    /**
     * A return dispatch params. Can be overridden by an option parameter.
     */
    returnDispatchParams = null;

    /**
     * A middle view name.
     */
    middleView = 'views/record/detail-middle';

    /**
     * A side view name.
     */
    sideView = 'views/record/detail-side';

    /**
     * A bottom view name.
     */
    bottomView = 'views/record/detail-bottom';

    /**
     * Disable a side view. Can be overridden by an option parameter.
     */
    sideDisabled = false;

    /**
     * Disable a bottom view. Can be overridden by an option parameter.
     */
    bottomDisabled = false;
    gridLayoutType = 'record';

    /**
     * Disable edit mode. Can be overridden by an option parameter.
     */
    editModeDisabled = false;

    /**
     * Disable navigate (prev, next) buttons. Can be overridden by an option parameter.
     */
    navigateButtonsDisabled = false;

    /**
     * Read-only. Can be overridden by an option parameter.
     */
    readOnly = false;

    /**
     * Read-only locked.
     */

    /**
     * Middle view expanded to full width (no side view).
     * Can be overridden by an option parameter.
     */
    isWide = false;

    /**
     * Enable a duplicate action.
     */
    duplicateAction = true;

    /**
     * Enable a self-assign action.
     */
    selfAssignAction = false;

    /**
     * Enable a print-pdf action.
     */
    printPdfAction = true;

    /**
     * Enable a convert-currency action.
     */
    convertCurrencyAction = true;

    /**
     * Enable a save-and-continue-editing action.
     */
    saveAndContinueEditingAction = true;

    /**
     * Disable the inline-edit. Can be overridden by an option parameter.
     */
    inlineEditDisabled = false;

    /**
     * Disable a portal layout usage. Can be overridden by an option parameter.
     */
    portalLayoutDisabled = false;
    panelSoftLockedTypeList = ['default', 'acl', 'delimiter', 'dynamicLogic'];

    /**
     * Dynamic logic. Can be overridden by an option parameter.
     */
    dynamicLogicDefs = {};

    /**
     * Disable confirm leave-out processing.
     */
    confirmLeaveDisabled = false;
    setupHandlerType = 'record/detail';
    currentTab = 0;
    blockUpdateWebSocketPeriod = 500;

    /**
     * @internal
     */

    /**
     * Disable access control.
     */

    inlineEditModeIsOn = false;

    /**
     * A Ctrl+Enter shortcut action.
     */
    shortcutKeyCtrlEnterAction = 'save';

    /**
     * Additional data. Passed to sub-views and fields.
     *
     * @since 9.0.0
     */

    /**
     * Data from the root view.
     *
     * @since 9.0.0
     */

    _webSocketDebounceInterval = 500;
    webSocketManager = _init_webSocketManager(this);
    isSubscribedToWebSocket = (_init_extra_webSocketManager(this), false);
    updateWebSocketIsBlocked = false;
    /**
     * @internal
     */
    hasModifyDetailLayout = false;

    /**
     * A shortcut-key => action map.
     */
    shortcutKeys = {
      'Control+Enter': function (e) {
        this.handleShortcutKeyCtrlEnter(e);
      },
      'Control+Alt+Enter': function (e) {
        this.handleShortcutKeyCtrlAltEnter(e);
      },
      'Control+KeyS': function (e) {
        this.handleShortcutKeyCtrlS(e);
      },
      'Control+Space': function (e) {
        this.handleShortcutKeyCtrlSpace(e);
      },
      'Escape': function (e) {
        this.handleShortcutKeyEscape(e);
      },
      'Control+Backslash': function (e) {
        this.handleShortcutKeyControlBackslash(e);
      },
      'Control+ArrowLeft': function (e) {
        this.handleShortcutKeyControlArrowLeft(e);
      },
      'Control+ArrowRight': function (e) {
        this.handleShortcutKeyControlArrowRight(e);
      }
    };

    /**
     * An `edit` action.
     */
    actionEdit() {
      if (!this.editModeDisabled) {
        this.setEditMode();
        this.focusOnFirstDiv();
        $(window).scrollTop(0);
        return;
      }
      const options = {
        id: this.model.id,
        model: this.model.clone()
      };
      if (this.model.collection) {
        const index = this.model.collection.indexOf(this.model);
        if (index > -1) {
          options.model.collection = this.model.collection;
          options.model.collection.models[index] = options.model;
        }
      }
      if (this.options.rootUrl) {
        options.rootUrl = this.options.rootUrl;
      }
      if (this.inlineEditModeIsOn) {
        options.attributes = this.getChangedAttributes();
        this.resetModelChanges();
      }
      this.getRouter().navigate(`#${this.scope}/edit/${this.model.id}`, {
        trigger: false
      });
      this.getRouter().dispatch(this.scope, 'edit', options);
    }

    // noinspection JSUnusedGlobalSymbols
    actionDelete() {
      this.delete();
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * A `save` action.
     *
     * @param data Data.
     */
    actionSave(data) {
      data = data || {};
      const modeBeforeSave = this.mode;
      const promise = this.save(data.options).catch(reason => {
        if (modeBeforeSave === this.MODE_EDIT && ['error', 'cancel'].includes(reason)) {
          this.setEditMode();
        }
        return Promise.reject(reason);
      });
      if (!this.lastSaveCancelReason || this.lastSaveCancelReason === 'notModified') {
        this.setDetailMode();
        this.focusOnFirstDiv();
        $(window).scrollTop(0);
      }
      return promise;
    }
    actionCancelEdit() {
      this.cancelEdit();
      this.focusOnFirstDiv();
      $(window).scrollTop(0);
    }
    focusOnFirstDiv() {
      const element = /** @type {HTMLElement} */this.$el.find('> div').get(0);
      if (element) {
        element.focus({
          preventScroll: true
        });
      }
    }

    /**
     * A `save-and-continue-editing` action.
     */
    actionSaveAndContinueEditing(data) {
      data = data || {};
      this.save(data.options).catch(() => {});
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * A `self-assign` action.
     */
    actionSelfAssign() {
      const attributes = {
        assignedUserId: this.getUser().id,
        assignedUserName: this.getUser().get('name')
      };
      if ('getSelfAssignAttributes' in this) {
        const attributesAdditional = this.getSelfAssignAttributes();
        if (attributesAdditional) {
          for (const i in attributesAdditional) {
            attributes[i] = attributesAdditional[i];
          }
        }
      }
      this.model.save(attributes, {
        patch: true
      }).then(() => {
        _ui.default.success(this.translate('Self-Assigned'));
      });
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * A `convert-currency` action.
     */
    actionConvertCurrency() {
      this.createView('modalConvertCurrency', 'views/modals/convert-currency', {
        entityType: this.entityType,
        model: this.model
      }).then(view => {
        view.render();
        this.listenToOnce(view, 'after:update', attributes => {
          let isChanged = false;
          for (const a in attributes) {
            if (attributes[a] !== this.model.get(a)) {
              isChanged = true;
              break;
            }
          }
          if (!isChanged) {
            _ui.default.warning(this.translate('notUpdated', 'messages'));
            return;
          }
          this.model.fetch().then(() => {
            _ui.default.success(this.translate('done', 'messages'));
          });
        });
      });
    }

    /**
     * Compose attribute values for a self-assignment.
     */
    getSelfAssignAttributes() {
      return null;
    }

    /**
     * Set up action items.
     */
    setupActionItems() {
      if (this.model.isNew()) {
        this.isNew = true;
        this.removeActionItem('delete');
      } else if (this.scope && this.getMetadata().get(['clientDefs', this.scope, 'removeDisabled'])) {
        this.removeActionItem('delete');
      }
      if (this.duplicateAction && this.entityType && this.scope && this.getAcl().check(this.entityType, 'create') && !this.getMetadata().get(['clientDefs', this.scope, 'duplicateDisabled']) && !this.getMetadata().get(['clientDefs', this.scope, 'createDisabled'])) {
        this.addDropdownItem({
          label: 'Duplicate',
          name: 'duplicate',
          groupIndex: 0,
          iconClass: 'far fa-copy'
        });
      }
      if (this.selfAssignAction && this.entityType && this.getAcl().check(this.entityType, 'edit') && !this.getAcl().getScopeForbiddenFieldList(this.entityType).includes('assignedUser') && !this.getUser().isPortal() && this.model.has('assignedUserId')) {
        this.addDropdownItem({
          label: 'Self-Assign',
          name: 'selfAssign',
          hidden: !!this.model.get('assignedUserId'),
          groupIndex: 0
        });
        this.listenTo(this.model, 'change:assignedUserId', () => {
          if (!this.model.get('assignedUserId')) {
            this.showActionItem('selfAssign');
          } else {
            this.hideActionItem('selfAssign');
          }
        });
      }
      if (this.type === this.TYPE_DETAIL && this.printPdfAction) {
        let printPdfAction = true;
        if (!~(this.getHelper().getAppParam('templateEntityTypeList') || []).indexOf(this.entityType)) {
          printPdfAction = false;
        }
        if (printPdfAction) {
          this.addDropdownItem({
            label: 'Print to PDF',
            name: 'printPdf',
            groupIndex: 6,
            iconClass: 'far fa-file-pdf'
          });
        }
      }
      if (this.type === this.TYPE_DETAIL && this.convertCurrencyAction && this.entityType && this.scope && this.getAcl().check(this.entityType, 'edit') && !this.getMetadata().get(['clientDefs', this.scope, 'convertCurrencyDisabled'])) {
        const currencyFieldList = this.getFieldManager().getEntityTypeFieldList(this.entityType, {
          type: 'currency',
          acl: 'edit'
        });
        if (currencyFieldList.length) {
          this.addDropdownItem({
            label: 'Convert Currency',
            name: 'convertCurrency',
            groupIndex: 5
          });
        }
      }
      if (this.type === this.TYPE_DETAIL && this.getMetadata().get(['scopes', this.scope ?? '_', 'hasPersonalData'])) {
        if (this.getAcl().getPermissionLevel('dataPrivacyPermission') === 'yes') {
          this.dropdownItemList.push({
            label: 'View Personal Data',
            name: 'viewPersonalData',
            groupIndex: 4
          });
        }
      }
      if (this.type === this.TYPE_DETAIL && this.getMetadata().get(['scopes', this.scope ?? '_', 'stream'])) {
        this.addDropdownItem({
          label: 'View Followers',
          name: 'viewFollowers',
          groupIndex: 4
        });
      }
      if (this.buttonsDisabled) {
        return;
      }
      const actionItemSetup = new _actionItemSetup.default();
      if (this.type === this.TYPE_DETAIL) {
        actionItemSetup.setup({
          view: this,
          type: 'detailActionList',
          waitFunc: promise => this.wait(promise),
          addFunc: item => this.addDropdownItem(item),
          showFunc: name => this.showActionItem(name),
          hideFunc: name => this.hideActionItem(name),
          enableFunc: name => this.enableActionItem(name),
          disableFunc: name => this.disableActionItem(name)
        });
        if (this.saveAndContinueEditingAction) {
          this.dropdownEditItemList.push({
            name: 'saveAndContinueEditing',
            label: 'Save & Continue Editing',
            title: 'Ctrl+S',
            groupIndex: 0,
            iconClass: 'far fa-floppy-disk'
          });
        }
      }
      if (this.type === this.TYPE_EDIT || this.type === this.TYPE_DETAIL) {
        actionItemSetup.setup({
          view: this,
          type: 'editActionList',
          waitFunc: promise => this.wait(promise),
          addFunc: item => {
            if (this.type === this.TYPE_EDIT) {
              this.addDropdownItem(item);
            } else {
              this.dropdownEditItemList.push(item);
            }
          },
          showFunc: name => this.showActionItem(name),
          hideFunc: name => this.hideActionItem(name),
          enableFunc: name => this.enableActionItem(name),
          disableFunc: name => this.disableActionItem(name)
        });
        actionItemSetup.setup({
          view: this,
          type: 'recordControls.editSide.buttons',
          waitFunc: promise => this.wait(promise),
          addFunc: item => {
            if (this.type === this.TYPE_EDIT) {
              this.sideButtonList.push(item);
            } else {
              this.sideButtonEditList.push(item);
            }
          },
          showFunc: name => this.showActionItem(name),
          hideFunc: name => this.hideActionItem(name),
          enableFunc: name => this.enableActionItem(name),
          disableFunc: name => this.disableActionItem(name)
        });
      }
    }

    /**
     * Disable action items.
     */
    disableActionItems() {
      this.disableButtons();
    }

    /**
     * Enable action items.
     */
    enableActionItems() {
      this.enableButtons();
    }

    /**
     * Hide a button or dropdown action item.
     *
     * @param name A name.
     */
    hideActionItem(name) {
      let changed = false;
      for (const list of this.getActionGroups()) {
        for (const item of list) {
          if (item.name === name) {
            changed ||= !item.hidden;
            item.hidden = true;
            break;
          }
        }
      }
      if (!changed) {
        return;
      }
      if (this.isRendered()) {
        this.reRenderButtons();
      }
    }
    getActionGroups() {
      return [this.buttonList, this.dropdownItemList, this.dropdownEditItemList, this.buttonEditList, this.sideButtonList, this.sideButtonEditList];
    }

    /**
     * Show a button or dropdown action item.
     *
     * @param name A name.
     */
    showActionItem(name) {
      let changed = false;
      for (const list of this.getActionGroups()) {
        for (const item of list) {
          if (item.name === name) {
            changed ||= item.hidden;
            item.hidden = false;
            break;
          }
        }
      }
      if (!changed) {
        return;
      }
      if (this.isRendered()) {
        this.reRenderButtons();
      }
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * Disable a button or dropdown action item.
     *
     * @param name A name.
     */
    disableActionItem(name) {
      let changed = false;
      for (const list of this.getActionGroups()) {
        for (const item of list) {
          if (item.name === name) {
            changed ||= !item.disabled;
            item.disabled = true;
            break;
          }
        }
      }
      if (!changed) {
        return;
      }
      if (this.isRendered()) {
        this.reRenderButtons();
      }
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * Enable a button or dropdown action item.
     *
     * @param name A name.
     */
    enableActionItem(name) {
      let changed = false;
      for (const list of this.getActionGroups()) {
        for (const item of list) {
          if (item.name === name) {
            changed ||= item.disabled;
            item.disabled = false;
            break;
          }
        }
      }
      if (!changed) {
        return;
      }
      if (this.isRendered()) {
        this.reRenderButtons();
      }
    }

    /**
     * Whether an action item is visible and not disabled.
     *
     * @param name An action item name.
     */
    hasAvailableActionItem(name) {
      if (this.allActionItemsDisabled) {
        return false;
      }
      let groups;
      if (this.type === this.TYPE_DETAIL && this.mode === this.MODE_EDIT) {
        groups = [this.buttonEditList, this.dropdownEditItemList, this.sideButtonEditList];
      } else {
        groups = [this.buttonList, this.dropdownItemList, this.sideButtonList];
      }
      for (const list of groups) {
        const has = list.findIndex(item => {
          return item.name === name && !item.disabled && !item.hidden;
        }) !== -1;
        if (has) {
          return true;
        }
      }
      return false;
    }

    /**
     * Show a panel.
     *
     * @param name A panel name.
     * @param softLockedType A soft-locked type.
     */
    showPanel(name) {
      let softLockedType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'default';
      if (this.recordHelper.getPanelStateParam(name, 'hiddenLocked')) {
        return;
      }
      softLockedType = softLockedType || 'default';
      const softLockedParam = 'hidden' + _utils.default.upperCaseFirst(softLockedType) + 'Locked';
      this.recordHelper.setPanelStateParam(name, softLockedParam, false);
      if (softLockedType === 'dynamicLogic' && this.recordHelper.getPanelStateParam(name, 'hidden') === false) {
        return;
      }
      for (let i = 0; i < this.panelSoftLockedTypeList.length; i++) {
        const iType = this.panelSoftLockedTypeList[i];
        if (iType === softLockedType) {
          continue;
        }
        const iParam = 'hidden' + _utils.default.upperCaseFirst(iType) + 'Locked';
        if (this.recordHelper.getPanelStateParam(name, iParam)) {
          return;
        }
      }
      const middleView = this.getMiddleView();
      if (middleView) {
        middleView.showPanelInternal(name);
      }
      const bottomView = this.getBottomView();
      if (bottomView) {
        if ('showPanel' in bottomView) {
          bottomView.showPanel(name);
        }
      } else if (this.bottomView) {
        this.once('ready', () => {
          const view = this.getBottomView();
          if (!view) {
            return;
          }
          if ('processShowPanel' in view) {
            view.processShowPanel(name);
            return;
          }
          if ('showPanel' in view) {
            view.showPanel(name);
          }
        });
      }
      const sideView = this.getSideView();
      if (sideView) {
        if ('showPanel' in sideView) {
          sideView.showPanel(name);
        }
      } else if (this.sideView) {
        this.once('ready', () => {
          const view = this.getSideView();
          if (!view) {
            return;
          }
          if ('processShowPanel' in view) {
            view.processShowPanel(name);
            return;
          }
          if ('showPanel' in view) {
            view.showPanel(name);
          }
        });
      }
      this.recordHelper.setPanelStateParam(name, 'hidden', false);
      if (this.middlePanelDefs[name]) {
        this.controlTabVisibilityShow(this.middlePanelDefs[name].tabNumber);
        this.adjustMiddlePanels();
      }
      this.recordHelper.trigger('panel-show');
    }

    /**
     * Hide a panel.
     *
     * @param name A panel name.
     * @param [locked=false] Won't be able to un-hide.
     * @param [softLockedType='default']
     *   A soft-locked type.
     */
    hidePanel(name, locked) {
      let softLockedType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'default';
      softLockedType = softLockedType || 'default';
      if (locked) {
        this.recordHelper.setPanelStateParam(name, 'hiddenLocked', true);
      }
      const softLockedParam = 'hidden' + _utils.default.upperCaseFirst(softLockedType) + 'Locked';
      this.recordHelper.setPanelStateParam(name, softLockedParam, true);
      if (softLockedType === 'dynamicLogic' && this.recordHelper.getPanelStateParam(name, 'hidden') === true) {
        return;
      }
      const middleView = this.getMiddleView();
      if (middleView) {
        middleView.hidePanelInternal(name);
      }
      const bottomView = this.getBottomView();
      if (bottomView) {
        if ('hidePanel' in bottomView) {
          bottomView.hidePanel(name);
        }
      } else if (this.bottomView) {
        this.once('ready', () => {
          const view = this.getBottomView();
          if (!view) {
            return;
          }
          if ('processHidePanel' in view) {
            view.processHidePanel(name);
            return;
          }
          if ('hidePanel' in view) {
            view.hidePanel(name);
          }
        });
      }
      const sideView = this.getSideView();
      if (sideView) {
        if ('hidePanel' in sideView) {
          sideView.hidePanel(name);
        }
      } else if (this.sideView) {
        this.once('ready', () => {
          const view = this.getSideView();
          if (!view) {
            return;
          }
          if ('processHidePanel' in view) {
            view.processHidePanel(name);
            return;
          }
          if ('hidePanel' in view) {
            view.hidePanel(name);
          }
        });
      }
      this.recordHelper.setPanelStateParam(name, 'hidden', true);
      if (this.middlePanelDefs[name]) {
        this.controlTabVisibilityHide(this.middlePanelDefs[name].tabNumber);
        this.adjustMiddlePanels();
      }
    }
    afterRender() {
      this.$middle = this.$el.find('.middle').first();
      if (this.bottomView) {
        this.$bottom = this.$el.find('.bottom').first();
      }
      this.adjustMiddlePanels();
      this.initStickableButtonsContainer();
      this.initFieldsControlBehaviour();
    }
    initFieldsControlBehaviour() {
      const fields = this.getFieldViews();
      let fieldInEditMode = null;
      for (const field in fields) {
        const fieldView = fields[field];
        this.listenTo(fieldView, 'edit', view => {
          if (fieldInEditMode && fieldInEditMode.isEditMode()) {
            fieldInEditMode.inlineEditClose();
          }
          fieldInEditMode = view;
        });
        this.listenTo(fieldView, 'inline-edit-on', () => {
          this.inlineEditModeIsOn = true;
        });
        this.listenTo(fieldView, 'inline-edit-off', o => {
          o = o || {};
          if (o.all) {
            return;
          }
          this.inlineEditModeIsOn = false;
          this.setIsNotChanged();
        });
        this.listenTo(fieldView, 'after:inline-edit-off', o => {
          if (this.updatedAttributes && !o.noReset) {
            this.resetModelChanges();
          }
        });
      }
    }
    initStickableButtonsContainer() {
      const helper = new _stickyBar.default(this, this.stickButtonsFormBottomSelector, this.stickButtonsContainerAllTheWay, this.numId);
      helper.init();
    }
    fetch() {
      let data = super.fetch();
      if (this.hasView('side')) {
        const view = this.getSideView();
        if ('fetch' in view) {
          data = _underscore.default.extend(data, view.fetch());
        }
      }
      if (this.hasView('bottom')) {
        const view = this.getBottomView();
        if ('fetch' in view) {
          data = _underscore.default.extend(data, view.fetch());
        }
      }
      return data;
    }
    setEditMode() {
      this.trigger('before:set-edit-mode');
      this.inlineEditModeIsOn = false;
      this.$el.find('.record-buttons').addClass('hidden');
      this.$el.find('.edit-buttons').removeClass('hidden');
      return new Promise(resolve => {
        const fields = this.getFieldViews(true);
        const promiseList = [];
        for (const field in fields) {
          const fieldView = fields[field];
          if (fieldView.readOnly) {
            continue;
          }
          if (fieldView.isEditMode()) {
            fieldView.fetchToModel();
            fieldView.removeInlineEditLinks();
            fieldView.setIsInlineEditMode(false);
          }
          promiseList.push(fieldView.setEditMode().then(() => {
            return fieldView.render();
          }));
        }
        this.mode = this.MODE_EDIT;
        this.trigger('after:set-edit-mode');
        this.trigger('after:mode-change', this.MODE_EDIT);
        Promise.all(promiseList).then(() => resolve(undefined));
      });
    }
    setDetailMode() {
      this.trigger('before:set-detail-mode');
      this.$el.find('.edit-buttons').addClass('hidden');
      this.$el.find('.record-buttons').removeClass('hidden');
      this.inlineEditModeIsOn = false;
      return new Promise(resolve => {
        const fields = this.getFieldViews(true);
        const promiseList = [];
        for (const field in fields) {
          const fieldView = fields[field];
          if (!fieldView.isDetailMode()) {
            if (fieldView.isEditMode()) {
              fieldView.trigger('inline-edit-off', {
                all: true
              });
            }
            promiseList.push(fieldView.setDetailMode().then(() => fieldView.render()));
          }
        }
        this.mode = this.MODE_DETAIL;
        this.trigger('after:set-detail-mode');
        this.trigger('after:mode-change', this.MODE_DETAIL);
        Promise.all(promiseList).then(() => resolve(undefined));
      });
    }
    cancelEdit() {
      this.resetModelChanges();
      this.setDetailMode();
      this.setIsNotChanged();
    }

    /**
     * Whether in edit mode.
     */
    isEditMode() {
      return this.mode === 'edit';
    }
    resetModelChanges() {
      let skipReRender = true;
      if (this.updatedAttributes) {
        this.attributes = this.updatedAttributes;
        this.updatedAttributes = null;
        skipReRender = false;
      }
      const attributes = this.model.attributes;
      for (const attr in attributes) {
        if (!(attr in this.attributes)) {
          this.model.unset(attr);
        }
      }
      this.model.setMultiple(this.attributes, {
        skipReRenderInEditMode: skipReRender,
        action: 'cancel-edit'
      });
    }

    /**
     * Delete the record.
     */
    async delete() {
      await this.confirm({
        message: this.translate('removeRecordConfirmation', 'messages', this.scope),
        confirmText: this.translate('Remove')
      });
      this.trigger('before:delete');
      this.trigger('delete');
      _ui.default.notifyWait();
      const collection = this.model.collection;
      await this.model.destroy({
        wait: true
      });
      if (collection) {
        if (collection.total > 0) {
          collection.total--;
        }
      }
      this.model.set('deleted', true, {
        silent: true
      });
      _ui.default.success(this.translate('Removed'), {
        suppress: true
      });
      this.trigger('after:delete');
      this.exit('delete');
    }

    /**
     * Get field views.
     *
     * @param withHidden With hidden.
     */
    getFieldViews() {
      let withHidden = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
      const fields = {};
      if (this.hasView('middle')) {
        if ('getFieldViews' in this.getMiddleView()) {
          _underscore.default.extend(fields, _utils.default.clone(this.getMiddleView().getFieldViews()));
        }
      }
      if (this.hasView('side')) {
        if ('getFieldViews' in this.getSideView()) {
          _underscore.default.extend(fields, this.getSideView().getFieldViews(withHidden));
        }
      }
      if (this.hasView('bottom')) {
        if ('getFieldViews' in this.getBottomView()) {
          _underscore.default.extend(fields, this.getBottomView().getFieldViews(withHidden));
        }
      }
      return fields;
    }

    /**
     * Get a field view.
     *
     * @param name A field name.
     */
    getFieldView(name) {
      let view;
      if (this.hasView('middle')) {
        view = (this.getMiddleView().getFieldViews() || {})[name];
      }
      if (!view && this.hasView('side')) {
        view = (this.getSideView().getFieldViews(true) || {})[name];
      }
      if (!view && this.hasView('bottom')) {
        view = (this.getBottomView().getFieldViews(true) || {})[name];
      }
      return view ?? null;
    }
    data() {
      let navigateButtonsEnabled = !this.navigateButtonsDisabled && !!this.model.collection;
      let previousButtonEnabled = false;
      let nextButtonEnabled = false;
      if (navigateButtonsEnabled) {
        const collection = this.model.collection;
        if (this.indexOfRecord > 0 || collection.offset) {
          previousButtonEnabled = true;
        }
        const total = collection.total !== undefined ? collection.total : collection.length;
        if (this.indexOfRecord < total - 1 - collection.offset) {
          nextButtonEnabled = true;
        } else {
          if (total === -1) {
            nextButtonEnabled = true;
          } else if (total === -2) {
            if (this.indexOfRecord < collection.length - 1 - collection.offset) {
              nextButtonEnabled = true;
            }
          }
        }
        if (!previousButtonEnabled && !nextButtonEnabled) {
          navigateButtonsEnabled = false;
        }
      }
      const hasMiddleTabs = this.hasTabs();
      const middleTabDataList = hasMiddleTabs ? this.getMiddleTabDataList() : [];
      return {
        scope: this.scope,
        entityType: this.entityType,
        buttonsDisabled: this.buttonsDisabled,
        id: this.id,
        isWide: this.isWide,
        isSmall: this.type === 'editSmall' || this.type === 'detailSmall',
        navigateButtonsEnabled: navigateButtonsEnabled,
        previousButtonEnabled: previousButtonEnabled,
        nextButtonEnabled: nextButtonEnabled,
        hasMiddleTabs: hasMiddleTabs,
        middleTabDataList: middleTabDataList
      };
    }
    getDropdownItemDataList() {
      let type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'detail';
      const dropdownGroups = [];
      const list = type === 'edit' ? this.dropdownEditItemList : this.dropdownItemList;
      list.forEach(item => {
        // For bc.
        if (item === false) {
          return;
        }
        const index = (item.groupIndex === undefined ? 9999 : item.groupIndex) + 100;
        if (dropdownGroups[index] === undefined) {
          dropdownGroups[index] = [];
        }
        dropdownGroups[index].push(item);
      });
      const dropdownItemList = [];
      dropdownGroups.forEach(list => {
        list.forEach(it => dropdownItemList.push(it));
        dropdownItemList.push(false);
      });
      return dropdownItemList;
    }
    init() {
      this.entityType = this.model.entityType || this.model.name || 'Common';
      this.scope = this.options.scope || this.entityType;
      this.layoutName = this.options.layoutName || this.layoutName;
      this.detailLayout = this.options.detailLayout || this.detailLayout;
      this.type = this.options.type || this.type;
      this.buttonList = this.options.buttonList || this.buttonList;
      this.dropdownItemList = this.options.dropdownItemList || this.dropdownItemList;
      this.buttonList = _utils.default.cloneDeep(this.buttonList);
      this.buttonEditList = _utils.default.cloneDeep(this.buttonEditList);
      this.dropdownItemList = _utils.default.cloneDeep(this.dropdownItemList);
      this.dropdownEditItemList = _utils.default.cloneDeep(this.dropdownEditItemList);
      this.sideButtonList = _utils.default.cloneDeep(this.sideButtonList);
      this.sideButtonEditList = _utils.default.cloneDeep(this.sideButtonEditList);
      this.returnAfterCreate = this.options.returnAfterCreate ?? false;
      this.returnUrl = this.options.returnUrl || this.returnUrl;
      this.returnDispatchParams = this.options.returnDispatchParams || this.returnDispatchParams;
      this.exit = this.options.exit || this.exit;
      if (this.shortcutKeys) {
        this.shortcutKeys = _utils.default.cloneDeep(this.shortcutKeys);
      }
    }
    setup() {
      this.setupEventHandlers();
      if (typeof this.model === 'undefined') {
        throw new Error('Model has not been injected into record view.');
      }
      this.setupButtons();
      this.recordHelper = this.options.recordHelper ?? new _viewRecordHelper.default();
      this._initInlineEditSave();
      const collection = this.model.collection;
      if (collection) {
        this.listenTo(this.model, 'destroy', () => {
          if (this.model.id) {
            collection.remove(this.model.id);
          }
          collection.trigger('sync', collection, {}, {});
        });
        if (this.options.indexOfRecord != null) {
          this.indexOfRecord = this.options.indexOfRecord;
        } else {
          this.indexOfRecord = collection.indexOf(this.model);
        }
      }
      this.middlePanelDefs = {};
      this.middlePanelDefsList = [];
      if (this.getUser().isPortal() && !this.portalLayoutDisabled) {
        if (this.getMetadata().get(['clientDefs', this.scope ?? '_', 'additionalLayouts', `${this.layoutName}Portal`])) {
          this.layoutName += 'Portal';
        }
      }
      this.numId = Math.floor(Math.random() * 10000 + 1).toString();

      // For testing purpose.
      $(window).on('fetch-record.' + this.cid, () => this._webSocketDebounceHelper.process());
      this.once('remove', () => {
        if (this.isChanged) {
          this.resetModelChanges();
        }
        this.setIsNotChanged();
        $(window).off('scroll.detail-' + this.numId);
        $(window).off('fetch-record.' + this.cid);
      });
      this.id = _utils.default.toDom(this.entityType ?? '_') + '-' + _utils.default.toDom(this.type) + '-' + this.numId;
      this.isNew = this.model.isNew();
      if (!this.editModeDisabled) {
        if ('editModeDisabled' in this.options) {
          this.editModeDisabled = this.options.editModeDisabled;
        }
      }
      this.confirmLeaveDisabled = this.options.confirmLeaveDisabled || this.confirmLeaveDisabled;
      this.buttonsDisabled = this.options.buttonsDisabled || this.buttonsDisabled;

      // for backward compatibility
      // @todo remove
      if ('buttonsPosition' in this.options && !this.options.buttonsPosition) {
        this.buttonsDisabled = true;
      }
      if ('isWide' in this.options) {
        this.isWide = this.options.isWide;
      }
      if ('sideView' in this.options) {
        this.sideView = this.options.sideView;
      }
      if ('bottomView' in this.options) {
        this.bottomView = this.options.bottomView;
      }
      this.sideDisabled = this.options.sideDisabled || this.sideDisabled;
      this.bottomDisabled = this.options.bottomDisabled || this.bottomDisabled;
      this.readOnly = this.options.readOnly || this.readOnly;
      if (!this.readOnly && !this.isNew) {
        this.readOnly = this.getMetadata().get(['clientDefs', this.scope ?? '_', 'editDisabled']) || false;
      }
      if (this.getMetadata().get(['clientDefs', this.scope ?? '_', 'createDisabled'])) {
        this.duplicateAction = false;
      }
      if ((this.getConfig().get('currencyList') || []).length <= 1) {
        this.convertCurrencyAction = false;
      }
      this.readOnlyLocked = this.readOnly;
      this.inlineEditDisabled = this.inlineEditDisabled || this.getMetadata().get(['clientDefs', this.scope ?? '_', 'inlineEditDisabled']) || false;
      this.inlineEditDisabled = this.options.inlineEditDisabled || this.inlineEditDisabled;
      this.navigateButtonsDisabled = this.options.navigateButtonsDisabled || this.navigateButtonsDisabled;
      this.dynamicLogicDefs = this.options.dynamicLogicDefs ?? this.dynamicLogicDefs;
      this.dataObject = this.options.dataObject || {};
      this.rootData = this.options.rootData || {};
      this.setupActionItems();
      this.setupBeforeFinal();
      this.setupDynamicBehavior();
      this._webSocketDebounceHelper = new _debounce.default({
        interval: this._webSocketDebounceInterval,
        handler: () => this.handleRecordUpdate()
      });
      if (!this.options.webSocketDisabled && !this.isNew && this.webSocketManager.isEnabled() && this.getMetadata().get(['scopes', this.entityType ?? '_', 'object'])) {
        this.subscribeToWebSocket();
        this.once('remove', () => {
          if (this.isSubscribedToWebSocket) {
            this.unsubscribeFromWebSocket();
          }
        });
      }
      this.wait(this.getHelper().processSetupHandlers(this, this.setupHandlerType));
      this.initInlineEditDynamicWithLogicInteroperability();
      this.forcePatchAttributeDependencyMap = this.getMetadata().get(['clientDefs', this.scope ?? '_', 'forcePatchAttributeDependencyMap']) ?? {};
    }
    setupEventHandlers() {
      this.addHandler('click', '.button-container .action', (event, target) => {
        let actionItems = undefined;
        if (target.classList.contains('detail-action-item')) {
          actionItems = [...this.buttonList, ...this.dropdownItemList];
        } else if (target.classList.contains('edit-action-item')) {
          actionItems = [...this.buttonEditList, ...this.dropdownEditItemList];
        } else if (target.classList.contains('side-action-item')) {
          actionItems = [...this.sideButtonList];
        } else if (target.classList.contains('edit-side-action-item')) {
          actionItems = [...this.sideButtonEditList];
        }
        _utils.default.handleAction(this, event, target, {
          actionItems: actionItems
        });
      });
      this.addActionHandler('showMoreDetailPanels', () => this.showMoreDetailPanels());
      this.addHandler('click', '.middle-tabs > button', (_, target) => {
        this.selectTab(parseInt(target.dataset.tab));
      });
    }
    setupBeforeFinal() {
      if (!this.accessControlDisabled) {
        this.manageAccess();
      }
      this.attributes = this.model.getClonedAttributes();
      if (this.options.attributes) {
        this.model.setMultiple(this.options.attributes);
      }
      this.listenTo(this.model, 'sync', () => {
        this.attributes = this.model.getClonedAttributes();
      });
      this.listenTo(this.model, 'change', (m, o) => {
        if (o.sync) {
          for (const attribute in m.attributes) {
            if (!m.hasChanged(attribute)) {
              continue;
            }
            this.attributes[attribute] = _utils.default.cloneDeep(m.get(attribute));
          }
          return;
        }
        if (this.mode === this.MODE_EDIT || this.inlineEditModeIsOn) {
          this.setIsChanged();
        }
      });
    }

    /**
     * @protected
     */
    setupDynamicBehavior() {
      const dependencyDefs = _utils.default.clone(this.getMetadata().get(['clientDefs', this.entityType ?? '_', 'formDependency']) || {});

      // noinspection JSDeprecatedSymbols
      this.dependencyDefs = _underscore.default.extend(dependencyDefs, this.dependencyDefs);
      this.initDependency();
      const dynamicLogic = {
        ...this.getMetadata().get(`logicDefs.${this.entityType}`, {})
      };
      this.dynamicLogicDefs = _underscore.default.extend(dynamicLogic, this.dynamicLogicDefs);
      this.initDynamicLogic();
      this.setupFieldLevelSecurity();
      this.initDynamicHandler();
    }

    /**
     * @private
     */
    _initInlineEditSave() {
      this.listenTo(this.recordHelper, 'inline-edit-save', (field, o) => {
        this.inlineEditSave(field, o);
      });
    }
    inlineEditSave(field, options) {
      const view = this.getFieldView(field);
      if (!view) {
        throw new Error(`No field '${field}'.`);
      }
      options = _underscore.default.extend({
        inline: true,
        field: field,
        afterValidate: () => {
          var _options;
          if ((_options = options) !== null && _options !== void 0 && _options.bypassClose) {
            return;
          }
          view.inlineEditClose(true);
        }
      }, options ?? {});
      this.save(options).then(() => {
        view.trigger('after:inline-save');
        view.trigger('after:save');
        if (options.bypassClose) {
          view.initialAttributes = this.model.getClonedAttributes();
        }
      }).catch(reason => {
        if (reason === 'notModified') {
          if (options.bypassClose) {
            return;
          }
          view.inlineEditClose(true);
          return;
        }
        if (reason === 'error') {
          if (options.bypassClose) {
            return;
          }
          const initialAttributes = {
            ...view.initialAttributes
          };
          view.inlineEdit().then(() => view.initialAttributes = initialAttributes);
        }
      });
    }
    initInlineEditDynamicWithLogicInteroperability() {
      let blockEdit = false;
      const process = (type, field) => {
        if (!this.inlineEditModeIsOn || this.editModeDisabled) {
          return;
        }
        if (blockEdit) {
          return;
        }
        if (type === 'required') {
          const fieldView = this.getFieldView(field);
          if (fieldView && fieldView.validateRequired) {
            fieldView.suspendValidationMessage();
            try {
              if (!fieldView.validateRequired()) {
                return;
              }
            } catch (e) {}
          }
        }
        blockEdit = true;
        setTimeout(() => blockEdit = false, 300);
        setTimeout(() => {
          this.setEditMode();
          this.getFieldViewList().forEach(view => view.removeInlineEditLinks());
        }, 10);
      };
      this.on('set-field-required', field => process('required', field));
      this.on('set-field-option-list', field => process('options', field));
      this.on('reset-field-option-list', field => process('options', field));
    }
    initDynamicHandler() {
      const dynamicHandlerClassName = this.dynamicHandlerClassName || this.getMetadata().get(['clientDefs', this.scope ?? '_', 'dynamicHandler']);
      const init = dynamicHandler => {
        this.listenTo(this.model, 'change', (model, o) => {
          if ('onChange' in dynamicHandler) {
            dynamicHandler.onChange.call(dynamicHandler, model, o);
          }
          const changedAttributes = model.changedAttributes();
          for (const attribute in changedAttributes) {
            const methodName = 'onChange' + _utils.default.upperCaseFirst(attribute);
            if (methodName in dynamicHandler) {
              // @ts-ignore
              dynamicHandler[methodName].call(dynamicHandler, model, changedAttributes[attribute], o);
            }
          }
        });
        if ('init' in dynamicHandler) {
          dynamicHandler.init();
        }
      };
      if (dynamicHandlerClassName) {
        this.wait(new Promise(resolve => {
          Espo.loader.require(dynamicHandlerClassName, DynamicHandler => {
            const dynamicHandler = new DynamicHandler(this);
            init(dynamicHandler);
            resolve(undefined);
          });
        }));
      }
      const handlerList = this.scope ? this.getMetadata().get(['clientDefs', this.scope, 'dynamicHandlerList']) || [] : [];
      if (handlerList.length) {
        const self = this;
        const promiseList = [];
        handlerList.forEach(className => {
          promiseList.push(new Promise(resolve => {
            Espo.loader.require(className, DynamicHandler => {
              resolve(new DynamicHandler(self));
            });
          }));
        });
        this.wait(Promise.all(promiseList).then(list => {
          list.forEach(dynamicHandler => {
            init(dynamicHandler);
          });
        }));
      }
    }

    /**
     * @private
     */
    initShortcuts() {
      if (this.shortcutKeys && this.options.shortcutKeysEnabled) {
        this.shortcutManager.add(this, this.shortcutKeys);
        this.once('remove', () => {
          this.shortcutManager.remove(this);
        });
      }
    }
    setupFinal() {
      this.build();
      this.initShortcuts();
      if (!this.options.focusForCreate) {
        this.once('after:render', () => this.focusOnFirstDiv());
      }
    }
    setIsChanged() {
      this.isChanged = true;
      this.recordHelper.setIsChanged(true);
      if (this.confirmLeaveDisabled) {
        return;
      }
      this.setConfirmLeaveOut(true);
    }
    setIsNotChanged() {
      this.isChanged = false;
      this.recordHelper.setIsChanged(false);
      if (this.confirmLeaveDisabled) {
        return;
      }
      this.setConfirmLeaveOut(false);
    }
    switchToModelByIndex(indexOfRecord) {
      const collection = this.model.collection;
      if (!collection) {
        return;
      }
      const model = collection.at(indexOfRecord);
      if (!model) {
        console.error("Model is not found in collection by index.");
        return;
      }
      const id = model.id;
      const scope = this.entityType || this.scope;
      this.getRouter().navigate(`#${scope}/view/${id}`, {
        trigger: false
      });
      this.getRouter().dispatch(scope, 'view', {
        id: id,
        model: model,
        indexOfRecord: indexOfRecord,
        rootUrl: this.options.rootUrl
      });
    }
    actionPrevious() {
      this.model.abortLastFetch();
      if (!this.model.collection) {
        return;
      }
      const collection = this.model.collection;
      if (this.indexOfRecord <= 0 && !collection.offset) {
        return;
      }
      if (this.indexOfRecord === 0 && collection.offset > 0 && collection.maxSize) {
        collection.offset = Math.max(0, collection.offset - collection.maxSize);
        collection.fetch().then(() => {
          // Restore as it's removed by fetch.
          this.model.collection = collection;
          const indexOfRecord = collection.length - 1;
          if (indexOfRecord < 0) {
            return;
          }
          this.switchToModelByIndex(indexOfRecord);
        });
        return;
      }
      const indexOfRecord = this.indexOfRecord - 1;
      this.switchToModelByIndex(indexOfRecord);
    }
    actionNext() {
      this.model.abortLastFetch();
      if (!this.model.collection) {
        return;
      }
      const collection = this.model.collection;
      if (!(this.indexOfRecord < collection.total - 1 - collection.offset) && collection.total >= 0) {
        return;
      }
      if (collection.total === -2 && this.indexOfRecord >= collection.length - 1 - collection.offset) {
        return;
      }
      const indexOfRecord = this.indexOfRecord + 1;
      if (indexOfRecord <= collection.length - 1 - collection.offset) {
        this.switchToModelByIndex(indexOfRecord);
        return;
      }
      collection.fetch({
        more: true,
        remove: false
      }).then(() => {
        this.switchToModelByIndex(indexOfRecord);
      });
    }

    // noinspection JSUnusedGlobalSymbols
    actionViewPersonalData() {
      this.createView('viewPersonalData', 'views/personal-data/modals/personal-data', {
        model: this.model
      }).then(view => {
        view.render();
        this.listenToOnce(view, 'erase', () => {
          this.clearView('viewPersonalData');
          this.model.fetch();
        });
      });
    }

    // noinspection JSUnusedGlobalSymbols
    actionViewFollowers(data) {
      if (!this.entityType) {
        return;
      }
      const viewName = this.getMetadata().get(['clientDefs', this.entityType, 'relationshipPanels', 'followers', 'viewModalView']) || this.getMetadata().get(['clientDefs', 'User', 'modalViews', 'relatedList']) || 'views/modals/followers-list';
      const selectDisabled = !this.getUser().isAdmin() && this.getAcl().getPermissionLevel('followerManagementPermission') === 'no' && this.getAcl().getPermissionLevel('portalPermission') === 'no';
      const options = {
        model: this.model,
        link: 'followers',
        scope: 'User',
        title: this.translate('Followers'),
        filtersDisabled: true,
        url: `${this.entityType}/${this.model.id}/followers`,
        createDisabled: true,
        selectDisabled: selectDisabled,
        rowActionsView: 'views/user/record/row-actions/relationship-followers'
      };
      if (data.viewOptions) {
        for (const item in data.viewOptions) {
          options[item] = data.viewOptions[item];
        }
      }
      _ui.default.notifyWait();
      this.createView('modalRelatedList', viewName, options).then(view => {
        _ui.default.notify();
        view.render();
        this.listenTo(view, 'action', (event, element) => {
          _utils.default.handleAction(this, event, element);
        });
        this.listenToOnce(view, 'close', () => {
          this.clearView('modalRelatedList');
        });
        view.listenTo(this.model, 'after:relate:followers', () => {
          this.model.fetch();
        });
        view.listenTo(this.model, 'after:unrelate:followers', () => {
          this.model.fetch();
        });
      });
    }

    // noinspection JSUnusedGlobalSymbols
    async actionPrintPdf() {
      const view = new _selectTemplate.default({
        entityType: this.entityType,
        onSelect: models => {
          const model = models[0];
          const url = `?entryPoint=pdf&entityType=${this.entityType}&entityId=${this.model.id}` + `&templateId=${model.id}`;
          window.open(url, '_blank');
        }
      });
      await this.assignView('modal', view);
      await view.render();
    }
    afterSave() {
      if (this.isNew) {
        _ui.default.success(this.translate('Created'));
      } else {
        _ui.default.success(this.translate('Saved'));
      }
      this.enableActionItems();
      this.setIsNotChanged();
      setTimeout(() => {
        this.unblockUpdateWebSocket();
      }, this.blockUpdateWebSocketPeriod);
    }
    beforeSave() {
      _ui.default.notify(this.translate('saving', 'messages'));
      this.blockUpdateWebSocket();
    }
    beforeBeforeSave() {
      this.disableActionItems();
    }
    afterSaveError() {
      this.enableActionItems();
    }
    afterNotModified() {
      const msg = this.translate('notModified', 'messages');
      _ui.default.warning(msg);
      this.enableActionItems();
      this.setIsNotChanged();
    }
    afterNotValid() {
      _ui.default.error(this.translate('Not valid'));
      this.enableActionItems();
    }

    /**
     * @internal
     */
    errorHandlerDuplicate(duplicates, options, resolve, reject) {
      // noinspection BadExpressionStatementJS
      options;
      _ui.default.notify(false);
      this.createView('duplicate', 'views/modals/duplicate', {
        scope: this.entityType,
        duplicates: duplicates,
        model: this.model
      }).then(view => {
        view.render();
        this.listenToOnce(view, 'save', () => {
          this.actionSave({
            options: {
              headers: {
                'X-Skip-Duplicate-Check': 'true'
              }
            }
          }).then(() => resolve()).catch(() => reject('error'));
        });
        this.listenToOnce(view, 'cancel', () => reject('cancel'));
      });
      return true;
    }

    // noinspection JSUnusedGlobalSymbols
    errorHandlerModified(data, options) {
      _ui.default.notify(false);
      const versionNumber = data.versionNumber;
      const values = data.values || {};
      const attributeList = Object.keys(values);
      const diffAttributeList = [];
      attributeList.forEach(attribute => {
        if (this.attributes[attribute] !== values[attribute]) {
          diffAttributeList.push(attribute);
        }
      });
      if (diffAttributeList.length === 0) {
        setTimeout(() => {
          this.model.set('versionNumber', versionNumber, {
            silent: true
          });
          this.attributes.versionNumber = versionNumber;
          if (options.inline && options.field) {
            this.inlineEditSave(options.field);
            return;
          }
          this.actionSave();
        }, 5);
        return;
      }
      this.createView('dialog', 'views/modals/resolve-save-conflict', {
        model: this.model,
        attributeList: diffAttributeList,
        currentAttributes: _utils.default.cloneDeep(this.model.attributes),
        originalAttributes: _utils.default.cloneDeep(this.attributes),
        actualAttributes: _utils.default.cloneDeep(values)
      }).then(view => {
        view.render();
        this.listenTo(view, 'resolve', () => {
          this.model.set('versionNumber', versionNumber, {
            silent: true
          });
          this.attributes.versionNumber = versionNumber;
          for (const attribute in values) {
            this.setInitialAttributeValue(attribute, values[attribute]);
          }
        });
      });
    }

    /**
     * Get a middle view.
     *
     */
    getMiddleView() {
      return this.getView('middle');
    }

    /**
     * Get a side view.
     */
    getSideView() {
      return this.getView('side');
    }

    /**
     * Get a bottom view.
     */
    getBottomView() {
      return this.getView('bottom');
    }
    setReadOnly() {
      if (!this.readOnlyLocked) {
        this.readOnly = true;
      }
      const bottomView = this.getBottomView();
      if (bottomView && 'setReadOnly' in bottomView) {
        bottomView.setReadOnly();
      }
      const sideView = this.getSideView();
      if (sideView && 'setReadOnly' in sideView) {
        sideView.setReadOnly();
      }
      this.getFieldList().forEach(field => {
        this.setFieldReadOnly(field);
      });
    }
    setNotReadOnly() {
      let onlyNotSetAsReadOnly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
      if (!this.readOnlyLocked) {
        this.readOnly = false;
      }
      const bottomView = this.getBottomView();
      if (bottomView && 'setNotReadOnly' in bottomView) {
        bottomView.setNotReadOnly(onlyNotSetAsReadOnly);
      }
      const sideView = this.getSideView();
      if (sideView && 'setNotReadOnly' in sideView) {
        sideView.setNotReadOnly(onlyNotSetAsReadOnly);
      }
      this.getFieldList().forEach(field => {
        if (onlyNotSetAsReadOnly) {
          if (this.recordHelper.getFieldStateParam(field, 'readOnly')) {
            return;
          }
        }
        this.setFieldNotReadOnly(field);
      });
    }
    manageAccessEdit() {
      let second = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
      if (this.isNew) {
        return;
      }
      const editAccess = this.getAcl().checkModel(this.model, 'edit', true);
      if (!editAccess || this.readOnlyLocked) {
        this.readOnly = true;
        this.hideActionItem('edit');
        if (this.selfAssignAction) {
          this.hideActionItem('selfAssign');
        }
      } else {
        this.showActionItem('edit');
        if (this.selfAssignAction) {
          this.hideActionItem('selfAssign');
          if (this.model.has('assignedUserId')) {
            if (!this.model.get('assignedUserId')) {
              this.showActionItem('selfAssign');
            }
          }
        }
        if (!this.readOnlyLocked) {
          if (this.readOnly && second) {
            if (this.isReady) {
              this.setNotReadOnly(true);
            } else {
              this.on('ready', () => this.setNotReadOnly(true));
            }
          }
          this.readOnly = false;
        }
      }
      if (editAccess === null) {
        this.listenToOnce(this.model, 'sync', () => {
          this.model.trigger('acl-edit-ready');
          this.manageAccessEdit(true);
        });
      }
    }
    manageAccessDelete() {
      if (this.isNew) {
        return;
      }
      const deleteAccess = this.getAcl().checkModel(this.model, 'delete', true);
      if (!deleteAccess) {
        this.hideActionItem('delete');
      } else {
        this.showActionItem('delete');
      }
      if (deleteAccess === null) {
        this.listenToOnce(this.model, 'sync', () => this.manageAccessDelete());
      }
    }
    manageAccessStream() {
      if (this.isNew) {
        return;
      }
      if (['no', 'own'].includes(this.getAcl().getLevel('User', 'read')) && this.getAcl().getPermissionLevel('portalPermission') === 'no') {
        this.hideActionItem('viewFollowers');
        return;
      }
      const streamAccess = this.getAcl().checkModel(this.model, 'stream', true);
      if (!streamAccess) {
        this.hideActionItem('viewFollowers');
      } else {
        this.showActionItem('viewFollowers');
      }
      if (streamAccess === null) {
        this.listenToOnce(this.model, 'sync', () => this.manageAccessStream());
      }
    }
    manageAccess() {
      this.manageAccessEdit();
      this.manageAccessDelete();
      this.manageAccessStream();
    }

    /**
     * Add a button.
     *
     */
    addButton(item) {
      let toBeginning = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
      const name = item.name;
      if (!name) {
        return;
      }
      for (const it of this.buttonList) {
        if (it.name === name) {
          return;
        }
      }
      toBeginning ? this.buttonList.unshift(item) : this.buttonList.push(item);
    }

    /**
     * Add a dropdown item.
     */
    addDropdownItem(item) {
      let toBeginning = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
      if (!item) {
        // For bc.
        return;
      }
      const name = item.name;
      if (!name) {
        return;
      }
      for (const item of this.dropdownItemList) {
        if (item.name === name) {
          return;
        }
      }
      toBeginning ? this.dropdownItemList.unshift(item) : this.dropdownItemList.push(item);
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * Add an 'edit' mode button.
     *
     * @param item
     * @param [toBeginning]
     */
    addButtonEdit(item) {
      let toBeginning = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
      const name = item.name;
      if (!name) {
        return;
      }
      for (const item of this.buttonEditList) {
        if (item.name === name) {
          return;
        }
      }
      toBeginning ? this.buttonEditList.unshift(item) : this.buttonEditList.push(item);
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * @deprecated Use `enableActionItems`.
     */
    enableButtons() {
      this.allActionItemsDisabled = false;
      this.reRenderButtons();
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * @deprecated Use `disableActionItems`.
     */
    disableButtons() {
      this.allActionItemsDisabled = true;
      this.reRenderButtons();
    }

    /**
     * Remove a button or dropdown item.
     *
     * @param {string} name A name.
     */
    removeActionItem(name) {
      this.removeButton(name);
    }

    /**
     * @deprecated Use `removeActionItem`.
     *
     * @param {string} name A name.
     */
    removeButton(name) {
      for (const [i, item] of this.buttonList.entries()) {
        if (item.name === name) {
          this.buttonList.splice(i, 1);
          break;
        }
      }
      for (const [i, item] of this.dropdownItemList.entries()) {
        if (item.name === name) {
          this.dropdownItemList.splice(i, 1);
          break;
        }
      }
      if (!this.isRendered()) {
        return;
      }
      this.reRenderButtons();
    }

    /**
     * Convert a detail layout to an internal layout.
     *
     * @param layout A detail layout.
     */
    convertDetailLayout(layout) {
      this.panelFieldListMap = {};
      this.underShowMoreDetailPanelList = [];
      return new _layoutConverter.default().convert(layout, {
        selector: this.getSelector(),
        id: this.id,
        entityType: this.entityType,
        model: this.model,
        panelFieldListMap: this.panelFieldListMap,
        middlePanelDefs: this.middlePanelDefs,
        middlePanelDefsList: this.middlePanelDefsList,
        underShowMoreDetailPanelList: this.underShowMoreDetailPanelList,
        dynamicLogic: this.dynamicLogic,
        dynamicLogicDefs: this.dynamicLogicDefs,
        recordHelper: this.recordHelper,
        hidePanel: name => this.hidePanel(name),
        validateField: name => this.validateField(name),
        readOnly: this.readOnly,
        readOnlyLocked: this.readOnlyLocked,
        inlineEditDisabled: this.inlineEditDisabled,
        dataObject: this.dataObject,
        fieldsMode: this.fieldsMode
      });
    }
    getGridLayout(callback) {
      if (this.gridLayout !== null) {
        callback(this.gridLayout);
        return;
      }
      if (this.detailLayout) {
        this.gridLayout = {
          type: this.gridLayoutType,
          layout: this.convertDetailLayout(this.detailLayout)
        };
        callback(this.gridLayout);
        return;
      }
      this.getHelper().layoutManager.get(this.entityType, this.layoutName, detailLayout => {
        if (this.hasModifyDetailLayout) {
          detailLayout = _utils.default.cloneDeep(detailLayout);
          this.modifyDetailLayout(detailLayout);
        }
        this.detailLayout = detailLayout;
        this.gridLayout = {
          type: this.gridLayoutType,
          layout: this.convertDetailLayout(this.detailLayout)
        };
        callback(this.gridLayout);
      });
    }

    /**
     * Create a side view.
     */
    createSideView() {
      const el = this.getSelector() || '#' + this.id;
      this.createView('side', this.sideView, {
        model: this.model,
        scope: this.scope,
        fullSelector: el + ' .side',
        type: this.type,
        readOnly: this.readOnly,
        inlineEditDisabled: this.inlineEditDisabled,
        recordHelper: this.recordHelper,
        recordViewObject: this,
        isReturn: this.options.isReturn,
        dataObject: this.dataObject
      });
    }

    /**
     * Create a middle view.
     *
     */
    createMiddleView(callback) {
      const el = this.getSelector() || '#' + this.id;
      this.waitForView('middle');
      this.getGridLayout(layout => {
        if (this.hasTabs() && this.options.isReturn && this.isStoredTabForThisRecord()) {
          this.selectStoredTab();
        }
        this.createView('middle', this.middleView, {
          model: this.model,
          scope: this.scope,
          type: this.type,
          layoutDefs: layout,
          fullSelector: el + ' .middle',
          layoutData: {
            model: this.model
          },
          recordHelper: this.recordHelper,
          recordViewObject: this,
          panelFieldListMap: this.panelFieldListMap
        }, callback);
      });
    }

    /**
     * Create a bottom view.
     *
     */
    createBottomView() {
      const el = this.getSelector() || '#' + this.id;
      this.createView('bottom', this.bottomView, {
        model: this.model,
        scope: this.scope,
        fullSelector: el + ' .bottom',
        readOnly: this.readOnly,
        type: this.type,
        inlineEditDisabled: this.inlineEditDisabled,
        recordHelper: this.recordHelper,
        recordViewObject: this,
        portalLayoutDisabled: this.portalLayoutDisabled,
        isReturn: this.options.isReturn,
        dataObject: this.dataObject
      });
    }

    /**
     * Create views.
     *
     * @param [callback]
     */
    build(callback) {
      if (!this.sideDisabled && this.sideView) {
        this.createSideView();
      }
      if (this.middleView) {
        this.createMiddleView(callback);
      }
      if (!this.bottomDisabled && this.bottomView) {
        this.createBottomView();
      }
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * Called after create.
     *
     * @return True if redirecting is processed.
     */
    exitAfterCreate() {
      if (!this.returnAfterCreate && this.model.id) {
        const url = `#${this.scope}/view/${this.model.id}`;
        this.getRouter().navigate(url, {
          trigger: false
        });
        this.getRouter().dispatch(this.scope, 'view', {
          id: this.model.id,
          rootUrl: this.options.rootUrl,
          model: this.model,
          isAfterCreate: true
        });
        return true;
      }
      return false;
    }

    /**
     * Called after save or cancel. By default, redirects a page. Can be overridden in options.
     *
     * @param [after] Name of an action after which #exit is invoked.
     */
    exit(after) {
      if (after) {
        const methodName = 'exitAfter' + _utils.default.upperCaseFirst(after);
        if (methodName in this) {
          // @ts-ignore
          const result = this[methodName]();
          if (result) {
            return;
          }
        }
      }
      let url;
      let options;
      if (this.returnUrl) {
        url = this.returnUrl;
      } else {
        if (after === 'delete') {
          url = this.options.rootUrl ?? `#${this.scope}`;
          if (url !== `#${this.scope}`) {
            this.getRouter().navigate(url, {
              trigger: true
            });
            return;
          }
          this.getRouter().navigate(url, {
            trigger: false
          });
          this.getRouter().dispatch(this.scope, null, {
            isReturn: true
          });
          return;
        }
        if (this.model.id) {
          url = `#${this.scope}/view/${this.model.id}`;
          if (!this.returnDispatchParams) {
            this.getRouter().navigate(url, {
              trigger: false
            });
            options = {
              id: this.model.id,
              model: this.model
            };
            if (this.options.rootUrl) {
              options.rootUrl = this.options.rootUrl;
            }
            this.getRouter().dispatch(this.scope, 'view', options);
          }
        } else {
          url = this.options.rootUrl ?? '#' + this.scope;
        }
      }
      if (this.returnDispatchParams && this.returnDispatchParams.controller) {
        const controller = this.returnDispatchParams.controller;
        const action = this.returnDispatchParams.action;
        options = this.returnDispatchParams.options || {};
        this.getRouter().navigate(url, {
          trigger: false
        });
        this.getRouter().dispatch(controller, action, options);
        return;
      }
      this.getRouter().navigate(url, {
        trigger: true
      });
    }
    subscribeToWebSocket() {
      const topic = `recordUpdate.${this.entityType}.${this.model.id}`;
      this.recordUpdateWebSocketTopic = topic;
      this.isSubscribedToWebSocket = true;
      this.webSocketManager.subscribe(topic, () => this._webSocketDebounceHelper.process());
    }
    unsubscribeFromWebSocket() {
      if (!this.isSubscribedToWebSocket) {
        return;
      }
      this.webSocketManager.unsubscribe(this.recordUpdateWebSocketTopic);
      this.isSubscribedToWebSocket = false;
    }
    async handleRecordUpdate() {
      if (this.updateWebSocketIsBlocked) {
        return;
      }
      if (this.inlineEditModeIsOn || this.mode === this.MODE_EDIT) {
        const m = this.model.clone();
        await m.fetch();
        if (this.inlineEditModeIsOn || this.mode === this.MODE_EDIT) {
          this.updatedAttributes = _utils.default.cloneDeep(m.attributes);
        }
        return;
      }
      await this.model.fetch({
        highlight: true
      });
    }

    /**
     * @internal
     * @param [toUnblock]
     */
    blockUpdateWebSocket() {
      let toUnblock = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
      this.updateWebSocketIsBlocked = true;
      if (toUnblock) {
        setTimeout(() => {
          this.unblockUpdateWebSocket();
        }, this.blockUpdateWebSocketPeriod);
      }
    }
    unblockUpdateWebSocket() {
      this.updateWebSocketIsBlocked = false;
    }

    /**
     * Show more detail panels.
     */
    showMoreDetailPanels() {
      this.hidePanel('showMoreDelimiter');
      this.underShowMoreDetailPanelList.forEach(item => {
        this.showPanel(item);
      });
    }

    // noinspection JSUnusedGlobalSymbols
    getTabCount() {
      if (!this.hasTabs()) {
        return 0;
      }
      let count = 1;
      (this.detailLayout || []).forEach(item => {
        if (item.tabBreak) {
          count++;
        }
      });
      return count;
    }
    hasTabs() {
      if (typeof this._hasMiddleTabs !== 'undefined') {
        return this._hasMiddleTabs;
      }
      if (!this.detailLayout) {
        return false;
      }
      for (const item of this.detailLayout) {
        if (item.tabBreak) {
          this._hasMiddleTabs = true;
          return true;
        }
      }
      this._hasMiddleTabs = false;
      return false;
    }
    getMiddleTabDataList() {
      const currentTab = this.currentTab;
      const panelDataList = this.middlePanelDefsList;
      return panelDataList.filter((item, i) => i === 0 || item.tabBreak).map((item, i) => {
        let label = item.tabLabel;
        let hidden = false;
        if (i > 0) {
          hidden = panelDataList.filter(panel => panel.tabNumber === i).findIndex(panel => !this.recordHelper.getPanelStateParam(panel.name, 'hidden')) === -1;
        }
        if (!label) {
          label = i === 0 ? this.translate('Overview') : (i + 1).toString();
        } else if (label.substring(0, 7) === '$label:') {
          label = this.translate(label.substring(7), 'labels', this.scope);
        } else if (label[0] === '$') {
          label = this.translate(label.substring(1), 'tabs', this.scope);
        }
        return {
          label: label,
          isActive: currentTab === i,
          hidden: hidden
        };
      });
    }

    /**
     * Select a tab.
     */
    selectTab(tab) {
      this.currentTab = tab;
      $('.popover.in').removeClass('in');
      this.whenRendered().then(() => {
        this.$el.find('.middle-tabs > button').removeClass('active');
        this.$el.find(`.middle-tabs > button[data-tab="${tab}"]`).addClass('active');
        this.$el.find('.middle > .panel[data-tab]').addClass('tab-hidden');
        this.$el.find(`.middle > .panel[data-tab="${tab}"]`).removeClass('tab-hidden');
        this.adjustMiddlePanels();
        this.recordHelper.trigger('panel-show');
      });
      this.storeTab();
    }
    storeTab() {
      const key = 'tab_middle';
      const keyRecord = 'tab_middle_record';
      this.getSessionStorage().set(key, this.currentTab);
      this.getSessionStorage().set(keyRecord, `${this.entityType}_${this.model.id}`);
    }
    selectStoredTab() {
      const key = 'tab_middle';
      const tab = this.getSessionStorage().get(key);
      if (tab > 0) {
        this.selectTab(tab);
      }
    }
    isStoredTabForThisRecord() {
      const keyRecord = 'tab_middle_record';
      return this.getSessionStorage().get(keyRecord) === `${this.entityType}_${this.model.id}`;
    }
    onInvalid(invalidFieldList) {
      if (!this.hasTabs()) {
        return;
      }
      const tabList = [];
      for (const field of invalidFieldList) {
        const view = this.getMiddleView().getFieldView(field);
        if (!view) {
          continue;
        }
        const tabString = view.$el.closest('.panel.tab-hidden').attr('data-tab');
        const tab = parseInt(tabString);
        if (tabList.indexOf(tab) !== -1) {
          continue;
        }
        tabList.push(tab);
      }
      if (!tabList.length) {
        return;
      }
      const $tabs = this.$el.find('.middle-tabs');
      tabList.forEach(tab => {
        const $tab = $tabs.find(`> [data-tab="${tab.toString()}"]`);
        $tab.addClass('invalid');
        $tab.one('click', () => {
          $tab.removeClass('invalid');
        });
      });
    }
    controlTabVisibilityShow(tab) {
      if (!this.hasTabs() || tab === 0) {
        return;
      }
      if (this.isBeingRendered()) {
        this.once('after:render', () => this.controlTabVisibilityShow(tab));
        return;
      }
      this.$el.find(`.middle-tabs > [data-tab="${tab.toString()}"]`).removeClass('hidden');
    }
    controlTabVisibilityHide(tab) {
      if (!this.hasTabs() || tab === 0) {
        return;
      }
      if (this.isBeingRendered()) {
        this.once('after:render', () => this.controlTabVisibilityHide(tab));
        return;
      }
      const panelList = this.middlePanelDefsList.filter(panel => panel.tabNumber === tab);
      const allIsHidden = panelList.findIndex(panel => !this.recordHelper.getPanelStateParam(panel.name, 'hidden')) === -1;
      if (!allIsHidden) {
        return;
      }
      const $tab = this.$el.find(`.middle-tabs > [data-tab="${tab.toString()}"]`);
      $tab.addClass('hidden');
      if (this.currentTab === tab) {
        this.selectTab(0);
      }
    }
    adjustMiddlePanels() {
      if (!this.isRendered() || !this.$middle.length) {
        return;
      }
      const $panels = this.$middle.find('> .panel');
      const $bottomPanels = this.$bottom ? this.$bottom.find('> .panel') : null;
      $panels.removeClass('first').removeClass('last').removeClass('in-middle');
      const $visiblePanels = $panels.filter(`:not(.tab-hidden):not(.hidden)`);
      $visiblePanels.each((i, el) => {
        const $el = $(el);
        if (i === $visiblePanels.length - 1) {
          if ($bottomPanels && $bottomPanels.first().hasClass('sticked')) {
            if (i === 0) {
              $el.addClass('first');
              return;
            }
            $el.addClass('in-middle');
            return;
          }
          if (i === 0) {
            return;
          }
          $el.addClass('last');
          return;
        }
        if (i > 0 && i < $visiblePanels.length - 1) {
          $el.addClass('in-middle');
          return;
        }
        if (i === 0) {
          $el.addClass('first');
        }
      });
    }
    focusForEdit() {
      this.$el.find('.field:not(.hidden) .form-control:not([disabled])').first().focus();
    }
    focusForCreate() {
      this.$el.find('.form-control:not([disabled])').first().focus();
    }
    handleShortcutKeyCtrlEnter(event) {
      const action = this.shortcutKeyCtrlEnterAction;
      if (this.inlineEditModeIsOn || this.buttonsDisabled || !action) {
        return;
      }
      if (this.mode !== this.MODE_EDIT) {
        return;
      }
      if (!this.hasAvailableActionItem(action)) {
        return;
      }
      event.preventDefault();
      event.stopPropagation();
      if (document.activeElement instanceof HTMLInputElement) {
        // Fields may need to fetch data first.
        document.activeElement.dispatchEvent(new Event('change', {
          bubbles: true
        }));
      }
      const methodName = 'action' + _utils.default.upperCaseFirst(action);

      // @ts-ignore
      this[methodName]();
    }
    handleShortcutKeyCtrlS(event) {
      if (this.inlineEditModeIsOn || this.buttonsDisabled) {
        return;
      }
      event.preventDefault();
      event.stopPropagation();
      if (this.mode !== this.MODE_EDIT) {
        return;
      }
      if (!this.saveAndContinueEditingAction) {
        return;
      }
      if (!this.hasAvailableActionItem('saveAndContinueEditing')) {
        return;
      }
      this.actionSaveAndContinueEditing();
    }
    handleShortcutKeyCtrlSpace(e) {
      if (this.inlineEditModeIsOn || this.buttonsDisabled) {
        return;
      }
      if (this.type !== this.TYPE_DETAIL || this.mode !== this.MODE_DETAIL) {
        return;
      }
      if (_utils.default.isKeyEventInTextInput(e)) {
        return;
      }
      if (!this.hasAvailableActionItem('edit')) {
        return;
      }
      e.preventDefault();
      e.stopPropagation();
      this.actionEdit();
      if (!this.editModeDisabled) {
        setTimeout(() => this.focusForEdit(), 200);
      }
    }
    handleShortcutKeyEscape(event) {
      if (this.inlineEditModeIsOn || this.buttonsDisabled) {
        return;
      }
      if (this.type !== this.TYPE_DETAIL || this.mode !== this.MODE_EDIT) {
        return;
      }
      event.preventDefault();
      event.stopPropagation();

      // Fetching a currently edited form element.
      this.model.setMultiple(this.fetch());
      if (this.isChanged) {
        this.confirm({
          message: this.translate('confirmLeaveOutMessage', 'messages')
        }).then(() => this.actionCancelEdit());
        return;
      }
      this.actionCancelEdit();
    }
    handleShortcutKeyCtrlAltEnter(event) {
      // noinspection BadExpressionStatementJS
      event;
    }

    /**
     * @internal
     */
    handleShortcutKeyControlBackslash(event) {
      if (!this.hasTabs()) {
        return;
      }
      const $buttons = this.$el.find('.middle-tabs > button:not(.hidden)');
      if ($buttons.length === 1) {
        return;
      }
      event.preventDefault();
      event.stopPropagation();
      let index = $buttons.toArray().findIndex(el => $(el).hasClass('active'));
      index++;
      if (index >= $buttons.length) {
        index = 0;
      }
      const $tab = $($buttons.get(index));
      const tab = parseInt($tab.attr('data-tab') ?? '0');
      this.selectTab(tab);
      if (this.mode === this.MODE_EDIT) {
        setTimeout(() => {
          this.$middle.find(`.panel[data-tab="${tab}"] .cell:not(.hidden)`).first().trigger('focus');
        }, 50);
        return;
      }
      this.$el.find(`.middle-tabs button[data-tab="${tab}"]`).trigger('focus');
    }
    handleShortcutKeyControlArrowLeft(event) {
      if (this.inlineEditModeIsOn || this.buttonsDisabled) {
        return;
      }
      if (this.navigateButtonsDisabled) {
        return;
      }
      if (this.type !== this.TYPE_DETAIL || this.mode !== this.MODE_DETAIL) {
        return;
      }
      if (_utils.default.isKeyEventInTextInput(event)) {
        return;
      }
      const $button = this.$el.find('button[data-action="previous"]');
      if (!$button.length || $button.hasClass('disabled')) {
        return;
      }
      event.preventDefault();
      event.stopPropagation();
      this.actionPrevious();
    }
    handleShortcutKeyControlArrowRight(event) {
      if (this.inlineEditModeIsOn || this.buttonsDisabled) {
        return;
      }
      if (this.navigateButtonsDisabled) {
        return;
      }
      if (this.type !== this.TYPE_DETAIL || this.mode !== this.MODE_DETAIL) {
        return;
      }
      if (_utils.default.isKeyEventInTextInput(event)) {
        return;
      }
      const $button = this.$el.find('button[data-action="next"]');
      if (!$button.length || $button.hasClass('disabled')) {
        return;
      }
      event.preventDefault();
      event.stopPropagation();
      this.actionNext();
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * Get a current mode.
     *
     * @since 8.0.0
     */
    getMode() {
      return this.mode;
    }

    /**
     * @internal
     * @since 9.2.0
     */
    setupReuse() {
      this.initShortcuts();
    }
    setupButtons() {
      if (this.buttonsDisabled) {
        return;
      }
      const buttonsView = new _buttons.default({
        entityType: this.entityType,
        dataProvider: () => {
          return {
            buttonList: this.buttonList,
            dropdownItemList: this.getDropdownItemDataList(),
            allDisabled: this.allActionItemsDisabled
          };
        },
        actionClassName: 'detail-action-item'
      });
      this.assignView('buttons', buttonsView);
      if (this.type === 'detail') {
        const editButtonsView = new _buttons.default({
          entityType: this.entityType,
          dataProvider: () => {
            return {
              buttonList: this.buttonEditList,
              dropdownItemList: this.getDropdownItemDataList('edit'),
              allDisabled: this.allActionItemsDisabled
            };
          },
          actionClassName: 'edit-action-item'
        });
        this.assignView('editButtons', editButtonsView);
        const editSideButtonsView = new _buttons.default({
          entityType: this.entityType,
          dataProvider: () => {
            return {
              buttonList: this.sideButtonEditList,
              dropdownItemList: [],
              allDisabled: this.allActionItemsDisabled
            };
          },
          actionClassName: 'edit-side-action-item'
        });
        this.assignView('editSideButtons', editSideButtonsView);
      }
      if (this.type === 'edit') {
        const sideButtonsView = new _buttons.default({
          entityType: this.entityType,
          dataProvider: () => {
            return {
              buttonList: this.sideButtonList,
              dropdownItemList: [],
              allDisabled: this.allActionItemsDisabled
            };
          },
          actionClassName: 'side-action-item'
        });
        this.assignView('sideButtons', sideButtonsView);
      }
    }
    getButtonsView() {
      return this.getView('buttons');
    }
    getEditButtonsView() {
      return this.getView('editButtons');
    }
    getSideButtonsView() {
      return this.getView('sideButtons');
    }
    getEditSideButtonsView() {
      return this.getView('editSideButtons');
    }
    reRenderButtons() {
      var _this$getButtonsView, _this$getEditButtonsV, _this$getSideButtonsV, _this$getEditSideButt;
      (_this$getButtonsView = this.getButtonsView()) === null || _this$getButtonsView === void 0 || _this$getButtonsView.reRender({
        buffer: true
      });
      (_this$getEditButtonsV = this.getEditButtonsView()) === null || _this$getEditButtonsV === void 0 || _this$getEditButtonsV.reRender({
        buffer: true
      });
      (_this$getSideButtonsV = this.getSideButtonsView()) === null || _this$getSideButtonsV === void 0 || _this$getSideButtonsV.reRender({
        buffer: true
      });
      (_this$getEditSideButt = this.getEditSideButtonsView()) === null || _this$getEditSideButt === void 0 || _this$getEditSideButt.reRender({
        buffer: true
      });
    }

    /**
     * @internal
     */
    modifyDetailLayout(layout) {
      // noinspection BadExpressionStatementJS
      layout;
    }
    static #_ = _staticBlock = () => [_init_shortcutManager, _init_extra_shortcutManager, _init_webSocketManager, _init_extra_webSocketManager] = _applyDecs(this, [], [[(0, _di.inject)(_shortcutManager.default), 0, "shortcutManager"], [(0, _di.inject)(_webSocketManager.default), 0, "webSocketManager"]], 0, void 0, _base.default).e;
  }
  _staticBlock();
  var _default = _exports.default = DetailRecordView;
});

define("ui/multi-select", ["exports", "lib!selectize"], function (_exports, _libSelectize) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _libSelectize = _interopRequireDefault(_libSelectize);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module module:ui/multi-select */

  /**
   * @typedef module:ui/multi-select~Options
   * @type {Object}
   * @property {{value: string, text: string, style?: string, small?: boolean}[]} items
   * @property {string} [delimiter=':,:']
   * @property {boolean} [restoreOnBackspace=false]
   * @property {boolean} [removeButton=true]
   * @property {boolean} [draggable=false]
   * @property {boolean} [selectOnTab=false]
   * @property {boolean} [matchAnyWord=false]
   * @property {boolean} [allowCustomOptions=false]
   * @property {function (string): {value: string, text: string}|null} [create]
   * @property {string[]} [values] Values. As of v9.1.0.
   */

  /**
   * @module ui/multi-select
   */
  const MultiSelect = {
    /**
     * @const
     */
    defaultDelimiter: ':,:',
    /**
     * @param {Element|JQuery} element An element.
     * @param {module:ui/multi-select~Options} options Options.
     */
    init: function (element, options) {
      const $el = $(element);
      const delimiter = options.delimiter || this.defaultDelimiter;
      if (options.values) {
        $el.val(options.values.join(delimiter));
      }
      options = MultiSelect.applyDefaultOptions(options);
      const plugins = {};
      if (options.removeButton) {
        plugins.remove_button = {
          title: ''
        };
      }
      if (options.draggable) {
        plugins.drag_drop = {};
      }
      if (options.restoreOnBackspace) {
        MultiSelect.loadRestoreOnBackspacePlugin();
        plugins.restore_on_backspace_espo = {};
      }
      MultiSelect.loadBypassCtrlEnterPlugin();
      plugins.bypass_ctrl_enter = {};
      const selectizeOptions = {
        options: options.items,
        plugins: plugins,
        delimiter: delimiter,
        labelField: 'text',
        valueField: 'value',
        searchField: ['text'],
        highlight: false,
        selectOnTab: options.selectOnTab
      };
      if (!options.matchAnyWord) {
        // noinspection JSUnresolvedReference
        /** @this Selectize */
        selectizeOptions.score = function (search) {
          // noinspection JSUnresolvedReference
          const score = this.getScoreFunction(search);
          search = search.toLowerCase();
          return function (item) {
            if (item.text.toLowerCase().indexOf(search) === 0) {
              return score(item);
            }
            return 0;
          };
        };
      }
      if (options.matchAnyWord) {
        /** @this Selectize */
        selectizeOptions.score = function (search) {
          // noinspection JSUnresolvedReference
          const score = this.getScoreFunction(search);
          search = search.toLowerCase();
          return function (item) {
            const text = item.text.toLowerCase();
            if (!text.split(' ').find(item => item.startsWith(search)) && !text.startsWith(search)) {
              return 0;
            }
            return score(item);
          };
        };
      }
      selectizeOptions.render = {};
      if (options.allowCustomOptions) {
        selectizeOptions.persist = false;
        selectizeOptions.create = options.create;
        selectizeOptions.render.option_create = data => {
          return $('<div>').addClass('create').append($('<span>').text(data.input).addClass('text-bold')).append('&hellip;').get(0).outerHTML;
        };
      }
      const classMap = {};
      const styleMap = {};
      (options.items || []).forEach(it => {
        if (it.small) {
          classMap[it.value] = 'small';
        }
        if (it.style) {
          styleMap[it.value] = it.style;
        }
      });
      (options.items || []).forEach(it => {
        if (it.small) {
          classMap[it.value] = 'small';
        }
      });
      selectizeOptions.render.item = (/** {text: string, value: string} */data, escape) => {
        const text = escape(data.text);
        const style = escape(styleMap[data.value] || '');
        const classString = escape(classMap[data.value] || '');
        return `<div class="item ${style}"><span class="${classString}">${text}</span> ` + `<a href="javascript:" class="remove">&times;</a></div>`;
      };
      selectizeOptions.render.option = (/** {text: string, value: string} */data, escape) => {
        const value = data.value;
        let classes = '';
        if (value === '') {
          classes += ' selectize-dropdown-emptyoptionlabel';
        }
        const style = styleMap[data.value];
        if (style) {
          classes += ' ' + escape('text-' + style);
        }
        const text = escape(data.text);
        return `<div class="option ${classes}">${text}</div>`;
      };
      $el.selectize(selectizeOptions);
      if ($el[0]) {
        // Check for compatibility with existing code where initialing is called against non-existing element.

        $el[0].selectize.on('item_before_remove', (v, $item) => {
          // Otherwise, the item is left active.
          $item.removeClass('active');
        });
      }
    },
    /**
     * Focus.
     *
     * @param {Element|JQuery} element An element.
     */
    focus: function (element) {
      const $el = $(element);
      if (!$el[0] || !$el[0].selectize) {
        return;
      }
      const selectize = $el[0].selectize;
      selectize.focus();
    },
    /**
     * @private
     * @param {module:ui/multi-select~Options} options
     * @return {module:ui/multi-select~Options}
     */
    applyDefaultOptions: function (options) {
      options = Espo.Utils.clone(options);
      const defaults = {
        removeButton: true,
        draggable: false,
        selectOnTab: false,
        delimiter: MultiSelect.defaultDelimiter,
        matchAnyWord: false,
        allowCustomOptions: false
      };
      for (const key in defaults) {
        if (key in options) {
          continue;
        }
        options[key] = defaults[key];
      }
      return options;
    },
    /**
     * @private
     */
    loadBypassCtrlEnterPlugin: function () {
      if ('bypass_ctrl_enter' in _libSelectize.default.plugins) {
        return;
      }
      const IS_MAC = /Mac/.test(navigator.userAgent);
      _libSelectize.default.define('bypass_ctrl_enter', function () {
        const self = this;
        this.onKeyDown = function () {
          const original = self.onKeyDown;
          return function (e) {
            if (e.code === 'Enter' && (IS_MAC ? e.metaKey : e.ctrlKey)) {
              return;
            }
            return original.apply(this, arguments);
          };
        }();
      });
    },
    /**
     * @private
     */
    loadRestoreOnBackspacePlugin: function () {
      if ('restore_on_backspace_espo' in _libSelectize.default.plugins) {
        return;
      }
      _libSelectize.default.define('restore_on_backspace_espo', function (options) {
        options.text = options.text || function (option) {
          return option[this.settings.labelField];
        };
        const self = this;
        this.onKeyDown = function () {
          const original = self.onKeyDown;
          return function (e) {
            let index, option;
            if (e.code === 'Backspace' && this.$control_input.val() === '' && !this.$activeItems.length) {
              index = this.caretPos - 1;
              if (index >= 0 && index < this.items.length) {
                option = this.options[this.items[index]];
                option = {
                  value: option.value,
                  $order: option.$order,
                  text: option.value
                };

                // noinspection JSUnresolvedReference
                if (this.deleteSelection(e)) {
                  // noinspection JSUnresolvedReference
                  this.setTextboxValue(options.text.apply(this, [option]));
                  this.refreshOptions(true);
                }
                e.preventDefault();
                return;
              }
            }
            return original.apply(this, arguments);
          };
        }();
      });
    }
  };
  var _default = _exports.default = MultiSelect;
});

define("ui/autocomplete", ["exports", "jquery", "handlebars"], function (_exports, _jquery, _handlebars) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _jquery = _interopRequireDefault(_jquery);
  _handlebars = _interopRequireDefault(_handlebars);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module ui/autocomplete */

  /**
   * @typedef {Object} AutocompleteItem
   * @property {string} value
   */

  /**
   * @typedef {{
   *     name?: string,
   *     forceHide?: boolean,
   *     lookup?: string[],
   *     lookupFunction?: function (string): Promise<Array<AutocompleteItem & Record>>,
   *     minChars?: Number,
   *     formatResult?: function (AutocompleteItem & Record<string, any>): string,
   *     onSelect?: function (AutocompleteItem & Record<string, any>): void,
   *     beforeRender?: function (HTMLElement): void,
   *     triggerSelectOnValidInput?: boolean,
   *     autoSelectFirst?: boolean,
   *     handleFocusMode?: 1|2|3,
   *     focusOnSelect?: boolean,
   *     catchFastEnter?: boolean,
   * }} AutocompleteOptions
   */

  /**
   * An autocomplete.
   */
  class Autocomplete {
    /**
     * @param {HTMLInputElement} element
     * @param {AutocompleteOptions} options
     */
    constructor(element, options) {
      /** @private */
      this.$element = (0, _jquery.default)(element);
      let deferredEnter = false;
      let catchEnter = false;
      let catchEnterTimeout = null;
      this.$element.on('keydown', e => {
        if (e.code === 'Tab' && !this.$element.val()) {
          e.stopImmediatePropagation();
        }

        // Scanner input.
        if (options.catchFastEnter) {
          if (e.code !== 'Enter') {
            catchEnter = true;
            if (catchEnterTimeout) {
              clearTimeout(catchEnterTimeout);
            }
            catchEnterTimeout = setTimeout(() => catchEnter = false, 40);
          }
          if (catchEnter && e.code === 'Enter' && this.$element.val()) {
            deferredEnter = true;
          } else {
            deferredEnter = false;
          }
        }
      });
      const lookup = options.lookupFunction ? (query, done) => {
        options.lookupFunction(query).then(items => {
          done({
            suggestions: items
          });
        });
      } : options.lookup;
      const lookupFilter = !options.lookupFunction ? (/** AutocompleteItem */suggestion, /** string */query, /** string */queryLowerCase) => {
        if (suggestion.value.toLowerCase().indexOf(queryLowerCase) === 0) {
          return suggestion.value.length !== queryLowerCase.length;
        }
        return false;
      } : undefined;
      const $modalBody = this.$element.closest('.modal-body');
      const isModal = !!$modalBody.length;
      this.$element.autocomplete({
        beforeRender: $container => {
          if (options.beforeRender) {
            options.beforeRender($container.get(0));
          }
          if (this.$element.hasClass('input-sm')) {
            $container.addClass('small');
          }
          if (options.forceHide) {
            // Prevent an issue that suggestions are shown and not hidden
            // when clicking outside the window and then focusing back on the document.
            if (this.$element.get(0) !== document.activeElement) {
              setTimeout(() => this.$element.autocomplete('hide'), 30);
            }
          }
          if (isModal) {
            // Fixes dropdown dissapearing when clicking scrollbar.
            $container.on('mousedown', e => {
              e.preventDefault();
            });
          }
          if (deferredEnter) {
            setTimeout(() => {
              element.dispatchEvent(new KeyboardEvent("keydown", {
                key: 'Enter',
                code: 'Enter',
                keyCode: 13,
                which: 13,
                bubbles: true,
                cancelable: true
              }));
            }, 100);
          }
          catchEnter = false;
          deferredEnter = false;
        },
        lookup: lookup,
        minChars: options.minChars || 0,
        noCache: true,
        autoSelectFirst: options.autoSelectFirst,
        appendTo: $modalBody.length ? $modalBody : 'body',
        forceFixPosition: true,
        maxHeight: 308,
        formatResult: item => {
          if (options.formatResult) {
            return options.formatResult(item);
          }
          return _handlebars.default.Utils.escapeExpression(item.value);
        },
        lookupFilter: lookupFilter,
        onSelect: item => {
          if (options.onSelect) {
            options.onSelect(item);
          }
          if (options.focusOnSelect) {
            this.$element.focus();
          }
          catchEnter = false;
          deferredEnter = false;
        },
        triggerSelectOnValidInput: options.triggerSelectOnValidInput || false
      });
      this.$element.attr('autocomplete', 'espo-' + (options.name || 'dummy'));
      if (options.handleFocusMode) {
        this.initHandleFocus(options);
      }
    }

    /**
     * @private
     * @param {AutocompleteOptions} options
     */
    initHandleFocus(options) {
      this.$element.off('focus.autocomplete');
      this.$element.on('focus', () => {
        if (options.handleFocusMode === 1) {
          if (this.$element.val()) {
            return;
          }
          this.$element.autocomplete('onValueChange');
          return;
        }
        if (this.$element.val()) {
          // noinspection JSUnresolvedReference
          this.$element.get(0).select();
          return;
        }
        this.$element.autocomplete('onFocus');
      });
      if (options.handleFocusMode === 3) {
        this.$element.on('change', () => this.$element.val(''));
      }
    }

    /**
     * Dispose.
     */
    dispose() {
      this.$element.autocomplete('dispose');
    }

    /**
     * Hide.
     */
    hide() {
      this.$element.autocomplete('hide');
    }

    /**
     * Clear.
     */
    clear() {
      this.$element.autocomplete('clear');
    }
  }
  var _default = _exports.default = Autocomplete;
});

define("helpers/reg-exp-pattern", ["exports", "di", "metadata", "language"], function (_exports, _di, _metadata, _language) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _metadata = _interopRequireDefault(_metadata);
  _language = _interopRequireDefault(_language);
  var _staticBlock;
  let _init_metadata, _init_extra_metadata, _init_language, _init_extra_language;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  /**
   * A regular expression pattern helper.
   */
  class RegExpPatternHelper {
    constructor() {
      _init_extra_language(this);
    }
    /**
     * @private
     * @type {Metadata}
     */
    metadata = _init_metadata(this);

    /**
     * @private
     * @type {Language}
     */
    language = (_init_extra_metadata(this), _init_language(this));

    /**
     *
     * @param {string} pattern
     * @param {string|null} value
     * @param {string} [field]
     * @param {string | null} [entityType]
     * @return {{message: string}|null}
     */
    validate(pattern, value, field, entityType) {
      if (value === '' || value === null) {
        return null;
      }
      let messageKey = 'fieldNotMatchingPattern';
      if (pattern[0] === '$') {
        const patternName = pattern.slice(1);
        const foundPattern = this.metadata.get(['app', 'regExpPatterns', patternName, 'pattern']);
        if (foundPattern) {
          messageKey += '$' + patternName;
          pattern = foundPattern;
        }
      }
      const regExp = new RegExp('^' + pattern + '$');
      if (regExp.test(value)) {
        return null;
      }
      let message = this.language.translate(messageKey, 'messages').replace('{pattern}', pattern);
      if (field && entityType) {
        message = message.replace('{field}', this.language.translate(field, 'fields', entityType));
      }
      return {
        message: message
      };
    }
    static #_ = _staticBlock = () => [_init_metadata, _init_extra_metadata, _init_language, _init_extra_language] = _applyDecs(this, [], [[(0, _di.inject)(_metadata.default), 0, "metadata"], [(0, _di.inject)(_language.default), 0, "language"]]).e;
  }
  _staticBlock();
  var _default = _exports.default = RegExpPatternHelper;
});

define("views/record/edit", ["exports", "views/record/detail", "ui"], function (_exports, _detail, _ui) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _detail = _interopRequireDefault(_detail);
  _ui = _interopRequireDefault(_ui);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * An edit-record view. Used for create and edit.
   */
  class EditRecordView extends _detail.default {
    template = 'record/edit';
    type = 'edit';
    fieldsMode = 'edit';
    mode = 'edit';
    buttonList = [{
      name: 'save',
      label: 'Save',
      style: 'primary',
      title: 'Ctrl+Enter'
    }, {
      name: 'cancel',
      label: 'Cancel',
      title: 'Esc'
    }];
    dropdownItemList = [];
    sideView = 'views/record/edit-side';
    bottomView = 'views/record/edit-bottom';
    duplicateAction = false;
    saveAndContinueEditingAction = true;
    saveAndNewAction = true;
    setupHandlerType = 'record/edit';
    async actionSave(data) {
      data = data || {};
      const isNew = this.isNew;
      try {
        await this.save(data.options);
      } catch (reason) {
        return await Promise.reject(reason);
      }
      if (this.options.duplicateSourceId) {
        this.returnUrl = null;
      }
      this.exit(isNew ? 'create' : 'save');
    }

    /**
     * A `cancel` action.
     */
    actionCancel() {
      this.cancel();
    }

    /**
     * Cancel.
     */
    cancel() {
      if (this.isChanged) {
        this.resetModelChanges();
      }
      this.setIsNotChanged();
      this.exit('cancel');
    }
    setupBeforeFinal() {
      let promise = undefined;
      if (this.model.isNew()) {
        promise = this.populateDefaults();
      }
      if (!promise) {
        // Attributes are yet not ready.
        super.setupBeforeFinal();
      }

      // @todo To be removed.
      if (promise) {
        this.wait(promise);
        promise.then(() => {
          super.setupBeforeFinal();
          this.processDynamicLogic();
        });
      }
      if (this.model.isNew()) {
        this.once('after:render', () => {
          this.model.setMultiple(this.fetch(), {
            silent: true
          });
        });
      }
      if (this.options.focusForCreate) {
        this.once('after:render', () => {
          if (this.$el.closest('.modal').length) {
            setTimeout(() => this.focusForCreate(), 50);
            return;
          }
          this.focusForCreate();
        });
      }
      this.setupHighlight();
    }
    setupActionItems() {
      super.setupActionItems();
      if (this.saveAndContinueEditingAction && this.entityType && this.getAcl().checkScope(this.entityType, 'edit')) {
        this.dropdownItemList.push({
          name: 'saveAndContinueEditing',
          label: 'Save & Continue Editing',
          title: 'Ctrl+S',
          groupIndex: 0,
          iconClass: 'far fa-floppy-disk'
        });
      }
      if (this.isNew && this.saveAndNewAction && this.entityType && this.getAcl().checkScope(this.entityType, 'create')) {
        this.dropdownItemList.push({
          name: 'saveAndNew',
          label: 'Save & New',
          title: 'Ctrl+Alt+Enter',
          groupIndex: 0
        });
      }
    }

    /**
     * A `save-and-create-new` action.
     */
    actionSaveAndNew(data) {
      data = data || {};
      const proceedCallback = () => {
        _ui.default.success(this.translate('Created'));
        this.getRouter().dispatch(this.scope, 'create', {
          rootUrl: this.options.rootUrl,
          focusForCreate: !!data.focusForCreate
        });
        this.getRouter().navigate(`#${this.scope}/create`, {
          trigger: false
        });
      };
      this.save(data.options).then(proceedCallback).catch(() => {});
      if (this.lastSaveCancelReason === 'notModified') {
        proceedCallback();
      }
    }
    handleShortcutKeyEscape(event) {
      if (this.buttonsDisabled) {
        return;
      }
      if (this.buttonList.findIndex(item => item.name === 'cancel' && !item.hidden && !item.disabled) === -1) {
        return;
      }
      event.preventDefault();
      event.stopPropagation();
      const focusedFieldView = this.getFocusedFieldView();
      if (focusedFieldView) {
        this.model.setMultiple(focusedFieldView.fetch());
      }
      if (this.isChanged) {
        this.confirm({
          message: this.translate('confirmLeaveOutMessage', 'messages')
        }).then(() => this.actionCancel());
        return;
      }
      this.actionCancel();
    }
    handleShortcutKeyCtrlAltEnter(event) {
      if (this.buttonsDisabled) {
        return;
      }
      event.preventDefault();
      event.stopPropagation();
      if (!this.saveAndNewAction) {
        return;
      }
      if (!this.hasAvailableActionItem('saveAndNew')) {
        return;
      }
      this.actionSaveAndNew({
        focusForCreate: true
      });
    }
    setupHighlight() {
      if (!this.options.highlightFieldList) {
        return;
      }
      this.on('after:render', () => {
        const fieldList = this.options.highlightFieldList;
        fieldList.map(it => this.getFieldView(it)).filter(view => view != null).forEach(view => view.highlight());
      });
    }
  }
  var _default = _exports.default = EditRecordView;
});

define("views/fields/varchar", ["exports", "views/fields/base", "helpers/reg-exp-pattern", "ui/autocomplete", "ui/multi-select", "ajax", "ui"], function (_exports, _base, _regExpPattern, _autocomplete, _multiSelect, _ajax, _ui) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  _regExpPattern = _interopRequireDefault(_regExpPattern);
  _autocomplete = _interopRequireDefault(_autocomplete);
  _multiSelect = _interopRequireDefault(_multiSelect);
  _ajax = _interopRequireDefault(_ajax);
  _ui = _interopRequireDefault(_ui);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/fields/varchar */

  /**
   * A varchar field.
   */
  class VarcharFieldView extends _base.default {
    type = 'varchar';
    listTemplate = 'fields/varchar/list';
    detailTemplate = 'fields/varchar/detail';
    searchTemplate = 'fields/varchar/search';
    searchTypeList = ['startsWith', 'contains', 'equals', 'endsWith', 'like', 'notContains', 'notEquals', 'notLike', 'anyOf', 'noneOf', 'isEmpty', 'isNotEmpty'];
    validations = ['required', 'pattern'];

    /**
     * Use an autocomplete requesting data from the backend.
     */
    useAutocompleteUrl = false;

    /**
     * No spell-check.
     */
    noSpellCheck = false;
    originalOptionList = null;
    setup() {
      this.setupOptions();
      this.noSpellCheck = this.noSpellCheck || this.params.noSpellCheck || false;
      if (this.params.optionsPath) {
        this.params.options = Espo.Utils.clone(this.getMetadata().get(this.params.optionsPath) || []);
      }
      if (this.options.customOptionList) {
        this.setOptionList(this.options.customOptionList);
      }
      if (this.mode === this.MODE_DETAIL) {
        if (this.params.copyToClipboard) {
          this.events['click [data-action="copyToClipboard"]'] = () => this.copyToClipboard();
        }
      }
      this.on('remove', () => {
        this.searchMultiSelectInputElement = undefined;
      });
    }

    /**
     * Set up options.
     */
    setupOptions() {}

    /**
     * Set options.
     *
     * @param optionList Options.
     */
    setOptionList(optionList) {
      if (!this.originalOptionList) {
        this.originalOptionList = this.params.options || [];
      }
      this.params.options = Espo.Utils.clone(optionList);
      if (this.isEditMode()) {
        if (this.isRendered()) {
          this.reRender();
        }
      }
    }

    /**
     * Reset options.
     */
    resetOptionList() {
      if (this.originalOptionList) {
        this.params.options = Espo.Utils.clone(this.originalOptionList);
      }
      if (this.isEditMode()) {
        if (this.isRendered()) {
          this.reRender();
        }
      }
    }

    /**
     * @protected
     */
    copyToClipboard() {
      const value = this.model.get(this.name);
      navigator.clipboard.writeText(value).then(() => {
        _ui.default.success(this.translate('Copied to clipboard'));
      });
    }

    // noinspection JSUnusedLocalSymbols
    /**
     * Compose an autocomplete URL.
     *
     * @param query A query.
     * @return {string} A URL.
     */
    getAutocompleteUrl(query) {
      // noinspection BadExpressionStatementJS
      query;
      return '';
    }
    transformAutocompleteResult(response) {
      const responseParsed = typeof response === 'string' ? JSON.parse(response) : response;
      const list = [];
      responseParsed.list.forEach(item => {
        list.push({
          value: item.name || item.id,
          attributes: item
        });
      });
      return list;
    }
    setupSearch() {
      this.addHandler('change', 'select.search-type', (_e, target) => {
        this.handleSearchType(target.value);
      });
    }
    data() {
      const data = super.data();
      if (this.model.get(this.name) !== null && this.model.get(this.name) !== '' && this.model.has(this.name)) {
        data.isNotEmpty = true;
      }
      data.valueIsSet = this.model.has(this.name);
      if (this.isSearchMode()) {
        var _this$searchParams, _this$searchParams3, _this$searchParams4, _this$searchParams6, _this$searchParams7;
        if (typeof ((_this$searchParams = this.searchParams) === null || _this$searchParams === void 0 ? void 0 : _this$searchParams.value) === 'string') {
          var _this$searchParams2;
          this.searchData.value = (_this$searchParams2 = this.searchParams) === null || _this$searchParams2 === void 0 ? void 0 : _this$searchParams2.value;
        }
        if ((_this$searchParams3 = this.searchParams) !== null && _this$searchParams3 !== void 0 && _this$searchParams3.data && typeof ((_this$searchParams4 = this.searchParams) === null || _this$searchParams4 === void 0 ? void 0 : _this$searchParams4.data.value) === 'string') {
          var _this$searchParams5;
          this.searchData.value = (_this$searchParams5 = this.searchParams) === null || _this$searchParams5 === void 0 ? void 0 : _this$searchParams5.data.value;
        }
        if (!((_this$searchParams6 = this.searchParams) !== null && _this$searchParams6 !== void 0 && _this$searchParams6.value) && !((_this$searchParams7 = this.searchParams) !== null && _this$searchParams7 !== void 0 && _this$searchParams7.data)) {
          this.searchData.value = null;
        }
      }
      data.noSpellCheck = this.noSpellCheck;
      data.copyToClipboard = this.params.copyToClipboard;
      data.textClass = null;
      return data;
    }
    handleSearchType(type) {
      const mainElement = this.element.querySelector('input.main-element');
      const multiSelectContainer = this.element.querySelector('div[data-role="multi-select-container"]');
      if (['isEmpty', 'isNotEmpty', 'anyOf', 'noneOf'].includes(type)) {
        mainElement === null || mainElement === void 0 || mainElement.classList.add('hidden');
      } else {
        mainElement === null || mainElement === void 0 || mainElement.classList.remove('hidden');
      }
      if (multiSelectContainer) {
        if (['anyOf', 'noneOf'].includes(type)) {
          multiSelectContainer.classList.remove('hidden');
        } else {
          multiSelectContainer.classList.add('hidden');
        }
      }
    }
    afterRender() {
      super.afterRender();
      if (this.isSearchMode()) {
        const type = this.$el.find('select.search-type').val();
        this.handleSearchType(type);
        this.initSearchMultiSelect();
      }
      if ((this.isEditMode() || this.isSearchMode()) && (this.params.options && this.params.options.length || this.useAutocompleteUrl)) {
        var _this$$element;
        let lookupFunction = this.getAutocompleteLookupFunction();
        if (this.useAutocompleteUrl) {
          lookupFunction = async query => {
            const response = await _ajax.default.getRequest(this.getAutocompleteUrl(query));
            return this.transformAutocompleteResult(response);
          };
        }
        const autocomplete = new _autocomplete.default((_this$$element = this.$element) === null || _this$$element === void 0 ? void 0 : _this$$element.get(0), {
          name: this.name,
          triggerSelectOnValidInput: true,
          autoSelectFirst: true,
          handleFocusMode: 1,
          focusOnSelect: true,
          onSelect: () => this.trigger('change'),
          lookup: this.params.options,
          lookupFunction: lookupFunction
        });
        this.once('render remove', () => autocomplete.dispose());
      }
      if (this.isSearchMode()) {
        var _this$$element2;
        this.$el.find('select.search-type').on('change', () => {
          this.trigger('change');
        });
        (_this$$element2 = this.$element) === null || _this$$element2 === void 0 || _this$$element2.on('input', () => this.trigger('change'));
      }
    }

    // noinspection JSUnusedGlobalSymbols
    validatePattern() {
      const pattern = this.params.pattern;
      return this.fieldValidatePattern(this.name, pattern);
    }

    /**
     * Used by other field views.
     *
     * @internal
     */
    fieldValidatePattern(name, pattern) {
      pattern = pattern || this.model.getFieldParam(name, 'pattern');
      /** @var {string|null} value */
      const value = this.model.get(name);
      if (!pattern) {
        return false;
      }
      const helper = new _regExpPattern.default();
      const result = helper.validate(pattern, value, name, this.entityType ?? undefined);
      if (!result) {
        return false;
      }
      const message = result.message.replace('{field}', this.getLanguage().translate(this.getLabelText()));
      this.showValidationMessage(message, '[data-name="' + name + '"]');
      return true;
    }
    fetch() {
      var _this$$element3;
      const data = {};
      const value = (_this$$element3 = this.$element) === null || _this$$element3 === void 0 || (_this$$element3 = _this$$element3.val()) === null || _this$$element3 === void 0 ? void 0 : _this$$element3.trim();
      data[this.name] = value || null;
      return data;
    }
    fetchSearch() {
      var _this$$element4;
      const type = this.fetchSearchType() || 'startsWith';
      if (['isEmpty', 'isNotEmpty'].includes(type)) {
        if (type === 'isEmpty') {
          return {
            type: 'or',
            value: [{
              type: 'isNull',
              attribute: this.name
            }, {
              type: 'equals',
              attribute: this.name,
              value: ''
            }],
            data: {
              type: type
            }
          };
        }
        const value = [{
          type: 'isNotNull',
          attribute: this.name,
          value: null
        }];
        if (!this.model.getFieldParam(this.name, 'notStorable')) {
          value.push({
            type: 'notEquals',
            attribute: this.name,
            value: ''
          });
        }
        return {
          type: 'and',
          value: value,
          data: {
            type: type
          }
        };
      }
      if (type === 'anyOf' || type === 'noneOf') {
        let list = this.searchMultiSelectInputElement ? this.searchMultiSelectInputElement.value.split(_multiSelect.default.defaultDelimiter) : [];
        if (list.length === 1 && list[0] === '') {
          list = [];
        }
        if (type === 'anyOf') {
          if (list.length === 0) {
            return {
              type: 'any',
              data: {
                type: 'anyOf',
                valueList: list
              }
            };
          }
          return {
            type: 'in',
            value: list,
            data: {
              type: 'anyOf',
              valueList: list
            }
          };
        }
        if (list.length === 0) {
          return {
            type: 'any',
            data: {
              type: 'noneOf',
              valueList: list
            }
          };
        }
        return {
          type: 'or',
          value: [
          // Don't change order.
          {
            type: 'notIn',
            value: list,
            attribute: this.name
          }, {
            type: 'isNull',
            attribute: this.name
          }],
          data: {
            type: 'noneOf',
            valueList: list
          }
        };
      }
      const value = (_this$$element4 = this.$element) === null || _this$$element4 === void 0 || (_this$$element4 = _this$$element4.val()) === null || _this$$element4 === void 0 || (_this$$element4 = _this$$element4.toString()) === null || _this$$element4 === void 0 ? void 0 : _this$$element4.trim();
      if (!value) {
        return null;
      }
      return {
        value: value,
        type: type,
        data: {
          type: type
        }
      };
    }
    getSearchType() {
      var _this$getSearchParams, _this$searchParams8, _this$searchParams9;
      return ((_this$getSearchParams = this.getSearchParamsData()) === null || _this$getSearchParams === void 0 ? void 0 : _this$getSearchParams.type) ?? ((_this$searchParams8 = this.searchParams) === null || _this$searchParams8 === void 0 ? void 0 : _this$searchParams8.typeFront) ?? ((_this$searchParams9 = this.searchParams) === null || _this$searchParams9 === void 0 ? void 0 : _this$searchParams9.type) ?? null;
    }

    /**
     * Get an autocomplete lookup function.
     */
    getAutocompleteLookupFunction() {
      return undefined;
    }
    initSearchMultiSelect() {
      var _this$element, _this$element$querySe;
      this.searchMultiSelectInputElement = (_this$element = this.element) === null || _this$element === void 0 ? void 0 : _this$element.querySelector('input[data-role="multi-select-input"]');
      if (!this.searchMultiSelectInputElement) {
        throw new Error("No element.");
      }
      _multiSelect.default.init(this.searchMultiSelectInputElement, {
        items: (this.params.options || []).map(it => ({
          value: it,
          text: it
        })),
        allowCustomOptions: true,
        create: input => {
          return {
            value: input,
            text: input
          };
        },
        values: this.getSearchParamsData().valueList || []
      });
      (_this$element$querySe = this.element.querySelector('.selectize-dropdown-content')) === null || _this$element$querySe === void 0 || _this$element$querySe.classList.add('small');
    }
  }
  var _default = _exports.default = VarcharFieldView;
});

define("layout-manager", ["exports", "bullbone"], function (_exports, _bullbone) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module layout-manager */

  /**
   * A layout manager.
   *
   * @mixes Bull.Events
   */
  class LayoutManager {
    /**
     * @param {module:cache|null} [cache] A cache.
     * @param {string} [applicationId] An application ID.
     * @param {string} [userId] A user ID.
     */
    constructor(cache, applicationId, userId) {
      /**
       * @private
       * @type {module:cache|null}
       */
      this.cache = cache || null;

      /**
       * @private
       * @type {string}
       */
      this.applicationId = applicationId || 'espocrm';

      /**
       * @private
       * @type {string|null}
       */
      this.userId = userId || null;

      /**
       * @private
       * @type {Object}
       */
      this.data = {};

      /** @private */
      this.ajax = Espo.Ajax;

      /**
       * @private
       * @type {Object.<string, module:ajax~AjaxPromise>}
       */
      this.fetchPromises = {};
    }

    /**
     * Set a user ID. To be used for the cache purpose.
     *
     * @param {string} userId A user ID.
     * @internal
     * @todo Throw an exception if already set.
     */
    setUserId(userId) {
      this.userId = userId;
    }

    /**
     * @private
     * @param {string} scope
     * @param {string} type
     * @returns {string}
     */
    getKey(scope, type) {
      if (this.userId) {
        return `${this.applicationId}-${this.userId}-${scope}-${type}`;
      }
      return `${this.applicationId}-${scope}-${type}`;
    }

    /**
     * @private
     * @param {string} scope
     * @param {string} type
     * @param {string} [setId]
     * @returns {string}
     */
    getUrl(scope, type, setId) {
      let url = `${scope}/layout/${type}`;
      if (setId) {
        url += `/${setId}`;
      }
      return url;
    }

    /**
     * @callback module:layout-manager~getCallback
     *
     * @param {*} layout A layout.
     */

    /**
     * Get a layout.
     *
     * @param {string} scope A scope (entity type).
     * @param {string} type A layout type (name).
     * @param {module:layout-manager~getCallback} callback
     * @param {boolean} [cache=true] Use cache.
     */
    get(scope, type, callback, cache) {
      if (typeof cache === 'undefined') {
        cache = true;
      }
      if (!callback) {
        callback = () => {};
      }
      const key = this.getKey(scope, type);
      if (cache && key in this.data) {
        callback(this.data[key]);
        return;
      }
      if (this.cache && cache) {
        const cached = this.cache.get('app-layout', key);
        if (cached) {
          callback(cached);
          this.data[key] = cached;
          return;
        }
      }
      if (key in this.fetchPromises) {
        this.fetchPromises[key].then(layout => callback(layout));
        return;
      }
      this.fetchPromises[key] = this.ajax.getRequest(this.getUrl(scope, type)).then(layout => {
        callback(layout);
        this.data[key] = layout;
        if (this.cache) {
          this.cache.set('app-layout', key, layout);
        }
        return layout;
      }).finally(() => delete this.fetchPromises[key]);
    }

    /**
     * Get an original layout.
     *
     * @param {string} scope A scope (entity type).
     * @param {string} type A layout type (name).
     * @param {string} [setId]
     * @param {module:layout-manager~getCallback} callback
     */
    getOriginal(scope, type, setId, callback) {
      let url = 'Layout/action/getOriginal?scope=' + scope + '&name=' + type;
      if (setId) {
        url += '&setId=' + setId;
      }
      Espo.Ajax.getRequest(url).then(layout => {
        if (typeof callback === 'function') {
          callback(layout);
        }
      });
    }

    /**
     * Store and set a layout.
     *
     * @param {string} scope A scope (entity type).
     * @param {string} type A type (name).
     * @param {*} layout A layout.
     * @param {Function} callback A callback.
     * @param {string} [setId] A set ID.
     * @returns {Promise}
     */
    set(scope, type, layout, callback, setId) {
      return Espo.Ajax.putRequest(this.getUrl(scope, type, setId), layout).then(() => {
        const key = this.getKey(scope, type);
        if (this.cache && key) {
          this.cache.clear('app-layout', key);
        }
        delete this.data[key];
        this.trigger('sync');
        if (typeof callback === 'function') {
          callback();
        }
      });
    }

    /**
     * Reset a layout to default.
     *
     * @param {string} scope A scope (entity type).
     * @param {string} type A type (name).
     * @param {Function} callback A callback.
     * @param {string} [setId] A set ID.
     */
    resetToDefault(scope, type, callback, setId) {
      Espo.Ajax.postRequest('Layout/action/resetToDefault', {
        scope: scope,
        name: type,
        setId: setId
      }).then(() => {
        const key = this.getKey(scope, type);
        if (this.cache) {
          this.cache.clear('app-layout', key);
        }
        delete this.data[key];
        this.trigger('sync');
        if (typeof callback === 'function') {
          callback();
        }
      });
    }

    /**
     * Clear loaded data.
     */
    clearLoadedData() {
      this.data = {};
    }
  }
  Object.assign(LayoutManager.prototype, _bullbone.Events);
  var _default = _exports.default = LayoutManager;
});

define("views/record/edit-for-modal", ["exports", "views/record/edit"], function (_exports, _edit) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _edit = _interopRequireDefault(_edit);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * An edit-record view to used for custom forms.
   */
  class EditForModalRecordView extends _edit.default {
    bottomView = null;
    sideView = null;
    buttonsDisabled = true;
    isWide = true;
    accessControlDisabled = true;
    confirmLeaveDisabled = true;
  }
  var _default = _exports.default = EditForModalRecordView;
});

define("views/fields/enum", ["exports", "views/fields/base", "ui/multi-select", "ui/select", "underscore", "utils"], function (_exports, _base, _multiSelect, _select, _underscore, _utils) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  _multiSelect = _interopRequireDefault(_multiSelect);
  _select = _interopRequireDefault(_select);
  _underscore = _interopRequireDefault(_underscore);
  _utils = _interopRequireDefault(_utils);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/fields/enumeration */

  /**
   * Parameters.
   */

  /**
   * Options.
   */

  /**
   * An enum field (select-box).
   */
  class EnumFieldView extends _base.default {
    type = 'enum';
    listTemplate = 'fields/enum/list';
    listLinkTemplate = 'fields/enum/list-link';
    detailTemplate = 'fields/enum/detail';
    editTemplate = 'fields/enum/edit';
    searchTemplate = 'fields/enum/search';
    translatedOptions = null;

    /**
     * @todo Remove? Always treat as true.
     * @internal
     */
    fetchEmptyValueAsNull = true;
    searchTypeList = ['anyOf', 'noneOf', 'isEmpty', 'isNotEmpty'];
    validationElementSelector = '.selectize-control';
    nativeSelect = false;
    optionItemHandler = null;
    styleMap = null;
    originalOptionList = null;
    data() {
      const data = super.data();
      data.translatedOptions = this.translatedOptions;
      const value = this.model.get(this.name);
      if (this.isReadMode() && this.styleMap) {
        data.style = this.styleMap[value || ''] || 'default';
      }
      data.styleMap = this.styleMap;
      if (this.isReadMode()) {
        if (!this.params.displayAsLabel) {
          data.class = 'text';
        } else {
          if (this.params.labelType === 'state') {
            data.class = 'label label-md label-state label';
          } else {
            data.class = data.style && data.style !== 'default' ? 'label label-md label' : 'text';
          }
        }
      }
      const translationKey = value ?? '';
      if (typeof value !== 'undefined' && value !== null && value !== '' || translationKey === '' && translationKey in (this.translatedOptions || {}) && (this.translatedOptions || {})[translationKey] !== '') {
        data.isNotEmpty = true;
      }
      data.valueIsSet = this.model.has(this.name);
      if (data.isNotEmpty) {
        data.valueTranslated = this.translatedOptions ? this.translatedOptions[translationKey] || value : this.getLanguage().translateOption(translationKey, this.name, this.entityType);
      }
      if (this.isEditMode()) {
        data.nativeSelect = this.nativeSelect;
      }
      if (this.isReadMode() && this.optionItemHandler && this.model.attributes[this.name]) {
        const item = this.optionItemHandler({
          value: this.model.attributes[this.name]
        });
        if (item.color != null) {
          data.color = item.color;
          data.hasColor = true;
        }
      }
      return data;
    }
    setup() {
      if (!this.params.options) {
        // @todo Revise.
        const methodName = 'get' + _utils.default.upperCaseFirst(this.name) + 'Options';
        if (typeof this.model[methodName] === 'function') {
          this.params.options = this.model[methodName].call(this.model);
        }
      }
      if (this.options.optionItemHandler) {
        this.optionItemHandler = this.options.optionItemHandler;
      }
      this.styleMap = this.params.style ?? this.model.getFieldParam(this.name, 'style') ?? {};
      let optionsPath = this.params.optionsPath;
      const optionsReference = this.params.optionsReference ?? null;
      if (!optionsPath && optionsReference) {
        const [refEntityType, refField] = optionsReference.split('.');
        optionsPath = `entityDefs.${refEntityType}.fields.${refField}.options`;
        if (!this.styleMap || Object.keys(this.styleMap).length === 0) {
          this.styleMap = this.getMetadata().get(`entityDefs.${refEntityType}.fields.${refField}.style`) || {};
        }
      }
      if (optionsPath) {
        this.params.options = _utils.default.clone(this.getMetadata().get(optionsPath)) || [];
      }
      this.setupOptions();
      if ('translatedOptions' in this.options) {
        this.translatedOptions = this.options.translatedOptions ?? null;
      }
      if ('translatedOptions' in this.params) {
        this.translatedOptions = this.params.translatedOptions ?? null;
      }
      this.setupTranslation();
      if (this.translatedOptions === null) {
        const translations = this.getLanguage().translate(this.name, 'options', this.model.entityType) ?? {};
        if (translations === this.name) {
          this.translatedOptions = null;
        } else {
          this.translatedOptions = translations;
        }
      }
      if (this.params.isSorted && this.translatedOptions) {
        const translations = this.translatedOptions;
        this.params.options = _utils.default.clone(this.params.options) ?? [];
        this.params.options = this.params.options.sort((v1, v2) => {
          return (translations[v1] || v1).localeCompare(translations[v2] || v2);
        });
      }
      if (this.options.customOptionList) {
        this.setOptionList(this.options.customOptionList);
      }
    }
    setupTranslation() {
      let translation = this.params.translation;
      const optionsReference = this.params.optionsReference;
      if (!translation && optionsReference) {
        const [refEntityType, refField] = optionsReference.split('.');
        translation = `${refEntityType}.options.${refField}`;
      }
      if (!translation) {
        return;
      }
      this.translatedOptions = null;
      if (!this.params.options) {
        return;
      }
      const obj = this.getLanguage().translatePath(translation);
      const map = {};
      this.params.options.forEach(item => {
        if (typeof obj === 'object' && item in obj) {
          map[item] = obj[item];
          return;
        }
        if (Array.isArray(obj) && typeof item === 'number' && typeof obj[item] !== 'undefined') {
          map[item.toString()] = obj[item];
          return;
        }
        map[item] = item;
      });
      const value = this.model.get(this.name);
      if ((value || value === '') && !(value in map)) {
        if (typeof obj === 'object' && value in obj) {
          map[value] = obj[value];
        }
      }
      this.translatedOptions = map;
    }

    /**
     * Set up options.
     */
    setupOptions() {}

    /**
     * Set translated options.
     *
     * @param translatedOptions Translations.
     * @since 8.4.0
     */
    setTranslatedOptions(translatedOptions) {
      this.translatedOptions = translatedOptions;
    }

    /**
     * Set an option list.
     *
     * @param optionList An option list.
     */
    async setOptionList(optionList) {
      const previousOptions = this.params.options;
      if (!this.originalOptionList) {
        this.originalOptionList = this.params.options ?? null;
      }
      const newOptions = _utils.default.clone(optionList) || [];
      this.params.options = newOptions;
      const isChanged = !(0, _underscore.default)(previousOptions).isEqual(optionList);
      if (!this.isEditMode() || !isChanged) {
        return Promise.resolve();
      }
      let triggerChange = false;
      const currentValue = this.model.get(this.name);
      if (!newOptions.includes(currentValue) && this.isReady) {
        this.model.set(this.name, newOptions[0] ?? null, {
          silent: true
        });
        triggerChange = true;
      }
      await this.reRender();
      if (triggerChange) {
        this.trigger('change');
      }
    }

    /**
     * Reset a previously set option list.
     */
    resetOptionList() {
      if (!this.originalOptionList) {
        return Promise.resolve();
      }
      const previousOptions = this.params.options;
      this.params.options = _utils.default.clone(this.originalOptionList);
      const isChanged = !(0, _underscore.default)(previousOptions).isEqual(this.originalOptionList);
      if (!this.isEditMode() || !isChanged) {
        return Promise.resolve();
      }
      if (this.isRendered()) {
        return this.reRender();
      }
      return Promise.resolve();
    }
    setupSearch() {
      this.addHandler('change', 'select.search-type', (_e, target) => {
        this.handleSearchType(target.value);
      });
    }
    handleSearchType(type) {
      const $inputContainer = this.$el.find('div.input-container');
      if (['anyOf', 'noneOf'].includes(type)) {
        $inputContainer.removeClass('hidden');
      } else {
        $inputContainer.addClass('hidden');
      }
    }
    afterRender() {
      super.afterRender();
      if (this.isSearchMode()) {
        var _this$searchParams, _this$$element, _this$$element2;
        this.$element = this.$el.find('.main-element');
        const type = this.$el.find('select.search-type').val();
        this.handleSearchType(type);
        const valueList = this.getSearchParamsData().valueList ?? ((_this$searchParams = this.searchParams) === null || _this$searchParams === void 0 ? void 0 : _this$searchParams.value) ?? [];
        (_this$$element = this.$element) === null || _this$$element === void 0 || _this$$element.val(valueList.join(':,:'));
        const items = [];
        (this.params.options ?? []).forEach(value => {
          let label = this.getLanguage().translateOption(value, this.name, this.entityType);
          if (this.translatedOptions && value in this.translatedOptions) {
            label = this.translatedOptions[value];
          }
          if (label === '') {
            return;
          }
          items.push({
            value: value,
            text: label
          });
        });
        const multiSelectOptions = {
          items: items,
          delimiter: ':,:',
          matchAnyWord: true
        };
        _multiSelect.default.init(this.$element, multiSelectOptions);
        this.$el.find('.selectize-dropdown-content').addClass('small');
        this.$el.find('select.search-type').on('change', () => this.trigger('change'));
        (_this$$element2 = this.$element) === null || _this$$element2 === void 0 || _this$$element2.on('change', () => this.trigger('change'));
      }
      if ((this.isEditMode() || this.isSearchMode()) && !this.nativeSelect) {
        _select.default.init(this.$element, {
          matchAnyWord: true,
          itemHandler: this.optionItemHandler
        });
      }
    }
    focusOnInlineEdit() {
      _select.default.focus(this.$element);
    }
    validateRequired() {
      if (this.isRequired()) {
        if (!this.model.get(this.name)) {
          const msg = this.translate('fieldIsRequired', 'messages').replace('{field}', this.getLabelText());
          this.showValidationMessage(msg);
          return true;
        }
      }
      return false;
    }
    fetch() {
      var _this$$element3;
      let value = (_this$$element3 = this.$element) === null || _this$$element3 === void 0 ? void 0 : _this$$element3.val();
      if (this.fetchEmptyValueAsNull && !value) {
        value = null;
      }
      const data = {};
      data[this.name] = value;
      return data;
    }
    parseItemForSearch(item) {
      return item;
    }
    fetchSearch() {
      var _this$$element4;
      const type = this.fetchSearchType();
      let list = (((_this$$element4 = this.$element) === null || _this$$element4 === void 0 ? void 0 : _this$$element4.val()) ?? '').split(':,:');
      if (list.length === 1 && list[0] === '') {
        list = [];
      }
      list.forEach((item, i) => {
        list[i] = this.parseItemForSearch(item);
      });
      if (type === 'anyOf') {
        if (list.length === 0) {
          return {
            type: 'any',
            data: {
              type: 'anyOf',
              valueList: list
            }
          };
        }
        return {
          type: 'in',
          value: list,
          data: {
            type: 'anyOf',
            valueList: list
          }
        };
      }
      if (type === 'noneOf') {
        if (list.length === 0) {
          return {
            type: 'any',
            data: {
              type: 'noneOf',
              valueList: list
            }
          };
        }
        return {
          type: 'or',
          value: [
          // Don't change order.
          {
            type: 'notIn',
            value: list,
            attribute: this.name
          }, {
            type: 'isNull',
            attribute: this.name
          }],
          data: {
            type: 'noneOf',
            valueList: list
          }
        };
      }
      if (type === 'isEmpty') {
        return {
          type: 'or',
          value: [{
            type: 'isNull',
            attribute: this.name
          }, {
            type: 'equals',
            value: '',
            attribute: this.name
          }],
          data: {
            type: 'isEmpty'
          }
        };
      }
      if (type === 'isNotEmpty') {
        const value = [{
          type: 'isNotNull',
          attribute: this.name
        }];
        if (!this.model.getFieldParam(this.name, 'notStorable')) {
          value.push({
            type: 'notEquals',
            value: '',
            attribute: this.name
          });
        }
        return {
          type: 'and',
          value: value,
          data: {
            type: 'isNotEmpty'
          }
        };
      }
      return null;
    }
    getSearchType() {
      return this.getSearchParamsData().type ?? 'anyOf';
    }
  }
  var _default = _exports.default = EnumFieldView;
});

define("views/fields/colorpicker", ["exports", "views/fields/varchar"], function (_exports, _varchar) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _varchar = _interopRequireDefault(_varchar);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ColorpickerFieldView extends _varchar.default {
    type = 'varchar';
    detailTemplate = 'fields/colorpicker/detail';
    listTemplate = 'fields/colorpicker/detail';
    editTemplate = 'fields/colorpicker/edit';
    setup() {
      super.setup();
      this.params.maxLength = 7;
      this.wait(Espo.loader.requirePromise('lib!bootstrap-colorpicker'));
    }
    afterRender() {
      super.afterRender();
      if (this.isEditMode()) {
        const isModal = !!this.$el.closest('.modal').length;

        // noinspection JSUnresolvedReference
        this.$element.parent().colorpicker({
          format: 'hex',
          container: isModal ? this.$el : false,
          sliders: {
            saturation: {
              maxLeft: 200,
              maxTop: 200
            },
            hue: {
              maxTop: 200
            },
            alpha: {
              maxTop: 200
            }
          }
        });
        if (isModal) {
          this.$el.find('.colorpicker').css('position', 'relative').addClass('pull-right');
        }
        this.$element.on('change', () => {
          if (this.$element.val() === '') {
            this.$el.find('.input-group-addon > i').css('background-color', 'transparent');
          }
        });
      }
    }
  }
  var _default = _exports.default = ColorpickerFieldView;
});

define("model-factory", ["exports"], function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module model-factory */

  /**
   * A model factory.
   */
  class ModelFactory {
    constructor(metadata) {
      this.metadata = metadata;
    }

    /**
     * Create a model.
     *
     * @param entityType An entity type.
     * @param [callback] Deprecated.
     * @param [context] Deprecated.
     * @returns A created model.
     */
    create(entityType, callback, context) {
      return new Promise(resolve => {
        context = context || this;
        this.getSeed(entityType, Seed => {
          const model = new Seed({}, {
            entityType: entityType,
            defs: this.metadata.get(['entityDefs', entityType]) || {}
          });
          if (callback) {
            callback.call(context, model);
          }
          resolve(model);
        });
      });
    }

    /**
     * Get a class.
     *
     * @param {string} entityType An entity type.
     * @param callback A callback.
     * @public
     * @internal
     */
    getSeed(entityType, callback) {
      const className = this.metadata.get(['clientDefs', entityType, 'model']) ?? 'model';
      Espo.loader.require(className, modelClass => callback(modelClass));
    }
  }
  _exports.default = ModelFactory;
});

define("views/wysiwyg/modals/edit-table", ["exports", "views/modal", "views/record/edit-for-modal", "model", "views/fields/enum", "views/fields/varchar", "views/fields/colorpicker"], function (_exports, _modal, _editForModal, _model, _enum, _varchar, _colorpicker) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  _editForModal = _interopRequireDefault(_editForModal);
  _model = _interopRequireDefault(_model);
  _enum = _interopRequireDefault(_enum);
  _varchar = _interopRequireDefault(_varchar);
  _colorpicker = _interopRequireDefault(_colorpicker);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EditTableModalView extends _modal.default {
    templateContent = `
        <div class="record no-side-margin">{{{record}}}</div>
    `;
    /**
     * @param {{
     *     params: {
     *         align: null|'left'|'center'|'right',
     *         width: null|string,
     *         height: null|string,
     *         borderWidth: null|string,
     *         borderColor: null|string,
     *         cellPadding: null|string,
     *         backgroundColor: null|string,
     *    },
     *    onApply: function({
     *         align: null|'left'|'center'|'right',
     *         width: null|string,
     *         height: null|string,
     *         borderWidth: null|string,
     *         borderColor: null|string,
     *         cellPadding: null|string,
     *         backgroundColor: null|string,
     *    }),
     * }} options
     */
    constructor(options) {
      super(options);
      this.params = options.params;
      this.onApply = options.onApply;
    }
    setup() {
      this.addButton({
        name: 'apply',
        style: 'primary',
        label: 'Apply',
        onClick: () => this.apply()
      });
      this.addButton({
        name: 'cancel',
        label: 'Cancel',
        onClick: () => this.close()
      });
      this.shortcutKeys = {
        'Control+Enter': () => this.apply()
      };
      this.model = new _model.default({
        align: this.params.align,
        width: this.params.width,
        height: this.params.height,
        borderWidth: this.params.borderWidth,
        borderColor: this.params.borderColor,
        cellPadding: this.params.cellPadding,
        backgroundColor: this.params.backgroundColor
      });
      this.recordView = new _editForModal.default({
        model: this.model,
        detailLayout: [{
          rows: [[{
            view: new _varchar.default({
              name: 'width',
              labelText: this.translate('width', 'wysiwygLabels'),
              params: {
                maxLength: 12
              }
            })
          }, {
            view: new _varchar.default({
              name: 'height',
              labelText: this.translate('height', 'wysiwygLabels'),
              params: {
                maxLength: 12
              }
            })
          }], [{
            view: new _varchar.default({
              name: 'borderWidth',
              labelText: this.translate('borderWidth', 'wysiwygLabels'),
              params: {
                maxLength: 12
              }
            })
          }, {
            view: new _colorpicker.default({
              name: 'borderColor',
              labelText: this.translate('borderColor', 'wysiwygLabels')
            })
          }], [{
            view: new _varchar.default({
              name: 'cellPadding',
              labelText: this.translate('cellPadding', 'wysiwygLabels'),
              params: {
                maxLength: 12
              }
            })
          }, {
            view: new _colorpicker.default({
              name: 'backgroundColor',
              labelText: this.translate('backgroundColor', 'wysiwygLabels')
            })
          }], [{
            view: new _enum.default({
              name: 'align',
              labelText: this.translate('align', 'wysiwygLabels'),
              params: {
                options: ['', 'left', 'center', 'right'],
                translation: 'Global.wysiwygOptions.align'
              }
            })
          }, false]]
        }]
      });
      this.assignView('record', this.recordView, '.record');
    }
    apply() {
      if (this.recordView.validate()) {
        return;
      }
      let borderWidth = this.model.attributes.borderWidth;
      let cellPadding = this.model.attributes.cellPadding;
      let width = this.model.attributes.width;
      let height = this.model.attributes.height;
      if (/^\d+$/.test(borderWidth)) {
        borderWidth += 'px';
      }
      if (/^\d+$/.test(cellPadding)) {
        cellPadding += 'px';
      }
      if (/^\d+$/.test(width)) {
        width += 'px';
      }
      if (/^\d+$/.test(height)) {
        height += 'px';
      }
      this.onApply({
        align: this.model.attributes.align,
        width: width,
        height: height,
        borderWidth: borderWidth,
        borderColor: this.model.attributes.borderColor,
        cellPadding: cellPadding,
        backgroundColor: this.model.attributes.backgroundColor
      });
      this.close();
    }
  }
  var _default = _exports.default = EditTableModalView;
});

define("views/wysiwyg/modals/edit-cell", ["exports", "views/modal", "views/record/edit-for-modal", "model", "views/fields/varchar", "views/fields/colorpicker", "views/fields/enum"], function (_exports, _modal, _editForModal, _model, _varchar, _colorpicker, _enum) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  _editForModal = _interopRequireDefault(_editForModal);
  _model = _interopRequireDefault(_model);
  _varchar = _interopRequireDefault(_varchar);
  _colorpicker = _interopRequireDefault(_colorpicker);
  _enum = _interopRequireDefault(_enum);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EditCellModalView extends _modal.default {
    templateContent = `
        <div class="record no-side-margin">{{{record}}}</div>
    `;
    /**
     * @param {{
     *     params: {
     *         width: null|string,
     *         height: null|height,
     *         backgroundColor: null|string,
     *         verticalAlign: null|'top'|'middle'|'bottom',
     *    },
     *    onApply: function({
     *         width: null|string,
     *         height: null|height,
     *         backgroundColor: null|string,
     *         verticalAlign: null|'top'|'middle'|'bottom',
     *    }),
     * }} options
     */
    constructor(options) {
      super(options);
      this.params = options.params;
      this.onApply = options.onApply;
    }
    setup() {
      this.addButton({
        name: 'apply',
        style: 'primary',
        label: 'Apply',
        onClick: () => this.apply()
      });
      this.addButton({
        name: 'cancel',
        label: 'Cancel',
        onClick: () => this.close()
      });
      this.shortcutKeys = {
        'Control+Enter': () => this.apply()
      };
      this.model = new _model.default({
        width: this.params.width,
        height: this.params.height,
        backgroundColor: this.params.backgroundColor,
        verticalAlign: this.params.verticalAlign
      });
      this.recordView = new _editForModal.default({
        model: this.model,
        detailLayout: [{
          rows: [[{
            view: new _varchar.default({
              name: 'width',
              labelText: this.translate('width', 'wysiwygLabels'),
              params: {
                maxLength: 12
              }
            })
          }, {
            view: new _varchar.default({
              name: 'height',
              labelText: this.translate('height', 'wysiwygLabels'),
              params: {
                maxLength: 12
              }
            })
          }], [{
            view: new _enum.default({
              name: 'verticalAlign',
              labelText: this.translate('verticalAlign', 'wysiwygLabels'),
              params: {
                options: ['', 'top', 'middle', 'bottom'],
                translation: 'Global.wysiwygOptions.verticalAlign'
              }
            })
          }, {
            view: new _colorpicker.default({
              name: 'backgroundColor',
              labelText: this.translate('backgroundColor', 'wysiwygLabels')
            })
          }]]
        }]
      });
      this.assignView('record', this.recordView, '.record');
    }
    apply() {
      if (this.recordView.validate()) {
        return;
      }
      let width = this.model.attributes.width;
      if (/^\d+$/.test(width)) {
        width += 'px';
      }
      let height = this.model.attributes.height;
      if (/^\d+$/.test(height)) {
        height += 'px';
      }
      this.onApply({
        width: width,
        height: height,
        backgroundColor: this.model.attributes.backgroundColor,
        verticalAlign: this.model.attributes.verticalAlign
      });
      this.close();
    }
  }
  var _default = _exports.default = EditCellModalView;
});

define("views/record/list/settings", ["exports", "view"], function (_exports, _view) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * @typedef {Object} RecordListSettingsViewOnChangeOptions
   * @property {'resetToDefault'|'toggleColumn'|'toggleColumnResize'} action An action.
   * @property {string} [column] A column.
   */

  class RecordListSettingsView extends _view.default {
    // language=Handlebars
    templateContent = `
        {{#if toDisplay}}
        <div class="btn-group">
            <a
                role="button"
                class="btn btn-text dropdown-toggle"
                data-toggle="dropdown"
                tabindex="0"
            ><span class="caret"></span></a>
            <ul class="dropdown-menu pull-right">
                {{#if dataList.length}}
                <li class="dropdown-header">{{fieldsLabel}}</li>
                    {{#each dataList}}
                        <li>
                            <a
                                role="button"
                                tabindex="0"
                                data-action="toggleColumn"
                                data-name="{{name}}"
                            >
                                {{~null~}}
                                <span class="check-icon fas fa-check pull-right {{#if hidden}} hidden {{/if}}"></span>
                                {{~null~}}
                                <div><span class="item-text">{{label}}</span></div>
                                {{~null~}}
                            </a>
                        </li>
                    {{/each}}
                {{/if}}
            {{#if hasColumnResize}}
                <li class="divider"></li>
                <li>
                    <a
                        role="button"
                        tabindex="0"
                        data-action="toggleColumnResize"
                    >
                        {{~null~}}
                        <span class="check-icon fas fa-check pull-right {{#unless columnResize}} hidden {{/unless}}"></span>
                        {{~null~}}
                        <div>
                            {{~null~}}
                            <span class="item-icon fas fa-arrows-left-right-to-line"></span>
                            {{~null~}}
                            <span class="item-text">{{translate 'Column Resize'}}</span>
                            {{~null~}}
                        </div>
                    </a>
                </li>
            {{/if}}
            {{#if isNotDefault}}
                <li class="divider"></li>
                <li>
                    <a
                        role="button"
                        tabindex="0"
                        data-action="resetToDefault"
                    >
                        {{~null~}}
                        <span class="item-icon fas fa-times"></span>
                        {{~null~}}
                        <span class="item-text">{{translate 'Reset'}}</span>
                        {{~null~}}
                    </a>
                </li>
            {{/if}}
            </ul>
        </div>
        {{/if}}
    `;
    data() {
      const columnResize = this.helper.getColumnResize();
      const dataList = this.getDataList();
      const hasColumnResize = this.columnResize && (columnResize || this.isColumnResizeApplicable());
      const isNotDefault = dataList.find(item => item.hiddenDefault !== item.hidden) !== undefined || Object.keys(this.helper.getColumnWidthMap()).length > 0;
      return {
        dataList: dataList,
        toDisplay: dataList.length > 0 || columnResize,
        isNotDefault: isNotDefault,
        fieldsLabel: this.translate('Fields'),
        hasColumnResize: hasColumnResize,
        columnResize: columnResize
      };
    }

    /**
     * @param {{
     *     layoutProvider: function(): ({
     *         name: string,
     *         width?: number,
     *         widthPx?: number,
     *         label?: string,
     *         customLabel?: string,
     *         noLabel?: boolean,
     *         hidden?: boolean,
     *     }[]) | null,
     *     helper: import('helpers/list/settings').default,
     *     entityType: string,
     *     onChange: function(RecordListSettingsViewOnChangeOptions),
     *     columnResize?: boolean,
     * }} options
     */
    constructor(options) {
      super();
      this.layoutProvider = options.layoutProvider;
      this.helper = options.helper;
      this.entityType = options.entityType;
      this.onChange = options.onChange;
      this.columnResize = options.columnResize || false;
    }
    setup() {
      this.addActionHandler('toggleColumn', (e, target) => this.toggleColumn(target.dataset.name));
      this.addActionHandler('toggleColumnResize', () => this.toggleColumnResize());
      this.addActionHandler('resetToDefault', () => this.resetToDefault());

      /** @private */
      this.onColumnWidthChangeBind = this.onColumnWidthChange.bind(this);
      this.helper.subscribeToColumnWidthChange(this.onColumnWidthChangeBind);
      if (window.innerWidth < this.getThemeManager().getParam('screenWidthXs')) {
        this.columnResize = false;
      }
    }
    onRemove() {
      this.helper.unsubscribeFromColumnWidthChange(this.onColumnWidthChangeBind);
    }

    /**
     * @private
     */
    onColumnWidthChange() {
      this.reRender();
    }

    /**
     * @private
     * @return {{
     *     hidden: boolean,
     *     hiddenDefault: boolean,
     *     name: string,
     *     label: string,
     * }[]}
     */
    getDataList() {
      const list = this.layoutProvider() || [];
      const map = this.helper.getHiddenColumnMap() || {};
      return list.filter(item => item.name && !item.link && !item.noLabel && item.customLabel !== '').map(item => {
        const label = item.label || item.name;
        const hidden = item.name in map ? map[item.name] : !!item.hidden;
        return {
          name: item.name,
          label: item.customLabel ?? this.translate(label, 'fields', this.entityType),
          hidden: hidden,
          hiddenDefault: !!item.hidden
        };
      });
    }

    /**
     * @private
     * @return {boolean}
     */
    isColumnResizeApplicable() {
      const list = this.layoutProvider().filter(it => {
        return !this.helper.isColumnHidden(it.name, it.hidden);
      });
      if (!list || list.length <= 1) {
        return false;
      }
      if (!list.find(it => !it.widthPx && !it.width)) {
        return false;
      }
      return !!list.find(it => it.widthPx || it.width);
    }

    /**
     * @private
     * @param {string} name
     */
    toggleColumn(name) {
      const map = /** @type {Object.<string, boolean>} */this.helper.getHiddenColumnMap() || {};
      const item = this.getDataList().find(item => item.name === name);
      const defaultValue = item ? item.hiddenDefault : false;
      map[name] = !(name in map ? map[name] : defaultValue);
      this.helper.storeHiddenColumnMap(map);
      this.onChange({
        action: 'toggleColumn',
        column: name
      });
    }

    /**
     * @private
     */
    toggleColumnResize() {
      const value = !this.helper.getColumnResize();
      this.helper.storeColumnResize(value);
      this.onChange({
        action: 'toggleColumnResize'
      });
    }

    /**
     * @private
     */
    resetToDefault() {
      this.helper.clearHiddenColumnMap();
      this.helper.clearColumnWidthMap();
      this.onChange({
        action: 'resetToDefault'
      });
    }
  }
  var _default = _exports.default = RecordListSettingsView;
});

define("views/modals/text-preview", ["exports", "views/modal"], function (_exports, _modal) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class TextPreviewModalView extends _modal.default {
    // language=Handlebars
    templateContent = `
        <div class="panel panel-default no-side-margin">
            <div class="panel-body">
                <div class="complex-text">{{complexText viewObject.options.text linksInNewTab=true}}</div>
            </div>
        </div>
    `;
    backdrop = true;

    /**
     * @param {{text: string}} options
     */
    constructor(options) {
      super(options);
      this.options = options;
    }
    setup() {
      this.headerText = this.translate('Preview');
    }
  }
  _exports.default = TextPreviewModalView;
});

define("helpers/mass-action", ["exports", "di", "models/settings", "models/user"], function (_exports, _di, _settings, _user) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _settings = _interopRequireDefault(_settings);
  _user = _interopRequireDefault(_user);
  var _staticBlock;
  let _init_config, _init_extra_config, _init_user, _init_extra_user;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  /**
   * A mass-action helper.
   */
  class MassActionHelper {
    /**
     * @private
     * @type {Settings}
     */
    config = _init_config(this);

    /**
     * @private
     * @type {User}
     */
    user = (_init_extra_config(this), _init_user(this));

    /**
     * @param {module:view} view A view.
     */
    constructor(view) {
      _init_extra_user(this);
      /**
       * @private
       * @type {module:view}
       */
      this.view = view;
    }

    /**
     * Check whether an action should be run in idle.
     *
     * @param {number} [totalCount] A total record count.
     * @returns {boolean}
     */
    checkIsIdle(totalCount) {
      if (this.user.isPortal()) {
        return false;
      }
      if (typeof totalCount === 'undefined') {
        totalCount = this.view.options.totalCount;
      }
      if (typeof totalCount === 'undefined' && this.view.collection) {
        totalCount = this.view.collection.total;
      }
      return totalCount === -1 || totalCount > this.config.get('massActionIdleCountThreshold');
    }

    /**
     * Process.
     *
     * @param {string} id An ID.
     * @param {string} action An action.
     * @returns {Promise<module:view>} Resolves with a dialog view.
     *   The view emits the 'close:success' event.
     */
    process(id, action) {
      Espo.Ui.notify(false);
      return new Promise(resolve => {
        const entityType = this.view.scope || this.view.entityType;
        this.view.createView('dialog', 'views/modals/mass-action', {
          id: id,
          action: action,
          scope: entityType
        }).then(view => {
          view.render();
          resolve(view);
          this.view.listenToOnce(view, 'success', data => {
            resolve(data);
            this.view.listenToOnce(view, 'close', () => {
              view.trigger('close:success', data);
            });
          });
        });
      });
    }
    static #_ = _staticBlock = () => [_init_config, _init_extra_config, _init_user, _init_extra_user] = _applyDecs(this, [], [[(0, _di.inject)(_settings.default), 0, "config"], [(0, _di.inject)(_user.default), 0, "user"]]).e;
  }
  _staticBlock();
  var _default = _exports.default = MassActionHelper;
});

define("helpers/export", ["exports", "di", "models/settings", "models/user"], function (_exports, _di, _settings, _user) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _settings = _interopRequireDefault(_settings);
  _user = _interopRequireDefault(_user);
  var _staticBlock;
  let _init_config, _init_extra_config, _init_user, _init_extra_user;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  /**
   * An export helper.
   */
  class ExportHelper {
    /**
     * @private
     * @type {Settings}
     */
    config = _init_config(this);

    /**
     * @private
     * @type {User}
     */
    user = (_init_extra_config(this), _init_user(this));

    /**
     * @param {module:view} view A view.
     */
    constructor(view) {
      _init_extra_user(this);
      /**
       * @private
       * @type {module:view}
       */
      this.view = view;
    }

    /**
     * Check whether an export should be run in idle.
     *
     * @param {number} totalCount A total record count.
     * @returns {boolean}
     */
    checkIsIdle(totalCount) {
      if (this.user.isPortal()) {
        return false;
      }
      if (typeof totalCount === 'undefined') {
        totalCount = this.view.options.totalCount;
      }
      return totalCount === -1 || totalCount > this.config.get('exportIdleCountThreshold');
    }

    /**
     * Process export.
     *
     * @param {string} id An ID.
     * @returns {Promise<module:view>} Resolves with a dialog view.
     *   The view emits the 'close:success' event.
     */
    process(id) {
      Espo.Ui.notify(false);
      return new Promise(resolve => {
        this.view.createView('dialog', 'views/export/modals/idle', {
          id: id
        }).then(view => {
          view.render();
          resolve(view);
          this.view.listenToOnce(view, 'success', data => {
            resolve(data);
            this.view.listenToOnce(view, 'close', () => {
              view.trigger('close:success', data);
            });
          });
        });
      });
    }
    static #_ = _staticBlock = () => [_init_config, _init_extra_config, _init_user, _init_extra_user] = _applyDecs(this, [], [[(0, _di.inject)(_settings.default), 0, "config"], [(0, _di.inject)(_user.default), 0, "user"]]).e;
  }
  _staticBlock();
  var _default = _exports.default = ExportHelper;
});

define("helpers/record/list/column-width-control", ["exports"], function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ListColumnWidthControlHelper {
    /**
     * A min width in pixels.
     *
     * @private
     * @type {number}
     */
    minWidth = 30;

    /**
     * @param {{
     *     view?: import('views/record/list-base').default,
     *     helper: import('helpers/list/settings').default,
     *     layoutProvider?: function(): {
     *          name: string,
     *          width?: number,
     *          widthPx?: number,
     *          hidden?: boolean,
     *     }[]
     * }} options
     */
    constructor(options) {
      /** @private */
      this.view = options.view;
      /** @private */
      this.helper = options.helper;
      /** @private */
      this.layoutProvider = options.layoutProvider;
    }

    /**
     * Adjust widths.
     *
     * @param {{
     *     tableWidth?: number,
     *     staticWidth?: number,
     * }} [options]
     * @return {boolean}
     */
    adjust() {
      let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      let tableWidthData;
      if (options.tableWidth === undefined || options.staticWidth === undefined) {
        tableWidthData = this.getTableWidths();
      }
      const tableWidth = options.tableWidth === undefined ? tableWidthData.table : options.tableWidth;
      const staticWidth = options.staticWidth === undefined ? tableWidthData.static : options.staticWidth;
      const widthMap = this.helper.getColumnWidthMap();

      /**
       * @type {{
       *     name: string,
       *     width: {
       *         value: number,
       *         unit: 'px'|'%',
       *     }|null,
       *     isCustom: boolean,
       *     widthPx: number|null,
       * }[]}
       */
      const list = this.layoutProvider().filter(it => !this.helper.isColumnHidden(it.name, it.hidden)).map(it => {
        let widthItem = widthMap[it.name];
        const isCustom = !!widthItem;
        if (!widthItem) {
          widthItem = null;
          if (it.width) {
            widthItem = {
              value: it.width,
              unit: '%'
            };
          } else if (it.widthPx) {
            widthItem = {
              value: it.widthPx,
              unit: 'px'
            };
          }
        }
        let widthPx = null;
        if (widthItem) {
          if (widthItem.unit === 'px') {
            widthPx = widthItem.value;
          } else {
            widthPx = tableWidth * (widthItem.value / 100.0);
          }
        }
        return {
          name: it.name,
          width: widthItem,
          isCustom: isCustom,
          widthPx: widthPx
        };
      });
      const flexColumnCount = list.filter(it => !it.width).length;
      const extraWidth = flexColumnCount * this.minWidth;
      let sumWidth = 0;
      list.filter(it => it.widthPx).forEach(it => sumWidth += it.widthPx);
      if (tableWidth - extraWidth - staticWidth - sumWidth >= 0) {
        return true;
      }
      const listSorted = list.filter(it => it.widthPx && it.width).sort((a, b) => b.widthPx - a.widthPx);
      if (!listSorted.length) {
        return true;
      }
      const item = listSorted[0];
      const reduceWidthPx = 10;
      if (item.widthPx < reduceWidthPx) {
        return true;
      }

      /** @type {{value: number, unit: 'px'|'%'}} */
      let newWidth;
      if (item.width.unit === 'px') {
        newWidth = {
          value: item.width.value - reduceWidthPx,
          unit: 'px'
        };
      } else {
        const factor = Math.pow(10, 4);
        const reducePercent = Math.floor(factor * (reduceWidthPx / tableWidth) * 100) / factor;
        newWidth = {
          value: item.width.value - reducePercent,
          unit: '%'
        };
      }
      const map = this.helper.getColumnWidthMap();
      map[item.name] = newWidth;
      this.helper.storeColumnWidthMap(map);
      this.adjust({
        tableWidth,
        staticWidth
      });
      return false;
    }

    /**
     * @private
     * @return {{
     *     table: number,
     *     static: number,
     * }|null}
     */
    getTableWidths() {
      const tableElement = this.view.element.querySelector('.list > table');
      if (!tableElement) {
        return null;
      }
      const tableWidth = tableElement.clientWidth;
      let staticWidth = 0;
      tableElement.querySelectorAll(':scope > thead > tr > th').forEach(th => {
        if (!th.classList.contains('field-header-cell') || th.classList.contains('action-cell')) {
          staticWidth += th.clientWidth;
        }
      });
      return {
        table: tableWidth,
        static: staticWidth
      };
    }
  }
  _exports.default = ListColumnWidthControlHelper;
});

define("helpers/record/list/column-resize", ["exports"], function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * @internal
   */
  class ListColumnResizeHelper {
    /**
     * @type {{
     *     startX: number,
     *     startWidth: number,
     *     thElement: HTMLTableCellElement,
     *     name: string,
     *     inPx: boolean,
     *     onRight: boolean,
     *     newWidth: number|null,
     *     thElements: HTMLTableCellElement[],
     * }}
     * @private
     */
    item;

    /**
     * A min width in pixels.
     *
     * @private
     * @type {number}
     */
    minWidth = 30;
    static selector = 'table > thead > tr > th > .column-resizer';

    /**
     * @param {import('views/record/list-base').default} view
     * @param {import('helpers/list/settings').default} helper
     */
    constructor(view, helper) {
      /** @private */
      this.view = view;
      /** @private */
      this.helper = helper;

      /**
       * @private
       * @type {number}
       */
      this.fontSizeFactor = view.getThemeManager().getFontSizeFactor();
      this.onPointerUpBind = this.onPointerUp.bind(this);
      this.onPointerMoveBind = this.onPointerMove.bind(this);
      view.addHandler('pointerdown', ListColumnResizeHelper.selector, (/** PointerEvent */e, target) => {
        this.onPointerDown(e, target);
      });
    }

    /**
     * @private
     * @param {PointerEvent} event
     * @param {HTMLElement} target
     */
    onPointerDown(event, target) {
      if (!event.isPrimary) {
        return;
      }
      this.startResizeInit(event, target);
      window.addEventListener('pointerup', this.onPointerUpBind);
      window.addEventListener('pointermove', this.onPointerMoveBind);
    }

    /**
     * @private
     * @param {PointerEvent} event
     * @param {HTMLElement} target
     */
    startResizeInit(event, target) {
      const th = /** @type {HTMLTableCellElement} */target.parentNode;
      const thElements = [...th.parentNode.querySelectorAll(':scope > th.field-header-cell')].filter(it => !it.style.width);
      this.item = {
        startX: event.clientX,
        startWidth: th.clientWidth,
        thElement: th,
        name: th.dataset.name,
        inPx: th.style.width && th.style.width.endsWith('px'),
        onRight: target.classList.contains('column-resizer-right'),
        newWidth: null,
        thElements: thElements
      };
      document.body.style.cursor = 'col-resize';
      const trElement = this.item.thElement.closest('tr');
      trElement.classList.add('being-column-resized');
      this.item.thElement.classList.add('being-resized');
    }

    /**
     * @private
     * @param {number} width
     */
    isWidthOk(width) {
      if (width < this.minWidth * this.fontSizeFactor) {
        return false;
      }
      for (const th of this.item.thElements) {
        if (th.style.width) {
          continue;
        }
        if (th.clientWidth < this.minWidth * this.fontSizeFactor) {
          return false;
        }
      }
      return true;
    }

    /**
     * @private
     * @param {PointerEvent} event
     */
    onPointerMove(event) {
      let diff = event.clientX - this.item.startX;
      if (!this.item.onRight) {
        diff *= -1;
      }
      const width = this.item.startWidth + diff;
      if (!this.isWidthOk(width)) {
        return;
      }
      const previousWidth = this.item.newWidth;
      const previousStyleWidth = this.item.thElement.style.width;
      this.item.newWidth = width;
      this.item.thElement.style.width = width.toString() + 'px';
      if (!this.isWidthOk(width)) {
        if (previousWidth) {
          this.item.newWidth = previousWidth;
        }
        this.item.thElement.style.width = previousStyleWidth;
      }
    }

    /**
     * @private
     */
    onPointerUp() {
      window.removeEventListener('pointermove', this.onPointerMoveBind);
      window.removeEventListener('pointerup', this.onPointerUpBind);
      document.body.style.cursor = '';
      const width = this.item.newWidth;
      if (width === null) {
        this.disableResizingState();
        return;
      }
      let unit = 'px';
      let value = width;
      if (!this.item.inPx) {
        const tableElement = this.item.thElement.closest('table');
        const tableWidth = tableElement.clientWidth;
        const factor = Math.pow(10, 4);
        const widthPercents = width / tableWidth;
        const widthPercentsRounded = Math.floor(factor * widthPercents * 100) / factor;
        this.item.thElement.style.width = widthPercentsRounded.toString() + '%';
        unit = '%';
        value = widthPercentsRounded;
      }
      if (this.item.inPx) {
        value = value / this.fontSizeFactor;
      }
      this.helper.storeColumnWidth(this.item.name, {
        value: value,
        unit: unit
      });
      this.disableResizingState();
    }

    /**
     * @private
     */
    disableResizingState() {
      const trElement = this.item.thElement.closest('tr');
      trElement.classList.remove('being-column-resized');
      this.item.thElement.classList.remove('being-resized');
      this.item = undefined;
    }
  }
  _exports.default = ListColumnResizeHelper;
});

define("helpers/misc/mailto", ["exports", "di", "models/settings", "models/preferences", "acl-manager"], function (_exports, _di, _settings, _preferences, _aclManager) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _settings = _interopRequireDefault(_settings);
  _preferences = _interopRequireDefault(_preferences);
  _aclManager = _interopRequireDefault(_aclManager);
  var _staticBlock;
  let _init_config, _init_extra_config, _init_preferences, _init_extra_preferences, _init_acl, _init_extra_acl;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  class MailtoHelper {
    constructor() {
      _init_extra_acl(this);
    }
    /**
     * @type {Settings}
     */
    config = _init_config(this);

    /**
     * @type {Preferences}
     */
    preferences = (_init_extra_config(this), _init_preferences(this));

    /**
     * @type {AclManager}
     */
    acl = (_init_extra_preferences(this), _init_acl(this));

    /**
     * Whether mailto should be used.
     *
     * @return {boolean}
     */
    toUse() {
      return this.config.get('emailForceUseExternalClient') || this.preferences.get('emailUseExternalClient') || !this.acl.checkScope('Email', 'create');
    }

    /**
     * Compose a mailto link.
     *
     * @param {Record} attributes
     * @return {string}
     */
    composeLink(attributes) {
      let link = 'mailto:';
      link += (attributes.to || '').split(';').join(',');
      const params = {};
      if (attributes.cc) {
        params.cc = attributes.cc.split(';').join(',');
      }
      let bcc = this.config.get('outboundEmailBccAddress');
      if (attributes.bcc) {
        if (!bcc) {
          bcc = '';
        } else {
          bcc += ';';
        }
        bcc += attributes.bcc;
      }
      if (bcc) {
        params.bcc = bcc.split(';').join(',');
      }
      if (attributes.name) {
        params.subject = attributes.name;
      }
      if (attributes.body) {
        params.body = /** @type {string} */attributes.body;
        if (attributes.isHtml) {
          params.body = this.htmlToPlain(params.body);
        }
        if (params.body.length > 700) {
          params.body = params.body.substring(0, 700) + '...';
        }
      }
      if (attributes.inReplyTo) {
        params['In-Reply-To'] = attributes.inReplyTo;
      }
      let part = '';
      for (const key in params) {
        if (part !== '') {
          part += '&';
        } else {
          part += '?';
        }
        part += key + '=' + encodeURIComponent(params[key]);
      }
      link += part;
      return link;
    }

    /**
     * @private
     * @param {string} text
     * @returns {string}
     */
    htmlToPlain(text) {
      text = text || '';
      let value = text.replace(/<br\s*\/?>/mg, '\n');
      value = value.replace(/<\/p\s*\/?>/mg, '\n\n');
      const $div = $('<div>').html(value);
      $div.find('style').remove();
      $div.find('link[ref="stylesheet"]').remove();
      value = $div.text();
      return value;
    }
    static #_ = _staticBlock = () => [_init_config, _init_extra_config, _init_preferences, _init_extra_preferences, _init_acl, _init_extra_acl] = _applyDecs(this, [], [[(0, _di.inject)(_settings.default), 0, "config"], [(0, _di.inject)(_preferences.default), 0, "preferences"], [(0, _di.inject)(_aclManager.default), 0, "acl"]]).e;
  }
  _staticBlock();
  var _default = _exports.default = MailtoHelper;
});

define("helpers/list/settings", ["exports", "di", "storage", "utils"], function (_exports, _di, _storage, _utils) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _storage = _interopRequireDefault(_storage);
  _utils = _interopRequireDefault(_utils);
  var _staticBlock;
  let _init_storage, _init_extra_storage;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  /**
   * @typedef {Object} ColumnWidth
   * @property {number} value A value.
   * @property {'px'|'%'} unit A unit.
   */

  class ListSettingsHelper {
    /**
     * @private
     * @type {Storage}
     */
    storage = _init_storage(this);

    /**
     * @private
     * @type {boolean}
     */
    useStorage = void _init_extra_storage(this);

    /**
     * Note: Do not change the signature for the first 3 parameters.
     * @internal
     *
     * @param {string} entityType
     * @param {string} key A key used for storage.
     * @param {string} userId
     * @param {{useStorage?: boolean}} options
     */
    constructor(entityType, key, userId) {
      let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
      /** @private */
      this.layoutColumnsKey = `${key}-${entityType}-${userId}`;

      /**
       * @private
       * @type {Object.<string, boolean>}
       */
      this.hiddenColumnMapCache = undefined;

      /**
       * @private
       * @type {Object.<string, ColumnWidth>}
       */
      this.columnWidthMapCache = undefined;

      /**
       * @private
       * @type {boolean|undefined}
       */
      this.columnResize = undefined;

      /**
       * @private
       * @type {function()[]}
       */
      this.columnWidthChangeFunctions = [];
      this.useStorage = options.useStorage ?? true;
    }

    /**
     * @private
     * @param {string} key
     * @return {*}
     */
    getStored(key) {
      if (this.useStorage) {
        return this.storage.get(key, this.layoutColumnsKey);
      }
      return null;
    }

    /**
     * @private
     * @param {string} key
     * @param {*} value
     */
    store(key, value) {
      if (this.useStorage) {
        this.storage.set(key, this.layoutColumnsKey, value);
      }
    }

    /**
     * @private
     * @param {string} key
     */
    clearStored(key) {
      if (this.useStorage) {
        this.storage.clear(key, this.layoutColumnsKey);
      }
    }

    /**
     * Get a stored hidden column map.
     *
     * @return {Object.<string, boolean>}
     */
    getHiddenColumnMap() {
      if (this.hiddenColumnMapCache) {
        return this.hiddenColumnMapCache;
      }
      this.hiddenColumnMapCache = /** @type {Object} */
      this.getStored('listHiddenColumns') ?? {};
      return this.hiddenColumnMapCache;
    }

    /**
     * Is a column hidden.
     *
     * @param {string} name A name.
     * @param {boolean} [hidden] Is hidden by default.
     * @return {boolean}
     * @since 9.0.0
     */
    isColumnHidden(name, hidden) {
      const hiddenMap = this.getHiddenColumnMap();
      if (hiddenMap[name]) {
        return true;
      }
      if (!hidden) {
        return false;
      }
      if (!(name in hiddenMap)) {
        return true;
      }
      return hiddenMap[name];
    }

    /**
     * Is column resize enabled.
     *
     * @return {boolean}
     * @since 9.0.0
     */
    getColumnResize() {
      if (this.columnResize === undefined) {
        this.columnResize = this.getStored('listColumnResize') ?? false;
      }
      return this.columnResize;
    }

    /**
     * Store column width editable.
     *
     * @param {boolean} columnResize
     */
    storeColumnResize(columnResize) {
      this.columnResize = columnResize;
      this.store('listColumnResize', columnResize);
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * Clear column width editable.
     */
    clearColumnResize() {
      this.columnResize = undefined;
      this.clearStored('listColumnResize');
    }

    /**
     * Store a hidden column map.
     *
     * @param {Object.<string, boolean>} map
     */
    storeHiddenColumnMap(map) {
      this.hiddenColumnMapCache = _utils.default.cloneDeep(map);
      this.store('listHiddenColumns', map);
    }

    /**
     * Clear a hidden column map in the storage.
     */
    clearHiddenColumnMap() {
      this.hiddenColumnMapCache = undefined;
      this.clearStored('listHiddenColumns');
    }

    /**
     * Get a stored column width map.
     *
     * @return {Object.<string, ColumnWidth>}
     */
    getColumnWidthMap() {
      if (this.columnWidthMapCache) {
        return this.columnWidthMapCache;
      }
      this.columnWidthMapCache = /** @type {Object} */
      this.getStored('listColumnsWidths') ?? {};
      return this.columnWidthMapCache;
    }

    /**
     * Store a column width map.
     *
     * @param {Object.<string, ColumnWidth>} map
     */
    storeColumnWidthMap(map) {
      this.columnWidthMapCache = _utils.default.cloneDeep(map);
      this.store('listColumnsWidths', map);
    }

    /**
     * Clear a column width map in the storage.
     */
    clearColumnWidthMap() {
      this.columnWidthMapCache = undefined;
      this.clearStored('listColumnsWidths');
    }

    /**
     * Set a column width.
     *
     * @param {string} name A column name.
     * @param {ColumnWidth} width Width data.
     */
    storeColumnWidth(name, width) {
      if (!this.columnWidthMapCache) {
        this.columnWidthMapCache = {};
      }
      this.columnWidthMapCache[name] = width;
      this.storeColumnWidthMap(this.columnWidthMapCache);
      for (const handler of this.columnWidthChangeFunctions) {
        handler();
      }
    }

    /**
     * Subscribe to a column width change.
     *
     * @param {function()} handler A handler.
     */
    subscribeToColumnWidthChange(handler) {
      this.columnWidthChangeFunctions.push(handler);
    }

    /**
     * Unsubscribe from a column width change.
     *
     * @param {function()} handler A handler.
     */
    unsubscribeFromColumnWidthChange(handler) {
      const index = this.columnWidthChangeFunctions.findIndex(it => handler === it);
      if (!~index) {
        return;
      }
      this.columnWidthChangeFunctions.splice(index, 1);
    }
    static #_ = _staticBlock = () => [_init_storage, _init_extra_storage] = _applyDecs(this, [], [[(0, _di.inject)(_storage.default), 0, "storage"]]).e;
  }
  _staticBlock();
  var _default = _exports.default = ListSettingsHelper;
});

define("helpers/list/select-provider", ["exports", "di", "layout-manager", "metadata", "field-manager"], function (_exports, _di, _layoutManager, _metadata, _fieldManager) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _layoutManager = _interopRequireDefault(_layoutManager);
  _metadata = _interopRequireDefault(_metadata);
  _fieldManager = _interopRequireDefault(_fieldManager);
  var _staticBlock;
  let _init_layoutManager, _init_extra_layoutManager, _init_metadata, _init_extra_metadata, _init_fieldManager, _init_extra_fieldManager;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  class SelectProvider {
    constructor() {
      _init_extra_fieldManager(this);
    }
    /**
     * @type {LayoutManager}
     * @private
     */
    layoutManager = _init_layoutManager(this);

    /**
     * @type {Metadata}
     * @private
     */
    metadata = (_init_extra_layoutManager(this), _init_metadata(this));

    /**
     * @type {FieldManager}
     * @private
     */
    fieldManager = (_init_extra_metadata(this), _init_fieldManager(this));

    /**
     * Get select attributes.
     *
     * @param {string} entityType
     * @param {string} [layoutName='list']
     * @return {Promise<string[]>}
     */
    get(entityType, layoutName) {
      return new Promise(resolve => {
        this.layoutManager.get(entityType, layoutName || 'list', layout => {
          const list = this.getFromLayout(entityType, layout);
          resolve(list);
        });
      });
    }

    /**
     * Get select attributes from a layout.
     *
     * @param {string} entityType
     * @param {module:views/record/list~columnDefs[]} listLayout
     * @param {import('helpers/list/settings').default} [settings]
     * @return {string[]}
     */
    getFromLayout(entityType, listLayout, settings) {
      const list = [];
      listLayout.forEach(item => {
        if (!item.name) {
          return;
        }
        if (settings !== null && settings !== void 0 && settings.isColumnHidden(item.name, item.hidden)) {
          return;
        }
        if (!settings && item.hidden) {
          return;
        }
        const field = item.name;
        const type = this.metadata.get(`entityDefs.${entityType}.fields.${field}.type`);
        if (!type) {
          return;
        }
        list.push(...this.fieldManager.getEntityTypeFieldAttributeList(entityType, field));
      });
      return list;
    }
    static #_ = _staticBlock = () => [_init_layoutManager, _init_extra_layoutManager, _init_metadata, _init_extra_metadata, _init_fieldManager, _init_extra_fieldManager] = _applyDecs(this, [], [[(0, _di.inject)(_layoutManager.default), 0, "layoutManager"], [(0, _di.inject)(_metadata.default), 0, "metadata"], [(0, _di.inject)(_fieldManager.default), 0, "fieldManager"]]).e;
  }
  _staticBlock();
  var _default = _exports.default = SelectProvider;
});

define("helpers/list/misc/sticky-bar", ["exports", "jquery", "bullbone"], function (_exports, _jquery, _bullbone) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _jquery = _interopRequireDefault(_jquery);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * @internal
   */
  class StickyBarHelper {
    /** @private */
    $bar;
    /** @private */
    $scrollable;
    /** @private */
    $window;
    /** @private */
    $navbarRight;
    /** @private */
    $middle;
    /** @private */
    _isReady = false;

    /**
     * @param {import('views/record/list-base').default} view
     * @param {{force?: boolean}} options
     */
    constructor(view) {
      let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
      this.view = view;

      /**
       * @private
       * @type {import('theme-manager').default}
       */

      this.themeManager = this.view.getThemeManager();
      this.$el = view.$el;

      /** @private */
      this.force = options.force || false;
      this.init();
    }
    init() {
      this.$bar = this.$el.find('.sticked-bar');
      this.$middle = this.$el.find('> .list');
      if (!this.$middle.get(0)) {
        return;
      }
      this.$window = (0, _jquery.default)(window);
      this.$scrollable = this.$window;
      this.$navbarRight = (0, _jquery.default)('#navbar .navbar-right');
      this.isModal = !!this.$el.closest('.modal-body').length;
      this.isSmallWindow = (0, _jquery.default)(window.document).width() < this.themeManager.getParam('screenWidthXs');
      if (this.isModal) {
        this.$scrollable = this.$el.closest('.modal-body');
        this.$navbarRight = this.$scrollable.parent().find('.modal-footer');
      }
      if (!this.force) {
        this.$scrollable.off(`scroll.list-${this.view.cid}`);
        this.$scrollable.on(`scroll.list-${this.view.cid}`, () => this._controlSticking());
        this.$window.off(`resize.list-${this.view.cid}`);
        this.$window.on(`resize.list-${this.view.cid}`, () => this._controlSticking());
      }
      this.listenTo(this.view, 'check', () => {
        if (this.view.getCheckedIds().length === 0 && !this.view.isAllResultChecked()) {
          return;
        }
        this._controlSticking();
      });
      this._isReady = true;
    }
    _getMiddleTop() {
      if (this._middleTop !== undefined && this._middleTop >= 0) {
        return this._middleTop;
      }
      this._middleTop = this._getOffsetTop(this.$middle.get(0));
      return this._middleTop;
    }
    _getButtonsTop() {
      if (this._buttonsTop !== undefined && this._buttonsTop >= 0) {
        return this._buttonsTop;
      }
      this._buttonsTop = this._getOffsetTop(this.$el.find('.list-buttons-container').get(0));
      return this._buttonsTop;
    }

    /**
     * @private
     */
    _controlSticking() {
      if (!this.view.toShowStickyBar()) {
        return;
      }
      if (this.isSmallWindow && (0, _jquery.default)('#navbar .navbar-body').hasClass('in')) {
        return;
      }
      const scrollTop = this.$scrollable.scrollTop();
      const stickTop = !this.force ? this._getButtonsTop() : 0;
      const edge = this._getMiddleTop() + this.$middle.outerHeight(true);
      const hide = () => {
        this.$bar.addClass('hidden');
        this.$navbarRight.removeClass('has-sticked-bar');
      };
      const show = () => {
        this.$bar.removeClass('hidden');
        this.$navbarRight.addClass('has-sticked-bar');
      };
      if (scrollTop >= edge) {
        hide();
        return;
      }
      if (scrollTop > stickTop || this.force) {
        show();
        return;
      }
      hide();
    }

    /**
     * @private
     * @param {HTMLElement} element
     */
    _getOffsetTop(element) {
      if (!element) {
        return 0;
      }
      const navbarHeight = this.themeManager.getParam('navbarHeight') * this.themeManager.getFontSizeFactor();
      const withHeader = !this.isSmallWindow && !this.isModal;
      let offsetTop = 0;
      do {
        if (element.classList.contains('modal-body')) {
          break;
        }
        if (!isNaN(element.offsetTop)) {
          offsetTop += element.offsetTop;
        }
        element = element.offsetParent;
      } while (element);
      if (withHeader) {
        offsetTop -= navbarHeight;
      }
      if (!this.isModal) {
        // padding
        offsetTop -= 5;
      }
      return offsetTop;
    }
    hide() {
      this.$bar.addClass('hidden');
    }
    destroy() {
      this.stopListening(this.view, 'check');
      if (!this._isReady) {
        return;
      }
      this.$window.off(`resize.list-${this.view.cid}`);
      this.$scrollable.off(`scroll.list-${this.view.cid}`);
    }
  }
  Object.assign(StickyBarHelper.prototype, _bullbone.Events);
  var _default = _exports.default = StickyBarHelper;
});

define("helpers/field/cascade-links", ["exports", "di", "metadata"], function (_exports, _di, _metadata) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _metadata = _interopRequireDefault(_metadata);
  var _staticBlock;
  let _init_metadata, _init_extra_metadata;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  // noinspection JSUnusedGlobalSymbols
  class CascadeLinksHelper {
    /**
     * @type {Metadata}
     * @private}
     */
    metadata = _init_metadata(this);

    /**
     * @param {{
     *     model: import('model').default,
     *     foreignEntityType: string,
     *     items: {
     *         localField: string,
     *         foreignField: string,
     *         matchRequired: boolean,
     *     }[],
     * }} options
     */
    constructor(options) {
      _init_extra_metadata(this);
      this.options = options;
      this.model = options.model;
    }

    /**
     * @private
     * @param {
     *     {
     *         localField: string,
     *         foreignField: string,
     *         matchRequired: boolean,
     *     }
     * } item
     * @param {string|null} targetEntityType
     * @return {{id: string, entityType: string, name: string}[]|null}
     */
    prepareItemEntries(item, targetEntityType) {
      const field = item.localField;
      const foreignField = item.foreignField;
      if (!field || !foreignField) {
        console.warn("Bad cascading fields definition.");
        return null;
      }
      const type = this.model.getFieldType(field);
      let entityType = this.model.getLinkParam(field, 'entity');

      /** @type {{id: string, entityType: string, name: string}[]} */
      const entries = [];
      if (type === 'linkParent') {
        entityType = this.model.get(field + 'Type');
      }
      if (!entityType) {
        return null;
      }
      if (targetEntityType !== entityType) {
        return null;
      }
      if (type === 'link' || type === 'linkParent' || type === 'linkOne') {
        const id = this.model.get(field + 'Id');
        const name = this.model.get(field + 'Name');
        if (!id) {
          return null;
        }
        entries.push({
          id,
          entityType,
          name
        });
      } else if (type === 'linkMultiple') {
        /** @type {string[]} */
        const ids = this.model.get(field + 'Ids') ?? [];
        const names = this.model.get(field + 'Names') ?? {};
        entries.push(...ids.map(id => ({
          id,
          entityType,
          name: names[id]
        })));
      } else {
        return null;
      }
      return entries;
    }

    /**
     * @return {Object.<string, import('search-manager').AdvancedFilter>}
     */
    prepareFilters() {
      /**
       * @param {{localField: string, foreignField: string, matchRequired: boolean}} item
       * @return {Object.<string, import('search-manager').AdvancedFilter>|null}
       */
      const prepareItem = item => {
        const field = item.localField;
        const foreignField = item.foreignField;
        if (!field || !foreignField) {
          console.warn("Bad cascading fields definition.");
          return null;
        }
        const linkEntityType = this.getLinkEntityType(foreignField);
        const foreignType = this.getForeignType(foreignField);
        const entries = this.prepareItemEntries(item, linkEntityType);
        if (entries === null || !entries.length) {
          return null;
        }
        if (foreignType === 'link' || foreignType === 'linkOne') {
          if (entries.length > 1) {
            return {
              [foreignField]: {
                type: 'in',
                attribute: foreignField + 'Id',
                value: entries.map(it => it.id),
                data: {
                  type: 'isOneOf',
                  oneOfIdList: entries.map(it => it.id),
                  oneOfNameHash: entries.reduce((p, it) => {
                    p[it.id] = it.name;
                    return p;
                  }, {})
                }
              }
            };
          }
          return {
            [foreignField]: {
              type: 'equals',
              attribute: foreignField + 'Id',
              value: entries[0].id,
              data: {
                type: 'equals',
                idValue: entries[0].id,
                nameValue: entries[0].name
              }
            }
          };
        }
        if (foreignType === 'linkMultiple') {
          return {
            [foreignField]: {
              type: 'linkedWithAll',
              attribute: foreignField,
              value: entries.map(it => it.id),
              data: {
                type: 'allOf',
                nameHash: entries.reduce((p, it) => {
                  p[it.id] = it.name;
                  return p;
                }, {})
              }
            }
          };
        }

        // Not supported.
        if (foreignType === 'linkParent') {
          if (entries.length > 1) {
            console.warn("Cascading fields do not support multiple matches for link-parent filters.");
            return null;
          }
          return {
            [foreignField]: {
              type: 'and',
              attribute: foreignField + 'Id',
              value: [{
                type: 'equals',
                field: foreignField + 'Id',
                value: entries[0].id
              }, {
                type: 'equals',
                field: foreignField + 'Type',
                value: entries[0].entityType
              }],
              data: {
                type: 'is',
                idValue: entries[0].id,
                nameValue: entries[0].name,
                typeValue: entries[0].entityType
              }
            }
          };
        }
        return null;
      };
      const output = {};
      for (const item of this.options.items) {
        const itemOutput = prepareItem(item);
        if (itemOutput === null && item.matchRequired) {
          return {
            id: {
              type: 'isNull',
              attribute: 'id',
              data: {
                type: 'isEmpty'
              }
            }
          };
        }
        Object.assign(output, itemOutput);
      }
      return output;
    }

    /**
     * @return {Object.<string, unknown>}
     */
    prepareCreateAttributes() {
      const attributes = {};

      /**
       * @param {{localField: string, foreignField: string, matchRequired: boolean}} item
       * @return {Object.<string, *>}
       */
      const prepareItem = item => {
        const field = item.localField;
        const foreignField = item.foreignField;
        if (!field || !foreignField) {
          console.warn("Bad cascading fields definition.");
          return null;
        }
        const linkEntityType = this.getLinkEntityType(foreignField);
        const foreignType = this.getForeignType(foreignField);
        const entries = this.prepareItemEntries(item, linkEntityType);
        if (entries === null || !entries.length) {
          return null;
        }
        if (foreignType === 'link' || foreignType === 'linkOne') {
          return {
            [foreignField + 'Id']: entries[0].id,
            [foreignField + 'Name']: entries[0].name
          };
        }
        if (foreignType === 'linkMultiple') {
          return {
            [foreignField + 'Ids']: entries.map(it => it.id),
            [foreignField + 'Names']: entries.reduce((p, it) => {
              p[it.id] = it.name;
              return p;
            }, {})
          };
        }

        // Not supported.
        if (foreignType === 'linkParent') {
          return {
            [foreignField + 'Id']: entries[0].id,
            [foreignField + 'Name']: entries[0].name,
            [foreignField + 'Type']: entries[0].entityType
          };
        }
      };
      for (const item of this.options.items) {
        const itemOutput = prepareItem(item);
        if (itemOutput === null && item.matchRequired) {
          continue;
        }
        Object.assign(attributes, itemOutput);
      }
      return attributes;
    }

    /**
     * @private
     * @param {string} foreignField
     * @return {string|null}
     */
    getLinkEntityType(foreignField) {
      return this.metadata.get(`entityDefs.${this.options.foreignEntityType}.links.${foreignField}.entity`);
    }

    /**
     * @private
     * @param {string} foreignField
     * @return {string|null}
     */
    getForeignType(foreignField) {
      return this.metadata.get(`entityDefs.${this.options.foreignEntityType}.fields.${foreignField}.type`);
    }
    static #_ = _staticBlock = () => [_init_metadata, _init_extra_metadata] = _applyDecs(this, [], [[(0, _di.inject)(_metadata.default), 0, "metadata"]]).e;
  }
  _exports.default = CascadeLinksHelper;
  _staticBlock();
});

define("handlers/create-related", ["exports"], function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * Prepares attributes for a related record that is being created.
   */
  class CreateRelatedHandler {
    /**
     * @internal
     */

    /**
     * @internal
     */
    constructor(viewHelper) {
      this.viewHelper = viewHelper;
    }

    /**
     * Get attributes for a new record.
     *
     * @param model A model.
     * @param link A link name. As of v9.2.0.
     * @return {Promise<Object.<string, unknown>>} Attributes.
     */
    async getAttributes(model, link) {
      // noinspection BadExpressionStatementJS
      model;
      // noinspection BadExpressionStatementJS
      link;
      return {};
    }
  }
  var _default = _exports.default = CreateRelatedHandler;
});

define("contracts/relation", ["exports"], function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
});

define("exceptions", ["exports"], function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module exceptions */

  Espo.Exceptions = Espo.Exceptions || {};

  /**
   * An access-denied exception.
   *
   * @param {string} [message] A message.
   * @class
   */
  Espo.Exceptions.AccessDenied = function (message) {
    this.message = message;
    Error.apply(this, arguments);
  };
  Espo.Exceptions.AccessDenied.prototype = new Error();
  Espo.Exceptions.AccessDenied.prototype.name = 'AccessDenied';

  /**
   * A not-found exception.
   *
   * @param {string} [message] A message.
   * @class
   */
  Espo.Exceptions.NotFound = function (message) {
    this.message = message;
    Error.apply(this, arguments);
  };
  Espo.Exceptions.NotFound.prototype = new Error();
  Espo.Exceptions.NotFound.prototype.name = 'NotFound';
  var _default = _exports.default = Espo.Exceptions;
});

define("views/record/list-base", ["exports", "view", "helpers/mass-action", "helpers/export", "helpers/record-modal", "helpers/list/select-provider", "views/record/list/settings", "helpers/list/settings", "helpers/list/misc/sticky-bar", "helpers/record/list/column-resize", "helpers/record/list/column-width-control", "underscore", "utils", "ui", "ajax"], function (_exports, _view, _massAction, _export, _recordModal, _selectProvider, _settings, _settings2, _stickyBar, _columnResize, _columnWidthControl, _underscore, _utils, _ui, _ajax) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  _massAction = _interopRequireDefault(_massAction);
  _export = _interopRequireDefault(_export);
  _recordModal = _interopRequireDefault(_recordModal);
  _selectProvider = _interopRequireDefault(_selectProvider);
  _settings = _interopRequireDefault(_settings);
  _settings2 = _interopRequireDefault(_settings2);
  _stickyBar = _interopRequireDefault(_stickyBar);
  _columnResize = _interopRequireDefault(_columnResize);
  _columnWidthControl = _interopRequireDefault(_columnWidthControl);
  _underscore = _interopRequireDefault(_underscore);
  _utils = _interopRequireDefault(_utils);
  _ui = _interopRequireDefault(_ui);
  _ajax = _interopRequireDefault(_ajax);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * List view options.
   *
   * @internal
   */

  /**
   * @internal
   */

  /**
   * @internal
   */
  class ListBaseRecordView extends _view.default {
    constructor(options) {
      super(options);
    }
    template = 'record/list';

    /**
     * A type. Can be 'list', 'listSmall'.
     */
    type = 'list';
    name = 'list';

    /**
     * If true checkboxes will be shown. Can be overridden by an option parameter.
     */
    checkboxes = true;

    /**
     * If true clicking on the record link will trigger the 'select' event with model passed.
     * Can be overridden by an option parameter.
     */
    selectable = false;

    /**
     * A row-actions view. A dropdown on the right side.
     */
    rowActionsView = 'views/record/row-actions/default';

    /**
     * Disable row-actions. Can be overridden by an option parameter.
     */
    rowActionsDisabled = false;

    /**
     * An entity type. Set automatically.
     */
    entityType = null;

    /**
     * A scope. Set automatically.
     */
    scope = null;

    /**
     * @internal
     */
    _internalLayoutType = 'list-row';

    /**
     * A selector to a list container.
     */
    listContainerEl = '.list > table > tbody';

    /**
     * To show number of records. Can be overridden by an option parameter.
     */
    showCount = true;
    rowActionsColumnWidth = 25;
    checkboxColumnWidth = 40;

    /**
     * A button list.
     */
    buttonList = [];

    /**
     * A dropdown item list. Can be overridden by an option parameter.
     */
    dropdownItemList = [];

    /**
     * Disable the header. Can be overridden by an option parameter.
     */
    headerDisabled = false;

    /**
     * Disable mass actions. Can be overridden by an option parameter.
     */
    massActionsDisabled = false;

    /**
     * Disable a portal layout usage. Can be overridden by an option parameter.
     */
    portalLayoutDisabled = false;

    /**
     * Mandatory select attributes. Can be overridden by an option parameter.
     * Attributes to be selected regardless being in the layout.
     */
    mandatorySelectAttributeList = null;

    /**
     * A layout name. If null, a value from `type` property will be used.
     * Can be overridden by an option parameter.
     */
    layoutName = null;

    /**
     * A scope name for layout loading. If null, an entity type of collection will be used.
     * Can be overridden by an option parameter.
     */
    layoutScope = null;

    /**
     * To disable field-level access check for a layout.
     * Can be overridden by an option parameter.
     */
    layoutAclDisabled = false;

    /**
     * A setup-handler type.
     */
    setupHandlerType = 'record/list';

    /**
     * @internal
     */
    checkboxesDisabled = false;

    /**
     * Force displaying the top bar even if empty. Can be overridden by an option parameter.
     */
    forceDisplayTopBar = false;

    /**
     * Where to display the pagination. Can be overridden by an option parameter.
     */
    pagination = false;

    /**
     * To display a table header with column names. Can be overridden by an option parameter.
     */
    header = true;

    /**
     * A show-more button. Can be overridden by an option parameter.
     */
    showMore = true;

    /**
     * Column resize.
     * @since 9.0.0
     */
    columnResize = true;

    /**
     * A mass-action list.
     */
    massActionList = ['remove', 'merge', 'massUpdate', 'export'];

    /**
     * A mass-action list available when selecting all results.
     */
    checkAllResultMassActionList = ['remove', 'massUpdate', 'export'];

    /**
     * A forced mass-action list.
     */
    forcedCheckAllResultMassActionList = null;

    /**
     * Disable quick-detail (viewing a record in modal)
     */
    quickDetailDisabled = false;

    /**
     * Disable quick-edit (editing a record in modal)
     */
    quickEditDisabled = false;

    /**
     * Force settings.
     */
    forceSettings = false;

    /**
     * Disable settings.
     */
    settingsDisabled = false;

    /**
     * A list layout. Can be overridden by an option parameter.
     * If null, then will be loaded from the backend (using the `layoutName` value).
     */
    listLayout = null;
    multiListLayout = null;
    _internalLayout = null;

    /**
     * A list of record IDs currently selected. Only for reading.
     */

    /**
     * Whether all results currently selected. Only for reading.
     */
    allResultIsChecked = false;

    /**
     * Disable the ability to select all results. Can be overridden by an option parameter.
     */
    checkAllResultDisabled = false;

    /**
     * Disable buttons. Can be overridden by an option parameter.
     */
    buttonsDisabled = false;

    /**
     * Disable edit. Can be overridden by an option parameter.
     */
    editDisabled = false;

    /**
     * Disable remove. Can be overridden by an option parameter.
     */
    removeDisabled = false;

    /**
     * Disable a stick-bar. Can be overridden by an option parameter.
     */
    stickyBarDisabled = false;

    /**
     * To show sticky bar regardless of scrolling.
     */
    forceStickyBar = false;

    /**
     * Disable the follow/unfollow mass action.
     */
    massFollowDisabled = false;

    /**
     * Disable the print-pdf mass action.
     */
    massPrintPdfDisabled = false;

    /**
     * Disable the convert-currency mass action.
     */
    massConvertCurrencyDisabled = false;

    /**
     * Disable mass-update.
     */
    massUpdateDisabled = false;

    /**
     * Disable export.
     */
    exportDisabled = false;

    /**
     * Disable merge.
     */
    mergeDisabled = false;

    /**
     * Disable the no-data label (when no result).
     */
    noDataDisabled = false;

    /**
     * Disable pagination.
     */
    paginationDisabled = false;
    _focusedCheckbox = null;
    _disabledCheckboxes = false;

    /**
     * Data to pass to record views.
     *
     * @since 9.0.0
     */

    /**
     * @internal
     */

    /**
     * @since 9.1.1
     */

    /**
     * @since 10.0.0
     */
    starredAttribute = 'isStarred';

    /**
     * @type {boolean}
     * @since 10.0.0
     */

    _stickyBarHelper = null;

    /**
     * @internal
     */

    /**
     * @internal
     */

    /**
     * @internal
     */

    /**
     * @internal
     */

    /**
     * @internal
     */

    /**
     * @internal
     */

    focusOnList() {
      const element = this.element.querySelector('.list');
      if (!element) {
        return;
      }
      element.focus({
        preventScroll: true
      });
    }
    goToPage(page) {
      _ui.default.notifyWait();
      const onSync = () => {
        _ui.default.notify();
        this.trigger('after:paginate');
        this.focusOnList();
      };
      if (page === 'current') {
        this.collection.fetch().then(() => onSync());
        this.deactivate();
        return;
      }
      if (page === 'next') {
        this.collection.nextPage().then(() => onSync());
      } else if (page === 'previous') {
        this.collection.previousPage().then(() => onSync());
      } else if (page === 'last') {
        this.collection.lastPage().then(() => onSync());
      } else if (page === 'first') {
        this.collection.firstPage().then(() => onSync());
      }
      this.trigger('paginate');
      this.deactivate();
    }
    checkboxClick(element, checked) {
      const id = element.dataset.id;
      if (checked) {
        this._checkRecord(id, element);
        return;
      }
      this._uncheckRecord(id, element);
    }
    async resetCustomOrder() {
      this.collection.offset = 0;
      this.collection.resetOrderToDefault();
      this.collection.trigger('order-changed');
      await this.collection.fetch();
      this.trigger('sort', {
        orderBy: this.collection.orderBy,
        order: this.collection.order
      });
    }
    toggleSort(orderBy) {
      let asc = true;
      if (orderBy === this.collection.orderBy && this.collection.order === 'asc') {
        asc = false;
      }
      const order = asc ? 'asc' : 'desc';
      _ui.default.notifyWait();
      const maxSizeLimit = this.getConfig().get('recordListMaxSizeLimit') || 200;
      while (this.collection.length > maxSizeLimit) {
        this.collection.pop();
      }
      this.collection.offset = 0;
      this.collection.sort(orderBy, order).then(() => {
        _ui.default.notify(false);
        this.trigger('sort', {
          orderBy: orderBy,
          order: order
        });
      });
      this.collection.trigger('order-changed');
      this.deactivate();
    }

    /**
     * @internal
     */
    toShowStickyBar() {
      return this.getCheckedIds().length > 0 || this.isAllResultChecked() || this.pagination;
    }
    initStickyBar() {
      this._stickyBarHelper = new _stickyBar.default(this, {
        force: this.forceStickyBar
      });
    }
    showActions() {
      this.$el.find('.actions-button').removeClass('hidden');
      if (!this.options.stickyBarDisabled && !this.stickyBarDisabled && this.massActionList.length) {
        if (!this._stickyBarHelper) {
          this.initStickyBar();
        }
      }
    }
    hideActions() {
      this.$el.find('.actions-button').addClass('hidden');
      if (this._stickyBarHelper && (!this.pagination || this.forceStickyBar)) {
        this._stickyBarHelper.hide();
      }
    }
    selectAllHandler() {
      let isChecked = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
      this.checkedList = [];
      if (isChecked) {
        this.$el.find('input.record-checkbox').prop('checked', true);
        this.showActions();
        this.collection.models.forEach(model => {
          if (model.id) {
            this.checkedList.push(model.id);
          }
        });
        this.$el.find('.list > table tbody tr').addClass('active');
      } else {
        if (this.allResultIsChecked) {
          this.unselectAllResult();
        }
        this.$el.find('input.record-checkbox').prop('checked', false);
        this.hideActions();
        this.$el.find('.list > table tbody tr').removeClass('active');
      }
      this.trigger('check');
    }
    data() {
      const moreCount = this.collection.total - this.collection.length - this.collection.offset;
      let checkAllResultDisabled = this.checkAllResultDisabled;
      if (!this.massActionsDisabled) {
        if (!this.checkAllResultMassActionList.length) {
          checkAllResultDisabled = true;
        }
      }
      const displayTotalCount = this.displayTotalCount && this.collection.total > 0 && !this.pagination;
      let topBar = this.forceDisplayTopBar || this.collection.length && (this.pagination || this.checkboxes || this.buttonList.length && !this.buttonsDisabled || this.dropdownItemList.length && !this.buttonsDisabled || displayTotalCount);
      if (!topBar && this.pagination && !this.collection.length && this.collection.offset > 0) {
        topBar = true;
      }
      if (this.forceStickyBar) {
        topBar = false;
      }
      const checkboxes = this.checkboxes && this.massActionList.length;
      const displayActionsButtonGroup = checkboxes || this.buttonList.length || this.dropdownItemList.length;
      const hasStickyBar = this.forceStickyBar || displayActionsButtonGroup || this.pagination;
      const noDataDisabled = this.noDataDisabled || this._renderEmpty;
      const rowDataList = this.rowList ? this.rowList.map(id => {
        var _this$collection$get;
        return {
          id: id,
          isStarred: this.hasStars && this.collection.get(id) ? (_this$collection$get = this.collection.get(id)) === null || _this$collection$get === void 0 ? void 0 : _this$collection$get.attributes[this.starredAttribute] : false
        };
      }) : [];
      const checkboxColumnWidth = (this.checkboxColumnWidth * this._fontSizeFactor).toString() + 'px';
      return {
        scope: this.scope,
        collectionLength: this.collection.models.length,
        entityType: this.entityType,
        header: this.header,
        hasColumnResize: this._hasColumnResize(),
        headerDefs: this._getHeaderDefs(),
        hasPagination: this.hasPagination(),
        showMoreActive: this.collection.hasMore(),
        showMoreEnabled: this.showMore,
        showCount: this.showCount && this.collection.total > 0,
        moreCount: moreCount,
        checkboxes: this.checkboxes,
        massActionDataList: this.getMassActionDataList(),
        rowList: this.rowList,
        // For bc.
        rowDataList: rowDataList,
        topBar: topBar,
        checkAllResultDisabled: checkAllResultDisabled,
        buttonList: this.buttonList,
        dropdownItemList: this.dropdownItemList,
        displayTotalCount: displayTotalCount,
        displayActionsButtonGroup: displayActionsButtonGroup,
        totalCountFormatted: this.getNumberUtil().formatInt(this.collection.total),
        moreCountFormatted: this.getNumberUtil().formatInt(moreCount),
        checkboxColumnWidth: checkboxColumnWidth,
        noDataDisabled: noDataDisabled,
        hasStickyBar: hasStickyBar,
        selectable: this.selectable
      };
    }
    init() {
      this.type = this.options.type || this.type;
      this.listLayout = this.options.listLayout || this.listLayout || null;
      this.multiListLayout = this.options.multiListLayout || this.multiListLayout || null;
      this.layoutName = this.options.layoutName || this.layoutName || this.type;
      this.layoutScope = this.options.layoutScope || this.layoutScope;
      this.layoutAclDisabled = this.options.layoutAclDisabled || this.layoutAclDisabled;
      this.headerDisabled = this.options.headerDisabled || this.headerDisabled;
      this.noDataDisabled = this.options.noDataDisabled || this.noDataDisabled;
      if (!this.collectionEventSyncList) {
        this.collectionEventSyncList = [];
      } else {
        this.collectionEventSyncList = [...this.collectionEventSyncList];
      }
      if (!this.headerDisabled) {
        this.header = _underscore.default.isUndefined(this.options.header) ? this.header : this.options.header;
      } else {
        this.header = false;
      }
      this.pagination = this.options.pagination == null ? this.pagination : this.options.pagination;
      if (this.paginationDisabled) {
        this.pagination = false;
      }
      if (this.options.columnResize !== undefined) {
        this.columnResize = this.options.columnResize;
      }
      this.checkboxes = _underscore.default.isUndefined(this.options.checkboxes) ? this.checkboxes : this.options.checkboxes;
      this.selectable = _underscore.default.isUndefined(this.options.selectable) ? this.selectable : this.options.selectable;
      this.checkboxesDisabled = this.options.checkboxes === false;
      this.rowActionsView = _underscore.default.isUndefined(this.options.rowActionsView) ? this.rowActionsView : this.options.rowActionsView;
      this.showMore = _underscore.default.isUndefined(this.options.showMore) ? this.showMore : this.options.showMore;
      this.massActionsDisabled = this.options.massActionsDisabled || this.massActionsDisabled;
      this.portalLayoutDisabled = this.options.portalLayoutDisabled || this.portalLayoutDisabled;
      if (this.massActionsDisabled && !this.selectable) {
        this.checkboxes = false;
      }
      this.rowActionsDisabled = this.options.rowActionsDisabled || this.rowActionsDisabled;
      this.dropdownItemList = _utils.default.cloneDeep(this.options.dropdownItemList || this.dropdownItemList);
      if ('buttonsDisabled' in this.options) {
        this.buttonsDisabled = this.options.buttonsDisabled;
      }
      if ('checkAllResultDisabled' in this.options) {
        this.checkAllResultDisabled = this.options.checkAllResultDisabled;
      }
      this.rootData = this.options.rootData || {};
      this._fontSizeFactor = this.getThemeManager().getFontSizeFactor();
    }

    /**
     * Get a record scope (not necessarily matching the entity type).
     *
     * @param {string} id A record ID.
     */
    getModelScope(id) {
      // noinspection BadExpressionStatementJS
      id;
      return this.scope;
    }

    /**
     * Select all results.
     */
    selectAllResult() {
      this.allResultIsChecked = true;
      this.hideActions();
      this.$el.find('input.record-checkbox').prop('checked', true).attr('disabled', 'disabled');
      this.$selectAllCheckbox.prop('checked', true);
      this.massActionList.forEach(item => {
        if (!this.checkAllResultMassActionList.includes(item)) {
          this.$el.find(`div.list-buttons-container .actions-menu li a.mass-action[data-action="${item}"]`).parent().addClass('hidden');
        }
      });
      if (this.checkAllResultMassActionList.length) {
        this.showActions();
      }
      this.$el.find('.list > table tbody tr').removeClass('active');
      this.trigger('select-all-results');
    }

    /**
     * Unselect all results.
     */
    unselectAllResult() {
      this.allResultIsChecked = false;
      this.$el.find('input.record-checkbox').prop('checked', false).removeAttr('disabled');
      this.$selectAllCheckbox.prop('checked', false);
      this.massActionList.forEach(item => {
        if (!this.checkAllResultMassActionList.includes(item) && !(this.massActionDefs[item] || {}).hidden) {
          this.$el.find(`div.list-buttons-container .actions-menu li a.mass-action[data-action="${item}"]`).parent().removeClass('hidden');
        }
      });
    }
    deactivate() {
      var _this$element, _this$element2;
      (_this$element = this.element) === null || _this$element === void 0 || _this$element.querySelectorAll('.pagination a').forEach(element => {
        element.classList.add('disabled');
      });
      (_this$element2 = this.element) === null || _this$element2 === void 0 || _this$element2.querySelectorAll('a.sort').forEach(element => {
        element.classList.add('disabled');
      });
    }

    /**
     * Process export.
     *
     * @param [data]
     * @param [url='Export'] An API URL.
     * @param [fieldList] A field list.
     */
    async export(data, url, fieldList) {
      if (!data) {
        data = {
          entityType: this.entityType
        };
        if (this.allResultIsChecked) {
          data.where = this.getWhereForAllResult();
          data.searchParams = this.collection.data || null;
          data.searchData = this.collection.data || {}; // for bc;
        } else {
          data.ids = this.checkedList;
        }
      }
      url = url || 'Export';
      const o = {
        scope: this.entityType
      };
      if (fieldList) {
        o.fieldList = fieldList;
      } else {
        const layoutFieldList = [];
        if (Array.isArray(this.listLayout)) {
          this.listLayout.forEach(item => {
            if (item && item.name) {
              layoutFieldList.push(item.name);
            }
          });
        }
        o.fieldList = layoutFieldList;
      }
      const helper = new _export.default(this);
      const idle = this.allResultIsChecked && helper.checkIsIdle(this.collection.total);
      const proceedDownload = attachmentId => {
        window.location.href = `${this.getBasePath()}?entryPoint=download&id=${attachmentId}`;
      };
      const view = await this.createView('dialogExport', 'views/export/modals/export', o);
      this.listenToOnce(view, 'proceed', async dialogData => {
        if (!dialogData.exportAllFields) {
          data.attributeList = dialogData.attributeList;
          data.fieldList = dialogData.fieldList;
        }
        data.idle = idle;
        data.format = dialogData.format;
        data.params = dialogData.params;
        _ui.default.notify(this.translate('pleaseWait', 'messages'));
        const response = await _ajax.default.postRequest(url, data, {
          timeout: 0
        });
        _ui.default.notify();
        if (response.exportId) {
          const view = await helper.process(response.exportId);
          this.listenToOnce(view, 'download', id => proceedDownload(id));
          return;
        }
        if (!response.id) {
          throw new Error("No attachment-id.");
        }
        proceedDownload(response.id);
      });
      await view.render();
    }

    /**
     * Process a mass-action.
     *
     * @param {string} name An action.
     */
    massAction(name) {
      const defs = this.massActionDefs[name] || {};
      const handler = defs.handler;
      if (handler) {
        const method = defs.actionFunction || 'action' + _utils.default.upperCaseFirst(name);
        const data = {
          entityType: this.entityType,
          action: name,
          params: this.getMassActionSelectionPostData()
        };
        Espo.loader.require(handler, Handler => {
          const handler = new Handler(this);
          handler[method].call(handler, data);
        });
        return;
      }
      const bypassConfirmation = defs.bypassConfirmation || false;
      const confirmationMsg = defs.confirmationMessage || 'confirmation';
      const acl = defs.acl;
      const aclScope = defs.aclScope;
      const proceed = async () => {
        if (acl || aclScope) {
          if (!this.getAcl().check(aclScope || this.scope, acl)) {
            _ui.default.error(this.translate('Access denied'));
            return;
          }
        }
        const idList = [];
        const data = {};
        if (this.allResultIsChecked) {
          data.where = this.getWhereForAllResult();
          data.searchParams = this.collection.data || {};
          data.selectData = data.searchData; // for bc;
          data.byWhere = true; // for bc
        } else {
          data.idList = idList; // for bc
          data.ids = idList;
        }
        for (const i in this.checkedList) {
          idList.push(this.checkedList[i]);
        }
        data.entityType = this.entityType;
        const waitMessage = defs.waitMessage || 'pleaseWait';
        _ui.default.notify(this.translate(waitMessage, 'messages', this.scope));
        const url = defs.url;
        if (!url) {
          throw new Error('No collection URL.');
        }
        const result = await _ajax.default.postRequest(url, data);
        const successMessage = result.successMessage || defs.successMessage || 'done';
        await this.collection.fetch();
        let message = this.translate(successMessage, 'messages', this.scope);
        if ('count' in result) {
          message = message.replace('{count}', result.count);
        }
        _ui.default.success(message);
      };
      if (!bypassConfirmation) {
        this.confirm({
          message: this.translate(confirmationMsg, 'messages', this.scope)
        }).then(() => proceed());
        return;
      }
      proceed();
    }

    /**
     * Get the where clause for all result.
     *
     * @since 9.2.0
     */
    getWhereForAllResult() {
      const where = [...this.collection.getWhere()];
      if (this.options.allResultWhereItem) {
        where.push(this.options.allResultWhereItem);
      }
      return where;
    }
    getMassActionSelectionPostData() {
      const data = {};
      if (this.allResultIsChecked) {
        data.where = this.getWhereForAllResult();
        data.searchParams = this.collection.data || {};
        data.selectData = this.collection.data || {}; // for bc;
        data.byWhere = true; // for bc;
      } else {
        data.ids = [];
        for (const i in this.checkedList) {
          data.ids.push(this.checkedList[i]);
        }
      }
      return data;
    }

    // noinspection JSUnusedGlobalSymbols
    async massActionRecalculateFormula() {
      let ids = null;
      const allResultIsChecked = this.allResultIsChecked;
      if (!allResultIsChecked) {
        ids = this.checkedList;
      }
      await this.confirm({
        message: this.translate('recalculateFormulaConfirmation', 'messages'),
        confirmText: this.translate('Yes')
      });
      _ui.default.notify(this.translate('pleaseWait', 'messages'));
      const params = this.getMassActionSelectionPostData();
      const helper = new _massAction.default(this);
      const idle = !!params.searchParams && helper.checkIsIdle(this.collection.total);
      let result = await _ajax.default.postRequest('MassAction', {
        entityType: this.entityType,
        action: 'recalculateFormula',
        params: params,
        idle: idle
      });
      result = result || {};
      const final = async () => {
        var _ids;
        await this.collection.fetch();
        _ui.default.success(this.translate('Done'));
        if (allResultIsChecked) {
          this.selectAllResult();
          return;
        }
        (_ids = ids) === null || _ids === void 0 || _ids.forEach(id => this.checkRecord(id));
      };
      if (result.id) {
        const view = await helper.process(result.id, 'recalculateFormula');
        this.listenToOnce(view, 'close:success', () => final());
        return;
      }
      await final();
    }

    // noinspection JSUnusedGlobalSymbols
    async massActionRemove() {
      if (!this.getAcl().check(this.entityType, 'delete')) {
        _ui.default.error(this.translate('Access denied'));
        return false;
      }
      await this.confirm({
        message: this.translate('removeSelectedRecordsConfirmation', 'messages', this.scope),
        confirmText: this.translate('Remove')
      });
      _ui.default.notifyWait();
      const helper = new _massAction.default(this);
      const params = this.getMassActionSelectionPostData();
      const idle = !!params.searchParams && helper.checkIsIdle(this.collection.total);
      let result = await _ajax.default.postRequest('MassAction', {
        entityType: this.entityType,
        action: 'delete',
        params: params,
        idle: idle
      });
      result = result || {};
      const afterAllResult = count => {
        if (!count) {
          _ui.default.warning(this.translate('noRecordsRemoved', 'messages'));
          return;
        }
        this.unselectAllResult();
        this.collection.fetch().then(() => {
          const msg = count === 1 ? 'massRemoveResultSingle' : 'massRemoveResult';
          _ui.default.success(this.translate(msg, 'messages').replace('{count}', count.toString()));
        });
        this.collection.trigger('after:mass-remove');
        _ui.default.notify(false);
      };
      if (result.id) {
        const view = await helper.process(result.id, 'delete');
        this.listenToOnce(view, 'close:success', result => afterAllResult(result.count));
        return;
      }
      const count = result.count;
      if (this.allResultIsChecked) {
        afterAllResult(count);
        return;
      }
      const idsRemoved = result.ids ?? [];
      if (!count) {
        _ui.default.warning(this.translate('noRecordsRemoved', 'messages'));
        return;
      }
      idsRemoved.forEach(id => {
        _ui.default.notify(false);
        this.collection.trigger('model-removing', id);
        this.removeRecordFromList(id);
        this.uncheckRecord(id, true);
      });
      if (this.$selectAllCheckbox.prop('checked')) {
        this.$selectAllCheckbox.prop('checked', false);
        if (this.collection.hasMore()) {
          this.showMoreRecords({
            skipNotify: true
          });
        }
      }
      this.collection.trigger('after:mass-remove');
      const showSuccess = () => {
        const msgKey = count === 1 ? 'massRemoveResultSingle' : 'massRemoveResult';
        const msg = this.translate(msgKey, 'messages').replace('{count}', count);
        _ui.default.success(msg);
      };
      showSuccess();
    }

    // noinspection JSUnusedGlobalSymbols
    async massActionPrintPdf() {
      const maxCount = this.getConfig().get('massPrintPdfMaxCount');
      if (maxCount) {
        if (this.checkedList.length > maxCount) {
          const msg = this.translate('massPrintPdfMaxCountError', 'messages').replace('{maxCount}', maxCount.toString());
          _ui.default.error(msg);
          return;
        }
      }
      const idList = [];
      for (const i in this.checkedList) {
        idList.push(this.checkedList[i]);
      }
      const view = await this.createView('pdfTemplate', 'views/modals/select-template', {
        entityType: this.entityType
      });
      this.listenToOnce(view, 'select', async templateModel => {
        this.clearView('pdfTemplate');
        _ui.default.notifyWait();
        const result = await _ajax.default.postRequest('Pdf/action/massPrint', {
          idList: idList,
          entityType: this.entityType,
          templateId: templateModel.id
        }, {
          timeout: 0
        });
        _ui.default.notify(false);
        window.open(`?entryPoint=download&id=${result.id}`, '_blank');
      });
      await view.render();
    }

    // noinspection JSUnusedGlobalSymbols
    async massActionFollow() {
      const count = this.checkedList.length;
      const confirmMsg = this.translate('confirmMassFollow', 'messages').replace('{count}', count.toString());
      await this.confirm({
        message: confirmMsg,
        confirmText: this.translate('Follow')
      });
      _ui.default.notify(this.translate('pleaseWait', 'messages'));
      const result = await _ajax.default.postRequest('MassAction', {
        action: 'follow',
        entityType: this.entityType,
        params: this.getMassActionSelectionPostData()
      });
      const resultCount = result.count || 0;
      let msg = 'massFollowResult';
      if (resultCount) {
        if (resultCount === 1) {
          msg += 'Single';
        }
        msg = this.translate(msg, 'messages').replace('{count}', resultCount.toString());
        _ui.default.success(msg);
        return;
      }
      _ui.default.warning(this.translate('massFollowZeroResult', 'messages'));
    }

    // noinspection JSUnusedGlobalSymbols
    async massActionUnfollow() {
      const count = this.checkedList.length;
      const confirmMsg = this.translate('confirmMassUnfollow', 'messages').replace('{count}', count.toString());
      await this.confirm({
        message: confirmMsg,
        confirmText: this.translate('Yes')
      });
      _ui.default.notify(this.translate('pleaseWait', 'messages'));
      const params = this.getMassActionSelectionPostData();
      const helper = new _massAction.default(this);
      const idle = !!params.searchParams && helper.checkIsIdle(this.collection.total);
      const result = await _ajax.default.postRequest('MassAction', {
        action: 'unfollow',
        entityType: this.entityType,
        params: params,
        idle: idle
      });
      const final = count => {
        let msg = 'massUnfollowResult';
        if (!count) {
          _ui.default.warning(this.translate('massUnfollowZeroResult', 'messages'));
        }
        if (count === 1) {
          msg += 'Single';
        }
        msg = this.translate(msg, 'messages').replace('{count}', count.toString());
        _ui.default.success(msg);
      };
      if (result.id) {
        const view = await helper.process(result.id, 'unfollow');
        this.listenToOnce(view, 'close:success', result => final(result.count));
        return;
      }
      final(result.count || 0);
    }

    // noinspection JSUnusedGlobalSymbols
    massActionMerge() {
      if (!this.getAcl().check(this.entityType, 'edit')) {
        _ui.default.error(this.translate('Access denied'));
        return false;
      }
      if (this.checkedList.length < 2) {
        _ui.default.error(this.translate('select2OrMoreRecords', 'messages'));
        return;
      }
      if (this.checkedList.length > 4) {
        const msg = this.translate('selectNotMoreThanNumberRecords', 'messages').replace('{number}', '4');
        _ui.default.error(msg);
        return;
      }
      this.checkedList.sort();
      const url = '#' + this.entityType + '/merge/ids=' + this.checkedList.join(',');
      this.getRouter().navigate(url, {
        trigger: false
      });
      this.getRouter().dispatch(this.entityType, 'merge', {
        ids: this.checkedList.join(','),
        collection: this.collection
      });
    }

    // noinspection JSUnusedGlobalSymbols
    async massActionMassUpdate() {
      if (!this.getAcl().check(this.entityType, 'edit')) {
        _ui.default.error(this.translate('Access denied'));
        return false;
      }
      _ui.default.notifyWait();
      let ids = null;
      const allResultIsChecked = this.allResultIsChecked;
      if (!allResultIsChecked) {
        ids = this.checkedList;
      }
      const viewName = this.getMetadata().get(['clientDefs', this.entityType ?? '', 'modalViews', 'massUpdate']) || 'views/modals/mass-update';
      const view = await this.createView('massUpdate', viewName, {
        scope: this.scope,
        entityType: this.entityType,
        ids: ids,
        where: this.getWhereForAllResult(),
        searchParams: this.collection.data,
        byWhere: this.allResultIsChecked,
        totalCount: this.collection.total
      });
      this.listenToOnce(view, 'after:update', async o => {
        var _ids3;
        if (o.idle) {
          this.listenToOnce(view, 'close', async () => {
            var _ids2;
            await this.collection.fetch();
            if (allResultIsChecked) {
              this.selectAllResult();
              return;
            }
            (_ids2 = ids) === null || _ids2 === void 0 || _ids2.forEach(id => this.checkRecord(id));
          });
          return;
        }
        view.close();
        const count = o.count;
        await this.collection.fetch();
        if (count) {
          const msgKey = count === 1 ? 'massUpdateResultSingle' : 'massUpdateResult';
          const message = this.translate(msgKey, 'messages').replace('{count}', count);
          _ui.default.success(message);
        } else {
          _ui.default.warning(this.translate('noRecordsUpdated', 'messages'));
        }
        if (allResultIsChecked) {
          this.selectAllResult();
          return;
        }
        (_ids3 = ids) === null || _ids3 === void 0 || _ids3.forEach(id => this.checkRecord(id));
      });
      _ui.default.notify();
      await view.render();
    }

    // noinspection JSUnusedGlobalSymbols
    massActionExport() {
      if (this.getConfig().get('exportDisabled') && !this.getUser().isAdmin()) {
        return;
      }
      this.export();
    }

    // noinspection JSUnusedGlobalSymbols
    async massActionUnlink() {
      var _ref;
      if (!this.collection.url) {
        throw new Error('No collection URL.');
      }
      await this.confirm({
        message: this.translate('unlinkSelectedRecordsConfirmation', 'messages'),
        confirmText: this.translate('Unlink')
      });
      _ui.default.notifyWait();
      await _ajax.default.deleteRequest(this.collection.url, {
        ids: this.checkedList
      });
      _ui.default.success(this.translate('Unlinked'));
      this.collection.fetch();
      (_ref = this.model ?? this.collection.parentModel) === null || _ref === void 0 || _ref.trigger('after:unrelate');
    }

    // noinspection JSUnusedGlobalSymbols
    async massActionConvertCurrency() {
      let ids = null;
      const allResultIsChecked = this.allResultIsChecked;
      if (!allResultIsChecked) {
        ids = this.checkedList;
      }
      const view = await this.createView('modalConvertCurrency', 'views/modals/mass-convert-currency', {
        entityType: this.entityType,
        ids: ids,
        where: this.getWhereForAllResult(),
        searchParams: this.collection.data,
        byWhere: this.allResultIsChecked,
        totalCount: this.collection.total
      });
      this.listenToOnce(view, 'after:update', async o => {
        var _ids5;
        if (o.idle) {
          this.listenToOnce(view, 'close', async () => {
            var _ids4;
            await this.collection.fetch();
            if (allResultIsChecked) {
              this.selectAllResult();
              return;
            }
            (_ids4 = ids) === null || _ids4 === void 0 || _ids4.forEach(id => this.checkRecord(id));
          });
          return;
        }
        const count = o.count;
        await this.collection.fetch();
        if (count) {
          let msg = 'massUpdateResult';
          if (count === 1) {
            msg = 'massUpdateResultSingle';
          }
          _ui.default.success(this.translate(msg, 'messages').replace('{count}', count));
        } else {
          _ui.default.warning(this.translate('noRecordsUpdated', 'messages'));
        }
        if (allResultIsChecked) {
          this.selectAllResult();
          return;
        }
        (_ids5 = ids) === null || _ids5 === void 0 || _ids5.forEach(id => this.checkRecord(id));
      });
      await view.render();
    }

    /**
     * Add a mass action.
     *
     * @param item An action.
     * @param [allResult] To make available for all-result.
     * @param [toBeginning] Add to the beginning of the list.
     */
    addMassAction(item) {
      let allResult = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
      let toBeginning = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
      if (typeof item !== 'string') {
        const name = item.name;
        if (!name) {
          console.warn(`Cannot add mass action. No 'name'.`, item);
          return;
        }
        this.massActionDefs[name] = {
          ...this.massActionDefs[name],
          ...item
        };
        item = name;
      }
      toBeginning ? this.massActionList.unshift(item) : this.massActionList.push(item);
      if (allResult && !this.noAllResultMassActions) {
        toBeginning ? this.checkAllResultMassActionList.unshift(item) : this.checkAllResultMassActionList.push(item);
      }
      if (!this.checkboxesDisabled) {
        this.checkboxes = true;
      }
    }

    /**
     * Remove a mass action.
     *
     * @param item An action.
     */
    removeMassAction(item) {
      let index = this.massActionList.indexOf(item);
      if (~index) {
        this.massActionList.splice(index, 1);
      }
      index = this.checkAllResultMassActionList.indexOf(item);
      if (~index) {
        this.checkAllResultMassActionList.splice(index, 1);
      }
    }

    /**
     * Remove an all-result mass action.
     *
     * @param  item An action.
     */
    removeAllResultMassAction(item) {
      const index = this.checkAllResultMassActionList.indexOf(item);
      if (~index) {
        this.checkAllResultMassActionList.splice(index, 1);
      }
    }
    setup() {
      this.setupEventHandlers();
      this.checkedList = [];
      if (typeof this.collection === 'undefined') {
        throw new Error('Collection has not been injected into views/record/list view.');
      }
      this.layoutLoadCallbackList = [];
      this.entityType = this.collection.entityType || null;
      this.scope = this.options.scope || this.entityType;
      this.massActionList = _utils.default.clone(this.massActionList);
      this.checkAllResultMassActionList = _utils.default.clone(this.checkAllResultMassActionList);
      this.buttonList = _utils.default.clone(this.buttonList);
      this.mandatorySelectAttributeList = _utils.default.clone(this.options.mandatorySelectAttributeList || this.mandatorySelectAttributeList || []);
      this.forceStickyBar = this.options.forceStickyBar || this.forceStickyBar;
      this.editDisabled = this.options.editDisabled || this.editDisabled || this.getMetadata().get(['clientDefs', this.scope ?? '', 'editDisabled']);
      this.removeDisabled = this.options.removeDisabled || this.removeDisabled || this.getMetadata().get(['clientDefs', this.scope ?? '', 'removeDisabled']);
      this.setupMassActions();
      if (this.selectable) {
        this.addHandler('click', '.list a.link', (e, target) => {
          e.preventDefault();
          const id = target.dataset.id;
          if (id) {
            this.selectModel(id);
          }
          e.stopPropagation();
        });
      }
      if ('showCount' in this.options) {
        this.showCount = this.options.showCount;
      }
      this.displayTotalCount = this.showCount && this.getConfig().get('displayListViewRecordCount');
      if ('displayTotalCount' in this.options) {
        this.displayTotalCount = this.options.displayTotalCount;
      }
      this.forceDisplayTopBar = this.options.forceDisplayTopBar || this.forceDisplayTopBar;
      if (!this.massActionList.length && !this.selectable) {
        this.checkboxes = false;
      }
      if (this.options.forceSettings) {
        this.forceSettings = true;
      }
      this.hasStars = this.hasStars ?? this.getMetadata().get(`scopes.${this.entityType}.stars`) ?? false;
      if (this.getUser().isPortal() && !this.portalLayoutDisabled && this.scope && this.getMetadata().get(['clientDefs', this.scope, 'additionalLayouts', this.layoutName + 'Portal'])) {
        this.layoutName += 'Portal';
      }
      this.setupRowActionDefs();
      this.setupSettings();
      this.wait(this.getHelper().processSetupHandlers(this, this.setupHandlerType));
      this.listenTo(this.collection, 'sync', (_c, _r, options) => {
        this._renderEmpty = false;
        options = options || {};
        if (options.previousDataList) {
          const currentDataList = this.collection.models.map(model => {
            return _utils.default.cloneDeep(model.attributes);
          });
          if (_underscore.default.isEqual(currentDataList, options.previousDataList) && options.previousTotal === this.collection.total) {
            return;
          }
        }
        if (this.noRebuild) {
          this.noRebuild = null;
          return;
        }
        if (options.noRebuild) {
          this.noRebuild = null;
          return;
        }
        this.checkedList = [];
        this.allResultIsChecked = false;
        this.buildRowsAndRender();
      });
      this.checkedList = [];
      if (!this.options.skipBuildRows) {
        this.buildRows();
      }
      if (this.pagination) {
        this.createView('pagination', 'views/record/list-pagination', {
          collection: this.collection,
          displayTotalCount: this.displayTotalCount,
          recordView: this
        });
        this.createView('paginationSticky', 'views/record/list-pagination', {
          collection: this.collection,
          displayTotalCount: this.displayTotalCount,
          recordView: this
        });
        this.on('request-page', /** string */page => {
          if (this.collection.isBeingFetched()) {
            return;
          }
          if (page === 'next' && !this.collection.hasNextPage()) {
            return;
          }
          if (page === 'previous' && !this.collection.hasPreviousPage()) {
            return;
          }
          this.goToPage(page);
        });
      }
      this._renderEmpty = this.options.skipBuildRows ?? false;
      if (this.columnResize && this._listSettingsHelper) {
        this._columnResizeHelper = new _columnResize.default(this, this._listSettingsHelper);
      }
      if (this.hasStars) {
        this.listenTo(this.collection, 'change:' + this.starredAttribute, model => {
          const rowView = this.getRowView(model.id);
          const element = rowView === null || rowView === void 0 ? void 0 : rowView.element;
          if (!element) {
            return;
          }
          model.attributes[this.starredAttribute] ? element.classList.add('starred') : element.classList.remove('starred');
        });
      }
    }
    setupEventHandlers() {
      this.addHandler('auxclick', 'a.link', (e, target) => {
        var _target$parentElement;
        if (!(e instanceof MouseEvent)) {
          throw new Error();
        }
        const isCombination = e.button === 1 && (e.ctrlKey || e.metaKey);
        if (!isCombination) {
          return;
        }
        const id = target.dataset.id;
        if (!id) {
          return;
        }
        if (this.quickDetailDisabled) {
          return;
        }
        const menu = (_target$parentElement = target.parentElement) === null || _target$parentElement === void 0 || (_target$parentElement = _target$parentElement.closest(`[data-id="${id}"]`)) === null || _target$parentElement === void 0 ? void 0 : _target$parentElement.querySelector(`ul.list-row-dropdown-menu[data-id="${id}"]`);
        const quickView = menu === null || menu === void 0 ? void 0 : menu.querySelector(`a[data-action="quickView"]`);
        if (menu && !quickView) {
          return;
        }
        e.preventDefault();
        e.stopPropagation();
        this.actionQuickView({
          id: id
        });
      });
      this.addHandler('mousedown', 'a.sort', e => e.preventDefault());
      this.addHandler('click', 'a.sort', (_, target) => this.toggleSort(target.dataset.name));
      this.addHandler('click', '.pagination a[data-page]', (_, target) => {
        var _target$parentElement2;
        const page = target.dataset.page;
        if ((_target$parentElement2 = target.parentElement) !== null && _target$parentElement2 !== void 0 && _target$parentElement2.classList.contains('disabled')) {
          return;
        }
        this.goToPage(page);
      });
      this.addHandler('mousedown', 'input.record-checkbox', () => {
        const activeElement = document.activeElement;
        this._focusedCheckbox = null;
        if (activeElement instanceof HTMLInputElement && activeElement.classList.contains('record-checkbox')) {
          this._focusedCheckbox = activeElement;
        }
      });
      this.addHandler('click', 'input.record-checkbox', (e, target) => {
        if (!(e instanceof MouseEvent) || !(target instanceof HTMLInputElement)) {
          throw new Error();
        }
        if (this._disabledCheckboxes) {
          return;
        }
        const from = this._focusedCheckbox;
        if (!e.shiftKey || !from) {
          this.checkboxClick(target, target.checked);
          return;
        }
        const checkboxes = Array.from(this.element.querySelectorAll('input.record-checkbox'));
        const start = checkboxes.indexOf(target);
        const end = checkboxes.indexOf(from);
        const checked = from.checked;
        checkboxes.slice(Math.min(start, end), Math.max(start, end) + 1).forEach(element => {
          element.checked = checked;
          this.checkboxClick(element, checked);
        });
      });
      this.addHandler('click', 'input.select-all', (_, target) => {
        if (this._disabledCheckboxes) {
          return;
        }
        if (!(target instanceof HTMLInputElement)) {
          throw new Error();
        }
        this.selectAllHandler(target.checked);
      });
      this.addHandler('click', '.action', (e, target) => {
        _utils.default.handleAction(this, e, target, {
          actionItems: [...this.buttonList, ...this.dropdownItemList],
          className: 'list-action-item'
        });
      });
      this.addHandler('click', '.checkbox-dropdown [data-action="selectAllResult"]', () => {
        if (this._disabledCheckboxes) {
          return;
        }
        this.selectAllResult();
      });
      this.addHandler('click', '.actions-menu a.mass-action', (e, target) => {
        var _target$closest;
        const action = target.dataset.action;
        const method = 'massAction' + _utils.default.upperCaseFirst(action);
        e.preventDefault();
        e.stopPropagation();
        const parent = (_target$closest = target.closest('.dropdown-menu')) === null || _target$closest === void 0 ? void 0 : _target$closest.parentElement;
        const toggle = parent === null || parent === void 0 ? void 0 : parent.querySelector('.actions-button[data-toggle="dropdown"]');
        if (toggle) {
          // @ts-ignore
          $(toggle).dropdown('toggle').focus();
        }
        if (method in this) {
          // @ts-ignore
          this[method]();
          return;
        }
        this.massAction(action);
      });
      this.addHandler('click', 'a.reset-custom-order', () => this.resetCustomOrder());
      this.addHandler('click', 'a.link', (e, target) => {
        if (!(e instanceof MouseEvent)) {
          throw new Error();
        }
        if (e.ctrlKey || e.metaKey || e.shiftKey) {
          return;
        }
        e.stopPropagation();
        if (!this.scope || this.selectable) {
          return;
        }
        e.preventDefault();
        this.processLinkClick(target.dataset.id);
      });
      this.addHandler('click', '[data-action="showMore"]', (_e, target) => {
        if (target.dataset.ownerCid && target.dataset.ownerCid !== this.cid) {
          return;
        }
        this.showMoreRecords();
        this.focusOnList();
      });
    }

    /**
     * @since 9.1.0
     */
    buildRowsAndRender() {
      var _this$getView;
      let modalView;
      const modalKey = 'modal';
      if (this.hasView(modalKey) && (_this$getView = this.getView(modalKey)) !== null && _this$getView !== void 0 && _this$getView.isRendered()) {
        modalView = this.getView(modalKey);
        this.unchainView(modalKey);
      }
      this.buildRows(async () => {
        await this.reRender({
          force: true
        });
        if (modalView) {
          this.setView(modalKey, modalView);
        }
      });
    }
    processLinkClick(id) {
      var _this = this;
      const scope = this.getModelScope(id);
      const collection = this.collection.clone({
        withModels: true
      });
      const options = {
        id: id,
        model: collection.get(id)
      };
      if (this.collectionEventSyncList) {
        this.listenTo(collection, 'all', function (event) {
          if (_this.collectionEventSyncList.includes(event)) {
            for (var _len = arguments.length, parameters = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
              parameters[_key - 1] = arguments[_key];
            }
            _this.collection.trigger(event, ...parameters);
          }
        });
      }
      this.listenTo(collection, 'model-sync', (/** Model */m, /** Record */o) => {
        if (o.action === 'destroy') {
          this.removeRecordFromList(m.id);
        }
        const model = this.collection.get(m.id);
        if (!model) {
          return;
        }
        if (o.action === 'set' || o.action === 'fetch' || o.action === 'save') {
          model.setMultiple(m.getClonedAttributes(), o);
        }
      });
      this.listenTo(collection, 'sync', (c, r, /** Record */o) => {
        if (!o.more) {
          return;
        }
        const moreModels = collection.models.slice(this.collection.length);
        this.collection.add(moreModels);
        this.collection.total = collection.total;
        this.collection.lengthCorrection = collection.lengthCorrection;
        this.collection.trigger('sync', c, r, o);
      });
      if (this.options.keepCurrentRootUrl) {
        options.rootUrl = this.getRouter().getCurrentUrl();
      }
      options.rootData = this.rootData;
      this.getRouter().navigate(`#${scope}/view/${id}`, {
        trigger: false
      });
      this.getRouter().dispatch(scope, 'view', options);
    }
    selectModel(id) {
      const model = this.collection.get(id);
      if (!model) {
        return;
      }
      if (this.checkboxes) {
        this.trigger('select', [model]);
        return;
      }
      this.trigger('select', model);
      if (this.options.onSelect) {
        this.options.onSelect([model]);
      }
    }
    onRemove() {
      this.destroyStickyBar();
    }
    afterRender() {
      this.destroyStickyBar();
      this.$selectAllCheckbox = this.$el.find('input.select-all');
      if (this.allResultIsChecked) {
        this.selectAllResult();
      } else if (this.checkedList.length) {
        this.checkedList.forEach(id => {
          this.checkRecord(id);
        });
      }
      if (this.pagination && this.$el.find('.list-buttons-container').length) {
        this.initStickyBar();
      }
      if (this._disabledCheckboxes) {
        this.disableCheckboxes();
      }
    }
    destroyStickyBar() {
      if (this._stickyBarHelper) {
        this._stickyBarHelper.destroy();
      }
      this._stickyBarHelper = null;
    }
    setupMassActions() {
      if (this.massActionsDisabled || !this.checkboxes) {
        this.massActionList = [];
        this.checkAllResultMassActionList = [];
        this.massActionDefs = {};
        return;
      }
      if (!this.entityType || !this.getAcl().checkScope(this.entityType, 'delete')) {
        this.removeMassAction('remove');
        this.removeMassAction('merge');
      }
      if (this.removeDisabled || this.getMetadata().get(['clientDefs', this.scope ?? '_', 'massRemoveDisabled'])) {
        this.removeMassAction('remove');
      }
      if (!this.entityType || !this.getAcl().checkScope(this.entityType, 'edit')) {
        this.removeMassAction('massUpdate');
        this.removeMassAction('merge');
      }
      if (this.getMetadata().get(['clientDefs', this.scope ?? '_', 'mergeDisabled']) || this.mergeDisabled) {
        this.removeMassAction('merge');
      }
      this.massActionDefs = {
        remove: {
          groupIndex: 0,
          iconClass: 'fas fa-times'
        },
        merge: {
          groupIndex: 0,
          iconClass: 'fas fa-code-branch fa-flip-vertical'
        },
        massUpdate: {
          groupIndex: 0,
          iconClass: 'fas fa-pen-to-square'
        },
        export: {
          groupIndex: 2,
          iconClass: 'fas fa-arrow-up-right-from-square'
        },
        follow: {
          groupIndex: 4,
          iconClass: 'fas fa-rss'
        },
        unfollow: {
          groupIndex: 4
        },
        convertCurrency: {
          groupIndex: 6
        },
        printPdf: {
          groupIndex: 8,
          iconClass: 'far fa-file-pdf'
        },
        ...(this.getMetadata().get(['clientDefs', 'Global', 'massActionDefs']) || {}),
        ...(this.getMetadata().get(['clientDefs', this.scope ?? '_', 'massActionDefs']) || {})
      };
      const metadataMassActionList = [...(this.getMetadata().get(['clientDefs', 'Global', 'massActionList']) || []), ...(this.getMetadata().get(['clientDefs', this.scope ?? '_', 'massActionList']) || [])].filter((it, i, self) => self.indexOf(it) === i);
      const metadataCheckAllMassActionList = [...(this.getMetadata().get(['clientDefs', 'Global', 'checkAllResultMassActionList']) || []), ...(this.getMetadata().get(['clientDefs', this.scope ?? '_', 'checkAllResultMassActionList']) || [])].filter((it, i, self) => self.indexOf(it) === i);
      metadataMassActionList.forEach(item => {
        const defs = this.massActionDefs[item] || {};
        if (!_utils.default.checkActionAvailability(this.getHelper(), defs) || this.entityType && !_utils.default.checkActionAccess(this.getAcl(), this.entityType, defs)) {
          return;
        }
        this.massActionList.push(item);
      });
      this.noAllResultMassActions = this.collection.url !== this.entityType && !this.options.forceAllResultSelectable;
      this.checkAllResultMassActionList = this.checkAllResultMassActionList.filter(item => this.massActionList.includes(item));
      metadataCheckAllMassActionList.forEach(item => {
        if (this.noAllResultMassActions || !this.massActionList.includes(item)) {
          return;
        }
        const defs = this.massActionDefs[item] ?? {};
        if (!_utils.default.checkActionAvailability(this.getHelper(), defs) || !_utils.default.checkActionAccess(this.getAcl(), this.entityType, defs)) {
          return;
        }
        this.checkAllResultMassActionList.push(item);
      });
      metadataMassActionList.concat(metadataCheckAllMassActionList).forEach(action => {
        const defs = this.massActionDefs[action] || {};
        if (!defs.initFunction || !defs.handler) {
          return;
        }
        const viewObject = this;
        this.wait(new Promise(resolve => {
          Espo.loader.require(defs.handler, Handler => {
            const handler = new Handler(viewObject);

            // @ts-ignore
            handler[defs.initFunction].call(handler);
            resolve(undefined);
          });
        }));
      });
      if (this.getConfig().get('exportDisabled') && !this.getUser().isAdmin() || this.getAcl().getPermissionLevel('exportPermission') === 'no' || this.scope && this.getMetadata().get(['clientDefs', this.scope, 'exportDisabled']) || this.exportDisabled) {
        this.removeMassAction('export');
      }
      if (this.getAcl().getPermissionLevel('massUpdatePermission') !== 'yes' || this.editDisabled || this.massUpdateDisabled || this.scope && this.getMetadata().get(['clientDefs', this.scope, 'massUpdateDisabled'])) {
        this.removeMassAction('massUpdate');
      }
      if (this.scope && this.entityType && (!this.massFollowDisabled && this.getMetadata().get(['scopes', this.entityType, 'stream']) && this.getAcl().check(this.entityType, 'stream') || this.getMetadata().get(['clientDefs', this.scope, 'massFollowDisabled']))) {
        this.addMassAction('follow');
        this.addMassAction('unfollow', true);
      }
      if (this.entityType && !this.massPrintPdfDisabled && (this.getHelper().getAppParam('templateEntityTypeList') || []).includes(this.entityType)) {
        this.addMassAction('printPdf');
      }
      if (this.options.unlinkMassAction && this.collection) {
        this.addMassAction('unlink', false, true);
      }
      if (this.scope && this.entityType && !this.massConvertCurrencyDisabled && !this.getMetadata().get(['clientDefs', this.scope, 'convertCurrencyDisabled']) && this.getConfig().get('currencyList').length > 1 && this.getAcl().checkScope(this.scope, 'edit') && this.getAcl().getPermissionLevel('massUpdatePermission') === 'yes') {
        const currencyFieldList = this.getFieldManager().getEntityTypeFieldList(this.entityType, {
          type: 'currency',
          acl: 'edit'
        });
        if (currencyFieldList.length) {
          this.addMassAction('convertCurrency', true);
        }
      }
      this.setupMassActionItems();
      if (this.getUser().isAdmin() && this.entityType && this.getMetadata().get(['formula', this.entityType, 'beforeSaveCustomScript'])) {
        this.addMassAction('recalculateFormula', true);
      }
      if (this.noAllResultMassActions) {
        _utils.default.clone(this.checkAllResultMassActionList).forEach(item => {
          this.removeAllResultMassAction(item);
        });
      }
      if (this.forcedCheckAllResultMassActionList) {
        this.checkAllResultMassActionList = _utils.default.clone(this.forcedCheckAllResultMassActionList);
      }
      if (this.getAcl().getPermissionLevel('massUpdatePermission') !== 'yes') {
        this.removeAllResultMassAction('remove');
      }
      _utils.default.clone(this.massActionList).forEach(item => {
        const propName = 'massAction' + _utils.default.upperCaseFirst(item) + 'Disabled';
        if (
        // @ts-ignore
        this[propName] || this.options[propName]) {
          this.removeMassAction(item);
        }
      });
    }
    setupMassActionItems() {}

    /**
     * @internal
     */
    filterListLayout(listLayout) {
      if (this._cachedFilteredListLayout) {
        return this._cachedFilteredListLayout;
      }
      if (!Array.isArray(listLayout)) {
        return listLayout;
      }
      let forbiddenFieldList = [];
      if (this.entityType) {
        forbiddenFieldList = this._cachedScopeForbiddenFieldList = this._cachedScopeForbiddenFieldList || this.getAcl().getScopeForbiddenFieldList(this.entityType, 'read');
      }
      if (this.layoutAclDisabled) {
        forbiddenFieldList = [];
      }
      const filteredListLayout = _utils.default.cloneDeep(listLayout);
      const deleteIndexes = [];
      for (const [i, item] of listLayout.entries()) {
        if (item.name && forbiddenFieldList.includes(item.name)) {
          item.customLabel = '';
          item.notSortable = true;
          deleteIndexes.push(i);
        }
      }
      deleteIndexes.reverse().forEach(index => filteredListLayout.splice(index, 1));
      const fieldDefs = this.getMetadata().get(`entityDefs.${this.entityType}.fields`) || {};
      filteredListLayout.forEach(item => {
        if (!item || !item.name || !fieldDefs[item.name]) {
          return;
        }
        if (fieldDefs[item.name].orderDisabled) {
          item.notSortable = true;
        }
      });
      this._cachedFilteredListLayout = filteredListLayout;
      return this._cachedFilteredListLayout;
    }

    /**
     * @internal
     */
    _loadListLayout(callback) {
      this.layoutLoadCallbackList.push(callback);
      if (this.layoutIsBeingLoaded) {
        return;
      }
      this.layoutIsBeingLoaded = true;
      const layoutName = this.layoutName;
      const layoutScope = this.layoutScope || this.collection.entityType;
      this.getHelper().layoutManager.get(layoutScope, layoutName, listLayout => {
        const filteredListLayout = this.filterListLayout(listLayout);
        this.layoutLoadCallbackList.forEach(callbackItem => {
          callbackItem(filteredListLayout);
          this.layoutLoadCallbackList = [];
          this.layoutIsBeingLoaded = false;
        });
      });
    }

    /**
     * Get a select-attribute list.
     *
     * @param [callback] A callback. For bc.
     */
    async getSelectAttributeList(callback) {
      callback ??= () => {};
      if (this.scope === null) {
        callback(null);
        return null;
      }
      if (!this.listLayout) {
        await new Promise(resolve => {
          this._loadListLayout(listLayout => {
            this.listLayout = listLayout;
            resolve(undefined);
          });
        });
      }
      const attributeList = this.fetchAttributeListFromLayout();
      if (this.mandatorySelectAttributeList) {
        attributeList.push(...this.mandatorySelectAttributeList);
      }
      callback(attributeList);
      return attributeList;
    }
    fetchAttributeListFromLayout() {
      if (!this.entityType) {
        return [];
      }
      const selectProvider = new _selectProvider.default();
      return selectProvider.getFromLayout(this.entityType, this.listLayout, this._listSettingsHelper);
    }
    _hasColumnResize() {
      return this._listSettingsHelper ? this._listSettingsHelper.getColumnResize() : false;
    }
    _getHeaderDefs() {
      const resize = this._hasColumnResize();
      const widthMap = this._listSettingsHelper ? this._listSettingsHelper.getColumnWidthMap() : {};

      // noinspection JSIncompatibleTypesComparison
      if (!this.listLayout || !Array.isArray(this.listLayout)) {
        return [];
      }
      let emptyWidthMet = false;
      const visibleColumns = this.listLayout.filter(it => {
        if (!it) {
          return false;
        }
        if (!this._listSettingsHelper && it.hidden) {
          return false;
        }
        if (!this._listSettingsHelper) {
          return true;
        }
        if (it.name && this._listSettingsHelper.isColumnHidden(it.name, it.hidden)) {
          return false;
        }
        return true;
      }).map(it => ({
        ...it
      }));
      const defs = [];
      for (const col of visibleColumns) {
        let width = false;
        let widthPercent = null;
        let isResized = false;
        const itemName = col.name;
        if (itemName && itemName in widthMap) {
          const widthItem = widthMap[itemName];
          width = widthItem.value + widthItem.unit;
          if (widthItem.unit === '%') {
            widthPercent = widthItem.value;
          }
          isResized = true;
        } else if ('width' in col && col.width !== null) {
          width = col.width + '%';
          widthPercent = col.width;
        } else if ('widthPx' in col) {
          width = (col.widthPx * this._fontSizeFactor).toString() + 'px';
        } else {
          emptyWidthMet = true;
        }
        const label = col.label || itemName;
        const item = {
          name: itemName,
          isSortable: !(col.notSortable || false),
          width: width,
          align: 'align' in col ? col.align : false,
          resizable: resize && width && visibleColumns.length > 1,
          resizeOnRight: resize && width && !emptyWidthMet,
          widthPercent: widthPercent,
          isResized: isResized
        };
        if ('customLabel' in col) {
          item.customLabel = col.customLabel;
          item.hasCustomLabel = true;
          item.label = item.customLabel;
        } else {
          item.label = this.translate(label, 'fields', this.collection.entityType);
        }
        if (col.noLabel) {
          item.label = null;
        }
        if (item.isSortable) {
          item.isSorted = this.collection.orderBy === itemName;
          if (item.isSorted) {
            item.isDesc = this.collection.order === 'desc';
          }
        }
        defs.push(item);
      }
      {
        const emptyWidth = 3.0;
        let sum = 0.0;
        let sumResized = 0.0;
        let countEmpty = 0;
        for (const item of defs) {
          if (item.widthPercent === null) {
            sum += emptyWidth;
            countEmpty++;
            continue;
          }
          sum += item.widthPercent;
          if (item.isResized) {
            sumResized += item.widthPercent;
          }
        }
        if (emptyWidthMet && sum > 100) {
          const space = 5;
          const factor = (100 - countEmpty * emptyWidth - space - sumResized) / sum;
          for (const item of defs) {
            if (item.widthPercent === null || item.isResized) {
              continue;
            }
            item.widthPercent = item.widthPercent * factor;
            item.width = item.widthPercent.toString() + '%';
          }
        }
      }
      const isCustomSorted = this.collection.orderBy !== this.collection.defaultOrderBy || this.collection.order !== this.collection.defaultOrder;
      if (this.rowActionsView && !this.rowActionsDisabled || isCustomSorted) {
        let html = null;
        if (isCustomSorted) {
          const a = document.createElement('a');
          a.role = 'button';
          a.tabIndex = 0;
          a.classList.add('reset-custom-order');
          a.title = this.translate('Reset');
          a.append((() => {
            const span = document.createElement('span');
            span.className = 'fas fa-times fa-sm';
            return span;
          })());
          html = a.outerHTML;
        }
        const width = (this._fontSizeFactor * this.rowActionsColumnWidth).toString() + 'px';
        defs.push({
          width: width,
          html: html,
          className: 'action-cell'
        });
      }
      return defs;
    }

    /**
     * @internal
     */

    /**
     * Select a record.
     *
     * @param id An ID.
     * @param [isSilent] Do not trigger the `check` event.
     */
    checkRecord(id) {
      let isSilent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
      this._checkRecord(id, undefined, isSilent);
    }
    _checkRecord(id) {
      var _this$element3;
      let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
      let isSilent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
      if (this._disabledCheckboxes) {
        return;
      }
      if (!this.collection.get(id)) {
        return;
      }
      target ??= (_this$element3 = this.element) === null || _this$element3 === void 0 ? void 0 : _this$element3.querySelector(`.record-checkbox[data-id="${id}"]`);
      if (target) {
        var _target$closest2;
        target.checked = true;
        (_target$closest2 = target.closest('tr')) === null || _target$closest2 === void 0 || _target$closest2.classList.add('active');
      }
      const index = this.checkedList.indexOf(id);
      if (index === -1) {
        this.checkedList.push(id);
      }
      this.handleAfterCheck(isSilent);
    }

    /**
     * Unselect a record.
     *
     * @param id An ID.
     * @param [isSilent] Do not trigger the `check` event.
     */
    uncheckRecord(id) {
      let isSilent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
      this._uncheckRecord(id, null, isSilent);
    }
    _uncheckRecord(id) {
      var _this$element4;
      let target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
      let isSilent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
      target ??= (_this$element4 = this.element) === null || _this$element4 === void 0 ? void 0 : _this$element4.querySelector(`.record-checkbox[data-id="${id}"]`);
      if (target) {
        var _target$closest3;
        target.checked = false;
        (_target$closest3 = target.closest('tr')) === null || _target$closest3 === void 0 || _target$closest3.classList.remove('active');
      }
      const index = this.checkedList.indexOf(id);
      if (index !== -1) {
        this.checkedList.splice(index, 1);
      }
      this.handleAfterCheck(isSilent);
    }
    handleAfterCheck() {
      let isSilent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
      if (this.checkedList.length) {
        this.showActions();
      } else {
        this.hideActions();
      }
      if (this.element) {
        if (this.checkedList.length === this.collection.models.length) {
          this.$el.find('.select-all').prop('checked', true);
        } else {
          this.$el.find('.select-all').prop('checked', false);
        }
      }
      if (!isSilent) {
        this.trigger('check');
      }
    }

    /**
     * Get row-actions defs.
     */
    getRowActionsDefs() {
      const options = {
        defs: {
          params: {}
        },
        additionalActionList: this._additionalRowActionList || [],
        scope: this.scope
      };
      if (this.options.rowActionsOptions) {
        for (const item in this.options.rowActionsOptions) {
          options[item] = this.options.rowActionsOptions[item];
        }
      }
      return {
        columnName: 'buttons',
        name: 'buttonsField',
        view: this.rowActionsView,
        options: options
      };
    }

    /**
     * Is all-result is checked.
     */
    isAllResultChecked() {
      return this.allResultIsChecked;
    }

    /**
     * Get checked record IDs.
     */
    getCheckedIds() {
      return _utils.default.clone(this.checkedList);
    }

    /**
     * Get selected models.
     */
    getSelected() {
      const list = [];
      this.element.querySelectorAll('input.record-checkbox:checked').forEach(element => {
        const id = element.dataset.id;
        const model = this.collection.get(id);
        if (model) {
          list.push(model);
        }
      });
      return list;
    }
    getInternalLayoutForModel(callback, model) {
      const scope = model.entityType;
      if (this._internalLayout === null) {
        this._internalLayout = {};
      }
      if (!(scope in this._internalLayout)) {
        var _this$multiListLayout;
        const layout = (_this$multiListLayout = this.multiListLayout) === null || _this$multiListLayout === void 0 ? void 0 : _this$multiListLayout[scope];
        if (!layout) {
          throw new Error(`No layout for '${scope}'.`);
        }
        this._internalLayout[scope] = this._convertLayout(layout, model);
      }
      callback(this._internalLayout[scope]);
    }
    getInternalLayout(callback, model) {
      if (this.scope === null && this.multiListLayout) {
        if (!model) {
          callback(null);
          return;
        }
        this.getInternalLayoutForModel(callback, model);
        return;
      }
      if (this._internalLayout !== null) {
        callback(this._internalLayout);
        return;
      }
      if (this.listLayout !== null) {
        this._internalLayout = this._convertLayout(this.listLayout);
        callback(this._internalLayout);
        return;
      }
      this._loadListLayout(listLayout => {
        this.listLayout = listLayout;
        this._internalLayout = this._convertLayout(listLayout);
        callback(this._internalLayout);
      });
    }

    /**
     * Compose a cell selector for a layout item.
     *
     * @param model A model.
     * @param item An item.
     */
    getCellSelector(model, item) {
      return `${this.getSelector()} ${this.getRowSelector(model.id)} .cell[data-name="${item.columnName}"]`;
    }

    /**
     * @internal
     */
    prepareInternalLayout(internalLayout, model) {
      internalLayout.forEach(item => {
        // @todo Revise whether has any effect.
        //     Has to be in options instead? item.options.fullSelector;
        item.fullSelector = this.getCellSelector(model, item);
        if (this.header && item.options && item.options.defs) {
          item.options.defs.width = undefined;
          item.options.defs.widthPx = undefined;
        }
      });
    }

    /**
     * Get a row view.
     *
     * @since 10.0.0
     */
    getRowView(id) {
      return this.getView(id);
    }

    /**
     * Build a row.
     *
     * @param i An index.
     * @param model A model.
     * @param [callback] A callback.
     */
    buildRow(i, model, callback) {
      const key = model.id ?? i.toString();
      this.rowList.push(key);
      this.getInternalLayout(internalLayout => {
        internalLayout = _utils.default.cloneDeep(internalLayout);
        this.prepareInternalLayout(internalLayout, model);
        const acl = {
          edit: this.getAcl().checkModel(model, 'edit') && !this.editDisabled,
          delete: this.getAcl().checkModel(model, 'delete') && !this.removeDisabled
        };
        this.createView(key, 'views/base', {
          model: model,
          acl: acl,
          rowActionHandlers: this._rowActionHandlers || {},
          selector: this.getRowSelector(key),
          optionsToPass: ['acl', 'rowActionHandlers'],
          layoutDefs: {
            type: this._internalLayoutType,
            layout: internalLayout
          },
          setViewBeforeCallback: this.options.skipBuildRows && !this.isRendered()
        }, callback);
      }, model);
    }

    /**
     * Build rows.
     *
     * @param [callback] A callback.
     */
    buildRows(callback) {
      this.checkedList = [];
      this.rowList = [];
      if (this.collection.length <= 0) {
        if (typeof callback === 'function') {
          callback();
          this.trigger('after:build-rows');
        }
        return;
      }
      this.wait(true);
      const modelList = this.collection.models;
      let counter = 0;
      modelList.forEach((model, i) => {
        this.buildRow(i, model, () => {
          counter++;
          if (counter !== modelList.length) {
            return;
          }
          if (typeof callback === 'function') {
            callback();
          }
          this.wait(false);
          this.trigger('after:build-rows');
        });
      });
    }

    /**
     * Show more records.
     *
     * @param [options]
     * @param [collection]
     * @param [$list]
     * @param [$showMore]
     * @param [callback] A callback.
     *
     * @internal
     */
    showMoreRecords(options, collection, $list, $showMore, callback) {
      var _$showMore;
      collection = collection || this.collection;
      $showMore = $showMore || this.$el.find(`.show-more[data-owner-cid="${this.cid}"]`);
      $list = $list || this.$el.find(this.listContainerEl);
      options = options || {};
      const $container = this.$el.find('.list');
      (_$showMore = $showMore) === null || _$showMore === void 0 || _$showMore.children('a').addClass('disabled');
      if (!options.skipNotify) {
        _ui.default.notifyWait();
      }
      const lengthBefore = collection.length;
      const final = () => {
        var _$showMore2, _$showMore5;
        (_$showMore2 = $showMore) === null || _$showMore2 === void 0 || _$showMore2.parent().append($showMore);
        if (collection.hasMore()) {
          var _$showMore3;
          const moreCount = collection.total - collection.offset - collection.length - collection.lengthCorrection;
          this.$el.find('.more-count').text(this.getNumberUtil().formatInt(moreCount));
          (_$showMore3 = $showMore) === null || _$showMore3 === void 0 || _$showMore3.removeClass('hidden');
          $container.addClass('has-show-more');
        } else {
          var _$showMore4;
          (_$showMore4 = $showMore) === null || _$showMore4 === void 0 || _$showMore4.remove();
          $container.removeClass('has-show-more');
        }
        (_$showMore5 = $showMore) === null || _$showMore5 === void 0 || _$showMore5.children('a').removeClass('disabled');
        if (this.allResultIsChecked) {
          this.$el.find('input.record-checkbox').attr('disabled', 'disabled').prop('checked', true);
        }
        if (!options.skipNotify) {
          _ui.default.notify(false);
        }
        if (callback) {
          callback.call(this);
        }
        this.trigger('after:show-more', lengthBefore);
      };
      const initialCount = collection.length;
      const success = () => {
        var _$showMore6;
        if (!options.skipNotify) {
          _ui.default.notify(false);
        }
        (_$showMore6 = $showMore) === null || _$showMore6 === void 0 || _$showMore6.addClass('hidden');
        $container.removeClass('has-show-more');
        const rowCount = collection.length - initialCount;
        let rowsReady = 0;
        if (collection.length <= initialCount) {
          final();
        }
        for (let i = initialCount; i < collection.length; i++) {
          var _$list;
          const model = collection.at(i);
          const existingRow = this.getDomRowItem(model.id);
          if (existingRow) {
            existingRow.remove();
          }
          (_$list = $list) === null || _$list === void 0 || _$list.append(this.getRowContainerHtml(model.id));
          this.buildRow(i, model, async view => {
            await view.render();
            rowsReady++;
            if (rowsReady === rowCount) {
              final();
            }
          });
        }
        this.noRebuild = true;
      };
      const onUpdate = (_c, o) => {
        if (o.changes.merged.length) {
          collection.lengthCorrection += o.changes.merged.length;
        }
      };
      this.listenToOnce(collection, 'update', onUpdate);

      // If using promise callback, then need to pass `noRebuild: true`.
      collection.fetch({
        success: success,
        remove: false,
        more: true
      }).catch(() => this.stopListening(collection, 'update', onUpdate));
    }
    getDomRowItem(id) {
      // noinspection BadExpressionStatementJS
      id;
      return null;
    }

    /**
     * Compose a row-container HTML.
     *
     * @param {string} id A record ID.
     * @return {string} HTML.
     */
    getRowContainerHtml(id) {
      const tr = document.createElement('tr');
      tr.dataset.id = id;
      tr.classList.add('list-row');
      return tr.outerHTML;
    }
    async actionQuickView(data) {
      data = data || {};
      const id = data.id;
      if (!id) {
        console.error("No id.");
        return;
      }
      let model = null;
      if (this.collection) {
        model = this.collection.get(id);
      }
      let scope = data.scope;
      if (!scope && model) {
        scope = model.entityType;
      }
      if (!scope) {
        scope = this.scope;
      }
      if (!scope) {
        console.error("No scope.");
        return;
      }
      if (this.quickDetailDisabled) {
        this.getRouter().navigate(`#${scope}/view/${id}`, {
          trigger: true
        });
        return;
      }
      const rootUrl = this.options.keepCurrentRootUrl ? this.getRouter().getCurrentUrl() : undefined;
      const helper = new _recordModal.default();
      await helper.showDetail(this, {
        id: id,
        entityType: scope,
        model: model ?? null,
        rootUrl: rootUrl,
        editDisabled: this.quickEditDisabled,
        beforeSave: m => {
          if (!model) {
            // @todo Revise.
            return;
          }
          this.trigger('before:save', m);
        },
        afterSave: m => {
          if (!model) {
            return;
          }
          this.trigger('after:save', m);
        },
        afterDestroy: m => {
          if (!model) {
            return;
          }
          this.removeRecordFromList(m.id);
        }
      });
    }

    // noinspection JSUnusedGlobalSymbols
    async actionQuickEdit(data) {
      data = data || {};
      const id = data.id;
      if (!id) {
        console.error("No id.");
        return;
      }
      let model = null;
      if (this.collection) {
        model = this.collection.get(id);
      }
      let scope = data.scope;
      if (!scope && model) {
        scope = model.entityType;
      }
      if (!scope) {
        scope = this.scope;
      }
      if (!scope) {
        console.error("No scope.");
        return;
      }
      if (!this.quickEditDisabled) {
        const helper = new _recordModal.default();
        const rootUrl = this.options.keepCurrentRootUrl ? this.getRouter().getCurrentUrl() : undefined;
        await helper.showEdit(this, {
          entityType: scope,
          id: id,
          model: model ?? null,
          fullFormDisabled: data.noFullForm,
          rootUrl: rootUrl,
          beforeSave: m => {
            this.trigger('before:save', m);
          },
          afterSave: m => {
            const model = this.collection.get(m.id);
            if (model) {
              model.setMultiple(m.getClonedAttributes(), {
                sync: true
              });
            }
            this.trigger('after:save', m);
          },
          returnDispatchParams: {
            controller: scope,
            action: null,
            options: {
              isReturn: true
            }
          }
        });
        return;
      }
      const options = {
        id: id,
        model: this.collection.get(id),
        returnUrl: this.getRouter().getCurrentUrl(),
        returnDispatchParams: {
          controller: scope,
          action: null,
          options: {
            isReturn: true
          }
        }
      };
      if (this.options.keepCurrentRootUrl) {
        options.rootUrl = this.getRouter().getCurrentUrl();
      }
      this.getRouter().navigate(`#${scope}/edit/${id}`, {
        trigger: false
      });
      this.getRouter().dispatch(scope, 'edit', options);
    }

    /**
     * Compose a row selector.
     */
    getRowSelector(id) {
      return `tr.list-row[data-id="${id}"]`;
    }

    // noinspection JSUnusedGlobalSymbols
    async actionQuickRemove(data) {
      data = data || {};
      const id = data.id;
      if (!id) {
        return;
      }
      const model = this.collection.get(id);
      if (!model) {
        throw new Error("No model.");
      }
      const index = this.collection.indexOf(model);
      if (!this.getAcl().checkModel(model, 'delete')) {
        _ui.default.error(this.translate('Access denied'));
        return;
      }
      await this.confirm({
        message: this.translate('removeRecordConfirmation', 'messages', this.scope),
        confirmText: this.translate('Remove')
      });
      this.collection.trigger('model-removing', id);
      this.collection.remove(model);
      _ui.default.notifyWait();
      try {
        await model.destroy({
          wait: true,
          fromList: true
        });
      } catch (e) {
        if (!this.collection.models.includes(model)) {
          this.collection.add(model, {
            at: index
          });
        }
        return;
      }
      _ui.default.success(this.translate('Removed'));
      this.trigger('after:delete', model);
      this.removeRecordFromList(id);
    }

    /**
     * @param id An ID.
     */
    removeRecordFromList(id) {
      if (this.collection.total > 0) {
        this.collection.total--;
        this.collection.trigger('update-total');
      }
      this.collection.remove(id);
      this.$el.find('.total-count-span').text(this.collection.total.toString());
      let index = this.checkedList.indexOf(id);
      if (index !== -1) {
        this.checkedList.splice(index, 1);
      }
      const key = id;
      this.clearView(key);
      index = this.rowList.indexOf(key);
      if (~index) {
        this.rowList.splice(index, 1);
      }
      this.removeRowHtml(id);
    }

    /**
     * @param {string} id An ID.
     */
    removeRowHtml(id) {
      this.$el.find(this.getRowSelector(id)).remove();
      if (this.collection.length === 0 && (this.collection.total === 0 || this.collection.total === -2)) {
        this.reRender();
      }
    }

    /**
     * @param id An ID.
     */
    isIdChecked(id) {
      return this.checkedList.indexOf(id) !== -1;
    }
    setupRowActionDefs() {
      this._rowActionHandlers = {};
      const list = this.options.additionalRowActionList;
      if (!list) {
        return;
      }
      this._additionalRowActionList = list;
      const defs = this.getMetadata().get(`clientDefs.${this.scope}.rowActionDefs`) || {};
      const promiseList = list.map(async action => {
        const itemDefs = defs[action] || {};
        if (!itemDefs.handler) {
          return Promise.resolve();
        }
        const Handler = await Espo.loader.requirePromise(itemDefs.handler);
        this._rowActionHandlers[action] = new Handler(this);
        return true;
      });
      this.wait(Promise.all(promiseList));
    }

    // noinspection JSUnusedGlobalSymbols
    actionRowAction(data) {
      const action = data.actualAction;
      const id = data.id;
      if (!action) {
        return;
      }
      const handler = (this._rowActionHandlers || {})[action];
      if (!handler) {
        console.warn(`No handler for action ${action}.`);
        return;
      }
      const model = this.collection.get(id);
      if (!model) {
        return;
      }
      handler.process(model, action);
    }

    /**
     * @todo Move to `views/record/list`.
     */
    setupSettings() {
      if (!this.options.settingsEnabled || !this.collection.entityType || !this.layoutName || !this.entityType) {
        return;
      }
      if (!this.forceSettings && !this.getMetadata().get(`scopes.${this.entityType}.object`) || this.getConfig().get('listViewSettingsDisabled')) {
        return;
      }
      if (this.settingsDisabled) {
        return;
      }
      this._listSettingsHelper = this.options.settingsHelper ?? new _settings2.default(this.entityType, this.layoutName, this.getUser().id, {
        useStorage: this.options.storeSettings ?? true
      });
      const view = new _settings.default({
        layoutProvider: () => this.listLayout,
        helper: this._listSettingsHelper,
        entityType: this.entityType,
        columnResize: this.columnResize,
        onChange: options => this.afterSettingsChange(options)
      });
      this.assignView('settings', view, '.settings-container');
    }

    /**
     * @todo Move to `views/record/list`.
     */
    async afterSettingsChange(options) {
      if (options.action === 'toggleColumnResize') {
        await this.reRender();
        return;
      }
      if (options.action === 'toggleColumn' || options.action === 'resetToDefault') {
        const selectAttributes = await this.getSelectAttributeList();
        if (selectAttributes) {
          this.collection.data.select = selectAttributes.join(',');
        }
      }
      if (options.action === 'toggleColumn' && !this._listSettingsHelper.getHiddenColumnMap()[options.column] && this._columnResizeHelper) {
        const helper = new _columnWidthControl.default({
          view: this,
          helper: this._listSettingsHelper,
          layoutProvider: () => this.listLayout
        });
        helper.adjust();
      }
      this._internalLayout = null;
      _ui.default.notifyWait();
      await this.collection.fetch();
      _ui.default.notify();
    }

    /**
     * Whether the pagination is enabled.
     *
     * @return {boolean}
     */
    hasPagination() {
      return this.pagination;
    }

    /**
     * Hide a mass action. Requires re-render.
     *
     * @param name An action name.
     * @since 8.4.0
     */
    hideMassAction(name) {
      if (!this.massActionDefs[name]) {
        this.massActionDefs[name] = {};
      }
      this.massActionDefs[name].hidden = true;
    }

    /**
     * Show a mass action. Requires re-render.
     *
     * @param name An action name.
     * @since 8.4.0
     */
    showMassAction(name) {
      if (!this.massActionDefs[name]) {
        this.massActionDefs[name] = {};
      }
      this.massActionDefs[name].hidden = false;
    }
    getMassActionDataList() {
      const groups = [];
      this.massActionList.forEach(action => {
        const item = this.massActionDefs[action];

        // For bc.
        // @ts-ignore
        if (item === false) {
          return;
        }
        const index = (!item || item.groupIndex === undefined ? 9999 : item.groupIndex) + 100;
        if (groups[index] === undefined) {
          groups[index] = [];
        }
        groups[index].push(action);
      });
      const list = [];
      groups.forEach(subList => {
        subList.forEach(it => list.push(it));
        list.push(false);
      });
      return list.map(name => {
        if (name === false) {
          return false;
        }
        const defs = this.massActionDefs[name] || {};
        return {
          name,
          hidden: defs.hidden,
          iconClass: defs.iconClass
        };
      });
    }

    /**
     * Uncheck all.
     *
     * @since 8.4.0
     */
    uncheckAll() {
      if (this.allResultIsChecked) {
        this.unselectAllResult();
      }
      this.checkedList.forEach(id => this.uncheckRecord(id));
    }

    /**
     * To temporarily disable checkboxes.
     *
     * @since 8.4.0
     */
    disableCheckboxes() {
      if (!this.checkboxes) {
        return;
      }
      this._disabledCheckboxes = true;
      this.uncheckAll();
      this.$el.find('input.record-checkbox').attr('disabled', 'disabled');
      if (this.$selectAllCheckbox) {
        this.$selectAllCheckbox.attr('disabled', 'disabled');
      }
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * To enabled temporarily disabled checkboxes.
     *
     * @since 8.4.0
     */
    enableCheckboxes() {
      if (!this.checkboxes) {
        return;
      }
      this._disabledCheckboxes = false;
      this.$el.find('input.record-checkbox').removeAttr('disabled');
      if (this.$selectAllCheckbox) {
        this.$selectAllCheckbox.removeAttr('disabled');
      }
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * Checkboxes are disabled.
     *
     * @since 9.0.1
     */
    checkboxesAreDisabled() {
      return this._disabledCheckboxes || !this.checkboxes;
    }

    /**
     * Rebuild the internal layout.
     *
     * @since 8.4.0
     */
    rebuild() {
      return new Promise(resolve => {
        this._internalLayout = null;
        this.buildRows(() => resolve(undefined));
      });
    }
  }
  var _default = _exports.default = ListBaseRecordView;
});

define("views/fields/text", ["exports", "views/fields/base", "helpers/misc/mailto", "views/modals/text-preview", "ui"], function (_exports, _base, _mailto, _textPreview, _ui) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  _mailto = _interopRequireDefault(_mailto);
  _textPreview = _interopRequireDefault(_textPreview);
  _ui = _interopRequireDefault(_ui);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * Parameters.
   */

  /**
   * Options.
   */

  /**
   * A text field.
   */
  class TextFieldView extends _base.default {
    type = 'text';
    listTemplate = 'fields/text/list';
    detailTemplate = 'fields/text/detail';
    editTemplate = 'fields/text/edit';
    searchTemplate = 'fields/text/search';

    /**
     * Show-more is applied.
     *
     * @internal
     */
    seeMoreText = false;
    rowsDefault = 50000;
    rowsMin = 2;
    seeMoreDisabled = false;
    cutHeight = 200;
    noResize = false;
    changeInterval = 5;
    shrinkThreshold = 10;
    searchTypeList = ['contains', 'startsWith', 'equals', 'endsWith', 'like', 'notContains', 'notLike', 'isEmpty', 'isNotEmpty'];
    setup() {
      super.setup();
      this.addActionHandler('seeMoreText', () => this.seeMore());
      this.addActionHandler('mailTo', (_, target) => this.mailTo(target.dataset.emailAddress));
      this.maxRows = this.params.rows || this.rowsDefault;
      this.noResize = this.options.noResize || this.params.noResize || this.noResize;
      this.seeMoreDisabled = this.seeMoreDisabled || this.params.seeMoreDisabled || false;
      this.autoHeightDisabled = this.options.autoHeightDisabled || this.params.autoHeightDisabled || this.autoHeightDisabled;
      if (this.params.cutHeight) {
        this.cutHeight = this.params.cutHeight;
      }
      this.rowsMin = this.options.rowsMin || this.params.rowsMin || this.rowsMin;
      if (this.maxRows < this.rowsMin) {
        this.rowsMin = this.maxRows;
      }
      this.on('remove', () => {
        $(window).off('resize.see-more-' + this.cid);
        if (this.textAreaElement) {
          this.textAreaElement.removeEventListener('keydown', this.onKeyDownMarkdownBind);
          this.textAreaElement = null;
        }
      });
      if (this.params.preview) {
        this.addHandler('input', 'textarea', (_, target) => {
          const text = target.value;
          if (!this.previewButtonElement) {
            return;
          }
          if (text) {
            this.previewButtonElement.classList.remove('hidden');
          } else {
            this.previewButtonElement.classList.add('hidden');
          }
        });
        this.addActionHandler('previewText', () => this.preview());
      }
      this.listenTo(this.model, `change:${this.name}`, (_m, _v, o) => {
        if (o.ui === true && this.mode === this.MODE_EDIT) {
          // After changing the field content it's reasonable to show all text
          // when returning to the detail mode.
          this.seeMoreText = true;
        }
      });
      this.controlSeeMoreBind = this.controlSeeMore.bind(this);
      this.onPasteBind = this.onPaste.bind(this);
      this.onKeyDownMarkdownBind = this.onKeyDownMarkdown.bind(this);
    }
    setupSearch() {
      this.addHandler('change', 'select.search-type', (_, target) => {
        this.handleSearchType(target.type);
      });
    }
    data() {
      const data = super.data();
      if (this.model.get(this.name) !== null && this.model.get(this.name) !== '' && this.model.has(this.name)) {
        data.isNotEmpty = true;
      }
      if (this.mode === this.MODE_SEARCH) {
        var _this$searchParams;
        if (typeof ((_this$searchParams = this.searchParams) === null || _this$searchParams === void 0 ? void 0 : _this$searchParams.value) === 'string') {
          var _this$searchParams2;
          this.searchData.value = (_this$searchParams2 = this.searchParams) === null || _this$searchParams2 === void 0 ? void 0 : _this$searchParams2.value;
        }
      }
      if (this.mode === this.MODE_EDIT) {
        data.rows = this.autoHeightDisabled ? this.maxRows : this.rowsMin;
      }
      data.valueIsSet = this.model.has(this.name);
      if (this.isReadMode()) {
        data.isCut = this.isCut();
        if (data.isCut) {
          data.cutHeight = this.cutHeight;
        }
        data.displayRawText = this.params.displayRawText;
      }
      data.htmlValue = undefined;
      data.noResize = this.noResize || !this.autoHeightDisabled && !this.params.rows;
      data.preview = this.params.preview && !this.params.displayRawText;
      return data;
    }
    handleSearchType(type) {
      if (['isEmpty', 'isNotEmpty'].includes(type)) {
        this.$el.find('input.main-element').addClass('hidden');
      } else {
        this.$el.find('input.main-element').removeClass('hidden');
      }
    }
    getValueForDisplay() {
      const text = this.model.get(this.name);
      return text || '';
    }

    /**
     * @internal
     */
    controlTextareaHeight(lastHeight) {
      var _this$$element, _this$$element2, _this$$element3, _this$$element4;
      const scrollHeight = (_this$$element = this.$element) === null || _this$$element === void 0 ? void 0 : _this$$element.prop('scrollHeight');
      const clientHeight = (_this$$element2 = this.$element) === null || _this$$element2 === void 0 ? void 0 : _this$$element2.prop('clientHeight');
      if (typeof lastHeight === 'undefined' && clientHeight === 0) {
        setTimeout(this.controlTextareaHeight.bind(this), 10);
        return;
      }
      const element = (_this$$element3 = this.$element) === null || _this$$element3 === void 0 ? void 0 : _this$$element3.get(0);
      if (!element || element.value === undefined) {
        return;
      }
      const length = element.value.length;
      if (this._lastLength === undefined) {
        this._lastLength = length;
      }
      if (length > this._lastLength) {
        this._lastLength = length;
      }
      if (clientHeight === lastHeight) {
        // @todo Revise.
        return;
      }
      if (scrollHeight > clientHeight + 1) {
        const rows = element.rows;
        if (this.maxRows && rows >= this.maxRows) {
          return;
        }
        element.rows++;
        this.controlTextareaHeight(clientHeight);
        return;
      }
      if (((_this$$element4 = this.$element) === null || _this$$element4 === void 0 ? void 0 : _this$$element4.val()).length === 0) {
        element.rows = this.rowsMin;
        return;
      }
      const tryShrink = () => {
        const rows = element.rows;
        if (this.rowsMin && rows - 1 <= this.rowsMin) {
          return;
        }
        element.rows--;
        if (element.scrollHeight > element.clientHeight + 1) {
          this.controlTextareaHeight();
          return;
        }
        tryShrink();
      };
      if (length < this._lastLength - this.shrinkThreshold) {
        this._lastLength = length;
        tryShrink();
      }
    }
    isCut() {
      return !this.seeMoreText && !this.seeMoreDisabled;
    }
    controlSeeMore() {
      if (!this.isCut()) {
        return;
      }
      if (this.$text.height() > this.cutHeight) {
        this.$seeMoreContainer.removeClass('hidden');
        this.$textContainer.addClass('cut');
      } else {
        this.$seeMoreContainer.addClass('hidden');
        this.$textContainer.removeClass('cut');
      }
    }
    afterRender() {
      this.textAreaElement = null;
      if (this.mode === this.MODE_EDIT) {
        this.textAreaElement = this.element ? this.element.querySelector('textarea') : null;
      }
      super.afterRender();
      if (this.isReadMode()) {
        $(window).off(`resize.see-more-${this.cid}`);
        this.$textContainer = this.$el.find('> .complex-text-container');
        this.$text = this.$textContainer.find('> .complex-text');
        this.$seeMoreContainer = this.$el.find('> .see-more-container');
        if (this.isCut()) {
          this.controlSeeMore();
          if (this.model.get(this.name) && this.$text.height() === 0) {
            this.$textContainer.addClass('cut');
            setTimeout(this.controlSeeMore.bind(this), 50);
          }
          if (this.recordHelper) {
            this.listenTo(this.recordHelper, 'panel-show', () => this.controlSeeMore());
          }
          this.on('panel-show-propagated', () => this.controlSeeMore());
          $(window).on('resize.see-more-' + this.cid, () => {
            this.controlSeeMore();
          });

          // @todo Revise stream post with empty text.

          this.element.querySelectorAll('img').forEach(image => {
            image.addEventListener('load', this.controlSeeMoreBind);
          });
        }
      }
      if (this.mode === this.MODE_EDIT) {
        const text = this.getValueForDisplay();
        if (text) {
          var _this$$element5;
          (_this$$element5 = this.$element) === null || _this$$element5 === void 0 || _this$$element5.val(text);
        }
        this.previewButtonElement = this.element ? this.element.querySelector('a[data-action="previewText"]') : null;
        const textAreaElement = this.textAreaElement;
        if (this.params.attachmentField && textAreaElement) {
          textAreaElement.removeEventListener('paste', this.onPasteBind);
          textAreaElement.addEventListener('paste', this.onPasteBind);
        }
        if (!this.params.displayRawText) {
          this.initTextareaMarkdownHelper();
        }
      }
      if (this.mode === this.MODE_SEARCH) {
        var _this$$element6;
        const type = this.$el.find('select.search-type').val();
        this.handleSearchType(type);
        this.$el.find('select.search-type').on('change', () => {
          this.trigger('change');
        });
        (_this$$element6 = this.$element) === null || _this$$element6 === void 0 || _this$$element6.on('input', () => {
          this.trigger('change');
        });
      }
      if (this.mode === this.MODE_EDIT && !this.autoHeightDisabled) {
        var _this$$element8;
        if (!this.autoHeightDisabled) {
          var _this$$element7;
          this.controlTextareaHeight();
          (_this$$element7 = this.$element) === null || _this$$element7 === void 0 || _this$$element7.on('input', () => this.controlTextareaHeight());
        }
        let lastChangeKeydown = Date.now();
        const changeKeydownInterval = this.changeInterval * 1000;
        (_this$$element8 = this.$element) === null || _this$$element8 === void 0 || _this$$element8.on('keydown', () => {
          if (Date.now() - lastChangeKeydown > changeKeydownInterval) {
            this.trigger('change');
            lastChangeKeydown = Date.now();
          }
        });
      }
    }
    fetch() {
      var _this$$element9;
      const data = {};
      let value = ((_this$$element9 = this.$element) === null || _this$$element9 === void 0 ? void 0 : _this$$element9.val()) || null;
      if (value && value.trim() === '') {
        value = '';
      }
      data[this.name] = value;
      return data;
    }
    fetchSearch() {
      var _this$$element0;
      const type = this.fetchSearchType() || 'startsWith';
      if (type === 'isEmpty') {
        return {
          type: 'or',
          value: [{
            type: 'isNull',
            field: this.name
          }, {
            type: 'equals',
            field: this.name,
            value: ''
          }],
          data: {
            type: type
          }
        };
      }
      if (type === 'isNotEmpty') {
        return {
          type: 'and',
          value: [{
            type: 'notEquals',
            field: this.name,
            value: ''
          }, {
            type: 'isNotNull',
            field: this.name,
            value: null
          }],
          data: {
            type: type
          }
        };
      }
      const value = (_this$$element0 = this.$element) === null || _this$$element0 === void 0 || (_this$$element0 = _this$$element0.val()) === null || _this$$element0 === void 0 || (_this$$element0 = _this$$element0.toString()) === null || _this$$element0 === void 0 ? void 0 : _this$$element0.trim();
      if (value) {
        return {
          value: value,
          type: type
        };
      }
      return null;
    }
    getSearchType() {
      var _this$searchParams3, _this$searchParams4;
      return this.getSearchParamsData().type ?? ((_this$searchParams3 = this.searchParams) === null || _this$searchParams3 === void 0 ? void 0 : _this$searchParams3.typeFront) ?? ((_this$searchParams4 = this.searchParams) === null || _this$searchParams4 === void 0 ? void 0 : _this$searchParams4.type) ?? null;
    }
    async mailTo(emailAddress) {
      const attributes = {
        status: 'Draft',
        to: emailAddress
      };
      const helper = new _mailto.default();
      if (helper.toUse()) {
        document.location.href = helper.composeLink(attributes);
        return;
      }
      const viewName = 'views/modals/compose-email';
      _ui.default.notifyWait();
      const view = await this.createView('quickCreate', viewName, {
        attributes: attributes
      });
      await view.render();
      _ui.default.notify();
    }

    /**
     * Show the preview modal.
     *
     * @since 9.0.0
     */
    async preview() {
      const text = this.model.attributes[this.name] || '';
      const view = new _textPreview.default({
        text: text
      });
      await this.assignView('modal', view);
      await view.render();
    }
    onPaste(event) {
      var _event$clipboardData;
      const items = (_event$clipboardData = event.clipboardData) === null || _event$clipboardData === void 0 ? void 0 : _event$clipboardData.items;
      if (!items) {
        return;
      }
      for (let i = 0; i < items.length; i++) {
        var _this$recordHelper;
        if (!items[i].type.startsWith('image')) {
          continue;
        }
        const blob = items[i].getAsFile();
        (_this$recordHelper = this.recordHelper) === null || _this$recordHelper === void 0 || _this$recordHelper.trigger('upload-files:' + this.params.attachmentField, [blob]);
      }
    }

    /**
     * @since 9.0.0
     */
    async seeMore() {
      this.seeMoreText = true;
      await this.reRender();
    }
    initTextareaMarkdownHelper() {
      if (!this.textAreaElement) {
        return;
      }
      this.textAreaElement.addEventListener('keydown', this.onKeyDownMarkdownBind);
    }
    _lastEnteredKeyIsEnter = false;
    onKeyDownMarkdown(event) {
      const key = Espo.Utils.getKeyFromKeyEvent(event);
      if (key !== 'Enter') {
        this._lastEnteredKeyIsEnter = false;
        this.handleKeyDownMarkdown(event, key);
        return;
      }
      const lastEnteredKeyIsEnter = this._lastEnteredKeyIsEnter;
      this._lastEnteredKeyIsEnter = true;
      const target = event.target;
      if (!(target instanceof HTMLTextAreaElement)) {
        return;
      }
      const {
        selectionStart,
        selectionEnd,
        value
      } = target;
      const before = value.substring(0, selectionStart);
      const after = value.substring(selectionEnd);

      // Last line, a list item syntax.
      const match = before.match(/(^|\n)( *[-*]|\d+\.) ([^\n]*)$/);
      if (!match) {
        // Prevent unwanted scroll applied by the browser on enter.
        const previousWindowScroll = window.scrollY;
        setTimeout(() => window.scrollTo({
          top: previousWindowScroll
        }), 0);
        this.controlTextareaHeight();
        return;
      }
      event.preventDefault();
      if (match[3].trim() === '' && lastEnteredKeyIsEnter) {
        target.value = before.substring(0, match.index) + '\n' + after;
        target.selectionStart = target.selectionEnd = target.value.length - after.length;
        this.controlTextareaHeight();
        return;
      }
      let itemPart = match[2];
      const matchPart = itemPart.match(/( *)(\d+)/);
      if (matchPart) {
        const number = parseInt(matchPart[2]);
        if (!isNaN(number)) {
          itemPart = matchPart[1] + (number + 1).toString() + '.';
        }
      }
      const newLine = "\n" + itemPart + " ";
      target.value = before + newLine + after;
      target.selectionStart = target.selectionEnd = target.value.length - after.length;
      this.controlTextareaHeight();
    }
    handleKeyDownMarkdown(event, key) {
      const target = event.target;
      if (!(target instanceof HTMLTextAreaElement)) {
        return;
      }
      const toggleWrap = wrapper => {
        const {
          selectionStart,
          selectionEnd
        } = target;
        let text = target.value.substring(selectionStart, selectionEnd);
        if (text === '') {
          return;
        }
        let textPrevious = text;
        text = text.trimStart();
        const startPart = textPrevious.substring(0, textPrevious.length - text.length);
        textPrevious = text;
        text = text.trimEnd();
        const endPart = textPrevious.substring(text.length);
        if (text.startsWith(wrapper) && text.endsWith(wrapper)) {
          text = text.slice(wrapper.length, -wrapper.length);
        } else {
          text = wrapper + text + wrapper;
        }
        const newText = startPart + text + endPart;

        // noinspection JSDeprecatedSymbols
        document.execCommand('insertText', false, newText);
        const newStart = selectionStart + startPart.length;
        target.setSelectionRange(newStart, newStart + text.length);
        event.preventDefault();
        event.stopPropagation();
      };
      if (key === 'Control+KeyB') {
        toggleWrap('**');
      }
      if (key === 'Control+KeyI') {
        toggleWrap('_');
      }
    }
  }
  var _default = _exports.default = TextFieldView;
});

define("views/fields/link", ["exports", "views/fields/base", "helpers/record-modal", "ui/autocomplete", "helpers/field/cascade-links", "ajax", "ui"], function (_exports, _base, _recordModal, _autocomplete, _cascadeLinks, _ajax, _ui) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  _recordModal = _interopRequireDefault(_recordModal);
  _autocomplete = _interopRequireDefault(_autocomplete);
  _cascadeLinks = _interopRequireDefault(_cascadeLinks);
  _ajax = _interopRequireDefault(_ajax);
  _ui = _interopRequireDefault(_ui);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * Parameters.
   */

  /**
   * Options.
   */

  /**
   * A link field (belongs-to relation).
   */
  class LinkFieldView extends _base.default {
    type = 'link';
    listTemplate = 'fields/link/list';
    detailTemplate = 'fields/link/detail';
    editTemplate = 'fields/link/edit';
    searchTemplate = 'fields/link/search';

    /**
     * A name attribute name.
     */

    /**
     * An ID attribute name.
     */

    /**
     * A foreign entity type.
     */

    /**
     * A select-record view.
     */
    selectRecordsView = 'views/modals/select-records';

    /**
     * Autocomplete disabled.
     */
    autocompleteDisabled = false;

    /**
     * Create disabled.
     */
    createDisabled = false;

    /**
     * To display the create button.
     */
    createButton = false;

    /**
     * Force create button even is disabled in clientDefs > relationshipPanels.
     */
    forceCreateButton = false;

    /**
     * A search type list.
     */
    searchTypeList = ['is', 'isEmpty', 'isNotEmpty', 'isNot', 'isOneOf', 'isNotOneOf'];

    /**
     * A primary filter list that will be available when selecting a record.
     */
    selectFilterList = null;

    /**
     * A select primary filter.
     */
    selectPrimaryFilterName = null;

    /**
     * A select bool filter list.
     */
    selectBoolFilterList = null;

    /**
     * An autocomplete max record number.
     */
    autocompleteMaxCount = null;

    /**
     * Select all attributes.
     */
    forceSelectAllAttributes = false;
    mandatorySelectAttributeList = null;

    /**
     * Trigger autocomplete on empty input.
     */
    autocompleteOnEmpty = false;

    /**
     * A link element class name. Applicable in the detail mode.
     *
     * @since 9.1.6
     */
    linkClass = null;

    /**
     * @since 9.2.5
     */

    /**
     * Panel definitions.
     */

    data() {
      let nameValue = this.model.has(this.nameName) ? this.model.get(this.nameName) : this.model.get(this.idName);
      if (nameValue === null) {
        nameValue = this.model.get(this.idName);
      }
      if (this.isReadMode() && !nameValue && this.model.get(this.idName)) {
        nameValue = this.translate(this.foreignScope, 'scopeNames');
      }
      let iconHtml = null;
      if (this.isDetailMode() || this.isListMode()) {
        iconHtml = this.getHelper().getScopeColorIconHtml(this.foreignScope);
      }
      const createButton = this.createButton && (!this.createDisabled || this.forceCreateButton);
      let linkClass = this.linkClass;
      if (!linkClass && this.isDetailMode()) {
        linkClass = 'text-record';
      }
      return {
        ...super.data(),
        idName: this.idName,
        nameName: this.nameName,
        idValue: this.model.get(this.idName),
        nameValue: nameValue,
        foreignScope: this.foreignScope,
        valueIsSet: this.model.has(this.idName),
        iconHtml: iconHtml,
        url: this.getUrl(),
        createButton: createButton,
        linkClass: linkClass
      };
    }
    getUrl() {
      const id = this.model.get(this.idName);
      if (!id) {
        return null;
      }
      return `#${this.foreignScope}/view/${id}`;
    }

    /**
     * Get advanced filters (field filters) to be applied when select a record.
     * Can be extended.
     */
    getSelectFilters() {
      return null;
    }

    /**
     * Get a select bool filter list. Applied when select a record.
     * Can be extended.
     */
    getSelectBoolFilterList() {
      return this.selectBoolFilterList;
    }

    /**
     * Get a select primary filter. Applied when select a record.
     * Can be extended.
     */
    getSelectPrimaryFilterName() {
      return this.selectPrimaryFilterName;
    }

    /**
     * Get a primary filter list that will be available when selecting a record.
     * Can be extended.
     */
    getSelectFilterList() {
      return this.selectFilterList;
    }

    /**
     * Attributes to pass to a model when creating a new record.
     * Can be extended.
     */
    getCreateAttributes() {
      const attributeMap = this.panelDefs.createAttributeMap ?? {};
      const attributes = {};
      Object.keys(attributeMap).forEach(attribute => {
        attributes[attributeMap[attribute]] = this.model.get(attribute);
      });
      return {
        ...attributes,
        ...this._getCascadingCreateAttributes()
      };
    }
    setup() {
      this.addHandler('auxclick', 'a[href]:not([role="button"])', e => {
        this.onAuxClickLink(e);
      });
      this.nameName = this.name + 'Name';
      this.idName = this.name + 'Id';
      this.foreignScope = this.options.foreignScope || this.foreignScope;
      this.foreignScope = this.foreignScope ?? this.params.entity ?? this.model.getFieldParam(this.name, 'entity') ?? this.model.getLinkParam(this.name, 'entity');
      this.foreignNameAttribute = this.model.getLinkParam(this.name, 'foreignName') ?? this.getMetadata().get(`clientDefs.${this.foreignScope}.nameAttribute`) ?? 'name';
      if ('createDisabled' in this.options) {
        this.createDisabled = this.options.createDisabled;
      }
      if (!this.isListMode()) {
        this.addActionHandler('selectLink', () => this.actionSelect());
        this.addActionHandler('clearLink', () => this.clearLink());
      }
      if (this.isSearchMode()) {
        this.addActionHandler('selectLinkOneOf', () => this.actionSelectOneOf());
        this.addActionHandler('clearLinkOneOf', (_e, target) => this.deleteLinkOneOf(target.dataset.id));
      }
      this.autocompleteOnEmpty = this.params.autocompleteOnEmpty || this.autocompleteOnEmpty;
      this.createButton = this.params.createButton || this.createButton;
      if (this.createButton && !this.getAcl().checkScope(this.foreignScope, 'create')) {
        this.createButton = false;
      }
      if (this.createButton) {
        this.addActionHandler('createLink', () => this.actionCreateLink());
      }
      if (this.entityType) {
        this.panelDefs = this.getMetadata().get(`clientDefs.${this.entityType}.relationshipPanels.${this.name}`) ?? {};
      } else {
        this.panelDefs = {};
      }
      if (this.panelDefs.createDisabled) {
        this.createDisabled = true;
      }
    }
    onAuxClickLink(e) {
      if (!this.isReadMode()) {
        return;
      }
      const isCombination = e.button === 1 && (e.ctrlKey || e.metaKey);
      if (!isCombination) {
        return;
      }
      e.preventDefault();
      e.stopPropagation();
      this.quickView();
    }

    /**
     * Select.
     *
     * @param model A model.
     */
    select(model) {
      this.$elementName.val(model.get(this.foreignNameAttribute) ?? model.id);
      this.$elementId.val(model.id);
      if (this.mode === this.MODE_SEARCH) {
        this.searchData.idValue = model.id;
        this.searchData.nameValue = model.get(this.foreignNameAttribute) ?? model.id;
      }
      this.trigger('change');
      this.controlCreateButtonVisibility();
      const attributes = {};
      for (const [foreign, field] of Object.entries(this.getDependantForeignMap())) {
        attributes[field] = model.get(foreign);
      }
      this.getSelectFieldHandler().then(async handler => {
        this.model.setMultiple({
          ...attributes,
          ...(await handler.getAttributes(model))
        }, {
          fromField: this.name
        });
      });
      return Promise.resolve();
    }

    /**
     * Clear.
     */
    clearLink() {
      this.$elementName.val('');
      this.$elementId.val('');
      this.trigger('change');
      this.controlCreateButtonVisibility();
      for (const [, field] of Object.entries(this.getDependantForeignMap())) {
        this.model.unset(field, {
          fromField: this.name
        });
      }
      this.getSelectFieldHandler().then(handler => {
        handler.getClearAttributes().then(attributes => {
          this.model.setMultiple(attributes, {
            fromField: this.name
          });
        });
      });
    }
    controlCreateButtonVisibility() {
      if (!this.createButton) {
        return;
      }
      const $btn = this.$el.find('[data-action="createLink"]');
      this.model.get(this.idName) ? $btn.addClass('hidden') : $btn.removeClass('hidden');
    }
    getSelectFieldHandler() {
      if (!this.panelDefs.selectFieldHandler) {
        return Promise.resolve({
          getAttributes: _ => Promise.resolve({}),
          getClearAttributes: () => Promise.resolve({})
        });
      }
      return new Promise(async resolve => {
        const handler = this.panelDefs.selectFieldHandler;
        const Handler = await Espo.loader.requirePromise(handler);

        // Model is passed as of v8.2.
        const handlerImplementation = new Handler(this.getHelper(), this.model);
        resolve(handlerImplementation);
      });
    }
    setupSearch() {
      var _this$searchParams, _this$searchParams2;
      this.searchData.oneOfIdList = this.getSearchParamsData().oneOfIdList ?? ((_this$searchParams = this.searchParams) === null || _this$searchParams === void 0 ? void 0 : _this$searchParams.oneOfIdList) ?? [];
      this.searchData.oneOfNameHash = this.getSearchParamsData().oneOfNameHash ?? ((_this$searchParams2 = this.searchParams) === null || _this$searchParams2 === void 0 ? void 0 : _this$searchParams2.oneOfNameHash) ?? {};
      if (['is', 'isNot', 'equals'].includes(this.getSearchType())) {
        var _this$searchParams3, _this$searchParams4, _this$searchParams5, _this$searchParams6;
        this.searchData.idValue = this.getSearchParamsData().idValue ?? ((_this$searchParams3 = this.searchParams) === null || _this$searchParams3 === void 0 ? void 0 : _this$searchParams3.idValue) ?? ((_this$searchParams4 = this.searchParams) === null || _this$searchParams4 === void 0 ? void 0 : _this$searchParams4.value);
        this.searchData.nameValue = this.getSearchParamsData().nameValue ?? ((_this$searchParams5 = this.searchParams) === null || _this$searchParams5 === void 0 ? void 0 : _this$searchParams5.nameValue) ?? ((_this$searchParams6 = this.searchParams) === null || _this$searchParams6 === void 0 ? void 0 : _this$searchParams6.valueName);
      }
      this.addHandler('change', 'select.search-type', (_, target) => {
        this.handleSearchType(target.value);
      });
    }

    /**
     * Handle a search type.
     *
     * @param {string} type A type.
     */
    handleSearchType(type) {
      if (['is', 'isNot', 'isNotAndIsNotEmpty'].includes(type)) {
        this.$el.find('div.primary').removeClass('hidden');
      } else {
        this.$el.find('div.primary').addClass('hidden');
      }
      if (['isOneOf', 'isNotOneOf', 'isNotOneOfAndIsNotEmpty'].includes(type)) {
        this.$el.find('div.one-of-container').removeClass('hidden');
      } else {
        this.$el.find('div.one-of-container').addClass('hidden');
      }
    }

    /**
     * Get an autocomplete max record number. Can be extended.
     */
    getAutocompleteMaxCount() {
      if (this.autocompleteMaxCount) {
        return this.autocompleteMaxCount;
      }
      return this.getConfig().get('recordsPerPage');
    }
    getMandatorySelectAttributeList() {
      const list = this.mandatorySelectAttributeList || this.panelDefs.selectMandatoryAttributeList || [];
      const map = this.getDependantForeignMap();
      return [...list, ...Object.keys(map)];
    }
    getDependantForeignMap() {
      if (this._dependantForeignMap) {
        return this._dependantForeignMap;
      }
      const map = {};
      this.model.getFieldList().filter(it => {
        return this.model.getFieldType(it) === 'foreign' && this.model.getFieldParam(it, 'link') === this.name;
      }).forEach(field => {
        const foreign = this.model.getFieldParam(field, 'field');
        if (!foreign) {
          return;
        }
        map[foreign] = field;
      });
      this._dependantForeignMap = map;
      return map;
    }

    /**
     * Compose an autocomplete URL. Can be extended.
     *
     * @param q A query.
     */
    getAutocompleteUrl(q) {
      // noinspection BadExpressionStatementJS
      q;
      let url = this.foreignScope + '?maxSize=' + this.getAutocompleteMaxCount();
      if (!this.forceSelectAllAttributes) {
        const mandatorySelectAttributeList = this.getMandatorySelectAttributeList();
        let select = ['id', this.foreignNameAttribute];
        if (mandatorySelectAttributeList) {
          select = select.concat(mandatorySelectAttributeList);
        }
        url += '&select=' + select.join(',');
      }
      return new Promise(async resolve => {
        const filters = await this._getSelectFilters();
        if (filters.bool) {
          url += '&' + $.param({
            'boolFilterList': filters.bool
          });
        }
        if (filters.primary) {
          url += '&' + $.param({
            'primaryFilter': filters.primary
          });
        }
        if (filters.advanced && Object.keys(filters.advanced).length) {
          url += '&' + $.param({
            'where': filters.advanced
          });
        }
        const orderBy = filters.orderBy || this.panelDefs.selectOrderBy;
        const orderDirection = filters.orderBy ? filters.order : this.panelDefs.selectOrderDirection;
        if (orderBy) {
          url += '&' + $.param({
            orderBy: orderBy,
            order: orderDirection || 'asc'
          });
        }
        resolve(url);
      });
    }
    afterRender() {
      if (this.isEditMode() || this.isSearchMode()) {
        this.$elementId = this.$el.find('input[data-name="' + this.idName + '"]');
        this.$elementName = this.$el.find('input[data-name="' + this.nameName + '"]');
        this.$elementName.on('change', () => {
          if (this.$elementName.val() === '') {
            this.clearLink();
          }
        });
        this.$elementName.on('blur', e => {
          setTimeout(() => {
            if (!(this.mode === this.MODE_EDIT && this.model.has(this.nameName))) {
              return;
            }
            e.currentTarget.value = this.model.get(this.nameName) || this.model.get(this.idName);
          }, 100);
        });
        const $elementName = this.$elementName;
        if (!this.autocompleteDisabled) {
          var _this$$elementName;
          let lastAjaxPromise;
          const autocomplete = new _autocomplete.default((_this$$elementName = this.$elementName) === null || _this$$elementName === void 0 ? void 0 : _this$$elementName.get(0), {
            name: this.name,
            handleFocusMode: 2,
            autoSelectFirst: true,
            forceHide: true,
            triggerSelectOnValidInput: false,
            catchFastEnter: true,
            onSelect: async item => {
              const model = await this.getModelFactory().create(this.foreignScope);
              model.setMultiple(item.attributes);
              await this.select(model);
              this.$elementName.trigger('focus');
            },
            lookupFunction: async query => {
              if (!this.autocompleteOnEmpty && query.length === 0) {
                const list = await this.getOnEmptyAutocomplete();
                if (!list) {
                  return [];
                }
                return this._transformAutocompleteResult({
                  list: list
                });
              }
              const url = await this.getAutocompleteUrl(query);
              if (lastAjaxPromise && lastAjaxPromise.getReadyState() < 4) {
                lastAjaxPromise.abort();
              }
              lastAjaxPromise = _ajax.default.getRequest(url, {
                q: query
              });
              const response = await lastAjaxPromise;
              return this._transformAutocompleteResult(response);
            }
          });
          this.once('render remove', () => autocomplete.dispose());
          if (this.isSearchMode()) {
            const $elementOneOf = this.$el.find('input.element-one-of');
            let lastAjaxPromise;
            const autocomplete = new _autocomplete.default($elementOneOf.get(0), {
              minChars: 1,
              focusOnSelect: true,
              handleFocusMode: 3,
              autoSelectFirst: true,
              triggerSelectOnValidInput: false,
              forceHide: true,
              onSelect: async item => {
                const model = await this.getModelFactory().create(this.foreignScope);
                model.setMultiple(item.attributes);
                this.selectOneOf([model]);
                $elementOneOf.val('');
                setTimeout(() => $elementOneOf.focus(), 50);
              },
              lookupFunction: async query => {
                const url = await this.getAutocompleteUrl(query);
                if (lastAjaxPromise && lastAjaxPromise.getReadyState() < 4) {
                  lastAjaxPromise.abort();
                }
                lastAjaxPromise = _ajax.default.getRequest(url, {
                  q: query
                });
                const response = await lastAjaxPromise;
                return response.list.map(item => ({
                  value: item.name,
                  attributes: item
                }));
              }
            });
            this.once('render remove', () => autocomplete.dispose());
            this.$el.find('select.search-type').on('change', () => {
              this.trigger('change');
            });
          }
        }
        $elementName.on('change', () => {
          if (!this.isSearchMode() && !this.model.get(this.idName)) {
            $elementName.val(this.model.get(this.nameName));
          }
        });
      }
      if (this.isSearchMode()) {
        const type = this.$el.find('select.search-type').val();
        this.handleSearchType(type);
        if (['isOneOf', 'isNotOneOf', 'isNotOneOfAndIsNotEmpty'].includes(type)) {
          this.searchData.oneOfIdList.forEach(id => {
            this.addLinkOneOfHtml(id, this.searchData.oneOfNameHash[id]);
          });
        }
      }
    }
    _transformAutocompleteResult(response) {
      const list = [];
      response.list.forEach(item => {
        const name = item[this.foreignNameAttribute] || item.name || item.id;
        const attributes = item;
        if (this.foreignNameAttribute !== 'name') {
          attributes[this.foreignNameAttribute] = name;
        }
        list.push({
          id: item.id,
          name: name,
          data: item.id,
          value: name,
          attributes: attributes
        });
      });
      return list;
    }
    getValueForDisplay() {
      return this.model.get(this.nameName);
    }
    validateRequired() {
      if (this.isRequired()) {
        if (this.model.get(this.idName) == null) {
          const msg = this.translate('fieldIsRequired', 'messages').replace('{field}', this.getLabelText());
          this.showValidationMessage(msg);
          return true;
        }
      }
      return false;
    }

    /**
     * Delete a one-of item. For search mode.
     */
    deleteLinkOneOf(id) {
      this.deleteLinkOneOfHtml(id);
      const index = this.searchData.oneOfIdList.indexOf(id);
      if (index > -1) {
        this.searchData.oneOfIdList.splice(index, 1);
      }
      delete this.searchData.oneOfNameHash[id];
      this.trigger('change');
    }

    /**
     * Add a one-of item. For search mode.
     *
     * @param id An ID.
     * @param name A name.
     */
    addLinkOneOf(id, name) {
      const ids = this.searchData.oneOfIdList;
      if (ids.includes(id)) {
        return;
      }
      ids.push(id);
      this.searchData.oneOfNameHash[id] = name;
      this.addLinkOneOfHtml(id, name);
      this.trigger('change');
    }

    /**
     * @param id An ID.
     */
    deleteLinkOneOfHtml(id) {
      this.$el.find('.link-one-of-container .link-' + id).remove();
    }

    /**
     * @param id An ID.
     * @param name A name.
     */
    addLinkOneOfHtml(id, name) {
      const $container = this.$el.find('.link-one-of-container');
      const $el = $('<div>').addClass('link-' + id).addClass('list-group-item');
      $el.append($('<a>').attr('role', 'button').addClass('pull-right').attr('data-id', id).attr('data-action', 'clearLinkOneOf').append($('<span>').addClass('fas fa-times')), $('<span>').text(name), ' ');
      $container.append($el);
      return $el;
    }
    fetch() {
      const data = {};
      data[this.nameName] = this.$el.find(`[data-name="${this.nameName}"]`).val() || null;
      data[this.idName] = this.$el.find(`[data-name="${this.idName}"]`).val() || null;
      return data;
    }
    fetchSearch() {
      const type = this.$el.find('select.search-type').val();
      const value = this.$el.find('[data-name="' + this.idName + '"]').val();
      if (~['isOneOf', 'isNotOneOf'].indexOf(type) && !this.searchData.oneOfIdList.length) {
        return {
          type: 'isNotNull',
          attribute: 'id',
          data: {
            type: type
          }
        };
      }
      if (type === 'isEmpty') {
        return {
          type: 'isNull',
          attribute: this.idName,
          data: {
            type: type
          }
        };
      }
      if (type === 'isNotEmpty') {
        return {
          type: 'isNotNull',
          attribute: this.idName,
          data: {
            type: type
          }
        };
      }
      if (type === 'isOneOf') {
        return {
          type: 'in',
          attribute: this.idName,
          value: this.searchData.oneOfIdList,
          data: {
            type: type,
            oneOfIdList: this.searchData.oneOfIdList,
            oneOfNameHash: this.searchData.oneOfNameHash
          }
        };
      }
      if (type === 'isNotOneOf') {
        return {
          type: 'or',
          value: [{
            type: 'notIn',
            attribute: this.idName,
            value: this.searchData.oneOfIdList
          }, {
            type: 'isNull',
            attribute: this.idName
          }],
          data: {
            type: type,
            oneOfIdList: this.searchData.oneOfIdList,
            oneOfNameHash: this.searchData.oneOfNameHash
          }
        };
      }
      if (type === 'isNotOneOfAndIsNotEmpty') {
        return {
          type: 'notIn',
          attribute: this.idName,
          value: this.searchData.oneOfIdList,
          data: {
            type: type,
            oneOfIdList: this.searchData.oneOfIdList,
            oneOfNameHash: this.searchData.oneOfNameHash
          }
        };
      }
      if (type === 'isNot') {
        if (!value) {
          return null;
        }
        const nameValue = this.$el.find('[data-name="' + this.nameName + '"]').val();
        return {
          type: 'or',
          value: [{
            type: 'notEquals',
            attribute: this.idName,
            value: value
          }, {
            type: 'isNull',
            attribute: this.idName
          }],
          data: {
            type: type,
            idValue: value,
            nameValue: nameValue
          }
        };
      }
      if (type === 'isNotAndIsNotEmpty') {
        if (!value) {
          return null;
        }
        const nameValue = this.$el.find('[data-name="' + this.nameName + '"]').val();
        return {
          type: 'notEquals',
          attribute: this.idName,
          value: value,
          data: {
            type: type,
            idValue: value,
            nameValue: nameValue
          }
        };
      }
      if (!value) {
        return null;
      }
      const nameValue = this.$el.find('[data-name="' + this.nameName + '"]').val();
      return {
        type: 'equals',
        attribute: this.idName,
        value: value,
        data: {
          type: type,
          idValue: value,
          nameValue: nameValue
        }
      };
    }

    /** @inheritDoc */
    getSearchType() {
      var _this$searchParams7, _this$searchParams8;
      return this.getSearchParamsData().type ?? ((_this$searchParams7 = this.searchParams) === null || _this$searchParams7 === void 0 ? void 0 : _this$searchParams7.typeFront) ?? ((_this$searchParams8 = this.searchParams) === null || _this$searchParams8 === void 0 ? void 0 : _this$searchParams8.type);
    }
    quickView() {
      const id = this.model.get(this.idName);
      if (!id) {
        return;
      }
      const entityType = this.foreignScope;
      const helper = new _recordModal.default();
      helper.showDetail(this, {
        id: id,
        entityType: entityType
      });
    }
    getCreateAttributesProvider() {
      return () => {
        const attributes = this.getCreateAttributes() ?? {};
        if (!this.panelDefs.createHandler) {
          return Promise.resolve(attributes);
        }
        return new Promise(async resolve => {
          const handler = this.panelDefs.createHandler;
          const Handler = await Espo.loader.requirePromise(handler);
          const handlerInstance = new Handler(this.getHelper());
          const additionalAttributes = await handlerInstance.getAttributes(this.model, this.name);
          resolve({
            ...attributes,
            ...additionalAttributes
          });
        });
      };
    }
    async actionSelect() {
      const viewName = this.panelDefs.selectModalView || this.getMetadata().get(`clientDefs.${this.foreignScope}.modalViews.select`) || this.selectRecordsView;
      const mandatorySelectAttributeList = this.getMandatorySelectAttributeList();
      const createButton = this.isEditMode() && (!this.createDisabled || this.forceCreateButton);
      const createAttributesProvider = createButton ? this.getCreateAttributesProvider() : null;
      _ui.default.notifyWait();
      const filters = await this._getSelectFilters();
      const orderBy = filters.orderBy || this.panelDefs.selectOrderBy;
      const orderDirection = filters.orderBy ? filters.order : this.panelDefs.selectOrderDirection;
      const options = {
        entityType: this.foreignScope,
        createButton: createButton,
        filters: filters.advanced,
        boolFilterList: filters.bool,
        primaryFilterName: filters.primary,
        mandatorySelectAttributeList: mandatorySelectAttributeList,
        forceSelectAllAttributes: this.forceSelectAllAttributes,
        filterList: this.getSelectFilterList(),
        createAttributesProvider: createAttributesProvider,
        layoutName: this.panelDefs.selectLayout,
        orderBy: orderBy,
        orderDirection: orderDirection,
        onSelect: models => {
          this.select(models[0]);
        }
      };
      const view = await this.createView('modal', viewName, options);
      await view.render();
      _ui.default.notify();
    }
    _applyAdditionalFilter(advanced) {
      const foreignLink = this.model.getLinkParam(this.name, 'foreign');
      if (!foreignLink) {
        return;
      }
      if (advanced[foreignLink]) {
        return;
      }
      const linkType = this.model.getLinkParam(this.name, 'type');
      const foreignLinkType = this.getMetadata().get(['entityDefs', this.foreignScope, 'links', foreignLink, 'type']);
      const foreignFieldType = this.getMetadata().get(['entityDefs', this.foreignScope, 'fields', foreignLink, 'type']);
      if (!foreignFieldType) {
        return;
      }
      const isOneToOne = (linkType === 'hasOne' || foreignLinkType === 'hasOne') && ['link', 'linkOne'].includes(foreignFieldType);
      if (!isOneToOne) {
        return;
      }
      advanced[foreignLink] = {
        type: 'isNull',
        attribute: foreignLink + 'Id',
        data: {
          type: 'isEmpty'
        }
      };
    }
    _getSelectFilters() {
      const handler = this.panelDefs.selectHandler;
      const localBoolFilterList = this.getSelectBoolFilterList();
      if (!handler || this.isSearchMode()) {
        const boolFilterList = localBoolFilterList || this.panelDefs.selectBoolFilterList ? [...(localBoolFilterList || []), ...(this.panelDefs.selectBoolFilterList || [])] : undefined;
        const advanced = {
          ...(this.getSelectFilters() ?? {}),
          ...(!this.isSearchMode() ? this._getCascadingFilters() : {})
        };
        this._applyAdditionalFilter(advanced);
        return Promise.resolve({
          primary: this.getSelectPrimaryFilterName() ?? this.panelDefs.selectPrimaryFilterName,
          bool: boolFilterList,
          advanced: advanced
        });
      }
      return new Promise(async resolve => {
        const Handler = await Espo.loader.requirePromise(handler);
        const filters = await new Handler(this.getHelper()).getFilters(this.model);
        const advanced = {
          ...(this.getSelectFilters() ?? {}),
          ...(filters.advanced ?? {}),
          ...this._getCascadingFilters()
        };
        const primaryFilter = this.getSelectPrimaryFilterName() || filters.primary || this.panelDefs.selectPrimaryFilterName;
        const boolFilterList = localBoolFilterList || filters.bool || this.panelDefs.selectBoolFilterList ? [...(localBoolFilterList || []), ...(filters.bool || []), ...(this.panelDefs.selectBoolFilterList || [])] : undefined;
        this._applyAdditionalFilter(advanced);
        const orderBy = filters.orderBy;
        const order = orderBy ? filters.order : undefined;
        resolve({
          bool: boolFilterList,
          primary: primaryFilter,
          advanced: advanced,
          orderBy: orderBy,
          order: order
        });
      });
    }
    _createCascadeLinksHelper() {
      var _this$options$cascadi;
      const items = ((_this$options$cascadi = this.options.cascadingLogic) === null || _this$options$cascadi === void 0 ? void 0 : _this$options$cascadi.items) ?? [];
      if (!items.length) {
        return null;
      }
      if (!this.foreignScope) {
        return null;
      }
      return new _cascadeLinks.default({
        model: this.model,
        foreignEntityType: this.foreignScope,
        items: items
      });
    }
    _getCascadingFilters() {
      var _this$_createCascadeL;
      return ((_this$_createCascadeL = this._createCascadeLinksHelper()) === null || _this$_createCascadeL === void 0 ? void 0 : _this$_createCascadeL.prepareFilters()) ?? {};
    }
    _getCascadingCreateAttributes() {
      var _this$_createCascadeL2;
      return ((_this$_createCascadeL2 = this._createCascadeLinksHelper()) === null || _this$_createCascadeL2 === void 0 ? void 0 : _this$_createCascadeL2.prepareCreateAttributes()) ?? {};
    }
    async actionSelectOneOf() {
      Espo.Ui.notifyWait();
      const viewName = this.getMetadata().get(['clientDefs', this.foreignScope, 'modalViews', 'select']) || this.selectRecordsView;
      const view = await this.createView('dialog', viewName, {
        scope: this.foreignScope,
        createButton: false,
        filters: this.getSelectFilters(),
        boolFilterList: this.getSelectBoolFilterList(),
        primaryFilterName: this.getSelectPrimaryFilterName(),
        multiple: true,
        layoutName: this.panelDefs.selectLayout
      });
      this.listenToOnce(view, 'select', models => {
        this.clearView('dialog');
        if (Object.prototype.toString.call(models) !== '[object Array]') {
          models = [models];
        }
        this.selectOneOf(models);
      });
      view.render().then(() => {});
      Espo.Ui.notify(false);
    }

    /**
     * Get an empty autocomplete result.
     */
    getOnEmptyAutocomplete() {
      return null;
    }
    async actionCreateLink() {
      const helper = new _recordModal.default();
      const attributes = await this.getCreateAttributesProvider()();
      await helper.showCreate(this, {
        entityType: this.foreignScope,
        fullFormDisabled: true,
        attributes: attributes,
        afterSave: model => this.select(model)
      });
    }

    /**
     * @since 8.0.4
     */
    selectOneOf(models) {
      models.forEach(model => {
        this.addLinkOneOf(model.id, model.get(this.foreignNameAttribute));
      });
    }
  }
  var _default = _exports.default = LinkFieldView;
});

define("views/fields/int", ["exports", "views/fields/base", "autonumeric"], function (_exports, _base, _autonumeric) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  _autonumeric = _interopRequireDefault(_autonumeric);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/fields/int */

  /**
   * Parameters.
   */

  /**
   * Options.
   */

  /**
   * An integer field.
   */
  class IntFieldView extends _base.default {
    type = 'int';
    listTemplate = 'fields/int/list';
    detailTemplate = 'fields/int/detail';
    editTemplate = 'fields/int/edit';
    searchTemplate = 'fields/int/search';
    validations = ['required', 'int', 'range'];
    thousandSeparator = ',';
    searchTypeList = ['isNotEmpty', 'isEmpty', 'equals', 'notEquals', 'greaterThan', 'lessThan', 'greaterThanOrEquals', 'lessThanOrEquals', 'between'];
    autoNumericInstance = null;
    disableFormatting = false;
    setup() {
      if (this.getPreferences().has('thousandSeparator')) {
        this.thousandSeparator = this.getPreferences().get('thousandSeparator');
      } else if (this.getConfig().has('thousandSeparator')) {
        this.thousandSeparator = this.getConfig().get('thousandSeparator');
      }
      if (this.params.disableFormatting) {
        this.disableFormatting = true;
      }
    }
    setupFinal() {
      super.setupFinal();
      this.setupAutoNumericOptions();
    }
    setupAutoNumericOptions() {
      const separator = (!this.disableFormatting ? this.thousandSeparator : null) || '';
      let decimalCharacter = '.';
      if (separator === '.') {
        decimalCharacter = ',';
      }
      this.autoNumericOptions = {
        digitGroupSeparator: separator,
        decimalCharacter: decimalCharacter,
        modifyValueOnWheel: false,
        decimalPlaces: 0,
        selectOnFocus: false,
        // @ts-ignore
        formulaMode: true
      };
      if (this.params.max != null && this.params.max > Math.pow(10, 6)) {
        this.autoNumericOptions.maximumValue = this.params.max.toString();
      }
      if (this.params.min != null && this.params.min < -Math.pow(10, 6)) {
        this.autoNumericOptions.minimumValue = this.params.min.toString();
      }
    }
    afterRender() {
      super.afterRender();
      if (this.mode === this.MODE_EDIT) {
        if (this.autoNumericOptions) {
          var _this$$element;
          const element = (_this$$element = this.$element) === null || _this$$element === void 0 ? void 0 : _this$$element.get(0);
          this.autoNumericInstance = new _autonumeric.default(element, null, this.autoNumericOptions);
        }
      }
      if (this.mode === this.MODE_SEARCH) {
        var _this$$element2;
        const $searchType = this.$el.find('select.search-type');
        this.handleSearchType($searchType.val());
        this.$el.find('select.search-type').on('change', () => {
          this.trigger('change');
        });
        (_this$$element2 = this.$element) === null || _this$$element2 === void 0 || _this$$element2.on('input', () => {
          this.trigger('change');
        });
        const $inputAdditional = this.$el.find('input.additional');
        $inputAdditional.on('input', () => {
          this.trigger('change');
        });
        if (this.autoNumericOptions) {
          var _this$$element3;
          const element1 = (_this$$element3 = this.$element) === null || _this$$element3 === void 0 ? void 0 : _this$$element3.get(0);
          const element2 = $inputAdditional.get(0);
          new _autonumeric.default(element1, null, this.autoNumericOptions);
          new _autonumeric.default(element2, null, this.autoNumericOptions);
        }
      }
    }
    data() {
      const data = super.data();
      if (this.model.get(this.name) !== null && typeof this.model.get(this.name) !== 'undefined') {
        data.isNotEmpty = true;
      }
      data.valueIsSet = this.model.has(this.name);
      if (this.isSearchMode()) {
        var _this$searchParams;
        data.value = (_this$searchParams = this.searchParams) === null || _this$searchParams === void 0 ? void 0 : _this$searchParams.value;
        if (this.getSearchType() === 'between') {
          var _this$searchParams2, _this$searchParams3;
          data.value = this.getSearchParamsData().value1 ?? ((_this$searchParams2 = this.searchParams) === null || _this$searchParams2 === void 0 ? void 0 : _this$searchParams2.value1);
          data.value2 = this.getSearchParamsData().value2 ?? ((_this$searchParams3 = this.searchParams) === null || _this$searchParams3 === void 0 ? void 0 : _this$searchParams3.value2);
        }
      }
      if (this.isEditMode()) {
        data.value = this.model.get(this.name);
      }

      // noinspection JSValidateTypes
      return data;
    }
    getValueForDisplay() {
      const value = isNaN(this.model.get(this.name)) ? null : this.model.get(this.name);
      return this.formatNumber(value);
    }
    formatNumber(value) {
      if (this.disableFormatting) {
        return (value === null || value === void 0 ? void 0 : value.toString()) ?? null;
      }
      return this.formatNumberDetail(value);
    }
    formatNumberDetail(value) {
      if (value === null) {
        return '';
      }
      let stringValue = value.toString();
      stringValue = stringValue.replace(/\B(?=(\d{3})+(?!\d))/g, this.thousandSeparator);
      return stringValue;
    }
    setupSearch() {
      this.addHandler('change', 'select.search-type', (_e, target) => {
        this.handleSearchType(target.value);
      });
    }
    handleSearchType(type) {
      const $additionalInput = this.$el.find('input.additional');
      const $input = this.$el.find('input[data-name="' + this.name + '"]');
      if (type === 'between') {
        $additionalInput.removeClass('hidden');
        $input.removeClass('hidden');
      } else if (~['isEmpty', 'isNotEmpty'].indexOf(type)) {
        $additionalInput.addClass('hidden');
        $input.addClass('hidden');
      } else {
        $additionalInput.addClass('hidden');
        $input.removeClass('hidden');
      }
    }
    getMaxValue() {
      let maxValue = this.model.getFieldParam(this.name, 'max') ?? null;
      if (!maxValue && maxValue !== 0) {
        maxValue = null;
      }
      if ('max' in this.params) {
        maxValue = this.params.max;
      }
      return maxValue;
    }
    getMinValue() {
      if ('min' in this.params) {
        return this.params.min ?? null;
      }
      return this.model.getFieldParam(this.name, 'min') ?? null;
    }

    // noinspection JSUnusedGlobalSymbols
    validateInt() {
      const value = this.model.get(this.name);
      if (isNaN(value)) {
        const msg = this.translate('fieldShouldBeInt', 'messages').replace('{field}', this.getLabelText());
        this.showValidationMessage(msg);
        return true;
      }
      return false;
    }

    // noinspection JSUnusedGlobalSymbols
    validateRange() {
      const value = this.model.get(this.name);
      if (value === null) {
        return false;
      }
      const minValue = this.getMinValue();
      const maxValue = this.getMaxValue();
      if (minValue !== null && maxValue !== null) {
        if (value < minValue || value > maxValue) {
          const msg = this.translate('fieldShouldBeBetween', 'messages').replace('{field}', this.getLabelText()).replace('{min}', minValue.toString()).replace('{max}', maxValue.toString());
          this.showValidationMessage(msg);
          return true;
        }
      } else {
        if (minValue !== null) {
          if (value < minValue) {
            const msg = this.translate('fieldShouldBeGreater', 'messages').replace('{field}', this.getLabelText()).replace('{value}', minValue.toString());
            this.showValidationMessage(msg);
            return true;
          }
        } else if (maxValue !== null) {
          if (value > maxValue) {
            const msg = this.translate('fieldShouldBeLess', 'messages').replace('{field}', this.getLabelText()).replace('{value}', maxValue.toString());
            this.showValidationMessage(msg);
            return true;
          }
        }
      }
      return false;
    }
    validateRequired() {
      if (this.isRequired()) {
        const value = this.model.get(this.name);
        if (value === null || value === false) {
          const msg = this.translate('fieldIsRequired', 'messages').replace('{field}', this.getLabelText());
          this.showValidationMessage(msg);
          return true;
        }
      }
      return false;
    }
    parse(input) {
      let value = input !== '' ? input : null;
      if (value === null) {
        return null;
      }
      value = value.split(this.thousandSeparator).join('');
      if (value.indexOf('.') !== -1 || value.indexOf(',') !== -1) {
        return NaN;
      }
      return parseInt(value);
    }
    fetch() {
      var _this$$element4;
      const valueString = ((_this$$element4 = this.$element) === null || _this$$element4 === void 0 ? void 0 : _this$$element4.val()) ?? '';
      const value = this.parse(valueString);
      const data = {};
      data[this.name] = value;
      return data;
    }
    fetchSearch() {
      var _this$$element5;
      const value = this.parse(((_this$$element5 = this.$element) === null || _this$$element5 === void 0 ? void 0 : _this$$element5.val()) ?? '');
      const type = this.fetchSearchType();
      let data;
      if (typeof value === 'number' && isNaN(value)) {
        return null;
      }
      if (type === 'between') {
        const valueTo = this.parse(this.$el.find('input.additional').val());
        if (typeof valueTo === 'number' && isNaN(valueTo)) {
          return null;
        }
        data = {
          type: type,
          value: [value, valueTo],
          data: {
            value1: value,
            value2: valueTo
          }
        };
      } else if (type === 'isEmpty') {
        data = {
          type: 'isNull',
          typeFront: 'isEmpty'
        };
      } else if (type === 'isNotEmpty') {
        data = {
          type: 'isNotNull',
          typeFront: 'isNotEmpty'
        };
      } else {
        data = {
          type: type,
          value: value,
          data: {
            value1: value
          }
        };
      }
      return data;
    }
    getSearchType() {
      var _this$searchParams4, _this$searchParams5;
      return ((_this$searchParams4 = this.searchParams) === null || _this$searchParams4 === void 0 ? void 0 : _this$searchParams4.typeFront) ?? ((_this$searchParams5 = this.searchParams) === null || _this$searchParams5 === void 0 ? void 0 : _this$searchParams5.type) ?? null;
    }
  }
  var _default = _exports.default = IntFieldView;
});

define("ui/datepicker", ["exports", "jquery", "language", "models/settings", "di", "moment"], function (_exports, _jquery, _language, _settings, _di, _moment) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _jquery = _interopRequireDefault(_jquery);
  _language = _interopRequireDefault(_language);
  _settings = _interopRequireDefault(_settings);
  _moment = _interopRequireDefault(_moment);
  var _staticBlock;
  let _init_language, _init_extra_language, _init_config, _init_extra_config;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  /**
   * A datepicker.
   *
   * @since 9.0.0
   */
  class Datepicker {
    /**
     * @private
     * @type {Language}
     */
    language = _init_language(this);

    /**
     * @private
     * @type {Settings}
     */
    config = (_init_extra_language(this), _init_config(this));

    /**
     * @param {HTMLElement} element
     * @param {{
     *     format: string,
     *     weekStart: number,
     *     todayButton?: boolean,
     *     date?: string,
     *     startDate?: string|undefined,
     *     onChange?: function(),
     *     hasDay?: function(string): boolean,
     *     hasMonth?: function(string): boolean,
     *     hasYear?: function(string): boolean,
     *     onChangeDate?: function(),
     *     onChangeMonth?: function(string),
     *     defaultViewDate?: string,
     * }} options
     */
    constructor(element, options) {
      _init_extra_config(this);
      /**
       * @private
       */
      this.$element = (0, _jquery.default)(element);

      /**
       * @private
       * @type {string}
       */
      this.format = options.format;
      if (element instanceof HTMLInputElement) {
        if (options.date) {
          element.value = options.date;
        }
        let wait = false;
        this.$element.on('change', /** Record */e => {
          if (!wait) {
            if (options.onChange) {
              options.onChange();
            }
            wait = true;
            setTimeout(() => wait = false, 100);
          }
          if (e.isTrigger && document.activeElement !== this.$element.get(0)) {
            this.$element.focus();
          }
        });
        this.$element.on('click', () => this.show());
      } else {
        if (options.date) {
          element.dataset.date = options.date;
        }
      }
      const modalBodyElement = element.closest('.modal-body');
      const language = this.config.get('language');
      const format = options.format;
      const datepickerOptions = {
        autoclose: true,
        todayHighlight: true,
        keyboardNavigation: true,
        assumeNearbyYear: true,
        format: format.toLowerCase(),
        weekStart: options.weekStart,
        todayBtn: options.todayButton || false,
        startDate: options.startDate,
        orientation: 'bottom auto',
        templates: {
          leftArrow: '<span class="fas fa-chevron-left fa-sm"></span>',
          rightArrow: '<span class="fas fa-chevron-right fa-sm"></span>'
        },
        container: modalBodyElement ? (0, _jquery.default)(modalBodyElement) : 'body',
        language: language,
        maxViewMode: 2,
        defaultViewDate: options.defaultViewDate
      };
      if (options.hasDay) {
        datepickerOptions.beforeShowDay = (/** Date */date) => {
          const stringDate = (0, _moment.default)(date).format(this.format);
          return {
            enabled: options.hasDay(stringDate)
          };
        };
      }
      if (options.hasMonth) {
        datepickerOptions.beforeShowMonth = (/** Date */date) => {
          const stringDate = (0, _moment.default)(date).format(this.format);
          return {
            enabled: options.hasMonth(stringDate)
          };
        };
      }
      if (options.hasYear) {
        datepickerOptions.beforeShowYear = (/** Date */date) => {
          const stringDate = (0, _moment.default)(date).format(this.format);
          return {
            enabled: options.hasYear(stringDate)
          };
        };
      }

      // noinspection JSUnresolvedReference
      if (!(language in _jquery.default.fn.datepicker.dates)) {
        // noinspection JSUnresolvedReference
        _jquery.default.fn.datepicker.dates[language] = {
          days: this.language.get('Global', 'lists', 'dayNames'),
          daysShort: this.language.get('Global', 'lists', 'dayNamesShort'),
          daysMin: this.language.get('Global', 'lists', 'dayNamesMin'),
          months: this.language.get('Global', 'lists', 'monthNames'),
          monthsShort: this.language.get('Global', 'lists', 'monthNamesShort'),
          today: this.language.translate('Today'),
          clear: this.language.translate('Clear')
        };
      }
      this.$element.datepicker(datepickerOptions).on('changeDate', () => {
        if (options.onChangeDate) {
          options.onChangeDate();
        }
      }).on('changeMonth', (/** {date: Date} */event) => {
        if (options.onChangeMonth) {
          const dateString = (0, _moment.default)(event.date).startOf('month').format(options.format);
          options.onChangeMonth(dateString);
        }
      });
      if (element.classList.contains('input-group') && !(element instanceof HTMLInputElement)) {
        element.querySelectorAll('input').forEach(input => {
          (0, _jquery.default)(input).on('click', () => (0, _jquery.default)(input).datepicker('show'));
        });
      }
    }

    /**
     * Set a start date.
     *
     * @param {string|undefined} startDate
     */
    setStartDate(startDate) {
      this.$element.datepicker('setStartDate', startDate);
    }

    /**
     * Show.
     */
    show() {
      this.$element.datepicker('show');
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * Get the value.
     *
     * @return {string|null}
     */
    getDate() {
      const date = this.$element.datepicker('getDate');
      if (!date) {
        return null;
      }
      return (0, _moment.default)(date).format(this.format);
    }

    /**
     * Refresh.
     */
    refresh() {
      const picker = this.$element.data('datepicker');
      if (!picker) {
        return;
      }
      picker.fill();
    }
    static #_ = _staticBlock = () => [_init_language, _init_extra_language, _init_config, _init_extra_config] = _applyDecs(this, [], [[(0, _di.inject)(_language.default), 0, "language"], [(0, _di.inject)(_settings.default), 0, "config"]]).e;
  }
  _staticBlock();
  var _default = _exports.default = Datepicker;
});

define("helpers/file-upload", ["exports", "di", "models/settings"], function (_exports, _di, _settings) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _settings = _interopRequireDefault(_settings);
  var _staticBlock;
  let _init_config, _init_extra_config;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  /** @module helpers/file-upload */
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  /**
   * A file-upload helper.
   */
  class FileUploadExport {
    constructor() {
      _init_extra_config(this);
    }
    /**
     * @private
     * @type {Settings}
     */
    config = _init_config(this);

    /**
     * @typedef {Object} module:helpers/file-upload~Options
     *
     * @property {function(number):void} [afterChunkUpload] After every chunk is uploaded.
     * @property {function(module:model):void} [afterAttachmentSave] After an attachment is saved.
     * @property {{isCanceled?: boolean}} [mediator] A mediator.
     */

    /**
     * Upload.
     *
     * @param {File} file A file.
     * @param {module:model} attachment An attachment model.
     * @param {module:helpers/file-upload~Options} [options] Options.
     * @returns {Promise}
     */
    upload(file, attachment, options) {
      options = options || {};
      options.afterChunkUpload = options.afterChunkUpload || (() => {});
      options.afterAttachmentSave = options.afterAttachmentSave || (() => {});
      options.mediator = options.mediator || {};
      attachment.set('name', file.name);
      attachment.set('type', file.type || 'text/plain');
      attachment.set('size', file.size);
      if (this._useChunks(file)) {
        return this._uploadByChunks(file, attachment, options);
      }
      return new Promise((resolve, reject) => {
        const fileReader = new FileReader();
        fileReader.onload = e => {
          attachment.set('file', e.target.result);
          attachment.save({}, {
            timeout: 0
          }).then(() => resolve()).catch(() => reject());
        };
        fileReader.readAsDataURL(file);
      });
    }

    /**
     * @private
     */
    _uploadByChunks(file, attachment, options) {
      return new Promise((resolve, reject) => {
        attachment.set('isBeingUploaded', true);
        attachment.save().then(() => {
          options.afterAttachmentSave(attachment);
          return this._uploadChunks(file, attachment, resolve, reject, options);
        }).catch(() => reject());
      });
    }

    /**
     * @private
     */
    _uploadChunks(file, attachment, resolve, reject, options, start) {
      start = start || 0;
      let end = start + this._getChunkSize() + 1;
      if (end > file.size) {
        end = file.size;
      }
      if (options.mediator.isCanceled) {
        reject();
        return;
      }
      const blob = file.slice(start, end);
      const fileReader = new FileReader();
      fileReader.onloadend = e => {
        if (e.target.readyState !== FileReader.DONE) {
          return;
        }
        Espo.Ajax.postRequest('Attachment/chunk/' + attachment.id, e.target.result, {
          headers: {
            contentType: 'multipart/form-data'
          }
        }).then(() => {
          options.afterChunkUpload(end);
          if (end === file.size) {
            resolve();
            return;
          }
          this._uploadChunks(file, attachment, resolve, reject, options, end);
        }).catch(() => reject());
      };
      fileReader.readAsDataURL(blob);
    }

    /**
     * @private
     */
    _useChunks(file) {
      const chunkSize = this._getChunkSize();
      if (!chunkSize) {
        return false;
      }
      if (file.size > chunkSize) {
        return true;
      }
      return false;
    }

    /**
     * @private
     */
    _getChunkSize() {
      return (this.config.get('attachmentUploadChunkSize') || 0) * 1024 * 1024;
    }
    static #_ = _staticBlock = () => [_init_config, _init_extra_config] = _applyDecs(this, [], [[(0, _di.inject)(_settings.default), 0, "config"]]).e;
  }
  _staticBlock();
  var _default = _exports.default = FileUploadExport;
});

define("helpers/misc/summernote-custom", ["exports", "jquery", "views/wysiwyg/modals/edit-table", "views/wysiwyg/modals/edit-cell"], function (_exports, _jquery, _editTable, _editCell) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.init = init;
  _jquery = _interopRequireDefault(_jquery);
  _editTable = _interopRequireDefault(_editTable);
  _editCell = _interopRequireDefault(_editCell);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * @type {{
   *     edit: import('ace-builds').edit,
   *     require: import('ace-builds').require,
   * }}
   */
  let ace;
  function init(langSets) {
    _jquery.default.extend(_jquery.default.summernote.options, {
      espoImage: {
        icon: '<i class="note-icon-picture"/>',
        tooltip: langSets.image.image
      },
      espoLink: {
        icon: '<i class="note-icon-link"/>',
        tooltip: langSets.link.link
      },
      espoTable: {
        icon: '<i class="note-icon-table"/>',
        tooltip: langSets.table.table
      },
      popover: {
        table: [['custom', ['tableParams', 'cellParams']], ['add', ['addRowDown', 'addRowUp', 'addColLeft', 'addColRight']], ['delete', ['deleteRow', 'deleteCol', 'deleteTable']]]
      }
    });
    _jquery.default.extend(_jquery.default.summernote.plugins, {
      'cellParams': function (/** Record */context) {
        const ui = _jquery.default.summernote.ui;
        const options = context.options;
        const view = /** @type {import('view').default} */options.espoView;
        if (!view) {
          return;
        }
        context.memo('button.cellParams', () => {
          return ui.button({
            className: '',
            contents: '<i class="far fa-square fa-sm"/>',
            tooltip: view.translate('cell', 'wysiwygLabels'),
            click: () => {
              context.invoke('cellParams.show');
            }
          }).render();
        });
        this.show = function () {
          const range = context.invoke('editor.getLastRange');
          const $td = (0, _jquery.default)(range.ec).closest('td,th');
          const td = /** @type {HTMLTableCellElement} */$td[0];
          const width = td.style.width;
          const height = td.style.height;
          const backgroundColor = td.style.backgroundColor;
          const verticalAlign = td.style.verticalAlign;
          const params = {
            width,
            height,
            backgroundColor,
            verticalAlign
          };

          //const prevParams = params;

          const modalView = new _editCell.default({
            params,
            headerText: view.translate('cell', 'wysiwygLabels'),
            onApply: params => applyParams(params)
          });
          view.assignView('dialog', modalView).then(() => {
            modalView.render();
          });

          /**
           * @param {{
           *     width: string|null,
           *     height: string|null,
           *     backgroundColor: string|null,
           *     verticalAlign: string|null,
           * }} params
           */
          const applyParams = params => {
            let backgroundColor = td.style.backgroundColor;
            if (backgroundColor === 'transparent') {
              backgroundColor = null;
            }
            td.style.backgroundColor = params.backgroundColor;
            td.style.width = params.width;
            td.style.height = params.height;
            td.style.verticalAlign = params.verticalAlign;
          };
        };
        this.destroy = function () {
          if (view) {
            view.clearView('dialog');
          }
        };
      },
      'tableParams': function (/** Record */context) {
        const ui = _jquery.default.summernote.ui;
        const options = context.options;
        const view = /** @type {import('view').default} */options.espoView;
        if (!view) {
          // Prevents an issue with a collapsed modal.
          // @todo Revise.
          return;
        }
        context.memo('button.tableParams', () => {
          return ui.button({
            className: '',
            contents: '<i class="note-icon-table"/>',
            tooltip: langSets.table.table,
            click: () => {
              context.invoke('tableParams.show');
            }
          }).render();
        });
        this.show = function () {
          const range = context.invoke('editor.getLastRange');
          const $table = (0, _jquery.default)(range.ec).closest('table');
          const table = /** @type {HTMLTableElement} */$table[0];
          let borderWidth = table.style.borderWidth;
          if (borderWidth !== null) {
            // @todo
            for (const /** HTMLTableCellElement */cell of table.querySelectorAll('td, th')) {
              if (cell.style.borderWidth !== borderWidth) {
                borderWidth = null;
                break;
              }
            }
          }
          let backgroundColor = table.style.backgroundColor;
          if (backgroundColor === 'transparent') {
            backgroundColor = null;
          }
          let borderColor = table.style.borderColor;
          if (borderColor !== null) {
            // @todo
            for (const /** HTMLTableCellElement */cell of table.querySelectorAll('td, th')) {
              if (cell.style.borderColor !== borderColor) {
                borderColor = null;
                break;
              }
            }
          }
          let cellPadding = null;
          for (const /** HTMLTableCellElement */cell of table.querySelectorAll('td, th')) {
            if (cellPadding !== null && cell.style.padding !== cellPadding) {
              cellPadding = null;
              break;
            }
            cellPadding = cell.style.padding;
          }
          let align = null;
          if (table.style.marginLeft === 'auto' && table.style.marginRight === '0px') {
            align = 'right';
          } else if (table.style.marginLeft === 'auto' && table.style.marginRight === 'auto') {
            align = 'center';
          } else if (table.style.marginLeft === '0px' && table.style.marginRight === 'auto') {
            align = 'left';
          }
          const width = table.style.width;
          const height = table.style.height;
          const params = {
            align,
            width,
            height,
            borderWidth,
            borderColor,
            cellPadding,
            backgroundColor
          };
          const prevParams = params;
          const modalView = new _editTable.default({
            params,
            headerText: langSets.table.table,
            onApply: params => applyParams(params)
          });
          view.assignView('dialog', modalView).then(() => {
            modalView.render();
          });

          /**
           * @param {{
           *     align: string|null,
           *     width: string|null,
           *     height: string|null,
           *     borderWidth: string|null,
           *     borderColor: string|null,
           *     cellPadding: string|null,
           *     backgroundColor: string|null,
           * }} params
           */
          const applyParams = params => {
            if (params.align === 'left') {
              table.style.marginLeft = '0';
              table.style.marginRight = 'auto';
            } else if (params.align === 'right') {
              table.style.marginLeft = 'auto';
              table.style.marginRight = '0';
            } else if (params.align === 'center') {
              table.style.marginLeft = 'auto';
              table.style.marginRight = 'auto';
            } else if (params.align === null && prevParams.align !== null) {
              table.style.marginLeft = null;
              table.style.marginRight = null;
            }
            table.style.backgroundColor = params.backgroundColor;
            table.style.width = params.width;
            table.style.height = params.height;
            if (params.borderWidth !== null || prevParams.borderWidth !== null) {
              table.style.borderWidth = params.borderWidth;
              table.style.borderStyle = params.borderWidth !== null ? 'solid' : null;
              for (const /** HTMLTableCellElement */cell of table.querySelectorAll('td, th')) {
                cell.style.borderWidth = params.borderWidth;
                cell.style.borderStyle = params.borderWidth !== null ? 'solid' : null;
              }
            }
            if (params.borderColor !== null || prevParams.borderColor !== null) {
              table.style.borderColor = params.borderColor;
              for (const /** HTMLTableCellElement */cell of table.querySelectorAll('td, th')) {
                cell.style.borderColor = params.borderColor;
              }
            }
            if (params.cellPadding !== null || prevParams.padding !== null) {
              for (const /** HTMLTableCellElement */cell of table.querySelectorAll('td, th')) {
                cell.style.padding = params.cellPadding;
              }
            }
          };
        };
        this.destroy = function () {
          if (view) {
            view.clearView('dialog');
          }
        };
      },
      'aceCodeview': function (/** Record */context) {
        const ui = _jquery.default.summernote.ui;
        const options = context.options;
        const lang = options.langInfo;
        /** @type {JQuery} */
        const $editor = context.layoutInfo.editor;
        /** @type {JQuery} */
        const $editable = context.layoutInfo.editable;
        const view = /** @type {import('view').default} */options.espoView;
        if (!view) {
          return;
        }

        // noinspection SpellCheckingInspection
        let $codable;
        /** @type {import('ace-builds').Ace.Editor} */
        let aceEditor;
        let isActivated = false;
        let isReplaced = false;
        let isBeingActivated = false;
        const EMPTY = '<p>&nbsp;</p>';
        context.destroyAceCodeview = function () {
          if (isActivated) {
            deactivate();
          }
        };
        context.code = function (html) {
          if (html === undefined) {
            let value;
            if (isActivated) {
              value = prepareValue(aceEditor.getValue()) || EMPTY;
              $editable.html(value);
            }
            return isActivated ? value : $editable.html();
          }
          if (isActivated) {
            aceEditor.setValue(html);
          }
          $editable.html(html);
          this.$note.val(html);
          context.triggerEvent('change', html, $editable);
        };
        const id = 'editor-' + Math.random().toString(36).substring(2, 17);
        const prepareValue = input => {
          return input;
        };
        const prepareHtml = (/** string */input) => {
          return prepareValue(input);
        };
        const toggle = () => {
          isActivated ? deactivate() : activate();
          context.triggerEvent('codeview.toggled');
        };
        const deactivate = () => {
          if (!isActivated) {
            return;
          }
          $codable.addClass('hidden');
          let value = prepareValue(aceEditor.getValue()) || EMPTY;
          value = context.invoke('codeview.purify', value);
          const isChange = $editable.html() !== value;
          $editable.html(value);
          $editor.removeClass('codeview');
          if (isChange) {
            context.triggerEvent('change', $editable.html(), $editable);
          }
          $editable.focus();
          context.invoke('toolbar.updateCodeview', false);
          context.invoke('airPopover.updateCodeview', false);
          if (aceEditor) {
            aceEditor.destroy();
            aceEditor = null;
          }
          context.aceEditor = undefined;
          isActivated = false;
        };
        const activate = () => {
          if (isBeingActivated) {
            return;
          }
          isBeingActivated = true;
          context.invoke('toolbar.updateCodeview', true);
          context.invoke('airPopover.updateCodeview', true);
          $editor.addClass('codeview');
          if (!isReplaced) {
            $codable = (0, _jquery.default)('<div>').attr('id', id).css('minHeight', 40 + 'px');
            (0, _jquery.default)(context.layoutInfo.codable).replaceWith($codable);
            context.$aceCodable = $codable;
            isReplaced = true;
          }
          $codable.removeClass('hidden');
          if ($editor.hasClass('fullscreen')) {
            $codable.css('height', $editable.css('height'));
          }
          requireAce().then(() => {
            const html = prepareHtml($editable.html());
            aceEditor = ace.edit(id);
            aceEditor.setValue(html);
            aceEditor.setOptions({
              maxLines: !$editor.hasClass('fullscreen') ? 100000 : null,
              enableLiveAutocompletion: true,
              tabSize: 2,
              useSoftTabs: true
            });
            aceEditor.setOptions({
              fontFamily: 'var(--font-family-monospace)'
            });
            aceEditor.setFontSize('var(--font-size-small)');
            aceEditor.container.style.lineHeight = 'var(--line-height-small)';
            aceEditor.renderer.updateFontSize();
            if (options.isDark) {
              aceEditor.setOptions({
                theme: 'ace/theme/tomorrow_night'
              });
            }
            aceEditor.getSession().setUseWrapMode(true);
            aceEditor.setShowPrintMargin(false);
            aceEditor.getSession().setUseWorker(false);
            aceEditor.commands.removeCommand('find');
            aceEditor.setHighlightActiveLine(false);
            aceEditor.focus();
            try {
              aceEditor.gotoLine(0, 0, false);
            } catch (e) {}
            aceEditor.on('blur', e => {
              context.triggerEvent('blur.codeview', aceEditor.getValue(), e);
            });
            aceEditor.on('change', () => {
              context.triggerEvent('change.codeview', aceEditor.getValue());
            });

            // noinspection JSValidateTypes
            context.aceEditor = aceEditor;
            const modeToRequired = options.handlebars ? 'ace/mode/handlebars' : 'ace/mode/html';
            if (options.handlebars) {
              aceEditor.completers ??= [];
              aceEditor.completers.push({
                getCompletions(editor, session, pos, prefix, callback) {
                  const before = session.getLine(pos.row).substring(0, pos.column);
                  const lastOpen = before.lastIndexOf('<');
                  const lastClose = before.lastIndexOf('>');
                  const insideTag = lastOpen > lastClose;
                  if (!insideTag) {
                    return callback(null, []);
                  }
                  callback(null, [{
                    caption: 'x-if',
                    snippet: 'x-if="\{\{${1}\}\}"',
                    value: 'x-if',
                    meta: 'attribute'
                  }, {
                    caption: 'iterate',
                    snippet: 'iterate="\{\{${1}\}\}"',
                    value: 'iterate',
                    meta: 'attribute'
                  }]);
                }
              });
            }
            const Mode = ace.require(modeToRequired).Mode;
            aceEditor.session.setMode(new Mode());
            isActivated = true;
            isBeingActivated = false;
          });
        };
        context.memo('button.aceCodeview', () => {
          return ui.button({
            className: 'btn-codeview note-codeview-keep',
            contents: '<i class="note-icon-code"/>',
            tooltip: lang.options.codeview,
            click: () => toggle()
          }).render();
        });

        /**
         * @return Promise
         */
        const requireAce = function () {
          return Espo.loader.requirePromise('lib!ace').then(lib => {
            ace = /** window.ace */lib;
            const list = [Espo.loader.requirePromise('lib!ace-ext-language_tools')];
            list.push(options.handlebars ? Espo.loader.requirePromise('lib!ace-mode-handlebars') : Espo.loader.requirePromise('lib!ace-mode-html'));
            if (options.isDark) {
              list.push(Espo.loader.requirePromise('lib!ace-theme-tomorrow_night'));
            }
            return Promise.all(list);
          });
        };
      },
      'espoTable': function (context) {
        const ui = _jquery.default.summernote.ui;
        const options = context.options;
        const self = options.espoView;
        const lang = options.langInfo;
        if (!self) {
          return;
        }
        context.memo('button.espoTable', () => {
          return ui.buttonGroup([ui.button({
            className: 'dropdown-toggle',
            contents: ui.dropdownButtonContents(ui.icon(options.icons.table), options),
            tooltip: options.espoTable.tooltip,
            data: {
              toggle: 'dropdown'
            }
          }), ui.dropdown({
            title: lang.table.table,
            className: 'note-table',
            items: ['<div class="note-dimension-picker">', '<div class="note-dimension-picker-mousecatcher" data-event="insertTable" data-value="1x1"></div>', '<div class="note-dimension-picker-highlighted"></div>', '<div class="note-dimension-picker-unhighlighted"></div>', '</div>', '<div class="note-dimension-display">1 x 1</div>'].join('')
          })], {
            callback: $node => {
              const $catcher = $node.find('.note-dimension-picker-mousecatcher');
              const createTable = (colCount, rowCount, options) => {
                const tds = [];
                let tdHTML;
                for (let idxCol = 0; idxCol < colCount; idxCol++) {
                  tds.push('<td>&nbsp;</td>');
                }
                tdHTML = tds.join('\n');
                const trs = [];
                let trHTML;
                for (let idxRow = 0; idxRow < rowCount; idxRow++) {
                  trs.push('<tr>' + tdHTML + '</tr>');
                }
                trHTML = trs.join('\n');
                const $table = (0, _jquery.default)('<table>\n' + trHTML + '</table>');

                /*if (options.tableBorderWidth !== undefined) {
                    $table.attr('border', options.tableBorderWidth);
                }
                  if (options.tableCellPadding !== undefined) {
                    $table.attr('cellpadding', options.tableCellPadding);
                }*/

                $table.css({
                  width: '100%',
                  borderCollapse: 'collapse'
                  //borderSpacing: 0,
                });
                if (options && options.tableClassName) {
                  $table.addClass(options.tableClassName);
                }
                return $table[0];
              };
              $catcher.css({
                width: options.insertTableMaxSize.col + 'em',
                height: options.insertTableMaxSize.row + 'em'
              }).mousedown(() => {
                const $note = context.$note;
                const dims = $catcher.data('value').split('x');
                const range = $note.summernote('editor.getLastRange').deleteContents();
                createTable(dims[0], dims[1], options);
                range.insertNode(createTable(dims[0], dims[1], options));
              }).on('mousemove', event => {
                const PX_PER_EM = 18;
                const $picker = (0, _jquery.default)(event.target.parentNode);
                const $dimensionDisplay = $picker.next();
                const $catcher = $picker.find('.note-dimension-picker-mousecatcher');
                const $highlighted = $picker.find('.note-dimension-picker-highlighted');
                const $unhighlighted = $picker.find('.note-dimension-picker-unhighlighted');
                let posOffset;
                if (event.offsetX === undefined) {
                  const posCatcher = (0, _jquery.default)(event.target).offset();
                  posOffset = {
                    x: event.pageX - posCatcher.left,
                    y: event.pageY - posCatcher.top
                  };
                } else {
                  posOffset = {
                    x: event.offsetX,
                    y: event.offsetY
                  };
                }
                const dim = {
                  c: Math.ceil(posOffset.x / PX_PER_EM) || 1,
                  r: Math.ceil(posOffset.y / PX_PER_EM) || 1
                };
                $highlighted.css({
                  width: dim.c + 'em',
                  height: dim.r + 'em'
                });
                $catcher.data('value', dim.c + 'x' + dim.r);
                if (dim.c > 3 && dim.c < options.insertTableMaxSize.col) {
                  $unhighlighted.css({
                    width: dim.c + 1 + 'em'
                  });
                }
                if (dim.r > 3 && dim.r < options.insertTableMaxSize.row) {
                  $unhighlighted.css({
                    height: dim.r + 1 + 'em'
                  });
                }
                $dimensionDisplay.html(dim.c + ' x ' + dim.r);
              });
            }
          }).render();
        });
      },
      'espoImage': function (context) {
        const ui = _jquery.default.summernote.ui;
        const options = context.options;
        const self = options.espoView;
        const lang = options.langInfo;
        if (!self) {
          return;
        }
        context.memo('button.espoImage', () => {
          const button = ui.button({
            contents: options.espoImage.icon,
            tooltip: options.espoImage.tooltip,
            click() {
              context.invoke('espoImage.show');
            }
          });
          return button.render();
        });
        this.initialize = function () {};
        this.destroy = function () {
          if (!self) {
            return;
          }
          self.clearView('insertImageDialog');
        };
        this.show = function () {
          self.createView('insertImageDialog', 'views/wysiwyg/modals/insert-image', {
            labels: {
              insert: lang.image.insert,
              url: lang.image.url,
              selectFromFiles: lang.image.selectFromFiles
            }
          }, view => {
            view.render();
            self.listenToOnce(view, 'upload', target => {
              self.$summernote.summernote('insertImagesOrCallback', target);
            });
            self.listenToOnce(view, 'insert', target => {
              self.$summernote.summernote('insertImage', target);
            });
            self.listenToOnce(view, 'close', () => {
              self.clearView('insertImageDialog');
              self.fixPopovers();
            });
          });
        };
      },
      // Not used?
      'linkDialog': function (context) {
        const options = context.options;
        const self = options.espoView;
        const lang = options.langInfo;
        if (!self) {
          return;
        }
        this.show = function () {
          const linkInfo = context.invoke('editor.getLinkInfo');
          self.createView('dialogInsertLink', 'views/wysiwyg/modals/insert-link', {
            labels: {
              insert: lang.link.insert,
              openInNewWindow: lang.link.openInNewWindow,
              url: lang.link.url,
              textToDisplay: lang.link.textToDisplay
            },
            linkInfo: linkInfo
          }, view => {
            view.render();
            self.listenToOnce(view, 'insert', data => {
              self.$summernote.summernote('createLink', data);
            });
            self.listenToOnce(view, 'close', () => {
              self.clearView('dialogInsertLink');
              self.fixPopovers();
            });
          });
        };
      },
      'espoLink': function (context) {
        const ui = _jquery.default.summernote.ui;
        const options = context.options;
        const self = options.espoView;
        const lang = options.langInfo;
        if (!self) {
          return;
        }
        const isMacLike = /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform);
        context.memo('button.espoLink', function () {
          const button = ui.button({
            contents: options.espoLink.icon,
            tooltip: options.espoLink.tooltip + ' (' + (isMacLike ? 'CMD+K' : 'CTRL+K') + ')',
            click() {
              context.invoke('espoLink.show');
            }
          });
          return button.render();
        });
        this.initialize = function () {
          this.$modalBody = self.$el.closest('.modal-body');
          this.isInModal = this.$modalBody.length > 0;
        };
        this.destroy = function () {
          if (!self) {
            return;
          }
          self.clearView('dialogInsertLink');
        };
        this.show = function () {
          const linkInfo = context.invoke('editor.getLinkInfo');
          const container = this.isInModal ? this.$modalBody.get(0) : window;
          self.createView('dialogInsertLink', 'views/wysiwyg/modals/insert-link', {
            labels: {
              insert: lang.link.insert,
              openInNewWindow: lang.link.openInNewWindow,
              url: lang.link.url,
              textToDisplay: lang.link.textToDisplay
            },
            linkInfo: linkInfo
          }, view => {
            view.render();
            self.listenToOnce(view, 'insert', data => {
              const scrollY = 'scrollY' in container ? container.scrollY : container.scrollTop;
              self.$summernote.summernote('createLink', data);
              setTimeout(() => container.scroll(0, scrollY), 20);
            });
            self.listenToOnce(view, 'close', () => {
              self.clearView('dialogInsertLink');
              self.fixPopovers();
            });
          });
        };
      },
      'fullscreen': function (context) {
        const options = context.options;
        const self = options.espoView;
        if (!self) {
          return;
        }
        this.$window = (0, _jquery.default)(window);
        this.$scrollbar = (0, _jquery.default)('html, body');
        this.initialize = function () {
          this.$editor = context.layoutInfo.editor;
          this.$toolbar = context.layoutInfo.toolbar;
          this.$editable = context.layoutInfo.editable;
          this.$modal = self.$el.closest('.modal');
          this.isInModal = this.$modal.length > 0;
        };
        this.resizeTo = function (size) {
          this.$editable.css('height', size.h);
          if (context.$aceCodable) {
            context.$aceCodable.css('height', size.h);
          }
        };
        this.onResize = function () {
          this.resizeTo({
            h: this.$window.height() - this.$toolbar.outerHeight()
          });
        };
        this.isFullscreen = function () {
          return this.$editor.hasClass('fullscreen');
        };
        this.destroy = function () {
          this.$window.off('resize.summernote' + self.cid);
          if (this.isInModal) {
            this.$modal.css('overflow-y', '');
          } else {
            this.$scrollbar.css('overflow', '');
          }
        };
        let maxLines;
        this.toggle = function () {
          this.$editor.toggleClass('fullscreen');
          const aceEditor = /** @type {import('ace-builds').Ace.Editor} */context.aceEditor;
          if (this.isFullscreen()) {
            this.$editable.data('orgHeight', this.$editable.css('height'));
            this.$editable.data('orgMaxHeight', this.$editable.css('maxHeight'));
            this.$editable.css('maxHeight', '');
            this.$window.on('resize.summernote' + self.cid, this.onResize.bind(this)).trigger('resize');
            if (this.isInModal) {
              this.$modal.css('overflow-y', 'hidden');
            } else {
              this.$scrollbar.css('overflow', 'hidden');
            }

            // noinspection JSUnusedGlobalSymbols
            this._isFullscreen = true;
            if (aceEditor) {
              maxLines = aceEditor.getOption('maxLines');
              aceEditor.setOptions({
                maxLines: null
              });
              aceEditor.resize();
            }
          } else {
            this.$window.off('resize.summernote' + self.cid);
            this.resizeTo({
              h: this.$editable.data('orgHeight')
            });
            if (context.$aceCodable) {
              context.$aceCodable.css('height', '');
            }
            this.$editable.css('maxHeight', this.$editable.css('orgMaxHeight'));
            this.$editable.css('height', '');
            if (this.isInModal) {
              this.$modal.css('overflow-y', '');
            } else {
              this.$scrollbar.css('overflow', '');
            }

            // noinspection JSUnusedGlobalSymbols
            this._isFullscreen = false;
            if (aceEditor) {
              aceEditor.setOptions({
                maxLines: 100000
              });
              aceEditor.resize();
            }
          }
          context.invoke('toolbar.updateFullscreen', this.isFullscreen());
        };
      }
    });
  }
});

define("helpers/misc/attachment-insert-from-source", ["exports", "di", "metadata", "model-factory"], function (_exports, _di, _metadata, _modelFactory) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _metadata = _interopRequireDefault(_metadata);
  _modelFactory = _interopRequireDefault(_modelFactory);
  var _staticBlock;
  let _init_metadata, _init_extra_metadata, _init_modelFactory, _init_extra_modelFactory;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  /**
   * @internal
   */
  class AttachmentInsertSourceFromHelper {
    /**
     * @param {import('views/fields/attachment-multiple').default|import('views/fields/file').default} view
     */
    constructor(view) {
      _init_extra_modelFactory(this);
      /** @private */
      this.view = view;

      /** @private */
      this.model = view.model;
    }

    /**
     * @type {Metadata}
     * @private
     */
    metadata = _init_metadata(this);

    /**
     * @type {ModelFactory}
     * @private
     */
    modelFactory = (_init_extra_metadata(this), _init_modelFactory(this));

    /**
     * @param {{
     *     source: string,
     *     onInsert: function(import('model').default[]),
     * }} params
     */
    insert(params) {
      const source = params.source;
      const viewName = this.metadata.get(['clientDefs', 'Attachment', 'sourceDefs', source, 'insertModalView']) || this.metadata.get(['clientDefs', source, 'modalViews', 'select']) || 'views/modals/select-records';
      let filters = {};
      if ('getSelectFilters' + source in this.view) {
        filters = this.view['getSelectFilters' + source]() || {};
      }

      // @todo EntityType => link mapping defined in metadata for automatic filtering.
      if (this.model.attributes.parentId && this.model.attributes.parentType === 'Account') {
        if (this.metadata.get(`entityDefs.${source}.fields.account.type`) === 'link' && this.metadata.get(`entityDefs.${source}.links.account.entity`) === 'Account') {
          filters = {
            account: {
              type: 'equals',
              attribute: 'accountId',
              value: this.model.attributes.parentId,
              data: {
                type: 'is',
                idValue: this.model.attributes.parentId,
                nameValue: this.model.attributes.parentType
              }
            },
            ...filters
          };
        }
      }
      let boolFilterList = this.metadata.get(`clientDefs.Attachment.sourceDefs.${source}.boolFilterList`);
      if ('getSelectBoolFilterList' + source in this.view) {
        boolFilterList = this.view['getSelectBoolFilterList' + source]();
      }
      let primaryFilterName = this.metadata.get(`clientDefs.Attachment.sourceDefs.${source}.primaryFilter`);
      if ('getSelectPrimaryFilterName' + source in this.view) {
        primaryFilterName = this.view['getSelectPrimaryFilterName' + source]();
      }

      /** @type {module:views/modals/select-records~Options} */
      const options = {
        entityType: source,
        createButton: false,
        filters: filters,
        boolFilterList: boolFilterList,
        primaryFilterName: primaryFilterName,
        multiple: true,
        onSelect: models => {
          models.forEach(async model => {
            if (model.entityType === 'Attachment') {
              params.onInsert([model]);
              return;
            }

            /** @type {Record[]} */
            const attachmentDataList = await Espo.Ajax.postRequest(`${source}/action/getAttachmentList`, {
              id: model.id,
              field: this.view.name,
              parentType: this.view.entityType
            });
            const attachmentSeed = await this.modelFactory.create('Attachment');
            for (const item of attachmentDataList) {
              const attachment = attachmentSeed.clone();
              attachment.set(item);
              params.onInsert([attachment]);
            }
          });
        }
      };
      Espo.Ui.notifyWait();
      this.view.createView('modal', viewName, options, view => {
        view.render();
        Espo.Ui.notify();
      });
    }
    static #_ = _staticBlock = () => [_init_metadata, _init_extra_metadata, _init_modelFactory, _init_extra_modelFactory] = _applyDecs(this, [], [[(0, _di.inject)(_metadata.default), 0, "metadata"], [(0, _di.inject)(_modelFactory.default), 0, "modelFactory"]]).e;
  }
  _exports.default = AttachmentInsertSourceFromHelper;
  _staticBlock();
});

define("controller", ["exports", "exceptions", "bullbone", "di", "helpers/site/modal-bar-provider"], function (_exports, _exceptions, _bullbone, _di, _modalBarProvider) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _exceptions = _interopRequireDefault(_exceptions);
  _modalBarProvider = _interopRequireDefault(_modalBarProvider);
  var _staticBlock;
  let _init_modalBarProvider, _init_extra_modalBarProvider;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  /** @module controller */
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  /**
   * @callback module:controller~viewCallback
   * @param {import('view')} view A view.
   */

  /**
   * @callback module:controller~masterViewCallback
   * @param {module:views/site/master} view A master view.
   */

  /**
   * A controller. To be extended.
   *
   * @mixes Events
   */
  class Controller {
    /**
     * @internal
     * @param {Object.<string, *>} params
     * @param {Object} injections
     */
    constructor(params, injections) {
      _init_extra_modalBarProvider(this);
      this.params = params || {};

      /** @type {module:controllers/base} */
      this.baseController = injections.baseController;
      this.viewFactory = injections.viewFactory;
      /** @type {import('model-factory').default} */
      this.modelFactory = injections.modelFactory;
      /** @type {import('collection-factory').default} */
      this.collectionFactory = injections.collectionFactory;
      this._settings = injections.settings || null;
      this._user = injections.user || null;
      this._preferences = injections.preferences || null;
      this._acl = injections.acl || null;
      this._cache = injections.cache || null;
      this._router = injections.router || null;
      this._storage = injections.storage || null;
      this._metadata = injections.metadata || null;
      this._dateTime = injections.dateTime || null;
      this._broadcastChannel = injections.broadcastChannel || null;
      this.setMasterRendered(false);
    }

    /**
     * A default action.
     *
     * @type {string}
     */
    defaultAction = 'index';

    /**
     * A name.
     *
     * @type {string|null}
     */
    name = null;

    /**
     * Params.
     *
     * @type {Object}
     * @private
     */
    params = null;

    /**
     * A view factory.
     *
     * @type {import('bullbone').Factory}
     * @protected
     */
    viewFactory = null;

    /**
     * A model factory.
     *
     * @type {module:model-factory}
     * @protected
     */
    modelFactory = null;

    /**
     * A body view.
     *
     * @public
     * @type {string|null}
     */
    masterView = null;

    /**
     * @private
     * @type {ModalBarProvider}
     */
    modalBarProvider = _init_modalBarProvider(this);

    /**
     * Set the router.
     *
     * @internal
     * @param {import(router).default} router
     */
    setRouter(router) {
      this._router = router;
      this.trigger('router-set', router);
    }

    /**
     * @protected
     * @returns {module:models/settings}
     */
    getConfig() {
      return this._settings;
    }

    /**
     * @protected
     * @returns {module:models/user}
     */
    getUser() {
      return this._user;
    }

    /**
     * @protected
     * @returns {module:models/preferences}
     */
    getPreferences() {
      return this._preferences;
    }

    /**
     * @protected
     * @returns {module:acl-manager}
     */
    getAcl() {
      return this._acl;
    }

    /**
     * @protected
     * @returns {module:cache}
     */
    getCache() {
      return this._cache;
    }

    /**
     * @protected
     * @returns {import('router').default}
     */
    getRouter() {
      return this._router;
    }

    /**
     * @protected
     * @returns {module:storage}
     */
    getStorage() {
      return this._storage;
    }

    /**
     * @protected
     * @returns {module:metadata}
     */
    getMetadata() {
      return this._metadata;
    }

    /**
     * @protected
     * @returns {module:date-time}
     */
    getDateTime() {
      return this._dateTime;
    }

    /**
     * Get a parameter of all controllers.
     *
     * @param {string} key A key.
     * @return {*} Null if a key doesn't exist.
     */
    get(key) {
      if (key in this.params) {
        return this.params[key];
      }
      return null;
    }

    /**
     * Set a parameter for all controllers.
     *
     * @param {string} key A name of a view.
     * @param {*} value
     */
    set(key, value) {
      this.params[key] = value;
    }

    /**
     * Unset a parameter.
     *
     * @param {string} key A key.
     */
    unset(key) {
      delete this.params[key];
    }

    /**
     * Has a parameter.
     *
     * @param {string} key A key.
     * @returns {boolean}
     */
    has(key) {
      return key in this.params;
    }

    /**
     * @param {string} key
     * @param {string} [name]
     * @return {string}
     * @private
     */
    _composeScrollKey(key, name) {
      name = name || this.name;
      return `scrollTop-${name}-${key}`;
    }

    /**
     * @param {string} key
     * @return {string}
     * @private
     */
    _composeMainViewKey(key) {
      return `mainView-${this.name}-${key}`;
    }

    /**
     * Get a stored main view.
     *
     * @param {string} key A key.
     * @returns {import('view').default|null}
     */
    getStoredMainView(key) {
      return this.get(this._composeMainViewKey(key));
    }

    /**
     * Has a stored main view.
     * @param {string} key
     * @returns {boolean}
     */
    hasStoredMainView(key) {
      return this.has(this._composeMainViewKey(key));
    }

    /**
     * Clear a stored main view.
     * @param {string} key
     */
    clearStoredMainView(key) {
      const view = this.getStoredMainView(key);
      if (view) {
        view.remove(true);
      }
      this.unset(this._composeScrollKey(key));
      this.unset(this._composeMainViewKey(key));
    }

    /**
     * Store a main view.
     *
     * @param {string} key A key.
     * @param {import('view').default} view A view.
     */
    storeMainView(key, view) {
      this.set(this._composeMainViewKey(key), view);
      this.listenTo(view, 'remove', o => {
        o = o || {};
        if (o.ignoreCleaning) {
          return;
        }
        this.stopListening(view, 'remove');
        this.clearStoredMainView(key);
      });
    }

    /**
     * Check access to an action.
     *
     * @param {string} action An action.
     * @returns {boolean}
     */
    checkAccess(action) {
      return true;
    }

    /**
     * Process access check to the controller.
     */
    handleAccessGlobal() {
      if (!this.checkAccessGlobal()) {
        throw new _exceptions.default.AccessDenied("Denied access to '" + this.name + "'");
      }
    }

    /**
     * Check access to the controller.
     *
     * @returns {boolean}
     */
    checkAccessGlobal() {
      return true;
    }

    /**
     * Check access to an action. Throwing an exception.
     *
     * @param {string} action An action.
     */
    handleCheckAccess(action) {
      if (this.checkAccess(action)) {
        return;
      }
      const msg = action ? "Denied access to action '" + this.name + "#" + action + "'" : "Denied access to scope '" + this.name + "'";
      throw new _exceptions.default.AccessDenied(msg);
    }

    /**
     * Process an action.
     *
     * @param {string} action
     * @param {Object} options
     */
    doAction(action, options) {
      this.handleAccessGlobal();
      action = action || this.defaultAction;
      const method = 'action' + Espo.Utils.upperCaseFirst(action);
      if (!(method in this)) {
        throw new _exceptions.default.NotFound("Action '" + this.name + "#" + action + "' is not found");
      }
      const preMethod = 'before' + Espo.Utils.upperCaseFirst(action);
      const postMethod = 'after' + Espo.Utils.upperCaseFirst(action);
      if (preMethod in this) {
        this[preMethod].call(this, options || {});
      }
      this[method].call(this, options || {});
      if (postMethod in this) {
        this[postMethod].call(this, options || {});
      }
    }

    /**
     * Serve a master view. Render if not already rendered.
     *
     * @param {module:controller~masterViewCallback} callback A callback with a created master view.
     * @private
     */
    master(callback) {
      const entireView = this.getEntireView();
      if (entireView) {
        entireView.remove();
        this.setEntireView(null);
      }
      const masterView = this.getMasterView();
      if (masterView) {
        callback.call(this, masterView);
        return;
      }
      const viewName = this.masterView || 'views/site/master';
      this.viewFactory.create(viewName, {
        fullSelector: 'body'
      }, async (/** import('views/site/master').default */masterView) => {
        this.setMasterView(masterView);
        if (this.isMasterRendered()) {
          callback.call(this, masterView);
          return;
        }
        this.modalBarProvider.set(masterView.collapsedModalBarView || null);
        await masterView.render();
        this.setMasterRendered(true);
        callback.call(this, masterView);
      });
    }

    /**
     * @private
     * @return {import('view').default|null}
     */
    getEntireView() {
      return this.get('entire');
    }

    /**
     * @private
     * @param {import('view').default|null} view
     */
    setEntireView(view) {
      this.set('entire', view);
    }

    /**
     * @private
     * @return {import('views/site/master').default|null}
     */
    getMasterView() {
      return this.get('master');
    }

    /**
     * @private
     * @param {import('views/site/master').default|null} view
     */
    setMasterView(view) {
      if (!view) {
        this.modalBarProvider.set(null);
      }
      this.set('master', view);
    }

    /**
     * @private
     * @param {boolean} value
     */
    setMasterRendered(value) {
      this.set('masterRendered', value);
    }

    /**
     * @private
     * @return {boolean}
     */
    isMasterRendered() {
      return !!this.get('masterRendered');
    }

    /**
     * @param {import('views/site/master').default} masterView
     * @private
     */
    _unchainMainView(masterView) {
      if (!masterView.currentViewKey /*||
                                     !this.hasStoredMainView(masterView.currentViewKey)*/) {
        return;
      }
      const currentMainView = masterView.getMainView();
      if (!currentMainView) {
        return;
      }
      currentMainView.propagateEvent('remove', {
        ignoreCleaning: true
      });
      masterView.unchainView('main');
    }

    /**
     * @typedef {Object} module:controller~mainParams
     * @property {boolean} [useStored] Use a stored view if available.
     * @property {string} [key] A stored view key.
     */

    /**
     * Create a main view in the master container and render it.
     *
     * @param {string|import('view').default} [view] A view name or view instance.
     * @param {Object.<string, *>} [options] Options for a view.
     * @param {module:controller~viewCallback} [callback] A callback with a created view.
     * @param {module:controller~mainParams} [params] Parameters.
     */
    main(view, options, callback) {
      let params = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
      const dto = {
        isCanceled: false,
        key: params.key,
        useStored: params.useStored,
        callback: callback
      };
      const selector = '#main';
      const useStored = params.useStored || false;
      const key = params.key;
      this.listenToOnce(this.baseController, 'action', () => dto.isCanceled = true);
      const mainView = view && typeof view === 'object' ? view : undefined;
      const viewName = !mainView ? view || 'views/base' : undefined;
      this.master(async masterView => {
        if (dto.isCanceled) {
          return;
        }
        options = options || {};
        options.fullSelector = selector;
        if (useStored && this.hasStoredMainView(key)) {
          const mainView = this.getStoredMainView(key);
          let isActual = true;
          if (mainView && 'isActualForReuse' in mainView && typeof mainView.isActualForReuse === 'function') {
            isActual = mainView.isActualForReuse();
          }
          const lastUrl = mainView && 'lastUrl' in mainView ? mainView.lastUrl : null;
          if (isActual && (!lastUrl || lastUrl === this.getRouter().getCurrentUrl())) {
            this._processMain(mainView, masterView, dto);
            if ('setupReuse' in mainView && typeof mainView.setupReuse === 'function') {
              mainView.setupReuse(options.params || {});
            }
            return;
          }
          this.clearStoredMainView(key);
        }
        if (mainView) {
          this._unchainMainView(masterView);
          await masterView.assignView('main', mainView, selector);
          dto.isSet = true;
          this._processMain(view, masterView, dto);
          return;
        }
        this.viewFactory.create(viewName, options, view => {
          this._processMain(view, masterView, dto);
        });
      });
    }

    /**
     * @param {import('view').default} mainView
     * @param {import('views/site/master').default} masterView
     * @param {{
     *     isCanceled: boolean,
     *     key?: string,
     *     useStored?: boolean,
     *     callback?: module:controller~viewCallback,
     *     isSet?: boolean,
     * }} dto Data.
     * @private
     */
    _processMain(mainView, masterView, dto) {
      if (dto.isCanceled) {
        return;
      }
      const key = dto.key;
      if (key) {
        this.storeMainView(key, mainView);
      }
      const onAction = () => {
        mainView.cancelRender();
        dto.isCanceled = true;
      };
      mainView.listenToOnce(this.baseController, 'action', onAction);
      if (masterView.currentViewKey) {
        const scrollKey = this._composeScrollKey(masterView.currentViewKey, masterView.currentName);
        this.set(scrollKey, window.scrollY);
        if (!dto.isSet) {
          this._unchainMainView(masterView);
        }
      }
      masterView.currentViewKey = key;
      masterView.currentName = this.name;
      if (!dto.isSet) {
        masterView.setView('main', mainView);
      }
      const afterRender = () => {
        setTimeout(() => mainView.stopListening(this.baseController, 'action', onAction), 500);
        mainView.updatePageTitle();
        const scrollKey = this._composeScrollKey(key);
        if (dto.useStored && this.has(scrollKey)) {
          window.scrollTo({
            top: this.get(scrollKey)
          });
          return;
        }
        window.scrollTo({
          top: 0
        });
      };
      if (dto.callback) {
        this.listenToOnce(mainView, 'after:render', afterRender);
        dto.callback.call(this, mainView);
        return;
      }
      mainView.render().then(afterRender);
    }

    /**
     * Show a loading notify-message.
     */
    showLoadingNotification() {
      const master = this.getMasterView();
      if (!master) {
        return;
      }
      master.showLoadingNotification();
    }

    /**
     * Hide a loading notify-message.
     */
    hideLoadingNotification() {
      const master = this.getMasterView();
      if (!master) {
        return;
      }
      master.hideLoadingNotification();
    }

    /**
     * Create a view in the BODY element. Use for rendering separate pages without the default navbar and footer.
     * If a callback is not passed, the view will be automatically rendered.
     *
     * @param {string|import('view').default} view A view name or view instance.
     * @param {Object.<string, *>} [options] Options for a view.
     * @param {module:controller~viewCallback} [callback] A callback with a created view.
     */
    entire(view, options, callback) {
      const masterView = this.getMasterView();
      if (masterView) {
        masterView.remove();
      }
      this.setMasterView(null);
      this.setMasterRendered(false);
      if (typeof view === 'object') {
        view.setElement('body');
        this.viewFactory.prepare(view, () => {
          if (!callback) {
            view.render();
            return;
          }
          callback(view);
        });
        return;
      }
      options = options || {};
      options.fullSelector = 'body';
      this.viewFactory.create(view, options, view => {
        this.setEntireView(view);
        if (!callback) {
          view.render();
          return;
        }
        callback(view);
      });
    }
    static #_ = _staticBlock = () => [_init_modalBarProvider, _init_extra_modalBarProvider] = _applyDecs(this, [], [[(0, _di.inject)(_modalBarProvider.default), 0, "modalBarProvider"]]).e;
  }
  _staticBlock();
  Object.assign(Controller.prototype, _bullbone.Events);

  /** For backward compatibility. */
  Controller.extend = _bullbone.View.extend;
  var _default = _exports.default = Controller;
});

define("views/popup-notification", ["exports", "view", "jquery"], function (_exports, _view, _jquery) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  _jquery = _interopRequireDefault(_jquery);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * To be extended with an own template.
   *
   * @abstract
   */
  class PopupNotificationView extends _view.default {
    type = 'default';
    style = 'default';

    /**
     * @protected
     * @type {boolean}
     */
    closeButton = true;

    /**
     * @protected
     * @type {boolean}
     * @since 10.0
     */
    collapseButton = true;

    /**
     * @type {boolean}
     * @internal
     */
    isCollapsed = false;
    soundPath = 'client/sounds/cloud.ogg';

    /**
     * @param {{
     *     id: string,
     *     notificationData: Record,
     *     notificationId: string|null,
     *     isFirstCheck: boolean,
     *     onCollapse: function(),
     *     onExpand: function(),
     * }} options
     */
    constructor(options) {
      super(options);
      this.options = options;
    }
    init() {
      super.init();
      const id = this.options.id;
      const containerSelector = this.containerSelector = `#${id}`;
      this.setSelector(containerSelector);
      this.soundPath = this.getBasePath() + (this.getConfig().get('popupNotificationSound') || this.soundPath);
      this.on('render', () => {
        this.hide();
        if (this.isCollapsed) {
          return;
        }
        const className = 'popup-notification-' + Espo.Utils.toDom(this.type);
        (0, _jquery.default)('<div>').attr('id', id).addClass('popup-notification').addClass(className).addClass('popup-notification-' + this.style).appendTo('#popup-notifications-container');
        this.setElement(containerSelector);
      });
      this.on('after:render', () => {
        this.$el.find('[data-action="close"]').on('click', () => {
          this.resolveCancel();
        });
      });
      this.once('after:render', () => {
        this.onShow();
      });
      this.once('remove', function () {
        (0, _jquery.default)(containerSelector).remove();
      });
      this.notificationData = this.options.notificationData;
      this.notificationId = this.options.notificationId;
      this.id = this.options.id;
      if (!this.notificationId) {
        this.collapseButton = false;
      }
      this.addActionHandler('collapse', () => this.collapse());
    }
    data() {
      return {
        closeButton: this.closeButton,
        notificationData: this.notificationData,
        notificationId: this.notificationId,
        collapseButton: true
      };
    }

    /**
     * @internal
     * @since 10.0
     */
    hide() {
      this.element = undefined;
      (0, _jquery.default)(this.containerSelector).remove();
    }
    playSound() {
      if (!this.getPreferences().get('notificationSound')) {
        return;
      }
      const audio = new Audio(this.soundPath);
      audio.volume = 0.3;
      audio.play();
    }

    /**
     * @protected
     */
    onShow() {
      if (!this.options.isFirstCheck) {
        this.playSound();
      }
    }

    /**
     * An on-confirm action. To be extended.
     *
     * @protected
     */
    onConfirm() {}

    /**
     * An on-cancel action. To be extended.
     *
     * @protected
     */
    onCancel() {}
    resolveConfirm() {
      this.onConfirm();
      this.trigger('confirm');
      this.remove();
    }
    resolveCancel() {
      this.onCancel();
      this.trigger('cancel');
      this.remove();
    }

    // noinspection JSCheckFunctionSignatures
    /**
     * @deprecated Use `resolveConfirm`.
     */
    confirm() {
      console.warn(`Method 'confirm' in views/popup-notification is deprecated. Use 'resolveConfirm' instead.`);
      this.resolveConfirm();
    }

    /**
     * @deprecated Use `resolveCancel`.
     */
    cancel() {
      console.warn(`Method 'cancel' in views/popup-notification is deprecated. Use 'resolveCancel' instead.`);
      this.resolveCancel();
    }

    /**
     * Collapse.
     *
     * @since 10.0
     * @private
     */
    collapse() {
      this.isCollapsed = true;
      this.options.onCollapse();
      this.hide();
    }

    /**
     * Expand.
     *
     * @since 10.0
     * @internal
     */
    expand() {
      this.isCollapsed = false;
      this.options.onExpand();
      this.reRender(true);
    }

    /**
     * Collapse silently.
     *
     * @since 10.0
     * @internal
     */
    makeCollapsed() {
      this.isCollapsed = true;
      this.hide();
    }

    /**
     * Expand silently.
     *
     * @since 10.0
     * @internal
     */
    makeExpanded() {
      this.isCollapsed = false;
      this.reRender(true);
    }

    /**
     * Get title.
     *
     * @return string|null
     * @since 10.0
     */
    getTitle() {
      return null;
    }
  }
  var _default = _exports.default = PopupNotificationView;
});

define("views/main", ["exports", "view", "di", "helpers/site/shortcut-manager", "utils"], function (_exports, _view, _di, _shortcutManager, _utils) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  _shortcutManager = _interopRequireDefault(_shortcutManager);
  _utils = _interopRequireDefault(_utils);
  var _staticBlock;
  let _init_shortcutManager, _init_extra_shortcutManager;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  /**
   * A top-right menu item (button or dropdown action).
   * Handled by a class method `action{Action}`, a click handler or a handler class.
   */

  /**
   * Options.
   */

  /**
   * A base main view. The detail, edit, list views to be extended from.
   */
  class MainView extends _view.default {
    /**
     * A scope name.
     */
    scope = '';

    /**
     * A name.
     */
    name = '';

    /**
     * Top-right menu definitions.
     *
     * @internal
     */

    //private $headerActionsContainer: JQuery

    /**
     * A shortcut-key => action map.
     */
    shortcutKeys = null;
    shortcutManager = _init_shortcutManager(this);

    /**
     * @internal
     */
    lastUrl = (_init_extra_shortcutManager(this), null);
    headerActionItemTypeList = ['buttons', 'dropdown', 'actions'];
    /**
     * A root URL.
     */
    rootUrl = null;
    _reRenderHeaderOnSync = false;
    menuDisabled = false;
    init() {
      this.scope = this.options.scope ?? this.scope;
      let menu = {};
      this.options.params = this.options.params ?? {};
      if (this.name && this.scope) {
        const key = `clientDefs.${this.scope}.menu.${_utils.default.lowerCaseFirst(this.name)}`;
        menu = this.getMetadata().get(key) ?? {};
      }
      menu = _utils.default.cloneDeep(menu);
      let globalMenu = {};
      if (this.name) {
        const key = `clientDefs.Global.menu.${_utils.default.lowerCaseFirst(this.name)}`;
        globalMenu = _utils.default.cloneDeep(this.getMetadata().get(key) ?? {});
      }
      this._reRenderHeaderOnSync = false;
      this._menuHandlers = {};
      this.menu = menu;
      this.headerActionItemTypeList.forEach(type => {
        let itemList = (menu[type] ?? []).concat(globalMenu[type] ?? []);
        if (type === 'buttons') {
          itemList = itemList.sort((a, b) => {
            return (a.index ?? 0) - (b.index ?? 0);
          });
        }
        menu[type] = itemList;
        itemList.forEach(item => {
          var _item$data;
          const viewObject = this;
          if (!item.hander && (_item$data = item.data) !== null && _item$data !== void 0 && _item$data.handler) {
            item.handler = item.data.handler;
          }

          // @todo Set _reRenderHeaderOnSync to true if `acl` is set `ascScope` is not set?
          //     Set _reRenderHeaderOnSync in `addMenuItem` method.

          if ((item.initFunction || item.checkVisibilityFunction) && item.handler) {
            this.wait(new Promise(resolve => {
              const handler = item.handler || item.data.handler;
              Espo.loader.require(handler, Handler => {
                const handler = new Handler(viewObject);
                const name = item.name || item.action;
                if (name) {
                  this._menuHandlers[name] = handler;
                }
                if (item.initFunction) {
                  handler[item.initFunction].call(handler);
                }
                if (item.checkVisibilityFunction && this.model) {
                  this._reRenderHeaderOnSync = true;
                }
                resolve(undefined);
              });
            }));
          }
        });
      });
      if (this.model) {
        this.whenReady().then(() => {
          if (!this._reRenderHeaderOnSync) {
            return;
          }
          this.listenTo(this.model, 'sync', () => {
            this.reRenderHeader();
          });
        });
      }
      this.updateLastUrl();
      if (this.shortcutKeys) {
        this.shortcutKeys = _utils.default.cloneDeep(this.shortcutKeys);
      } else {
        this.shortcutKeys = {};
      }
      this.addHandler('click', '.action', (event, target) => {
        _utils.default.handleAction(this, event, target, {
          actionItems: [...this.menu.buttons, ...this.menu.dropdown],
          className: 'main-header-manu-action'
        });
      });
    }
    reRenderHeader() {
      var _this$getHeaderView;
      (_this$getHeaderView = this.getHeaderView()) === null || _this$getHeaderView === void 0 || _this$getHeaderView.reRender({
        buffer: true,
        force: true
      });
    }
    initShortcuts() {
      if (!this.shortcutKeys) {
        return;
      }
      this.shortcutManager.add(this, this.shortcutKeys);
      this.once('remove', () => {
        this.shortcutManager.remove(this);
      });
    }
    setupFinal() {
      this.initShortcuts();
    }

    /**
     * Update a last history URL.
     */
    updateLastUrl() {
      this.lastUrl = this.getRouter().getCurrentUrl();
    }

    /**
     * @internal
     */
    getMenu() {
      if (this.menuDisabled || !this.menu) {
        return {};
      }
      const menu = {};
      this.headerActionItemTypeList.forEach(type => {
        (this.menu[type] || []).forEach(item => {
          if (item === false) {
            menu[type].push(false);
            return;
          }
          item = _utils.default.clone(item);
          menu[type] = menu[type] || [];
          if (!_utils.default.checkActionAvailability(this.getHelper(), item)) {
            return;
          }
          if (!_utils.default.checkActionAccess(this.getAcl(), this.model || this.scope, item)) {
            return;
          }
          if (item.accessDataList) {
            if (!_utils.default.checkAccessDataList(item.accessDataList, this.getAcl(), this.getUser())) {
              return;
            }
          }
          item.name = item.name ?? item.action ?? null;
          item.action = item.action ?? null;
          if (item.name && this._menuHandlers[item.name] && item.checkVisibilityFunction) {
            const handler = this._menuHandlers[item.name];
            if (!handler[item.checkVisibilityFunction](item.name)) {
              return;
            }
          }
          menu[type].push(item);
        });
      });
      return menu;
    }

    /**
     * Get a header HTML. To be overridden.
     *
     * @returns HTML.
     */
    getHeader() {
      return '';
    }

    /**
     * Build a header HTML. To be called from the #getHeader method.
     * Beware of XSS.
     *
     * @param itemList A breadcrumb path. Like: Account > Name > edit.
     * @returns HTML
     */
    buildHeaderHtml(itemList) {
      var _$div$get;
      const $itemList = itemList.map(item => {
        return $('<div>').addClass('breadcrumb-item').append(item);
      });
      const $div = $('<div>').addClass('header-breadcrumbs');
      $itemList.forEach(($item, i) => {
        $div.append($item);
        if (i === $itemList.length - 1) {
          return;
        }
        $div.append($('<div>').addClass('breadcrumb-separator').append($('<span>')));
      });
      return (_$div$get = $div.get(0)) === null || _$div$get === void 0 ? void 0 : _$div$get.outerHTML;
    }

    /**
     * Get an icon HTML.
     *
     * @returns HTML
     */
    getHeaderIconHtml() {
      return this.getHelper().getScopeColorIconHtml(this.scope);
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * Action 'showModal'.
     *
     * @internal
     */
    async actionShowModal(data) {
      const viewName = data.view;
      if (!viewName) {
        return;
      }
      const view = await this.createView('modal', viewName, {
        model: this.model,
        collection: this.collection
      });
      this.listenTo(view, 'after:save', () => {
        if (this.model) {
          this.model.fetch();
        }
        if (this.collection) {
          this.collection.fetch();
        }
      });
      await view.render();
    }

    /**
     * Update a menu item.
     *
     * @param  name An item name.
     * @param item New item definitions to write.
     *
     * @since 8.2.0
     */
    updateMenuItem(name, item) {
      var _this$getHeaderView2;
      const actionItem = this._getHeaderActionItem(name);
      if (!actionItem) {
        return;
      }
      for (const key in item) {
        actionItem[key] = item[key];
      }
      (_this$getHeaderView2 = this.getHeaderView()) === null || _this$getHeaderView2 === void 0 || _this$getHeaderView2.reRenderButtons();
    }

    /**
     * Add a menu item.
     *
     * @param type A type.
     * @param item Item definitions.
     * @param toBeginning To beginning.
     */
    addMenuItem(type, item) {
      var _this$getHeaderView3;
      let toBeginning = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
      const list = this.menu[type];
      if (item) {
        item.name = item.name ?? item.action ?? _utils.default.generateId();
        const name = item.name;
        const index = list.findIndex(it => (it || {}).name === name);
        if (~index) {
          list.splice(index, 1);
        }
      }
      if (type === 'buttons' && item) {
        const itemIndex = item.index ?? 0;
        if (toBeginning) {
          const index = list.findIndex(it => ((it || {}).index ?? 0) >= itemIndex);
          if (index === -1) {
            var _list;
            itemIndex < (((_list = list[list.length - 1]) === null || _list === void 0 ? void 0 : _list.index) ?? 0) ? list.unshift(item) : list.push(item);
          } else {
            list.splice(index, 0, item);
          }
        } else {
          const index = list.length - list.slice().reverse().findIndex(it => ((it || {}).index ?? 0) <= itemIndex);
          if (index === list.length + 1) {
            var _list$;
            itemIndex < (((_list$ = list[0]) === null || _list$ === void 0 ? void 0 : _list$.index) ?? 0) ? list.unshift(item) : list.push(item);
          } else {
            list.splice(index, 0, item);
          }
        }
      }
      if (type !== 'buttons') {
        const list = this.menu[type];
        toBeginning ? list.unshift(item) : list.push(item);
      }
      (_this$getHeaderView3 = this.getHeaderView()) === null || _this$getHeaderView3 === void 0 || _this$getHeaderView3.reRenderButtons();
    }

    /**
     * Remove a menu item.
     *
     * @param name An item name.
     */
    removeMenuItem(name) {
      var _this$getHeaderView4;
      let index = -1;
      let type = false;
      this.headerActionItemTypeList.forEach(t => {
        (this.menu[t] ?? []).forEach((item, i) => {
          item = item || {};
          if (item.name === name) {
            index = i;
            type = t;
          }
        });
      });
      if (~index && type) {
        const items = this.menu[type];
        items.splice(index, 1);
      }
      (_this$getHeaderView4 = this.getHeaderView()) === null || _this$getHeaderView4 === void 0 || _this$getHeaderView4.reRenderButtons();
    }

    /**
     * Disable a menu item.
     *
     * @param name A name.
     */
    disableMenuItem(name) {
      var _this$getHeaderView5;
      const item = this._getHeaderActionItem(name);
      if (item) {
        item.disabled = true;
      }
      (_this$getHeaderView5 = this.getHeaderView()) === null || _this$getHeaderView5 === void 0 || _this$getHeaderView5.reRenderButtons();
    }

    /**
     * Enable a menu item.
     *
     * @param name A name.
     */
    enableMenuItem(name) {
      var _this$getHeaderView6;
      const item = this._getHeaderActionItem(name);
      if (item) {
        item.disabled = false;
      }
      (_this$getHeaderView6 = this.getHeaderView()) === null || _this$getHeaderView6 === void 0 || _this$getHeaderView6.reRenderButtons();
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * Action 'navigateToRoot'.
     *
     * @param data
     * @param event
     */
    actionNavigateToRoot(data, event) {
      // noinspection BadExpressionStatementJS
      data;
      event.stopPropagation();
      this.getRouter().checkConfirmLeaveOut(() => {
        var _this$options$params;
        const rootUrl = this.rootUrl ?? this.options.rootUrl ?? ((_this$options$params = this.options.params) === null || _this$options$params === void 0 ? void 0 : _this$options$params.rootUrl) ?? `#${this.scope}`;
        this.getRouter().navigate(rootUrl, {
          trigger: true,
          isReturn: true
        });
      });
    }
    _getHeaderActionItem(name) {
      for (const type of this.headerActionItemTypeList) {
        if (!this.menu[type]) {
          continue;
        }
        for (const item of this.menu[type]) {
          if (item && item.name === name) {
            return item;
          }
        }
      }
      return undefined;
    }

    /**
     * Hide a menu item.
     *
     * @param name A name.
     */
    hideHeaderActionItem(name) {
      var _this$getHeaderView7;
      const item = this._getHeaderActionItem(name);
      if (item) {
        item.hidden = true;
      }
      (_this$getHeaderView7 = this.getHeaderView()) === null || _this$getHeaderView7 === void 0 || _this$getHeaderView7.reRenderButtons();
    }

    /**
     * Show a hidden menu item.
     *
     * @param name A name.
     */
    async showHeaderActionItem(name) {
      var _this$getHeaderView8, _this$getHeaderView9;
      const item = this._getHeaderActionItem(name);
      if (item) {
        item.hidden = false;
      }
      await ((_this$getHeaderView8 = this.getHeaderView()) === null || _this$getHeaderView8 === void 0 ? void 0 : _this$getHeaderView8.reRenderButtons());
      (_this$getHeaderView9 = this.getHeaderView()) === null || _this$getHeaderView9 === void 0 || _this$getHeaderView9.trigger('action-item-update');
    }
    getHeaderView() {
      return this.getView('header');
    }
    /**
     * Called when a stored view is reused (by the controller).
     *
     * @param params Routing params.
     */
    setupReuse(params) {
      // noinspection BadExpressionStatementJS
      params;
      this.initShortcuts();
    }
    updatePageTitle() {}
    static #_ = _staticBlock = () => [_init_shortcutManager, _init_extra_shortcutManager] = _applyDecs(this, [], [[(0, _di.inject)(_shortcutManager.default), 0, "shortcutManager"]], 0, void 0, _view.default).e;
  }
  _staticBlock();
  var _default = _exports.default = MainView;
});

define("views/collapsed-modal", ["exports", "view"], function (_exports, _view) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class CollapsedModalView extends _view.default {
    templateContent = `
        <div class="title-container">
            <a role="button" data-action="expand" class="title">{{title}}</a>
        </div>
        <div class="close-container">
            <a role="button" data-action="close"><span class="fas fa-times"></span></a>
        </div>
    `;
    events = {
      /** @this CollapsedModalView */
      'click [data-action="expand"]': function () {
        this.expand();
      },
      /** @this CollapsedModalView */
      'click [data-action="close"]': function () {
        this.close();
      }
    };

    /**
     * @private
     */
    title;

    /**
     * @type {import('views/modal').default|import('views/popup-notification').default}
     */
    modalView;

    /**
     * @param {{
     *     modalView: import('views/modal').default|import('views/popup-notification').default,
     *     onClose: function(),
     *     onExpand: function(),
     *     duplicateNumber?: number|null,
     *     title?: string | null,
     * }} options
     */
    constructor(options) {
      super(options);
      this.options = options;
      this.modalView = options.modalView;
    }
    data() {
      let title = this.title;
      if (this.options.duplicateNumber) {
        title = `${this.title} ${this.options.duplicateNumber}`;
      }
      return {
        title: title
      };
    }
    setup() {
      this.title = this.options.title || 'no-title';
    }
    expand() {
      this.options.onExpand();
    }
    close() {
      this.options.onClose();
    }
  }

  // noinspection JSUnusedGlobalSymbols
  var _default = _exports.default = CollapsedModalView;
});

define("views/base", ["exports", "view"], function (_exports, _view) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/base */

  class BaseView extends _view.default {
    /**
     * @typedef {Object} module:views/base~options
     * @property {string} [template] A template.
     */

    /**
     * @param {module:views/base~options & Object.<string, *>} [options] Options.
     */
    constructor(options) {
      super(options);
    }
  }
  var _default = _exports.default = BaseView;
});

define("views/search/filter", ["exports", "view"], function (_exports, _view) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/search/filter */

  class FilterView extends _view.default {
    template = 'search/filter';
    data() {
      return {
        name: this.name,
        scope: this.model.entityType,
        notRemovable: this.options.notRemovable
      };
    }

    /**
     * @param {{
     *     name: string,
     *     viewName?: string|null,
     *     params?: Record|null,
     *     notRemovable?: boolean,
     *     model: import('model').default,
     * }} options Field view is supported as of v9.3.
     */
    constructor(options) {
      super(options);
      this.options = options;
    }
    setup() {
      const name = this.name = this.options.name;
      let viewName = this.options.viewName;
      if (!viewName) {
        let type = this.model.getFieldType(name);
        if (!type && name === 'id') {
          type = 'id';
        }
        if (type) {
          viewName = this.model.getFieldParam(name, 'view') || this.getFieldManager().getViewName(type);
        }
      }
      if (!viewName) {
        return;
      }
      this.createView('field', viewName, {
        mode: 'search',
        model: this.model,
        selector: '.field',
        name: name,
        searchParams: this.options.params
      }, view => {
        this.listenTo(view, 'change', () => this.trigger('change'));
        this.listenTo(view, 'search', () => this.trigger('search'));
      });
    }

    /**
     * @return {import('views/fields/base').default|null}
     */
    getFieldView() {
      return this.getView('field');
    }
    populateDefaults() {
      const view = this.getFieldView();
      if (!view) {
        return;
      }
      if (!('populateSearchDefaults' in view)) {
        return;
      }
      view.populateSearchDefaults();
    }
  }
  var _default = _exports.default = FilterView;
});

define("views/record/panels-container", ["exports", "view"], function (_exports, _view) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/record/panels-container */

  /**
   * A panel container view. For bottom and side views.
   */
  class PanelsContainerRecordView extends _view.default {
    /** @private */
    panelSoftLockedTypeList = ['default', 'acl', 'delimiter', 'dynamicLogic'];

    /**
     * A panel.
     *
     * @typedef {Object} module:views/record/panels-container~panel
     *
     * @property {string} name A name.
     * @property {boolean} [hidden] Hidden.
     * @property {string} [label] A label.
     * @property {'default'|'success'|'danger'|'warning'} [style] A style.
     * @property {string} [titleHtml] A title HTML.
     * @property {boolean} [notRefreshable] Not refreshable.
     * @property {boolean} [isForm] If for a form.
     * @property {module:views/record/panels-container~button[]} [buttonList] Buttons.
     * @property {module:views/record/panels-container~action[]} [actionList] Dropdown actions.
     * @property {string} [view] A view name.
     * @property {Object.<string, *>} [Options] A view options.
     * @property {boolean} [sticked] To stick to an upper panel.
     * @property {number} [tabNumber] A tab number.
     * @property {string} [aclScope] A scope to check access to.
     * @property {import('util').AccessDefs[]} [accessDataList] Access control defs.
     * @property {Record} [dynamicLogicVisible] Visibility rules.
     * @property {Record} [dynamicLogicStyled] Style rules.
     * @property {Record} [options] Options.
     * @property {boolean} [disabled] Disabled.
     */

    /**
     * A button. Handled by an `action{Action}` method or a click handler.
     *
     * @typedef {Object} module:views/record/panels-container~button
     *
     * @property {string} [action] An action.
     * @property {string} [name] A name. Required if a handler is used.
     * @property {boolean} [hidden] Hidden.
     * @property {string} [label] A label. Translatable.
     * @property {string} [html] A HTML.
     * @property {string} [text] A text.
     * @property {string} [title] A title (on hover). Translatable.
     * @property {Object.<string, (string|number|boolean)>} [data] Data attributes.
     * @property {string} [handler] A handler.
     * @property {string} [actionFunction] An action function.
     * @property {function()} [onClick] A click event.
     */

    /**
     * An action. Handled by an `action{Action}` method or a click handler.
     *
     * @typedef {Object} module:views/record/panels-container~action
     *
     * @property {string} [action] An action.
     * @property {string} [name] A name. Required if a handler is used.
     * @property {string} [link] A link URL.
     * @property {boolean} [hidden] Hidden.
     * @property {string} [label] A label. Translatable.
     * @property {string} [html] A HTML.
     * @property {string} [text] A text.
     * @property {string} [iconClass] An icon class. As of v10.0.
     * @property {Object.<string, (string|number|boolean)>} [data] Data attributes.
     * @property {string} [handler] A handler.
     * @property {string} [actionFunction] An action function.
     * @property {function()} [onClick] A click event.
     */

    /**
     * A panel list.
     *
     * @protected
     * @type {module:views/record/panels-container~panel[]}
     */
    panelList = null;

    /** @private */
    hasTabs = false;

    /**
     * @private
     * @type {Object.<string,*>[]|null}
     */
    tabDataList = null;

    /**
     * @protected
     */
    currentTab = 0;

    /**
     * @protected
     * @type {string}
     */
    scope = '';

    /**
     * @protected
     * @type {string}
     */
    entityType = '';

    /**
     * @protected
     * @type {string}
     */
    name = '';

    /**
     * A mode.
     *
     * @type 'detail'|'edit'
     */
    mode = 'detail';
    data() {
      const tabDataList = this.hasTabs ? this.getTabDataList() : [];
      return {
        panelList: this.panelList,
        scope: this.scope,
        entityType: this.entityType,
        tabDataList: tabDataList
      };
    }
    events = {
      'click .action': function (e) {
        const $target = $(e.currentTarget);
        const panel = $target.data('panel');
        if (!panel) {
          return;
        }
        const panelView = this.getView(panel);
        if (!panelView) {
          return;
        }
        let actionItems;
        if (typeof panelView.getButtonList === 'function' && typeof panelView.getActionList === 'function') {
          actionItems = [...panelView.getButtonList(), ...panelView.getActionList()];
        }
        Espo.Utils.handleAction(panelView, e.originalEvent, e.currentTarget, {
          actionItems: actionItems,
          className: 'panel-action'
        });

        // @todo Check data. Maybe pass cloned data with unset params.

        /*
        let action = $target.data('action');
        let data = $target.data();
          if (action && panel) {
            let method = 'action' + Espo.Utils.upperCaseFirst(action);
            let d = _.clone(data);
              delete d['action'];
            delete d['panel'];
              let view = this.getView(panel);
              if (view && typeof view[method] == 'function') {
                view[method].call(view, d, e);
            }
        }*/
      },
      'click .panels-show-more-delimiter [data-action="showMorePanels"]': 'actionShowMorePanels',
      /** @this module:views/record/panels-container */
      'click .tabs > button': function (e) {
        const tab = parseInt($(e.currentTarget).attr('data-tab'));
        this.selectTab(tab);
      }
    };
    afterRender() {
      this.adjustPanels();
    }
    adjustPanels() {
      if (!this.isRendered()) {
        return;
      }
      const $panels = this.$el.find('> .panel');
      $panels.removeClass('first').removeClass('last').removeClass('in-middle');
      const $visiblePanels = $panels.filter(`:not(.tab-hidden):not(.hidden)`);
      const groups = [];
      let currentGroup = [];
      let inTab = false;
      $visiblePanels.each((i, el) => {
        const $el = $(el);
        let breakGroup = false;
        if (!breakGroup && this.hasTabs && !inTab && $el.attr('data-tab') !== '-1') {
          inTab = true;
          breakGroup = true;
        }
        if (!breakGroup && !$el.hasClass('sticked')) {
          breakGroup = true;
        }
        if (breakGroup) {
          if (i !== 0) {
            groups.push(currentGroup);
          }
          currentGroup = [];
        }
        currentGroup.push($el);
        if (i === $visiblePanels.length - 1) {
          groups.push(currentGroup);
        }
      });
      groups.forEach(group => {
        group.forEach(($el, i) => {
          if (i === group.length - 1) {
            if (i === 0) {
              return;
            }
            $el.addClass('last');
            return;
          }
          if (i === 0 && group.length) {
            $el.addClass('first');
            return;
          }
          $el.addClass('in-middle');
        });
      });
    }

    /**
     * Set read-only.
     */
    setReadOnly() {
      this.readOnly = true;
    }

    /**
     * Set not read-only.
     */
    setNotReadOnly(onlyNotSetAsReadOnly) {
      this.readOnly = false;
      if (!onlyNotSetAsReadOnly) {
        return;
      }
      this.panelList.forEach(item => {
        this.applyAccessToActions(item.buttonList);
        this.applyAccessToActions(item.actionList);
        this.whenRendered().then(() => {
          if (this.getPanelActionsView(item.name)) {
            this.getPanelActionsView(item.name).reRender();
          }
        });
      });
    }

    /**
     * @private
     * @param {Object[]} actionList
     */
    applyAccessToActions(actionList) {
      if (!actionList) {
        return;
      }
      actionList.forEach(item => {
        if (!Espo.Utils.checkActionAvailability(this.getHelper(), item)) {
          item.hidden = true;
          return;
        }
        const access = Espo.Utils.checkActionAccess(this.getAcl(), this.model, item, true);
        if (access) {
          if (item.isHiddenByAcl) {
            item.isHiddenByAcl = false;
            item.hidden = false;
            delete item.hiddenByAclSoft;
          }
        } else if (!item.hidden) {
          item.isHiddenByAcl = true;
          item.hidden = true;
          delete item.hiddenByAclSoft;
          if (access === null) {
            item.hiddenByAclSoft = true;
          }
        }
      });
    }

    /**
     * Set up panel views.
     *
     * @protected
     */
    setupPanelViews() {
      this.panelList.forEach(p => {
        const name = p.name;
        let options = {
          model: this.model,
          panelName: name,
          selector: `.panel[data-name="${name}"] > .panel-body`,
          defs: p,
          mode: this.mode,
          recordHelper: this.recordHelper,
          inlineEditDisabled: this.inlineEditDisabled,
          readOnly: this.readOnly,
          disabled: p.hidden || false,
          recordViewObject: this.recordViewObject,
          dataObject: this.options.dataObject
        };
        options = _.extend(options, p.options);
        this.createView(name, p.view, options, view => {
          let hasSoftHidden = false;
          if ('getActionList' in view) {
            p.actionList = view.getActionList();
            this.applyAccessToActions(p.actionList);

            // noinspection JSUnresolvedReference
            if (p.actionList.find(it => it.hiddenByAclSoft)) {
              hasSoftHidden = true;
            }
          }
          if ('getButtonList' in view) {
            p.buttonList = view.getButtonList();
            this.applyAccessToActions(p.buttonList);

            // noinspection JSUnresolvedReference
            if (p.buttonList.find(it => it.hiddenByAclSoft)) {
              hasSoftHidden = true;
            }
          }
          if (hasSoftHidden) {
            this.listenToOnce(this.model, 'sync', () => {
              this.applyAccessToActions(p.actionList);
              this.applyAccessToActions(p.buttonList);
              view.whenRendered().then(() => {
                if (this.getPanelActionsView(name)) {
                  this.getPanelActionsView(name).reRender();
                }
              });
            });
          }
          if (view.titleHtml) {
            p.titleHtml = view.titleHtml;
          } else {
            if (p.label) {
              p.title = this.translate(p.label, 'labels', this.scope);
            } else {
              p.title = view.title;
            }
          }

          // @todo Use name_Actions.
          this.createView(name + 'Actions', 'views/record/panel-actions', {
            selector: `.panel[data-name="${p.name}"] > .panel-heading > .panel-actions-container`,
            model: this.model,
            defs: p,
            scope: this.scope,
            entityType: this.entityType
          });
        });
      });
    }

    /**
     * @param {string} name
     * @return {import('views/record/panel-actions')}
     */
    getPanelActionsView(name) {
      return this.getView(name + 'Actions');
    }

    /**
     * Set up panels.
     *
     * @protected
     */
    setupPanels() {}

    /**
     * Get field views.
     *
     * @param {boolean} [withHidden] With hidden.
     * @return {Object.<string, module:views/fields/base>}
     */
    getFieldViews(withHidden) {
      let fields = {};
      this.panelList.forEach(p => {
        const panelView = this.getPanelView(p.name);
        if ((!panelView.disabled || withHidden) && 'getFieldViews' in panelView) {
          fields = _.extend(fields, panelView.getFieldViews());
        }
      });
      return fields;
    }

    /**
     * Fetch.
     *
     * @return {Object.<string, *>}
     */
    fetch() {
      let data = {};
      this.panelList.forEach(p => {
        const panelView = this.getPanelView(p.name);
        if (!panelView.disabled && 'fetch' in panelView) {
          data = _.extend(data, panelView.fetch());
        }
      });
      return data;
    }

    /**
     * @private
     * @param name
     * @return {import('views/record/panels/side').default|import('views/record/panels/side').default|null}
     */
    getPanelView(name) {
      return this.getView(name);
    }

    /**
     * @param {string} name
     * @return {boolean}
     */
    hasPanel(name) {
      return !!this.panelList.find(item => item.name === name);
    }

    /**
     * @internal
     *
     * @param {string} name
     * @param [callback] Not to be used.
     * @param {boolean} [wasShown]
     */
    processShowPanel(name, callback) {
      let wasShown = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
      if (this.recordHelper.getPanelStateParam(name, 'hidden')) {
        return;
      }
      if (!this.hasPanel(name)) {
        return;
      }
      this.panelList.filter(item => item.name === name).forEach(item => {
        item.hidden = false;
        if (typeof item.tabNumber !== 'undefined') {
          this.controlTabVisibilityShow(item.tabNumber);
        }
      });
      this.showPanelFinalize(name, callback, wasShown);
    }

    /**
     * @internal
     *
     * @param {string} name
     * @param [callback] Not to be used.
     */
    processHidePanel(name, callback) {
      if (!this.recordHelper.getPanelStateParam(name, 'hidden')) {
        return;
      }
      if (!this.hasPanel(name)) {
        return;
      }
      this.panelList.filter(item => item.name === name).forEach(item => {
        item.hidden = true;
        if (typeof item.tabNumber !== 'undefined') {
          this.controlTabVisibilityHide(item.tabNumber);
        }
      });
      this.hidePanelFinalize(name, callback);
    }

    /**
     * @private
     *
     * @param {string} name
     * @param [callback] Not to be used.
     * @param {boolean} [wasShown]
     */
    async showPanelFinalize(name, callback, wasShown) {
      const process = wasRendered => {
        const view = this.getPanelView(name);
        if (view) {
          if (view.element) {
            const panelElement = view.element.closest('.panel');
            if (panelElement) {
              panelElement.classList.remove('hidden');
            }
          }
          view.disabled = false;
          view.trigger('show');
          view.trigger('panel-show-propagated');
          if (wasRendered && !wasShown && view.getFieldViews) {
            const fields = view.getFieldViews();
            if (fields) {
              for (const i in fields) {
                fields[i].reRender();
              }
            }
          }
        }
        if (typeof callback === 'function') {
          callback.call(this);
        }
      };
      if (this.isRendered()) {
        process(true);
        this.adjustPanels();
        return;
      }
      await this.whenRendered();
      process();
    }

    /**
     * @private
     *
     * @param {string} name
     * @param [callback] Not to be used.
     */
    async hidePanelFinalize(name, callback) {
      if (this.isRendered()) {
        const view = this.getPanelView(name);
        if (view) {
          if (view.element) {
            const panelElement = view.element.closest('.panel');
            if (panelElement) {
              panelElement.classList.add('hidden');
            }
          }
          view.disabled = true;
          view.trigger('hide');
        }
        if (typeof callback === 'function') {
          callback();
        }
        this.adjustPanels();
        return;
      }
      if (typeof callback === 'function') {
        await this.whenRendered();
        callback();
      }
    }

    /**
     * @param {string} name
     * @param {string} [softLockedType]
     * @param [callback] Not to be used.
     */
    showPanel(name, softLockedType, callback) {
      if (this.recordHelper.getPanelStateParam(name, 'hiddenLocked')) {
        return;
      }
      if (softLockedType) {
        const param = 'hidden' + Espo.Utils.upperCaseFirst(softLockedType) + 'Locked';
        this.recordHelper.setPanelStateParam(name, param, false);
        for (let i = 0; i < this.panelSoftLockedTypeList.length; i++) {
          const iType = this.panelSoftLockedTypeList[i];
          if (iType === softLockedType) {
            continue;
          }
          const iParam = 'hidden' + Espo.Utils.upperCaseFirst(iType) + 'Locked';
          if (this.recordHelper.getPanelStateParam(name, iParam)) {
            return;
          }
        }
      }
      const wasShown = this.recordHelper.getPanelStateParam(name, 'hidden') === false;
      this.recordHelper.setPanelStateParam(name, 'hidden', false);
      this.processShowPanel(name, callback, wasShown);
    }

    /**
     * @param {string} name
     * @param {boolean} [locked=false]
     * @param {string} [softLockedType]
     * @param [callback] Not to be used.
     */
    hidePanel(name, locked, softLockedType, callback) {
      this.recordHelper.setPanelStateParam(name, 'hidden', true);
      if (locked) {
        this.recordHelper.setPanelStateParam(name, 'hiddenLocked', true);
      }
      if (softLockedType) {
        const param = 'hidden' + Espo.Utils.upperCaseFirst(softLockedType) + 'Locked';
        this.recordHelper.setPanelStateParam(name, param, true);
      }
      this.processHidePanel(name, callback);
    }

    /**
     * @internal
     * @protected
     * @param {Object} layoutData
     */
    alterPanels(layoutData) {
      layoutData = layoutData || this.layoutData || {};
      const tabBreakIndexList = [];
      const tabDataList = [];
      for (const name in layoutData) {
        const item = layoutData[name];
        if (name === '_delimiter_') {
          this.panelList.push({
            name: name
          });
        }
        if (item.tabBreak) {
          tabBreakIndexList.push(item.index);
          tabDataList.push({
            index: item.index,
            label: item.tabLabel
          });
        }
      }

      /**
       * @private
       * @type {Object.<string, *>[]}
       */
      this.tabDataList = tabDataList.sort((v1, v2) => v1.index - v2.index);
      this.panelList = this.panelList.filter(item => {
        return !this.recordHelper.getPanelStateParam(item.name, 'hiddenLocked');
      });
      const newList = [];
      this.panelList.forEach((item, i) => {
        item.index = 'index' in item ? item.index : i;
        let allowedInLayout = false;
        if (item.name) {
          const itemData = layoutData[item.name] || {};
          if (itemData.disabled) {
            return;
          }
          if (layoutData[item.name]) {
            allowedInLayout = true;
          }
          for (const i in itemData) {
            item[i] = itemData[i];
          }
        }
        if (item.disabled && !allowedInLayout) {
          return;
        }
        item.tabNumber = tabBreakIndexList.length - tabBreakIndexList.slice().reverse().findIndex(index => item.index > index) - 1;
        if (item.tabNumber === tabBreakIndexList.length) {
          item.tabNumber = -1;
        }
        newList.push(item);
      });
      newList.sort((v1, v2) => v1.index - v2.index);
      const firstTabIndex = newList.findIndex(item => item.tabNumber !== -1);

      /*let firstNonHiddenTabIndex = newList.findIndex(item => item.tabNumber !== -1 && !item.hidden);
        if (firstNonHiddenTabIndex < 0) {
          firstNonHiddenTabIndex = firstTabIndex;
      }*/

      if (firstTabIndex !== -1) {
        newList[firstTabIndex].isTabsBeginning = true;
        this.hasTabs = true;
        this.currentTab = newList[firstTabIndex].tabNumber;
        this.panelList.filter(item => item.tabNumber !== -1 && item.tabNumber !== this.currentTab).forEach(item => {
          item.tabHidden = true;
        });
        this.panelList.forEach((item, i) => {
          if (item.tabNumber !== -1 && (i === 0 || this.panelList[i - 1].tabNumber !== item.tabNumber)) {
            item.sticked = false;
          }
        });
      }
      this.panelList = newList;
      if (this.recordViewObject && this.recordViewObject.dynamicLogic) {
        const dynamicLogic = this.recordViewObject.dynamicLogic;
        this.panelList.forEach(item => {
          if (item.dynamicLogicVisible) {
            dynamicLogic.addPanelVisibleCondition(item.name, item.dynamicLogicVisible);
            if (this.recordHelper.getPanelStateParam(item.name, 'hidden')) {
              item.hidden = true;
            }
          }
          if (item.style && item.style !== 'default' && item.dynamicLogicStyled) {
            dynamicLogic.addPanelStyledCondition(item.name, item.dynamicLogicStyled);
          }
        });
      }
      if (this.hasTabs && this.options.isReturn && this.isStoredTabForThisRecord()) {
        this.selectStoredTab();
      }
    }

    /**
     * @protected
     */
    setupPanelsFinal() {
      let afterDelimiter = false;
      let rightAfterDelimiter = false;
      let index = -1;
      this.panelList.forEach((p, i) => {
        if (p.name === '_delimiter_') {
          afterDelimiter = true;
          rightAfterDelimiter = true;
          index = i;
          return;
        }
        if (afterDelimiter) {
          p.hidden = true;
          p.hiddenAfterDelimiter = true;
          this.recordHelper.setPanelStateParam(p.name, 'hidden', true);
          this.recordHelper.setPanelStateParam(p.name, 'hiddenDelimiterLocked', true);
        }
        if (rightAfterDelimiter) {
          p.isRightAfterDelimiter = true;
          rightAfterDelimiter = false;
        }
      });
      if (~index) {
        this.panelList.splice(index, 1);
      }
      this.panelsAreSet = true;
      this.trigger('panels-set');
    }
    actionShowMorePanels() {
      this.panelList.forEach(/** module:views/record/panels-container~panel & Record*/p => {
        if (!p.hiddenAfterDelimiter) {
          return;
        }
        delete p.isRightAfterDelimiter;
        this.showPanel(p.name, 'delimiter');
      });
      this.$el.find('.panels-show-more-delimiter').remove();
    }

    /**
     * @internal
     * @protected
     * @param {function} callback
     */
    onPanelsReady(callback) {
      Promise.race([new Promise(resolve => {
        if (this.panelsAreSet) {
          resolve();
        }
      }), new Promise(resolve => {
        this.once('panels-set', resolve);
      })]).then(() => {
        callback.call(this);
      });
    }

    /**
     * @private
     * @return {{
     *     label: string,
     *     isActive: boolean,
     *     hidden: boolean,
     * }[]}
     */
    getTabDataList() {
      return this.tabDataList.map((item, i) => {
        let label = item.label;
        if (!label) {
          label = (i + 1).toString();
        } else if (label[0] === '$') {
          label = this.translate(label.substring(1), 'tabs', this.scope);
        }
        const hidden = this.panelList.filter(panel => panel.tabNumber === i).findIndex(panel => !this.recordHelper.getPanelStateParam(panel.name, 'hidden')) === -1;
        return {
          label: label,
          isActive: i === this.currentTab,
          hidden: hidden
        };
      });
    }

    /**
     * @private
     * @param {number} tab
     * @param {boolean} [doNotStore]
     */
    selectTab(tab) {
      let doNotStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
      this.currentTab = tab;
      if (this.isRendered()) {
        $('body > .popover').remove();
        this.$el.find('.tabs > button').removeClass('active');
        this.$el.find(`.tabs > button[data-tab="${tab}"]`).addClass('active');
        this.$el.find('.panel[data-tab]:not([data-tab="-1"])').addClass('tab-hidden');
        this.$el.find(`.panel[data-tab="${tab}"]`).removeClass('tab-hidden');
      }
      this.adjustPanels();
      this.panelList.filter(item => item.tabNumber === tab && item.name).forEach(item => {
        const view = this.getPanelView(item.name);
        if (view) {
          view.trigger('tab-show');
          view.propagateEvent('panel-show-propagated');
        }
        item.tabHidden = false;
      });
      this.panelList.filter(item => item.tabNumber !== tab && item.name).forEach(item => {
        const view = this.getPanelView(item.name);
        if (view) {
          view.trigger('tab-hide');
        }
        if (item.tabNumber > -1) {
          item.tabHidden = true;
        }
      });
      if (doNotStore) {
        return;
      }
      this.storeTab();
    }

    /** @private */
    storeTab() {
      const key = `tab_${this.name}`;
      const keyRecord = `tab_${this.name}_record`;
      this.getSessionStorage().set(key, this.currentTab);
      this.getSessionStorage().set(keyRecord, `${this.entityType}_${this.model.id}`);
    }

    /** @private */
    isStoredTabForThisRecord() {
      const keyRecord = `tab_${this.name}_record`;
      return this.getSessionStorage().get(keyRecord) === `${this.entityType}_${this.model.id}`;
    }

    /** @private */
    selectStoredTab() {
      const key = `tab_${this.name}`;
      const tab = this.getSessionStorage().get(key);
      if (tab > 0) {
        this.selectTab(tab);
      }
    }

    /**
     * @private
     * @param {number} tab
     */
    async controlTabVisibilityShow(tab) {
      if (!this.hasTabs) {
        return;
      }
      await this.whenRendered();
      if (this.element) {
        const tabElement = this.element.querySelector(`.tabs > [data-tab="${tab.toString()}"]`);
        if (tabElement) {
          tabElement.classList.remove('hidden');
        }
      }
    }

    /**
     * @private
     * @param {number} tab
     */
    async controlTabVisibilityHide(tab) {
      if (!this.hasTabs) {
        return;
      }
      await this.whenRendered();
      const panelList = this.panelList.filter(panel => panel.tabNumber === tab);
      const allHidden = panelList.findIndex(panel => !this.recordHelper.getPanelStateParam(panel.name, 'hidden')) === -1;
      if (!allHidden) {
        return;
      }
      if (this.element) {
        const tabElement = this.element.querySelector(`.tabs > [data-tab="${tab.toString()}"]`);
        if (tabElement) {
          tabElement.classList.add('hidden');
        }
      }
      if (this.currentTab === tab) {
        const firstVisiblePanel = this.panelList.find(panel => panel.tabNumber > -1 && !panel.hidden);
        const firstVisibleTab = firstVisiblePanel ? firstVisiblePanel.tabNumber : 0;
        this.selectTab(firstVisibleTab, true);
      }
    }

    /**
     * @protected
     */
    setupInitial() {
      // Handles the situation when the first tab is hidden.
      this.listenToOnce(this.model, 'sync', async (m, r, /** Record */o) => {
        if (o.action !== 'fetch') {
          return;
        }
        setTimeout(async () => {
          await this.whenRendered();
          if (!this.hasTabs) {
            return;
          }
          const firstVisiblePanel = this.panelList.find(p => !p.hidden && p.tabNumber > -1);
          if (!firstVisiblePanel) {
            return;
          }
          if (firstVisiblePanel.tabNumber > this.currentTab) {
            this.selectTab(firstVisiblePanel.tabNumber, true);
          }
        }, 1);
      });
    }
  }
  var _default = _exports.default = PanelsContainerRecordView;
});

define("views/record/list-expanded", ["exports", "views/record/list-base"], function (_exports, _listBase) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _listBase = _interopRequireDefault(_listBase);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ListExpandedRecordView extends _listBase.default {
    template = 'record/list-expanded';
    checkboxes = false;
    selectable = false;
    rowActionsView = null;

    /**
     * @internal
     */
    _internalLayoutType = 'list-row-expanded';
    paginationDisabled = true;
    header = false;
    listContainerEl = '> .list > ul';
    columnResize = false;
    init() {
      if (this.options.forcePagination) {
        this.paginationDisabled = false;
      }
      super.init();
    }
    setup() {
      super.setup();
      this.on('after:save', model => {
        const view = this.getView(model.id);
        if (!view) {
          return;
        }
        view.reRender();
      });

      // Prevents displaying an empty buttons container.
      this.displayTotalCount = false;
    }

    /**
     * @internal
     */
    _loadListLayout(callback) {
      const type = this.type + 'Expanded';
      this.layoutLoadCallbackList.push(callback);
      if (this.layoutIsBeingLoaded) {
        return;
      }
      this.layoutIsBeingLoaded = true;
      this.getHelper().layoutManager.get(this.collection.entityType, type, listLayout => {
        this.layoutLoadCallbackList.forEach(callbackItem => {
          callbackItem(listLayout);
          this.layoutLoadCallbackList = [];
          this.layoutIsBeingLoaded = false;
        });
      });
    }

    /**
     * @internal
     */
    _convertLayout(listLayout, model) {
      model = model || this.collection.prepareModel();
      const layout = {
        rows: [],
        right: false
      };
      for (const i in listLayout.rows) {
        const row = listLayout.rows[i];
        const layoutRow = [];
        for (const j in row) {
          const rowItem = row[j];
          const type = rowItem.type || model.getFieldType(rowItem.name) || 'base';
          const item = {
            name: rowItem.name + 'Field',
            field: rowItem.name,
            view: rowItem.view || model.getFieldParam(rowItem.name, 'view') || this.getFieldManager().getViewName(type),
            options: {
              defs: {
                name: rowItem.name,
                params: rowItem.params || {}
              },
              mode: 'list'
            },
            align: rowItem.align,
            small: rowItem.small,
            soft: rowItem.soft
          };
          if (rowItem.options) {
            for (const optionName in rowItem.options) {
              if (typeof item.options[optionName] !== 'undefined') {
                continue;
              }
              item.options[optionName] = rowItem.options[optionName];
            }
          }
          if (rowItem.link) {
            item.options.mode = 'listLink';
          }
          layoutRow.push(item);
        }
        layout.rows.push(layoutRow);
      }
      if ('right' in listLayout) {
        if (listLayout.right) {
          const name = listLayout.right.name || 'right';
          layout.right = {
            field: name,
            name: name,
            view: listLayout.right.view,
            options: {
              name: name,
              defs: {
                params: {
                  width: listLayout.right.width || '7%'
                }
              }
            }
          };
        }
      } else if (this.rowActionsView) {
        layout.right = this.getRowActionsDefs();
      }
      return layout;
    }
    getRowSelector(id) {
      return `li[data-id="${id}"]`;
    }
    getCellSelector(model, item) {
      const name = item.field || item.columnName;
      if (!model.id) {
        console.warn(`No record ID.`);
      }
      return `${this.getSelector()} ${this.getRowSelector(model.id)} .cell[data-name="${name}"]`;
    }
    getRowContainerHtml(id) {
      const li = document.createElement('li');
      li.dataset.id = id;
      li.className = 'list-group-item list-row';
      return li.outerHTML;
    }

    /**
     * @internal
     */
    prepareInternalLayout(internalLayout, model) {
      const rows = internalLayout.rows ?? [];
      rows.forEach(row => {
        row.forEach(cell => {
          cell.options ??= {};
          cell.options.fullSelector = this.getCellSelector(model, cell);
        });
      });
      if (internalLayout.right) {
        internalLayout.right.options ??= {};
        internalLayout.right.options.fullSelector = this.getCellSelector(model, internalLayout.right);
      }
    }
    fetchAttributeListFromLayout() {
      var _this$listLayout;
      const entityType = this.entityType;
      if (!((_this$listLayout = this.listLayout) !== null && _this$listLayout !== void 0 && _this$listLayout.rows) || !entityType) {
        return [];
      }
      const list = [];
      this.listLayout.rows.forEach(row => {
        row.forEach(item => {
          if (!item.name) {
            return;
          }
          const field = item.name;
          const fieldType = this.getMetadata().get(['entityDefs', entityType, 'fields', field, 'type']);
          if (!fieldType) {
            return;
          }
          this.getFieldManager().getEntityTypeFieldAttributeList(entityType, field).forEach(attribute => list.push(attribute));
        });
      });
      return list;
    }
  }
  var _default = _exports.default = ListExpandedRecordView;
});

define("views/record/panels/bottom", ["exports", "view"], function (_exports, _view) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/record/panels/bottom */

  /**
   * @typedef {Object} module:views/record/panels/bottom~defs
   * @property [buttonList]
   * @property [actionList]
   * @property [tabNumber] For internal purposes.
   */

  /**
   * A bottom panel.
   */
  class BottomPanelView extends _view.default {
    template = 'record/panels/side';

    /**
     * A field list.
     *
     * @protected
     * @type {module:views/record/panels/side~field[]}
     */
    fieldList;

    /**
     * @protected
     * @type {Array<module:views/record/panels-container~action|false>}
     */
    actionList;

    /**
     * @protected
     * @type {module:views/record/panels-container~button[]}
     */
    buttonList;

    /**
     * @protected
     * @type {module:views/record/panels/bottom~defs|Object.<string, *>}
     */
    defs;

    /**
     * A mode.
     *
     * @protected
     * @type {'list'|'detail'|'edit'}
     */
    mode = 'detail';

    /**
     * Disable.
     *
     * @protected
     */
    disabled = false;
    events = {
      /** @this BottomPanelView */
      'click .action': function (e) {
        Espo.Utils.handleAction(this, e.originalEvent, e.currentTarget, {
          actionItems: [...this.buttonList, ...this.actionList],
          className: 'panel-action'
        });
      }
    };
    data() {
      return {
        scope: this.scope,
        entityType: this.entityType,
        name: this.panelName,
        hiddenFields: this.recordHelper.getHiddenFields(),
        fieldList: this.getFieldList()
      };
    }
    init() {
      this.panelName = this.options.panelName;
      this.defs = this.options.defs || {};
      this.recordHelper = this.options.recordHelper;
      if ('disabled' in this.options) {
        this.disabled = this.options.disabled;
      }
      this.mode = this.options.mode || this.mode;
      this.readOnlyLocked = this.options.readOnlyLocked || this.readOnly;
      this.readOnly = this.readOnly || this.options.readOnly;
      this.inlineEditDisabled = this.inlineEditDisabled || this.options.inlineEditDisabled;
      this.buttonList = Espo.Utils.clone(this.defs.buttonList || this.buttonList || []);
      this.actionList = Espo.Utils.clone(this.defs.actionList || this.actionList || []);
      this.actionList.forEach(it => {
        if (it.name) {
          it.action = it.name;
        }
      });
      this.fieldList = this.options.fieldList || this.fieldList || [];
      this.recordViewObject = this.options.recordViewObject;
    }
    setup() {
      this.setupFields();
      this.fieldList = this.fieldList.map(d => {
        let item = d;
        if (typeof item !== 'object') {
          item = {
            name: item,
            viewKey: item + 'Field'
          };
        }
        item = Espo.Utils.clone(item);
        item.viewKey = item.name + 'Field';
        item.label = item.label || item.name;
        if (this.recordHelper.getFieldStateParam(item.name, 'hidden') !== null) {
          item.hidden = this.recordHelper.getFieldStateParam(item.name, 'hidden');
        } else {
          this.recordHelper.setFieldStateParam(item.name, 'hidden', item.hidden || false);
        }
        return item;
      });
      this.fieldList = this.fieldList.filter(item => {
        if (!item.name) {
          return;
        }
        if (!(item.name in ((this.model.defs || {}).fields || {}))) {
          return;
        }
        return true;
      });
      this.createFields();
    }

    /**
     * Set up fields.
     *
     * @protected
     */
    setupFields() {}

    /**
     * @return {module:views/record/panels-container~button[]}
     */
    getButtonList() {
      return this.buttonList || [];
    }

    /**
     * @return {module:views/record/panels-container~action[]}
     */
    getActionList() {
      return this.actionList || [];
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * Get field views.
     *
     * @return {Object.<string,module:views/fields/base>}
     */
    getFieldViews() {
      const fields = {};
      this.getFieldList().forEach(item => {
        if (this.hasView(item.viewKey)) {
          fields[item.name] = this.getView(item.viewKey);
        }
      });
      return fields;
    }

    /**
     * Get a field list.
     *
     * @return {module:views/record/panels/side~field[]}
     */
    getFieldList() {
      return this.fieldList.map(item => {
        if (typeof item !== 'object') {
          return {
            name: item
          };
        }
        return item;
      });
    }

    /**
     * @private
     */
    createFields() {
      this.getFieldList().forEach(item => {
        let view = null;
        let field;
        let readOnly = null;
        if (typeof item === 'object') {
          field = item.name;
          view = item.view;
          if ('readOnly' in item) {
            readOnly = item.readOnly;
          }
        } else {
          field = item;
        }
        if (!(field in this.model.defs.fields)) {
          return;
        }
        this.createField(field, view, null, null, readOnly);
      });
    }

    /**
     * Create a field view.
     *
     * @protected
     * @param {string} field A field name.
     * @param {string|null} [viewName] A view name/path.
     * @param {Object<string,*>} [params] Field params.
     * @param {'detail'|'edit'|'list'|null} [mode='edit'] A mode.
     * @param {boolean} [readOnly] Read-only.
     * @param {Object<string,*>} [options] View options.
     */
    createField(field, viewName, params, mode, readOnly, options) {
      const type = this.model.getFieldType(field) || 'base';
      viewName = viewName || this.model.getFieldParam(field, 'view') || this.getFieldManager().getViewName(type);
      const o = {
        model: this.model,
        selector: '.field[data-name="' + field + '"]',
        defs: {
          name: field,
          params: params || {}
        },
        mode: mode || this.mode,
        dataObject: this.options.dataObject
      };
      if (options) {
        for (const param in options) {
          o[param] = options[param];
        }
      }
      let readOnlyLocked = this.readOnlyLocked;
      if (this.readOnly) {
        o.readOnly = true;
      } else {
        if (readOnly !== null) {
          o.readOnly = readOnly;
        }
      }
      if (readOnly) {
        readOnlyLocked = true;
      }
      if (this.inlineEditDisabled) {
        o.inlineEditDisabled = true;
      }
      if (this.recordHelper.getFieldStateParam(field, 'hidden')) {
        o.disabled = true;
      }
      if (this.recordHelper.getFieldStateParam(field, 'hiddenLocked')) {
        o.disabledLocked = true;
      }
      if (this.recordHelper.getFieldStateParam(field, 'readOnly')) {
        o.readOnly = true;
      }
      if (this.recordHelper.getFieldStateParam(field, 'required') !== null) {
        o.defs.params.required = this.recordHelper.getFieldStateParam(field, 'required');
      }
      if (!readOnlyLocked && this.recordHelper.getFieldStateParam(field, 'readOnlyLocked')) {
        readOnlyLocked = true;
      }
      if (readOnlyLocked) {
        o.readOnlyLocked = readOnlyLocked;
      }
      if (this.recordHelper.hasFieldOptionList(field)) {
        o.customOptionList = this.recordHelper.getFieldOptionList(field);
      }
      if (this.recordViewObject) {
        o.validateCallback = () => this.recordViewObject.validateField(field);
      }
      const viewKey = field + 'Field';
      this.createView(viewKey, viewName, o);
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * Is tab-hidden.
     *
     * @return {boolean}
     */
    isTabHidden() {
      if (this.defs.tabNumber === -1 || typeof this.defs.tabNumber === 'undefined') {
        return false;
      }
      const parentView = this.getParentView();
      if (!parentView) {
        return this.defs.tabNumber > 0;
      }

      // noinspection JSUnresolvedReference
      if (parentView && parentView.hasTabs) {
        return parentView.currentTab !== this.defs.tabNumber;
      }
      return false;
    }
  }
  var _default = _exports.default = BottomPanelView;
});

define("views/modals/save-filters", ["exports", "views/modal", "model", "views/fields/varchar"], function (_exports, _modal, _model, _varchar) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  _model = _interopRequireDefault(_model);
  _varchar = _interopRequireDefault(_varchar);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class SaveFiltersModalView extends _modal.default {
    // language=Handlebars
    templateContent = `
        <div class="panel panel-default no-side-margin">
            <div class="panel-body">
                <div class="cell form-group" data-name="name">
                    <label
                        class="control-label"
                        data-name="name"
                    >{{translate 'name' category='fields'}}</label>
                    <div class="field" data-name="name">{{{nameField}}}</div>
                </div>
            </div>
        </div>
    `;
    cssName = 'save-filters';

    /**
     * @private
     * @type {VarcharFieldView}
     */
    nameFieldView;
    data() {
      return {
        dashletList: this.dashletList
      };
    }
    setup() {
      this.shortcutKeys = {
        'Control+Enter': e => {
          e.preventDefault();
          e.stopPropagation();
          this.actionSave();
        }
      };
      this.buttonList = [{
        name: 'save',
        label: 'Save',
        style: 'primary',
        onClick: () => this.actionSave()
      }, {
        name: 'cancel',
        label: 'Cancel',
        onClick: () => this.actionCancel()
      }];
      this.headerText = this.translate('Save Filter');
      this.formModel = new _model.default();
      this.nameFieldView = new _varchar.default({
        name: 'name',
        params: {
          required: true
        },
        mode: 'edit',
        model: this.formModel,
        labelText: this.translate('name', 'fields')
      });
      this.assignView('nameField', this.nameFieldView);
    }
    afterRender() {
      setTimeout(() => {
        var _this$nameFieldView$e;
        (_this$nameFieldView$e = this.nameFieldView.element.querySelector('input')) === null || _this$nameFieldView$e === void 0 || _this$nameFieldView$e.focus();
      }, 1);
    }
    actionSave() {
      this.fetchToModel();
      if (this.nameFieldView.validate()) {
        return;
      }
      this.trigger('save', this.formModel.attributes.name);
      return true;
    }

    /**
     * @private
     */
    fetchToModel() {
      this.formModel.setMultiple({
        ...this.nameFieldView.fetch()
      });
    }
  }
  var _default = _exports.default = SaveFiltersModalView;
});

define("views/fields/wysiwyg", ["exports", "views/fields/text", "helpers/misc/summernote-custom", "ui", "utils"], function (_exports, _text, _summernoteCustom, _ui, _utils) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _text = _interopRequireDefault(_text);
  _ui = _interopRequireDefault(_ui);
  _utils = _interopRequireDefault(_utils);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  let summernote;

  /**
   * Parameters.
   */

  /**
   * Options.
   */

  /**
   * A wysiwyg field.
   *
   */
  class WysiwygFieldView extends _text.default {
    type = 'wysiwyg';
    listTemplate = 'fields/wysiwyg/detail';
    detailTemplate = 'fields/wysiwyg/detail';
    editTemplate = 'fields/wysiwyg/edit';
    height = 250;
    rowsDefault = 10000;
    fallbackBodySideMargin = 5;
    fallbackBodyTopMargin = 4;
    seeMoreDisabled = true;
    fetchEmptyValueAsNull = true;
    validationElementSelector = '.note-editor';
    htmlPurificationDisabled = false;
    htmlPurificationForEditDisabled = false;
    tableClassName = 'table table-bordered';
    noStylesheet = false;
    useIframe = false;
    handlebars = false;

    /**
     * @internal
     */

    hasBodyPlainField = false;
    setup() {
      this.addHandler('click', '.note-editable', () => {
        this.fixPopovers();
      });
      this.addHandler('focus', '.note-editable', () => {
        var _this$$noteEditor;
        (_this$$noteEditor = this.$noteEditor) === null || _this$$noteEditor === void 0 || _this$$noteEditor.addClass('in-focus');
      });
      this.addHandler('blur', '.note-editable', () => {
        var _this$$noteEditor2;
        (_this$$noteEditor2 = this.$noteEditor) === null || _this$$noteEditor2 === void 0 || _this$$noteEditor2.removeClass('in-focus');
      });
      super.setup();
      this.loadSummernote();
      if ('height' in this.params) {
        this.height = this.params.height;
      }
      if ('minHeight' in this.params) {
        this.minHeight = this.params.minHeight;
      }
      this.useIframe = this.params.useIframe || this.useIframe;
      this.setupToolbar();
      this.setupIsHtml();
      this.once('remove', () => this.destroySummernote());
      this.on('inline-edit-off', () => this.destroySummernote());
      this.on('render', () => this.destroySummernote());
      this.once('remove', () => {
        $(window).off(`resize.${this.cid}`);
        if (this.$scrollable) {
          this.$scrollable.off(`scroll.${this.cid}-edit`);
        }
      });
    }
    loadSummernote() {
      this.wait(Espo.loader.requirePromise('lib!summernote').then(() => {
        summernote = $.summernote;

        // @ts-ignore
        if (!summernote.options || 'espoImage' in summernote.options) {
          return;
        }
        this.initEspoPlugin();
      }));
    }
    setupIsHtml() {
      if (!this.hasBodyPlainField) {
        return;
      }
      this.model.onChange({
        owner: this,
        attributes: ['isHtml'],
        callback: o => {
          if (o.ui && this.isEditMode()) {
            if (!this.isRendered()) {
              return;
            }
            if (this.isHtml()) {
              let value = this.plainToHtml(this.model.get(this.name));
              if (this.lastHtmlValue && this.model.get(this.name) === this.htmlToPlain(this.lastHtmlValue)) {
                value = this.lastHtmlValue;
              }
              this.model.set(this.name, value, {
                skipReRender: true
              });
              this.enableWysiwygMode();
              return;
            }
            this.lastHtmlValue = this.model.get(this.name);
            const value = this.htmlToPlain(this.model.get(this.name));
            this.disableWysiwygMode();
            this.model.set(this.name, value);
            return;
          }
          if (this.isDetailMode() && this.isRendered()) {
            this.reRender();
          }
        }
      });
    }
    data() {
      const data = super.data();
      data.useIframe = this.useIframe;
      data.isPlain = !this.isHtml();
      data.isNone = !data.isNotEmpty && data.valueIsSet && this.isDetailMode();

      // noinspection JSValidateTypes
      return data;
    }
    setupToolbar() {
      this.buttons = {};
      const codeviewName = this.getConfig().get('wysiwygCodeEditorDisabled') ? 'codeview' : 'aceCodeview';
      this.toolbar = this.params.toolbar || this.toolbar || [['style', ['style']], ['style', ['bold', 'italic', 'underline', 'clear']], ['fontsize', ['fontsize']], ['color', ['color']], ['para', ['ul', 'ol', 'paragraph']], ['height', ['height']], ['table', ['espoTable', 'espoLink', 'espoImage', 'hr']], ['misc', [codeviewName, 'fullscreen']]];
      if (this.params.toolbar) {
        return;
      }
      if (!this.params.attachmentField) {
        return;
      }
      this.toolbar.push(['attachment', ['attachment']]);
      this.buttons['attachment'] = () => {
        const ui = summernote.ui;
        const button = ui.button({
          contents: '<i class="fas fa-paperclip"></i>',
          tooltip: this.translate('Attach File'),
          click: () => {
            this.attachFile();
          }
        });
        return button.render();
      };
    }
    isHtml() {
      if (!this.hasBodyPlainField) {
        return true;
      }
      return !this.model.has('isHtml') || this.model.get('isHtml');
    }
    fixPopovers() {
      $('body > .note-popover').removeClass('hidden');
    }
    getValueForDisplay() {
      if (!this.isReadMode() && this.isHtml()) {
        return undefined;
      }
      const value = super.getValueForDisplay();
      if (!this.isHtml()) {
        return value;
      }
      return this.sanitizeHtml(value);
    }
    sanitizeHtml(value) {
      if (!value) {
        return '';
      }
      if (this.htmlPurificationDisabled) {
        return this.sanitizeHtmlLight(value);
      }
      value = this.getHelper().sanitizeHtml(value);
      if (this.isEditMode()) {
        // Trick to handle the issue that attributes are re-ordered.
        value = this.getHelper().sanitizeHtml(value);
      }
      return value;
    }
    sanitizeHtmlLight(value) {
      return this.getHelper().moderateSanitizeHtml(value);
    }
    getValueForEdit() {
      const value = this.model.get(this.name) || '';
      if (this.htmlPurificationForEditDisabled) {
        return this.sanitizeHtmlLight(value);
      }
      return this.sanitizeHtml(value);
    }
    afterRender() {
      super.afterRender();
      if (this.isEditMode()) {
        this.$summernote = this.$el.find('.summernote');
      }
      const language = this.getConfig().get('language');
      if (!(language in summernote.lang)) {
        summernote.lang[language] = this.getLanguage().translate('summernote', 'sets');
      }
      if (this.isEditMode()) {
        if (this.isHtml()) {
          this.enableWysiwygMode();
        } else {
          var _this$$element;
          (_this$$element = this.$element) === null || _this$$element === void 0 || _this$$element.removeClass('hidden');
        }
        if (this.params.attachmentField && this.isInlineEditMode()) {
          this.$el.find('.note-attachment').addClass('hidden');
        }
      }
      if (this.isReadMode()) {
        this.renderDetail();
      }
    }
    renderDetail() {
      if (!this.isHtml()) {
        this.$el.find('.plain').removeClass('hidden');
        return;
      }
      if (!this.useIframe) {
        this.$element = this.$el.find('.html-container');
        return;
      }
      this.$el.find('iframe').removeClass('hidden');
      const $iframe = this.$el.find('iframe');
      const iframeElement = $iframe.get(0);
      iframeElement.setAttribute('sandbox', '');
      if (!iframeElement || !iframeElement.contentWindow) {
        return;
      }
      $iframe.on('load', () => {
        $iframe.contents().find('a').attr('target', '_blank');
      });
      const documentElement = iframeElement.contentWindow.document;
      let bodyHtml = this.getValueForIframe();
      const useFallbackStylesheet = this.getThemeManager().getParam('isDark') && this.htmlHasColors(bodyHtml);
      const addFallbackClass = this.getThemeManager().getParam('isDark') && (this.htmlHasColors(bodyHtml) || this.noStylesheet);
      const $iframeContainer = $iframe.parent();
      addFallbackClass ? $iframeContainer.addClass('fallback') : $iframeContainer.removeClass('fallback');
      if (!this.noStylesheet) {
        const linkElement = iframeElement.contentWindow.document.createElement('link');
        linkElement.type = 'text/css';
        linkElement.rel = 'stylesheet';
        linkElement.href = this.getBasePath() + (useFallbackStylesheet ? this.getThemeManager().getIframeFallbackStylesheet() : this.getThemeManager().getIframeStylesheet());
        bodyHtml = linkElement.outerHTML + bodyHtml;
      }
      let headHtml = '';
      if (this.noStylesheet) {
        const styleElement = documentElement.createElement('style');
        styleElement.textContent = `\ntable.bordered, table.bordered td, table.bordered th {border: 1px solid;}\n`;
        headHtml = styleElement.outerHTML;
      }

      // noinspection HtmlRequiredTitleElement
      const documentHtml = `<head>${headHtml}</head><body>${bodyHtml}</body>`;

      // @ts-ignore
      documentElement.write(documentHtml);
      documentElement.close();
      const $body = $iframe.contents().find('html body');
      $body.find('img').each((_i, img) => {
        const $img = $(img);
        if ($img.css('max-width') !== 'none') {
          return;
        }
        $img.css('max-width', '100%');
      });
      const $document = $(documentElement);

      // Make dropdowns closed.
      $document.on('click', () => {
        const event = new MouseEvent('click', {
          bubbles: true
        });
        $iframe[0].dispatchEvent(event);
      });

      // Make notifications & global-search popup closed.
      $document.on('mouseup', () => {
        const event = new MouseEvent('mouseup', {
          bubbles: true
        });
        $iframe[0].dispatchEvent(event);
      });

      // Make shortcuts working.
      $document.on('keydown', e => {
        const originalEvent = e.originalEvent;
        const event = new KeyboardEvent('keydown', {
          bubbles: true,
          code: originalEvent.code,
          ctrlKey: originalEvent.ctrlKey,
          metaKey: originalEvent.metaKey,
          altKey: originalEvent.altKey
        });
        $iframe[0].dispatchEvent(event);
      });
      const processWidth = function () {
        const bodyElement = $body.get(0);
        if (bodyElement) {
          if (bodyElement.clientWidth !== iframeElement.scrollWidth) {
            iframeElement.style.height = iframeElement.scrollHeight + 20 + 'px';
          }
        }
      };
      if (useFallbackStylesheet) {
        $iframeContainer.css({
          paddingLeft: this.fallbackBodySideMargin + 'px',
          paddingRight: this.fallbackBodySideMargin + 'px',
          paddingTop: this.fallbackBodyTopMargin + 'px'
        });
      }
      const increaseHeightStep = 10;
      const processIncreaseHeight = function (iteration, previousDiff) {
        $body.css('height', '');
        iteration = iteration || 0;
        if (iteration > 200) {
          return;
        }
        iteration++;
        const diff = $document.height() - iframeElement.scrollHeight;
        if (typeof previousDiff !== 'undefined') {
          if (diff === previousDiff) {
            $body.css('height', iframeElement.clientHeight - increaseHeightStep + 'px');
            processWidth();
            return;
          }
        }
        if (diff) {
          const height = iframeElement.scrollHeight + increaseHeightStep;
          iframeElement.style.height = height + 'px';
          processIncreaseHeight(iteration, diff);
        } else {
          processWidth();
        }
      };
      const processBg = () => {
        var _iframeElement$conten;
        const color = (_iframeElement$conten = iframeElement.contentWindow) === null || _iframeElement$conten === void 0 ? void 0 : _iframeElement$conten.getComputedStyle($body.get(0)).backgroundColor;
        $iframeContainer.css({
          backgroundColor: color
        });
      };
      const processHeight = function (isOnLoad) {
        if (!isOnLoad) {
          $iframe.css({
            overflowY: 'hidden',
            overflowX: 'hidden'
          });
          iframeElement.style.height = '0px';
        } else if (iframeElement.scrollHeight >= $document.height()) {
          return;
        }
        const $body = $iframe.contents().find('html body');
        let height = $body.height();
        if (height === 0) {
          height = $body.children().height() + 100;
        }
        iframeElement.style.height = height + 'px';
        processIncreaseHeight();
        if (!isOnLoad) {
          $iframe.css({
            overflowY: 'hidden',
            overflowX: 'scroll'
          });
        }
      };
      $iframe.css({
        visibility: 'hidden'
      });
      setTimeout(() => {
        processHeight();
        $iframe.css({
          visibility: 'visible'
        });
        $iframe.on('load', () => {
          processHeight(true);
          if (useFallbackStylesheet && !this.noStylesheet) {
            processBg();
          }
        });
      }, 40);
      if (!this.model.get(this.name)) {
        $iframe.addClass('hidden');
      }
      let windowWidth = $(window).width();
      $(window).off('resize.' + this.cid);
      $(window).on('resize.' + this.cid, () => {
        if ($(window).width() !== windowWidth) {
          processHeight();
          windowWidth = $(window).width();
        }
      });
    }
    getValueForIframe() {
      return this.sanitizeHtml(this.model.get(this.name) || '');
    }
    enableWysiwygMode() {
      var _this$$element2;
      if (!this.$element) {
        return;
      }
      (_this$$element2 = this.$element) === null || _this$$element2 === void 0 || _this$$element2.addClass('hidden');
      this.$summernote.removeClass('hidden');
      const contents = this.getValueForEdit();
      this.$summernote.html(contents);

      // The same sanitizing in the email body field.
      this.$summernote.find('style').remove();
      this.$summernote.find('link[ref="stylesheet"]').remove();
      const keyMap = _utils.default.cloneDeep(summernote.options.keyMap);
      keyMap.pc['CTRL+K'] = 'espoLink.show';
      keyMap.mac['CMD+K'] = 'espoLink.show';
      keyMap.pc['CTRL+DELETE'] = 'removeFormat';
      keyMap.mac['CMD+DELETE'] = 'removeFormat';
      delete keyMap.pc['CTRL+ENTER'];
      delete keyMap.mac['CMD+ENTER'];
      delete keyMap.pc['CTRL+BACKSLASH'];
      delete keyMap.mac['CMD+BACKSLASH'];
      const toolbar = this.toolbar;
      let lastChangeKeydown = Date.now();
      const changeKeydownInterval = this.changeInterval * 1000;

      // noinspection JSUnusedGlobalSymbols
      const options = {
        handlebars: this.handlebars,
        prettifyHtml: false,
        // should not be true
        disableResizeEditor: true,
        isDark: this.getThemeManager().getParam('isDark'),
        espoView: this,
        lang: this.getConfig().get('language'),
        keyMap: keyMap,
        callbacks: {
          onImageUpload: files => {
            const file = files[0];
            _ui.default.notify(this.translate('Uploading...'));
            this.uploadInlineAttachment(file).then(attachment => {
              const url = '?entryPoint=attachment&id=' + attachment.id;
              // @ts-ignore
              this.$summernote.summernote('insertImage', url);
              _ui.default.notify();
            });
          },
          onBlur: () => {
            this.trigger('change');
          },
          onKeydown: () => {
            if (Date.now() - lastChangeKeydown > changeKeydownInterval) {
              this.trigger('change');
              lastChangeKeydown = Date.now();
            }
          }
        },
        onCreateLink(link) {
          return link;
        },
        toolbar: toolbar,
        buttons: this.buttons,
        dialogsInBody: this.$el,
        codeviewFilter: true,
        tableClassName: this.tableClassName,
        // Dnd has issues.
        disableDragAndDrop: true,
        colorButton: {
          foreColor: '#000000',
          backColor: '#FFFFFF'
        }
      };
      if (this.height) {
        options.height = this.height;
      } else {
        let $scrollable = this.$el.closest('.modal-body');
        if (!$scrollable.length) {
          $scrollable = $(window);
        }
        this.$scrollable = $scrollable;
        $scrollable.off(`scroll.${this.cid}-edit`);
        $scrollable.on(`scroll.${this.cid}-edit`, e => this.onScrollEdit(e));
      }
      if (this.minHeight) {
        options.minHeight = this.minHeight;
      }
      this.destroySummernote();

      // @ts-ignore
      this.$summernote.summernote(options);
      this.summernoteIsInitialized = true;
      this.$toolbar = this.$el.find('.note-toolbar');
      this.$area = this.$el.find('.note-editing-area');
      this.$noteEditor = this.$el.find('> .note-editor');
    }
    focusOnInlineEdit() {
      if (this.$noteEditor) {
        // @ts-ignore
        this.$summernote.summernote('focus');
        return;
      }
      super.focusOnInlineEdit();
    }
    uploadInlineAttachment(file) {
      return new Promise((resolve, reject) => {
        this.getModelFactory().create('Attachment').then(attachment => {
          const fileReader = new FileReader();
          fileReader.onload = e => {
            var _e$target;
            attachment.set('name', file.name);
            attachment.set('type', file.type);
            attachment.set('role', 'Inline Attachment');
            attachment.set('global', true);
            attachment.set('size', file.size);
            if (this.model.id) {
              attachment.set('relatedId', this.model.id);
            }
            attachment.set('relatedType', this.model.entityType);
            attachment.set('file', (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.result);
            attachment.set('field', this.name);
            attachment.save().then(() => resolve(attachment)).catch(() => reject());
          };
          fileReader.readAsDataURL(file);
        });
      });
    }
    destroySummernote() {
      if (this.summernoteIsInitialized && this.$summernote) {
        // @ts-ignore
        this.$summernote.summernote('destroyAceCodeview');
        // @ts-ignore
        this.$summernote.summernote('destroy');
        this.summernoteIsInitialized = false;
      }
    }
    plainToHtml(html) {
      html = html || '';
      return html.replace(/\n/g, '<br>');
    }
    htmlToPlain(html) {
      const div = document.createElement('div');
      div.innerHTML = html;
      function processNode(node) {
        if (node.nodeType === Node.TEXT_NODE) {
          return node.nodeValue;
        }
        if (node.nodeType === Node.ELEMENT_NODE) {
          if (node instanceof HTMLAnchorElement) {
            if (node.textContent === node.href) {
              return node.href;
            }
            return `${node.textContent} (${node.href})`;
          }
          if (node instanceof HTMLQuoteElement) {
            return `> ${node.textContent.trim()}`;
          }
          switch (node.tagName.toLowerCase()) {
            case 'br':
            case 'p':
            case 'div':
              return `\n${Array.from(node.childNodes).map(processNode).join('')}\n`;
          }
          return Array.from(node.childNodes).map(processNode).join('');
        }
        return '';
      }
      return processNode(div).replace(/\n{2,}/g, '\n\n').trim();
    }
    disableWysiwygMode() {
      var _this$$element3;
      this.destroySummernote();
      this.$noteEditor = null;
      if (this.$summernote) {
        this.$summernote.addClass('hidden');
      }
      (_this$$element3 = this.$element) === null || _this$$element3 === void 0 || _this$$element3.removeClass('hidden');
      if (this.$scrollable) {
        this.$scrollable.off('scroll.' + this.cid + '-edit');
      }
    }
    fetch() {
      const data = {};
      if (this.isHtml()) {
        // @ts-ignore
        let code = this.$summernote.summernote('code');
        if (code === '<p><br></p>') {
          code = '';
        }
        const imageTagString = `<img src="${window.location.origin}${window.location.pathname}?entryPoint=attachment`;
        code = code.replace(new RegExp(imageTagString.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1"), 'g'), '<img src="?entryPoint=attachment');
        data[this.name] = code;
      } else {
        var _this$$element4;
        data[this.name] = (_this$$element4 = this.$element) === null || _this$$element4 === void 0 ? void 0 : _this$$element4.val();
      }
      if (this.fetchEmptyValueAsNull && !data[this.name]) {
        data[this.name] = null;
      }
      return data;
    }
    onScrollEdit(e) {
      const $target = $(e.target);
      const toolbarHeight = this.$toolbar.height();
      const toolbarWidth = this.$toolbar.parent().width();
      let edgeTop = 0;
      let edgeTopAbsolute = 0;

      // noinspection JSIncompatibleTypesComparison
      if ($target.get(0) === window.document) {
        const $buttonContainer = $target.find('.detail-button-container:not(.hidden)');
        const offset = $buttonContainer.offset();
        if (offset) {
          edgeTop = offset.top + $buttonContainer.outerHeight();
          edgeTopAbsolute = edgeTop - $(window).scrollTop();
        }
      } else {
        const offset = $target.offset();
        if (offset) {
          edgeTop = offset.top;
          edgeTopAbsolute = edgeTop - $(window).scrollTop();
        }
      }
      const top = this.$el.offset().top;
      const bottom = top + this.$el.height() - toolbarHeight;
      let toStick = false;
      if (edgeTop > top && bottom > edgeTop) {
        toStick = true;
      }
      if (toStick) {
        this.$toolbar.css({
          top: edgeTopAbsolute + 'px',
          width: toolbarWidth + 'px'
        });
        this.$toolbar.addClass('sticked');
        this.$area.css({
          marginTop: toolbarHeight + 'px',
          backgroundColor: ''
        });
        return;
      }
      this.$toolbar.css({
        top: '',
        width: ''
      });
      this.$toolbar.removeClass('sticked');
      this.$area.css({
        marginTop: ''
      });
    }
    attachFile() {
      const $form = this.$el.closest('.record');
      $form.find(`.field[data-name="${this.params.attachmentField}"] input.file`).click();
      this.stopListening(this.model, 'attachment-uploaded:attachments');
      this.listenToOnce(this.model, 'attachment-uploaded:attachments', attachments => {
        if (this.isEditMode()) {
          const msg = this.translate('Attached') + '\n' + attachments.map(m => m.attributes.name).join('\n');
          _ui.default.notify(msg, 'success', 3000);
        }
      });
    }
    initEspoPlugin() {
      const langSets = this.getLanguage().get('Global', 'sets', 'summernote') || {
        image: {},
        link: {},
        video: {}
      };
      (0, _summernoteCustom.init)(langSets);
    }
    htmlHasColors(string) {
      if (string.includes('background-color:')) {
        return true;
      }
      if (string.includes('color:')) {
        return true;
      }
      if (string.includes('<font color="')) {
        return true;
      }
      return false;
    }

    /**
     * @since 8.4.0
     */
    insertText(text) {
      if (this.isHtml()) {
        // @ts-ignore
        this.$summernote.summernote('insertText', text);
      }
    }
    toSkipReRenderOnChange() {
      if (!this.element || !this.element.contains(document.activeElement)) {
        return false;
      }
      if (!this.model.hasChanged(this.name)) {
        return true;
      }
      return false;
    }
  }
  var _default = _exports.default = WysiwygFieldView;
});

define("views/fields/float", ["exports", "views/fields/int"], function (_exports, _int) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _int = _interopRequireDefault(_int);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/fields/float */

  /**
   * Parameters.
   */

  /**
   * Options.
   */

  /**
   * A float field.
   */
  class FloatFieldView extends _int.default {
    type = 'float';
    editTemplate = 'fields/float/edit';
    decimalMark = '.';
    decimalPlacesRawValue = 10;
    validations = ['required', 'float', 'range'];
    setup() {
      super.setup();
      if (this.getPreferences().has('decimalMark')) {
        this.decimalMark = this.getPreferences().get('decimalMark');
      } else if (this.getConfig().has('decimalMark')) {
        this.decimalMark = this.getConfig().get('decimalMark');
      }
      if (!this.decimalMark) {
        this.decimalMark = '.';
      }
      if (this.decimalMark === this.thousandSeparator) {
        this.thousandSeparator = '';
      }
    }
    setupAutoNumericOptions() {
      this.autoNumericOptions = {
        digitGroupSeparator: this.thousandSeparator || '',
        decimalCharacter: this.decimalMark,
        modifyValueOnWheel: false,
        selectOnFocus: false,
        decimalPlaces: this.decimalPlacesRawValue,
        decimalPlacesRawValue: this.decimalPlacesRawValue,
        allowDecimalPadding: false,
        showWarnings: false,
        // @ts-ignore
        formulaMode: true
      };
    }
    getValueForDisplay() {
      const value = isNaN(this.model.get(this.name)) ? null : this.model.get(this.name);
      return this.formatNumber(value);
    }
    formatNumberDetail(value) {
      if (value === null) {
        return '';
      }
      const decimalPlaces = this.params.decimalPlaces;
      if (decimalPlaces === 0) {
        value = Math.round(value);
      } else if (decimalPlaces) {
        value = Math.round(value * Math.pow(10, decimalPlaces)) / Math.pow(10, decimalPlaces);
      }
      const parts = value.toString().split(".");
      parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, this.thousandSeparator);
      if (decimalPlaces === 0) {
        return parts[0];
      }
      if (decimalPlaces) {
        let decimalPartLength = 0;
        if (parts.length > 1) {
          decimalPartLength = parts[1].length;
        } else {
          parts[1] = '';
        }
        if (decimalPlaces && decimalPartLength < decimalPlaces) {
          const limit = decimalPlaces - decimalPartLength;
          for (let i = 0; i < limit; i++) {
            parts[1] += '0';
          }
        }
      }
      return parts.join(this.decimalMark);
    }
    validateFloat() {
      const value = this.model.get(this.name);
      if (isNaN(value)) {
        const msg = this.translate('fieldShouldBeFloat', 'messages').replace('{field}', this.getLabelText());
        this.showValidationMessage(msg);
        return true;
      }
      return false;
    }
    parse(input) {
      let value = input !== '' ? input : null;
      if (value === null) {
        return null;
      }
      value = value.split(this.thousandSeparator).join('').split(this.decimalMark).join('.');
      return parseFloat(value);
    }
    fetch() {
      var _this$$element;
      const valueString = ((_this$$element = this.$element) === null || _this$$element === void 0 ? void 0 : _this$$element.val()) ?? '';
      const value = this.parse(valueString);
      return {
        [this.name]: value
      };
    }
  }
  var _default = _exports.default = FloatFieldView;
});

define("views/fields/file", ["exports", "views/fields/link", "helpers/file-upload", "helpers/misc/attachment-insert-from-source"], function (_exports, _link, _fileUpload, _attachmentInsertFromSource) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _link = _interopRequireDefault(_link);
  _fileUpload = _interopRequireDefault(_fileUpload);
  _attachmentInsertFromSource = _interopRequireDefault(_attachmentInsertFromSource);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * A file field.
   */
  class FileFieldView extends _link.default {
    type = 'file';
    listTemplate = 'fields/file/list';
    listLinkTemplate = 'fields/file/list';
    detailTemplate = 'fields/file/detail';
    editTemplate = 'fields/file/edit';
    showPreview = false;
    accept = null;
    defaultType = null;
    previewSize = 'small';
    validations = ['ready', 'required'];
    searchTypeList = ['isNotEmpty', 'isEmpty'];
    isUploading = false;
    data() {
      const data = {
        ...super.data(),
        id: this.model.get(this.idName),
        acceptAttribute: this.acceptAttribute,
        capture: this.params.capture
      };
      if (this.mode === this.MODE_EDIT) {
        data.sourceList = this.sourceList;
      }
      data.valueIsSet = this.model.has(this.idName);
      return data;
    }
    showValidationMessage(msg, selector, view) {
      const $label = this.$el.find('label');
      const title = $label.attr('title');
      $label.attr('title', '');
      super.showValidationMessage(msg, selector, view);
      $label.attr('title', title);
    }
    validateRequired() {
      if (!this.isRequired()) {
        return false;
      }
      if (this.model.get(this.idName) == null) {
        const msg = this.translate('fieldIsRequired', 'messages').replace('{field}', this.getLabelText());
        let $target;
        if (this.isUploading) {
          $target = this.$el.find('.gray-box');
        } else {
          $target = this.$el.find('.attachment-button label');
        }
        this.showValidationMessage(msg, $target);
        return true;
      }
      return false;
    }

    // noinspection JSUnusedGlobalSymbols
    validateReady() {
      if (this.isUploading) {
        const $target = this.$el.find('.gray-box');
        const msg = this.translate('fieldIsUploading', 'messages').replace('{field}', this.getLabelText());
        this.showValidationMessage(msg, $target);
        return true;
      }
      return false;
    }
    setup() {
      this.addHandler('click', 'a.remove-attachment', (_e, target) => this.removeAttachmentHandler(target));
      this.addHandler('change', 'input.file', (_e, target) => this.handeInputChange(target));
      this.addActionHandler('showImagePreview', e => this.showPreviewHandler(e));
      this.addActionHandler('insertFromSource', (_e, target) => this.insertFromSource(target.dataset.name));
      this.addHandler('keydown', 'label.attach-file-label', e => this.keydownAttachFileLabelHandler(e));
      this.nameName = this.name + 'Name';
      this.idName = this.name + 'Id';
      this.typeName = this.name + 'Type';
      this.foreignScope = 'Attachment';
      this.previewSize = this.options.previewSize || this.params.previewSize || this.previewSize;
      this.previewTypeList = this.getMetadata().get(['app', 'image', 'previewFileTypeList']) || [];
      this.imageSizes = this.getMetadata().get(['app', 'image', 'sizes']) || {};
      const sourceDefs = this.getMetadata().get(['clientDefs', 'Attachment', 'sourceDefs']) || {};
      this.sourceList = Espo.Utils.clone(this.params.sourceList || []);
      this.sourceList = this.sourceList.concat(this.getMetadata().get(['clientDefs', 'Attachment', 'generalSourceList']) || []).filter((item, i, self) => {
        return self.indexOf(item) === i;
      }).filter(item => {
        const defs = sourceDefs[item] || {};
        if (defs.accessDataList) {
          if (!Espo.Utils.checkAccessDataList(defs.accessDataList, this.getAcl(), this.getUser())) {
            return false;
          }
        }
        if (defs.configCheck) {
          const arr = defs.configCheck.split('.');
          if (!this.getConfig().getByPath(arr)) {
            return false;
          }
        }
        return true;
      });
      if ('showPreview' in this.params) {
        this.showPreview = this.params.showPreview;
      }
      if ('accept' in this.params) {
        this.accept = this.params.accept;
      }
      if (this.accept && this.accept.length) {
        this.acceptAttribute = this.accept.join(', ');
      }
      this.on('remove', () => {
        if (this.resizeIsBeingListened) {
          $(window).off('resize.' + this.cid);
        }
      });
      this.on('inline-edit-off', () => {
        this.isUploading = false;
      });
    }
    keydownAttachFileLabelHandler(e) {
      const key = Espo.Utils.getKeyFromKeyEvent(e);
      if (key === 'Enter') {
        const input = this.element.querySelector('input.file');
        input === null || input === void 0 || input.click();
      }
    }
    showPreviewHandler(e) {
      e.preventDefault();
      const id = this.model.get(this.idName);
      this.createView('preview', 'views/modals/image-preview', {
        id: id,
        model: this.model,
        name: this.model.get(this.nameName)
      }).then(view => {
        view.render();
      });
    }
    handeInputChange(input) {
      const files = input.files;
      if (!(files !== null && files !== void 0 && files.length)) {
        return;
      }
      this.uploadFile(files[0]);
      input.value = '';

      // @todo Test.
      // @todo The same in multiple.

      // Note: Event listeners are not cloned.
      const newInput = input.cloneNode(true);
      input.replaceWith(newInput);
    }
    removeAttachmentHandler(target) {
      var _div$parentElement;
      const div = target.parentElement;
      this.deleteAttachment();
      div === null || div === void 0 || (_div$parentElement = div.parentElement) === null || _div$parentElement === void 0 || _div$parentElement.remove();
      const input = this.element.querySelector('input.file');
      if (input) {
        input.value = '';
      }
      setTimeout(() => this.focusOnUploadButton(), 10);
    }
    afterRender() {
      if (this.mode === this.MODE_EDIT) {
        this.$attachment = this.$el.find('div.attachment');
        const name = this.model.get(this.nameName);
        const type = this.model.get(this.typeName) || this.defaultType;
        const id = this.model.get(this.idName);
        if (id) {
          this.addAttachmentBox(name, type, id);
        }
        this.$el.off('drop');
        this.$el.off('dragover');
        this.$el.off('dragleave');
        this.$el.on('drop', e => {
          e.preventDefault();
          e.stopPropagation();
          const event = e.originalEvent;
          if (event.dataTransfer && event.dataTransfer.files && event.dataTransfer.files.length) {
            this.uploadFile(event.dataTransfer.files[0]);
          }
        });
        this.$el.on('dragover', e => {
          e.preventDefault();
        });
        this.$el.on('dragleave', e => {
          e.preventDefault();
        });
      }
      if (this.mode === this.MODE_SEARCH) {
        const type = this.$el.find('select.search-type').val();
        this.handleSearchType(type);
      }
      if (this.mode === this.MODE_DETAIL) {
        if (this.previewSize === 'large') {
          this.handleResize();
          this.resizeIsBeingListened = true;
          $(window).on('resize.' + this.cid, () => {
            this.handleResize();
          });
        }
      }
    }
    focusOnInlineEdit() {
      this.focusOnUploadButton();
    }
    focusOnUploadButton() {
      const $element = this.$el.find('.attach-file-label');
      if ($element.length) {
        $element.focus();
      }
    }
    handleResize() {
      const width = this.$el.width();
      this.$el.find('img.image-preview').css('maxWidth', width + 'px');
    }
    getDetailPreview(name, type, id) {
      var _$$attr$attr$attr$att;
      if (!this.previewTypeList.includes(type)) {
        return name;
      }
      let previewSize = this.previewSize;
      if (this.isListMode()) {
        previewSize = this.params.listPreviewSize || 'small';
      }
      const src = this.getBasePath() + '?entryPoint=image&size=' + previewSize + '&id=' + id;
      let maxHeight = (this.imageSizes[previewSize] || {})[1];
      if (this.isListMode() && !this.params.listPreviewSize) {
        maxHeight = '';
      }

      // noinspection HtmlRequiredAltAttribute,RequiredAttributes
      const $img = $('<img>').attr('src', src).attr('alt', name).addClass('image-preview').css({
        maxWidth: (this.imageSizes[previewSize] || {})[0],
        maxHeight: maxHeight
      });
      if (this.mode === this.MODE_LIST_LINK) {
        var _$$attr$append$get;
        const link = `#${this.model.entityType}/view/${this.model.id}`;
        return (_$$attr$append$get = $('<a>').attr('href', link).append($img).get(0)) === null || _$$attr$append$get === void 0 ? void 0 : _$$attr$append$get.outerHTML;
      }
      return (_$$attr$attr$attr$att = $('<a>').attr('data-action', 'showImagePreview').attr('data-id', id).attr('title', name).attr('href', this.getImageUrl(id)).append($img).get(0)) === null || _$$attr$attr$attr$att === void 0 ? void 0 : _$$attr$attr$attr$att.outerHTML;
    }
    getEditPreview(name, type, id) {
      var _$$attr$attr$attr$att2;
      if (!this.previewTypeList.includes(type)) {
        return null;
      }

      // noinspection HtmlRequiredAltAttribute,RequiredAttributes
      return (_$$attr$attr$attr$att2 = $('<img>').attr('src', this.getImageUrl(id, 'small')).attr('title', name).attr('alt', name).attr('draggable', 'false').css({
        maxWidth: (this.imageSizes[this.previewSize] || {})[0],
        maxHeight: (this.imageSizes[this.previewSize] || {})[1]
      }).get(0)) === null || _$$attr$attr$attr$att2 === void 0 ? void 0 : _$$attr$attr$attr$att2.outerHTML;
    }
    getValueForDisplay() {
      if (!(this.isDetailMode() || this.isListMode())) {
        return '';
      }
      const name = this.model.get(this.nameName);
      const type = this.model.get(this.typeName) || this.defaultType;
      const id = this.model.get(this.idName);
      if (!id) {
        return false;
      }
      if (this.showPreview && ~this.previewTypeList.indexOf(type)) {
        var _$$addClass$append$ge;
        let className = '';
        if (this.isListMode() && this.params.listPreviewSize) {
          className += 'no-shrink';
        }
        const $item = $('<div>').addClass('attachment-preview').addClass(className).append(this.getDetailPreview(name, type, id));
        let containerClassName = 'attachment-block-container';
        if (this.previewSize === 'large') {
          containerClassName += ' attachment-block-container-large';
        }
        if (this.previewSize === 'small') {
          containerClassName += ' attachment-block-container-small';
        }
        return (_$$addClass$append$ge = $('<div>').addClass(containerClassName).append($('<div>').addClass('attachment-block attachment-block-preview').append($item)).get(0)) === null || _$$addClass$append$ge === void 0 ? void 0 : _$$addClass$append$ge.outerHTML;
      }
      const container = document.createElement('div');
      container.classList.add('attachment-block');
      container.append((() => {
        const span = document.createElement('span');
        span.classList.add('fas', 'fa-paperclip', 'text-soft', 'small');
        return span;
      })(), (() => {
        const a = document.createElement('a');
        a.target = '_blank';
        a.textContent = name;
        a.href = this.getDownloadUrl(id);
        return a;
      })());
      return container.outerHTML;
    }
    getImageUrl(id, size) {
      let url = this.getBasePath() + '?entryPoint=image&id=' + id;
      if (size) {
        url += '&size=' + size;
      }
      if (this.getUser().get('portalId')) {
        url += '&portalId=' + this.getUser().get('portalId');
      }
      return url;
    }
    getDownloadUrl(id) {
      let url = `${this.getBasePath()}?entryPoint=download&id=${id}`;
      if (this.getUser().get('portalId')) {
        url += '&portalId=' + this.getUser().get('portalId');
      }
      return url;
    }
    deleteAttachment() {
      const id = this.model.get(this.idName);
      const o = {};
      o[this.idName] = null;
      o[this.nameName] = null;
      this.model.setMultiple(o);
      this.$attachment.empty();
      if (!id || !this.model.isNew()) {
        return;
      }
      this.getModelFactory().create('Attachment').then(attachment => {
        attachment.id = id;
        attachment.destroy();
      });
    }
    setAttachment(attachment, ui) {
      const attributes = {};
      attributes[this.idName] = attachment.id;
      attributes[this.nameName] = attachment.get('name');
      this.model.setMultiple(attributes, {
        ui: ui
      });
    }
    getMaxFileSize() {
      let maxFileSize = this.params.maxFileSize || 0;
      const noChunk = !this.getConfig().get('attachmentUploadChunkSize');
      const attachmentUploadMaxSize = this.getConfig().get('attachmentUploadMaxSize') || 0;
      const appMaxUploadSize = this.getHelper().getAppParam('maxUploadSize') || 0;
      if (!maxFileSize || maxFileSize > attachmentUploadMaxSize) {
        maxFileSize = attachmentUploadMaxSize;
      }
      if (noChunk && maxFileSize > appMaxUploadSize) {
        maxFileSize = appMaxUploadSize;
      }
      return maxFileSize;
    }
    uploadFile(file) {
      let isCanceled = false;
      let exceedsMaxFileSize = false;
      const maxFileSize = this.getMaxFileSize();
      if (maxFileSize && file.size > maxFileSize * 1024 * 1024) {
        exceedsMaxFileSize = true;
      }
      if (exceedsMaxFileSize) {
        const msg = this.translate('fieldMaxFileSizeError', 'messages').replace('{field}', this.getLabelText()).replace('{max}', maxFileSize.toString());
        this.showValidationMessage(msg, '.attachment-button label');
        return;
      }
      this.isUploading = true;
      const uploadHelper = new _fileUpload.default();
      this.getModelFactory().create('Attachment').then(attachment => {
        const $attachmentBox = this.addAttachmentBox(file.name, file.type);
        const $uploadingMsg = $attachmentBox.parent().find('.uploading-message');
        this.$el.find('.attachment-button').addClass('hidden');
        const mediator = {};
        $attachmentBox.find('.remove-attachment').on('click.uploading', () => {
          isCanceled = true;
          this.isUploading = false;
          this.$el.find('.attachment-button').removeClass('hidden');
          this.$el.find('input.file').val(null);
          mediator.isCanceled = true;
        });
        attachment.set('role', 'Attachment');
        attachment.set('relatedType', this.model.entityType);
        attachment.set('field', this.name);
        this.handleUploadingFile(file).then(file => {
          uploadHelper.upload(file, attachment, {
            afterChunkUpload: size => {
              const msg = Math.floor(size / file.size * 100) + '%';
              $uploadingMsg.html(msg);
            },
            afterAttachmentSave: attachment => {
              $attachmentBox.attr('data-id', attachment.id);
            },
            mediator: mediator
          }).then(() => {
            if (isCanceled) {
              return;
            }
            if (!this.isUploading) {
              return;
            }
            this.setAttachment(attachment, true);
            $attachmentBox.trigger('ready');
            this.isUploading = false;
            setTimeout(() => {
              if (document.activeElement && document.activeElement.tagName !== 'BODY') {
                return;
              }
              const $a = this.$el.find('.preview a');
              $a.focus();
            }, 50);
          }).catch(() => {
            if (mediator.isCanceled) {
              return;
            }
            $attachmentBox.remove();
            this.$el.find('.uploading-message').remove();
            this.$el.find('.attachment-button').removeClass('hidden');
            this.isUploading = false;
          });
        });
      });
    }
    handleUploadingFile(file) {
      return new Promise(resolve => resolve(file));
    }
    getBoxPreviewHtml(name, type, id) {
      var _$$attr$attr$text$get;
      const $text = $('<span>').text(name);
      if (!id) {
        var _$text$get;
        return (_$text$get = $text.get(0)) === null || _$text$get === void 0 ? void 0 : _$text$get.outerHTML;
      }
      if (this.showPreview) {
        const html = this.getEditPreview(name, type, id);
        if (html) {
          return html;
        }
      }
      const url = this.getBasePath() + '?entryPoint=download&id=' + id;
      return (_$$attr$attr$text$get = $('<a>').attr('href', url).attr('target', '_BLANK').text(name).get(0)) === null || _$$attr$attr$text$get === void 0 ? void 0 : _$$attr$attr$text$get.outerHTML;
    }
    addAttachmentBox(name, type, id) {
      this.$attachment.empty();
      const $remove = $('<a>').attr('role', 'button').attr('tabindex', '0').addClass('remove-attachment pull-right').append($('<span>').addClass('fas fa-times'));
      const previewHtml = this.getBoxPreviewHtml(name, type, id);
      const $att = $('<div>').addClass('gray-box').append($remove).append($('<span>').addClass('preview').append($(previewHtml)));
      const $container = $('<div>').append($att);
      this.$attachment.append($container);
      if (id) {
        return $att;
      }
      const $loading = $('<span>').addClass('small uploading-message').text(this.translate('Uploading...'));
      $container.append($loading);
      $att.on('ready', () => {
        const id = this.model.get(this.idName);
        const previewHtml = this.getBoxPreviewHtml(name, type, id);
        $att.find('.preview').html(previewHtml);
        $loading.html(this.translate('Ready'));
        if ($att.find('.preview').find('img').length) {
          $loading.remove();
        }
      });
      return $att;
    }
    insertFromSource(source) {
      const helper = new _attachmentInsertFromSource.default(this);
      helper.insert({
        source: source,
        onInsert: models => {
          models.forEach(model => this.setAttachment(model));
        }
      });
    }
    fetch() {
      const data = {};
      data[this.idName] = this.model.get(this.idName);
      return data;
    }
  }
  var _default = _exports.default = FileFieldView;
});

define("views/fields/date", ["exports", "views/fields/base", "moment", "ui/datepicker", "jquery"], function (_exports, _base, _moment, _datepicker, _jquery) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  _moment = _interopRequireDefault(_moment);
  _datepicker = _interopRequireDefault(_datepicker);
  _jquery = _interopRequireDefault(_jquery);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/fields/date */

  const $ = _jquery.default;
  /**
   * A date field.
   */
  class DateFieldView extends _base.default {
    type = 'date';
    listTemplate = 'fields/date/list';
    listLinkTemplate = 'fields/date/list-link';
    detailTemplate = 'fields/date/detail';
    editTemplate = 'fields/date/edit';
    searchTemplate = 'fields/date/search';
    validations = ['required', 'date', 'after', 'before'];
    searchTypeList = ['lastSevenDays', 'ever', 'isEmpty', 'currentMonth', 'lastMonth', 'nextMonth', 'currentQuarter', 'lastQuarter', 'currentYear', 'lastYear', 'today', 'past', 'future', 'lastXDays', 'nextXDays', 'olderThanXDays', 'afterXDays', 'on', 'after', 'before', 'between'];
    searchWithPrimaryTypeList = ['on', 'notOn', 'after', 'before'];
    searchWithRangeTypeList = ['between'];
    searchWithAdditionalNumberTypeList = ['lastXDays', 'nextXDays', 'olderThanXDays', 'afterXDays'];

    /**
     * @inheritDoc
     */
    initialSearchIsNotIdle = true;
    datepicker = null;
    setup() {
      super.setup();
      if (this.getConfig().get('fiscalYearShift')) {
        this.searchTypeList = Espo.Utils.clone(this.searchTypeList);
        if (this.getConfig().get('fiscalYearShift') % 3 !== 0) {
          this.searchTypeList.push('currentFiscalQuarter');
          this.searchTypeList.push('lastFiscalQuarter');
        }
        this.searchTypeList.push('currentFiscalYear');
        this.searchTypeList.push('lastFiscalYear');
      }
      if (this.params.after) {
        this.listenTo(this.model, `change:${this.params.after}`, async () => {
          if (!this.isEditMode()) {
            return;
          }
          await this.whenRendered();

          // Timeout prevents the picker popping one when the duration field adjusts the date end.
          setTimeout(() => {
            var _this$datepicker;
            this.onAfterChange();
            (_this$datepicker = this.datepicker) === null || _this$datepicker === void 0 || _this$datepicker.setStartDate(this.getStartDateForDatePicker());
          }, 100);
        });
      }
      this.useNumericFormat = this.getConfig().get('readableDateFormatDisabled') || this.params.useNumericFormat;
    }
    data() {
      const data = super.data();
      data.dateValue = this.getDateStringValue();
      data.isNone = data.dateValue === null;
      if (data.dateValue === -1) {
        data.dateValue = null;
        data.isLoading = true;
      }
      if (this.isSearchMode()) {
        var _this$searchParams, _this$searchParams2;
        const value = this.getSearchParamsData().value || ((_this$searchParams = this.searchParams) === null || _this$searchParams === void 0 ? void 0 : _this$searchParams.dateValue);
        const valueTo = this.getSearchParamsData().valueTo || ((_this$searchParams2 = this.searchParams) === null || _this$searchParams2 === void 0 ? void 0 : _this$searchParams2.dateValueTo);
        data.dateValue = this.getDateTime().toDisplayDate(value);
        data.dateValueTo = this.getDateTime().toDisplayDate(valueTo);
        if (this.searchWithAdditionalNumberTypeList.includes(this.getSearchType() ?? '')) {
          var _this$searchParams3;
          data.number = (_this$searchParams3 = this.searchParams) === null || _this$searchParams3 === void 0 ? void 0 : _this$searchParams3.value;
        }
      }
      if (this.isListMode()) {
        data.titleDateValue = data.dateValue;
      }
      if (this.useNumericFormat) {
        data.useNumericFormat = true;
      }

      // noinspection JSValidateTypes
      return data;
    }
    setupSearch() {
      this.addHandler('change', 'select.search-type', (_e, target) => {
        this.handleSearchType(target.value);
        this.trigger('change');
      });
      this.addHandler('change', 'input.number', () => this.trigger('change'));
    }
    stringifyDateValue(value) {
      if (!value) {
        if (this.mode === this.MODE_EDIT || this.mode === this.MODE_SEARCH || this.mode === this.MODE_LIST || this.mode === this.MODE_LIST_LINK) {
          return '';
        }
        return null;
      }
      if (this.mode === this.MODE_LIST || this.mode === this.MODE_DETAIL || this.mode === this.MODE_LIST_LINK) {
        return this.convertDateValueForDetail(value);
      }
      return this.getDateTime().toDisplayDate(value);
    }
    convertDateValueForDetail(value) {
      if (this.useNumericFormat) {
        return this.getDateTime().toDisplayDate(value);
      }
      const timezone = this.getDateTime().getTimeZone();
      const internalDateTimeFormat = this.getDateTime().internalDateTimeFormat;
      const readableFormat = this.getDateTime().getReadableDateFormat();
      const valueWithTime = value + ' 00:00:00';

      // @ts-ignore
      const today = _moment.default.tz(timezone).startOf('day');
      // @ts-ignore
      let dateTime = _moment.default.tz(valueWithTime, internalDateTimeFormat, timezone);
      const temp = today.clone();
      const ranges = {
        'today': [temp.unix(), temp.add(1, 'days').unix()],
        'tomorrow': [temp.unix(), temp.add(1, 'days').unix()],
        'yesterday': [temp.add(-3, 'days').unix(), temp.add(1, 'days').unix()]
      };
      if (dateTime.unix() >= ranges['today'][0] && dateTime.unix() < ranges['today'][1]) {
        return this.translate('Today');
      }
      if (dateTime.unix() >= ranges['tomorrow'][0] && dateTime.unix() < ranges['tomorrow'][1]) {
        return this.translate('Tomorrow');
      }
      if (dateTime.unix() >= ranges['yesterday'][0] && dateTime.unix() < ranges['yesterday'][1]) {
        return this.translate('Yesterday');
      }

      // Need to use UTC, otherwise there's a DST issue with old dates.
      dateTime = _moment.default.utc(valueWithTime, internalDateTimeFormat);
      if (dateTime.format('YYYY') === today.format('YYYY')) {
        return dateTime.format(readableFormat);
      }
      return dateTime.format(readableFormat + ', YYYY');
    }
    getDateStringValue() {
      if (this.mode === this.MODE_DETAIL && !this.model.has(this.name)) {
        return -1;
      }
      const value = this.model.get(this.name);
      return this.stringifyDateValue(value);
    }
    getStartDateForDatePicker() {
      if (!this.isEditMode() || !this.params.after) {
        return undefined;
      }
      let date = this.model.attributes[this.params.after];
      if (date == null) {
        return undefined;
      }
      if (date.length > 10) {
        date = this.getDateTime().toDisplay(date);
        [date] = date.split(' ');
        return date;
      }
      return this.getDateTime().toDisplayDate(date);
    }
    afterRender() {
      if (this.isEditMode() || this.isSearchMode()) {
        var _this$element, _this$mainInputElemen;
        this.mainInputElement = (_this$element = this.element) === null || _this$element === void 0 ? void 0 : _this$element.querySelector(`[data-name="${this.name}"]`);
        this.$element = $(this.mainInputElement);
        const options = {
          format: this.getDateTime().dateFormat,
          weekStart: this.getDateTime().weekStart,
          startDate: this.getStartDateForDatePicker(),
          todayButton: this.getConfig().get('datepickerTodayButton') || false
        };
        this.datepicker = null;
        if (this.mainInputElement instanceof HTMLInputElement) {
          this.datepicker = new _datepicker.default(this.mainInputElement, {
            ...options,
            onChange: () => this.trigger('change')
          });
        }
        if (this.isSearchMode()) {
          var _this$element2;
          const additionalGroup = (_this$element2 = this.element) === null || _this$element2 === void 0 ? void 0 : _this$element2.querySelector('.input-group.additional');
          if (additionalGroup) {
            new _datepicker.default(additionalGroup, options);
            this.initDatePickerEventHandlers('input.filter-from');
            this.initDatePickerEventHandlers('input.filter-to');
          }
        }
        const button = (_this$mainInputElemen = this.mainInputElement) === null || _this$mainInputElemen === void 0 || (_this$mainInputElemen = _this$mainInputElemen.parentNode) === null || _this$mainInputElemen === void 0 ? void 0 : _this$mainInputElemen.querySelector('button.date-picker-btn');
        if (button instanceof HTMLElement) {
          button.addEventListener('click', () => {
            var _this$datepicker2;
            return (_this$datepicker2 = this.datepicker) === null || _this$datepicker2 === void 0 ? void 0 : _this$datepicker2.show();
          });
        }
        if (this.isSearchMode()) {
          const type = this.fetchSearchType();
          this.handleSearchType(type);
        }
      }
    }

    /**
     * @private
     * @param {string} selector
     */
    initDatePickerEventHandlers(selector) {
      var _this$element3;
      const input = (_this$element3 = this.element) === null || _this$element3 === void 0 ? void 0 : _this$element3.querySelector(selector);
      if (!(input instanceof HTMLInputElement)) {
        return;
      }
      $(input).on('change', e => {
        this.trigger('change');
        if (e.isTrigger) {
          if (document.activeElement !== input) {
            input.focus({
              preventScroll: true
            });
          }
        }
      });
    }
    handleSearchType(type) {
      var _this$element4, _this$element5, _this$element6;
      const primary = (_this$element4 = this.element) === null || _this$element4 === void 0 ? void 0 : _this$element4.querySelector('div.primary');
      const additional = (_this$element5 = this.element) === null || _this$element5 === void 0 ? void 0 : _this$element5.querySelector('div.additional');
      const additionalNumber = (_this$element6 = this.element) === null || _this$element6 === void 0 ? void 0 : _this$element6.querySelector('div.additional-number');
      primary === null || primary === void 0 || primary.classList.add('hidden');
      additional === null || additional === void 0 || additional.classList.add('hidden');
      additionalNumber === null || additionalNumber === void 0 || additionalNumber.classList.add('hidden');
      if (this.searchWithPrimaryTypeList.includes(type)) {
        primary === null || primary === void 0 || primary.classList.remove('hidden');
        return;
      }
      if (this.searchWithAdditionalNumberTypeList.includes(type)) {
        additionalNumber === null || additionalNumber === void 0 || additionalNumber.classList.remove('hidden');
        return;
      }
      if (this.searchWithRangeTypeList.includes(type)) {
        additional === null || additional === void 0 || additional.classList.remove('hidden');
      }
    }
    parseDate(string) {
      return this.getDateTime().fromDisplayDate(string);
    }
    parse(string) {
      if (!string) {
        return null;
      }
      return this.parseDate(string);
    }
    fetch() {
      var _this$mainInputElemen2;
      const data = {};
      data[this.name] = this.parse(((_this$mainInputElemen2 = this.mainInputElement) === null || _this$mainInputElemen2 === void 0 ? void 0 : _this$mainInputElemen2.value) ?? '');
      return data;
    }
    fetchSearch() {
      const type = this.fetchSearchType();
      if (this.searchWithRangeTypeList.includes(type)) {
        var _this$element7, _this$element8;
        const inputFrom = (_this$element7 = this.element) === null || _this$element7 === void 0 ? void 0 : _this$element7.querySelector('input.filter-from');
        const inputTo = (_this$element8 = this.element) === null || _this$element8 === void 0 ? void 0 : _this$element8.querySelector('input.filter-to');
        const valueFrom = inputFrom instanceof HTMLInputElement ? this.parseDate(inputFrom.value) : undefined;
        const valueTo = inputTo instanceof HTMLInputElement ? this.parseDate(inputTo.value) : undefined;
        if (!valueFrom || !valueTo) {
          return null;
        }
        return {
          type: type,
          value: [valueFrom, valueTo],
          data: {
            value: valueFrom,
            valueTo: valueTo
          }
        };
      }
      if (this.searchWithAdditionalNumberTypeList.includes(type)) {
        var _this$element9;
        const input = (_this$element9 = this.element) === null || _this$element9 === void 0 ? void 0 : _this$element9.querySelector('input.number');
        const number = input instanceof HTMLInputElement ? input.value : undefined;
        return {
          type: type,
          value: number,
          date: true
        };
      }
      if (this.searchWithPrimaryTypeList.includes(type)) {
        var _this$element0;
        const input = (_this$element0 = this.element) === null || _this$element0 === void 0 ? void 0 : _this$element0.querySelector(`[data-name="${this.name}"]`);
        const value = input instanceof HTMLInputElement ? this.parseDate(input.value) : undefined;
        if (!value) {
          return null;
        }
        return {
          type: type,
          value: value,
          data: {
            value: value
          }
        };
      }
      if (type === 'isEmpty') {
        return {
          type: 'isNull',
          data: {
            type: type
          }
        };
      }
      return {
        type: type,
        date: true
      };
    }
    getSearchType() {
      var _this$searchParams4, _this$searchParams5;
      return this.getSearchParamsData().type ?? ((_this$searchParams4 = this.searchParams) === null || _this$searchParams4 === void 0 ? void 0 : _this$searchParams4.typeFront) ?? ((_this$searchParams5 = this.searchParams) === null || _this$searchParams5 === void 0 ? void 0 : _this$searchParams5.type) ?? null;
    }
    validateRequired() {
      if (!this.isRequired()) {
        return false;
      }
      if (this.model.get(this.name) === null) {
        const msg = this.translate('fieldIsRequired', 'messages').replace('{field}', this.getLabelText());
        this.showValidationMessage(msg);
        return true;
      }
      return false;
    }

    // noinspection JSUnusedGlobalSymbols
    validateDate() {
      if (this.model.get(this.name) === -1) {
        const msg = this.translate('fieldShouldBeDate', 'messages').replace('{field}', this.getLabelText());
        this.showValidationMessage(msg);
        return true;
      }
    }

    // noinspection JSUnusedGlobalSymbols
    validateAfter() {
      const field = this.params.after;
      if (!field) {
        return false;
      }
      const value = this.model.get(this.name);
      const otherValue = this.model.get(field);
      if (!(value && otherValue)) {
        return false;
      }
      const unix = (0, _moment.default)(value).unix();
      const otherUnix = (0, _moment.default)(otherValue).unix();
      if (this.params.afterOrEqual && unix === otherUnix) {
        return false;
      }
      if (unix <= otherUnix) {
        const otherFieldLabelText = this.options.otherFieldLabelText || this.translate(field, 'fields', this.entityType);
        const msg = this.translate('fieldShouldAfter', 'messages').replace('{field}', this.getLabelText()).replace('{otherField}', otherFieldLabelText);
        this.showValidationMessage(msg);
        return true;
      }
      return false;
    }

    // noinspection JSUnusedGlobalSymbols
    validateBefore() {
      const field = this.params.before;
      if (!field) {
        return false;
      }
      const value = this.model.get(this.name);
      const otherValue = this.model.get(field);
      if (!(value && otherValue)) {
        return;
      }
      if ((0, _moment.default)(value).unix() >= (0, _moment.default)(otherValue).unix()) {
        const msg = this.translate('fieldShouldBefore', 'messages').replace('{field}', this.getLabelText()).replace('{otherField}', this.translate(field, 'fields', this.entityType));
        this.showValidationMessage(msg);
        return true;
      }
    }

    /**
     * @since 9.2.0
     */
    onAfterChange() {
      const after = this.params.after;
      const from = this.model.attributes[after];
      const currentValue = this.model.attributes[this.name];
      if (!from || !currentValue || from.length !== currentValue.length) {
        return;
      }
      if (this.getDateTime().toMomentDate(currentValue).isBefore(this.getDateTime().toMomentDate(from))) {
        this.model.set(this.name, from);
      }
    }
  }
  var _default = _exports.default = DateFieldView;
});

define("helpers/record/select-related", ["exports", "di", "metadata"], function (_exports, _di, _metadata) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _metadata = _interopRequireDefault(_metadata);
  var _staticBlock;
  let _init_metadata, _init_extra_metadata;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  /**
   * @internal
   */
  class SelectRelatedHelper {
    /**
     * @private
     * @type {Metadata}
     */
    metadata = _init_metadata(this);

    /**
     * @param {import('view').default} view
     */
    constructor(view) {
      _init_extra_metadata(this);
      /** @private */
      this.view = view;
    }

    /**
     * @param {import('model').default} model
     * @param {string} link
     * @param {{
     *     foreignEntityType?: string,
     *     massSelect?: boolean,
     *     primaryFilterName?: string,
     *     boolFilterList?: string[]|string,
     *     viewKey?: string,
     *     hasCreate?: boolean,
     *     onCreate?: function(): void,
     * }} options
     */
    process(model, link) {
      let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
      if (!options.foreignEntityType && !model.defs['links'][link]) {
        throw new Error(`Link ${link} does not exist.`);
      }
      const scope = options.foreignEntityType || model.defs['links'][link].entity;

      /** @var {Object.<string, *>} */
      const panelDefs = this.metadata.get(['clientDefs', model.entityType, 'relationshipPanels', link]) || {};
      const massRelateEnabled = options.massSelect || panelDefs.massSelect;
      let advanced = {};
      const foreignLink = model.getLinkParam(link, 'foreign');
      if (foreignLink && scope) {
        // Select only records not related with any.
        const foreignLinkType = this.metadata.get(['entityDefs', scope, 'links', foreignLink, 'type']);
        const foreignLinkFieldType = this.metadata.get(['entityDefs', scope, 'fields', foreignLink, 'type']);
        if (['belongsTo', 'belongsToParent'].includes(foreignLinkType) && foreignLinkFieldType && !advanced[foreignLink] && ['link', 'linkParent'].includes(foreignLinkFieldType)) {
          advanced[foreignLink] = {
            type: 'isNull',
            attribute: foreignLink + 'Id',
            data: {
              type: 'isEmpty'
            }
          };
        }
      }
      let primaryFilterName = options.primaryFilterName || null;
      if (typeof primaryFilterName === 'function') {
        primaryFilterName = primaryFilterName.call(this);
      }
      let dataBoolFilterList = options.boolFilterList;
      if (typeof options.boolFilterList === 'string') {
        dataBoolFilterList = options.boolFilterList.split(',');
      }
      let boolFilterList = dataBoolFilterList || panelDefs.selectBoolFilterList;
      if (typeof boolFilterList === 'function') {
        boolFilterList = boolFilterList.call(this);
      }
      boolFilterList = Espo.Utils.clone(boolFilterList);
      primaryFilterName = primaryFilterName || panelDefs.selectPrimaryFilterName || null;
      const viewKey = options.viewKey || 'select';
      const viewName = panelDefs.selectModalView || this.metadata.get(['clientDefs', scope, 'modalViews', viewKey]) || 'views/modals/select-records';
      Espo.Ui.notifyWait();
      const handler = panelDefs.selectHandler || null;
      new Promise(resolve => {
        if (!handler) {
          resolve({});
          return;
        }
        Espo.loader.requirePromise(handler).then(Handler => new Handler(this.view.getHelper())).then(/** import('contracts/relation').SelectRelatedHandler */handler => {
          handler.getFilters(model).then(filters => resolve(filters));
        });
      }).then(filters => {
        advanced = {
          ...advanced,
          ...(filters.advanced || {})
        };
        if (boolFilterList || filters.bool) {
          boolFilterList = [...(boolFilterList || []), ...(filters.bool || [])];
        }
        if (filters.primary && !primaryFilterName) {
          primaryFilterName = filters.primary;
        }
        const orderBy = filters.orderBy || panelDefs.selectOrderBy;
        const orderDirection = filters.orderBy ? filters.order : panelDefs.selectOrderDirection;
        const createButton = options.hasCreate === true && options.onCreate !== undefined;

        /** @type {import('views/modals/select-records').default} */
        let modalView;
        this.view.createView('dialogSelectRelated', viewName, {
          scope: scope,
          multiple: true,
          filters: advanced,
          massRelateEnabled: massRelateEnabled,
          primaryFilterName: primaryFilterName,
          boolFilterList: boolFilterList,
          mandatorySelectAttributeList: panelDefs.selectMandatoryAttributeList,
          layoutName: panelDefs.selectLayout,
          orderBy: orderBy,
          orderDirection: orderDirection,
          createButton: createButton,
          onCreate: () => {
            modalView.close();
            if (options.onCreate) {
              options.onCreate();
            }
          }
        }, view => {
          modalView = view;
          view.render();
          Espo.Ui.notify(false);
          this.view.listenToOnce(view, 'select', selectObj => {
            const data = {};
            if (Object.prototype.toString.call(selectObj) === '[object Array]') {
              const ids = [];
              selectObj.forEach(model => ids.push(model.id));
              data.ids = ids;
            } else if (selectObj.massRelate) {
              data.massRelate = true;
              data.where = selectObj.where;
              data.searchParams = selectObj.searchParams;
            } else {
              data.id = selectObj.id;
            }
            const url = `${model.entityType}/${model.id}/${link}`;
            Espo.Ajax.postRequest(url, data).then(() => {
              Espo.Ui.success(this.view.translate('Linked'));
              model.trigger(`update-related:${link}`);
              model.trigger('after:relate');
              model.trigger(`after:relate:${link}`);
            });
          });
        });
      });
    }
    static #_ = _staticBlock = () => [_init_metadata, _init_extra_metadata] = _applyDecs(this, [], [[(0, _di.inject)(_metadata.default), 0, "metadata"]]).e;
  }
  _staticBlock();
  var _default = _exports.default = SelectRelatedHelper;
});

define("helpers/record/create-related", ["exports", "di", "metadata", "helpers/record-modal"], function (_exports, _di, _metadata, _recordModal) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _metadata = _interopRequireDefault(_metadata);
  _recordModal = _interopRequireDefault(_recordModal);
  var _staticBlock;
  let _init_metadata, _init_extra_metadata;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  /**
   * @internal
   */
  class CreateRelatedHelper {
    /**
     * @private
     * @type {Metadata}
     */
    metadata = _init_metadata(this);

    /**
     * @param {import('view').default} view
     */
    constructor(view) {
      _init_extra_metadata(this);
      /** @private */
      this.view = view;
    }

    /**
     * @param {import('model').default} model
     * @param {string} link
     * @param {{
     *     focusForCreate?: boolean,
     *     afterSave: function(import('model').default),
     * }} [options]
     * @return {Promise<import('views/modals/edit').default>}
     */
    async process(model, link) {
      let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
      const scope = model.defs['links'][link].entity;
      const foreignLink = model.defs['links'][link].foreign;

      /** @type {Record} */
      const panelDefs = this.metadata.get(`clientDefs.${model.entityType}.relationshipPanels.${link}`) || {};
      const attributeMap = panelDefs.createAttributeMap || {};
      const handler = panelDefs.createHandler;
      let attributes = {};
      Object.keys(attributeMap).forEach(attr => attributes[attributeMap[attr]] = model.get(attr));
      if (handler) {
        const Handler = await Espo.loader.requirePromise(handler);
        /** @type {import('contracts/relation').CreateRelatedHandler} */
        const handlerObj = new Handler(this.view.getHelper(), {
          link: link
        });
        const additionalAttributes = await handlerObj.getAttributes(model, link);
        attributes = {
          ...attributes,
          ...additionalAttributes
        };
      }
      const helper = new _recordModal.default();
      return await helper.showCreate(this.view, {
        entityType: scope,
        relate: {
          model: model,
          link: foreignLink
        },
        attributes: attributes,
        focusForCreate: options.focusForCreate,
        afterSave: m => {
          if (options.afterSave) {
            options.afterSave(m);
          }
          model.trigger(`update-related:${link}`);
          model.trigger('after:relate');
          model.trigger(`after:relate:${link}`);
        }
      });
    }
    static #_ = _staticBlock = () => [_init_metadata, _init_extra_metadata] = _applyDecs(this, [], [[(0, _di.inject)(_metadata.default), 0, "metadata"]]).e;
  }
  _staticBlock();
  var _default = _exports.default = CreateRelatedHelper;
});

define("helpers/misc/stored-text-search", ["exports"], function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module helpers/misc/stored-text-search */

  class _default {
    /**
     * @param {module:storage} storage
     * @param {string} scope
     * @param {Number} [maxCount]
     */
    constructor(scope, storage, maxCount) {
      this.scope = scope;
      this.storage = storage;
      this.key = 'textSearches';
      this.maxCount = maxCount || 100;
      /** @type {string[]|null} */
      this.list = null;
    }

    /**
     * Match.
     *
     * @param {string} text
     * @param {Number} [limit]
     * @return {string[]}
     */
    match(text, limit) {
      text = text.toLowerCase().trim();
      const list = this.get();
      const matchedList = [];
      for (const item of list) {
        if (item.toLowerCase().startsWith(text)) {
          matchedList.push(item);
        }
        if (limit !== undefined && matchedList.length === limit) {
          break;
        }
      }
      return matchedList;
    }

    /**
     * Get stored text filters.
     *
     * @private
     * @return {string[]}
     */
    get() {
      if (this.list === null) {
        this.list = this.getFromStorage();
      }
      return this.list;
    }

    /**
     * @private
     * @return {string[]}
     */
    getFromStorage() {
      /** @var {string[]} */
      return this.storage.get(this.key, this.scope) || [];
    }

    /**
     * Store a text filter.
     *
     * @param {string} text
     */
    store(text) {
      text = text.trim();
      let list = this.getFromStorage();
      const index = list.indexOf(text);
      if (index !== -1) {
        list.splice(index, 1);
      }
      list.unshift(text);
      if (list.length > this.maxCount) {
        list = list.slice(0, this.maxCount);
      }
      this.list = list;
      this.storage.set(this.key, this.scope, list);
    }

    /**
     * Remove a text filter.
     *
     * @param {string} text
     */
    remove(text) {
      text = text.trim();
      const list = this.getFromStorage();
      const index = list.indexOf(text);
      if (index === -1) {
        return;
      }
      list.splice(index, 1);
      this.list = list;
      this.storage.set(this.key, this.scope, list);
    }
  }
  _exports.default = _default;
});

define("helpers/misc/foreign-field", ["exports"], function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module helpers/misc/foreign-field */

  class _default {
    /**
     * @private
     * @type {string}
     */
    entityType;

    /**
     * @param {module:views/fields/base} view A field view.
     */
    constructor(view) {
      /**
       * @private
       * @type {module:views/fields/base}
       */
      this.view = view;
      const metadata = view.getMetadata();
      const model = view.model;
      const field = view.params.field;
      const link = view.params.link;
      const entityType = metadata.get(['entityDefs', model.entityType, 'links', link, 'entity']) || model.entityType;
      this.entityType = entityType;
      const fieldDefs = metadata.get(['entityDefs', entityType, 'fields', field]) || {};
      const type = fieldDefs.type;
      const ignoreList = ['default', 'audited', 'readOnly', 'required'];

      /** @private */
      this.foreignParams = {};
      view.getFieldManager().getParamList(type).forEach(defs => {
        const name = defs.name;
        if (ignoreList.includes(name)) {
          return;
        }
        this.foreignParams[name] = fieldDefs[name] || null;
      });
    }

    /**
     * @return {Object.<string, *>}
     */
    getForeignParams() {
      return Espo.Utils.cloneDeep(this.foreignParams);
    }

    /**
     * @return {string}
     */
    getEntityType() {
      return this.entityType;
    }
  }
  _exports.default = _default;
});

define("theme-manager", ["exports"], function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module theme-manager */

  /**
   * A theme manager.
   */
  class ThemeManager {
    /**
     * @param {module:models/settings} config A config.
     * @param {module:models/preferences} preferences Preferences.
     * @param {module:metadata} metadata Metadata.
     * @param {string|null} [name] A name. If not set, then will be obtained from config and preferences.
     */
    constructor(config, preferences, metadata, name) {
      /**
       * @private
       * @type {module:models/settings}
       */
      this.config = config;

      /**
       * @private
       * @type {module:models/preferences}
       */
      this.preferences = preferences;

      /**
       * @private
       * @type {module:metadata}
       */
      this.metadata = metadata;

      /**
       * @private
       * @type {boolean}
       */
      this.useConfig = !name;

      /**
       * @private
       * @type {string|null}
       */
      this.name = name || null;
    }

    /**
     * @private
     */
    defaultParams = {
      screenWidthXs: 768,
      dashboardCellHeight: 40,
      dashboardCellMargin: 16
    };

    /**
     * Get a theme name for the current user.
     *
     * @returns {string}
     */
    getName() {
      if (this.name) {
        return this.name;
      }
      if (!this.config.get('userThemesDisabled')) {
        const name = this.preferences.get('theme');
        if (name && name !== '') {
          return name;
        }
      }
      return this.config.get('theme');
    }

    /**
     * Get a theme name currently applied to the DOM.
     *
     * @returns {string|null} Null if not applied.
     */
    getAppliedName() {
      const name = window.getComputedStyle(document.body).getPropertyValue('--theme-name');
      if (!name) {
        return null;
      }
      return name.trim();
    }

    /**
     * Whether a current theme is applied to the DOM.
     *
     * @returns {boolean}
     */
    isApplied() {
      const appliedName = this.getAppliedName();
      if (!appliedName) {
        return true;
      }
      return this.getName() === appliedName;
    }

    /**
     * Get a stylesheet path for a current theme.
     *
     * @returns {string}
     */
    getStylesheet() {
      let link = this.getParam('stylesheet') || 'client/css/espo/espo.css';
      if (this.config.get('cacheTimestamp')) {
        link += '?r=' + this.config.get('cacheTimestamp').toString();
      }
      return link;
    }

    /**
     * Get an iframe stylesheet path for a current theme.
     *
     * @returns {string}
     */
    getIframeStylesheet() {
      let link = this.getParam('stylesheetIframe') || 'client/css/espo/espo-iframe.css';
      if (this.config.get('cacheTimestamp')) {
        link += '?r=' + this.config.get('cacheTimestamp').toString();
      }
      return link;
    }

    /**
     * Get an iframe-fallback stylesheet path for a current theme.
     *
     * @returns {string}
     */
    getIframeFallbackStylesheet() {
      let link = this.getParam('stylesheetIframeFallback') || 'client/css/espo/espo-iframe.css';
      if (this.config.get('cacheTimestamp')) {
        link += '?r=' + this.config.get('cacheTimestamp').toString();
      }
      return link;
    }

    /**
     * Get a theme parameter.
     *
     * @param {string} name A parameter name.
     * @returns {*} Null if not set.
     */
    getParam(name) {
      if (name !== 'params' && name !== 'mappedParams') {
        const varValue = this.getVarParam(name);
        if (varValue !== null) {
          return varValue;
        }
        const mappedValue = this.getMappedParam(name);
        if (mappedValue !== null) {
          return mappedValue;
        }
      }
      let value = this.metadata.get(['themes', this.getName(), name]);
      if (value !== null) {
        return value;
      }
      value = this.metadata.get(['themes', this.getParentName(), name]);
      if (value !== null) {
        return value;
      }
      return this.defaultParams[name] || null;
    }

    /**
     * @private
     * @param {string} name
     * @returns {*}
     */
    getVarParam(name) {
      const params = this.getParam('params') || {};
      if (!(name in params)) {
        return null;
      }
      let values = null;
      if (this.useConfig && !this.config.get('userThemesDisabled') && this.preferences.get('theme')) {
        values = this.preferences.get('themeParams');
      }
      if (!values && this.useConfig) {
        values = this.config.get('themeParams');
      }
      if (values && name in values) {
        return values[name];
      }
      if ('default' in params[name]) {
        return params[name].default;
      }
      return null;
    }

    /**
     * @private
     * @param {string} name
     * @returns {*}
     */
    getMappedParam(name) {
      const mappedParams = this.getParam('mappedParams') || {};
      if (!(name in mappedParams)) {
        return null;
      }
      const mapped = mappedParams[name].param;
      const valueMap = mappedParams[name].valueMap;
      if (mapped && valueMap) {
        const key = this.getParam(mapped);
        return valueMap[key];
      }
      return null;
    }

    /**
     * @private
     * @returns {string}
     */
    getParentName() {
      return this.metadata.get(['themes', this.getName(), 'parent']) || 'Espo';
    }

    /**
     * Whether a current theme is different from a system default theme.
     *
     * @returns {boolean}
     */
    isUserTheme() {
      if (this.config.get('userThemesDisabled')) {
        return false;
      }
      const name = this.preferences.get('theme');
      if (!name || name === '') {
        return false;
      }
      return name !== this.config.get('theme');
    }

    /**
     * Get a font-size factor. To adjust px sizes based on font-size.
     *
     * @return {number}
     * @since 9.0.0
     * @internal Experimental.
     */
    getFontSizeFactor() {
      const paramFontSize = this.getParam('fontSize') || 14;
      const fontSize = parseInt(getComputedStyle(document.body).fontSize);
      return Math.round(fontSize / paramFontSize * 10000) / 10000;
    }
  }
  var _default = _exports.default = ThemeManager;
});

define("session-storage", ["exports"], function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module session-storage */

  /**
   * A session storage. Cleared when a page session ends.
   */
  class SessionStorage {
    /** @private */
    storageObject = sessionStorage;

    /**
     * Get a value.
     *
     * @param {string} name A name.
     * @returns {*} Null if not set.
     */
    get(name) {
      let stored;
      try {
        stored = this.storageObject.getItem(name);
      } catch (error) {
        console.error(error);
        return null;
      }
      if (stored) {
        let result = stored;
        if (stored.length > 9 && stored.substring(0, 9) === '__JSON__:') {
          const jsonString = stored.slice(9);
          try {
            result = JSON.parse(jsonString);
          } catch (error) {
            result = stored;
          }
        }
        return result;
      }
      return null;
    }

    /**
     * Set (store) a value.
     *
     * @param {string} name A name.
     * @param {*} value A value.
     */
    set(name, value) {
      if (value === null) {
        this.clear(name);
        return;
      }
      if (value instanceof Object || Array.isArray(value) || value === true || value === false || typeof value === 'number') {
        value = '__JSON__:' + JSON.stringify(value);
      }
      try {
        this.storageObject.setItem(name, value);
      } catch (error) {
        console.error(error);
      }
    }

    /**
     * Has a value.
     *
     * @param {string} name A name.
     * @returns {boolean}
     */
    has(name) {
      return this.storageObject.getItem(name) !== null;
    }

    /**
     * Clear a value.
     *
     * @param {string} name A name.
     */
    clear(name) {
      for (const i in this.storageObject) {
        if (i === name) {
          delete this.storageObject[i];
        }
      }
    }
  }
  var _default = _exports.default = SessionStorage;
});

define("page-title", ["exports", "jquery"], function (_exports, _jquery) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _jquery = _interopRequireDefault(_jquery);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module page-title */

  /**
   * A page-title util.
   */
  class PageTitle {
    /**
     * @class
     * @param {module:models/settings} config A config.
     */
    constructor(config) {
      /**
       * @private
       * @type {boolean}
       */
      this.displayNotificationNumber = config.get('newNotificationCountInTitle') || false;

      /**
       * @private
       * @type {string}
       */
      this.title = (0, _jquery.default)('head title').text() || '';

      /**
       * @private
       * @type {number}
       */
      this.notificationNumber = 0;
    }

    /**
     * Set a title.
     *
     * @param {string} title A title.
     */
    setTitle(title) {
      this.title = title;
      this.update();
    }

    /**
     * Set a notification number.
     *
     * @param {number} notificationNumber A number.
     */
    setNotificationNumber(notificationNumber) {
      this.notificationNumber = notificationNumber;
      if (this.displayNotificationNumber) {
        this.update();
      }
    }

    /**
     * Update a page title.
     */
    update() {
      let value = '';
      if (this.displayNotificationNumber && this.notificationNumber) {
        value = '(' + this.notificationNumber.toString() + ')';
        if (this.title) {
          value += ' ';
        }
      }
      value += this.title;
      (0, _jquery.default)('head title').text(value);
    }
  }
  var _default = _exports.default = PageTitle;
});

define("number-util", ["exports"], function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module num-util */

  /**
   * A number util.
   */
  class NumberUtil {
    /**
     * @param {module:models/settings} config A config.
     * @param {module:models/preferences} preferences Preferences.
     */
    constructor(config, preferences) {
      /**
       * @private
       * @type {module:models/settings}
       */
      this.config = config;

      /**
       * @private
       * @type {module:models/preferences}
       */
      this.preferences = preferences;

      /**
       * A thousand separator.
       *
       * @private
       * @type {string|null}
       */
      this.thousandSeparator = null;

      /**
       * A decimal mark.
       *
       * @private
       * @type {string|null}
       */
      this.decimalMark = null;
      this.config.on('change', () => {
        this.thousandSeparator = null;
        this.decimalMark = null;
      });
      this.preferences.on('change', () => {
        this.thousandSeparator = null;
        this.decimalMark = null;
      });

      /**
       * A max decimal places.
       *
       * @private
       * @type {number}
       */
      this.maxDecimalPlaces = 10;
    }

    /**
     * Format an integer number.
     *
     * @param {number} value A value.
     * @returns {string}
     */
    formatInt(value) {
      if (value === null || value === undefined) {
        return '';
      }
      let stringValue = value.toString();
      stringValue = stringValue.replace(/\B(?=(\d{3})+(?!\d))/g, this.getThousandSeparator());
      return stringValue;
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * Format a float number.
     *
     * @param {number} value A value.
     * @param {number} [decimalPlaces] Decimal places.
     * @returns {string}
     */
    formatFloat(value, decimalPlaces) {
      if (value === null || value === undefined) {
        return '';
      }
      if (decimalPlaces === 0) {
        value = Math.round(value);
      } else if (decimalPlaces) {
        value = Math.round(value * Math.pow(10, decimalPlaces)) / Math.pow(10, decimalPlaces);
      } else {
        value = Math.round(value * Math.pow(10, this.maxDecimalPlaces)) / Math.pow(10, this.maxDecimalPlaces);
      }
      const parts = value.toString().split('.');
      parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, this.getThousandSeparator());
      if (decimalPlaces === 0) {
        return parts[0];
      }
      if (decimalPlaces) {
        let decimalPartLength = 0;
        if (parts.length > 1) {
          decimalPartLength = parts[1].length;
        } else {
          parts[1] = '';
        }
        if (decimalPlaces && decimalPartLength < decimalPlaces) {
          const limit = decimalPlaces - decimalPartLength;
          for (let i = 0; i < limit; i++) {
            parts[1] += '0';
          }
        }
      }
      return parts.join(this.getDecimalMark());
    }

    /**
     * @private
     * @returns {string}
     */
    getThousandSeparator() {
      if (this.thousandSeparator !== null) {
        return this.thousandSeparator;
      }
      let thousandSeparator = '.';
      if (this.preferences.has('thousandSeparator')) {
        thousandSeparator = this.preferences.get('thousandSeparator');
      } else if (this.config.has('thousandSeparator')) {
        thousandSeparator = this.config.get('thousandSeparator');
      }

      /**
       * A thousand separator.
       *
       * @private
       * @type {string|null}
       */
      this.thousandSeparator = thousandSeparator;
      return thousandSeparator;
    }

    /**
     * @private
     * @returns {string}
     */
    getDecimalMark() {
      if (this.decimalMark !== null) {
        return this.decimalMark;
      }
      let decimalMark = '.';
      if (this.preferences.has('decimalMark')) {
        decimalMark = this.preferences.get('decimalMark');
      } else {
        if (this.config.has('decimalMark')) {
          decimalMark = this.config.get('decimalMark');
        }
      }

      /**
       * A decimal mark.
       *
       * @private
       * @type {string|null}
       */
      this.decimalMark = decimalMark;
      return decimalMark;
    }
  }
  var _default = _exports.default = NumberUtil;
});

define("email-helper", ["exports", "di", "language", "models/user", "date-time", "acl-manager"], function (_exports, _di, _language, _user, _dateTime, _aclManager) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _language = _interopRequireDefault(_language);
  _user = _interopRequireDefault(_user);
  _dateTime = _interopRequireDefault(_dateTime);
  _aclManager = _interopRequireDefault(_aclManager);
  var _staticBlock;
  let _init_language, _init_extra_language, _init_user, _init_extra_user, _init_dateTime, _init_extra_dateTime, _init_acl, _init_extra_acl;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  /** @module email-helper */
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  /**
   * An email helper.
   */
  class EmailHelper {
    /**
     * @private
     * @type {Language}
     */
    language = _init_language(this);

    /**
     * @private
     * @type {User}
     */
    user = (_init_extra_language(this), _init_user(this));

    /**
     * @private
     * @type {DateTime}
     */
    dateTime = (_init_extra_user(this), _init_dateTime(this));

    /**
     * @private
     * @type {AclManager}
     */
    acl = (_init_extra_dateTime(this), _init_acl(this));
    constructor() {
      _init_extra_acl(this);
      /** @private */
      this.erasedPlaceholder = 'ERASED:';
    }

    /**
     * Get reply email attributes.
     *
     * @param {module:model} model An email model.
     * @param {boolean} [cc=false] To include CC (reply-all).
     * @returns {Object.<string, *>}
     */
    getReplyAttributes(model, cc) {
      const attributes = {
        status: 'Draft',
        isHtml: model.attributes.isHtml
      };
      const subject = model.attributes.name || '';
      attributes['name'] = subject.toUpperCase().indexOf('RE:') !== 0 ? 'Re: ' + subject : subject;
      let to = '';
      let isReplyOnSent = false;
      const nameHash = model.attributes.nameHash || {};
      const replyToAddressString = model.attributes.replyTo || null;
      const replyToString = model.attributes.replyToString || null;
      const userEmailAddressList = this.user.attributes.emailAddressList || [];
      const idHash = model.attributes.idHash || {};
      const typeHash = model.attributes.typeHash || {};
      if (replyToAddressString) {
        const replyToAddressList = replyToAddressString.split(';');
        to = replyToAddressList.join(';');
      } else if (replyToString) {
        const a = [];
        replyToString.split(';').forEach(item => {
          const part = item.trim();
          const address = this.parseAddressFromStringAddress(item);
          if (address) {
            a.push(address);
            const name = this.parseNameFromStringAddress(part);
            if (name && name !== address) {
              nameHash[address] = name;
            }
          }
        });
        to = a.join(';');
      }
      if ((!to || !to.includes('@')) && model.attributes.from) {
        if (!userEmailAddressList.includes(model.attributes.from)) {
          to = model.attributes.from;
          if (!nameHash[to]) {
            const fromString = model.attributes.fromString || model.attributes.fromName;
            if (fromString) {
              const name = this.parseNameFromStringAddress(fromString);
              if (name !== to) {
                nameHash[to] = name;
              }
            }
          }
        } else {
          isReplyOnSent = true;
        }
      }
      attributes.to = to;
      if (cc) {
        attributes.cc = model.attributes.cc || '';

        /** @type {string[]} */
        const excludeFromReplyEmailAddressList = this.user.get('excludeFromReplyEmailAddressList') || [];
        (model.get('to') || '').split(';').forEach(item => {
          item = item.trim();
          if (item === this.user.get('emailAddress')) {
            return;
          }
          if (excludeFromReplyEmailAddressList.includes(item)) {
            return;
          }
          if (isReplyOnSent) {
            if (attributes.to) {
              attributes.to += ';';
            }
            attributes.to += item;
            return;
          }
          if (attributes.cc) {
            attributes.cc += ';';
          }
          attributes.cc += item;
        });
        attributes.cc = attributes.cc.replace(/^(; )/, "");
      }
      if (attributes.to) {
        let toList = attributes.to.split(';');
        toList = toList.filter(item => {
          if (item.indexOf(this.erasedPlaceholder) === 0) {
            return false;
          }
          return true;
        });
        attributes.to = toList.join(';');
      }

      /** @type {string[]} */
      const personalAddresses = this.user.get('userEmailAddressList') || [];
      const lcPersonalAddresses = personalAddresses.map(it => it.toLowerCase());
      if (attributes.cc) {
        const ccList = attributes.cc.split(';').filter(item => {
          if (lcPersonalAddresses.includes(item.toLowerCase())) {
            return false;
          }
          if (item.indexOf(this.erasedPlaceholder) === 0) {
            return false;
          }
          return true;
        });
        attributes.cc = ccList.join(';');
      }
      if (model.get('parentId')) {
        attributes['parentId'] = model.get('parentId');
        attributes['parentName'] = model.get('parentName');
        attributes['parentType'] = model.get('parentType');
      }
      if (model.get('teamsIds') && model.get('teamsIds').length) {
        attributes.teamsIds = Espo.Utils.clone(model.get('teamsIds'));
        attributes.teamsNames = Espo.Utils.clone(model.get('teamsNames') || {});
        const defaultTeamId = this.user.get('defaultTeamId');
        if (defaultTeamId && !~attributes.teamsIds.indexOf(defaultTeamId)) {
          attributes.teamsIds.push(this.user.get('defaultTeamId'));
          attributes.teamsNames[this.user.get('defaultTeamId')] = this.user.get('defaultTeamName');
        }
        attributes.teamsIds = attributes.teamsIds.filter(teamId => this.acl.checkTeamAssignmentPermission(teamId));
      }
      attributes.nameHash = nameHash;
      attributes.typeHash = typeHash;
      attributes.idHash = idHash;
      attributes.repliedId = model.id;
      attributes.inReplyTo = model.get('messageId');

      /** @type {string[]} */
      const lcToAddresses = (model.attributes.to || '').split(';').map(it => it.toLowerCase());
      for (const address of personalAddresses) {
        if (lcToAddresses.includes(address.toLowerCase())) {
          attributes.from = address;
          break;
        }
      }
      this.addReplyBodyAttributes(model, attributes);
      return attributes;
    }

    /**
     * Get forward email attributes.
     *
     * @param {module:model} model An email model.
     * @returns {Object}
     */
    getForwardAttributes(model) {
      const attributes = {
        status: 'Draft',
        isHtml: model.get('isHtml')
      };
      const subject = model.get('name');
      if (~!subject.toUpperCase().indexOf('FWD:') && ~!subject.toUpperCase().indexOf('FW:')) {
        attributes['name'] = 'Fwd: ' + subject;
      } else {
        attributes['name'] = subject;
      }
      if (model.get('parentId')) {
        attributes['parentId'] = model.get('parentId');
        attributes['parentName'] = model.get('parentName');
        attributes['parentType'] = model.get('parentType');
      }
      this.addForwardBodyAttributes(model, attributes);
      return attributes;
    }

    /**
     * Add body attributes for a forward email.
     *
     * @param {module:model} model An email model.
     * @param {Object} attributes
     */
    addForwardBodyAttributes(model, attributes) {
      let prepending = '';
      if (model.get('isHtml')) {
        prepending = '<br>' + '------' + this.language.translate('Forwarded message', 'labels', 'Email') + '------';
      } else {
        prepending = '\n\n' + '------' + this.language.translate('Forwarded message', 'labels', 'Email') + '------';
      }
      const list = [];
      if (model.get('from')) {
        const from = model.get('from');
        let line = this.language.translate('from', 'fields', 'Email') + ': ';
        const nameHash = model.get('nameHash') || {};
        if (from in nameHash) {
          line += nameHash[from] + ' ';
        }
        if (model.get('isHtml')) {
          line += '&lt;' + from + '&gt;';
        } else {
          line += '<' + from + '>';
        }
        list.push(line);
      }
      if (model.get('dateSent')) {
        let line = this.language.translate('dateSent', 'fields', 'Email') + ': ';
        line += this.dateTime.toDisplay(model.get('dateSent'));
        list.push(line);
      }
      if (model.get('name')) {
        let line = this.language.translate('subject', 'fields', 'Email') + ': ';
        line += model.get('name');
        list.push(line);
      }
      if (model.get('to')) {
        let line = this.language.translate('to', 'fields', 'Email') + ': ';
        const partList = [];
        model.get('to').split(';').forEach(to => {
          const nameHash = model.get('nameHash') || {};
          let line = '';
          if (to in nameHash) {
            line += nameHash[to] + ' ';
          }
          if (model.get('isHtml')) {
            line += '&lt;' + to + '&gt;';
          } else {
            line += '<' + to + '>';
          }
          partList.push(line);
        });
        line += partList.join(';');
        list.push(line);
      }
      list.forEach(line => {
        if (model.get('isHtml')) {
          prepending += '<br>' + line;
        } else {
          prepending += '\n' + line;
        }
      });
      if (model.get('isHtml')) {
        const body = model.get('body');
        attributes['body'] = prepending + '<br><br>' + body;
      } else {
        const bodyPlain = model.get('body') || model.get('bodyPlain') || '';
        attributes['bodyPlain'] = attributes['body'] = prepending + '\n\n' + bodyPlain;
      }
    }

    /**
     * Parse a name from a string address.
     *
     * @param {string} value A string address. E.g. `Test Name <address@domain>`.
     * @returns {string|null}
     */
    parseNameFromStringAddress(value) {
      if (!value.includes('<')) {
        return null;
      }
      let name = value.replace(/<(.*)>/, '').trim();
      if (name.charAt(0) === '"' && name.charAt(name.length - 1) === '"') {
        name = name.slice(1, name.length - 2);
      }
      return name;
    }

    /**
     * Parse an address from a string address.
     *
     * @param {string} value A string address. E.g. `Test Name <address@domain>`.
     * @returns {string|null}
     */
    parseAddressFromStringAddress(value) {
      const r = value.match(/<(.*)>/);
      let address;
      if (r && r.length > 1) {
        address = r[1];
      } else {
        address = value.trim();
      }
      return address;
    }

    /**
     * Add body attributes for a reply email.
     *
     * @param {module:model} model An email model.
     * @param {Object.<string, *>} attributes
     */
    addReplyBodyAttributes(model, attributes) {
      const format = this.dateTime.getReadableShortDateTimeFormat();
      const dateSent = model.get('dateSent');
      let dateSentString = null;
      if (dateSent) {
        const dateSentMoment = this.dateTime.toMoment(dateSent);
        dateSentString = dateSentMoment.format(format);
        if (dateSentMoment.year() !== this.dateTime.getNowMoment().year()) {
          dateSentString += ', ' + dateSentMoment.year();
        }
      }
      let replyHeadString = dateSentString || this.language.translate('Original message', 'labels', 'Email');
      let fromName = model.get('fromName');
      if (!fromName && model.get('from')) {
        fromName = (model.get('nameHash') || {})[model.get('from')];
        if (fromName) {
          replyHeadString += ', ' + fromName;
        }
      }
      replyHeadString += ':';
      if (model.get('isHtml')) {
        const body = model.get('body');
        attributes['body'] = `<p data-quote-start="true"><br></p>` + `<p>${replyHeadString}</p><blockquote>${body}</blockquote>`;
        return;
      }
      let bodyPlain = model.get('body') || model.get('bodyPlain') || '';
      let b = '\n\n';
      b += replyHeadString + '\n';
      bodyPlain.split('\n').forEach(line => {
        b += '> ' + line + '\n';
      });
      bodyPlain = b;
      attributes['body'] = bodyPlain;
      attributes['bodyPlain'] = bodyPlain;
    }
    static #_ = _staticBlock = () => [_init_language, _init_extra_language, _init_user, _init_extra_user, _init_dateTime, _init_extra_dateTime, _init_acl, _init_extra_acl] = _applyDecs(this, [], [[(0, _di.inject)(_language.default), 0, "language"], [(0, _di.inject)(_user.default), 0, "user"], [(0, _di.inject)(_dateTime.default), 0, "dateTime"], [(0, _di.inject)(_aclManager.default), 0, "acl"]]).e;
  }
  _staticBlock();
  var _default = _exports.default = EmailHelper;
});

define("collection-factory", ["exports"], function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module collection-factory */

  /**
   * A collection factory.
   */
  class CollectionFactory {
    /**
     * @param {module:model-factory} modelFactory
     * @param {module:models/settings} config
     * @param {module:metadata} metadata
     */
    constructor(modelFactory, config, metadata) {
      this.modelFactory = modelFactory;
      this.metadata = metadata;
      this.recordListMaxSizeLimit = config.get('recordListMaxSizeLimit') || 200;
    }

    /**
     * Create a collection.
     *
     * @param entityType An entity type.
     * @param [callback] Deprecated.
     * @param [context] Deprecated.
     * @returns A created collection.
     */
    create(entityType, callback, context) {
      return new Promise(resolve => {
        context = context || this;
        this.modelFactory.getSeed(entityType, Model => {
          const orderBy = this.metadata.get(['entityDefs', entityType, 'collection', 'orderBy']);
          const order = this.metadata.get(['entityDefs', entityType, 'collection', 'order']);
          const className = this.metadata.get(['clientDefs', entityType, 'collection']) || 'collection';
          const defs = this.metadata.get(['entityDefs', entityType]) || {};
          Espo.loader.require(className, collectionClass => {
            const collection = new collectionClass(null, {
              entityType: entityType,
              orderBy: orderBy,
              order: order,
              defs: defs,
              model: Model
            });
            collection.entityType = entityType;
            collection.maxMaxSize = this.recordListMaxSizeLimit;
            if (callback) {
              callback.call(context, collection);
            }
            resolve(collection);
          });
        });
      });
    }
  }
  _exports.default = CollectionFactory;
});

define("cache", ["exports"], function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module cache */

  /**
   * Cache for source and resource files.
   */
  class Cache {
    /**
     * @param {Number} [cacheTimestamp] A cache timestamp.
     */
    constructor(cacheTimestamp) {
      this.basePrefix = this.prefix;
      if (cacheTimestamp) {
        this.prefix = this.basePrefix + '-' + cacheTimestamp;
      }
      if (!this.get('app', 'timestamp')) {
        this.storeTimestamp();
      }
    }

    /** @private */
    prefix = 'cache';

    /**
     * Handle actuality. Clears cache if not actual.
     *
     * @param {Number} cacheTimestamp A cache timestamp.
     */
    handleActuality(cacheTimestamp) {
      const storedTimestamp = this.getCacheTimestamp();
      if (storedTimestamp) {
        if (storedTimestamp !== cacheTimestamp) {
          this.clear();
          this.set('app', 'cacheTimestamp', cacheTimestamp);
          this.storeTimestamp();
        }
        return;
      }
      this.clear();
      this.set('app', 'cacheTimestamp', cacheTimestamp);
      this.storeTimestamp();
    }

    /**
     * Get a cache timestamp.
     *
     * @returns {number}
     */
    getCacheTimestamp() {
      return parseInt(this.get('app', 'cacheTimestamp') || 0);
    }

    /**
     * @todo Revise whether is needed.
     */
    storeTimestamp() {
      const frontendCacheTimestamp = Date.now();
      this.set('app', 'timestamp', frontendCacheTimestamp);
    }

    /**
     * @private
     * @param {string} type
     * @returns {string}
     */
    composeFullPrefix(type) {
      return this.prefix + '-' + type;
    }

    /**
     * @private
     * @param {string} type
     * @param {string} name
     * @returns {string}
     */
    composeKey(type, name) {
      return this.composeFullPrefix(type) + '-' + name;
    }

    /**
     * @private
     * @param {string} type
     */
    checkType(type) {
      if (typeof type === 'undefined' && toString.call(type) !== '[object String]') {
        throw new TypeError("Bad type \"" + type + "\" passed to Cache().");
      }
    }

    /**
     * Get a stored value.
     *
     * @param {string} type A type/category.
     * @param {string} name A name.
     * @returns {string|null} Null if no stored value.
     */
    get(type, name) {
      this.checkType(type);
      const key = this.composeKey(type, name);
      let stored;
      try {
        stored = localStorage.getItem(key);
      } catch (error) {
        console.error(error);
        return null;
      }
      if (stored) {
        let result = stored;
        if (stored.length > 9 && stored.substring(0, 9) === '__JSON__:') {
          const jsonString = stored.slice(9);
          try {
            result = JSON.parse(jsonString);
          } catch (error) {
            result = stored;
          }
        }
        return result;
      }
      return null;
    }

    /**
     * Store a value.
     *
     * @param {string} type A type/category.
     * @param {string} name A name.
     * @param {any} value A value.
     */
    set(type, name, value) {
      this.checkType(type);
      const key = this.composeKey(type, name);
      if (value instanceof Object || Array.isArray(value)) {
        value = '__JSON__:' + JSON.stringify(value);
      }
      try {
        localStorage.setItem(key, value);
      } catch (error) {
        console.log('Local storage limit exceeded.');
      }
    }

    /**
     * Clear a stored value.
     *
     * @param {string} [type] A type/category.
     * @param {string} [name] A name.
     */
    clear(type, name) {
      let reText;
      if (typeof type !== 'undefined') {
        if (typeof name === 'undefined') {
          reText = '^' + this.composeFullPrefix(type);
        } else {
          reText = '^' + this.composeKey(type, name);
        }
      } else {
        reText = '^' + this.basePrefix + '-';
      }
      const re = new RegExp(reText);
      for (const i in localStorage) {
        if (re.test(i)) {
          delete localStorage[i];
        }
      }
    }
  }
  var _default = _exports.default = Cache;
});

define("broadcast-channel", ["exports"], function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module broadcast-channel */

  class BroadcastChannel {
    constructor() {
      this.object = null;
      if (window.BroadcastChannel) {
        this.object = new window.BroadcastChannel('app');
      }
    }

    /**
     * Post a message.
     *
     * @param {string} message A message.
     */
    postMessage(message) {
      if (!this.object) {
        return;
      }
      this.object.postMessage(message);
    }

    /**
     * @callback module:broadcast-channel~callback
     *
     * @param {MessageEvent} event An event. A message can be obtained from the `data` property.
     */

    /**
     * Subscribe to a message.
     *
     * @param {module:broadcast-channel~callback} callback A callback.
     */
    subscribe(callback) {
      if (!this.object) {
        return;
      }
      this.object.addEventListener('message', callback);
    }
  }
  var _default = _exports.default = BroadcastChannel;
});

define("acl-portal", ["exports", "acl", "di", "metadata"], function (_exports, _acl, _di, _metadata) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _acl = _interopRequireDefault(_acl);
  _metadata = _interopRequireDefault(_metadata);
  var _staticBlock;
  let _init_metadata, _init_extra_metadata;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  /** @module acl-portal */
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  /**
   * Internal class for portal access checking. Can be extended to customize access checking
   * for a specific scope.
   */
  class AclPortal extends _acl.default {
    constructor() {
      super(...arguments);
      _init_extra_metadata(this);
    }
    /**
     * @private
     * @type {Metadata}
     */
    metadata = _init_metadata(this);

    /** @inheritDoc */
    checkScope(data, action, precise, entityAccessData) {
      entityAccessData = entityAccessData || {};
      const inAccount = entityAccessData.inAccount;
      const isOwnContact = entityAccessData.isOwnContact;
      const isOwner = entityAccessData.isOwner;
      if (this.getUser().isAdmin()) {
        return true;
      }
      if (data === false) {
        return false;
      }
      if (data === true) {
        return true;
      }
      if (typeof data === 'string') {
        return true;
      }
      if (data === null) {
        return false;
      }
      action = action || null;
      if (action === null) {
        return true;
      }
      if (!(action in data)) {
        return false;
      }
      const value = data[action];
      if (value === 'all') {
        return true;
      }
      if (value === 'yes') {
        return true;
      }
      if (value === 'no') {
        return false;
      }
      if (typeof isOwner === 'undefined') {
        return true;
      }
      if (isOwner && (value === 'own' || value === 'account' || value === 'contact')) {
        return true;
      }
      let result = false;
      if (value === 'account') {
        result = inAccount;
        if (inAccount === null) {
          if (!precise) {
            return true;
          }
          result = null;
        } else if (inAccount) {
          return true;
        }
        if (!result) {
          result = isOwnContact;
          if (isOwnContact === null) {
            if (!precise) {
              return true;
            }
            result = null;
          } else if (isOwnContact) {
            return true;
          }
        }
      }
      if (value === 'contact') {
        result = isOwnContact;
        if (isOwnContact === null) {
          if (!precise) {
            return true;
          }
          result = null;
        } else if (isOwnContact) {
          return true;
        }
      }
      if (isOwner === null) {
        if (!precise) {
          return true;
        }
        result = null;
      }
      return result;
    }

    /** @inheritDoc */
    checkModel(model, data, action, precise) {
      if (this.getUser().isAdmin()) {
        return true;
      }
      const entityAccessData = {
        isOwner: this.checkIsOwner(model),
        inAccount: this.checkInAccount(model),
        isOwnContact: this.checkIsOwnContact(model)
      };
      return this.checkScope(data, action, precise, entityAccessData);
    }

    /** @inheritDoc */
    checkIsOwner(model) {
      if (model.hasField('createdBy') && this.getUser().id === model.get('createdById')) {
        return true;
      }
      return false;
    }

    /**
     * Check if a user in an account of a model.
     *
     * @param {import('model').default} model A model.
     * @returns {boolean|null} True if in an account, null if not clear.
     */
    checkInAccount(model) {
      const accountsIds = this.getUser().getLinkMultipleIdList('accounts');
      if (!accountsIds.length) {
        return false;
      }
      const link = this.metadata.get(`aclDefs.${model.entityType}.accountLink`);
      if (link) {
        const linkType = model.getLinkType(link);
        if (linkType === 'belongsTo' || linkType === 'hasOne') {
          const idAttribute = link + 'Id';
          if (!model.has(idAttribute)) {
            return null;
          }
          const id = model.get(idAttribute);
          if (!id) {
            return false;
          }
          return accountsIds.includes(id);
        }
        if (linkType === 'belongsToParent') {
          const idAttribute = link + 'Id';
          const typeAttribute = link + 'Type';
          if (!model.has(idAttribute) || !model.has(typeAttribute)) {
            return null;
          }
          const id = model.get(idAttribute);
          if (model.get(typeAttribute) !== 'Account' || !id) {
            return false;
          }
          return accountsIds.includes(id);
        }
        if (linkType === 'hasMany') {
          if (!model.hasField(link) || model.getFieldType(link) !== 'linkMultiple') {
            return true;
          }
          if (!model.has(link + 'Ids')) {
            return null;
          }
          const ids = model.getLinkMultipleIdList(link);
          for (const id of ids) {
            if (accountsIds.includes(id)) {
              return true;
            }
          }
          return false;
        }
        return false;
      }
      if (model.hasField('account') && model.get('accountId') && accountsIds.includes(model.get('accountId'))) {
        return true;
      }
      let result = false;
      if (model.hasField('accounts') && model.hasLink('accounts')) {
        if (!model.has('accountsIds')) {
          result = null;
        }
        model.getLinkMultipleIdList('accounts').forEach(id => {
          if (accountsIds.includes(id)) {
            result = true;
          }
        });
      }
      if (model.hasField('parent') && model.hasLink('parent') && model.get('parentType') === 'Account' && accountsIds.includes(model.get('parentId'))) {
        return true;
      }
      if (result === false) {
        if (!model.hasField('accounts') && model.hasLink('accounts')) {
          return true;
        }
      }
      return result;
    }

    /**
     * Check if a user is a contact-owner to a model.
     *
     * @param {module:model} model A model.
     * @returns {boolean|null} True if in a contact-owner, null if not clear.
     */
    checkIsOwnContact(model) {
      const contactId = this.getUser().get('contactId');
      if (!contactId) {
        return false;
      }
      const link = this.metadata.get(`aclDefs.${model.entityType}.contactLink`);
      if (link) {
        const linkType = model.getLinkType(link);
        if (linkType === 'belongsTo' || linkType === 'hasOne') {
          const idAttribute = link + 'Id';
          if (!model.has(idAttribute)) {
            return null;
          }
          return model.get(idAttribute) === contactId;
        }
        if (linkType === 'belongsToParent') {
          const idAttribute = link + 'Id';
          const typeAttribute = link + 'Type';
          if (!model.has(idAttribute) || !model.has(typeAttribute)) {
            return null;
          }
          if (model.get(typeAttribute) !== 'Contact') {
            return false;
          }
          return model.get(idAttribute) === contactId;
        }
        if (linkType === 'hasMany') {
          if (!model.hasField(link) || model.getFieldType(link) !== 'linkMultiple') {
            return true;
          }
          if (!model.has(link + 'Ids')) {
            return null;
          }
          const ids = model.getLinkMultipleIdList(link);
          return ids.includes(contactId);
        }
        return false;
      }
      if (model.hasField('contact')) {
        if (model.get('contactId')) {
          if (contactId === model.get('contactId')) {
            return true;
          }
        }
      }
      let result = false;
      if (model.hasField('contacts') && model.hasLink('contacts')) {
        if (!model.has('contactsIds')) {
          result = null;
        }
        model.getLinkMultipleIdList('contacts').forEach(id => {
          if (contactId === id) {
            result = true;
          }
        });
      }
      if (model.hasField('parent') && model.hasLink('parent')) {
        if (model.get('parentType') === 'Contact' && model.get('parentId') === contactId) {
          return true;
        }
      }
      if (result === false) {
        if (!model.hasField('contacts') && model.hasLink('contacts')) {
          return true;
        }
      }
      return result;
    }
    static #_ = _staticBlock = () => [_init_metadata, _init_extra_metadata] = _applyDecs(this, [], [[(0, _di.inject)(_metadata.default), 0, "metadata"]], 0, void 0, _acl.default).e;
  }
  _staticBlock();
  var _default = _exports.default = AclPortal;
});

define("views/list", ["exports", "views/main", "search-manager", "helpers/record-modal", "utils", "helpers/misc/pipelines", "ui"], function (_exports, _main, _searchManager, _recordModal, _utils, _pipelines, _ui) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _main = _interopRequireDefault(_main);
  _searchManager = _interopRequireDefault(_searchManager);
  _recordModal = _interopRequireDefault(_recordModal);
  _utils = _interopRequireDefault(_utils);
  _pipelines = _interopRequireDefault(_pipelines);
  _ui = _interopRequireDefault(_ui);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * A list view.
   */
  class ListView extends _main.default {
    template = 'list';
    name = 'List';
    optionsToPass = [];

    /**
     * A header view name.
     */
    headerView = 'views/header';

    /**
     * A search view name.
     */
    searchView = 'views/record/search';

    /**
     * A record/list view name.
     */
    recordView = 'views/record/list';

    /**
     * A record/kanban view name.
     */
    recordKanbanView = 'views/record/kanban';

    /**
     * Has a search panel.
     */
    searchPanel = true;

    /**
     * A search manager.
     */
    searchManager = null;

    /**
     * Has a create button.
     */
    createButton = true;

    /**
     * To use a modal dialog when creating a record.
     */
    quickCreate = false;

    /**
     * After create a view will be stored, so it can be re-used after.
     * Useful to avoid re-rendering when come back the list view.
     */
    storeViewAfterCreate = false;

    /**
     * After update a view will be stored, so it can be re-used after.
     * Useful to avoid re-rendering when come back the list view.
     */
    storeViewAfterUpdate = true;

    /**
     * Use a current URL as a root URL when open a record. To be able to return to the same URL.
     */
    keepCurrentRootUrl = false;

    /**
     * A view mode. 'list', 'kanban'.
     */

    /**
     * An available view mode list.
     */

    /**
     * A default view mode.
     */
    defaultViewMode = 'list';
    MODE_LIST = 'list';
    MODE_KANBAN = 'kanban';

    /**
     * Root data. To be passed to the detail record view when following to a record.
     *
     * @since 9.0.0
     */

    /**
     * @internal
     */

    shortcutKeys = {
      'Control+Space': function (e) {
        this.handleShortcutKeyCtrlSpace(e);
      },
      /** @this ListView */'Control+Slash': function (e) {
        this.handleShortcutKeyCtrlSlash(e);
      },
      'Control+Comma': function (e) {
        this.handleShortcutKeyCtrlComma(e);
      },
      'Control+Period': function (e) {
        this.handleShortcutKeyCtrlPeriod(e);
      },
      'Control+ArrowLeft': function (e) {
        this.handleShortcutKeyControlArrowLeft(e);
      },
      'Control+ArrowRight': function (e) {
        this.handleShortcutKeyControlArrowRight(e);
      }
    };
    setup() {
      var _this$options$params, _this$options$params2;
      this.collection.maxSize = this.getConfig().get('recordsPerPage') || this.collection.maxSize;
      this.collectionUrl = this.collection.url;
      this.collectionMaxSize = this.collection.maxSize;
      this.rootData = {};
      this._primaryFilter = ((_this$options$params = this.options.params) === null || _this$options$params === void 0 ? void 0 : _this$options$params.primaryFilter) ?? null;
      this._fromAdmin = ((_this$options$params2 = this.options.params) === null || _this$options$params2 === void 0 ? void 0 : _this$options$params2.fromAdmin) ?? false;
      this.setupModes();
      this.setViewMode(this.viewMode);
      if (this.getMetadata().get(['clientDefs', this.scope, 'searchPanelDisabled'])) {
        this.searchPanel = false;
      }
      if (this.getUser().isPortal()) {
        if (this.getMetadata().get(['clientDefs', this.scope, 'searchPanelInPortalDisabled'])) {
          this.searchPanel = false;
        }
      }
      if (this.getMetadata().get(['clientDefs', this.scope, 'createDisabled'])) {
        this.createButton = false;
      }
      this.entityType = this.collection.entityType;
      this.headerView = this.options.headerView || this.headerView;
      this.recordView = this.options.recordView || this.recordView;
      this.searchView = this.options.searchView || this.searchView;
      this.setupHeader();
      this.defaultOrderBy = this.defaultOrderBy ?? this.collection.orderBy ?? null;
      this.defaultOrder = this.defaultOrder ?? this.collection.order ?? null;
      this.collection.setOrder(this.defaultOrderBy, this.defaultOrder, true);
      if (this.searchPanel) {
        this.setupSearchManager();
      }
      this.setupSorting();
      if (this.searchPanel) {
        this.setupSearchPanel();
      }
      if (this.createButton) {
        this.setupCreateButton();
      }
      if (this._fromAdmin || this._primaryFilter) {
        this.keepCurrentRootUrl = true;
      }
      this.addActionHandler('fullRefresh', () => this.actionFullRefresh());
    }
    setupFinal() {
      super.setupFinal();
      this.wait(this.getHelper().processSetupHandlers(this, 'list'));
    }

    /**
     * Set up modes.
     */
    setupModes() {
      this.defaultViewMode = this.options.defaultViewMode ?? this.getMetadata().get(['clientDefs', this.scope, 'listDefaultViewMode']) ?? this.defaultViewMode;
      this.viewMode = this.viewMode || this.defaultViewMode;
      const viewModeList = this.options.viewModeList || this.viewModeList || this.getMetadata().get(['clientDefs', this.scope, 'listViewModeList']);
      if (viewModeList) {
        this.viewModeList = viewModeList;
      } else {
        this.viewModeList = [this.MODE_LIST];

        // @todo Mode defs in metadata. Availability is checked in a handler class.

        if (this.getMetadata().get(`clientDefs.${this.scope}.kanbanViewMode`) && !this.viewModeList.includes(this.MODE_KANBAN)) {
          const pipelinesHelper = new _pipelines.default();
          if (!pipelinesHelper.isEnabled(this.scope) || pipelinesHelper.get(this.scope).length) {
            this.viewModeList.push(this.MODE_KANBAN);
          }
        }
      }
      if (this.viewModeList.length > 1) {
        let viewMode = null;
        const modeKey = 'listViewMode' + this.scope;
        if (this.getStorage().has('state', modeKey)) {
          const storedViewMode = this.getStorage().get('state', modeKey);
          if (storedViewMode && this.viewModeList.includes(storedViewMode)) {
            viewMode = storedViewMode;
          }
        }
        if (!viewMode) {
          viewMode = this.defaultViewMode;
        }
        this.viewMode = /** @type {string} */viewMode;
      }
    }

    /**
     * Set up a header.
     */
    setupHeader() {
      this.createView('header', this.headerView, {
        collection: this.collection,
        fullSelector: '#main > .page-header',
        scope: this.scope,
        isXsSingleRow: true
      });
    }

    /**
     * Set up a create button.
     */
    setupCreateButton() {
      if (this.quickCreate) {
        this.addMenuItem('buttons', {
          action: 'quickCreate',
          iconHtml: '<span class="fas fa-plus fa-sm"></span>',
          text: this.translate('Create ' + this.scope, 'labels', this.scope),
          style: 'default',
          acl: 'create',
          aclScope: this.entityType ?? this.scope,
          title: 'Ctrl+Space'
        }, true);
        return;
      }
      this.addMenuItem('buttons', {
        link: `#${this.scope}/create`,
        action: 'create',
        iconHtml: '<span class="fas fa-plus fa-sm"></span>',
        text: this.translate('Create ' + this.scope, 'labels', this.scope),
        style: 'default',
        acl: 'create',
        aclScope: this.entityType ?? this.scope,
        title: 'Ctrl+Space'
      }, true);
    }

    /**
     * Set up a search panel.
     *
     * @protected
     */
    setupSearchPanel() {
      this.createSearchView();
    }

    /**
     * Create a search view.
     */
    async createSearchView() {
      const view = await this.createView('search', this.searchView, {
        collection: this.collection,
        fullSelector: '#main > .search-container',
        searchManager: this.searchManager,
        scope: this.scope,
        viewMode: this.viewMode,
        viewModeList: this.viewModeList,
        isWide: true,
        disableSavePreset: !!this._primaryFilter,
        primaryFiltersDisabled: !!this._primaryFilter
      });
      this.listenTo(view, 'reset', () => this.resetSorting());
      if (this.viewModeList.length > 1) {
        this.listenTo(view, 'change-view-mode', mode => this.switchViewMode(mode));
      }
      return view;
    }

    /**
     * Switch a view mode.
     *
     * @param mode A mode.
     */
    switchViewMode(mode) {
      this.clearView('list');
      this.collection.isFetched = false;
      this.collection.reset();
      this.applyStoredSorting();
      this.setViewMode(mode, true);
      this.loadList();
    }

    /**
     * Set a view mode.
     *
     * @param mode A mode.
     * @param toStore To preserve a mode being set.
     */
    setViewMode(mode) {
      let toStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
      this.viewMode = mode;
      this.collection.url = this.collectionUrl;
      this.collection.maxSize = this.collectionMaxSize;
      if (toStore) {
        const modeKey = 'listViewMode' + this.scope;
        this.getStorage().set('state', modeKey, mode);
      }
      if (this.searchView && this.getView('search')) {
        this.getSearchView().setViewMode(mode);
      }
      if (this.viewMode === this.MODE_KANBAN) {
        this.setViewModeKanban();
        return;
      }
      const methodName = 'setViewMode' + _utils.default.upperCaseFirst(this.viewMode);
      if (this[methodName]) {
        this[methodName]();
      }
    }

    /**
     * Called when the kanban mode is set.
     */
    setViewModeKanban() {
      this.collection.url = 'Kanban/' + this.scope;
      this.collection.maxSize = this.getConfig().get('recordsPerPageKanban');
      this.collection.resetOrderToDefault();
    }

    /**
     * Reset sorting in a storage.
     */
    resetSorting() {
      this.getStorage().clear('listSorting', this.scope);
    }

    /**
     * Get default search data.
     *
     */
    getSearchDefaultData() {
      return this.getMetadata().get(`clientDefs.${this.scope}.defaultFilterData`);
    }

    /**
     * Set up a search manager.
     */
    setupSearchManager() {
      const collection = this.collection;
      let key = 'list';
      if (this._primaryFilter) {
        key += 'Filter' + _utils.default.upperCaseFirst(this._primaryFilter);
      }
      const searchManager = new _searchManager.default(collection, {
        storageKey: key,
        defaultData: this.getSearchDefaultData(),
        scope: this.scope
      });
      searchManager.loadStored();
      if (this._primaryFilter) {
        searchManager.clearPreset();
        searchManager.setPrimary(this._primaryFilter);
      }
      collection.where = searchManager.getWhere();
      this.searchManager = searchManager;
    }

    /**
     * Set up sorting.
     */
    setupSorting() {
      if (!this.searchPanel) {
        return;
      }
      this.applyStoredSorting();
    }

    /**
     * Apply stored sorting.
     */
    applyStoredSorting() {
      const sortingParams = this.getStorage().get('listSorting', this.scope) || {};
      if ('orderBy' in sortingParams) {
        this.collection.orderBy = sortingParams.orderBy;
      }
      if ('order' in sortingParams) {
        this.collection.order = sortingParams.order;
      }
    }
    getSearchView() {
      return this.getView('search');
    }
    getRecordView() {
      return this.getView('list');
    }

    /**
     * Get a record view name.
     */
    getRecordViewName() {
      let viewName = this.getMetadata().get(['clientDefs', this.scope, 'recordViews', this.viewMode]);
      if (viewName) {
        return viewName;
      }
      if (this.viewMode === this.MODE_LIST) {
        return this.recordView;
      }
      if (this.viewMode === this.MODE_KANBAN) {
        return this.recordKanbanView;
      }
      const propertyName = 'record' + _utils.default.upperCaseFirst(this.viewMode) + 'View';
      viewName = this[propertyName];
      if (!viewName) {
        throw new Error("No record view.");
      }
      return viewName;
    }
    cancelRender() {
      if (this.hasView('list')) {
        this.getRecordView();
        if (this.getRecordView().isBeingRendered()) {
          this.getRecordView().cancelRender();
        }
      }
      super.cancelRender();
    }
    afterRender() {
      var _this$$el$get;
      _ui.default.notify();
      if (!this.hasView('list')) {
        this.loadList();
      }

      // noinspection JSUnresolvedReference
      (_this$$el$get = this.$el.get(0)) === null || _this$$el$get === void 0 || _this$$el$get.focus({
        preventScroll: true
      });
    }

    /**
     * Load a record list view.
     */
    loadList() {
      if ('isFetched' in this.collection && this.collection.isFetched) {
        this.createListRecordView(false);
        return;
      }
      _ui.default.notifyWait();
      this.createListRecordView(true);
    }

    /**
     * Prepare record view options. Options can be modified in an extended method.
     *
     * @param options Options
     */
    prepareRecordViewOptions(options) {
      // noinspection BadExpressionStatementJS
      options;
    }

    /**
     * Create a record list view.
     *
     * @param fetch To fetch after creation.
     */
    async createListRecordView() {
      let fetch = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
      const o = {
        collection: this.collection,
        selector: '.list-container',
        scope: this.scope,
        skipBuildRows: true,
        shortcutKeysEnabled: true,
        forceDisplayTopBar: true,
        additionalRowActionList: this.getMetadata().get(`clientDefs.${this.scope}.rowActionList`),
        settingsEnabled: true,
        forceSettings: this.getMetadata().get(`clientDefs.${this.scope}.forceListViewSettings`)
      }; // @todo Add type.

      if (this.getHelper().isXsScreen()) {
        o.type = 'listSmall';
      }
      this.optionsToPass.forEach(option => {
        o[option] = this.options[option];
      });
      if (this.keepCurrentRootUrl) {
        o.keepCurrentRootUrl = true;
      }
      if (this.getConfig().get('listPagination') || this.getMetadata().get(['clientDefs', this.scope, 'listPagination'])) {
        o.pagination = true;
      }
      o.rootData = this.rootData;
      this.prepareRecordViewOptions(o);
      const listViewName = this.getRecordViewName();
      const promise = this.createView('list', listViewName, o).then(async view => {
        if (!this.hasParentView()) {
          view.undelegateEvents();
          return view;
        }
        this.listenTo(view, 'after:paginate', () => window.scrollTo({
          top: 0
        }));
        this.listenTo(view, 'sort', () => window.scrollTo({
          top: 0
        }));
        this.listenToOnce(view, 'after:render', () => {
          if (!this.hasParentView()) {
            view.undelegateEvents();
            this.clearView('list');
          }
        });
        if (!fetch) {
          _ui.default.notify();
        }
        if (this.searchPanel && this.scope) {
          this.listenTo(view, 'sort', o => {
            this.getStorage().set('listSorting', this.scope, o);
          });
        }
        if (!fetch) {
          await view.render();
          return view;
        }
        const selectAttributes = await view.getSelectAttributeList();
        if (this.options.mediator && this.options.mediator.abort) {
          return view;
        }
        if (selectAttributes) {
          this.collection.data.select = selectAttributes.join(',');
        }
        _ui.default.notifyWait();
        await this.collection.fetch({
          main: true
        });
        _ui.default.notify();
        return view;
      });
      return promise;
    }
    getHeader() {
      if (this._fromAdmin) {
        const root = document.createElement('a');
        root.href = '#Admin';
        root.textContent = this.translate('Administration', 'labels', 'Admin');
        root.style.userSelect = 'none';
        const scope = document.createElement('span');
        scope.textContent = this.getLanguage().translate(this.scope, 'scopeNamesPlural');
        scope.dataset.action = 'fullRefresh';
        scope.style.cursor = 'pointer';
        scope.style.userSelect = 'none';
        return this.buildHeaderHtml([root, scope]);
      }
      const root = document.createElement('span');
      root.textContent = this.getLanguage().translate(this.scope, 'scopeNamesPlural');
      root.title = this.translate('clickToRefresh', 'messages');
      root.dataset.action = 'fullRefresh';
      root.style.cursor = 'pointer';
      root.style.userSelect = 'none';
      const iconHtml = this.getHeaderIconHtml();
      if (iconHtml) {
        root.insertAdjacentHTML('afterbegin', iconHtml);
      }
      if (this._primaryFilter) {
        const label = this.translate(this._primaryFilter, 'presetFilters', this.entityType);

        // noinspection SpellCheckingInspection
        root.insertAdjacentHTML('beforeend', ' · ' + label);
      }
      return this.buildHeaderHtml([root]);
    }
    updatePageTitle() {
      this.setPageTitle(this.getLanguage().translate(this.scope, 'scopeNamesPlural'));
    }

    /**
     * Create attributes for an entity being created.
     */
    getCreateAttributes() {
      return null;
    }

    /**
     * Prepare return dispatch parameters to pass to a view when creating a record.
     * To pass some data to restore when returning to the list view.
     *
     * Example:
     * ```
     * params.options.categoryId = this.currentCategoryId;
     * params.options.categoryName = this.currentCategoryName;
     * ```
     *
     * @param params Parameters to be modified.
     * Unset `controller` if bypass return dispatching (to force to come back to the `returnUrl`).
     */
    prepareCreateReturnDispatchParams(params) {
      // noinspection BadExpressionStatementJS
      params;
    }

    /**
     * Action `quickCreate`.
     */
    actionQuickCreate(data) {
      data = data ?? {};
      const attributes = this.getCreateAttributes() || {};
      const returnDispatchParams = {
        controller: this.scope,
        action: null,
        options: {
          isReturn: true
        }
      };
      this.prepareCreateReturnDispatchParams(returnDispatchParams);
      const helper = new _recordModal.default();
      return helper.showCreate(this, {
        entityType: this.scope,
        attributes: attributes,
        rootUrl: this.keepCurrentRootUrl ? this.getRouter().getCurrentUrl() : undefined,
        focusForCreate: data.focusForCreate,
        returnUrl: this.getRouter().getCurrentUrl(),
        returnDispatchParams: returnDispatchParams,
        afterSave: () => {
          this.collection.fetch();
        }
      });
    }

    /**
     * Action 'create'.
     */
    actionCreate(data) {
      data = data || {};
      const router = this.getRouter();
      const url = '#' + this.scope + '/create';
      const attributes = this.getCreateAttributes() || {};
      let options = {
        attributes: attributes
      };
      if (this.keepCurrentRootUrl) {
        options.rootUrl = this.getRouter().getCurrentUrl();
      }
      if (data.focusForCreate) {
        options.focusForCreate = true;
      }
      const returnDispatchParams = {
        controller: this.scope,
        action: null,
        options: {
          isReturn: true
        }
      };
      this.prepareCreateReturnDispatchParams(returnDispatchParams);
      options = {
        ...options,
        returnUrl: this.getRouter().getCurrentUrl(),
        returnDispatchParams: returnDispatchParams
      };
      router.navigate(url, {
        trigger: false
      });
      router.dispatch(this.scope, 'create', options);
    }

    /**
     * Whether the view is actual to be reused.
     */
    isActualForReuse() {
      return 'isFetched' in this.collection && this.collection.isFetched;
    }
    handleShortcutKeyCtrlSpace(event) {
      if (!this.createButton) {
        return;
      }
      if (!this.getAcl().checkScope(this.scope, 'create')) {
        return;
      }
      event.preventDefault();
      event.stopPropagation();
      if (this.quickCreate) {
        this.actionQuickCreate({
          focusForCreate: true
        });
        return;
      }
      this.actionCreate({
        focusForCreate: true
      });
    }
    handleShortcutKeyCtrlSlash(event) {
      if (!this.searchPanel) {
        return;
      }
      const $search = this.$el.find('input.text-filter').first();
      if (!$search.length) {
        return;
      }
      event.preventDefault();
      event.stopPropagation();
      $search.focus();
    }
    handleShortcutKeyCtrlComma(event) {
      // noinspection BadExpressionStatementJS
      event;
      if (!this.getSearchView()) {
        return;
      }
      this.getSearchView().selectPreviousPreset();
    }
    handleShortcutKeyCtrlPeriod(event) {
      // noinspection BadExpressionStatementJS
      event;
      if (!this.getSearchView()) {
        return;
      }
      this.getSearchView().selectNextPreset();
    }
    handleShortcutKeyControlArrowLeft(event) {
      if (_utils.default.isKeyEventInTextInput(event)) {
        return;
      }
      this.getRecordView().trigger('request-page', 'previous');
    }
    handleShortcutKeyControlArrowRight(event) {
      if (_utils.default.isKeyEventInTextInput(event)) {
        return;
      }
      this.getRecordView().trigger('request-page', 'next');
    }
    async actionFullRefresh() {
      _ui.default.notifyWait();
      await this.collection.fetch();
      _ui.default.notify();
    }
  }
  var _default = _exports.default = ListView;
});

define("views/collapsed-modal-bar", ["exports", "view", "views/collapsed-modal", "views/popup-notification"], function (_exports, _view, _collapsedModal, _popupNotification) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  _collapsedModal = _interopRequireDefault(_collapsedModal);
  _popupNotification = _interopRequireDefault(_popupNotification);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class CollapsedModalBarView extends _view.default {
    // language=Handlebars
    templateContent = `
        {{#each dataList}}
            <div class="collapsed-modal" data-number="{{number}}">{{var key ../this}}</div>
        {{/each}}
    `;

    /**
     * @private
     * @type {number}
     */
    maxNumberToDisplay = 3;

    /**
     * @private
     * @type {number[]}
     */
    numberList;

    /**
     * @private
     * @type {number}
     */
    lastNumber;

    /**
     * @private
     * @type {WeakMap<import('view').default, number>}
     */
    map;
    data() {
      return {
        dataList: this.getDataList()
      };
    }
    init() {
      this.on('render', () => {
        if (document.querySelector('.collapsed-modal-bar')) {
          return;
        }
        const div = document.createElement('div');
        div.classList.add('collapsed-modal-bar');
        document.body.append(div);
      });
    }
    setup() {
      this.lastNumber = 0;
      this.numberList = [];
      this.map = new WeakMap();
    }

    /**
     * @private
     * @return {Record[]}
     */
    getDataList() {
      const list = [];
      let numberList = [...this.numberList];
      if (this.numberList.length > this.maxNumberToDisplay) {
        numberList = numberList.slice(this.numberList.length - this.maxNumberToDisplay);
      }
      numberList.reverse().forEach((number, i) => {
        list.push({
          number: number.toString(),
          key: this.composeKey(number),
          index: i
        });
      });
      return list;
    }

    /**
     * @private
     * @param {string} title
     * @return {number|null}
     */
    calculateDuplicateNumber(title) {
      let duplicateNumber = 0;
      for (const number of this.numberList) {
        const view = this.getCollapsedModalViewByNumber(number);
        if (!view) {
          continue;
        }
        if (view.title === title) {
          duplicateNumber++;
        }
      }
      if (duplicateNumber === 0) {
        return null;
      }
      return duplicateNumber;
    }

    /**
     * @param {number} number
     * @return {import('views/collapsed-modal').default|null}
     */
    getCollapsedModalViewByNumber(number) {
      const key = this.composeKey(number);
      return this.getView(key);
    }

    /**
     * @type {import('views/modal').default[]}
     */
    getModalViewList() {
      return this.numberList.map(number => this.getCollapsedModalViewByNumber(number)).filter(it => it).map(it => it.modalView);
    }

    /**
     * @param {import('views/modal').default|import('views/popup-notification').default} modalView
     * @param {{title: string | null}} options
     */
    async addModalView(modalView, options) {
      const number = this.lastNumber;
      this.numberList.push(this.lastNumber);
      const key = this.composeKey(number);
      this.lastNumber++;
      this.map.set(modalView, number);
      const view = new _collapsedModal.default({
        modalView: modalView,
        title: options.title,
        duplicateNumber: this.calculateDuplicateNumber(options.title),
        onClose: () => {
          this.removeModalViewByNumber(number);
          if (modalView instanceof _popupNotification.default) {
            modalView.resolveCancel();
          }
        },
        onExpand: () => {
          this.removeModalViewByNumber(number, true);

          // Use timeout to prevent DOM being updated after modal is re-rendered.
          setTimeout(async () => {
            if (modalView instanceof _popupNotification.default) {
              this.expandPopupNotification(modalView);
              return;
            }
            const key = `dialog-${number}`;
            this.setView(key, modalView);
            modalView.setSelector(modalView.containerSelector);
            await this.getView(key).render();
            modalView.trigger('after:expand');
          }, 5);
        }
      });
      await this.assignView(key, view, `[data-number="${number}"]`);
      await this.reRender(true);
    }

    /**
     * @param {import('views/modal').default|import('views/popup-notification').default} modalView
     * @since 10.0
     */
    removeModalView(modalView) {
      const number = this.map.get(modalView);
      if (number === undefined) {
        return;
      }
      this.removeModalViewByNumber(number);
    }

    /**
     * @param {number} number
     * @param {boolean} [noReRender]
     */
    removeModalViewByNumber(number) {
      let noReRender = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
      const key = this.composeKey(number);
      const index = this.numberList.indexOf(number);
      if (~index) {
        this.numberList.splice(index, 1);
      }
      if (this.isRendered()) {
        const element = this.element.querySelector(`.collapsed-modal[data-number="${number}"]`);
        if (element) {
          element.remove();
        }
      }
      if (!noReRender) {
        this.reRender();
      }
      const view = this.getCollapsedModalViewByNumber(number);
      if (view !== null && view !== void 0 && view.modalView) {
        this.getRouter().removeWindowLeaveOutObject(view.modalView);
      }
      this.clearView(key);
    }

    /**
     * @private
     * @param {number} number
     * @return {string}
     */
    composeKey(number) {
      return `key-${number}`;
    }

    /**
     * @private
     * @param {PopupNotificationView} view
     */
    expandPopupNotification(view) {
      view.expand();
    }
  }
  var _default = _exports.default = CollapsedModalBarView;
});

define("views/stream/note", ["exports", "view"], function (_exports, _view) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class NoteStreamView extends _view.default {
    /**
     * @protected
     * @type {string|null}
     */
    messageName = null;

    /**
     * @protected
     * @type {string|null}
     */
    messageTemplate = null;

    /**
     * Data to pass to a message template.
     *
     * @protected
     * @type {Object.<string,JQuery|Element|string>|null}
     */
    messageData = null;

    /** @protected */
    isEditable = false;
    /** @protected */
    isRemovable = false;
    /** @protected */
    isSystemAvatar = false;
    rowActionsView = 'views/stream/record/row-actions/default';
    data() {
      return {
        isUserStream: this.isUserStream,
        noEdit: this.options.noEdit,
        acl: this.options.acl,
        onlyContent: this.options.onlyContent,
        avatar: this.getAvatarHtml()
      };
    }
    init() {
      this.createField('createdAt', null, null, 'views/fields/datetime-short');

      /** @type {string} */
      this.listType = this.options.listType;
      this.isUserStream = this.options.isUserStream;
      this.isThis = !this.isUserStream;
      this.parentModel = this.options.parentModel;
      if (!this.isUserStream) {
        if (this.parentModel) {
          if (this.parentModel.entityType !== this.model.get('parentType') || this.parentModel.id !== this.model.get('parentId')) {
            this.isThis = false;
          }
        }
      }
      if (this.getUser().isAdmin()) {
        this.isRemovable = true;
      }
      if (this.messageName && this.isThis) {
        this.messageName += 'This';
      }
      if (!this.isThis) {
        this.createField('parent');
      }
      const translatedEntityType = this.translateEntityType(this.model.get('parentType'));
      this.messageData = {
        'user': 'field:createdBy',
        'entity': 'field:parent',
        'entityType': translatedEntityType
      };
      const rowActionsView = this.options.rowActionsView || this.rowActionsView;
      if (!this.options.noEdit && (this.isEditable || this.isRemovable)) {
        this.createView('right', rowActionsView, {
          selector: '.right-container',
          acl: this.options.acl,
          model: this.model,
          isEditable: this.isEditable,
          isRemovable: this.isRemovable,
          listType: this.listType,
          isThis: this.isThis,
          parentModel: this.parentModel,
          isNotification: this.options.isNotification
        });
      }
    }
    translateEntityType(entityType, isPlural) {
      let string = isPlural ? this.translate(entityType, 'scopeNamesPlural') || '' : this.translate(entityType, 'scopeNames') || '';
      if (!this.isToUpperCaseStringItems()) {
        string = string.toLowerCase();
      }
      return string;
    }
    isToUpperCaseStringItems() {
      const language = this.getPreferences().get('language') || this.getConfig().get('language');
      return ['de_DE', 'nl_NL'].includes(language);
    }
    createField(name, type, params, view, options) {
      type = type || this.model.getFieldType(name) || 'base';
      const o = {
        model: this.model,
        defs: {
          name: name,
          params: params || {}
        },
        selector: '.cell-' + name,
        mode: 'list'
      };
      if (options) {
        for (const i in options) {
          o[i] = options[i];
        }
      }
      this.createView(name, view || this.getFieldManager().getViewName(type), o);
    }
    isMale() {
      return this.model.get('createdByGender') === 'Male';
    }
    isFemale() {
      return this.model.get('createdByGender') === 'Female';
    }
    createMessage() {
      if (!this.messageTemplate) {
        let isTranslated = false;
        const parentType = this.model.get('parentType') || null;
        if (this.isMale()) {
          this.messageTemplate = this.translate(this.messageName, 'streamMessagesMale', parentType) || '';
          if (this.messageTemplate !== this.messageName) {
            isTranslated = true;
          }
        } else if (this.isFemale()) {
          this.messageTemplate = this.translate(this.messageName, 'streamMessagesFemale', parentType) || '';
          if (this.messageTemplate !== this.messageName) {
            isTranslated = true;
          }
        }
        if (!isTranslated) {
          this.messageTemplate = this.translate(this.messageName, 'streamMessages', parentType) || '';
        }
      }
      if (this.messageTemplate.indexOf('{entityType}') === 0 && typeof this.messageData.entityType === 'string') {
        this.messageData.entityTypeUcFirst = Espo.Utils.upperCaseFirst(this.messageData.entityType);
        this.messageTemplate = this.messageTemplate.replace('{entityType}', '{entityTypeUcFirst}');
      }
      this.createView('message', 'views/stream/message', {
        messageTemplate: this.messageTemplate,
        selector: '.message',
        model: this.model,
        messageData: this.messageData
      });
    }
    getAvatarHtml() {
      let id = this.model.get('createdById');
      if (this.isSystemAvatar) {
        id = this.getHelper().getAppParam('systemUserId');
      }
      return this.getHelper().getAvatarHtml(id, 'small', 20);
    }

    /**
     *
     * @param [scope]
     * @param [id]
     * @return {string|null}
     */
    getIconHtml(scope, id) {
      if (!scope) {
        if (!this.model.attributes.parentType) {
          return null;
        }
        scope = this.model.attributes.parentType;
        id = this.model.attributes.parentId;
      }
      if (this.options.isInGroup) {
        return null;
      }
      if (this.isThis && this.parentModel && scope === this.parentModel.entityType) {
        return null;
      }
      const iconClass = this.getMetadata().get(`clientDefs.${scope}.iconClass`);
      const color = this.getMetadata().get(`clientDefs.${scope}.color`);
      if (!iconClass) {
        return null;
      }
      return $('<span>').addClass(iconClass).addClass('action text-muted icon').css('cursor', 'pointer').css('color', color ? color : '').attr('title', this.translate('View')).attr('data-action', 'quickView').attr('data-id', id).attr('data-scope', scope).get(0).outerHTML;
    }
  }
  var _default = _exports.default = NoteStreamView;
});

define("views/stream/record/list", ["exports", "views/record/list-expanded"], function (_exports, _listExpanded) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _listExpanded = _interopRequireDefault(_listExpanded);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/stream/record/list */

  class ListStreamRecordView extends _listExpanded.default {
    type = 'listStream';
    massActionsDisabled = true;

    /**
     * @private
     * @type {boolean}
     */
    isUserStream;
    setup() {
      this.isUserStream = this.options.isUserStream || false;
      this.itemViews = this.getMetadata().get('clientDefs.Note.itemViews') || {};
      super.setup();
      this.isRenderingNew = false;
      this.listenTo(this.collection, 'update-sync', () => {
        this.buildRows(() => this.reRender());
      });
      if (this.isUserStream || this.model.entityType === 'User') {
        const collection = /** @type {import('collections/note').default} */this.collection;
        collection.reactionsCheckMaxSize = this.getConfig().get('streamReactionsCheckMaxSize') || 0;
      }
      this.listenTo(this.collection, 'sync', (c, r, options) => {
        if (!options.fetchNew) {
          return;
        }
        if (this.isRenderingNew) {
          // Prevent race condition.
          return;
        }
        const lengthBeforeFetch = options.lengthBeforeFetch || 0;
        if (lengthBeforeFetch === 0) {
          this.buildRows(() => this.reRender());
          return;
        }
        const $list = this.$el.find(this.listContainerEl);
        const rowCount = this.collection.length - lengthBeforeFetch;
        if (rowCount === 0) {
          return;
        }
        this.isRenderingNew = true;
        for (let i = rowCount - 1; i >= 0; i--) {
          const model = this.collection.at(i);
          this.buildRow(i, model, view => {
            if (i === 0) {
              this.isRenderingNew = false;
            }
            let $row = $(this.getRowContainerHtml(model.id));

            // Prevent a race condition issue.
            const $existingRow = this.$el.find(`[data-id="${model.id}"]`);
            if ($existingRow.length) {
              $row = $existingRow;
            }
            if (!$existingRow.length) {
              $list.prepend($row);
            }
            view.render();
          });
        }
      });
      this.events['auxclick a[href][data-scope][data-id]'] = e => {
        const isCombination = e.button === 1 && (e.ctrlKey || e.metaKey);
        if (!isCombination) {
          return;
        }
        const $target = $(e.currentTarget);
        const id = $target.attr('data-id');
        const scope = $target.attr('data-scope');
        e.preventDefault();
        e.stopPropagation();
        this.actionQuickView({
          id: id,
          scope: scope
        });
      };
    }
    buildRow(i, model, callback) {
      const key = model.id;
      this.rowList.push(key);
      const type = model.get('type');
      const viewName = this.itemViews[type] || 'views/stream/notes/' + Espo.Utils.camelCaseToHyphen(type);
      this.createView(key, viewName, {
        model: model,
        parentModel: this.model,
        acl: {
          edit: this.getAcl().checkModel(model, 'edit')
        },
        isUserStream: this.options.isUserStream,
        noEdit: this.options.noEdit,
        optionsToPass: ['acl'],
        name: this.type + '-' + model.entityType,
        selector: 'li[data-id="' + model.id + '"]',
        setViewBeforeCallback: this.options.skipBuildRows && !this.isRendered(),
        listType: this.type,
        rowActionsView: this.options.rowActionsView
      }, callback);
    }
    buildRows(callback) {
      this.checkedList = [];
      this.rowList = [];
      if (this.collection.length > 0) {
        this.wait(true);
        const count = this.collection.models.length;
        let built = 0;
        for (const i in this.collection.models) {
          const model = this.collection.models[i];
          this.buildRow(i, model, () => {
            built++;
            if (built === count) {
              if (typeof callback === 'function') {
                callback();
              }
              this.wait(false);
              this.trigger('after:build-rows');
            }
          });
        }
        return;
      }
      if (typeof callback === 'function') {
        callback();
        this.trigger('after:build-rows');
      }
    }

    /**
     * Load new records.
     *
     * @return {Promise}
     */
    showNewRecords() {
      const collection = /** @type {import('collections/note').default} */
      this.collection;
      return collection.fetchNew();
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * @private
     * @param {{id: string}} data
     */
    actionPin(data) {
      const collection = /** @type {import('collections/note').default} */this.collection;
      Espo.Ui.notifyWait();
      Espo.Ajax.postRequest(`Note/${data.id}/pin`).then(() => {
        Espo.Ui.notify(false);
        const model = collection.get(data.id);
        if (model) {
          model.set('isPinned', true);
        }
        if (collection.pinnedList) {
          collection.fetchNew();
        }
        collection.trigger('pin', model.id);
      });
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * @private
     * @param {{id: string}} data
     */
    actionUnpin(data) {
      const collection = /** @type {import('collections/note').default} */this.collection;
      Espo.Ui.notifyWait();
      Espo.Ajax.deleteRequest(`Note/${data.id}/pin`).then(() => {
        Espo.Ui.notify(false);
        const model = collection.get(data.id);
        if (model) {
          model.set('isPinned', false);
        }
        if (collection.pinnedList) {
          collection.fetchNew();
        }
        collection.trigger('unpin', model.id);
      });
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * @private
     * @param {{id: string}} data
     */
    actionQuoteReply(data) {
      const rowView = this.getView(data.id);
      const selection = window.getSelection();
      if (selection && selection.anchorNode && selection.focusNode) {
        const postContainer = rowView.element.querySelector('.complex-text');
        if (postContainer.contains(selection.anchorNode) && postContainer.contains(selection.focusNode)) {
          let contents = '';
          for (let i = 0; i < selection.rangeCount; i++) {
            const range = selection.getRangeAt(i);
            const div = document.createElement('div');
            div.appendChild(range.cloneContents());
            contents += div.innerHTML;
          }
          if (contents) {
            Espo.loader.requirePromise('turndown').then(/** typeof import('turndown').default */TurndownService => {
              const turndownService = new TurndownService();

              // noinspection JSValidateTypes
              const code = turndownService.turndown(contents);
              this.trigger('quote-reply', code);
            });
            return;
          }
        }
      }
      const model = this.collection.get(data.id);
      if (!model) {
        return;
      }
      const code = model.attributes.post;
      if (!code) {
        return;
      }
      this.trigger('quote-reply', code);
    }
  }
  var _default = _exports.default = ListStreamRecordView;
});

define("views/stream/record/row-actions/reactions/reactions", ["exports", "view"], function (_exports, _view) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ReactionsRowActionView extends _view.default {
    // language=Handlebars
    templateContent = `
        <div class="item-icon-grid">
            {{#each reactions}}
                <a
                    role="button"
                    {{#if isReacted}}
                        data-action="unReact"
                    {{else}}
                        data-action="react"
                    {{/if}}
                    data-type="{{type}}"
                    title="{{label}}"
                    class=" {{#if isReacted}} text-primary {{else}} text-soft {{/if}}"
                ><span class="{{iconClass}}"></span></a>
            {{/each}}
        </div>
    `;
    /**
     * @param {{
     *     reactions: {
     *         type: string,
     *         iconClass: string|null,
     *         label: string,
     *         isReacted: boolean,
     *     }[]
     * }} options
     */
    constructor(options) {
      super(options);
      this.reactions = options.reactions;
    }
    data() {
      return {
        reactions: this.reactions
      };
    }
  }
  _exports.default = ReactionsRowActionView;
});

define("views/record/search", ["exports", "view", "helpers/misc/stored-text-search", "ui/autocomplete", "views/search/filter", "utils", "ui", "views/modals/save-filters", "underscore"], function (_exports, _view, _storedTextSearch, _autocomplete, _filter, _utils, _ui, _saveFilters, _underscore) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  _storedTextSearch = _interopRequireDefault(_storedTextSearch);
  _autocomplete = _interopRequireDefault(_autocomplete);
  _filter = _interopRequireDefault(_filter);
  _utils = _interopRequireDefault(_utils);
  _ui = _interopRequireDefault(_ui);
  _saveFilters = _interopRequireDefault(_saveFilters);
  _underscore = _interopRequireDefault(_underscore);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * A search panel view.
   */
  class SearchView extends _view.default {
    constructor(options) {
      super(options);
    }
    template = 'record/search';
    fieldFilterList = null;
    textFilter = '';
    presetName = null;
    primary = null;
    bool = null;
    filtersLayoutName = 'filters';
    disableSavePreset = false;
    textFilterDisabled = false;
    toShowApplyFiltersButton = false;
    toShowResetFiltersText = false;
    isSearchedWithAdvancedFilter = false;
    primaryFiltersDisabled = false;
    viewModeIconClassMap = {
      list: 'fas fa-align-justify',
      kanban: 'fas fa-align-left fa-rotate-90'
    };
    FIELD_QUICK_SEARCH_COUNT_THRESHOLD = 4;
    autocompleteLimit = 7;
    currentFilterLabelList = null;
    data() {
      return {
        scope: this.scope,
        entityType: this.entityType,
        textFilter: this.textFilter,
        bool: this.bool || {},
        boolFilterList: this.boolFilterList,
        hasFieldQuickSearch: this.fieldFilterList.length >= this.FIELD_QUICK_SEARCH_COUNT_THRESHOLD,
        filterFieldDataList: this.getFilterFieldDataList(),
        filterDataList: this.getFilterDataList(),
        presetName: this.presetName,
        presetFilterList: this.getPresetFilterList(),
        leftDropdown: this.hasLeftDropdown(),
        textFilterDisabled: this.textFilterDisabled,
        viewMode: this.viewMode,
        viewModeDataList: this.viewModeDataList || [],
        hasViewModeSwitcher: this.viewModeList && this.viewModeList.length > 1,
        isWide: this.options.isWide,
        toShowApplyFiltersButton: this.toShowApplyFiltersButton,
        toShowResetFiltersText: this.toShowResetFiltersText,
        primaryFiltersDisabled: this.primaryFiltersDisabled
      };
    }
    setup() {
      this.setupEventHandlers();
      if (!this.collection.entityType) {
        throw new Error("No entity type.");
      }
      this.entityType = this.collection.entityType;
      this.scope = this.options.scope || this.entityType;
      this.filtersLayoutName = this.options.filtersLayoutName || this.filtersLayoutName;
      this.primaryFiltersDisabled = this.options.primaryFiltersDisabled || this.primaryFiltersDisabled;
      this.viewModeIconClassMap = {
        ...this.viewModeIconClassMap,
        ...this.getMetadata().get(`clientDefs.${this.scope}.viewModeIconClassMap`)
      };
      this.searchManager = this.options.searchManager;
      this.storedTextSearchHelper = new _storedTextSearch.default(this.scope, this.getHelper().storage);
      this.textSearchStoringDisabled = this.getPreferences().get('textSearchStoringDisabled');
      this.textFilterDisabled = this.options.textFilterDisabled || this.textFilterDisabled || this.getMetadata().get(['clientDefs', this.scope, 'textFilterDisabled']);
      if ('disableSavePreset' in this.options) {
        this.disableSavePreset = this.options.disableSavePreset;
      }
      this.viewMode = this.options.viewMode;
      this.viewModeList = this.options.viewModeList ?? null;
      this.addReadyCondition(() => {
        return this.fieldFilterList !== null;
      });
      const boolFilterList = this.getMetadata().get(['clientDefs', this.scope, 'boolFilterList']) ?? [];
      this.boolFilterList = boolFilterList.filter(item => {
        if (typeof item === 'string') {
          return true;
        }
        item = item || {};
        if (item.aux) {
          return false;
        }
        if (item.inPortalDisabled && this.getUser().isPortal()) {
          return false;
        }
        if (item.isPortalOnly && !this.getUser().isPortal()) {
          return false;
        }
        if (item.accessDataList) {
          if (!_utils.default.checkAccessDataList(item.accessDataList, this.getAcl(), this.getUser())) {
            return false;
          }
        }
        return true;
      }).map(item => {
        if (typeof item === 'string') {
          return item;
        }
        item = item ?? {};
        return item.name;
      }).filter(it => it != null);
      this.fieldFilterTranslations = {};
      const forbiddenFieldList = this.getAcl().getScopeForbiddenFieldList(this.entityType) || [];
      this.wait(new Promise(resolve => {
        this.getHelper().layoutManager.get(this.entityType, this.filtersLayoutName, list => {
          this.fieldFilterList = [];
          (list ?? []).forEach(field => {
            if (forbiddenFieldList.includes(field)) {
              return;
            }
            this.fieldFilterList.push(field);
            this.fieldFilterTranslations[field] = this.translate(field, 'fields', this.entityType);
          });
          resolve(undefined);
        });
      }));
      this.setupPresetFilters();
      if (this.getMetadata().get(['scopes', this.entityType, 'stream'])) {
        this.boolFilterList.push('followed');
      }
      if (this.getMetadata().get(`scopes.${this.entityType}.collaborators`) && !this.getUser().isPortal()) {
        this.boolFilterList.push('shared');
      }
      this.loadSearchData();
      if (this.hasAdvancedFilter()) {
        this.isSearchedWithAdvancedFilter = true;
      }
      if (this.presetName) {
        let hasPresetListed = false;
        for (const i in this.presetFilterList) {
          const item = this.presetFilterList[i] || {};
          const name = typeof item === 'string' ? item : item.name;
          if (name === this.presetName) {
            hasPresetListed = true;
            break;
          }
        }
        if (!hasPresetListed) {
          this.presetFilterList.push(this.presetName);
        }
      }
      this.model = this.collection.prepareModel();
      this.model.clear();
      this.createFilters();
      this.setupViewModeDataList();
      this.listenTo(this.collection, 'order-changed', () => {
        this.controlResetButtonVisibility();
      });
      this.wait(this.getHelper().processSetupHandlers(this, 'record/search'));
    }
    setupEventHandlers() {
      this.addHandler('keydown', 'input[data-name="textFilter"]', e => {
        if (!(e instanceof KeyboardEvent)) {
          throw new Error();
        }
        const key = _utils.default.getKeyFromKeyEvent(e);
        if (e.key === 'Enter' || key === 'Enter' || key === 'Control+Enter') {
          this.search();
          this.hideApplyFiltersButton();
        }
      });
      this.addHandler('focus', 'input[data-name="textFilter"]', (_, target) => {
        target.select();
      });
      this.addHandler('click', '.advanced-filters-apply-container a[data-action="applyFilters"]', () => {
        var _this$element$querySe;
        this.search();
        this.hideApplyFiltersButton();
        (_this$element$querySe = this.element.querySelector('button.search')) === null || _this$element$querySe === void 0 || _this$element$querySe.focus();
      });
      this.addHandler('click', 'button[data-action="search"]', () => {
        this.search();
        this.hideApplyFiltersButton();
      });
      this.addHandler('click', 'a[data-action="addFilter"]', (_, target) => {
        var _target$closest;
        const name = target.dataset.name;
        target === null || target === void 0 || (_target$closest = target.closest('li')) === null || _target$closest === void 0 || _target$closest.classList.add('hidden');
        this.addFilter(name);
      });
      this.addHandler('click', '.advanced-filters a.remove-filter', (_, target) => {
        const name = target.dataset.name;
        this.removeFilter(name);
      });
      this.addActionHandler('reset', () => this.resetFilters());
      this.addActionHandler('refresh', () => this.refresh());
      this.addActionHandler('selectPreset', (_, target) => {
        const presetName = target.dataset.name || null;
        this.selectPreset(presetName);
      });
      this.addHandler('click', '.dropdown-menu a[data-action="savePreset"]', () => this.savePresetHandler());
      this.addHandler('click', '.dropdown-menu a[data-action="removePreset"]', async () => {
        await this.confirm({
          message: this.translate('confirmation', 'messages')
        });
        this.removePreset(this.presetName);
      });
      this.addHandler('change', '.search-row ul.filter-menu input[data-role="boolFilterCheckbox"]', e => {
        e.stopPropagation();
        this.search();
        this.manageLabels();
      });
      this.addActionHandler('switchViewMode', (_, target) => {
        const mode = target.dataset.name;
        if (mode === this.viewMode) {
          return;
        }
        this._setViewMode(mode, false, true);
      });
      this.addHandler('keyup', 'input.field-filter-quick-search-input', (_, target) => {
        this.processFieldFilterQuickSearch(target.value);
      });
      this.addHandler('keydown', 'input.field-filter-quick-search-input', e => {
        if (!(e instanceof KeyboardEvent)) {
          return;
        }
        if (e.code === 'Enter') {
          this.addFirstFieldFilter();
          return;
        }
        if (e.code === 'Escape') {
          this.closeAddFieldDropdown();
        }
      });
    }
    setupPresetFilters() {
      if (this.primaryFiltersDisabled) {
        this.presetFilterList = [];
        return;
      }
      const filterList = this.options.filterList || this.getMetadata().get(['clientDefs', this.scope, 'filterList']) || [];
      this.presetFilterList = filterList.filter(item => {
        if (typeof item === 'string') {
          return true;
        }
        item = item || {};
        if (item.aux) {
          return false;
        }
        if (item.inPortalDisabled && this.getUser().isPortal()) {
          return false;
        }
        if (item.isPortalOnly && !this.getUser().isPortal()) {
          return false;
        }
        if (item.accessDataList) {
          if (!_utils.default.checkAccessDataList(item.accessDataList, this.getAcl(), this.getUser())) {
            return false;
          }
        }
        return true;
      });
      if (this.getMetadata().get(`scopes.${this.scope}.stars`)) {
        this.presetFilterList.unshift({
          name: 'starred'
        });
      }
      const presets = (this.getPreferences().get('presetFilters') ?? {})[this.scope] ?? [];
      presets.forEach(item => {
        this.presetFilterList.push(item);
      });
    }
    setupViewModeDataList() {
      if (!this.viewModeList) {
        return [];
      }
      const list = [];
      this.viewModeList.forEach(item => {
        const o = {
          name: item,
          title: this.translate(item, 'listViewModes'),
          iconClass: this.viewModeIconClassMap[item] ?? null
        };
        list.push(o);
      });
      this.viewModeDataList = list;
    }

    /**
     * Set a view mode.
     */
    setViewMode(mode) {
      this._setViewMode(mode);
    }
    _setViewMode(mode, preventLoop, toTriggerEvent) {
      this.viewMode = mode;
      if (this.isRendered()) {
        this.$el.find('[data-action="switchViewMode"]').removeClass('active');
        this.$el.find(`[data-action="switchViewMode"][data-name="${mode}"]`).addClass('active');
      } else if (this.isBeingRendered() && !preventLoop) {
        this.once('after:render', () => {
          this._setViewMode(mode, true);
        });
      }
      this.collection.offset = 0;
      if (toTriggerEvent) {
        this.trigger('change-view-mode', mode);
      }
    }
    hasLeftDropdown() {
      if (this.primaryFiltersDisabled && !this.boolFilterList.length) {
        return false;
      }
      return !!(this.presetFilterList.length || this.boolFilterList.length || Object.keys(this.advanced || {}).length);
    }
    handleLeftDropdownVisibility() {
      if (this.hasLeftDropdown()) {
        var _this$leftDropdownEle;
        (_this$leftDropdownEle = this.leftDropdownElement) === null || _this$leftDropdownEle === void 0 || _this$leftDropdownEle.classList.remove('hidden');
      } else {
        var _this$leftDropdownEle2;
        (_this$leftDropdownEle2 = this.leftDropdownElement) === null || _this$leftDropdownEle2 === void 0 || _this$leftDropdownEle2.classList.add('hidden');
      }
    }
    createFilters(callback) {
      let i = 0;
      const count = Object.keys(this.advanced || {}).length;
      if (count === 0) {
        if (typeof callback === 'function') {
          callback();
        }
      }
      for (const field in this.advanced) {
        this.createFilter(field, this.advanced[field], () => {
          i++;
          if (i === count) {
            if (typeof callback === 'function') {
              callback();
            }
          }
        });
      }
    }
    removeFilter(name) {
      var _this$element$querySe2, _this$getView;
      (_this$element$querySe2 = this.element.querySelector(`ul.filter-list li[data-name="${name}"]`)) === null || _this$element$querySe2 === void 0 || _this$element$querySe2.classList.remove('hidden');

      //
      const container = (_this$getView = this.getView(`filter-${name}`)) === null || _this$getView === void 0 || (_this$getView = _this$getView.element) === null || _this$getView === void 0 ? void 0 : _this$getView.closest('div.filter');
      //.$el.closest('div.filter');

      this.clearView(`filter-${name}`);
      container === null || container === void 0 || container.remove();
      delete this.advanced[name];
      this.presetName = this.primary;
      this.updateAddFilterButton();
      this.fetch();
      this.updateSearch();
      this.manageLabels();
      this.handleLeftDropdownVisibility();
      this.controlResetButtonVisibility();
      if (this.isSearchedWithAdvancedFilter) {
        this.hasAdvancedFilter() ? this.showApplyFiltersButton() : this.showResetFiltersButton();
        this.applyFiltersElement.focus();
        return;
      }
      if (!this.hasAdvancedFilter()) {
        this.hideApplyFiltersButton();
      }
    }
    addFilter(name) {
      this.advanced[name] = {};
      this.presetName = this.primary;
      this.createFilter(name, {}, view => {
        var _view$getFieldView;
        view.populateDefaults();
        this.fetch();
        this.updateSearch();
        if ((_view$getFieldView = view.getFieldView()) !== null && _view$getFieldView !== void 0 && _view$getFieldView.initialSearchIsNotIdle) {
          this.showApplyFiltersButton();
        }
      });
      this.updateAddFilterButton();
      this.handleLeftDropdownVisibility();
      this.manageLabels();
      this.controlResetButtonVisibility();
    }
    refresh() {
      _ui.default.notifyWait();
      this.collection.abortLastFetch();
      this.collection.reset();
      this.collection.fetch().then(() => {
        _ui.default.notify(false);
      });
    }
    selectPreset(presetName, forceClearAdvancedFilters) {
      const wasPreset = !(this.primary === this.presetName);
      this.presetName = presetName;
      const advanced = this.getPresetData();
      this.primary = this.getPrimaryFilterName();
      const isPreset = !(this.primary === this.presetName);
      if (forceClearAdvancedFilters || wasPreset || isPreset || Object.keys(advanced).length) {
        this.removeFilters();
        this.advanced = advanced;
      }
      this.updateSearch();
      this.manageLabels();
      this.createFilters(async () => {
        var _this$element$querySe3;
        await this.reRender();
        (_this$element$querySe3 = this.element.querySelector('.filters-button')) === null || _this$element$querySe3 === void 0 || _this$element$querySe3.focus({
          preventScroll: true
        });
      });
      this.updateCollection();
    }
    removeFilters() {
      this.advancedFiltersPanelElement.innerHTML = '';
      for (const name in this.advanced) {
        this.clearView('filter-' + name);
      }
    }
    resetFilters() {
      this.trigger('reset');
      this.collection.resetOrderToDefault();
      this.textFilter = '';
      this.selectPreset(this.presetName, true);
      this.hideApplyFiltersButton();
      this.trigger('update-ui');
    }
    savePreset(name) {
      const id = 'f' + Math.floor(Math.random() * 1000001).toString();
      this.fetch();
      this.updateSearch();
      const presetFilters = this.getPreferences().get('presetFilters') || {};
      if (!(this.scope in presetFilters)) {
        presetFilters[this.scope] = [];
      }
      const data = {
        id: id,
        name: id,
        label: name,
        data: this.advanced,
        primary: this.primary
      };
      presetFilters[this.scope].push(data);
      this.presetFilterList.push(data);
      this.getPreferences().once('sync', () => {
        this.getPreferences().trigger('update');
        this.updateSearch();
      });
      this.getPreferences().save({
        'presetFilters': presetFilters
      }, {
        patch: true
      });
      this.presetName = id;
    }
    removePreset(id) {
      const presetFilters = this.getPreferences().get('presetFilters') || {};
      if (!(this.scope in presetFilters)) {
        presetFilters[this.scope] = [];
      }
      let list;
      list = presetFilters[this.scope];
      list.forEach((item, i) => {
        if (item.id === id) {
          list.splice(i, 1);
        }
      });
      list = this.presetFilterList;
      list.forEach((item, i) => {
        if (item.id === id) {
          list.splice(i, 1);
        }
      });
      this.getPreferences().set('presetFilters', presetFilters);
      this.getPreferences().save({
        patch: true
      });
      this.getPreferences().trigger('update');
      this.presetName = this.primary;
      this.advanced = {};
      this.removeFilters();
      this.render();
      this.updateSearch();
      this.updateCollection();
    }
    updateAddFilterButton() {
      var _this$filterListEleme;
      const noFields = !Array.from(((_this$filterListEleme = this.filterListElement) === null || _this$filterListEleme === void 0 ? void 0 : _this$filterListEleme.children) ?? []).some(li => {
        return !li.classList.contains('hidden') && !li.classList.contains('dropdown-header') && !li.classList.contains('quick-search-list-item');
      });
      if (noFields) {
        var _this$addFilterButton;
        (_this$addFilterButton = this.addFilterButtonElement) === null || _this$addFilterButton === void 0 || _this$addFilterButton.classList.add('disabled');
      } else {
        var _this$addFilterButton2;
        (_this$addFilterButton2 = this.addFilterButtonElement) === null || _this$addFilterButton2 === void 0 || _this$addFilterButton2.classList.remove('disabled');
      }
      this.trigger('update-ui');
    }
    afterRender() {
      var _this$filterListEleme2;
      this.filtersLabel = this.element.querySelector('.search-row span.filters-label');
      this.applyFiltersContainer = this.element.querySelector('.advanced-filters-apply-container');
      this.applyFiltersElement = this.applyFiltersContainer.querySelector('[data-action="applyFilters"]');
      this.filtersButton = this.element.querySelector('.search-row button.filters-button');
      this.leftDropdownElement = this.element.querySelector('div.search-row div.left-dropdown');
      this.resetButtonElement = this.element.querySelector('[data-action="reset"]');
      this.filterListElement = this.element.querySelector('ul.filter-list');
      this.fieldQuickSearchInput = ((_this$filterListEleme2 = this.filterListElement) === null || _this$filterListEleme2 === void 0 ? void 0 : _this$filterListEleme2.querySelector('input.field-filter-quick-search-input')) ?? null;
      this.addFilterButtonElement = this.element.querySelector('button.add-filter-button');
      this.textFilterInputElement = this.element.querySelector('input.text-filter');
      this.updateAddFilterButton();
      this.advancedFiltersPanelElement = this.element.querySelector('.advanced-filters');
      this.manageLabels();
      this.controlResetButtonVisibility();
      this.initQuickSearchUi();
      this.initTextSearchAutocomplete();
    }
    initTextSearchAutocomplete() {
      if (this.textSearchStoringDisabled || !this.textFilterInputElement) {
        return;
      }
      const autocomplete = new _autocomplete.default(this.textFilterInputElement, {
        triggerSelectOnValidInput: false,
        focusOnSelect: true,
        onSelect: () => {
          setTimeout(() => autocomplete.hide(), 1);
        },
        lookupFunction: query => {
          return Promise.resolve(this.storedTextSearchHelper.match(query, this.autocompleteLimit).map(item => ({
            value: item
          })));
        },
        formatResult: item => {
          // @todo Refactor.
          return $('<span>').append($('<a>').attr('data-action', 'clearStoredTextSearch').attr('role', 'button').attr('data-value', item.value).attr('title', this.translate('Remove')).html('<span class="fas fa-times fa-sm"></span>').addClass('pull-right text-soft'), $('<span>').text(item.value)).get(0).innerHTML;
        },
        beforeRender: container => {
          // @todo Refactor.
          const $container = $(container);
          $container.addClass('text-search-suggestions');
          $container.find('a[data-action="clearStoredTextSearch"]').on('click', e => {
            var _this$storedTextSearc;
            e.stopPropagation();
            e.preventDefault();
            const text = e.currentTarget.getAttribute('data-value');
            (_this$storedTextSearc = this.storedTextSearchHelper) === null || _this$storedTextSearc === void 0 || _this$storedTextSearc.remove(text);
            autocomplete.hide();
            // 200 is hardcoded in autocomplete lib.

            setTimeout(() => {
              var _this$textFilterInput;
              return (_this$textFilterInput = this.textFilterInputElement) === null || _this$textFilterInput === void 0 ? void 0 : _this$textFilterInput.focus();
            }, 201);
          });
        }
      });
      this.once('render remove', () => autocomplete.dispose());
    }
    initQuickSearchUi() {
      if (!this.addFilterButtonElement) {
        return;
      }
      const parent = this.addFilterButtonElement.parentElement;

      // @ts-ignore
      $(parent).on('show.bs.dropdown', () => {
        setTimeout(() => {
          var _this$fieldQuickSearc;
          if (!this.fieldQuickSearchInput) {
            return;
          }
          this.fieldQuickSearchInput.focus();
          const width = (_this$fieldQuickSearc = this.fieldQuickSearchInput) === null || _this$fieldQuickSearc === void 0 ? void 0 : _this$fieldQuickSearc.offsetWidth;
          this.fieldQuickSearchInput.style.minWidth = width.toString() + 'px';
        }, 1);
      });

      // @ts-ignore
      $(parent).on('hide.bs.dropdown', () => {
        this.resetFieldFilterQuickSearch();
        this.fieldQuickSearchInput.style.minWidth = '';
      });
    }
    manageLabels() {
      this.element.querySelectorAll('ul.dropdown-menu > li.preset-control').forEach(li => li.classList.add('hidden'));
      this.currentFilterLabelList = [];
      this.managePresetFilters();
      this.manageBoolFilters();
      if (!this.filtersLabel) {
        return;
      }
      this.filtersLabel.innerHTML = this.currentFilterLabelList.map(it => this.getHelper().escapeString(it)).join(' &middot; ');
    }
    toShowResetButton() {
      if (this.textFilter) {
        return true;
      }
      const presetName = this.presetName || null;
      const primary = this.primary;
      if (!presetName || presetName === primary) {
        if (Object.keys(this.advanced).length) {
          return true;
        }
      }
      if (this.collection.orderBy !== this.collection.defaultOrderBy || this.collection.order !== this.collection.defaultOrder) {
        return true;
      }
      return false;
    }
    controlResetButtonVisibility() {
      if (!this.resetButtonElement) {
        return;
      }
      if (this.toShowResetButton()) {
        this.resetButtonElement.style.visibility = 'visible';
        return;
      }
      this.resetButtonElement.style.visibility = 'hidden';
    }
    managePresetFilters() {
      let presetName = this.presetName || null;
      const primary = this.primary;
      this.$el.find('ul.filter-menu a.preset span').remove();
      let filterLabel = this.translate('all', 'presetFilters', this.entityType);
      let filterStyle = 'default';
      if (!presetName && primary) {
        presetName = primary;
      }
      if (presetName && presetName !== primary) {
        this.advancedFiltersPanelElement.classList.add('hidden');
        let label = null;
        let style = 'default';
        let id = null;
        this.presetFilterList.forEach(item => {
          if (typeof item !== 'string' && item.name === presetName) {
            label = item.label || false;
            style = item.style || 'default';
            id = item.id;
          }
        });
        label = label || this.translate(this.presetName, 'presetFilters', this.entityType);
        filterLabel = label;
        filterStyle = style;
        if (id) {
          this.$el.find('ul.dropdown-menu > li.divider.preset-control').removeClass('hidden');
          this.$el.find('ul.dropdown-menu > li.preset-control.remove-preset').removeClass('hidden');
        }
      } else {
        this.advancedFiltersPanelElement.classList.remove('hidden');
        if (Object.keys(this.advanced).length !== 0) {
          if (!this.disableSavePreset) {
            this.$el.find('ul.dropdown-menu > li.divider.preset-control').removeClass('hidden');
            this.$el.find('ul.dropdown-menu > li.preset-control.save-preset').removeClass('hidden');
            this.$el.find('ul.dropdown-menu > li.preset-control.remove-preset').addClass('hidden');
          }
        }
        if (primary) {
          const label = this.translate(primary, 'presetFilters', this.entityType);
          const style = this.getPrimaryFilterStyle();
          filterLabel = label;
          filterStyle = style;
        }
      }
      this.currentFilterLabelList.push(filterLabel);
      this.filtersButton.classList.remove('btn-default', 'btn-primary', 'btn-danger', 'btn-success', 'btn-info', 'btn-info');
      this.filtersButton.classList.add(`btn-${filterStyle}`);
      presetName = presetName || '';
      this.$el.find('ul.filter-menu a.preset[data-name="' + presetName + '"]').prepend('<span class="fas fa-check check-icon pull-right"></span>');
    }
    manageBoolFilters() {
      (this.boolFilterList ?? []).forEach(item => {
        if (this.bool && this.bool[item]) {
          const label = this.translate(item, 'boolFilters', this.entityType);
          this.currentFilterLabelList.push(label);
        }
      });
    }
    search() {
      this.fetch();
      this.updateSearch();
      this.updateCollection();
      this.controlResetButtonVisibility();
      this.storeTextSearch();
      this.isSearchedWithAdvancedFilter = this.hasAdvancedFilter();
    }
    hasAdvancedFilter() {
      return Object.keys(this.advanced).length > 0;
    }
    getFilterDataList() {
      const list = [];
      for (const field in this.advanced) {
        list.push({
          key: `filter-${field}`,
          name: field
        });
      }
      return list;
    }
    async updateCollection() {
      this.collection.abortLastFetch();
      this.collection.reset();
      this.collection.where = this.searchManager.getWhere();
      this.collection.offset = 0;
      _ui.default.notifyWait();
      await this.collection.fetch();
      _ui.default.notify(false);
    }
    getPresetFilterList() {
      const output = [];
      this.presetFilterList.forEach(item => {
        if (typeof item == 'string') {
          item = {
            name: item
          };
        }
        output.push(item);
      });
      return output;
    }
    getPresetData() {
      let data = {};
      this.getPresetFilterList().forEach(item => {
        if (item.name === this.presetName) {
          data = _utils.default.clone(item.data || {});
        }
      });
      return data;
    }
    getPrimaryFilterName() {
      let primaryFilterName = null;
      this.getPresetFilterList().forEach(item => {
        if (item.name !== this.presetName) {
          return;
        }
        if (!('data' in item)) {
          primaryFilterName = item.name;
        } else if (item.primary) {
          primaryFilterName = item.primary;
        }
      });
      return primaryFilterName;
    }
    getPrimaryFilterStyle() {
      let style = null;
      this.getPresetFilterList().forEach(item => {
        if (item.name === this.primary) {
          style = item.style || 'default';
        }
      });
      return style;
    }
    loadSearchData() {
      const searchData = this.searchManager.get();
      this.textFilter = searchData.textFilter ?? '';
      if ('presetName' in searchData) {
        this.presetName = searchData.presetName ?? null;
      }
      let primaryIsSet = false;
      if ('primary' in searchData) {
        this.primary = searchData.primary ?? null;
        if (!this.presetName) {
          this.presetName = this.primary;
        }
        primaryIsSet = true;
      }
      if (this.presetName) {
        this.advanced = _underscore.default.extend(_utils.default.clone(this.getPresetData()), searchData.advanced);
        if (!primaryIsSet) {
          this.primary = this.getPrimaryFilterName();
        }
      } else {
        this.advanced = _utils.default.clone(searchData.advanced ?? {});
      }
      this.bool = searchData.bool ?? null;
    }
    async createFilter(name, params, callback, noRender) {
      params = params || {};
      let rendered = false;
      if (this.isRendered()) {
        rendered = true;
        this.advancedFiltersPanelElement.append((() => {
          const div = document.createElement('div');
          div.dataset.name = name;
          div.className = `filter filter-${name}`;
          return div;
        })());
      }
      const view = new _filter.default({
        name: name,
        model: this.model,
        params: params
      });
      await this.assignView(`filter-${name}`, view, `.filter[data-name="${name}"]`);
      if (typeof callback === 'function') {
        view.once('after:render', () => callback(view));
      }
      if (rendered && !noRender) {
        view.render().then(() => {});
      }
      this.listenTo(view, 'change', () => {
        let toShowApply = this.isSearchedWithAdvancedFilter;
        if (!toShowApply) {
          var _view$getFieldView2;
          const data = (_view$getFieldView2 = view.getFieldView()) === null || _view$getFieldView2 === void 0 ? void 0 : _view$getFieldView2.fetchSearch();
          if (data) {
            toShowApply = true;
          }
        }
        if (!toShowApply) {
          return;
        }
        this.showApplyFiltersButton();
      });
      this.listenTo(view, 'search', () => {
        this.search();
        this.hideApplyFiltersButton();
      });
    }
    fetch() {
      var _this$textFilterInput2;
      let value = ((_this$textFilterInput2 = this.textFilterInputElement) === null || _this$textFilterInput2 === void 0 ? void 0 : _this$textFilterInput2.value) ?? '';
      value = value.trim();
      this.textFilter = value;
      this.bool = {};
      this.boolFilterList.forEach(name => {
        var _this$element$querySe4;
        this.bool[name] = ((_this$element$querySe4 = this.element.querySelector(`input[data-name="${name}"][data-role="boolFilterCheckbox"]`)) === null || _this$element$querySe4 === void 0 ? void 0 : _this$element$querySe4.checked) == true;
      });
      for (const field in this.advanced) {
        var _this$getView2;
        const view = (_this$getView2 = this.getView(`filter-${field}`)) === null || _this$getView2 === void 0 ? void 0 : _this$getView2.getView('field');
        if (!view) {
          continue;
        }
        this.advanced[field] = view.fetchSearch();
        view.setSearchParams(_utils.default.clone(this.advanced[field] ?? {}));
      }
    }
    updateSearch() {
      this.searchManager.set({
        textFilter: this.textFilter,
        advanced: this.advanced,
        bool: this.bool ?? {},
        presetName: this.presetName ?? null,
        primary: this.primary
      });
    }
    getFilterFieldDataList() {
      const defs = [];
      for (const field of this.fieldFilterList) {
        const o = {
          name: field,
          checked: field in this.advanced,
          label: this.fieldFilterTranslations[field] || field
        };
        defs.push(o);
      }
      return defs;
    }
    showResetFiltersButton() {
      var _this$applyFiltersCon, _this$applyFiltersCon2;
      this.toShowApplyFiltersButton = true;
      this.toShowResetFiltersText = true;
      this.applyFiltersContainer.classList.remove('hidden');
      (_this$applyFiltersCon = this.applyFiltersContainer.querySelector('.text-apply')) === null || _this$applyFiltersCon === void 0 || _this$applyFiltersCon.classList.add('hidden');
      (_this$applyFiltersCon2 = this.applyFiltersContainer.querySelector('.text-reset')) === null || _this$applyFiltersCon2 === void 0 || _this$applyFiltersCon2.classList.remove('hidden');
    }
    showApplyFiltersButton() {
      var _this$applyFiltersCon3, _this$applyFiltersCon4;
      this.toShowApplyFiltersButton = true;
      this.toShowResetFiltersText = false;
      this.applyFiltersContainer.classList.remove('hidden');
      (_this$applyFiltersCon3 = this.applyFiltersContainer.querySelector('.text-reset')) === null || _this$applyFiltersCon3 === void 0 || _this$applyFiltersCon3.classList.add('hidden');
      (_this$applyFiltersCon4 = this.applyFiltersContainer.querySelector('.text-apply')) === null || _this$applyFiltersCon4 === void 0 || _this$applyFiltersCon4.classList.remove('hidden');
    }
    hideApplyFiltersButton() {
      this.toShowApplyFiltersButton = false;
      this.toShowResetFiltersText = false;
      this.applyFiltersContainer.classList.add('hidden');
    }
    selectPreviousPreset() {
      const list = _utils.default.clone(this.getPresetFilterList());
      list.unshift({
        name: null
      });
      if (list.length === 1) {
        return;
      }
      const index = list.findIndex(item => item.name === this.presetName) - 1;
      if (index < 0) {
        return;
      }
      const preset = list[index];
      this.selectPreset(preset.name);
    }
    selectNextPreset() {
      const list = _utils.default.clone(this.getPresetFilterList());
      list.unshift({
        name: null
      });
      if (list.length === 1) {
        return;
      }
      const index = list.findIndex(item => item.name === this.presetName) + 1;
      if (index >= list.length) {
        return;
      }
      const preset = list[index];
      this.selectPreset(preset.name);
    }
    processFieldFilterQuickSearch(text) {
      text = text.trim();
      text = text.toLowerCase();
      const lis = this.filterListElement.querySelectorAll('li.filter-item');
      if (text === '') {
        lis.forEach(element => element.classList.remove('search-hidden'));
        return;
      }
      lis.forEach(element => element.classList.add('search-hidden'));
      this.fieldFilterList.forEach(field => {
        let label = this.fieldFilterTranslations[field] || field;
        label = label.toLowerCase();
        const wordList = label.split(' ');
        let matched = label.indexOf(text) === 0;
        if (!matched) {
          matched = wordList.filter(word => word.length > 3 && word.indexOf(text) === 0).length > 0;
        }
        if (matched) {
          Array.from(lis).filter(li => li.dataset.name === field).forEach(li => li.classList.remove('search-hidden'));
        }
      });
    }
    resetFieldFilterQuickSearch() {
      var _this$filterListEleme3;
      if (!this.fieldQuickSearchInput) {
        return;
      }
      this.fieldQuickSearchInput.value = '';
      (_this$filterListEleme3 = this.filterListElement) === null || _this$filterListEleme3 === void 0 || _this$filterListEleme3.querySelectorAll('li.filter-item').forEach(li => li.classList.remove('search-hidden'));
    }
    addFirstFieldFilter() {
      var _this$filterListEleme4;
      const first = ((_this$filterListEleme4 = this.filterListElement) === null || _this$filterListEleme4 === void 0 ? void 0 : _this$filterListEleme4.querySelectorAll('li.filter-item:not(.hidden):not(.search-hidden)')[0]) ?? null;
      if (!first) {
        return;
      }
      const name = first.dataset.name;
      first.classList.add('hidden');
      this.closeAddFieldDropdown();
      this.addFilter(name);
      this.resetFieldFilterQuickSearch();
    }
    closeAddFieldDropdown() {
      var _this$addFilterButton3;
      if (!this.addFilterButtonElement) {
        return;
      }
      const dropdown = (_this$addFilterButton3 = this.addFilterButtonElement.parentElement) === null || _this$addFilterButton3 === void 0 ? void 0 : _this$addFilterButton3.querySelector('[data-toggle="dropdown"]');
      if (!dropdown) {
        return;
      }

      // @ts-ignore
      $(dropdown).dropdown('toggle');
    }
    storeTextSearch() {
      if (!this.textFilter) {
        return;
      }
      if (this.textSearchStoringDisabled) {
        return;
      }
      this.storedTextSearchHelper.store(this.textFilter);
    }
    async savePresetHandler() {
      const view = new _saveFilters.default();
      await this.assignView('savePreset', view);
      this.listenToOnce(view, 'save', name => {
        this.savePreset(name);
        view.close();
        this.removeFilters();
        this.createFilters(() => this.render());
      });
      await view.render();
    }
  }
  var _default = _exports.default = SearchView;
});

define("views/record/list", ["exports", "views/record/list-base"], function (_exports, _listBase) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _listBase = _interopRequireDefault(_listBase);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * Mass-action definitions.
   */

  /**
   * A row action.
   */

  /**
   * A dropdown item. Handled by a class method `action{Name}` or a handler.
   */

  /**
   * A button. Handled by a class method `action{Name}` or a handler.
   */

  /**
   * Column definitions.
   */

  /**
   * A record-list view. Renders and processes list items, actions.
   */
  class ListRecordView extends _listBase.default {
    setup() {
      super.setup();
    }

    /**
     * @internal
     */
    _convertLayout(listLayout, model) {
      model = model || this.collection.prepareModel();
      const layout = [];
      if (this.checkboxes) {
        layout.push({
          name: 'r-checkboxField',
          columnName: 'r-checkbox',
          template: 'record/list-checkbox'
        });
      }
      for (const col of listLayout) {
        const type = col.type || model.getFieldType(col.name) || 'base';
        if (!col.name) {
          continue;
        }
        const item = {
          columnName: col.name,
          name: col.name + 'Field',
          view: col.view || model.getFieldParam(col.name, 'view') || this.getFieldManager().getViewName(type),
          options: {
            defs: {
              name: col.name,
              params: col.params || {}
            },
            mode: 'list'
          }
        };
        if (col.width) {
          item.options.defs.width = col.width;
        }
        if (col.widthPx) {
          item.options.defs.widthPx = col.widthPx;
        }
        if (col.link) {
          item.options.mode = 'listLink';
        }
        if (col.align) {
          item.options.defs.align = col.align;
        }
        if (col.options) {
          for (const optionName in col.options) {
            if (typeof item.options[optionName] !== 'undefined') {
              continue;
            }
            item.options[optionName] = col.options[optionName];
          }
        }
        if (col.name && this._listSettingsHelper) {
          if (this._listSettingsHelper.isColumnHidden(col.name, col.hidden)) {
            continue;
          }
        }
        if (!this._listSettingsHelper && col.hidden) {
          continue;
        }
        layout.push(item);
      }
      if (this.rowActionsView && !this.rowActionsDisabled) {
        layout.push(this.getRowActionsDefs());
      }
      return layout;
    }
  }
  var _default = _exports.default = ListRecordView;
});

define("views/record/detail-side", ["exports", "views/record/panels-container"], function (_exports, _panelsContainer) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _panelsContainer = _interopRequireDefault(_panelsContainer);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/record/detail-side */

  /**
   * A detail-side record view.
   */
  class DetailSideRecordView extends _panelsContainer.default {
    /** @inheritDoc */
    template = 'record/side';

    /** @inheritDoc */
    mode = 'detail';
    readOnly = false;
    inlineEditDisabled = false;
    name = 'side';
    defaultPanel = true;

    /**
     * A panel list.
     *
     * @protected
     * @type {module:views/record/panels-container~panel[]}
     */
    panelList = [];

    /**
     * A default panel.
     *
     * @type {module:views/record/panels-container~panel}
     */
    defaultPanelDefs = {
      name: 'default',
      label: false,
      view: 'views/record/panels/default-side',
      isForm: true,
      options: {
        fieldList: [{
          name: ':assignedUser'
        }, {
          name: 'teams'
        }]
      }
    };
    init() {
      this.panelList = this.options.panelList || this.panelList;
      this.scope = this.entityType = this.options.model.entityType;
      this.recordHelper = this.options.recordHelper;
      this.panelList = Espo.Utils.clone(this.panelList);
      this.readOnlyLocked = this.options.readOnlyLocked || this.readOnly;
      this.readOnly = this.options.readOnly || this.readOnly;
      this.inlineEditDisabled = this.options.inlineEditDisabled || this.inlineEditDisabled;
      this.recordViewObject = this.options.recordViewObject;
    }

    /** @inheritDoc */
    setupPanels() {}
    setup() {
      this.type = this.mode;
      if ('type' in this.options) {
        this.type = this.options.type;
      }
      this.setupInitial();
      this.setupPanels();
      if (!this.additionalPanelsDisabled) {
        const additionalPanels = this.getMetadata().get(['clientDefs', this.scope, 'sidePanels', this.type]) || [];
        additionalPanels.forEach(panel => {
          this.panelList.push(panel);
        });
      }
      this.panelList = this.panelList.map(item => {
        if ('reference' in item && item.reference) {
          // noinspection UnnecessaryLocalVariableJS
          /** @type {module:views/record/panels-container~panel} */
          const newItem = {
            ...this.getMetadata().get(`app.clientRecord.panels.${item.reference}`),
            ...item
          };
          return newItem;
        }
        return item;
      });
      this.panelList = this.panelList.filter(p => {
        if (p.aclScope) {
          if (!this.getAcl().checkScope(p.aclScope)) {
            return;
          }
        }
        if (p.accessDataList) {
          if (!Espo.Utils.checkAccessDataList(p.accessDataList, this.getAcl(), this.getUser())) {
            return false;
          }
        }
        return true;
      });
      this.panelList = this.panelList.map(p => {
        const item = Espo.Utils.clone(p);
        if (this.recordHelper.getPanelStateParam(p.name, 'hidden') !== null) {
          item.hidden = this.recordHelper.getPanelStateParam(p.name, 'hidden');
        } else {
          this.recordHelper.setPanelStateParam(p.name, 'hidden', item.hidden || false);
        }
        return item;
      });
      this.panelList.forEach(item => {
        item.actionsViewKey = item.name + 'Actions';
      });
      this.wait(Promise.all([new Promise(resolve => {
        this.getHelper().layoutManager.get(this.scope, 'sidePanels' + Espo.Utils.upperCaseFirst(this.type), layoutData => {
          this.layoutData = layoutData;
          resolve();
        });
      }), new Promise(resolve => {
        if (!this.defaultPanel || this.getMetadata().get(['clientDefs', this.scope, 'defaultSidePanelDisabled']) || this.getMetadata().get(['clientDefs', this.scope, 'defaultSidePanel', this.type]) || this.getMetadata().get(['clientDefs', this.scope, 'defaultSidePanelFieldLists', this.type]) || this.getMetadata().get(['clientDefs', this.scope, 'defaultSidePanelFieldList'])) {
          resolve();
          return;
        }
        this.getHelper().layoutManager.get(this.scope, 'defaultSidePanel', layoutData => {
          this.defaultSidePanelLayoutData = layoutData;
          resolve();
        });
      })]).then(() => {
        if (this.defaultPanel) {
          this.setupDefaultPanel();
        }
        this.alterPanels();
        this.setupPanelsFinal();
        this.setupPanelViews();
      }));
    }

    /**
     * Set up a default panel.
     *
     * @protected
     */
    setupDefaultPanel() {
      let met = false;
      this.panelList.forEach(item => {
        if (item.name === 'default') {
          met = true;
        }
      });
      if (met) {
        return;
      }
      let defaultPanelDefs = this.getMetadata().get(['clientDefs', this.scope, 'defaultSidePanel', this.type]);
      if (defaultPanelDefs === false) {
        return;
      }
      if (this.getMetadata().get(['clientDefs', this.scope, 'defaultSidePanelDisabled'])) {
        return;
      }
      defaultPanelDefs = defaultPanelDefs || this.defaultPanelDefs;
      if (!defaultPanelDefs) {
        return;
      }
      defaultPanelDefs = Espo.Utils.cloneDeep(defaultPanelDefs);
      defaultPanelDefs.view = this.getMetadata().get(['clientDefs', this.scope, 'defaultSidePanelView']) || defaultPanelDefs.view;
      let fieldList = this.getMetadata().get(['clientDefs', this.scope, 'defaultSidePanelFieldLists', this.type]);
      if (!fieldList) {
        fieldList = this.getMetadata().get(['clientDefs', this.scope, 'defaultSidePanelFieldList']);
      }
      if (!fieldList && this.defaultSidePanelLayoutData) {
        fieldList = this.defaultSidePanelLayoutData;
      }
      if (fieldList) {
        defaultPanelDefs.options = defaultPanelDefs.options || {};
        defaultPanelDefs.options.fieldList = fieldList;
      }
      fieldList = defaultPanelDefs.options.fieldList;
      if (fieldList && fieldList.length) {
        fieldList.forEach((item, i) => {
          if (typeof item !== 'object') {
            item = {
              name: item
            };
            fieldList[i] = item;
          }
          if (item.name === ':assignedUser') {
            if (this.model.hasField('assignedUsers')) {
              item.name = 'assignedUsers';
              if (!this.model.getFieldParam('assignedUsers', 'view')) {
                item.view = 'views/fields/assigned-users';
              }
            } else if (this.model.hasField('assignedUser')) {
              item.name = 'assignedUser';
            } else {
              defaultPanelDefs.options.fieldList[i] = {};
            }
          }
        });
        const fieldDefs = this.getMetadata().get(['entityDefs', this.entityType, 'fields']) || {};
        defaultPanelDefs.options.fieldList = fieldList.filter(item => {
          const defs = fieldDefs[item.name] || {};
          return !defs.disabled;
        });
      }
      this.panelList.unshift(defaultPanelDefs);
    }
  }
  var _default = _exports.default = DetailSideRecordView;
});

define("views/record/row-actions/default", ["exports", "view"], function (_exports, _view) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * @module views/record/row-actions/actions
   */

  /**
   * @typedef {{
   *     label?: string,
   *     labelTranslation?: string,
   *     acl?: string,
   *     groupIndex?: number,
   *     name?: string,
   *     text?: string,
   *     html?: string,
   *     viewKey?: string,
   *     iconClass?: string,
   * }} module:views/record/row-actions/actions~item
   */

  /**
   * Row actions.
   */
  class DefaultRowActionsView extends _view.default {
    template = 'record/row-actions/default';

    /**
     * @private
     * @type {boolean}
     */
    menuIsShown = false;

    /**
     * @private
     * @type {module:views/record/row-actions/actions~item[]}
     */
    lastActionList;

    /**
     * @private
     * @type {Object.<string, {isAvailable: function(module:model, string)}>}
     */
    handlers;
    static ICON_CLASS_VIEW = 'fas fa-expand';
    static ICON_CLASS_EDIT = 'fas fa-pen-to-square';
    static ICON_CLASS_REMOVE = 'fas fa-times';

    /**
     * @param {{
     *    acl?: {
     *        edit?: boolean,
     *        detete?: boolean,
     *    },
     *    model: import('model').default,
     *    rowActionHandlers?: Object.<string, {isAvailable: function(module:model, string)}>,
     *    additionalActionList?: string[],
     *    scope?: string,
     * } & Record} options
     */
    constructor(options) {
      super(options);
      this.options = options;
    }
    setup() {
      this.options.acl = this.options.acl || {};
      this.scope = this.options.scope || this.model.entityType;

      // noinspection JSValidateTypes
      this.handlers = this.options.rowActionHandlers || {};

      /** @type {module:views/record/row-actions/actions~item[]} */
      this.additionalActionDataList = [];
      this.setupAdditionalActions();
      const handleReRender = (/** Record */o) => {
        if (o.keepRowActions) {
          return;
        }
        if (this.menuIsShown) {
          this.once('menu-hidden', () => this.reRender({
            buffer: true
          }));
          return;
        }
        this.reRender({
          buffer: true
        });
      };
      this.listenTo(this.model, 'change', (m, /** Record */o) => handleReRender(o));
      if (this.model.collection && this.model.collection.parentModel) {
        // Access to actions can be defined by a parent model.
        this.listenTo(this.model.collection.parentModel, 'sync', (m, r, /** Record */o) => {
          if (!this.lastActionList) {
            return;
          }
          setTimeout(() => {
            if (Espo.Utils.areEqual(this.lastActionList, this.getActionList())) {
              return true;
            }
            handleReRender(o);
          }, 0);
        });
      }
    }
    afterRender() {
      this.menuIsShown = false;
      const $dd = this.$el.find('button[data-toggle="dropdown"]').parent();
      let isChecked = false;
      $dd.on('show.bs.dropdown', () => {
        const $el = this.$el.closest('.list-row');
        isChecked = false;
        if ($el.hasClass('active')) {
          isChecked = true;
        }
        $el.addClass('active');
        this.menuIsShown = true;
      });
      $dd.on('hide.bs.dropdown', () => {
        if (!isChecked) {
          this.$el.closest('.list-row').removeClass('active');
        }
        this.menuIsShown = false;
        this.trigger('menu-hidden');
      });
    }

    /**
     * Get an action list.
     *
     * @return {import('views/record/list').RowAction[]}
     */
    getActionList() {
      /** @type {import('views/record/list').RowAction[]} */
      const list = [{
        action: 'quickView',
        label: 'View',
        data: {
          id: this.model.id
        },
        link: `#${this.model.entityType}/view/${this.model.id}`,
        groupIndex: 0,
        iconClass: DefaultRowActionsView.ICON_CLASS_VIEW
      }];
      if (this.checkAccess('edit')) {
        list.push({
          action: 'quickEdit',
          label: 'Edit',
          data: {
            id: this.model.id
          },
          link: `#${this.model.entityType}/edit/${this.model.id}`,
          groupIndex: 0,
          iconClass: DefaultRowActionsView.ICON_CLASS_EDIT
        });
      }
      this.getAdditionalActionList().forEach(item => list.push(item));
      if (this.checkAccess('delete')) {
        list.push({
          action: 'quickRemove',
          label: 'Remove',
          data: {
            id: this.model.id
          },
          groupIndex: 0,
          iconClass: DefaultRowActionsView.ICON_CLASS_REMOVE
        });
      }
      return list;
    }

    /**
     * Not to be overridden.
     *
     * @protected
     * @return {import('views/record/list').RowAction[]}
     */
    getAdditionalActionList() {
      const list = [];
      this.additionalActionDataList.forEach(item => {
        const handler = this.handlers[item.name];
        if (handler && !handler.isAvailable(this.model, item.name)) {
          return;
        }
        if (item.acl && item.acl !== 'read') {
          if (!this.getAcl().checkModel(this.model, item.acl)) {
            return;
          }
        }
        list.push({
          action: 'rowAction',
          text: item.text,
          data: {
            id: this.model.id,
            actualAction: item.name
          },
          groupIndex: item.groupIndex,
          iconClass: item.iconClass
        });
      });
      return list;
    }
    data() {
      /** @type {Array<module:views/record/row-actions/actions~item[]>} */
      const dropdownGroups = [];
      const actionList = this.getActionList();
      this.lastActionList = actionList;
      actionList.forEach(item => {
        // For bc.
        if (item === false) {
          return;
        }
        const index = (item.groupIndex === undefined ? 9999 : item.groupIndex) + 100;
        if (dropdownGroups[index] === undefined) {
          dropdownGroups[index] = [];
        }
        dropdownGroups[index].push(item);
      });
      const dropdownItemList = [];
      dropdownGroups.forEach(list => {
        list.forEach(it => dropdownItemList.push(it));
        dropdownItemList.push(false);
      });
      return {
        acl: this.options.acl,
        actionList: dropdownItemList,
        scope: this.model.entityType
      };
    }
    setupAdditionalActions() {
      const list = this.options.additionalActionList;
      if (!list) {
        return;
      }
      const defs = this.getMetadata().get(`clientDefs.${this.scope}.rowActionDefs`) || {};
      list.forEach(action => {
        /**
         * @type {{
         *     label?: string,
         *     labelTranslation?: string,
         *     acl?: string,
         *     groupIndex?: number,
         *     iconClass?: string,
         * }}
         */
        const itemDefs = defs[action] || {};
        const text = itemDefs.labelTranslation ? this.getLanguage().translatePath(itemDefs.labelTranslation) : this.getLanguage().translate(itemDefs.label, 'labels', this.model.entityType);
        this.additionalActionDataList.push({
          name: action,
          acl: itemDefs.acl,
          text: text,
          groupIndex: itemDefs.groupIndex,
          iconClass: itemDefs.iconClass
        });
      });
    }

    /**
     * @protected
     * @param {string} action
     * @retyrn {boolean}
     * @since 9.0.0
     */
    checkAccess(action) {
      if (typeof this.options.acl[action] === 'boolean') {
        return this.options.acl[action];
      }
      return this.getAcl().checkModel(this.model, action);
    }
  }
  var _default = _exports.default = DefaultRowActionsView;
});

define("views/record/panels/side", ["exports", "view"], function (_exports, _view) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/record/panels/side */

  /**
   * @typedef {Object} module:views/record/panels/side~defs
   * @property [buttonList]
   * @property [actionList]
   * @property [fieldList]
   * @property [tabNumber] For internal purposes.
   * @property [isForm] Is form.
   */

  /**
   * A side panel.
   */
  class SidePanelView extends _view.default {
    template = 'record/panels/side';

    /**
     * A field defs.
     *
     * @typedef module:views/record/panels/side~field
     *
     * @property {string} name
     * @property {string} [labelText] A translated label text.
     * @property {string} [labelTranslation] A label translation. As of v10.0.
     * @property {string} [view] A view name.
     * @property {boolean} [isAdditional]
     * @property {boolean} [readOnly]
     * @property {Object.<string,*>} [options] Options.
     * @property {string} [viewKey] Not to be set. For internal purposes.
     */

    /**
     * A field list.
     *
     * @protected
     * @type {module:views/record/panels/side~field[]}
     */
    fieldList = null;

    /**
     * A mode.
     *
     * @protected
     * @type {'list'|'detail'|'edit'}
     */
    mode = 'detail';

    /**
     * @protected
     * @type {module:views/record/panels-container~action[]}
     */
    actionList;

    /**
     * @protected
     * @type {Array<module:views/record/panels-container~action|false>}
     */
    buttonList;

    /**
     * Read-only.
     *
     * @protected
     */
    readOnly = false;

    /**
     * Disable inline edit.
     *
     * @protected
     */
    inlineEditDisabled = false;

    /**
     * Disabled.
     *
     * @internal
     */
    disabled = false;

    /**
     * @protected
     * @type {module:views/record/panels/side~defs}
     */
    defs;

    /**
     * @protected
     * @type {import('views/record/base').default}
     */
    recordViewObject;
    events = {
      /** @this SidePanelView */
      'click .action': function (e) {
        Espo.Utils.handleAction(this, e.originalEvent, e.currentTarget, {
          actionItems: [...this.buttonList, ...this.actionList],
          className: 'panel-action'
        });
      }
    };
    data() {
      return {
        fieldList: this.getFieldList(),
        hiddenFields: this.recordHelper.getHiddenFields()
      };
    }
    init() {
      this.panelName = this.options.panelName;
      this.defs = this.options.defs || {};
      this.recordHelper = this.options.recordHelper;
      if ('disabled' in this.options) {
        this.disabled = this.options.disabled;
      }
      this.buttonList = Espo.Utils.clone(this.defs.buttonList || this.buttonList || []);
      this.actionList = Espo.Utils.clone(this.defs.actionList || this.actionList || []);
      this.fieldList = this.options.fieldList || this.fieldList || this.defs.fieldList || [];
      this.mode = this.options.mode || this.mode;
      this.readOnlyLocked = this.options.readOnlyLocked || this.readOnly;
      this.readOnly = this.readOnly || this.options.readOnly;
      this.inlineEditDisabled = this.inlineEditDisabled || this.options.inlineEditDisabled;
      this.recordViewObject = /** @type {import('views/record/base').default} */
      this.options.recordViewObject;
    }
    setup() {
      this.setupFields();
      this.fieldList = this.fieldList.map(d => {
        let item = d;
        if (typeof item !== 'object') {
          item = {
            name: item,
            viewKey: item + 'Field'
          };
        }
        item = Espo.Utils.clone(item);
        item.viewKey = item.name + 'Field';
        item.label = item.label || item.name;
        if (item.labelTranslation) {
          item.labelText = this.getLanguage().translatePath(item.labelTranslation);
        }
        if (this.recordHelper.getFieldStateParam(item.name, 'hidden') !== null) {
          item.hidden = this.recordHelper.getFieldStateParam(item.name, 'hidden');
        } else {
          this.recordHelper.setFieldStateParam(item.name, 'hidden', item.hidden || false);
        }
        return item;
      });
      this.fieldList = this.fieldList.filter(item => {
        if (!item.name) {
          return;
        }
        if (!item.isAdditional) {
          if (!(item.name in ((this.model.defs || {}).fields || {}))) return;
        }
        return true;
      });
      this.createFields();
    }
    afterRender() {
      if (this.$el.children().length === 0 && this.defs.isForm) {
        this.$el.parent().addClass('hidden');
      }
    }

    /**
     * Set up fields.
     *
     * @protected
     */
    setupFields() {}

    /**
     * Create a field view.
     *
     * @protected
     * @param {string} field A field name.
     * @param {string|null} [viewName] A view name/path.
     * @param {Object<string,*>} [params] Field params.
     * @param {'detail'|'edit'|'list'|null} [mode='edit'] A mode.
     * @param {boolean} [readOnly] Read-only.
     * @param {Object<string,*>} [options] View options.
     */
    createField(field, viewName, params, mode, readOnly, options) {
      const type = this.model.getFieldType(field) || 'base';
      viewName = viewName || this.model.getFieldParam(field, 'view') || this.getFieldManager().getViewName(type);
      const o = {
        model: this.model,
        selector: '.field[data-name="' + field + '"]',
        defs: {
          name: field,
          params: params || {}
        },
        mode: mode || this.mode,
        dataObject: this.options.dataObject
      };
      if (options) {
        for (const param in options) {
          o[param] = options[param];
        }
      }
      let readOnlyLocked = this.readOnlyLocked;
      if (this.readOnly) {
        o.readOnly = true;
      } else {
        if (readOnly !== null) {
          o.readOnly = readOnly;
        }
      }
      if (readOnly) {
        readOnlyLocked = true;
      }
      if (this.inlineEditDisabled) {
        o.inlineEditDisabled = true;
      }
      if (this.recordHelper.getFieldStateParam(field, 'hidden')) {
        o.disabled = true;
      }
      if (this.recordHelper.getFieldStateParam(field, 'hiddenLocked')) {
        o.disabledLocked = true;
      }
      if (this.recordHelper.getFieldStateParam(field, 'readOnly')) {
        o.readOnly = true;
      }
      if (this.recordHelper.getFieldStateParam(field, 'required') !== null) {
        o.defs.params.required = this.recordHelper.getFieldStateParam(field, 'required');
      }
      if (!readOnlyLocked && this.recordHelper.getFieldStateParam(field, 'readOnlyLocked')) {
        readOnlyLocked = true;
      }
      if (readOnlyLocked) {
        o.readOnlyLocked = readOnlyLocked;
      }
      if (this.recordHelper.hasFieldOptionList(field)) {
        o.customOptionList = this.recordHelper.getFieldOptionList(field);
      }
      if (this.recordViewObject) {
        o.validateCallback = () => this.recordViewObject.validateField(field);
      }
      o.recordHelper = this.recordHelper;
      const viewKey = field + 'Field';
      this.createView(viewKey, viewName, o);
    }

    /**
     * @private
     */
    createFields() {
      this.getFieldList().forEach(item => {
        let view = null;
        let field;
        let readOnly = null;
        if (typeof item === 'object') {
          field = item.name;
          view = item.view;
          if ('readOnly' in item) {
            readOnly = item.readOnly;
          }
        } else {
          field = item;
        }
        if (!item.isAdditional && !(field in this.model.defs.fields)) {
          return;
        }
        readOnly = readOnly || false;
        this.createField(field, view, null, null, readOnly, item.options);
      });
    }

    /**
     * Get field views.
     *
     * @return {Object.<string, module:views/fields/base>}
     */
    getFieldViews() {
      const fields = {};
      this.getFieldList().forEach(item => {
        if (this.hasView(item.viewKey)) {
          fields[item.name] = this.getView(item.viewKey);
        }
      });
      return fields;
    }

    /**
     * Get a field list.
     *
     * @return {module:views/record/panels/side~field[]}
     */
    getFieldList() {
      return this.fieldList.map(item => {
        if (typeof item !== 'object') {
          return {
            name: item
          };
        }
        return item;
      });
    }

    /**
     * @return {module:views/record/panels-container~action[]}
     */
    getActionList() {
      return this.actionList || [];
    }

    /**
     * @return {module:views/record/panels-container~button[]}
     */
    getButtonList() {
      return this.buttonList || [];
    }

    /**
     * A `refresh` action.
     */
    async actionRefresh() {
      Espo.Ui.notifyWait();
      await this.model.fetch();
      Espo.Ui.notify();
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * Is tab-hidden.
     *
     * @return {boolean}
     */
    isTabHidden() {
      if (this.defs.tabNumber === -1 || typeof this.defs.tabNumber === 'undefined') {
        return false;
      }
      const parentView = this.getParentView();
      if (!parentView) {
        return this.defs.tabNumber > 0;
      }

      // noinspection JSUnresolvedReference
      if (parentView && parentView.hasTabs) {
        return parentView.currentTab !== this.defs.tabNumber;
      }
      return false;
    }
  }
  var _default = _exports.default = SidePanelView;
});

define("views/record/panels/relationship", ["exports", "views/record/panels/bottom", "search-manager", "helpers/record-modal", "helpers/record/create-related", "helpers/record/select-related", "di", "web-socket-manager"], function (_exports, _bottom, _searchManager, _recordModal, _createRelated, _selectRelated, _di, _webSocketManager) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _bottom = _interopRequireDefault(_bottom);
  _searchManager = _interopRequireDefault(_searchManager);
  _recordModal = _interopRequireDefault(_recordModal);
  _createRelated = _interopRequireDefault(_createRelated);
  _selectRelated = _interopRequireDefault(_selectRelated);
  _webSocketManager = _interopRequireDefault(_webSocketManager);
  var _staticBlock;
  let _init_webSocketManager, _init_extra_webSocketManager;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  /** @module views/record/panels/relationship */
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  /**
   * A relationship panel.
   *
   * @property {Object} defs
   */
  class RelationshipPanelView extends _bottom.default {
    constructor() {
      super(...arguments);
      _init_extra_webSocketManager(this);
    }
    /** @inheritDoc */
    template = 'record/panels/relationship';

    /**
     * A row-actions view.
     *
     * @protected
     */
    rowActionsView = 'views/record/row-actions/relationship';

    /**
     * An API URL.
     *
     * @protected
     * @type {string|null}
     */
    url = null;

    /**
     * @type {string}
     * @deprecated Use `entityType`.
     */
    scope;

    /**
     * An entity type.
     * @type {string}
     */
    entityType;

    /**
     * Read-only.
     */
    readOnly = false;

    /**
     * Fetch a collection on a model 'after:relate' event.
     *
     * @protected
     */
    fetchOnModelAfterRelate = false;

    /**
     * @protected
     */
    noCreateScopeList = ['User', 'Team', 'Role', 'Portal'];

    /**
     * Records per page. If not set, the value from config is used.
     *
     * @protected
     * @type {number|null}
     */
    recordsPerPage = null;

    /**
     * @protected
     */
    viewModalView = null;

    /**
     * @protected
     */
    listLayoutName;

    /**
     * Also used by the stream panel view.
     *
     * @protected
     * @type {WebSocketManager}
     * @since 9.2.0
     */
    webSocketManager = _init_webSocketManager(this);
    setup() {
      super.setup();
      this.link = this.link || this.defs.link || this.panelName;
      if (!this.link) {
        throw new Error(`No link or panelName.`);
      }

      // noinspection JSDeprecatedSymbols
      if (!this.scope && !this.entityType) {
        if (!this.model) {
          throw new Error(`No model passed.`);
        }
        if (!(this.link in this.model.defs.links)) {
          throw new Error(`Link '${this.link}' is not defined in model '${this.model.entityType}'.`);
        }
      }

      // noinspection JSDeprecatedSymbols
      if (this.scope && !this.entityType) {
        // For backward compatibility.
        // noinspection JSDeprecatedSymbols
        this.entityType = this.scope;
      }
      this.entityType = this.entityType || this.model.defs.links[this.link].entity;

      // For backward compatibility.
      // noinspection JSDeprecatedSymbols
      this.scope = this.entityType;

      /** @type {Record} */
      const linkDefs = this.getMetadata().get(`entityDefs.${this.model.entityType}.links.${this.link}`) || {};
      const url = this.url = this.url || `${this.model.entityType}/${this.model.id}/${this.link}`;
      if (!('create' in this.defs)) {
        this.defs.create = true;
      }
      if (!('select' in this.defs)) {
        this.defs.select = true;
      }
      if (!('view' in this.defs)) {
        this.defs.view = true;
      }
      if (linkDefs.readOnly) {
        let hasCreate = false;
        if (this.entityType && linkDefs.foreign) {
          const foreign = linkDefs.foreign;

          /** @type {Record} */
          const foreignLinkDefs = this.getMetadata().get(`entityDefs.${this.entityType}.links.${foreign}`) || {};
          if (foreignLinkDefs.type === 'belongsTo') {
            hasCreate = true;
          } else if (foreignLinkDefs.type === 'hasMany' && this.getMetadata().get(`entityDefs.${this.entityType}.fields.${foreign}.type`) === 'linkMultiple') {
            hasCreate = true;
          }
        }
        if (!hasCreate) {
          this.defs.create = false;
        }
        this.defs.select = false;
      }
      this.filterList = this.defs.filterList || this.filterList || null;
      if (this.filterList && this.filterList.length) {
        this.filter = this.getStoredFilter() || this.filterList[0];
        if (this.filter === 'all') {
          this.filter = null;
        }
      }
      this.setupCreateAvailability();
      this.setupTitle();
      if (this.defs.createDisabled) {
        this.defs.create = false;
      }
      if (this.defs.selectDisabled) {
        this.defs.select = false;
      }
      if (this.defs.viewDisabled) {
        this.defs.view = false;
      }
      const unlinkDisabled = this.defs.unlinkDisabled || this.model.getLinkParam(this.link, 'readOnly');
      let hasCreate = false;
      if (this.defs.create) {
        if (this.getAcl().check(this.entityType, 'create') && !~this.noCreateScopeList.indexOf(this.entityType)) {
          this.buttonList.push({
            title: 'Create',
            action: this.defs.createAction || 'createRelated',
            link: this.link,
            html: '<span class="fas fa-plus"></span>',
            data: {
              link: this.link
            },
            acl: this.defs.createRequiredAccess || null
          });
          hasCreate = true;
        }
      }
      if (this.defs.select) {
        const data = {
          link: this.link
        };
        if (this.defs.selectPrimaryFilterName) {
          data.primaryFilterName = this.defs.selectPrimaryFilterName;
        }
        if (this.defs.selectBoolFilterList) {
          data.boolFilterList = this.defs.selectBoolFilterList;
        }
        data.massSelect = this.defs.massSelect;
        data.createButton = hasCreate;
        this.actionList.unshift({
          label: 'Select',
          action: this.defs.selectAction || 'selectRelated',
          data: data,
          acl: this.defs.selectRequiredAccess || 'edit',
          iconClass: 'fas fa-angle-up'
        });
      }
      if (this.defs.view) {
        this.actionList.unshift({
          label: 'View List',
          action: this.defs.viewAction || 'viewRelatedList',
          iconClass: 'fas fa-align-justify'
        });
      }
      this.setupActions();
      let layoutName = 'listSmall';
      this.setupListLayout();
      if (this.listLayoutName) {
        layoutName = this.listLayoutName;
      }
      let listLayout = null;
      const layout = this.defs.layout || null;
      if (layout) {
        if (typeof layout === 'string') {
          layoutName = layout;
        } else {
          layoutName = 'listRelationshipCustom';
          listLayout = layout;
        }
      }
      this.listLayout = listLayout;
      this.layoutName = layoutName;
      this.setupSorting();
      this.wait(true);
      this.getCollectionFactory().create(this.entityType, collection => {
        collection.maxSize = this.recordsPerPage || this.getConfig().get('recordsPerPageSmall') || 5;
        if (this.defs.filters) {
          const searchManager = new _searchManager.default(collection);
          searchManager.setAdvanced(this.defs.filters);
          collection.where = searchManager.getWhere();
        }
        if (this.defs.primaryFilter) {
          this.filter = this.defs.primaryFilter;
        }
        collection.url = collection.urlRoot = url;
        if (this.defaultOrderBy) {
          collection.setOrder(this.defaultOrderBy, this.defaultOrder || false, true);
        }
        this.collection = collection;
        collection.parentModel = this.model;
        this.setFilter(this.filter);
        if (this.fetchOnModelAfterRelate) {
          this.listenTo(this.model, 'after:relate', () => collection.fetch());
        }
        this.listenTo(this.model, `update-related:${this.link} update-all`, () => collection.fetch());
        this.listenTo(this.collection, 'change', () => {
          this.model.trigger(`after:related-change:${this.link}`);
        });
        if (this.defs.syncWithModel) {
          this.listenTo(this.model, 'sync', (m, a, o) => {
            if (!o.patch && !o.highlight) {
              // Skip if not save and not web-socket update.
              return;
            }
            if (this.collection.lastSyncPromise && this.collection.lastSyncPromise.getReadyState() < 4) {
              return;
            }
            this.collection.fetch();
          });
        }
        const viewName = this.defs.recordListView || this.getMetadata().get(['clientDefs', this.entityType, 'recordViews', 'listRelated']) || this.getMetadata().get(['clientDefs', this.entityType, 'recordViews', 'list']) || 'views/record/list';
        this.listViewName = viewName;
        this.rowActionsView = this.defs.readOnly ? false : this.defs.rowActionsView || this.rowActionsView;
        this.once('after:render', async () => {
          const view = /** @type {import('views/record/list').default} */
          await this.createView('list', viewName, {
            collection: collection,
            layoutName: layoutName,
            listLayout: listLayout,
            checkboxes: false,
            rowActionsView: this.rowActionsView,
            buttonsDisabled: true,
            selector: '.list-container',
            skipBuildRows: true,
            rowActionsOptions: {
              unlinkDisabled: unlinkDisabled,
              editDisabled: this.defs.editDisabled,
              removeDisabled: this.defs.removeDisabled
            },
            displayTotalCount: false,
            additionalRowActionList: this.defs.rowActionList
          });
          let selectAttributeList = await view.getSelectAttributeList();
          if (selectAttributeList) {
            if (this.defs.mandatoryAttributeList) {
              selectAttributeList = [...selectAttributeList, ...this.defs.mandatoryAttributeList];
              selectAttributeList = selectAttributeList.filter((it, i) => selectAttributeList.indexOf(it) === i);
            }
            collection.data.select = selectAttributeList.join(',');
          }
          if (!this.defs.hidden) {
            collection.fetch();
            return;
          }
          this.once('show', () => collection.fetch());
          if (this.defs.syncBackWithModel) {
            this.listenTo(view, 'after:save after:delete', () => this.processSyncBack());
          }
        });
        this.wait(false);
      });
      this.setupFilterActions();
      this.setupLast();
    }

    /**
     * Set up lastly.
     *
     * @protected
     */
    setupLast() {}

    /**
     * Set up title.
     *
     * @protected
     */
    setupTitle() {
      this.title = this.title || this.translate(this.link, 'links', this.model.entityType);
      let iconHtml = '';
      if (!this.getConfig().get('scopeColorsDisabled')) {
        iconHtml = this.getHelper().getScopeColorIconHtml(this.entityType);
      }
      let titlePart;
      if (this.defs.label) {
        var _this$model;
        titlePart = this.translate(this.defs.label, 'labels', this.entityType);
        const parentEntityType = (_this$model = this.model) === null || _this$model === void 0 ? void 0 : _this$model.entityType;
        if (parentEntityType && this.getLanguage().has(this.defs.label, 'labels', parentEntityType)) {
          titlePart = this.translate(this.defs.label, 'labels', parentEntityType);
        }
      } else {
        titlePart = this.title;
      }
      this.titleHtml = iconHtml + this.getHelper().escapeString(titlePart);
      if (this.filter && this.filter !== 'all') {
        const filterPart = this.getHelper().escapeString(this.translateFilter(this.filter));
        this.titleHtml += ' &middot; ' + filterPart;
      }
    }

    /**
     * Set up sorting.
     *
     * @protected
     */
    setupSorting() {
      let orderBy = this.defs.orderBy || this.defs.sortBy || this.orderBy;
      let order = this.defs.orderDirection || this.orderDirection || this.order;
      if ('asc' in this.defs) {
        // @todo Remove.
        order = this.defs.asc ? 'asc' : 'desc';
      }
      if (!orderBy) {
        orderBy = this.getMetadata().get(['entityDefs', this.entityType, 'collection', 'orderBy']);
        order = this.getMetadata().get(['entityDefs', this.entityType, 'collection', 'order']);
      }
      if (orderBy && !order) {
        order = 'asc';
      }
      this.defaultOrderBy = orderBy;
      this.defaultOrder = order;
    }

    /**
     * Set up a list layout.
     *
     * @protected
     */
    setupListLayout() {}

    /**
     * Set up actions.
     *
     * @protected
     */
    setupActions() {}

    /**
     * Set up filter actions.
     *
     * @protected
     */
    setupFilterActions() {
      if (!(this.filterList && this.filterList.length)) {
        return;
      }
      this.actionList.push(false);
      this.filterList.slice(0).forEach(item => {
        let selected;
        selected = item === 'all' ? !this.filter : item === this.filter;
        const label = this.translateFilter(item);
        const $item = $('<div>').append($('<span>').addClass('check-icon fas fa-check pull-right').addClass(!selected ? 'hidden' : '')).append($('<div class="item-text">').text(label));
        this.actionList.push({
          action: 'selectFilter',
          html: $item.get(0).innerHTML,
          data: {
            name: item
          }
        });
      });
    }

    /**
     * Translate a filter.
     *
     * @param {string} name A name.
     * @return {string}
     */
    translateFilter(name) {
      return this.translate(name, 'presetFilters', this.entityType);
    }

    /**
     * @protected
     */
    getStoredFilter() {
      const key = 'panelFilter' + this.model.entityType + '-' + (this.panelName || this.link);
      return this.getStorage().get('state', key) || null;
    }

    /**
     * @private
     */
    storeFilter(filter) {
      const key = 'panelFilter' + this.model.entityType + '-' + (this.panelName || this.link);
      if (filter) {
        this.getStorage().set('state', key, filter);
      } else {
        this.getStorage().clear('state', key);
      }
    }

    /**
     * Set a filter.
     *
     * @param {string} filter A filter.
     */
    setFilter(filter) {
      this.filter = filter;
      this.collection.data.primaryFilter = null;
      if (filter && filter !== 'all') {
        this.collection.data.primaryFilter = filter;
      }
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * A `select-filter` action.
     *
     * @protected
     */
    actionSelectFilter(data) {
      const filter = data.name;
      let filterInternal = filter;
      if (filter === 'all') {
        filterInternal = false;
      }
      this.storeFilter(filterInternal);
      this.setFilter(filterInternal);
      this.filterList.forEach(item => {
        const $el = this.$el.closest('.panel').find('[data-name="' + item + '"] span');
        if (item === filter) {
          $el.removeClass('hidden');
        } else {
          $el.addClass('hidden');
        }
      });
      this.collection.abortLastFetch();
      this.collection.reset();
      const listView = this.getView('list');
      if (listView && listView.$el) {
        const height = listView.$el.parent().get(0).clientHeight;
        listView.$el.empty();
        if (height) {
          listView.$el.parent().css('height', height + 'px');
        }
      }
      this.collection.fetch().then(() => {
        listView.$el.parent().css('height', '');
      });
      this.setupTitle();
      if (this.isRendered()) {
        this.$el.closest('.panel').find('> .panel-heading > .panel-title > span').html(this.titleHtml);
      }
    }

    /**
     * A `refresh` action.
     *
     * @protected
     */
    async actionRefresh() {
      Espo.Ui.notifyWait();
      await this.collection.fetch();
      Espo.Ui.notify();
    }

    /**
     * A `view-related-list` action.
     *
     * @protected
     * @param {{
     *     scope?: string,
     *     entityType: string,
     *     title?: string,
     *     url?: string,
     *     viewOptions?: Record,
     * }} data
     */
    actionViewRelatedList(data) {
      const entityType = data.scope || data.entityType || this.entityType;
      const viewName = this.getMetadata().get(`clientDefs.${this.model.entityType}.relationshipPanels.${this.link}.viewModalView`) || this.getMetadata().get(`clientDefs.${entityType}.modalViews.relatedList`) || this.viewModalView || 'views/modals/related-list';
      let filter = this.filter;
      if (this.relatedListFiltersDisabled) {
        filter = null;
      }
      const options = {
        model: this.model,
        panelName: this.panelName,
        link: this.link,
        entityType: entityType,
        defs: this.defs,
        title: data.title || this.title,
        filterList: this.filterList,
        filter: filter,
        layoutName: this.layoutName,
        defaultOrder: this.defaultOrder,
        defaultOrderBy: this.defaultOrderBy,
        url: data.url || this.url,
        listViewName: this.listViewName,
        createDisabled: !this.isCreateAvailable(entityType),
        selectDisabled: !this.isSelectAvailable(entityType),
        rowActionsView: this.rowActionsView,
        panelCollection: this.collection,
        filtersDisabled: this.relatedListFiltersDisabled
      };
      if (data.viewOptions) {
        for (const item in data.viewOptions) {
          options[item] = data.viewOptions[item];
        }
      }
      Espo.Ui.notifyWait();
      this.createView('modalRelatedList', viewName, options, view => {
        Espo.Ui.notify(false);
        view.render();
        this.listenTo(view, 'action', (event, element) => {
          Espo.Utils.handleAction(this, event, element);
        });
        this.listenToOnce(view, 'close', () => {
          this.clearView('modalRelatedList');
        });
      });
    }

    /**
     * Is create available.
     *
     * @protected
     * @param {string} scope A scope (entity type).
     * @return {boolean};
     */
    isCreateAvailable(scope) {
      return !!this.defs.create;
    }

    // noinspection JSUnusedLocalSymbols
    /**
     * Is select available.
     *
     * @protected
     * @param {string} scope A scope (entity type).
     * @return {boolean};
     */
    isSelectAvailable(scope) {
      return !!this.defs.select;
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * A `view-related` action.
     *
     * @protected
     */
    actionViewRelated(data) {
      const id = data.id;
      const model = this.collection.get(id);
      if (!model) {
        return;
      }
      const scope = model.entityType;
      const helper = new _recordModal.default();
      helper.showDetail(this, {
        entityType: scope,
        id: id,
        model: model,
        afterSave: model => {
          if (!model) {
            return;
          }
          this.collection.fetch();
          this.processSyncBack();
        }
      });
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * An `edit-related` action.
     *
     * @protected
     */
    actionEditRelated(data) {
      const id = data.id;
      const entityType = this.collection.get(id).entityType;
      const helper = new _recordModal.default();
      helper.showEdit(this, {
        entityType: entityType,
        id: id,
        afterSave: () => {
          this.collection.fetch();
          this.processSyncBack();
        }
      });
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * An `unlink-related` action.
     *
     * @protected
     */
    actionUnlinkRelated(data) {
      const id = data.id;
      this.confirm({
        message: this.translate('unlinkRecordConfirmation', 'messages'),
        confirmText: this.translate('Unlink')
      }, () => {
        Espo.Ui.notifyWait();
        Espo.Ajax.deleteRequest(this.collection.url, {
          id: id
        }).then(() => {
          Espo.Ui.success(this.translate('Unlinked'));
          this.collection.fetch();
          this.model.trigger('after:unrelate');
          this.model.trigger('after:unrelate:' + this.link);
          this.processSyncBack();
        });
      });
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * A `remove-related` action.
     *
     * @protected
     * @param {{id?: string}} [data]
     * @return {Promise<void>}
     */
    async actionRemoveRelated(data) {
      const id = data.id;
      const model = this.collection.get(id);
      const index = this.collection.indexOf(model);
      if (!model) {
        throw new Error("No model.");
      }
      await this.confirm({
        message: this.translate('removeRecordConfirmation', 'messages'),
        confirmText: this.translate('Remove')
      });
      Espo.Ui.notifyWait();
      try {
        await model.destroy({
          wait: true
        });
      } catch (e) {
        if (!this.collection.models.includes(model)) {
          this.collection.add(model, {
            at: index
          });
        }
        return;
      }
      Espo.Ui.success(this.translate('Removed'));
      this.collection.fetch().then(() => {});
      this.model.trigger('after:unrelate');
      this.model.trigger(`after:unrelate:${this.link}`);
      this.processSyncBack();
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * An `unlink-all-related` action.
     *
     * @protected
     */
    actionUnlinkAllRelated(data) {
      this.confirm(this.translate('unlinkAllConfirmation', 'messages'), () => {
        Espo.Ui.notifyWait();
        Espo.Ajax.postRequest(this.model.entityType + '/action/unlinkAll', {
          link: data.link,
          id: this.model.id
        }).then(() => {
          Espo.Ui.success(this.translate('Unlinked'));
          this.collection.fetch();
          this.model.trigger('after:unrelate');
          this.model.trigger('after:unrelate:' + this.link);
          this.processSyncBack();
        });
      });
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * @protected
     * @since 8.4.0
     */
    actionCreateRelated() {
      const helper = new _createRelated.default(this);
      helper.process(this.model, this.link, {
        afterSave: () => {
          this.processSyncBack();
        }
      });
    }

    /**
     * @protected
     */
    processSyncBack() {
      if (!this.defs.syncBackWithModel || this.webSocketManager.isEnabled()) {
        return;
      }
      this.model.fetch({
        highlight: true
      });
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * @protected
     * @since 8.4.0
     */
    actionSelectRelated() {
      const helper = new _selectRelated.default(this);
      helper.process(this.model, this.link, {
        hasCreate: this.defs.create,
        onCreate: () => this.actionCreateRelated()
      });
    }

    /**
     * @private
     */
    setupCreateAvailability() {
      if (!this.link || !this.entityType || !this.model) {
        return;
      }
      const model = this.model;
      const entityType = model.getLinkParam(this.link, 'entity');
      const foreignLink = model.getLinkParam(this.link, 'foreign');
      if (!entityType || !foreignLink) {
        return;
      }
      const readOnly = this.getMetadata().get(`entityDefs.${entityType}.fields.${foreignLink}.readOnly`);
      if (!readOnly) {
        return;
      }
      this.defs.create = false;
    }
    static #_ = _staticBlock = () => [_init_webSocketManager, _init_extra_webSocketManager] = _applyDecs(this, [], [[(0, _di.inject)(_webSocketManager.default), 0, "webSocketManager"]], 0, void 0, _bottom.default).e;
  }
  _staticBlock();
  var _default = _exports.default = RelationshipPanelView;
});

define("views/notification/panel", ["exports", "view"], function (_exports, _view) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class NotificationPanelView extends _view.default {
    template = 'notification/panel';

    /**
     * @private
     * @type {boolean}
     */
    groupingEnabled;
    setup() {
      this.addActionHandler('markAllNotificationsRead', () => this.actionMarkAllRead());
      this.addActionHandler('openNotifications', () => this.actionOpenNotifications());
      this.addActionHandler('closePanel', () => this.close());
      this.addHandler('keydown', '', /** KeyboardEvent */event => {
        if (event.code === 'Escape') {
          this.close();
        }
      });
      this.groupingEnabled = this.getPreferences().get('notificationGrouping') === true;
      const promise = this.getCollectionFactory().create('Notification', collection => {
        this.collection = collection;
        this.collection.maxSize = this.getConfig().get('notificationsMaxSize') || 5;
        this.listenTo(this.collection, 'sync', () => {
          this.trigger('collection-fetched');
        });
      });
      this.wait(promise);
      this.once('remove', () => {
        if (this.collection) {
          this.collection.abortLastFetch();
        }
      });
    }
    afterRender() {
      this.collection.fetch().then(() => this.createRecordView()).then(view => view.render());
      $('#navbar li.notifications-badge-container').addClass('open');
      this.$el.find('> .panel').focus();
    }
    onRemove() {
      $('#navbar li.notifications-badge-container').removeClass('open');
    }

    /**
     * @return {Promise<module:views/record/list-expanded>}
     */
    createRecordView() {
      const viewName = this.getMetadata().get(['clientDefs', 'Notification', 'recordViews', 'list']) || 'views/notification/record/list';
      return /** @type {Promise<module:views/record/list-expanded>} */this.createView('list', viewName, {
        selector: '.list-container',
        collection: this.collection,
        showCount: false,
        listLayout: {
          rows: [[{
            name: 'data',
            view: 'views/notification/fields/container',
            options: {
              containerSelector: this.getSelector(),
              groupingEnabled: this.groupingEnabled
            }
          }]]
        }
      });
    }
    async actionMarkAllRead() {
      this.collection.trigger('all-read');
      await Espo.Ajax.postRequest('Notification/action/markAllRead');
      this.trigger('all-read');
      this.collection.models.forEach(model => {
        model.set('read', true, {
          sync: true
        });
      });
    }
    close() {
      this.trigger('close');
    }
    actionOpenNotifications() {
      this.getRouter().navigate('#Notification', {
        trigger: true
      });
      this.close();
    }
  }
  var _default = _exports.default = NotificationPanelView;
});

define("views/notification/record/list", ["exports", "views/record/list-expanded"], function (_exports, _listExpanded) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _listExpanded = _interopRequireDefault(_listExpanded);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/notification/record/list */

  class NotificationListRecordView extends _listExpanded.default {
    /**
     * @protected
     * @type {boolean}
     */
    hasStars = true;

    /**
     * @protected
     * @type {string}
     */
    starredAttribute = 'isNotRead';

    /**
     * @name collection
     * @type module:collections/note
     * @memberOf NotificationListRecordView#
     */
    setup() {
      super.setup();
      this.listenTo(this.collection, 'sync', (c, r, options) => {
        if (!options.fetchNew) {
          return;
        }
        const lengthBeforeFetch = options.lengthBeforeFetch || 0;
        if (lengthBeforeFetch === 0) {
          this.reRender();
          return;
        }
        const $list = this.$el.find(this.listContainerEl);
        const rowCount = this.collection.length - lengthBeforeFetch;
        for (let i = rowCount - 1; i >= 0; i--) {
          const model = this.collection.at(i);
          $list.prepend($(this.getRowContainerHtml(model.id)));
          this.buildRow(i, model, view => {
            view.render();
          });
        }
      });
      this.events['auxclick a[href][data-scope][data-id]'] = e => {
        const isCombination = e.button === 1 && (e.ctrlKey || e.metaKey);
        if (!isCombination) {
          return;
        }
        const $target = $(e.currentTarget);
        const id = $target.attr('data-id');
        const scope = $target.attr('data-scope');
        e.preventDefault();
        e.stopPropagation();
        this.actionQuickView({
          id: id,
          scope: scope
        });
      };
    }
    getCellSelector(model, item) {
      const current = this.getSelector();
      const row = this.getRowSelector(model.id);
      if (item.field === 'right') {
        return `${current} ${row} > .cell[data-name="${item.field}"]`;
      }
      return `${current} ${row} > .expanded-row > .cell[data-name="${item.field}"]`;
    }

    /**
     * @return {Promise}
     */
    showNewRecords() {
      if (this.isGroupingEnabled()) {
        return this.collection.fetch();
      }
      return this.collection.fetchNew();
    }

    /**
     * @todo Preferences?
     * @private
     * @return {boolean}
     */
    isGroupingEnabled() {
      return true;
    }
  }
  var _default = _exports.default = NotificationListRecordView;
});

define("views/note/fields/post", ["exports", "views/fields/text", "@textcomplete/core", "@textcomplete/textarea"], function (_exports, _text, _core, _textarea) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _text = _interopRequireDefault(_text);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class NotePostFieldView extends _text.default {
    /**
     * @private
     * @type {Textcomplete}
     */
    textcomplete;
    setup() {
      super.setup();
      this.insertedImagesData = {};
      this.addHandler('paste', 'textarea', (/** ClipboardEvent */event) => this.handlePaste(event));
    }
    onRemove() {
      super.onRemove();
      if (this.textcomplete) {
        this.textcomplete.destroy();
      }
    }

    /**
     * @return {HTMLTextAreaElement}
     */
    getTextAreaElement() {
      return this.$textarea.get(0);
    }

    /**
     * @private
     * @param {ClipboardEvent} event
     */
    handlePaste(event) {
      if (!event.clipboardData) {
        return;
      }
      let text = event.clipboardData.getData('text/plain');
      if (!text) {
        return;
      }
      text = text.trim();
      if (!text) {
        return;
      }
      this.handlePastedText(text);
    }
    afterRenderEdit() {
      const placeholderText = this.options.placeholderText || this.translate('writeMessage', 'messages', 'Note');
      this.$element.attr('placeholder', placeholderText);
      this.$textarea = this.$element;
      const $textarea = this.$textarea;
      $textarea.off('drop');
      $textarea.off('dragover');
      $textarea.off('dragleave');
      this.$textarea.on('drop', e => {
        e.preventDefault();
        e.stopPropagation();
        e = e.originalEvent;
        if (e.dataTransfer && e.dataTransfer.files && e.dataTransfer.files.length) {
          this.trigger('add-files', e.dataTransfer.files);
        }
        this.$textarea.attr('placeholder', originalPlaceholderText);
      });
      const originalPlaceholderText = this.$textarea.attr('placeholder');
      this.$textarea.on('dragover', e => {
        e.preventDefault();
        this.$textarea.attr('placeholder', this.translate('dropToAttach', 'messages'));
      });
      this.$textarea.on('dragleave', e => {
        e.preventDefault();
        this.$textarea.attr('placeholder', originalPlaceholderText);
      });
      this.initMentions();
    }
    initMentions() {
      const mentionPermissionLevel = this.getAcl().getPermissionLevel('mention');
      if (mentionPermissionLevel === 'no' /*|| this.model.isNew()*/) {
        return;
      }
      const maxSize = this.getConfig().get('recordsPerPage');
      const buildUserListUrl = term => {
        let url = `User?` + `${$.param({
          q: term
        })}` + `&${$.param({
          primaryFilter: 'active'
        })}` + `&orderBy=name` + `&maxSize=${maxSize}` + `&select=id,name,userName`;
        if (mentionPermissionLevel === 'team') {
          url += '&' + $.param({
            boolFilterList: ['onlyMyTeam']
          });
        }
        return url;
      };
      const editor = new _textarea.TextareaEditor(this.textAreaElement);
      let bypass = false;
      this.textcomplete = new _core.Textcomplete(editor, [{
        match: /(^|\s)@(\w[\w@.-]*)$/,
        index: 2,
        search: (term, callback) => {
          if (term.length === 0 || bypass) {
            callback([]);
            return;
          }
          Espo.Ajax.getRequest(buildUserListUrl(term)).then(data => callback(data.list));
        },
        template: mention => {
          const avatar = this.getHelper().getAvatarHtml(mention.id, 'medium', 16, 'avatar-link');
          const name = this.getHelper().escapeString(mention.name);
          const username = this.getHelper().escapeString(mention.userName);
          return `${avatar + name} <span class="text-muted">@${username}</span>`;
        },
        replace: it => {
          return '$1@' + it.userName + '';
        }
      }], {
        dropdown: {
          item: {
            className: "textcomplete-item",
            activeClassName: "textcomplete-item active"
          },
          style: {
            zIndex: '1100'
          }
        }
      });
      this.textcomplete.on('select', () => {
        bypass = true;
        setTimeout(() => {
          bypass = false;
        }, 100);
      });
      this.textAreaElement.addEventListener('blur', () => {
        bypass = true;
        setTimeout(() => {
          bypass = false;
        }, 200);
        setTimeout(() => {
          var _this$textcomplete;
          (_this$textcomplete = this.textcomplete) === null || _this$textcomplete === void 0 || _this$textcomplete.hide();
        }, 150);
      });
    }
    validateRequired() {
      if (this.isRequired()) {
        if ((this.model.get('attachmentsIds') || []).length) {
          return false;
        }
      }
      return super.validateRequired();
    }

    /**
     * @private
     * @param {string} text
     */
    handlePastedText(text) {
      // noinspection RegExpRedundantEscape,RegExpSimplifiable
      if (!/^http(s){0,1}\:\/\//.test(text)) {
        return;
      }
      const field = 'attachments';
      const imageExtensionList = ['jpg', 'jpeg', 'png', 'gif'];
      const regExpString = '.+\\.(' + imageExtensionList.join('|') + ')(/?.*){0,1}$';
      const regExp = new RegExp(regExpString, 'i');
      let url = text;
      const siteUrl = this.getConfig().get('siteUrl').replace(/\/$/, '');
      const setIds = /** @type {string[]} */this.model.attributes[`${field}Ids`] || [];
      if (regExp.test(text)) {
        const insertedId = this.insertedImagesData[url];
        if (insertedId && setIds.includes(insertedId)) {
          return;
        }
        Espo.Ajax.postRequest('Attachment/fromImageUrl', {
          url: url,
          parentType: this.model.entityType,
          field: field
        }).then(/** {id: string, name: string, type: string} */result => {
          const ids = [...(this.model.attributes[`${field}Ids`] || [])];
          const names = {
            ...this.model.attributes[`${field}Names`]
          };
          const types = {
            ...this.model.attributes[`${field}Types`]
          };
          ids.push(result.id);
          names[result.id] = result.name;
          types[result.id] = result.type;
          this.insertedImagesData[url] = result.id;
          this.model.set({
            [`${field}Ids`]: ids,
            [`${field}Names`]: names,
            [`${field}Types`]: types
          });
        }).catch(xhr => {
          xhr.errorIsHandled = true;
        });
        return;
      }

      // noinspection RegExpRedundantEscape
      if (/\?entryPoint\=image\&/.test(text) && text.indexOf(siteUrl) === 0) {
        // noinspection RegExpRedundantEscape,RegExpSimplifiable
        url = text.replace(/[\&]{0,1}size\=[a-z\-]*/, '');

        // noinspection RegExpRedundantEscape,RegExpSimplifiable
        const match = /\&{0,1}id\=([a-z0-9A-Z]*)/g.exec(text);
        if (match.length !== 2) {
          return;
        }
        const id = match[1];
        if (setIds.includes(id)) {
          return;
        }
        const insertedId = this.insertedImagesData[id];
        if (insertedId && setIds.includes(insertedId)) {
          return;
        }
        Espo.Ajax.postRequest(`Attachment/copy/${id}`, {
          parentType: this.model.entityType,
          field: field
        }).then(/** {id: string, name: string, type: string} */result => {
          const ids = [...(this.model.attributes[`${field}Ids`] || [])];
          const names = {
            ...this.model.attributes[`${field}Names`]
          };
          const types = {
            ...this.model.attributes[`${field}Types`]
          };
          ids.push(result.id);
          names[result.id] = result.name;
          types[result.id] = result.type;
          this.insertedImagesData[id] = result.id;
          this.model.set({
            [`${field}Ids`]: ids,
            [`${field}Names`]: names,
            [`${field}Types`]: types
          });
        }).catch(xhr => {
          xhr.errorIsHandled = true;
        });
      }
    }
  }
  var _default = _exports.default = NotePostFieldView;
});

define("views/fields/user", ["exports", "views/fields/link", "ui/autocomplete"], function (_exports, _link, _autocomplete) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _link = _interopRequireDefault(_link);
  _autocomplete = _interopRequireDefault(_autocomplete);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class UserFieldView extends _link.default {
    searchTemplate = 'fields/user/search';
    setup() {
      super.setup();

      // noinspection JSUnresolvedReference
      if (this.options.isInComplexField) {
        this.linkClass = 'text-default';
      }
    }
    setupSearch() {
      super.setupSearch();
      this.searchTypeList = Espo.Utils.clone(this.searchTypeList);
      this.searchTypeList.push('isFromTeams');
      this.searchData.teamIdList = this.getSearchParamsData().teamIdList || this.searchParams.teamIdList || [];
      this.searchData.teamNameHash = this.getSearchParamsData().teamNameHash || this.searchParams.teamNameHash || {};
      this.events['click a[data-action="clearLinkTeams"]'] = e => {
        const id = $(e.currentTarget).data('id').toString();
        this.deleteLinkTeams(id);
      };
      this.addActionHandler('selectLinkTeams', () => this.actionSelectLinkTeams());
      this.events['click a[data-action="clearLinkTeams"]'] = e => {
        const id = $(e.currentTarget).data('id').toString();
        this.deleteLinkTeams(id);
      };
    }
    getSelectPrimaryFilterName() {
      return 'active';
    }

    /**
     * @protected
     */
    async actionSelectLinkTeams() {
      const viewName = this.getMetadata().get('clientDefs.Team.modalViews.select') || 'views/modals/select-records';

      /** @type {module:views/modals/select-records~Options} */
      const options = {
        entityType: 'Team',
        createButton: false,
        multiple: true,
        onSelect: models => {
          models.forEach(model => this.addLinkTeams(model.id, model.attributes.name));
        }
      };
      Espo.Ui.notifyWait();
      const view = await this.createView('modal', viewName, options);
      await view.render();
    }
    handleSearchType(type) {
      super.handleSearchType(type);
      if (type === 'isFromTeams') {
        this.$el.find('div.teams-container').removeClass('hidden');
      } else {
        this.$el.find('div.teams-container').addClass('hidden');
      }
    }
    afterRender() {
      super.afterRender();
      if (this.mode === this.MODE_SEARCH) {
        const $elementTeams = this.$el.find('input.element-teams');

        /** @type {module:ajax.AjaxPromise & Promise<any>} */
        let lastAjaxPromise;
        const autocomplete = new _autocomplete.default($elementTeams.get(0), {
          minChars: 1,
          focusOnSelect: true,
          handleFocusMode: 3,
          autoSelectFirst: true,
          forceHide: true,
          onSelect: item => {
            this.addLinkTeams(item.id, item.name);
            $elementTeams.val('');
          },
          lookupFunction: query => {
            if (lastAjaxPromise && lastAjaxPromise.getReadyState() < 4) {
              lastAjaxPromise.abort();
            }
            lastAjaxPromise = Espo.Ajax.getRequest('Team', {
              maxSize: this.getAutocompleteMaxCount(),
              select: 'id,name',
              q: query
            });
            return lastAjaxPromise.then(/** {list: Record[]} */response => {
              return response.list.map(item => ({
                id: item.id,
                name: item.name,
                data: item.id,
                value: item.name
              }));
            });
          }
        });
        this.once('render remove', () => autocomplete.dispose());
        const type = this.$el.find('select.search-type').val();
        if (type === 'isFromTeams') {
          this.searchData.teamIdList.forEach(id => {
            this.addLinkTeamsHtml(id, this.searchData.teamNameHash[id]);
          });
        }
      }
    }
    deleteLinkTeams(id) {
      this.deleteLinkTeamsHtml(id);
      const index = this.searchData.teamIdList.indexOf(id);
      if (index > -1) {
        this.searchData.teamIdList.splice(index, 1);
      }
      delete this.searchData.teamNameHash[id];
      this.trigger('change');
    }
    addLinkTeams(id, name) {
      this.searchData.teamIdList = this.searchData.teamIdList || [];
      if (!~this.searchData.teamIdList.indexOf(id)) {
        this.searchData.teamIdList.push(id);
        this.searchData.teamNameHash[id] = name;
        this.addLinkTeamsHtml(id, name);
        this.trigger('change');
      }
    }
    deleteLinkTeamsHtml(id) {
      this.$el.find('.link-teams-container .link-' + id).remove();
    }
    addLinkTeamsHtml(id, name) {
      id = this.getHelper().escapeString(id);
      name = this.getHelper().escapeString(name);
      const $container = this.$el.find('.link-teams-container');
      const $el = $('<div />').addClass('link-' + id).addClass('list-group-item');
      $el.html(name + '&nbsp');
      $el.prepend('<a role="button" class="pull-right" data-id="' + id + '" ' + 'data-action="clearLinkTeams"><span class="fas fa-times"></a>');
      $container.append($el);
      return $el;
    }
    fetchSearch() {
      const type = this.$el.find('select.search-type').val();
      if (type === 'isFromTeams') {
        return {
          type: 'isUserFromTeams',
          field: this.name,
          value: this.searchData.teamIdList,
          data: {
            type: type,
            teamIdList: this.searchData.teamIdList,
            teamNameHash: this.searchData.teamNameHash
          }
        };
      }
      return super.fetchSearch();
    }
  }
  var _default = _exports.default = UserFieldView;
});

define("views/fields/range-int", ["exports", "views/fields/base", "views/fields/int", "autonumeric"], function (_exports, _base, _int, _autonumeric) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  _int = _interopRequireDefault(_int);
  _autonumeric = _interopRequireDefault(_autonumeric);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class RangeIntFieldView extends _base.default {
    type = 'rangeInt';
    listTemplate = 'fields/range-int/detail';
    detailTemplate = 'fields/range-int/detail';
    editTemplate = 'fields/range-int/edit';
    validations = ['required', 'int', 'range', 'order'];

    // noinspection JSCheckFunctionSignatures
    data() {
      const data = super.data();
      data.ucName = Espo.Utils.upperCaseFirst(this.name);
      data.fromValue = this.model.get(this.fromField);
      data.toValue = this.model.get(this.toField);

      // noinspection JSValidateTypes
      return data;
    }
    init() {
      const ucName = Espo.Utils.upperCaseFirst(this.options.defs.name);
      this.fromField = 'from' + ucName;
      this.toField = 'to' + ucName;
      super.init();
    }
    getValueForDisplay() {
      let fromValue = this.model.get(this.fromField);
      let toValue = this.model.get(this.toField);
      fromValue = isNaN(fromValue) ? null : fromValue;
      toValue = isNaN(toValue) ? null : toValue;
      if (fromValue !== null && toValue !== null) {
        return this.formatNumber(fromValue) + ' &#8211 ' + this.formatNumber(toValue);
      }
      if (fromValue) {
        return '&#62;&#61; ' + this.formatNumber(fromValue);
      }
      if (toValue) {
        return '&#60;&#61; ' + this.formatNumber(toValue);
      }
      return this.translate('None');
    }
    setup() {
      if (this.getPreferences().has('decimalMark')) {
        this.decimalMark = this.getPreferences().get('decimalMark');
      } else if (this.getConfig().has('decimalMark')) {
        this.decimalMark = this.getConfig().get('decimalMark');
      }
      if (this.getPreferences().has('thousandSeparator')) {
        this.thousandSeparator = this.getPreferences().get('thousandSeparator');
      } else if (this.getConfig().has('thousandSeparator')) {
        this.thousandSeparator = this.getConfig().get('thousandSeparator');
      }
    }
    setupFinal() {
      super.setupFinal();
      this.setupAutoNumericOptions();
    }

    /**
     * @protected
     */
    setupAutoNumericOptions() {
      const separator = (!this.disableFormatting ? this.thousandSeparator : null) || '';
      let decimalCharacter = '.';
      if (separator === '.') {
        decimalCharacter = ',';
      }
      this.autoNumericOptions = {
        digitGroupSeparator: separator,
        decimalCharacter: decimalCharacter,
        modifyValueOnWheel: false,
        decimalPlaces: 0,
        selectOnFocus: false,
        formulaMode: true
      };
    }
    afterRender() {
      super.afterRender();
      if (this.mode === this.MODE_EDIT) {
        this.$from = this.$el.find('[data-name="' + this.fromField + '"]');
        this.$to = this.$el.find('[data-name="' + this.toField + '"]');
        this.$from.on('change', () => {
          this.trigger('change');
        });
        this.$to.on('change', () => {
          this.trigger('change');
        });
        if (this.autoNumericOptions) {
          // noinspection JSUnusedGlobalSymbols
          this.autoNumericInstance1 = new _autonumeric.default(this.$from.get(0), this.autoNumericOptions);
          // noinspection JSUnusedGlobalSymbols
          this.autoNumericInstance2 = new _autonumeric.default(this.$to.get(0), this.autoNumericOptions);
        }
      }
    }
    validateRequired() {
      const validate = name => {
        if (this.model.isRequired(name) && this.model.get(name) === null) {
          const msg = this.translate('fieldIsRequired', 'messages').replace('{field}', this.getLabelText());
          this.showValidationMessage(msg, '[data-name="' + name + '"]');
          return true;
        }
      };
      let result = false;
      result = validate(this.fromField) || result;
      result = validate(this.toField) || result;
      return result;
    }

    // noinspection JSUnusedGlobalSymbols
    validateInt() {
      const validate = name => {
        if (isNaN(this.model.get(name))) {
          const msg = this.translate('fieldShouldBeInt', 'messages').replace('{field}', this.getLabelText());
          this.showValidationMessage(msg, '[data-name="' + name + '"]');
          return true;
        }
      };
      let result = false;
      result = validate(this.fromField) || result;
      result = validate(this.toField) || result;
      return result;
    }

    // noinspection JSUnusedGlobalSymbols
    validateRange() {
      const validate = name => {
        const value = this.model.get(name);
        if (value === null) {
          return false;
        }
        const minValue = this.model.getFieldParam(name, 'min');
        const maxValue = this.model.getFieldParam(name, 'max');
        if (minValue !== null && maxValue !== null) {
          if (value < minValue || value > maxValue) {
            const msg = this.translate('fieldShouldBeBetween', 'messages').replace('{field}', this.translate(name, 'fields', this.entityType)).replace('{min}', minValue).replace('{max}', maxValue);
            this.showValidationMessage(msg, '[data-name="' + name + '"]');
            return true;
          }
        } else if (minValue !== null) {
          if (value < minValue) {
            const msg = this.translate('fieldShouldBeLess', 'messages').replace('{field}', this.translate(name, 'fields', this.entityType)).replace('{value}', minValue);
            this.showValidationMessage(msg, '[data-name="' + name + '"]');
            return true;
          }
        } else if (maxValue !== null) {
          if (value > maxValue) {
            const msg = this.translate('fieldShouldBeGreater', 'messages').replace('{field}', this.translate(name, 'fields', this.entityType)).replace('{value}', maxValue);
            this.showValidationMessage(msg, '[data-name="' + name + '"]');
            return true;
          }
        }
      };
      let result = false;
      result = validate(this.fromField) || result;
      result = validate(this.toField) || result;
      return result;
    }

    // noinspection JSUnusedGlobalSymbols
    validateOrder() {
      const fromValue = this.model.get(this.fromField);
      const toValue = this.model.get(this.toField);
      if (fromValue !== null && toValue !== null && fromValue > toValue) {
        const msg = this.translate('fieldShouldBeGreater', 'messages').replace('{field}', this.translate(this.toField, 'fields', this.entityType)).replace('{value}', this.translate(this.fromField, 'fields', this.entityType));
        this.showValidationMessage(msg, '[data-name="' + this.fromField + '"]');
        return true;
      }
    }
    isRequired() {
      return this.model.getFieldParam(this.fromField, 'required') || this.model.getFieldParam(this.toField, 'required');
    }
    parse(value) {
      return _int.default.prototype.parse.call(this, value);
    }
    formatNumber(value) {
      if (this.params.disableFormatting) {
        return value.toString();
      }
      return _int.default.prototype.formatNumberDetail.call(this, value);
    }
    fetch() {
      const data = {};
      data[this.fromField] = this.parse(this.$from.val().trim());
      data[this.toField] = this.parse(this.$to.val().trim());
      return data;
    }
  }
  var _default = _exports.default = RangeIntFieldView;
});

define("views/fields/link-multiple", ["exports", "views/fields/base", "helpers/record-modal", "ui/autocomplete", "helpers/field/cascade-links", "ajax", "ui"], function (_exports, _base, _recordModal, _autocomplete, _cascadeLinks, _ajax, _ui) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  _recordModal = _interopRequireDefault(_recordModal);
  _autocomplete = _interopRequireDefault(_autocomplete);
  _cascadeLinks = _interopRequireDefault(_cascadeLinks);
  _ajax = _interopRequireDefault(_ajax);
  _ui = _interopRequireDefault(_ui);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * Options.
   */

  /**
   * A link-multiple field (for has-many relations).
   *
   */
  class LinkMultipleFieldView extends _base.default {
    type = 'linkMultiple';
    listTemplate = 'fields/link-multiple/list';
    detailTemplate = 'fields/link-multiple/detail';
    editTemplate = 'fields/link-multiple/edit';
    searchTemplate = 'fields/link-multiple/search';

    // noinspection JSUnusedGlobalSymbols
    listLinkTemplateContent = `
        {{#if value}}
            <a
                href="#{{scope}}/view/{{model.id}}"
                class="link"
                data-id="{{model.id}}"
            >{{{value}}}</a>
        {{/if}}
    `;
    validations = ['required', 'maxCount'];

    /**
     * A name-hash attribute name.
     */

    /**
     * A IDs attribute name.
     */

    nameHash = null;
    ids = null;

    /**
     * A foreign entity type.
     */

    /**
     * Autocomplete disabled.
     */
    autocompleteDisabled = false;

    /**
     * A select-record view.
     */
    selectRecordsView = 'views/modals/select-records';

    /**
     * Create disabled.
     */
    createDisabled = false;

    /**
     * Force create button even is disabled in clientDefs > relationshipPanels.
     */
    forceCreateButton = false;

    /**
     * To display the create button.
     */
    createButton = false;
    sortable = false;

    /**
     * A search type list.
     */
    searchTypeList = ['anyOf', 'isEmpty', 'isNotEmpty', 'noneOf', 'allOf'];

    /**
     * A primary filter list that will be available when selecting a record.
     */
    selectFilterList = null;

    /**
     * A select bool filter list.
     */
    selectBoolFilterList = null;

    /**
     * A select primary filter.
     */
    selectPrimaryFilterName = null;

    /**
     * An autocomplete max record number.
     */
    autocompleteMaxCount = null;

    /**
     * Trigger autocomplete on empty input.
     */
    autocompleteOnEmpty = false;

    /**
     * Select all attributes.
     */
    forceSelectAllAttributes = false;
    iconHtml = '';

    /**
     * A link element class name. Applicable in the detail mode.
     *
     * @protected
     * @since 9.1.6
     */

    /**
     * Panel definitions.
     */

    mandatorySelectAttributeList = null;
    data() {
      const ids = this.model.get(this.idsName);
      const createButton = this.createButton && (!this.createDisabled || this.forceCreateButton);
      return {
        ...super.data(),
        idValues: this.model.get(this.idsName),
        idValuesString: ids ? ids.join(',') : '',
        nameHash: this.model.get(this.nameHashName),
        foreignScope: this.foreignScope,
        valueIsSet: this.model.has(this.idsName),
        createButton: createButton
      };
    }

    /**
     * Get advanced filters (field filters) to be applied when select a record.
     * Can be extended.
     */
    getSelectFilters() {
      return null;
    }

    /**
     * Get a select bool filter list. Applied when select a record.
     * Can be extended.
     */
    getSelectBoolFilterList() {
      return this.selectBoolFilterList;
    }

    /**
     * Get a select primary filter. Applied when select a record.
     * Can be extended.
     */
    getSelectPrimaryFilterName() {
      return this.selectPrimaryFilterName;
    }

    /**
     * Get a primary filter list that will be available when selecting a record.
     * Can be extended.
     */
    getSelectFilterList() {
      return this.selectFilterList;
    }

    /**
     * Attributes to pass to a model when creating a new record.
     * Can be extended.
     */
    getCreateAttributes() {
      const attributeMap = this.panelDefs.createAttributeMap ?? {};
      const attributes = {};
      Object.keys(attributeMap).forEach(attr => attributes[attributeMap[attr]] = this.model.get(attr));
      return {
        ...attributes,
        ...this._getCascadingCreateAttributes()
      };
    }
    setup() {
      this.addHandler('auxclick', 'a[href]:not([role="button"])', (e, target) => {
        this.onAuxClickLink(e, target);
      });
      this.nameHashName = this.name + 'Names';
      this.idsName = this.name + 'Ids';
      this.foreignScope = this.options.foreignScope || this.foreignScope || this.params.entity || this.model.getFieldParam(this.name, 'entity') || this.model.getLinkParam(this.name, 'entity');
      if ('createDisabled' in this.options) {
        this.createDisabled = this.options.createDisabled;
      }
      if (this.isSearchMode()) {
        var _this$searchParams, _this$searchParams2;
        const nameHash = this.getSearchParamsData().nameHash ?? ((_this$searchParams = this.searchParams) === null || _this$searchParams === void 0 ? void 0 : _this$searchParams.nameHash) ?? {};
        const idList = this.getSearchParamsData().idList ?? ((_this$searchParams2 = this.searchParams) === null || _this$searchParams2 === void 0 ? void 0 : _this$searchParams2.value) ?? [];
        this.nameHash = Espo.Utils.clone(nameHash);
        this.ids = Espo.Utils.clone(idList);
      } else {
        this.copyValuesFromModel();
      }
      this.listenTo(this.model, 'change:' + this.idsName, () => {
        this.copyValuesFromModel();
      });
      this.sortable = this.sortable || this.params.sortable || false;
      this.iconHtml = this.getHelper().getScopeColorIconHtml(this.foreignScope);
      if (!this.isListMode()) {
        this.addActionHandler('selectLink', () => this.actionSelect());
        this.addActionHandler('clearLink', (_, target) => this.actionDeleteLink(target.dataset.id));
      }
      this.autocompleteOnEmpty = this.params.autocompleteOnEmpty || this.autocompleteOnEmpty;
      this.createButton = this.params.createButton || this.createButton;
      if (this.createButton && !this.getAcl().checkScope(this.foreignScope, 'create')) {
        this.createButton = false;
      }
      if (this.createButton) {
        this.addActionHandler('createLink', () => this.actionCreateLink());
      }
      if (this.entityType) {
        this.panelDefs = this.getMetadata().get(`clientDefs.${this.entityType}.relationshipPanels.${this.name}`) ?? {};
      } else {
        this.panelDefs = {};
      }
    }
    actionDeleteLink(id) {
      var _this$$element;
      this.deleteLink(id);

      // noinspection JSUnresolvedReference
      (_this$$element = this.$element) === null || _this$$element === void 0 || (_this$$element = _this$$element.get(0)) === null || _this$$element === void 0 || _this$$element.focus({
        preventScroll: true
      });

      // Timeout prevents autocomplete from disappearing.
      setTimeout(() => {
        var _this$$element2;
        // noinspection JSUnresolvedReference
        (_this$$element2 = this.$element) === null || _this$$element2 === void 0 || (_this$$element2 = _this$$element2.get(0)) === null || _this$$element2 === void 0 || _this$$element2.focus({
          preventScroll: true
        });
      }, 140);
    }

    /**
     * Copy values from a model to view properties.
     */
    copyValuesFromModel() {
      this.ids = Espo.Utils.clone(this.model.get(this.idsName) ?? []);
      this.nameHash = Espo.Utils.clone(this.model.get(this.nameHashName) || {});
    }

    /**
     * Handle a search type.
     *
     * @param type A type.
     */
    handleSearchType(type) {
      if (['anyOf', 'noneOf', 'allOf'].includes(type)) {
        this.$el.find('div.link-group-container').removeClass('hidden');
      } else {
        this.$el.find('div.link-group-container').addClass('hidden');
      }
    }
    setupSearch() {
      this.addHandler('change', 'select.search-type', (_, target) => {
        this.handleSearchType(target.value);
      });
    }

    /**
     * Get an autocomplete max record number. Can be extended.
     */
    getAutocompleteMaxCount() {
      if (this.autocompleteMaxCount) {
        return this.autocompleteMaxCount;
      }
      return this.getConfig().get('recordsPerPage');
    }

    // noinspection JSUnusedLocalSymbols
    /**
     * Compose an autocomplete URL. Can be extended.
     *
     * @param q query.
     */
    getAutocompleteUrl(q) {
      // noinspection BadExpressionStatementJS
      q;
      let url = this.foreignScope + '?&maxSize=' + this.getAutocompleteMaxCount();
      if (!this.forceSelectAllAttributes) {
        const mandatorySelectAttributeList = this.mandatorySelectAttributeList ?? this.panelDefs.selectMandatoryAttributeList;
        let select = ['id', 'name'];
        if (mandatorySelectAttributeList) {
          select = select.concat(mandatorySelectAttributeList);
        }
        url += '&select=' + select.join(',');
      }
      const notSelectedFilter = this.ids && this.ids.length ? {
        // Prefix to prevent conflict when the 'id' field is in filters.
        _id: {
          type: 'notIn',
          attribute: 'id',
          value: this.ids
        }
      } : {};
      return new Promise(async resolve => {
        const filters = await this._getSelectFilters();
        if (filters.bool) {
          url += '&' + $.param({
            boolFilterList: filters.bool
          });
        }
        if (filters.primary) {
          url += '&' + $.param({
            primaryFilter: filters.primary
          });
        }
        const advanced = {
          ...notSelectedFilter,
          ...(filters.advanced ?? {})
        };
        if (Object.keys(advanced).length) {
          url += '&' + $.param({
            where: advanced
          });
        }
        const orderBy = filters.orderBy || this.panelDefs.selectOrderBy;
        const orderDirection = filters.orderBy ? filters.order : this.panelDefs.selectOrderDirection;
        if (orderBy) {
          url += '&' + $.param({
            orderBy: orderBy,
            order: orderDirection || 'asc'
          });
        }
        resolve(url);
      });
    }
    afterRender() {
      if (this.isEditMode() || this.isSearchMode()) {
        this.$element = this.$el.find('input.main-element');
        if (!this.autocompleteDisabled) {
          var _this$$element3;
          let lastAjaxPromise;
          const autocomplete = new _autocomplete.default((_this$$element3 = this.$element) === null || _this$$element3 === void 0 ? void 0 : _this$$element3.get(0), {
            focusOnSelect: true,
            handleFocusMode: 3,
            autoSelectFirst: true,
            triggerSelectOnValidInput: false,
            forceHide: true,
            onSelect: item => {
              this.getModelFactory().create(this.foreignScope, model => {
                var _this$$element4, _this$$element5;
                model.setMultiple(item.attributes);
                this.select([model]);
                (_this$$element4 = this.$element) === null || _this$$element4 === void 0 || _this$$element4.val('');
                (_this$$element5 = this.$element) === null || _this$$element5 === void 0 || _this$$element5.trigger('focus');
              });
            },
            lookupFunction: async query => {
              if (!this.autocompleteOnEmpty && query.length === 0) {
                const onEmptyPromise = this.getOnEmptyAutocomplete();
                if (onEmptyPromise) {
                  const list = await onEmptyPromise;
                  return this._transformAutocompleteResult({
                    list: list
                  });
                }
                return [];
              }
              const url = await this.getAutocompleteUrl(query);
              if (lastAjaxPromise && lastAjaxPromise.getReadyState() < 4) {
                lastAjaxPromise.abort();
              }
              lastAjaxPromise = _ajax.default.getRequest(url, {
                q: query
              });
              const response = await lastAjaxPromise;
              return response.list.map(item => ({
                value: item.name,
                attributes: item
              }));
            }
          });
          this.once('render remove', () => autocomplete.dispose());
        }
        this.renderLinks();
        if (this.isEditMode() && this.sortable) {
          // noinspection JSUnresolvedReference
          this.$el.find('.link-container').sortable({
            stop: () => {
              this.fetchFromDom();
              this.trigger('change');
            }
          });
        }
        if (this.isSearchMode()) {
          const type = this.$el.find('select.search-type').val();
          this.handleSearchType(type);
          this.$el.find('select.search-type').on('change', () => {
            this.trigger('change');
          });
        }
      }
    }

    /**
     * Render items.
     *
     * @protected
     */
    renderLinks() {
      (this.ids ?? []).forEach(id => {
        var _this$nameHash;
        this.addLinkHtml(id, (_this$nameHash = this.nameHash) === null || _this$nameHash === void 0 ? void 0 : _this$nameHash[id]);
      });
    }

    /**
     * Delete an item.
     *
     * @param id An ID.
     */
    deleteLink(id) {
      if (!this.nameHash) {
        throw new Error("No nameHash.");
      }
      this.trigger('delete-link', id);
      this.trigger(`delete-link:${id}`);
      this.deleteLinkHtml(id);
      const ids = this.ids;
      const index = ids.indexOf(id);
      if (index > -1) {
        ids.splice(index, 1);
      }
      delete this.nameHash[id];
      this.afterDeleteLink(id);
      this.trigger('change');
    }

    /**
     * Add an item.
     *
     * @param id An ID.
     * @param name A name.
     */
    addLink(id, name) {
      if (!this.ids || !this.nameHash) {
        throw new Error("No ids or nameHash.");
      }
      if (!this.ids.includes(id)) {
        this.ids.push(id);
        this.nameHash[id] = name;
        this.addLinkHtml(id, name);
        this.afterAddLink(id);
        this.trigger('add-link', id);
        this.trigger('add-link:' + id);
      }
      this.trigger('change');
    }

    /**
     * @param id An ID.
     */
    afterDeleteLink(id) {
      // noinspection BadExpressionStatementJS
      id;
    }

    /**
     * @param id An ID.
     */
    afterAddLink(id) {
      // noinspection BadExpressionStatementJS
      id;
    }

    /**
     * @param id An ID.
     */
    deleteLinkHtml(id) {
      this.$el.find(`.link-${id}`).remove();
    }

    /**
     * Add an item for edit mode.
     *
     * @param id An ID.
     * @param name A name.
     * @internal
     */
    addLinkHtml(id, name) {
      // Beware of XSS.

      name = name ?? id;
      const $container = this.$el.find('.link-container');
      const itemElement = this.prepareEditItemElement(id, name);
      $container.append(itemElement);
      return $(itemElement);
    }

    /**
     * @param id An ID.
     * @param name A name.
     * @return {HTMLElement}
     */
    prepareEditItemElement(id, name) {
      const item = document.createElement('div');
      item.classList.add('link-' + id);
      item.classList.add('list-group-item');
      item.dataset.id = id;
      item.append((() => {
        const a = document.createElement('a');
        a.role = 'button';
        a.tabIndex = 0;
        a.classList.add('pull-right');
        a.dataset.id = id;
        a.dataset.action = 'clearLink';
        a.append((() => {
          const span = document.createElement('span');
          span.classList.add('fas', 'fa-times');
          return span;
        })());
        return a;
      })());
      item.append((() => {
        const span = document.createElement('span');
        span.classList.add('text');
        span.textContent = name;
        return span;
      })());
      return item;
    }

    /**
     * @param id An ID.
     */
    getIconHtml(id) {
      // noinspection BadExpressionStatementJS
      id;
      return this.iconHtml;
    }

    /**
     * Get an item HTML for detail mode.
     *
     * @param id An ID.
     * @param name A name.
     */
    getDetailLinkHtml(id, name) {
      var _this$nameHash2, _$a$get;
      // Do not use the `html` method to avoid XSS.

      name = name ?? ((_this$nameHash2 = this.nameHash) === null || _this$nameHash2 === void 0 ? void 0 : _this$nameHash2[id]) ?? id;
      if (!name && id) {
        name = this.translate(this.foreignScope, 'scopeNames');
      }
      const iconHtml = this.isDetailMode() ? this.getIconHtml(id) : '';
      const $a = $('<a>').attr('href', this.getUrl(id)).attr('data-id', id).text(name);
      if (this.mode === this.MODE_LIST) {
        $a.addClass('text-default');
      } else {
        $a.addClass(this.linkClass ?? 'text-record');
      }
      if (iconHtml) {
        $a.prepend(iconHtml);
      }
      return (_$a$get = $a.get(0)) === null || _$a$get === void 0 ? void 0 : _$a$get.outerHTML;
    }

    /**
     * @param id An ID.
     */
    getUrl(id) {
      return `#${this.foreignScope}/view/${id}`;
    }
    getValueForDisplay() {
      if (!this.isDetailMode() && !this.isListMode()) {
        return null;
      }
      if (this.mode === this.MODE_LIST_LINK) {
        const div = document.createElement('div');
        (this.ids ?? []).forEach(id => {
          var _this$nameHash3;
          const itemDiv = document.createElement('div');
          itemDiv.classList.add('link-multiple-item');
          itemDiv.textContent = ((_this$nameHash3 = this.nameHash) === null || _this$nameHash3 === void 0 ? void 0 : _this$nameHash3[id]) ?? id;
          div.append(itemDiv);
        });
        return div.outerHTML;
      }
      const itemList = [];
      (this.ids ?? []).forEach(id => {
        itemList.push(this.getDetailLinkHtml(id));
      });
      if (!itemList.length) {
        return null;
      }
      return itemList.map(item => $('<div>').addClass('link-multiple-item').html(item).wrap('<div />').parent().html()).join('');
    }

    /** @inheritDoc */
    validateRequired() {
      if (!this.isRequired()) {
        return false;
      }
      const idList = this.model.get(this.idsName) || [];
      if (idList.length === 0) {
        const msg = this.translate('fieldIsRequired', 'messages').replace('{field}', this.getLabelText());
        this.showValidationMessage(msg);
        return true;
      }
      return false;
    }

    // noinspection JSUnusedGlobalSymbols
    validateMaxCount() {
      const maxCount = this.params.maxCount;
      if (!maxCount) {
        return false;
      }
      const idList = this.model.get(this.idsName) || [];
      if (idList.length === 0) {
        return false;
      }
      if (idList.length <= maxCount) {
        return false;
      }
      const msg = this.translate('fieldExceedsMaxCount', 'messages').replace('{field}', this.getLabelText()).replace('{maxCount}', maxCount.toString());
      this.showValidationMessage(msg);
      return true;
    }
    fetch() {
      const data = {};
      data[this.idsName] = Espo.Utils.clone(this.ids);
      data[this.nameHashName] = Espo.Utils.clone(this.nameHash);
      return data;
    }
    fetchFromDom() {
      this.ids = [];
      const items = this.element.querySelectorAll('.link-container > *');
      for (const item of items) {
        const id = item.dataset.id;
        if (!id) {
          return;
        }
        this.ids.push(id);
      }
    }
    fetchSearch() {
      const type = this.$el.find('select.search-type').val();
      const idList = this.ids ?? [];
      if (['anyOf', 'allOf', 'noneOf'].includes(type) && !idList.length) {
        return {
          type: 'isNotNull',
          attribute: 'id',
          data: {
            type: type
          }
        };
      }
      let data;
      if (type === 'anyOf') {
        data = {
          type: 'linkedWith',
          value: idList,
          data: {
            type: type,
            nameHash: this.nameHash
          }
        };
        return data;
      }
      if (type === 'allOf') {
        data = {
          type: 'linkedWithAll',
          value: idList,
          data: {
            type: type,
            nameHash: this.nameHash
          }
        };
        if (!idList.length) {
          data.value = null;
        }
        return data;
      }
      if (type === 'noneOf') {
        data = {
          type: 'notLinkedWith',
          value: idList,
          data: {
            type: type,
            nameHash: this.nameHash
          }
        };
        return data;
      }
      if (type === 'isEmpty') {
        data = {
          type: 'isNotLinked',
          data: {
            type: type
          }
        };
        return data;
      }
      if (type === 'isNotEmpty') {
        data = {
          type: 'isLinked',
          data: {
            type: type
          }
        };
        return data;
      }
      return null;
    }
    getSearchType() {
      var _this$searchParams3, _this$searchParams4;
      return this.getSearchParamsData().type ?? ((_this$searchParams3 = this.searchParams) === null || _this$searchParams3 === void 0 ? void 0 : _this$searchParams3.typeFront) ?? ((_this$searchParams4 = this.searchParams) === null || _this$searchParams4 === void 0 ? void 0 : _this$searchParams4.type) ?? 'anyOf';
    }
    quickView(id) {
      const entityType = this.foreignScope;
      const helper = new _recordModal.default();
      helper.showDetail(this, {
        id: id,
        entityType: entityType
      });
    }
    async actionSelect() {
      _ui.default.notifyWait();
      const viewName = this.panelDefs.selectModalView ?? this.getMetadata().get(`clientDefs.${this.foreignScope}.modalViews.select`) ?? this.selectRecordsView;
      const mandatorySelectAttributeList = this.mandatorySelectAttributeList || this.panelDefs.selectMandatoryAttributeList;
      const createButton = this.isEditMode() && (!this.createDisabled && !this.panelDefs.createDisabled || this.forceCreateButton);
      const createAttributesProvider = createButton ? this.getCreateAttributesProvider() : null;
      const filters = await this._getSelectFilters();
      const orderBy = filters.orderBy || this.panelDefs.selectOrderBy;
      const orderDirection = filters.orderBy ? filters.order : this.panelDefs.selectOrderDirection;
      const options = {
        entityType: this.foreignScope,
        createButton: createButton,
        filters: filters.advanced,
        boolFilterList: filters.bool,
        primaryFilterName: filters.primary,
        filterList: this.getSelectFilterList(),
        multiple: true,
        mandatorySelectAttributeList: mandatorySelectAttributeList,
        forceSelectAllAttributes: this.forceSelectAllAttributes,
        createAttributesProvider: createAttributesProvider,
        layoutName: this.panelDefs.selectLayout,
        orderBy: orderBy,
        orderDirection: orderDirection,
        onSelect: models => {
          this.select(models);
        }
      };
      const view = await this.createView('modal', viewName, options);
      await view.render();
      _ui.default.notify();
    }
    getCreateAttributesProvider() {
      return () => {
        const attributes = this.getCreateAttributes() ?? {};
        if (!this.panelDefs.createHandler) {
          return Promise.resolve(attributes);
        }
        return new Promise(async resolve => {
          const handler = this.panelDefs.createHandler;
          const Handler = await Espo.loader.requirePromise(handler);
          const handlerInstance = new Handler(this.getHelper());
          const additionalAttributes = await handlerInstance.getAttributes(this.model, this.name);
          resolve({
            ...attributes,
            ...additionalAttributes
          });
        });
      };
    }

    /**
     * On records select.
     *
     * @since 8.0.4
     */
    select(models) {
      models.forEach(model => {
        this.addLink(model.id, model.attributes.name);
      });
    }
    _getSelectFilters() {
      const handler = this.panelDefs.selectHandler;
      const localBoolFilterList = this.getSelectBoolFilterList();
      if (!handler || this.isSearchMode()) {
        const boolFilterList = localBoolFilterList || this.panelDefs.selectBoolFilterList ? [...(localBoolFilterList ?? []), ...(this.panelDefs.selectBoolFilterList ?? [])] : undefined;
        const advanced = {
          ...(this.getSelectFilters() ?? {}),
          ...(!this.isSearchMode() ? this._getCascadingFilters() : {})
        };
        return Promise.resolve({
          primary: this.getSelectPrimaryFilterName() ?? this.panelDefs.selectPrimaryFilterName,
          bool: boolFilterList,
          advanced: advanced
        });
      }
      return new Promise(async resolve => {
        const Handler = await Espo.loader.requirePromise(handler);
        const filters = await new Handler(this.getHelper()).getFilters(this.model);
        const advanced = {
          ...(this.getSelectFilters() || {}),
          ...(filters.advanced || {}),
          ...this._getCascadingFilters()
        };
        const primaryFilter = this.getSelectPrimaryFilterName() || filters.primary || this.panelDefs.selectPrimaryFilterName;
        const boolFilterList = localBoolFilterList || filters.bool || this.panelDefs.selectBoolFilterList ? [...(localBoolFilterList ?? []), ...(filters.bool ?? []), ...(this.panelDefs.selectBoolFilterList ?? [])] : undefined;
        resolve({
          bool: boolFilterList,
          primary: primaryFilter,
          advanced: advanced
        });
      });
    }
    async actionCreateLink() {
      const helper = new _recordModal.default();
      const attributes = await this.getCreateAttributesProvider()();
      await helper.showCreate(this, {
        entityType: this.foreignScope,
        fullFormDisabled: true,
        attributes: attributes,
        afterSave: model => this.select([model])
      });
    }
    _transformAutocompleteResult(response) {
      const list = [];
      response.list.forEach(item => {
        list.push({
          id: item.id,
          name: item.name || item.id,
          data: item.id,
          value: item.name || item.id,
          attributes: item
        });
      });
      return list;
    }

    /**
     * Get an empty autocomplete result.
     */
    getOnEmptyAutocomplete() {
      return null;
    }
    _createCascadeLinksHelper() {
      var _this$options$cascadi;
      const items = ((_this$options$cascadi = this.options.cascadingLogic) === null || _this$options$cascadi === void 0 ? void 0 : _this$options$cascadi.items) ?? [];
      if (!items.length) {
        return null;
      }
      if (!this.foreignScope) {
        return null;
      }
      return new _cascadeLinks.default({
        model: this.model,
        foreignEntityType: this.foreignScope,
        items: items
      });
    }
    _getCascadingFilters() {
      var _this$_createCascadeL;
      return ((_this$_createCascadeL = this._createCascadeLinksHelper()) === null || _this$_createCascadeL === void 0 ? void 0 : _this$_createCascadeL.prepareFilters()) ?? {};
    }
    _getCascadingCreateAttributes() {
      var _this$_createCascadeL2;
      return ((_this$_createCascadeL2 = this._createCascadeLinksHelper()) === null || _this$_createCascadeL2 === void 0 ? void 0 : _this$_createCascadeL2.prepareCreateAttributes()) ?? {};
    }
    onAuxClickLink(e, target) {
      if (!this.isReadMode()) {
        return;
      }
      const isCombination = e.button === 1 && (e.ctrlKey || e.metaKey);
      if (!isCombination) {
        return;
      }
      const id = target.dataset.id;
      if (!id) {
        return;
      }
      e.preventDefault();
      e.stopPropagation();
      this.quickView(id);
    }
  }
  var _default = _exports.default = LinkMultipleFieldView;
});

define("views/fields/foreign-enum", ["exports", "views/fields/enum", "helpers/misc/foreign-field"], function (_exports, _enum, _foreignField) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _enum = _interopRequireDefault(_enum);
  _foreignField = _interopRequireDefault(_foreignField);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ForeignEnumFieldView extends _enum.default {
    type = 'foreign';

    /**
     * @private
     * @type {string}
     */
    foreignEntityType;
    setup() {
      const helper = new _foreignField.default(this);
      const foreignParams = helper.getForeignParams();
      for (const param in foreignParams) {
        this.params[param] = foreignParams[param];
      }
      this.foreignEntityType = helper.getEntityType();
      super.setup();
    }
    setupOptions() {
      const field = this.params.field;
      const link = this.params.link;
      if (!field || !link) {
        return;
      }
      let optionsPath = this.params.optionsPath;
      const optionsReference = this.params.optionsReference;
      let options = this.params.options;
      let style = this.params.style;
      let sourceEntityType = this.foreignEntityType;
      let sourceField = field;
      if (!optionsPath && optionsReference) {
        const [refEntityType, refField] = optionsReference.split('.');
        optionsPath = `entityDefs.${refEntityType}.fields.${refField}.options`;
        sourceEntityType = refEntityType;
        sourceField = field;
        style = this.getMetadata().get(`entityDefs.${sourceEntityType}.fields.${sourceField}.style`) ?? {};
      }
      if (optionsPath) {
        options = this.getMetadata().get(optionsPath);
      }
      this.params.options = Espo.Utils.clone(options) ?? [];
      this.styleMap = style ?? {};
      const pairs = this.params.options.map(item => [item, this.getLanguage().translateOption(item, sourceField, sourceEntityType)]);
      this.translatedOptions = Object.fromEntries(pairs);
    }
  }
  var _default = _exports.default = ForeignEnumFieldView;
});

define("views/fields/datetime", ["exports", "views/fields/date", "moment", "jquery"], function (_exports, _date, _moment, _jquery) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _date = _interopRequireDefault(_date);
  _moment = _interopRequireDefault(_moment);
  _jquery = _interopRequireDefault(_jquery);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/fields/datetime */

  const $ = _jquery.default;
  /**
   * A date-time field.
   */
  class DatetimeFieldView extends _date.default {
    type = 'datetime';
    editTemplate = 'fields/datetime/edit';
    validations = ['required', 'datetime', 'after', 'before'];
    searchTypeList = ['lastSevenDays', 'ever', 'isEmpty', 'currentMonth', 'lastMonth', 'nextMonth', 'currentQuarter', 'lastQuarter', 'currentYear', 'lastYear', 'today', 'past', 'future', 'lastXDays', 'nextXDays', 'olderThanXDays', 'afterXDays', 'on', 'after', 'before', 'between'];
    timeFormatMap = {
      'HH:mm': 'H:i',
      'hh:mm A': 'h:i A',
      'hh:mm a': 'h:i a',
      'hh:mmA': 'h:iA',
      'hh:mma': 'h:ia'
    };

    /** @internal */
    $date = null;
    /** @internal */
    $time = null;
    data() {
      const data = super.data();
      data.date = data.time = '';
      const value = this.getDateTime().toDisplay(this.model.get(this.name));
      if (value) {
        const pair = this.splitDatetime(value);
        data.date = pair[0];
        data.time = pair[1];
      }
      return data;
    }
    getDateStringValue() {
      if (this.mode === this.MODE_DETAIL && !this.model.has(this.name)) {
        return -1;
      }
      const value = this.model.get(this.name);
      if (!value) {
        if (this.mode === this.MODE_EDIT || this.mode === this.MODE_SEARCH || this.mode === this.MODE_LIST || this.mode === this.MODE_LIST_LINK) {
          return '';
        }
        return null;
      }
      if (this.mode === this.MODE_LIST || this.mode === this.MODE_DETAIL || this.mode === this.MODE_LIST_LINK) {
        if (this.getConfig().get('readableDateFormatDisabled') || this.params.useNumericFormat) {
          return this.getDateTime().toDisplay(value);
        }
        let timeFormat = this.getDateTime().timeFormat;
        if (this.params.hasSeconds) {
          timeFormat = timeFormat.replace(/:mm/, ':mm:ss');
        }
        const d = this.getDateTime().toMoment(value);
        // @ts-ignore
        const now = (0, _moment.default)().tz(this.getDateTime().timeZone || 'UTC');
        const dt = now.clone().startOf('day');
        const ranges = {
          'today': [dt.unix(), dt.add(1, 'days').unix()],
          'tomorrow': [dt.unix(), dt.add(1, 'days').unix()],
          'yesterday': [dt.add(-3, 'days').unix(), dt.add(1, 'days').unix()]
        };
        if (d.unix() >= ranges['today'][0] && d.unix() < ranges['today'][1]) {
          return this.translate('Today') + ' ' + d.format(timeFormat);
        }
        if (d.unix() > ranges['tomorrow'][0] && d.unix() < ranges['tomorrow'][1]) {
          return this.translate('Tomorrow') + ' ' + d.format(timeFormat);
        }
        if (d.unix() > ranges['yesterday'][0] && d.unix() < ranges['yesterday'][1]) {
          return this.translate('Yesterday') + ' ' + d.format(timeFormat);
        }
        const readableFormat = this.getDateTime().getReadableDateFormat();
        if (d.format('YYYY') === now.format('YYYY')) {
          return d.format(readableFormat) + ' ' + d.format(timeFormat);
        }
        return d.format(readableFormat + ', YYYY') + ' ' + d.format(timeFormat);
      }
      return this.getDateTime().toDisplay(value);
    }
    initTimepicker() {
      const $time = this.$time;
      const modalBodyElement = this.element.closest('.modal-body');

      // @ts-ignore
      $time.timepicker({
        step: this.params.minuteStep || 30,
        scrollDefaultNow: true,
        timeFormat: this.timeFormatMap[this.getDateTime().timeFormat],
        appendTo: modalBodyElement ? $(modalBodyElement) : 'body'
      });
      $time === null || $time === void 0 || $time.parent().find('button.time-picker-btn').on('click', () => {
        // @ts-ignore
        $time.timepicker('show');
      });
    }
    setDefaultTime() {
      const dtString = (0, _moment.default)('2014-01-01 00:00').format(this.getDateTime().getDateTimeFormat()) || '';
      const pair = this.splitDatetime(dtString);
      if (pair.length === 2) {
        var _this$$time;
        (_this$$time = this.$time) === null || _this$$time === void 0 || _this$$time.val(pair[1]);
      }
    }
    splitDatetime(value) {
      const m = (0, _moment.default)(value, this.getDateTime().getDateTimeFormat());
      const dateValue = m.format(this.getDateTime().getDateFormat());
      const timeValue = value.substring(dateValue.length + 1);
      return [dateValue, timeValue];
    }
    setup() {
      super.setup();
      this.on('remove', () => this.destroyTimepicker());
      this.on('mode-changed', () => this.destroyTimepicker());
    }
    destroyTimepicker() {
      if (this.$time && this.$time[0]) {
        // @ts-ignore
        this.$time.timepicker('remove');
      }
    }
    afterRender() {
      var _this$$element;
      super.afterRender();
      if (this.mode !== this.MODE_EDIT) {
        return;
      }
      this.$date = this.$element;
      const $time = this.$time = this.$el.find('input.time-part');
      this.initTimepicker();
      (_this$$element = this.$element) === null || _this$$element === void 0 || _this$$element.on('change.datetime', () => {
        var _this$$element2;
        if ((_this$$element2 = this.$element) !== null && _this$$element2 !== void 0 && _this$$element2.val() && !$time.val()) {
          this.setDefaultTime();
          this.trigger('change');
        }
      });
      let timeout = false;
      let isTimeFormatError = false;
      let previousValue = $time.val();
      $time.on('change', () => {
        if (!timeout) {
          var _this$$date;
          if (isTimeFormatError) {
            $time.val(previousValue);
            return;
          }
          if (this.noneOption && $time.val() === '' && ((_this$$date = this.$date) === null || _this$$date === void 0 ? void 0 : _this$$date.val()) !== '') {
            $time.val(this.noneOption);
            return;
          }
          this.trigger('change');
          previousValue = $time.val();
        }
        timeout = true;
        setTimeout(() => timeout = false, 100);
      });
      $time.on('timeFormatError', () => {
        isTimeFormatError = true;
        setTimeout(() => isTimeFormatError = false, 50);
      });
    }
    parse(string) {
      if (!string) {
        return null;
      }
      return this.getDateTime().fromDisplay(string);
    }
    fetch() {
      var _this$$date2, _this$$time2;
      const data = {};
      const date = (_this$$date2 = this.$date) === null || _this$$date2 === void 0 ? void 0 : _this$$date2.val();
      const time = (_this$$time2 = this.$time) === null || _this$$time2 === void 0 ? void 0 : _this$$time2.val();
      let value = null;
      if (date !== '' && time !== '') {
        value = this.parse(date + ' ' + time);
      }
      data[this.name] = value;
      return data;
    }

    // noinspection JSUnusedGlobalSymbols
    validateDatetime() {
      if (this.model.get(this.name) === -1) {
        const msg = this.translate('fieldShouldBeDatetime', 'messages').replace('{field}', this.getLabelText());
        this.showValidationMessage(msg);
        return true;
      }
      return false;
    }
    fetchSearch() {
      const data = super.fetchSearch();
      if (data) {
        data.dateTime = true;
        delete data.date;
      }
      return data;
    }

    /**
     * Not implemented. For datetimeOptions too.
     * When implementing, keep in mind the duration field.
     */
    onAfterChange() {}
  }
  var _default = _exports.default = DatetimeFieldView;
});

define("views/fields/currency", ["exports", "views/fields/float", "ui/select"], function (_exports, _float, _select) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _float = _interopRequireDefault(_float);
  _select = _interopRequireDefault(_select);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  // noinspection JSUnusedLocalSymbols

  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/fields/currency */

  /**
   * Parameters.
   */

  /**
   * Options.
   */

  /**
   * A currency field.
   */
  class CurrencyFieldView extends _float.default {
    type = 'currency';
    editTemplate = 'fields/currency/edit';
    detailTemplate = 'fields/currency/detail';
    listTemplate = 'fields/currency/list';

    // noinspection JSUnusedGlobalSymbols
    detailTemplate1 = 'fields/currency/detail-1';
    // noinspection JSUnusedGlobalSymbols
    detailTemplate2 = 'fields/currency/detail-2';
    // noinspection JSUnusedGlobalSymbols
    detailTemplate3 = 'fields/currency/detail-3';

    // noinspection JSUnusedGlobalSymbols
    listTemplate1 = 'fields/currency/list-1';
    // noinspection JSUnusedGlobalSymbols
    listTemplate2 = 'fields/currency/list-2';
    // noinspection JSUnusedGlobalSymbols
    listTemplate3 = 'fields/currency/list-3';
    detailTemplateNoCurrency = 'fields/currency/detail-no-currency';
    maxDecimalPlaces = 3;
    validations = ['required', 'number', 'range'];

    /**
     * @since 9.2.6
     */

    data() {
      const currencyValue = this.model.get(this.currencyFieldName) || this.getPreferences().get('defaultCurrency') || this.getConfig().get('defaultCurrency');
      const multipleCurrencies = !this.isSingleCurrency || currencyValue !== this.defaultCurrency;
      return {
        ...super.data(),
        currencyFieldName: this.currencyFieldName,
        currencyValue: currencyValue,
        currencyList: this.currencyList,
        currencySymbol: this.getMetadata().get(['app', 'currency', 'symbolMap', currencyValue]) || '',
        multipleCurrencies: multipleCurrencies,
        defaultCurrency: this.defaultCurrency
      };
    }
    setup() {
      super.setup();
      this.currencyFieldName = this.currencyAttribute ?? this.name + 'Currency';
      this.defaultCurrency = this.getConfig().get('defaultCurrency');
      this.currencyList = this.getConfig().get('currencyList') || [this.defaultCurrency];
      this.decimalPlaces = this.getConfig().get('currencyDecimalPlaces');
      if (typeof this.params.decimalPlaces === 'number') {
        this.decimalPlaces = this.params.decimalPlaces;
      }
      if (this.params.onlyDefaultCurrency) {
        this.currencyList = [this.defaultCurrency];
      }
      this.isSingleCurrency = this.currencyList.length <= 1;
      const currencyValue = this.model.get(this.currencyFieldName) || this.defaultCurrency;
      if (!this.currencyList.includes(currencyValue)) {
        this.currencyList = Espo.Utils.clone(this.currencyList);
        this.currencyList.push(currencyValue);
      }
    }
    setupAutoNumericOptions() {
      this.autoNumericOptions = {
        digitGroupSeparator: this.thousandSeparator || '',
        decimalCharacter: this.decimalMark,
        modifyValueOnWheel: false,
        selectOnFocus: false,
        decimalPlaces: this.decimalPlaces,
        allowDecimalPadding: true,
        showWarnings: false,
        // @ts-ignore
        formulaMode: true
      };
      if (this.decimalPlaces === null) {
        this.autoNumericOptions.decimalPlaces = this.decimalPlacesRawValue;
        this.autoNumericOptions.decimalPlacesRawValue = this.decimalPlacesRawValue;
        this.autoNumericOptions.allowDecimalPadding = false;
      }
    }
    getCurrencyFormat() {
      return this.getConfig().get('currencyFormat') || 1;
    }
    _getTemplateName() {
      if (this.mode === this.MODE_DETAIL || this.mode === this.MODE_LIST) {
        let prop;
        if (this.mode === this.MODE_LIST) {
          prop = 'listTemplate' + this.getCurrencyFormat().toString();
        } else {
          prop = 'detailTemplate' + this.getCurrencyFormat().toString();
        }
        if (this.options.hideCurrency) {
          prop = 'detailTemplateNoCurrency';
        }
        if (prop in this) {
          return this[prop];
        }
      }

      // @ts-ignore
      return super._getTemplateName();
    }
    formatNumber(value) {
      return this.formatNumberDetail(value);
    }
    formatNumberDetail(value) {
      if (value === null) {
        return '';
      }
      const currencyDecimalPlaces = this.decimalPlaces;
      if (currencyDecimalPlaces === 0) {
        value = Math.round(value);
      } else if (currencyDecimalPlaces) {
        value = Math.round(value * Math.pow(10, currencyDecimalPlaces)) / Math.pow(10, currencyDecimalPlaces);
      } else {
        value = Math.round(value * Math.pow(10, this.maxDecimalPlaces)) / Math.pow(10, this.maxDecimalPlaces);
      }
      const parts = value.toString().split('.');
      parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, this.thousandSeparator);
      if (currencyDecimalPlaces === 0) {
        return parts[0];
      } else if (currencyDecimalPlaces) {
        let decimalPartLength = 0;
        if (parts.length > 1) {
          decimalPartLength = parts[1].length;
        } else {
          parts[1] = '';
        }
        if (currencyDecimalPlaces && decimalPartLength < currencyDecimalPlaces) {
          const limit = currencyDecimalPlaces - decimalPartLength;
          for (let i = 0; i < limit; i++) {
            parts[1] += '0';
          }
        }
      }
      return parts.join(this.decimalMark);
    }
    parse(input) {
      let value = input !== '' ? input : null;
      if (value === null) {
        return null;
      }
      value = value.split(this.thousandSeparator).join('');
      value = value.split(this.decimalMark).join('.');
      if (this.params.decimal) {
        // @todo Obtain default scale.
        const scale = this.params.scale || 4;
        const parts = value.split('.');
        const decimalPart = parts[1] || '';
        if (decimalPart.length < scale) {
          value = parts[0] + '.' + decimalPart.padEnd(scale, '0');
        }
      }
      if (this.params.decimal) {
        return value;
      }
      return parseFloat(value);
    }
    afterRender() {
      super.afterRender();
      if (this.mode === this.MODE_EDIT) {
        this.$currency = this.$el.find(`[data-name="${this.currencyFieldName}"]`);
        if (this.$currency.length) {
          this.$currency.on('change', () => {
            this.model.set(this.currencyFieldName, this.$currency.val(), {
              ui: true
            });
          });
          _select.default.init(this.$currency);
        }
      }
    }

    // noinspection JSUnusedGlobalSymbols
    validateNumber() {
      if (!this.params.decimal) {
        return this.validateFloat();
      }
      const value = this.model.get(this.name);
      if (Number.isNaN(Number(value))) {
        const msg = this.translate('fieldShouldBeNumber', 'messages').replace('{field}', this.getLabelText());
        this.showValidationMessage(msg);
        return true;
      }
      return false;
    }
    fetch() {
      var _this$$element;
      const valueString = (((_this$$element = this.$element) === null || _this$$element === void 0 ? void 0 : _this$$element.val()) ?? '').trim();
      const value = this.parse(valueString);
      const data = {};
      let currencyValue = this.$currency.length ? this.$currency.val() : this.defaultCurrency;
      if (value === null) {
        currencyValue = null;
      }
      data[this.name] = value;
      data[this.currencyFieldName] = currencyValue;
      return data;
    }
  }
  var _default = _exports.default = CurrencyFieldView;
});

define("views/fields/bool", ["exports", "views/fields/base", "ui/select"], function (_exports, _base, _select) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  _select = _interopRequireDefault(_select);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/fields/bool */

  /**
   * A boolean field (checkbox).
   */
  class BoolFieldView extends _base.default {
    type = 'bool';
    listTemplate = 'fields/bool/list';
    detailTemplate = 'fields/bool/detail';
    editTemplate = 'fields/bool/edit';
    searchTemplate = 'fields/bool/search';
    validations = [];
    initialSearchIsNotIdle = true;
    data() {
      const data = super.data();
      data.valueIsSet = this.model.has(this.name);
      return data;
    }
    afterRender() {
      super.afterRender();
      if (this.mode === this.MODE_SEARCH && this.$element) {
        this.$element.on('change', () => {
          this.trigger('change');
        });
        _select.default.init(this.$element);
      }
    }
    fetch() {
      const element = this.mainInputElement;
      const value = element === null || element === void 0 ? void 0 : element.checked;
      const data = {};
      data[this.name] = value;
      return data;
    }
    fetchSearch() {
      var _this$$element;
      const type = (_this$$element = this.$element) === null || _this$$element === void 0 ? void 0 : _this$$element.val();
      if (!type) {
        return null;
      }
      if (type === 'any') {
        return {
          type: 'or',
          value: [{
            type: 'isTrue',
            attribute: this.name
          }, {
            type: 'isFalse',
            attribute: this.name
          }],
          data: {
            type: type
          }
        };
      }
      return {
        type: type,
        data: {
          type: type
        }
      };
    }
    getSearchType() {
      var _this$searchParams;
      return this.getSearchParamsData().type ?? ((_this$searchParams = this.searchParams) === null || _this$searchParams === void 0 ? void 0 : _this$searchParams.type) ?? 'isTrue';
    }
  }
  _exports.default = BoolFieldView;
});

define("views/fields/attachment-multiple", ["exports", "views/fields/base", "helpers/file-upload", "helpers/misc/attachment-insert-from-source", "utils"], function (_exports, _base, _fileUpload, _attachmentInsertFromSource, _utils) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  _fileUpload = _interopRequireDefault(_fileUpload);
  _attachmentInsertFromSource = _interopRequireDefault(_attachmentInsertFromSource);
  _utils = _interopRequireDefault(_utils);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * An attachment-multiple field.
   */
  class AttachmentMultipleFieldView extends _base.default {
    type = 'attachmentMultiple';
    listTemplate = 'fields/attachments-multiple/list';
    detailTemplate = 'fields/attachments-multiple/detail';
    editTemplate = 'fields/attachments-multiple/edit';
    searchTemplate = 'fields/link-multiple/search';
    previewSize = 'medium';
    accept = null;
    showPreviews = true;
    showPreviewsInListMode = false;

    /**
     * @internal
     */
    initialSearchIsNotIdle = true;
    validations = ['ready', 'required', 'maxCount'];
    searchTypeList = ['isNotEmpty', 'isEmpty'];
    isUploading = false;
    data() {
      const ids = this.model.get(this.idsName);
      const data = {
        ...super.data(),
        idValues: this.model.get(this.idsName),
        idValuesString: ids ? ids.join(',') : '',
        nameHash: this.model.get(this.nameHashName),
        foreignScope: this.foreignScope,
        valueIsSet: this.model.has(this.idsName),
        acceptAttribute: this.acceptAttribute
      };
      if (this.mode === this.MODE_EDIT) {
        data.fileSystem = this.sourceList.includes('FileSystem');
        data.sourceList = this.sourceList;
      }

      // noinspection JSValidateTypes
      return data;
    }
    setup() {
      this.addHandler('click', 'a.remove-attachment', (_e, target) => this.removeAttachmentHandler(target));
      this.addHandler('change', 'input.file', (_e, target) => this.changeFileHandler(target));
      this.addActionHandler('insertFromSource', (_e, target) => this.insertFromSource(target.dataset.name));
      this.addActionHandler('showImagePreview', (e, target) => this.showImagePreviewHandler(e, target));
      this.addHandler('keydown', 'label.attach-file-label', e => this.keydownAttachFileLabelHandler(e));
      this.nameHashName = this.name + 'Names';
      this.typeHashName = this.name + 'Types';
      this.idsName = this.name + 'Ids';
      this.foreignScope = 'Attachment';
      this.previewSize = this.options.previewSize || this.params.previewSize || this.previewSize;
      this.previewTypeList = this.getMetadata().get(['app', 'image', 'previewFileTypeList']) || [];
      this.imageSizes = this.getMetadata().get(['app', 'image', 'sizes']) || {};
      this.nameHash = _utils.default.clone(this.model.get(this.nameHashName) ?? {});
      if ('showPreviews' in this.params) {
        this.showPreviews = this.params.showPreviews;
      }
      if ('accept' in this.params) {
        this.accept = this.params.accept;
      }
      if (this.accept && this.accept.length) {
        this.acceptAttribute = this.accept.join(', ');
      }
      const sourceDefs = this.getMetadata().get(['clientDefs', 'Attachment', 'sourceDefs']) || {};
      this.sourceList = Espo.Utils.clone(this.params.sourceList || []);
      this.sourceList = this.sourceList.concat(this.getMetadata().get(['clientDefs', 'Attachment', 'generalSourceList']) || []).filter((item, i, self) => {
        return self.indexOf(item) === i;
      }).filter(item => {
        const defs = sourceDefs[item] || {};
        if (defs.accessDataList) {
          if (!Espo.Utils.checkAccessDataList(defs.accessDataList, this.getAcl(), this.getUser())) {
            return false;
          }
        }
        if (defs.configCheck) {
          const arr = defs.configCheck.split('.');
          if (!this.getConfig().getByPath(arr)) {
            return false;
          }
        }
        return true;
      });
      this.listenTo(this.model, 'change:' + this.nameHashName, () => {
        this.nameHash = _utils.default.clone(this.model.get(this.nameHashName) ?? {});
      });
      this.on('remove', () => {
        if (this.resizeIsBeingListened) {
          $(window).off('resize.' + this.cid);
        }
        this.uploadedIdMap = {};
      });
      this.on('inline-edit-off', () => {
        this.isUploading = false;
      });
      if (this.recordHelper) {
        this.listenTo(this.recordHelper, `upload-files:${this.name}`, files => {
          if (!this.isEditMode()) {
            return;
          }
          this.uploadFiles(files);
        });
      }
      this.uploadedIdMap = {};
    }
    keydownAttachFileLabelHandler(e) {
      const key = Espo.Utils.getKeyFromKeyEvent(e);
      if (key === 'Enter') {
        const element = this.$el.find('input.file').get(0);
        element.click();
      }
    }
    showImagePreviewHandler(e, target) {
      e.preventDefault();
      const id = target.dataset.id;
      const attachmentIdList = this.model.get(this.idsName) || [];
      const typeHash = this.model.get(this.typeHashName) || {};
      const imageIdList = [];
      attachmentIdList.forEach(cId => {
        if (!this.isTypeIsImage(typeHash[cId])) {
          return;
        }
        imageIdList.push(cId);
      });
      const imageList = [];
      imageIdList.forEach(cId => {
        imageList.push({
          id: cId,
          name: this.nameHash[cId]
        });
      });
      this.createView('preview', 'views/modals/image-preview', {
        id: id,
        model: this.model,
        name: this.nameHash[id],
        imageList: imageList
      }).then(view => {
        view.render();
      });
    }
    changeFileHandler(input) {
      const files = input.files;
      this.uploadFiles(files);
      input.value = '';

      // Note: Event listeners are not cloned.
      const newInput = input.cloneNode(true);
      input.replaceWith(newInput);
    }
    removeAttachmentHandler(target) {
      var _div$parentElement;
      const div = target.parentElement;
      const id = div === null || div === void 0 ? void 0 : div.dataset.id;
      if (id) {
        this.deleteAttachment(id);
      }
      div === null || div === void 0 || (_div$parentElement = div.parentElement) === null || _div$parentElement === void 0 || _div$parentElement.remove();
      const input = this.element.querySelector('input.file');
      if (input) {
        input.value = '';
      }
      setTimeout(() => this.focusOnUploadButton(), 10);
    }
    setupSearch() {
      this.addHandler('change', 'select.search-type', (_e, target) => {
        this.handleSearchType(target.value);
        this.trigger('change');
      });
    }
    focusOnInlineEdit() {
      this.focusOnUploadButton();
    }
    focusOnUploadButton() {
      this.$el.find('.attach-file-label').focus();
    }
    empty() {
      this.clearIds();
      this.$attachments.empty();
    }
    handleResize() {
      const width = this.$el.width();
      this.$el.find('img.image-preview').css('maxWidth', width + 'px');
    }
    deleteAttachment(id) {
      this.removeId(id);
      if (this.model.isNew()) {
        this.getModelFactory().create('Attachment').then(attachment => {
          attachment.id = id;
          attachment.destroy();
        });
      }
    }
    getImageUrl(id, size) {
      let url = `${this.getBasePath()}?entryPoint=image&id=${id}`;
      if (size) {
        url += '&size=' + size;
      }
      if (this.getUser().get('portalId')) {
        url += '&portalId=' + this.getUser().get('portalId');
      }
      return url;
    }
    getDownloadUrl(id) {
      let url = `${this.getBasePath()}?entryPoint=download&id=${id}`;
      if (this.getUser().get('portalId')) {
        url += '&portalId=' + this.getUser().get('portalId');
      }
      return url;
    }
    removeId(id) {
      const arr = _utils.default.clone(this.model.get(this.idsName) ?? []);
      const i = arr.indexOf(id);
      arr.splice(i, 1);
      this.model.set(this.idsName, arr);
      const nameHash = _utils.default.clone(this.model.get(this.nameHashName) ?? {});
      delete nameHash[id];
      this.model.set(this.nameHashName, nameHash);
      const typeHash = _utils.default.clone(this.model.get(this.typeHashName) ?? {});
      delete typeHash[id];
      this.model.set(this.typeHashName, typeHash);
    }
    clearIds(silent) {
      silent = silent || false;
      this.model.set(this.idsName, [], {
        silent: silent
      });
      this.model.set(this.nameHashName, {}, {
        silent: silent
      });
      this.model.set(this.typeHashName, {}, {
        silent: silent
      });
    }
    pushAttachment(attachment, ui) {
      const arr = _utils.default.clone(this.model.get(this.idsName) ?? []);
      arr.push(attachment.id);
      this.model.set(this.idsName, arr, {
        ui: ui
      });
      const typeHash = _utils.default.clone(this.model.get(this.typeHashName) ?? {});
      typeHash[attachment.id] = attachment.get('type');
      this.model.set(this.typeHashName, typeHash, {
        ui: ui
      });
      const nameHash = _utils.default.clone(this.model.get(this.nameHashName) ?? {});
      nameHash[attachment.id] = attachment.get('name');
      this.model.set(this.nameHashName, nameHash, {
        ui: ui
      });
      this.uploadedIdMap[attachment.id] = true;
    }
    getEditPreview(name, type, id) {
      var _$$attr$attr$attr$att;
      if (!this.previewTypeList.includes(type)) {
        return null;
      }
      const size = id in this.uploadedIdMap ? undefined : 'small';

      // noinspection HtmlRequiredAltAttribute,RequiredAttributes
      return (_$$attr$attr$attr$att = $('<img>').attr('src', this.getImageUrl(id, size)).attr('title', name).attr('alt', name).attr('draggable', 'false').css({
        maxWidth: (this.imageSizes['small'] || {})[0],
        maxHeight: (this.imageSizes['small'] || {})[1]
      }).get(0)) === null || _$$attr$attr$attr$att === void 0 ? void 0 : _$$attr$attr$attr$att.outerHTML;
    }
    getBoxPreviewHtml(name, type, id) {
      var _$$attr$attr$text$get;
      const $text = $('<span>').text(name);
      if (!id) {
        var _$text$get;
        return (_$text$get = $text.get(0)) === null || _$text$get === void 0 ? void 0 : _$text$get.outerHTML;
      }
      if (this.showPreviews) {
        const html = this.getEditPreview(name, type, id);
        if (html) {
          return html;
        }
      }
      const url = this.getBasePath() + '?entryPoint=download&id=' + id;
      return (_$$attr$attr$text$get = $('<a>').attr('href', url).attr('target', '_BLANK').text(name).get(0)) === null || _$$attr$attr$text$get === void 0 ? void 0 : _$$attr$attr$text$get.outerHTML;
    }
    addAttachmentBox(name, type, id) {
      const $attachments = this.$attachments;
      const $remove = $('<a>').attr('role', 'button').attr('tabindex', '0').addClass('remove-attachment pull-right').append($('<span>').addClass('fas fa-times'));
      const previewHtml = this.getBoxPreviewHtml(name, type, id);
      const $att = $('<div>').addClass('gray-box').append($remove).append($('<span>').addClass('preview').append($(previewHtml)));
      const $container = $('<div>').append($att);
      $attachments.append($container);
      if (id) {
        $att.attr('data-id', id);
        return $att;
      }
      const $loading = $('<span>').addClass('small uploading-message').text(this.translate('Uploading...'));
      $container.append($loading);
      $att.on('ready', () => {
        $loading.html(this.translate('Ready'));
        const id = $att.attr('data-id');
        const previewHtml = this.getBoxPreviewHtml(name, type, id);
        $att.find('.preview').html(previewHtml);
        if ($att.find('.preview').find('img').length) {
          $loading.remove();
        }
      });
      return $att;
    }
    showValidationMessage(msg, selector, view) {
      const $label = this.$el.find('label');
      const title = $label.attr('title');
      $label.attr('title', '');
      super.showValidationMessage(msg, selector, view);
      $label.attr('title', title);
    }
    getMaxFileSize() {
      let maxFileSize = this.params.maxFileSize || 0;
      const noChunk = !this.getConfig().get('attachmentUploadChunkSize');
      const attachmentUploadMaxSize = this.getConfig().get('attachmentUploadMaxSize') || 0;
      const appMaxUploadSize = this.getHelper().getAppParam('maxUploadSize') || 0;
      if (!maxFileSize || maxFileSize > attachmentUploadMaxSize) {
        maxFileSize = attachmentUploadMaxSize;
      }
      if (noChunk && maxFileSize > appMaxUploadSize) {
        maxFileSize = appMaxUploadSize;
      }
      return maxFileSize;
    }

    /**
     * Upload files.
     */
    uploadFiles(files) {
      let uploadedCount = 0;
      let totalCount = 0;
      let exceedsMaxFileSize = false;
      const maxFileSize = this.getMaxFileSize();
      if (maxFileSize) {
        for (let i = 0; i < files.length; i++) {
          const file = files[i];
          if (file.size > maxFileSize * 1024 * 1024) {
            exceedsMaxFileSize = true;
          }
        }
      }
      if (exceedsMaxFileSize) {
        const msg = this.translate('fieldMaxFileSizeError', 'messages').replace('{field}', this.getLabelText()).replace('{max}', maxFileSize.toString());
        this.showValidationMessage(msg, 'label');
        return;
      }
      const fileList = [];
      for (let i = 0; i < files.length; i++) {
        fileList.push(files[i]);
        totalCount++;
      }
      this.isUploading = true;
      this.getModelFactory().create('Attachment').then(model => {
        const canceledList = [];
        const uploadedList = [];
        const uploadHelper = new _fileUpload.default();
        fileList.forEach(file => {
          const $attachmentBox = this.addAttachmentBox(file.name, file.type);
          const $uploadingMsg = $attachmentBox.parent().find('.uploading-message');
          const mediator = {};
          $attachmentBox.find('.remove-attachment').on('click.uploading', () => {
            canceledList.push(attachment.cid);
            totalCount--;
            if (uploadedCount === totalCount) {
              this.isUploading = false;
              if (totalCount) {
                this.afterAttachmentsUploaded.call(this);
              }
            }
            mediator.isCanceled = true;
          });
          const attachment = model.clone();
          attachment.set('role', 'Attachment');
          attachment.set('parentType', this.model.entityType);
          attachment.set('field', this.name);
          uploadHelper.upload(file, attachment, {
            afterChunkUpload: size => {
              const msg = Math.floor(size / file.size * 100) + '%';
              $uploadingMsg.html(msg);
            },
            afterAttachmentSave: attachment => {
              $attachmentBox.attr('data-id', attachment.id);
            },
            mediator: mediator
          }).then(() => {
            if (canceledList.indexOf(attachment.cid) !== -1) {
              return;
            }
            this.pushAttachment(attachment, true);
            $attachmentBox.attr('data-id', attachment.id);
            $attachmentBox.trigger('ready');
            uploadedCount++;
            uploadedList.push(attachment);
            if (uploadedCount === totalCount && this.isUploading) {
              this.model.trigger(`attachment-uploaded:${this.name}`, uploadedList);
              this.afterAttachmentsUploaded();
              this.isUploading = false;
              setTimeout(() => {
                if (document.activeElement && document.activeElement.tagName !== 'BODY') {
                  return;
                }
                this.focusOnUploadButton();
              }, 50);
            }
          }).catch(() => {
            if (mediator.isCanceled) {
              return;
            }
            $attachmentBox.remove();
            $uploadingMsg.remove();
            totalCount--;
            if (!totalCount) {
              this.isUploading = false;
            }
            if (uploadedCount === totalCount && this.isUploading) {
              this.isUploading = false;
              this.afterAttachmentsUploaded.call(this);
            }
          });
        });
      });
    }
    afterAttachmentsUploaded() {}
    afterRender() {
      if (this.mode === this.MODE_EDIT) {
        this.$attachments = this.$el.find('div.attachments');
        const ids = this.model.get(this.idsName) || [];
        const nameHash = this.model.get(this.nameHashName);
        const typeHash = this.model.get(this.typeHashName) || {};
        ids.forEach(id => {
          if (nameHash) {
            const name = nameHash[id];
            const type = typeHash[id] || null;
            this.addAttachmentBox(name, type, id);
          }
        });
        this.$el.off('drop');
        this.$el.off('dragover');
        this.$el.off('dragleave');
        this.$el.on('drop', e => {
          e.preventDefault();
          e.stopPropagation();
          const event = e.originalEvent;
          if (event.dataTransfer && event.dataTransfer.files && event.dataTransfer.files.length) {
            this.uploadFiles(event.dataTransfer.files);
          }
        });
        this.$el.get(0).addEventListener('dragover', e => e.preventDefault());
        this.$el.get(0).addEventListener('dragleave', e => e.preventDefault());
      }
      if (this.mode === this.MODE_SEARCH) {
        const type = this.$el.find('select.search-type').val();
        this.handleSearchType(type);
      }
      if (this.mode === this.MODE_DETAIL) {
        if (this.previewSize === 'large') {
          this.handleResize();
          this.resizeIsBeingListened = true;
          $(window).on('resize.' + this.cid, () => {
            this.handleResize();
          });
        }
      }
    }
    isTypeIsImage(type) {
      if (this.previewTypeList.includes(type)) {
        return true;
      }
      return false;
    }
    getDetailPreview(name, type, id) {
      var _$$attr$attr$attr$att2;
      if (!this.isTypeIsImage(type)) {
        var _$$text$get;
        return (_$$text$get = $('<span>').text(name).get(0)) === null || _$$text$get === void 0 ? void 0 : _$$text$get.outerHTML;
      }

      // noinspection HtmlRequiredAltAttribute,RequiredAttributes
      return (_$$attr$attr$attr$att2 = $('<a>').attr('data-action', 'showImagePreview').attr('data-id', id).attr('title', name).attr('href', this.getImageUrl(id)).append($('<img>').attr('src', this.getImageUrl(id, this.previewSize)).addClass('image-preview').attr('alt', name).css({
        maxWidth: (this.imageSizes[this.previewSize] ?? [])[0],
        maxHeight: (this.imageSizes[this.previewSize] ?? [])[1]
      })).get(0)) === null || _$$attr$attr$attr$att2 === void 0 ? void 0 : _$$attr$attr$attr$att2.outerHTML;
    }
    getValueForDisplay() {
      if (this.isDetailMode() || this.isListMode()) {
        var _$container$get;
        const nameHash = this.nameHash;
        const typeHash = this.model.get(this.typeHashName) || {};
        const ids = this.model.get(this.idsName) || [];
        const previews = [];
        const names = [];
        for (const id of ids) {
          const type = typeHash[id] || false;
          const name = nameHash[id];
          if (this.showPreviews && this.previewTypeList.includes(type) && (this.isDetailMode() || this.isListMode() && this.showPreviewsInListMode)) {
            previews.push($('<div>').addClass('attachment-preview').append(this.getDetailPreview(name, type, id)));
            continue;
          }
          names.push($('<div>').addClass('attachment-block').append($('<span>').addClass('fas fa-paperclip text-soft small'), ' ', $('<a>').attr('href', this.getDownloadUrl(id)).attr('target', '_blank').text(name)));
        }
        let containerClassName = '';
        if (this.previewSize === 'large') {
          containerClassName = 'attachment-block-container-large';
        }
        if (this.previewSize === 'small') {
          containerClassName = 'attachment-block-container-small';
        }
        if (names.length === 0 && previews.length === 0) {
          return '';
        }
        const $container = $('<div>').append($('<div>').addClass('attachment-block-container').addClass(containerClassName).append(previews)).append(names);
        return (_$container$get = $container.get(0)) === null || _$container$get === void 0 ? void 0 : _$container$get.innerHTML;
      }
    }
    insertFromSource(source) {
      const helper = new _attachmentInsertFromSource.default(this);
      helper.insert({
        source: source,
        onInsert: models => {
          models.forEach(model => this.pushAttachment(model));
        }
      });
    }
    validateRequired() {
      if (this.isRequired()) {
        if ((this.model.get(this.idsName) || []).length === 0) {
          const msg = this.translate('fieldIsRequired', 'messages').replace('{field}', this.getLabelText());
          this.showValidationMessage(msg, 'label');
          return true;
        }
      }
      return false;
    }

    // noinspection JSUnusedGlobalSymbols
    validateReady() {
      if (this.isUploading) {
        const msg = this.translate('fieldIsUploading', 'messages').replace('{field}', this.getLabelText());
        this.showValidationMessage(msg, 'label');
        return true;
      }
      return false;
    }

    // noinspection JSUnusedGlobalSymbols
    validateMaxCount() {
      const maxCount = this.params.maxCount;
      if (!maxCount) {
        return false;
      }
      const idList = this.model.get(this.idsName) || [];
      if (idList.length === 0) {
        return false;
      }
      if (idList.length <= maxCount) {
        return false;
      }
      const msg = this.translate('fieldExceedsMaxCount', 'messages').replace('{field}', this.getLabelText()).replace('{maxCount}', maxCount.toString());
      this.showValidationMessage(msg, 'label');
      return true;
    }
    fetch() {
      const data = {};
      data[this.idsName] = this.model.get(this.idsName) || [];
      return data;
    }

    // noinspection JSUnusedLocalSymbols
    handleSearchType(type) {
      // noinspection BadExpressionStatementJS
      type;
      this.$el.find('div.link-group-container').addClass('hidden');
    }
    fetchSearch() {
      const type = this.$el.find('select.search-type').val();
      if (type === 'isEmpty') {
        return {
          type: 'isNotLinked',
          data: {
            type: type
          }
        };
      }
      if (type === 'isNotEmpty') {
        return {
          type: 'isLinked',
          data: {
            type: type
          }
        };
      }
      return null;
    }
  }
  var _default = _exports.default = AttachmentMultipleFieldView;
});

define("views/fields/array", ["exports", "views/fields/base", "helpers/reg-exp-pattern", "ui/multi-select", "views/modal", "model", "views/record/edit-for-modal", "views/fields/varchar", "underscore", "jquery", "utils"], function (_exports, _base, _regExpPattern, _multiSelect, _modal, _model, _editForModal, _varchar, _underscore, _jquery, _utils) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  _regExpPattern = _interopRequireDefault(_regExpPattern);
  _multiSelect = _interopRequireDefault(_multiSelect);
  _modal = _interopRequireDefault(_modal);
  _model = _interopRequireDefault(_model);
  _editForModal = _interopRequireDefault(_editForModal);
  _varchar = _interopRequireDefault(_varchar);
  _underscore = _interopRequireDefault(_underscore);
  _jquery = _interopRequireDefault(_jquery);
  _utils = _interopRequireDefault(_utils);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  const $ = _jquery.default;

  /**
   * Parameters.
   */

  /**
   * Options.
   */

  /**
   * An array field.
   */
  class ArrayFieldView extends _base.default {
    type = 'array';
    listTemplate = 'fields/array/list';
    listLinkTemplate = 'fields/array/list-link';
    detailTemplate = 'fields/array/detail';
    editTemplate = 'fields/array/edit';
    searchTemplate = 'fields/array/search';
    searchTypeList = ['anyOf', 'noneOf', 'allOf', 'isEmpty', 'isNotEmpty'];
    maxItemLength = null;
    validations = ['required', 'maxCount'];
    MAX_ITEM_LENGTH = 100;

    /**
     * An add-item model view.
     */
    addItemModalView = 'views/modals/array-field-add';
    itemDelimiter = ':,:';
    matchAnyWord = true;
    translatedOptions = null;

    /**
     * @since 9.2.0
     */
    noDragHandle = false;
    displayAsLabel = false;
    displayAsList = false;
    originalOptionList = null;
    data() {
      const itemHtmlList = [];
      (this.selected ?? []).forEach(value => {
        itemHtmlList.push(this.getItemHtml(value || ''));
      });

      // noinspection JSValidateTypes
      return {
        ...super.data(),
        selected: this.selected,
        translatedOptions: this.translatedOptions,
        hasAdd: !!this.params.options && !this.params.keepItems,
        keepItems: this.params.keepItems,
        itemHtmlList: itemHtmlList,
        isEmpty: (this.selected || []).length === 0,
        valueIsSet: this.model.has(this.name),
        maxItemLength: this.maxItemLength || this.MAX_ITEM_LENGTH,
        allowCustomOptions: this.allowCustomOptions
      };
    }
    setup() {
      super.setup();
      this.setupFieldEvents();
      this.noEmptyString = this.params.noEmptyString ?? false;
      if (this.params.maxItemLength != null) {
        this.maxItemLength = this.params.maxItemLength;
      }
      this.maxItemLength = this.maxItemLength || this.MAX_ITEM_LENGTH;
      this.listenTo(this.model, 'change:' + this.name, () => {
        this.selected = _utils.default.clone(this.model.get(this.name)) || [];
      });
      this.selected = _utils.default.clone(this.model.get(this.name) || []);
      if (Object.prototype.toString.call(this.selected) !== '[object Array]') {
        this.selected = [];
      }
      this.styleMap = this.params.style ?? {};
      let optionsPath = this.params.optionsPath;
      const optionsReference = this.params.optionsReference;
      if (!optionsPath && optionsReference) {
        const [refEntityType, refField] = optionsReference.split('.');
        optionsPath = `entityDefs.${refEntityType}.fields.${refField}.options`;
        if (Object.keys(this.styleMap).length === 0) {
          this.styleMap = this.getMetadata().get(`entityDefs.${refEntityType}.fields.${refField}.style`) || {};
        }
      }
      if (optionsPath) {
        this.params.options = _utils.default.clone(this.getMetadata().get(optionsPath)) || [];
      }
      this.setupOptions();
      if ('translatedOptions' in this.options) {
        this.translatedOptions = this.options.translatedOptions ?? null;
      }
      if ('translatedOptions' in this.params) {
        this.translatedOptions = this.params.translatedOptions ?? null;
      }
      if (!this.translatedOptions) {
        this.setupTranslation();
      }
      this.displayAsLabel = this.params.displayAsLabel || this.displayAsLabel;
      this.displayAsList = this.params.displayAsList || this.displayAsList;
      const translatedOptions = this.translatedOptions;
      if (this.params.isSorted && translatedOptions) {
        var _this$params$options;
        this.params.options = Espo.Utils.clone(this.params.options);
        this.params.options = (_this$params$options = this.params.options) === null || _this$params$options === void 0 ? void 0 : _this$params$options.sort((v1, v2) => {
          return (translatedOptions[v1] || v1).localeCompare(translatedOptions[v2] || v2);
        });
      }
      if (this.options.customOptionList) {
        this.setOptionList(this.options.customOptionList, true);
      }
      if (this.params.allowCustomOptions || !this.params.options) {
        this.allowCustomOptions = true;
      }
      if (this.params.allowCustomOptions === false) {
        this.allowCustomOptions = false;
      }
      if (this.type === 'array') {
        this.validations.push('noInputValue');
      }
    }

    /**
     * @internal
     */
    setupFieldEvents() {
      this.addActionHandler('removeValue', (_e, target) => {
        const value = target.dataset.value;
        this.removeValue(value);
        this.focusOnElement();
      });
      this.addActionHandler('showAddModal', () => {
        this.actionAddItem();
      });
      this.addActionHandler('editItem', (_e, target) => {
        this.actionEditItem(target.dataset.value);
      });
    }
    focusOnElement() {
      const $button = this.$el.find('button[data-action="showAddModal"]');
      if ($button[0]) {
        // noinspection JSUnresolvedReference
        $button[0].focus({
          preventScroll: true
        });
        return;
      }
      const $input = this.$el.find('input.main-element');
      if ($input[0]) {
        // noinspection JSUnresolvedReference
        $input[0].focus({
          preventScroll: true
        });
      }
    }
    setupSearch() {
      this.addHandler('change', 'select.search-type', (_e, target) => {
        this.handleSearchType(target.value);
      });
    }
    handleSearchType(type) {
      const $inputContainer = this.$el.find('div.input-container');
      if (['anyOf', 'noneOf', 'allOf'].includes(type)) {
        $inputContainer.removeClass('hidden');
      } else {
        $inputContainer.addClass('hidden');
      }
    }
    setupTranslation() {
      let obj = {};
      let translation = this.params.translation;
      const optionsReference = this.params.optionsReference;
      if (!translation && optionsReference) {
        const [refEntityType, refField] = optionsReference.split('.');
        translation = `${refEntityType}.options.${refField}`;
      }
      this.translatedOptions = null;
      if (!this.params.options) {
        return;
      }
      obj = translation ? this.getLanguage().translatePath(translation) : this.translate(this.name, 'options', this.model.name);
      const map = {};
      this.params.options.forEach(o => {
        if (typeof obj === 'object' && o in obj) {
          map[o] = obj[o];
          return;
        }
        map[o] = o;
      });
      this.translatedOptions = map;
    }
    setupOptions() {}
    setOptionList(optionList, silent) {
      const previousOptions = this.params.options;
      if (!this.originalOptionList) {
        this.originalOptionList = this.params.options ?? [];
      }
      this.params.options = _utils.default.clone(optionList);
      const isChanged = !(0, _underscore.default)(previousOptions).isEqual(optionList);
      if (this.isEditMode() && !silent && isChanged) {
        const selectedOptionList = [];
        this.selected.forEach(option => {
          if (optionList.includes(option)) {
            selectedOptionList.push(option);
          }
        });
        this.selected = selectedOptionList;
        if (this.isRendered()) {
          this.reRender();
          this.trigger('change');
        } else {
          this.once('after:render', () => {
            this.trigger('change');
          });
        }
      }
    }
    setTranslatedOptions(translatedOptions) {
      this.translatedOptions = translatedOptions;
    }
    resetOptionList() {
      if (!this.originalOptionList) {
        return;
      }
      const previousOptions = this.params.options;
      this.params.options = _utils.default.clone(this.originalOptionList);
      const isChanged = !(0, _underscore.default)(previousOptions).isEqual(this.originalOptionList);
      if (!this.isEditMode() || !isChanged) {
        return;
      }
      if (this.isRendered()) {
        this.reRender();
      }
    }
    controlAddItemButton() {
      var _$select$val;
      const $select = this.$select;
      if (!$select) {
        return;
      }
      if (!$select.get(0)) {
        return;
      }
      const value = (_$select$val = $select.val()) === null || _$select$val === void 0 ? void 0 : _$select$val.toString().trim();
      if (!value && this.params.noEmptyString) {
        this.$addButton.addClass('disabled').attr('disabled', 'disabled');
      } else {
        this.$addButton.removeClass('disabled').removeAttr('disabled');
      }
    }
    afterRender() {
      if (this.isEditMode()) {
        this.$list = this.$el.find('.list-group');
        const $select = this.$select = this.$el.find('.select');
        if (this.allowCustomOptions) {
          this.$addButton = this.$el.find('button[data-action="addItem"]');
          this.$addButton.on('click', () => {
            const value = $select.val().toString();
            this.addValueFromUi(value);
            this.focusOnElement();
          });
          $select.on('input', () => this.controlAddItemButton());
          $select.on('keydown', e => {
            const key = _utils.default.getKeyFromKeyEvent(e);
            if (key === 'Enter') {
              const value = $select.val().toString();
              this.addValueFromUi(value);
            }
          });
          this.controlAddItemButton();
        }

        // @ts-ignore
        this.$list.sortable({
          stop: () => {
            this.fetchFromDom();
            this.trigger('change');
          },
          distance: 5,
          cancel: 'input,textarea,button,select,option,a[role="button"]',
          cursor: 'grabbing',
          handle: !this.noDragHandle ? '.drag-handle' : undefined
        });
      }
      if (this.isSearchMode()) {
        this.renderSearch();
      }
    }
    addValueFromUi(value) {
      value = value.trim();
      if (this.noEmptyString && value === '') {
        return;
      }
      if (this.params.pattern) {
        const helper = new _regExpPattern.default();
        const result = helper.validate(this.params.pattern, value, this.name, this.entityType);
        if (result) {
          setTimeout(() => this.showValidationMessage(result.message, 'input.select'), 10);
          return;
        }
      }
      this.addValue(value);
      this.$select.val('');
      this.controlAddItemButton();
    }
    renderSearch() {
      var _this$searchParams, _this$$element, _this$$element2;
      this.$element = this.$el.find('.main-element');
      const valueList = this.getSearchParamsData().valueList ?? ((_this$searchParams = this.searchParams) === null || _this$searchParams === void 0 ? void 0 : _this$searchParams.valueFront) ?? [];
      (_this$$element = this.$element) === null || _this$$element === void 0 || _this$$element.val(valueList.join(this.itemDelimiter));
      const items = [];
      (this.params.options ?? []).forEach(value => {
        let label = this.getLanguage().translateOption(value, this.name, this.entityType);
        if (this.translatedOptions) {
          if (value in this.translatedOptions) {
            label = this.translatedOptions[value];
          }
        }
        if (label === '') {
          return;
        }
        items.push({
          value: value,
          text: label,
          style: this.styleMap[value] || undefined
        });
      });
      const options = this.params.options ?? [];
      valueList.filter(item => !options.includes(item)).forEach(item => {
        items.push({
          value: item,
          text: item
        });
      });
      const multiSelectOptions = {
        items: items,
        delimiter: this.itemDelimiter,
        matchAnyWord: this.matchAnyWord,
        allowCustomOptions: this.allowCustomOptions,
        create: input => {
          return {
            value: input,
            text: input
          };
        }
      };
      _multiSelect.default.init(this.$element, multiSelectOptions);
      this.$el.find('.selectize-dropdown-content').addClass('small');
      const type = this.$el.find('select.search-type').val();
      this.handleSearchType(type);
      this.$el.find('select.search-type').on('change', () => {
        this.trigger('change');
      });
      (_this$$element2 = this.$element) === null || _this$$element2 === void 0 || _this$$element2.on('change', () => {
        this.trigger('change');
      });
    }
    fetchFromDom() {
      const selected = [];
      this.$el.find('.list-group .list-group-item').each((_i, el) => {
        var _$;
        const value = ((_$ = $(el)) === null || _$ === void 0 ? void 0 : _$.attr('data-value')).toString();
        selected.push(value);
      });
      this.selected = selected;
    }
    getValueForDisplay() {
      // Do not use the `html` method to avoid XSS.

      const list = this.selected.map(item => {
        var _$$text$get;
        let label = null;
        if (this.translatedOptions !== null) {
          if (item in this.translatedOptions) {
            label = this.translatedOptions[item];
          }
        }
        if (label === null) {
          label = item;
        }
        if (label === '') {
          label = this.translate('None');
        }
        const style = this.styleMap[item] || 'default';
        if (this.displayAsLabel) {
          var _$$addClass$text$get;
          let className = 'label label-md label-' + style;
          if (this.params.labelType === 'state') {
            className += ' label-state';
          }
          return (_$$addClass$text$get = $('<span>').addClass(className).text(label).get(0)) === null || _$$addClass$text$get === void 0 ? void 0 : _$$addClass$text$get.outerHTML;
        }
        if (style && style !== 'default') {
          var _$$addClass$text$get2;
          return (_$$addClass$text$get2 = $('<span>').addClass('text-' + style).text(label).get(0)) === null || _$$addClass$text$get2 === void 0 ? void 0 : _$$addClass$text$get2.outerHTML;
        }
        return (_$$text$get = $('<span>').text(label).get(0)) === null || _$$text$get === void 0 ? void 0 : _$$text$get.outerHTML;
      });
      if (this.displayAsList) {
        if (!list.length) {
          return '';
        }
        let itemClassName = 'multi-enum-item-container';
        if (this.displayAsLabel) {
          itemClassName += ' multi-enum-item-label-container';
        }
        return list.map(item => {
          var _$$addClass$html$get;
          return (_$$addClass$html$get = $('<div>').addClass(itemClassName).html(item).get(0)) === null || _$$addClass$html$get === void 0 ? void 0 : _$$addClass$html$get.outerHTML;
        }).join('');
      }
      if (this.displayAsLabel) {
        return list.join(' ');
      }
      return list.join(', ');
    }
    getItemHtml(value) {
      // Do not use the `html` method to avoid XSS.

      if (this.translatedOptions !== null) {
        for (const item in this.translatedOptions) {
          if (this.translatedOptions[item] === value) {
            value = item;
            break;
          }
        }
      }
      value = value.toString();
      const text = this.translatedOptions && value in this.translatedOptions ? this.translatedOptions[value].toString() : value;
      const div = document.createElement('div');
      div.className = 'list-group-item';
      div.dataset.value = value;
      div.style.cursor = 'default';
      if (!this.params.keepItems) {
        const a = document.createElement('a');
        a.role = 'button';
        a.tabIndex = 0;
        a.classList.add('pull-right');
        a.dataset.value = value;
        a.dataset.action = 'removeValue';
        a.append((() => {
          const span = document.createElement('span');
          span.className = 'fas fa-times';
          return span;
        })());
        div.append(a);
      }
      div.append((() => {
        const span = document.createElement('span');
        span.className = 'drag-handle';
        span.append((() => {
          const span = document.createElement('span');
          span.className = 'fas fa-grip fa-sm';
          return span;
        })());
        return span;
      })());
      if (this.params.itemsEditable && this.allowCustomOptions) {
        div.append((() => {
          const span = document.createElement('span');
          span.className = 'item-button';
          span.append((() => {
            const a = document.createElement('a');
            a.role = 'button';
            a.tabIndex = 0;
            a.dataset.value = value;
            a.dataset.action = 'editItem';
            a.append((() => {
              const span = document.createElement('span');
              span.className = 'fas fa-pencil-alt fa-sm';
              return span;
            })());
            return a;
          })());
          return span;
        })());
      }
      div.append((() => {
        const span = document.createElement('span');
        span.classList.add('text');
        span.textContent = text;
        return span;
      })());
      return div.outerHTML;
    }
    addValue(value) {
      if (this.selected.indexOf(value) === -1) {
        const html = this.getItemHtml(value);
        this.$list.append(html);
        this.selected.push(value);
        this.trigger('change');
      }
    }
    removeValue(value) {
      const valueInternal = CSS.escape(value);
      this.$list.children('[data-value="' + valueInternal + '"]').remove();
      const index = this.selected.indexOf(value);
      this.selected.splice(index, 1);
      this.trigger('change');
    }
    fetch() {
      const data = {};
      let list = _utils.default.clone(this.selected || []);
      const translations = this.translatedOptions;
      if (this.params.isSorted && translations) {
        list = list.sort((v1, v2) => {
          return (translations[v1] || v1).localeCompare(translations[v2] || v2);
        });
      }
      data[this.name] = list;
      return data;
    }
    fetchSearch() {
      const type = this.$el.find('select.search-type').val() || 'anyOf';
      let valueList = [];
      if (['anyOf', 'noneOf', 'allOf'].includes(type)) {
        var _this$$element3;
        valueList = ((_this$$element3 = this.$element) === null || _this$$element3 === void 0 ? void 0 : _this$$element3.val()).split(this.itemDelimiter);
        if (valueList.length === 1 && valueList[0] === '') {
          valueList = [];
        }
        if (valueList.length === 0) {
          if (type === 'anyOf') {
            return {
              type: 'any',
              data: {
                type: type,
                valueList: valueList
              }
            };
          }
          if (type === 'noneOf') {
            return {
              type: 'any',
              data: {
                type: type,
                valueList: valueList
              }
            };
          }
          if (type === 'allOf') {
            return {
              type: 'any',
              data: {
                type: type,
                valueList: valueList
              }
            };
          }
        }
      }
      if (type === 'anyOf') {
        const data = {
          type: 'arrayAnyOf',
          value: valueList,
          data: {
            type: 'anyOf',
            valueList: valueList
          }
        };
        if (!valueList.length) {
          data.value = null;
        }
        return data;
      }
      if (type === 'noneOf') {
        return {
          type: 'arrayNoneOf',
          value: valueList,
          data: {
            type: 'noneOf',
            valueList: valueList
          }
        };
      }
      if (type === 'allOf') {
        const data = {
          type: 'arrayAllOf',
          value: valueList,
          data: {
            type: 'allOf',
            valueList: valueList
          }
        };
        if (!valueList.length) {
          data.value = null;
        }
        return data;
      }
      if (type === 'isEmpty') {
        return {
          type: 'arrayIsEmpty',
          data: {
            type: 'isEmpty'
          }
        };
      }
      if (type === 'isNotEmpty') {
        return {
          type: 'arrayIsNotEmpty',
          data: {
            type: 'isNotEmpty'
          }
        };
      }
      return null;
    }
    validateRequired() {
      if (this.isRequired()) {
        const value = this.model.get(this.name);
        if (!value || value.length === 0) {
          const msg = this.translate('fieldIsRequired', 'messages').replace('{field}', this.getLabelText());
          this.showValidationMessage(msg, '.array-control-container');
          return true;
        }
      }
      return false;
    }

    // noinspection JSUnusedGlobalSymbols
    validateMaxCount() {
      if (this.params.maxCount) {
        const itemList = this.model.get(this.name) || [];
        if (itemList.length > this.params.maxCount) {
          const msg = this.translate('fieldExceedsMaxCount', 'messages').replace('{field}', this.getLabelText()).replace('{maxCount}', this.params.maxCount.toString());
          this.showValidationMessage(msg, '.array-control-container');
          return true;
        }
      }
      return false;
    }
    getSearchType() {
      return this.getSearchParamsData().type || 'anyOf';
    }
    getAddItemModalOptions() {
      var _this$params$options2;
      const options = [];
      (_this$params$options2 = this.params.options) === null || _this$params$options2 === void 0 || _this$params$options2.forEach(item => {
        if (!this.selected.includes(item)) {
          options.push(item);
        }
      });
      return {
        options: options,
        translatedOptions: this.translatedOptions
      };
    }
    async actionAddItem() {
      const view = await this.createView('dialog', this.addItemModalView, this.getAddItemModalOptions());
      view.render().then(() => {});
      view.once('add', item => {
        this.addValue(item);
        view.close();
      });
      view.once('add-mass', items => {
        items.forEach(item => this.addValue(item));
        view.close();
      });
      return view;
    }
    async actionEditItem(value) {
      const view = new EditItemModalView({
        value: value,
        required: this.noEmptyString,
        maxLength: this.maxItemLength,
        onApply: async data => {
          const index = this.selected.findIndex(it => it === value);
          if (index < 0) {
            return;
          }
          this.selected[index] = data.value;
          this.selected = this.selected.filter((it, i) => this.selected.indexOf(it) === i);
          await this.reRender();
          this.trigger('change');
        }
      });
      await this.assignView('dialog', view);
      await view.render();
    }

    // noinspection JSUnusedGlobalSymbols
    validateNoInputValue() {
      if (!this.element) {
        return false;
      }
      const input = this.element.querySelector('input.select');
      if (!(input instanceof HTMLInputElement)) {
        return false;
      }
      if (!input.value) {
        return false;
      }
      const message = this.translate('arrayInputNotEmpty', 'messages');
      this.showValidationMessage(message, 'input.select');
      return true;
    }
  }
  var _default = _exports.default = ArrayFieldView;
  class EditItemModalView extends _modal.default {
    // language=Handlebars
    templateContent = `
        <div class="record no-side-margin">{{{record}}}</div>
    `;
    constructor(options) {
      super(options);
    }
    setup() {
      this.buttonList = [{
        name: 'apply',
        label: 'Apply',
        style: 'danger',
        onClick: () => this.actionApply()
      }, {
        name: 'cancel',
        label: 'Cancel',
        onClick: () => this.actionCancel()
      }];
      this.shortcutKeys = {
        'Control+Enter': () => this.actionApply()
      };
      this.headerText = this.translate('Edit Item');
      this.model = new _model.default({
        value: this.options.value
      });
      this.recordView = new _editForModal.default({
        model: this.model,
        detailLayout: [{
          rows: [[{
            view: new _varchar.default({
              name: 'value',
              labelText: this.translate('Value'),
              params: {
                required: this.options.required,
                maxLength: this.options.maxLength
              }
            })
          }, false]]
        }]
      });
      this.assignView('record', this.recordView);
    }
    actionApply() {
      const data = this.recordView.processFetch();
      if (!data) {
        return;
      }
      const value = this.model.attributes.value ?? '';
      this.options.onApply({
        value
      });
      this.close();
    }
  }
});

define("views/fields/address", ["exports", "views/fields/base", "views/fields/varchar", "ui/autocomplete"], function (_exports, _base, _varchar, _autocomplete) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  _varchar = _interopRequireDefault(_varchar);
  _autocomplete = _interopRequireDefault(_autocomplete);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/fields/address */

  /**
   * Parameters.
   */

  /**
   * Options.
   */

  /**
   * An address field.
   */
  class AddressFieldView extends _base.default {
    type = 'address';
    listTemplate = 'fields/address/detail';
    detailTemplate = 'fields/address/detail';
    editTemplate = 'fields/address/edit';
    // noinspection JSUnusedGlobalSymbols
    editTemplate1 = 'fields/address/edit-1';
    // noinspection JSUnusedGlobalSymbols
    editTemplate2 = 'fields/address/edit-2';
    // noinspection JSUnusedGlobalSymbols
    editTemplate3 = 'fields/address/edit-3';
    // noinspection JSUnusedGlobalSymbols
    editTemplate4 = 'fields/address/edit-4';
    searchTemplate = 'fields/address/search';
    listLinkTemplate = 'fields/address/list-link';
    validations = ['required', 'pattern'];
    data() {
      const data = super.data();
      data.ucName = Espo.Utils.upperCaseFirst(this.name);
      this.addressPartList.forEach(item => {
        const field = this.subFieldMap[item];
        data[`${item}Value`] = this.model.get(field);
      });
      if (this.isReadMode()) {
        data.formattedAddress = this.getFormattedAddress();
        data.isNone = data.formattedAddress === null;
        if (data.formattedAddress === -1) {
          data.formattedAddress = null;
          data.isLoading = true;
        }
        if (this.params.viewMap && this.canBeDisplayedOnMap()) {
          data.viewMap = true;
          data.viewMapLink = `#AddressMap/view/${this.model.entityType}/${this.model.id}/${this.name}`;
        }
      }
      if (this.isEditMode()) {
        data.stateMaxLength = this.maxLengthMap.state;
        data.streetMaxLength = this.maxLengthMap.street;
        data.postalCodeMaxLength = this.maxLengthMap.postalCode;
        data.cityMaxLength = this.maxLengthMap.city;
        data.countryMaxLength = this.maxLengthMap.country;
      }
      return data;
    }
    setupSearch() {
      var _this$searchParams;
      this.searchData.value = this.getSearchParamsData().value ?? ((_this$searchParams = this.searchParams) === null || _this$searchParams === void 0 ? void 0 : _this$searchParams.additionalValue);
    }
    canBeDisplayedOnMap() {
      return !!this.model.get(this.name + 'City') || !!this.model.get(this.name + 'PostalCode');
    }
    getFormattedAddress() {
      let isNotEmpty = false;
      let isSet = false;
      this.addressAttributeList.forEach(attribute => {
        isNotEmpty = isNotEmpty || this.model.get(attribute);
        isSet = isSet || this.model.has(attribute);
      });
      const isEmpty = !isNotEmpty;
      if (isEmpty) {
        if (this.mode === this.MODE_LIST) {
          return '';
        }
        if (!isSet) {
          return -1;
        }
        return null;
      }
      const format = this.getAddressFormat();
      if (format === 1) {
        return this.getFormattedAddress1();
      }
      if (format === 2) {
        return this.getFormattedAddress2();
      }
      if (format === 3) {
        return this.getFormattedAddress3();
      }
      if (format === 4) {
        return this.getFormattedAddress4();
      }
      return null;
    }
    getFormattedAddress1() {
      const postalCodeValue = this.model.get(this.postalCodeField);
      const streetValue = this.model.get(this.streetField);
      const cityValue = this.model.get(this.cityField);
      const stateValue = this.model.get(this.stateField);
      const countryValue = this.model.get(this.countryField);
      let html = '';
      if (streetValue) {
        html += streetValue;
      }
      if (cityValue || stateValue || postalCodeValue) {
        if (html !== '') {
          html += '\n';
        }
        if (cityValue) {
          html += cityValue;
        }
        if (stateValue) {
          if (cityValue) {
            html += ', ';
          }
          html += stateValue;
        }
        if (postalCodeValue) {
          if (cityValue || stateValue) {
            html += ' ';
          }
          html += postalCodeValue;
        }
      }
      if (countryValue) {
        if (html !== '') {
          html += '\n';
        }
        html += countryValue;
      }
      return html;
    }
    getFormattedAddress2() {
      const postalCodeValue = this.model.get(this.postalCodeField);
      const streetValue = this.model.get(this.streetField);
      const cityValue = this.model.get(this.cityField);
      const stateValue = this.model.get(this.stateField);
      const countryValue = this.model.get(this.countryField);
      let html = '';
      if (streetValue) {
        html += streetValue;
      }
      if (cityValue || postalCodeValue) {
        if (html !== '') {
          html += '\n';
        }
        if (postalCodeValue) {
          html += postalCodeValue;
          if (cityValue) {
            html += ' ';
          }
        }
        if (cityValue) {
          html += cityValue;
        }
      }
      if (stateValue || countryValue) {
        if (html !== '') {
          html += '\n';
        }
        if (stateValue) {
          html += stateValue;
          if (countryValue) {
            html += ' ';
          }
        }
        if (countryValue) {
          html += countryValue;
        }
      }
      return html;
    }
    getFormattedAddress3() {
      const postalCodeValue = this.model.get(this.postalCodeField);
      const streetValue = this.model.get(this.streetField);
      const cityValue = this.model.get(this.cityField);
      const stateValue = this.model.get(this.stateField);
      const countryValue = this.model.get(this.countryField);
      let html = '';
      if (countryValue) {
        html += countryValue;
      }
      if (cityValue || stateValue || postalCodeValue) {
        if (html !== '') {
          html += '\n';
        }
        if (postalCodeValue) {
          html += postalCodeValue;
        }
        if (stateValue) {
          if (postalCodeValue) {
            html += ' ';
          }
          html += stateValue;
        }
        if (cityValue) {
          if (postalCodeValue || stateValue) {
            html += ' ';
          }
          html += cityValue;
        }
      }
      if (streetValue) {
        if (html !== '') {
          html += '\n';
        }
        html += streetValue;
      }
      return html;
    }
    getFormattedAddress4() {
      const postalCodeValue = this.model.get(this.postalCodeField);
      const streetValue = this.model.get(this.streetField);
      const cityValue = this.model.get(this.cityField);
      const stateValue = this.model.get(this.stateField);
      const countryValue = this.model.get(this.countryField);
      let html = '';
      if (streetValue) {
        html += streetValue;
      }
      if (cityValue) {
        if (html !== '') {
          html += '\n';
        }
        html += cityValue;
      }
      if (countryValue || stateValue || postalCodeValue) {
        if (html !== '') {
          html += '\n';
        }
        if (countryValue) {
          html += countryValue;
        }
        if (stateValue) {
          if (countryValue) {
            html += ' - ';
          }
          html += stateValue;
        }
        if (postalCodeValue) {
          if (countryValue || stateValue) {
            html += ' ';
          }
          html += postalCodeValue;
        }
      }
      return html;
    }

    /**
     * @internal
     */
    _getTemplateName() {
      if (this.mode === this.MODE_EDIT) {
        const prop = 'editTemplate' + this.getAddressFormat().toString();
        if (prop in this) {
          return this[prop];
        }
      }

      // @todo
      return super._getTemplateName();
    }
    getAddressFormat() {
      return this.getConfig().get('addressFormat') || 1;
    }
    afterRender() {
      if (this.mode === this.MODE_EDIT) {
        this.$street = this.$el.find(`[data-name="${this.streetField}"]`);
        this.$postalCode = this.$el.find(`[data-name="${this.postalCodeField}"]`);
        this.$state = this.$el.find(`[data-name="${this.stateField}"]`);
        this.$city = this.$el.find(`[data-name="${this.cityField}"]`);
        this.$country = this.$el.find(`[data-name="${this.countryField}"]`);
        this.$street.on('change', () => this.trigger('change'));
        this.$postalCode.on('change', () => this.trigger('change'));
        this.$state.on('change', () => this.trigger('change'));
        this.$city.on('change', () => this.trigger('change'));
        this.$country.on('change', () => this.trigger('change'));
        const countryList = this.getCountryList();
        const cityList = this.getConfig().get('addressCityList') || [];
        const stateList = this.getConfig().get('addressStateList') || [];
        if (countryList.length) {
          const autocomplete = new _autocomplete.default(this.$country.get(0), {
            name: this.name + 'Country',
            triggerSelectOnValidInput: true,
            autoSelectFirst: true,
            handleFocusMode: 1,
            focusOnSelect: true,
            lookup: countryList,
            lookupFunction: this.getCountryAutocompleteLookupFunction(countryList),
            onSelect: () => this.trigger('change')
          });
          this.once('render remove', () => autocomplete.dispose());
        }
        if (cityList.length) {
          const autocomplete = new _autocomplete.default(this.$city.get(0), {
            name: this.name + 'City',
            triggerSelectOnValidInput: true,
            autoSelectFirst: true,
            handleFocusMode: 1,
            focusOnSelect: true,
            lookup: cityList,
            onSelect: () => this.trigger('change')
          });
          this.once('render remove', () => autocomplete.dispose());
        }
        if (stateList.length) {
          const autocomplete = new _autocomplete.default(this.$state.get(0), {
            name: this.name + 'State',
            triggerSelectOnValidInput: true,
            autoSelectFirst: true,
            handleFocusMode: 1,
            focusOnSelect: true,
            lookup: stateList,
            onSelect: () => this.trigger('change')
          });
          this.once('render remove', () => autocomplete.dispose());
        }
        this.controlStreetTextareaHeight();
        this.$street.on('input', () => this.controlStreetTextareaHeight());
      }
    }
    controlStreetTextareaHeight(lastHeight) {
      const scrollHeight = this.$street.prop('scrollHeight');
      const clientHeight = this.$street.prop('clientHeight');
      if (typeof lastHeight === 'undefined' && clientHeight === 0) {
        setTimeout(this.controlStreetTextareaHeight.bind(this), 10);
        return;
      }
      if (clientHeight === lastHeight) return;
      if (scrollHeight > clientHeight + 1) {
        const rows = this.$street.prop('rows');
        this.$street.attr('rows', rows + 1);
        this.controlStreetTextareaHeight(clientHeight);
      }
      if ((this.$street.val() ?? '').length === 0) {
        this.$street.attr('rows', 1);
      }
    }
    setup() {
      super.setup();
      this.addActionHandler('viewMap', e => this.viewMapHandler(e));
      this.maxLengthMap = {};
      const actualAttributePartList = this.getMetadata().get(['fields', this.type, 'actualFields']) ?? ['street', 'city', 'state', 'country', 'postalCode'];
      this.addressAttributeList = [];
      this.addressPartList = [];
      this.subFieldMap = {};
      actualAttributePartList.forEach(item => {
        const attribute = this.name + Espo.Utils.upperCaseFirst(item);
        this.addressAttributeList.push(attribute);
        this.addressPartList.push(item);

        // @ts-ignore
        this[item + 'Field'] = attribute;
        this.subFieldMap[item] = attribute;
        if (this.entityType) {
          this.maxLengthMap[item] = this.getMetadata().get(['entityDefs', this.entityType, 'fields', attribute, 'maxLength']);
        }
      });
    }
    viewMapHandler(e) {
      e.preventDefault();
      e.stopPropagation();
      this.viewMapAction();
    }
    validateRequired() {
      const validate = name => {
        if (!this.model.isRequired(name)) {
          return false;
        }
        if (this.model.get(name) !== null) {
          return false;
        }
        const msg = this.translate('fieldIsRequired', 'messages').replace('{field}', this.translate(name, 'fields', this.entityType));
        this.showValidationMessage(msg, `[data-name="${name}"]`);
        return true;
      };
      let result = false;
      this.getSubItems().forEach(item => {
        result = validate(item.field) || result;
      });
      return result;
    }
    getSubItems() {
      return this.addressPartList.map(it => {
        return {
          item: it,
          field: this.subFieldMap[it]
        };
      });
    }
    isRequired() {
      for (const item of this.getSubItems()) {
        if (this.model.getFieldParam(item.field, 'required')) {
          return true;
        }
      }
      return false;
    }

    // noinspection JSUnusedGlobalSymbols
    validatePattern() {
      const fieldList = [this.postalCodeField, this.stateField, this.cityField, this.countryField];
      let result = false;
      for (const field of fieldList) {
        result = _varchar.default.prototype.fieldValidatePattern.call(this, field) || result;
      }
      return result;
    }
    fetch() {
      var _this$$postalCode$val, _this$$street$val, _this$$state$val, _this$$city$val, _this$$country$val;
      const data = {};
      data[this.postalCodeField] = (_this$$postalCode$val = this.$postalCode.val()) === null || _this$$postalCode$val === void 0 ? void 0 : _this$$postalCode$val.toString().trim();
      data[this.streetField] = (_this$$street$val = this.$street.val()) === null || _this$$street$val === void 0 ? void 0 : _this$$street$val.toString().trim();
      data[this.stateField] = (_this$$state$val = this.$state.val()) === null || _this$$state$val === void 0 ? void 0 : _this$$state$val.toString().trim();
      data[this.cityField] = (_this$$city$val = this.$city.val()) === null || _this$$city$val === void 0 ? void 0 : _this$$city$val.toString().trim();
      data[this.countryField] = (_this$$country$val = this.$country.val()) === null || _this$$country$val === void 0 ? void 0 : _this$$country$val.toString().trim();
      const attributeList = [this.postalCodeField, this.streetField, this.stateField, this.cityField, this.countryField];
      attributeList.forEach(attribute => {
        if (data[attribute] === '') {
          data[attribute] = null;
        }
      });
      return data;
    }
    fetchSearch() {
      const value = this.$el.find('input.main-element').val().toString().trim();
      if (!value) {
        return null;
      }
      return {
        type: 'or',
        value: [{
          type: 'like',
          field: this.postalCodeField,
          value: value + '%'
        }, {
          type: 'like',
          field: this.streetField,
          value: value + '%'
        }, {
          type: 'like',
          field: this.cityField,
          value: value + '%'
        }, {
          type: 'like',
          field: this.stateField,
          value: value + '%'
        }, {
          type: 'like',
          field: this.countryField,
          value: value + '%'
        }],
        data: {
          value: value
        }
      };
    }
    async viewMapAction() {
      const view = await this.createView('mapDialog', 'views/modals/view-map', {
        model: this.model,
        field: this.name
      });
      await view.render();
    }
    getCountryList() {
      const list = (this.getHelper().getAppParam('addressCountryData') || {}).list || [];
      if (list.length) {
        return list;
      }
      return [];
    }
    getCountryAutocompleteLookupFunction(fullList) {
      const list = (this.getHelper().getAppParam('addressCountryData') || {}).preferredList || [];
      if (!list.length) {
        return undefined;
      }
      return query => {
        if (query.length === 0) {
          const result = list.map(item => ({
            value: item
          }));
          return Promise.resolve(result);
        }
        const queryLowerCase = query.toLowerCase();
        const result = fullList.filter(item => {
          if (item.toLowerCase().indexOf(queryLowerCase) === 0) {
            return item.length !== queryLowerCase.length;
          }
        }).map(item => ({
          value: item
        }));
        return Promise.resolve(result);
      };
    }
  }
  var _default = _exports.default = AddressFieldView;
});

define("views/email/record/detail", ["exports", "views/record/detail"], function (_exports, _detail) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _detail = _interopRequireDefault(_detail);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/email/record/detail */

  class EmailDetailRecordView extends _detail.default {
    sideView = 'views/email/record/detail-side';
    duplicateAction = false;
    layoutNameConfigure() {
      if (this.model.isNew()) {
        return;
      }
      const status = this.model.get('status');
      if (status === 'Draft') {
        this.layoutName = 'composeSmall';
        return;
      }
      let isRestricted = false;
      if (status === 'Sent') {
        isRestricted = true;
      }
      if (status === 'Archived') {
        if (this.model.get('createdById') === this.getHelper().getAppParam('systemUserId') || !this.model.get('createdById') || this.model.get('isImported')) {
          isRestricted = true;
        }
      }
      if (isRestricted) {
        this.layoutName += 'Restricted';
      }
      this.isRestricted = isRestricted;
    }
    init() {
      super.init();
      this.layoutNameConfigure();
    }
    setup() {
      super.setup();
      if (['Archived', 'Sent'].includes(this.model.get('status'))) {
        this.shortcutKeyCtrlEnterAction = 'save';
      }
      this.addButton({
        name: 'sendFromDetail',
        label: 'Send',
        hidden: true,
        onClick: () => this.actionSendFromDetail()
      });
      this.dropdownEditItemList.push({
        name: 'send',
        label: 'Send',
        onClick: () => this.actionSendFromDetail()
      });
      this.controlSendButton();
      this.listenTo(this.model, 'change:status', () => this.controlSendButton());
      if (this.model.get('status') !== 'Draft' && this.model.has('isRead') && !this.model.get('isRead')) {
        this.model.set('isRead', true, {
          sync: true
        });
      }
      this.listenTo(this.model, 'sync', () => {
        if (!this.model.get('isRead') && this.model.get('status') !== 'Draft') {
          this.model.set('isRead', true, {
            sync: true
          });
        }
      });
      if (!(this.model.get('isHtml') && this.model.get('bodyPlain'))) {
        this.listenToOnce(this.model, 'sync', () => {
          if (this.model.get('isHtml') && this.model.get('bodyPlain')) {
            this.showActionItem('showBodyPlain');
          }
        });
      }
      if (this.model.attributes.isUsers) {
        this.addDropdownItem({
          label: 'Mark as Important',
          name: 'markAsImportant',
          hidden: this.model.get('isImportant'),
          groupIndex: 1,
          iconClass: 'far fa-star'
        });
        this.addDropdownItem({
          label: 'Unmark Importance',
          name: 'markAsNotImportant',
          hidden: !this.model.get('isImportant'),
          groupIndex: 1
        });
        this.addDropdownItem({
          label: 'Move to Trash',
          name: 'moveToTrash',
          hidden: this.isInTrash(),
          groupIndex: 2,
          iconClass: 'far fa-trash-can'
        });
        this.addDropdownItem({
          label: 'Retrieve from Trash',
          name: 'retrieveFromTrash',
          hidden: !this.isInTrash(),
          groupIndex: 2
        });
        this.addDropdownItem({
          labelTranslation: 'Email.actions.moveToArchive',
          name: 'moveToArchive',
          groupIndex: 2,
          hidden: this.isInArchive(),
          onClick: () => this.actionMoveToArchive(),
          iconClass: 'far fa-caret-square-down'
        });
        this.addDropdownItem({
          label: 'Move to Folder',
          name: 'moveToFolder',
          groupIndex: 2,
          iconClass: 'far fa-folder'
        });
      } else if (this.model.attributes.groupFolderId) {
        this.addDropdownItem({
          label: 'Move to Trash',
          name: 'moveToTrash',
          hidden: this.isInTrash(),
          groupIndex: 2,
          iconClass: 'far fa-trash-can'
        });
        this.addDropdownItem({
          label: 'Retrieve from Trash',
          name: 'retrieveFromTrash',
          hidden: !this.isInTrash(),
          groupIndex: 2
        });
        this.addDropdownItem({
          labelTranslation: 'Email.actions.moveToArchive',
          name: 'moveToArchive',
          groupIndex: 2,
          hidden: this.isInArchive() || this.isInTrash(),
          onClick: () => this.actionMoveToArchive(),
          iconClass: 'far fa-caret-square-down'
        });
        this.addDropdownItem({
          label: 'Move to Folder',
          name: 'moveToFolder',
          groupIndex: 2,
          hidden: this.isInTrash(),
          iconClass: 'far fa-folder'
        });
      } else {
        this.addDropdownItem({
          label: 'Move to Folder',
          name: 'moveToFolder',
          groupIndex: 2,
          iconClass: 'far fa-folder'
        });
      }
      this.addDropdownItem({
        label: 'Show Plain Text',
        name: 'showBodyPlain',
        hidden: !(this.model.get('isHtml') && this.model.get('bodyPlain')),
        groupIndex: 7
      });
      this.addDropdownItem({
        label: 'Print',
        name: 'print',
        groupIndex: 7
      });
      this.listenTo(this.model, 'change:isImportant', () => {
        if (this.model.get('isImportant')) {
          this.hideActionItem('markAsImportant');
          this.showActionItem('markAsNotImportant');
        } else {
          this.hideActionItem('markAsNotImportant');
          this.showActionItem('markAsImportant');
        }
      });
      this.listenTo(this.model, 'change:inTrash change:groupStatusFolder', () => {
        if (this.isInTrash()) {
          this.hideActionItem('moveToTrash');
          this.showActionItem('retrieveFromTrash');
        } else {
          this.hideActionItem('retrieveFromTrash');
          this.showActionItem('moveToTrash');
        }
      });
      this.listenTo(this.model, 'change:inArchive change:groupStatusFolder', () => {
        if (this.isInArchive()) {
          this.hideActionItem('moveToArchive');
        } else {
          this.showActionItem('moveToArchive');
        }
      });
      if (this.getAcl().checkScope('User')) {
        this.addDropdownItem({
          label: 'View Users',
          name: 'viewUsers'
        });
      }
      this.setFieldReadOnly('replied');
      if (this.model.get('status') === 'Draft') {
        this.setFieldReadOnly('dateSent');
        this.controlSelectTemplateField();
        this.on('after:mode-change', () => this.controlSelectTemplateField());
      }
      if (this.isRestricted) {
        this.handleAttachmentField();
        this.listenTo(this.model, 'change:attachmentsIds', () => this.handleAttachmentField());
        this.handleCcField();
        this.listenTo(this.model, 'change:cc', () => this.handleCcField());
        this.handleBccField();
        this.listenTo(this.model, 'change:bcc', () => this.handleBccField());
      }
    }
    controlSelectTemplateField() {
      if (this.mode === this.MODE_EDIT) {
        // Not implemented for detail view yet.
        this.hideField('selectTemplate');
        return;
      }
      this.hideField('selectTemplate');
    }
    controlSendButton() {
      const status = this.model.get('status');
      if (status === 'Draft') {
        this.showActionItem('send');
        this.showActionItem('sendFromDetail');
        return;
      }
      this.hideActionItem('sendFromDetail');
      this.hideActionItem('send');
    }

    // noinspection JSUnusedGlobalSymbols
    actionSaveDraft() {
      this.actionSaveAndContinueEditing();
    }
    actionMarkAsImportant() {
      Espo.Ajax.postRequest('Email/inbox/important', {
        id: this.model.id
      });
      this.model.set('isImportant', true, {
        sync: true
      });
    }
    actionMarkAsNotImportant() {
      Espo.Ajax.deleteRequest('Email/inbox/important', {
        id: this.model.id
      });
      this.model.set('isImportant', false, {
        sync: true
      });
    }
    actionMoveToTrash() {
      Espo.Ajax.postRequest('Email/inbox/inTrash', {
        id: this.model.id
      }).then(() => {
        Espo.Ui.warning(this.translate('Moved to Trash', 'labels', 'Email'));
      });
      if (this.model.attributes.groupFolderId) {
        this.model.set('groupStatusFolder', 'Trash', {
          sync: true
        });
      } else {
        this.model.set('inTrash', true, {
          sync: true
        });
      }
      if (this.model.collection) {
        this.model.collection.trigger('moving-to-trash', this.model.id, true);
      }
    }

    // noinspection JSUnusedGlobalSymbols
    actionRetrieveFromTrash() {
      Espo.Ajax.deleteRequest('Email/inbox/inTrash', {
        id: this.model.id
      }).then(() => {
        Espo.Ui.warning(this.translate('Retrieved from Trash', 'labels', 'Email'));
      });
      this.model.set('inTrash', false, {
        sync: true
      });
      if (this.model.attributes.groupFolderId) {
        this.model.set('groupStatusFolder', null, {
          sync: true
        });
      }
      if (this.model.collection) {
        this.model.collection.trigger('retrieving-from-trash', this.model.id, true);
      }
    }
    actionMoveToFolder() {
      let currentFolderId = undefined;
      if (!this.isInArchive() && !this.isInTrash()) {
        if (this.model.attributes.groupFolderId) {
          currentFolderId = 'group:' + this.model.attributes.groupFolderId;
        } else if (this.model.attributes.folderId) {
          currentFolderId = this.model.attributes.folderId;
        }
      } else if (this.isInArchive()) {
        currentFolderId = 'archive';
      }
      this.createView('dialog', 'views/email-folder/modals/select-folder', {
        headerText: this.translate('Move to Folder', 'labels', 'Email'),
        isGroup: !!this.model.attributes.groupFolderId || !this.model.attributes.isUsers,
        noArchive: !this.model.attributes.groupFolderId && !this.model.attributes.isUsers,
        currentFolderId: currentFolderId
      }, view => {
        view.render();
        this.listenToOnce(view, 'select', /** string|null */folderId => {
          this.clearView('dialog');
          Espo.Ajax.postRequest(`Email/inbox/folders/${folderId}`, {
            id: this.model.id
          }).then(() => {
            if (this.model.attributes.groupFolderId) {
              if (folderId === 'archive') {
                this.model.set('groupStatusFolder', 'Archive');
              } else {
                this.model.set('groupStatusFolder', null);
              }
            } else {
              this.model.set('inArchive', folderId === 'archive');
            }
            if (folderId === 'inbox' || folderId === 'archive') {
              folderId = null;
            }
            if (!folderId) {
              this.model.set('groupFolderId', null);
              this.model.set('groupFolderName', null);
            }
            this.model.set('folderId', folderId);
            this.model.fetch();
            Espo.Ui.success(this.translate('Done'));
          });
        });
      });
    }
    actionMoveToArchive() {
      Espo.Ui.notifyWait();
      Espo.Ajax.postRequest(`Email/inbox/folders/archive`, {
        id: this.model.id
      }).then(() => {
        this.model.attributes.groupFolderId ? this.model.set('groupStatusFolder', 'Archive', {
          sync: true
        }) : this.model.set('inArchive', true, {
          sync: true
        });
        Espo.Ui.info(this.translate('Moved to Archive', 'labels', 'Email'));
        if (this.model.collection) {
          this.model.collection.trigger('moving-to-archive', this.model.id, true);
        }
      });
    }

    // noinspection JSUnusedGlobalSymbols
    actionShowBodyPlain() {
      this.createView('bodyPlain', 'views/email/modals/body-plain', {
        model: this.model
      }, view => {
        view.render();
      });
    }
    handleAttachmentField() {
      if ((this.model.get('attachmentsIds') || []).length === 0) {
        this.hideField('attachments');
      } else {
        this.showField('attachments');
      }
    }
    handleCcField() {
      if (!this.model.get('cc')) {
        this.hideField('cc');
      } else {
        this.showField('cc');
      }
    }
    handleBccField() {
      if (!this.model.get('bcc')) {
        this.hideField('bcc');
      } else {
        this.showField('bcc');
      }
    }

    /**
     * Send.
     *
     * @return {Promise}
     */
    send() {
      const model = this.model;
      const status = model.get('status');
      model.set('status', 'Sending');
      this.isSending = true;
      const afterSend = () => {
        model.trigger('after:send');
        this.trigger('after:send');
        this.isSending = false;
      };
      this.once('after:save', afterSend, this);
      this.once('cancel:save', () => {
        this.off('after:save', afterSend);
        this.isSending = false;
        model.set('status', status);
      });
      this.once('before:save', () => {
        Espo.Ui.notify(this.translate('Sending...', 'labels', 'Email'));
      });
      return this.save();
    }

    /**
     * @private
     * @return {Promise<void>}
     */
    async actionSendFromDetail() {
      await this.confirm(this.translate('confirmSend', 'messages', 'Email'));
      await this.setEditMode();
      await this.send();
      await this.setDetailMode();
    }

    // noinspection JSUnusedGlobalSymbols
    exitAfterDelete() {
      let folderId = this.rootData.selectedFolderId ? this.rootData.selectedFolderId : null;
      if (folderId === 'inbox') {
        folderId = null;
      }
      const options = {
        isReturn: true,
        isReturnThroughLink: false,
        folder: folderId
      };
      let url = '#' + this.scope;
      let action = null;
      if (folderId) {
        action = 'list';
        url += '/list/folder=' + folderId;
      }
      this.getRouter().dispatch(this.scope, action, options);
      this.getRouter().navigate(url, {
        trigger: false
      });
      return true;
    }

    // noinspection JSUnusedGlobalSymbols
    actionViewUsers(data) {
      const viewName = this.getMetadata().get(`clientDefs.${this.model.entityType}.relationshipPanels.users.viewModalView`) || this.getMetadata().get(`clientDefs.User.modalViews.relatedList`) || 'views/modals/related-list';
      const options = {
        model: this.model,
        link: 'users',
        scope: 'User',
        url: `${this.model.entityType}/${this.model.id}/users`,
        filtersDisabled: true,
        createDisabled: true,
        selectDisabled: !this.getAcl().checkModel(this.model, 'edit') || this.getAcl().getPermissionLevel('assignment') === 'no',
        unlinkDisabled: !this.getUser().isAdmin(),
        removeDisabled: true,
        rowActionsView: 'views/record/row-actions/relationship-view-and-unlink'
      };
      if (data.viewOptions) {
        for (const item in data.viewOptions) {
          options[item] = data.viewOptions[item];
        }
      }
      Espo.Ui.notifyWait();
      this.createView('modalRelatedList', viewName, options, view => {
        Espo.Ui.notify(false);
        view.render();
        this.listenTo(view, 'action', (event, element) => {
          Espo.Utils.handleAction(this, event, element);
        });
        this.listenToOnce(view, 'close', () => {
          this.clearView('modalRelatedList');
        });
      });
    }

    // noinspection JSUnusedGlobalSymbols
    actionSend() {
      this.send().then(() => {
        this.model.set('status', 'Sent', {
          sync: true
        });
        if (this.mode !== this.MODE_DETAIL) {
          this.setDetailMode();
          this.setFieldReadOnly('dateSent');
          this.setFieldReadOnly('name');
          this.setFieldReadOnly('attachments');
          this.setFieldReadOnly('isHtml');
          this.setFieldReadOnly('from');
          this.setFieldReadOnly('to');
          this.setFieldReadOnly('cc');
          this.setFieldReadOnly('bcc');
        }
      });
    }

    // noinspection JSUnusedGlobalSymbols
    actionPrint() {
      const bodyView = /** @type {import('views/fields/wysiwyg').default} */
      this.getFieldView('body');
      if (!bodyView) {
        return;
      }
      let iframe = /** @type HTMLIFrameElement */bodyView.$el.find('iframe').get(0);
      if (iframe) {
        iframe.contentWindow.print();
        return;
      }
      const el = bodyView.$el.get(0);
      /** @type {Element} */
      const recordElement = this.$el.get(0);
      iframe = document.createElement('iframe');
      iframe.style.display = 'none';
      recordElement.append(iframe);
      const contentWindow = iframe.contentWindow;
      contentWindow.document.open();
      contentWindow.document.write(el.innerHTML);
      contentWindow.document.close();
      contentWindow.focus();
      contentWindow.print();
      contentWindow.onafterprint = () => {
        recordElement.removeChild(iframe);
      };
    }
    errorHandlerSendingFail(data) {
      if (!this.model.id) {
        this.model.id = data.id;
      }
      let msg = this.translate('sendingFailed', 'strings', 'Email');
      if (data.message) {
        let part = data.message;
        if (this.getLanguage().has(part, 'messages', 'Email')) {
          part = this.translate(part, 'messages', 'Email');
        }
        msg += ': ' + part;
      }
      Espo.Ui.error(msg, true);
      console.error(msg);
    }

    /**
     * @protected
     * @param {KeyboardEvent} e
     */
    handleShortcutKeyCtrlS(e) {
      if (this.inlineEditModeIsOn || this.buttonsDisabled) {
        return;
      }
      e.preventDefault();
      e.stopPropagation();
      if (this.mode !== this.MODE_EDIT) {
        return;
      }
      if (!this.saveAndContinueEditingAction) {
        return;
      }
      if (!this.hasAvailableActionItem('saveAndContinueEditing')) {
        return;
      }
      this.actionSaveAndContinueEditing();
    }

    /**
     * @private
     * @return {boolean}
     */
    isInTrash() {
      return this.model.attributes.groupFolderId ? this.model.attributes.groupStatusFolder === 'Trash' : this.model.attributes.inTrash;
    }

    /**
     * @private
     * @return {boolean}
     */
    isInArchive() {
      return this.model.attributes.groupFolderId ? this.model.attributes.groupStatusFolder === 'Archive' : this.model.attributes.inArchive;
    }
  }
  var _default = _exports.default = EmailDetailRecordView;
});

define("views/email/fields/email-address", ["exports", "views/fields/base", "ui/autocomplete"], function (_exports, _base, _autocomplete) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  _autocomplete = _interopRequireDefault(_autocomplete);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EmailEmailAddressFieldView extends _base.default {
    getAutocompleteMaxCount() {
      if (this.autocompleteMaxCount) {
        return this.autocompleteMaxCount;
      }
      return this.getConfig().get('recordsPerPage');
    }
    afterRender() {
      super.afterRender();
      this.$input = this.$el.find('input');
      if (this.mode === this.MODE_SEARCH && this.getAcl().check('Email', 'create')) {
        this.initSearchAutocomplete();
      }
      if (this.mode === this.MODE_SEARCH) {
        this.$input.on('input', () => {
          this.trigger('change');
        });
      }
    }
    initSearchAutocomplete() {
      this.$input = this.$input || this.$el.find('input');

      /** @type {module:ajax.AjaxPromise & Promise<any>} */
      let lastAjaxPromise;
      const autocomplete = new _autocomplete.default(this.$input.get(0), {
        name: this.name,
        autoSelectFirst: true,
        triggerSelectOnValidInput: true,
        focusOnSelect: true,
        minChars: 1,
        forceHide: true,
        handleFocusMode: 2,
        onSelect: item => {
          this.$input.val(item.emailAddress);
        },
        formatResult: item => {
          return this.getHelper().escapeString(item.name) + ' &#60;' + this.getHelper().escapeString(item.id) + '&#62;';
        },
        lookupFunction: query => {
          if (lastAjaxPromise && lastAjaxPromise.getReadyState() < 4) {
            lastAjaxPromise.abort();
          }
          lastAjaxPromise = Espo.Ajax.getRequest('EmailAddress/search', {
            q: query,
            maxSize: this.getAutocompleteMaxCount()
          });
          return lastAjaxPromise.then(/** Record[] */response => {
            let result = response.map(item => {
              return {
                id: item.emailAddress,
                name: item.entityName,
                emailAddress: item.emailAddress,
                entityId: item.entityId,
                entityName: item.entityName,
                entityType: item.entityType,
                data: item.emailAddress,
                value: item.emailAddress
              };
            });
            if (this.skipCurrentInAutocomplete) {
              const current = this.$input.val();
              result = result.filter(item => item.emailAddress !== current);
            }
            return result;
          });
        }
      });
      this.once('render remove', () => autocomplete.dispose());
    }
    fetchSearch() {
      let value = this.$element.val();
      if (typeof value.trim === 'function') {
        value = value.trim();
      }
      if (value) {
        return {
          type: 'equals',
          value: value
        };
      }
      return null;
    }
  }
  var _default = _exports.default = EmailEmailAddressFieldView;
});

define("views/email/fields/body", ["exports", "views/fields/wysiwyg"], function (_exports, _wysiwyg) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _wysiwyg = _interopRequireDefault(_wysiwyg);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EmailBodyFieldView extends _wysiwyg.default {
    useIframe = true;
    hasBodyPlainField = true;
    toShowQuotePart = false;

    /**
     * @type {string}
     * @private
     */
    replyPart;
    getAttributeList() {
      return ['body', 'bodyPlain'];
    }
    setupToolbar() {
      super.setupToolbar();
      const attachmentItem = this.toolbar.find(it => it[0] === 'attachment');
      if (attachmentItem) {
        attachmentItem[1].push('insert-field');
      } else {
        this.toolbar.push(['insert-field', ['insert-field']]);
      }
      this.buttons['insert-field'] = () => {
        const ui = $.summernote.ui;
        const button = ui.button({
          contents: '<i class="fas fa-plus"></i>',
          tooltip: this.translate('Insert Field', 'labels', 'Email'),
          click: () => {
            this.showInsertFieldModal();
          }
        });
        return button.render();
      };
      this.listenTo(this.model, 'change', m => {
        if (!this.isRendered()) {
          return;
        }
        if (m.hasChanged('parentId') || m.hasChanged('to')) {
          this.controlInsertFieldButton();
        }
      });
    }
    onEditModeSet() {
      this.toShowQuotePart = false;
      return super.onEditModeSet();
    }
    afterRender() {
      super.afterRender();
      this.controlInsertFieldButton();
      if (this.isReadMode() && this.replyPart) {
        this.element.appendChild(this.createShowQuotePartButton());
      }
    }
    controlInsertFieldButton() {
      const $b = this.$el.find('.note-insert-field > button');
      if (this.model.get('to') && this.model.get('to').length || this.model.get('parentId')) {
        $b.removeAttr('disabled').removeClass('disabled');
      } else {
        $b.attr('disabled', 'disabled').addClass('disabled');
      }
    }
    showInsertFieldModal() {
      let to = this.model.get('to');
      if (to) {
        to = to.split(';')[0].trim();
      }
      const parentId = this.model.get('parentId');
      const parentType = this.model.get('parentType');
      Espo.Ui.notifyWait();
      this.createView('insertFieldDialog', 'views/email/modals/insert-field', {
        parentId: parentId,
        parentType: parentType,
        to: to
      }, view => {
        view.render();
        Espo.Ui.notify();
        this.listenToOnce(view, 'insert', /** string */string => {
          if (this.$summernote) {
            if (string.includes('\n')) {
              string = string.replace(/\r\n|\r|\n/g, '<br>');
              const html = '<p>' + string + '</p>';
              this.$summernote.summernote('editor.pasteHTML', html);
            } else {
              this.$summernote.summernote('editor.insertText', string);
            }
          }
          this.clearView('insertFieldDialog');
        });
      });
    }
    getValueForIframe() {
      let contents = super.getValueForIframe();
      if (this.toShowQuotePart) {
        this.replyPart = undefined;
        return contents;
      }
      this.replyPart = undefined;
      contents = this.processQuotePart(contents);
      if (!this.replyPart) {
        return contents;
      }
      return contents;
    }
    getValueForEdit() {
      this.replyPart = undefined;
      const contents = super.getValueForEdit();
      return this.processQuotePart(contents, true);
    }

    /**
     * @private
     * @param {string} contents
     * @param {boolean} [isEdit=false]
     * @return {string}
     */
    processQuotePart(contents, isEdit) {
      const container = document.createElement('div');
      container.innerHTML = contents;
      let selector = `:scope > [data-quote-start="true"]`;
      if (!isEdit) {
        selector += ', :scope > blockquote:last-child' + ', :scope > div:last-child > blockquote:last-child';
      }
      let element = container.querySelector(selector);
      if (!element) {
        return contents;
      }
      container.querySelectorAll('style, link[ref="stylesheet"]').forEach(element => {
        element.parentElement.removeChild(element);
      });
      this.replyPart = '';
      /** @type {HTMLElement[]} */
      const removeList = [];
      while (element) {
        this.replyPart += element.outerHTML;
        removeList.push(element);
        element = element.nextElementSibling;
      }
      removeList.forEach(element => element.parentElement.removeChild(element));
      if (isEdit) {
        this.element.appendChild(this.createShowQuotePartButton());
      }
      return container.innerHTML;
    }

    /**
     * @private
     * @return {HTMLAnchorElement}
     */
    createShowQuotePartButton() {
      const a = this.showQuoteButtonElement = document.createElement('a');
      a.setAttribute('role', 'button');
      a.innerHTML = '...';
      a.classList.add('show-quote-button', 'btn', 'btn-default', 'btn-sm');
      a.addEventListener('click', () => this.showQuotePart());
      return a;
    }

    /** @private */
    showQuotePart() {
      if (this.isReadMode()) {
        this.toShowQuotePart = true;
        this.reRender();
        return;
      }
      const value = this.$summernote.summernote('code') + this.replyPart;
      this.replyPart = undefined;
      this.showQuoteButtonElement.parentElement.removeChild(this.showQuoteButtonElement);
      this.$summernote.summernote('code', value);
    }
    fetch() {
      const data = super.fetch();
      if (this.model.attributes.isHtml && this.replyPart) {
        if (data[this.name] == null) {
          data[this.name] = '';
        }
        data[this.name] += this.replyPart;
      }
      if (this.model.attributes.isHtml) {
        data[this.name + 'Plain'] = this.htmlToPlain(data[this.name]);
      }
      return data;
    }
  }
  var _default = _exports.default = EmailBodyFieldView;
});

define("views/detail/modes", ["exports", "view"], function (_exports, _view) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class DetailModesView extends _view.default {
    // language=Handlebars
    templateContent = `
        <div class="button-container clearfix">
            <div class="btn-group">
                {{#each modeDataList}}
                    <button
                        class="btn btn-text btn-xs-wide{{#if active}} active{{/if}}"
                        data-action="switchMode"
                        data-value="{{name}}"
                        {{#if ../disabled}}disabled="disabled"{{/if}}
                    >{{label}}</button>
                {{/each}}
            </div>
        </div>
    `;

    /** @private */
    disabled = false;

    /**
     * @param {{
     *     modeList: string[],
     *     mode: string,
     *     scope: string.
     * }} options
     */
    constructor(options) {
      super(options);

      /** @private */
      this.modeList = options.modeList;
      /** @private */
      this.mode = options.mode;
      /** @private */
      this.scope = options.scope;

      /**
       * @private
       * @type {Object.<string, boolean>}
       */
      this.hiddenMap = {};
    }
    data() {
      return {
        disabled: this.disabled,
        modeDataList: this.modeList.filter(mode => !this.hiddenMap[mode] || mode === this.mode).map(mode => ({
          name: mode,
          active: mode === this.mode,
          label: this.translate(mode, 'detailViewModes', this.scope)
        }))
      };
    }

    /**
     * Change mode.
     *
     * @param {string} mode
     * @return {Promise}
     */
    changeMode(mode) {
      this.mode = mode;
      return this.reRender();
    }

    /**
     * Hide a mode.
     *
     * @param {string} mode
     */
    async hideMode(mode) {
      this.hiddenMap[mode] = true;
      await this.reRender();
    }

    /**
     * Show a mode.
     *
     * @param {string} mode
     */
    async showMode(mode) {
      delete this.hiddenMap[mode];
      await this.reRender();
    }

    /**
     * Disable.
     *
     * @return {Promise}
     */
    disable() {
      this.disabled = true;
      return this.reRender();
    }

    /**
     * Enable.
     *
     * @return {Promise}
     */
    enable() {
      this.disabled = false;
      return this.reRender();
    }
  }
  var _default = _exports.default = DetailModesView;
});

define("views/dashlets/abstract/base", ["exports", "view"], function (_exports, _view) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/dashlets/abstract/base */

  /**
   * A base dashlet view. All dashlets should extend it.
   */
  class BaseDashletView extends _view.default {
    /** @type {Object.<string, *>|null}*/
    optionsData = null;
    optionsFields = {
      title: {
        type: 'varchar',
        required: true
      },
      autorefreshInterval: {
        type: 'enumFloat',
        options: [0, 0.5, 1, 2, 5, 10]
      }
    };
    disabledForReadOnlyActionList = ['options', 'remove'];
    disabledForLockedActionList = ['remove'];

    /**
     * @type {boolean}
     */
    noPadding = false;

    /**
     * A button. Handled by an `action{Name}` method or a click handler.
     *
     * @typedef module:views/dashlets/abstract/base~button
     *
     * @property {string} name A name.
     * @property {string} [label] A label.
     * @property {string} [html] An HTML.
     * @property {string} [text] A text.
     * @property {string} [title] A title (not translatable).
     * @property {function()} [onClick] A click handler.
     */

    /**
     * A dropdown action. Handled by an `action{Name}` method or a click handler.
     *
     * @typedef module:views/dashlets/abstract/base~action
     *
     * @property {string} name A name.
     * @property {string} [label] A label.
     * @property {string} [html] An HTML.
     * @property {string} [text] A text.
     * @property {string} [title] A title (not translatable).
     * @property {string} [iconHtml] An icon HTML.
     * @property {string} [iconClass] An icon class. As of v10.0.
     * @property {string} [url] A link URL.
     * @property {function()} [onClick] A click handler.
     * @property {number} [groupIndex] A group index.
     */

    /**
     * Buttons.
     *
     * @type {Array<module:views/dashlets/abstract/base~button>}
     */
    buttonList = [];

    /**
     * Dropdown actions.
     *
     * @type {Array<module:views/dashlets/abstract/base~action>}
     */
    actionList = [{
      name: 'refresh',
      label: 'Refresh',
      iconClass: 'fas fa-sync-alt',
      groupIndex: 10000
    }, {
      name: 'options',
      label: 'Options',
      iconClass: 'fas fa-pencil-alt',
      groupIndex: 10000
    }, {
      name: 'remove',
      label: 'Remove',
      iconClass: 'fas fa-times',
      groupIndex: 10000
    }];

    /**
     * Refresh.
     */
    actionRefresh() {
      this.render();
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * Show options.
     */
    actionOptions() {}
    init() {
      this.name = this.options.name || this.name;
      this.id = this.options.id;
      this.defaultOptions = this.getMetadata().get(['dashlets', this.name, 'options', 'defaults']) || this.defaultOptions || {};
      this.defaultOptions = {
        title: this.getLanguage().translate(this.name, 'dashlets'),
        ...this.defaultOptions
      };
      this.defaultOptions = Espo.Utils.clone(this.defaultOptions);
      this.optionsFields = this.getMetadata().get(['dashlets', this.name, 'options', 'fields']) || this.optionsFields || {};
      this.optionsFields = Espo.Utils.clone(this.optionsFields);
      this.setupDefaultOptions();
      const options = Espo.Utils.cloneDeep(this.defaultOptions);
      for (const key in options) {
        if (typeof options[key] == 'function') {
          options[key] = options[key].call(this);
        }
      }
      let storedOptions;
      if (!this.options.readOnly) {
        storedOptions = this.getPreferences().getDashletOptions(this.id) || {};
      } else {
        const allOptions = this.getConfig().get('forcedDashletsOptions') || this.getConfig().get('dashletsOptions') || {};
        storedOptions = allOptions[this.id] || {};
      }
      this.optionsData = _.extend(options, storedOptions);
      if (this.optionsData.autorefreshInterval) {
        const interval = this.optionsData.autorefreshInterval * 60000;
        let t;
        const process = () => {
          t = setTimeout(() => {
            this.autoRefresh();
            process();
          }, interval);
        };
        process();
        this.once('remove', () => {
          clearTimeout(t);
        });
      }
      this.actionList = Espo.Utils.clone(this.actionList);
      this.buttonList = Espo.Utils.clone(this.buttonList);
      if (this.options.readOnly) {
        this.actionList = this.actionList.filter(item => {
          if (~this.disabledForReadOnlyActionList.indexOf(item.name)) {
            return false;
          }
          return true;
        });
      }
      if (this.options.locked) {
        this.actionList = this.actionList.filter(item => !this.disabledForLockedActionList.includes(item.name));
      }
      this.setupActionList();
      this.setupButtonList();
    }

    /**
     * Called on auto-refresh.
     *
     * @protected
     */
    autoRefresh() {
      this.actionRefresh();
    }

    /**
     * Set up default options.
     */
    setupDefaultOptions() {}

    /**
     * Set up actions.
     */
    setupActionList() {}

    /**
     * Set up buttons.
     */
    setupButtonList() {}

    /**
     * Has an option.
     *
     * @param {string} key
     * @return {boolean}
     */
    hasOption(key) {
      return key in this.optionsData;
    }

    /**
     * Get an option value.
     *
     * @param {string} key
     * @return {*}
     */
    getOption(key) {
      return this.optionsData[key];
    }

    /**
     * Get a title.
     * @return {string|null}
     */
    getTitle() {
      let title = this.getOption('title');
      if (!title) {
        title = null;
      }
      return title;
    }

    /**
     * @return {module:views/dashlet}
     */
    getContainerView() {
      return /** @type module:views/dashlet */this.getParentView();
    }

    /**
     * @internal
     * @param {MouseEvent} event
     * @param {HTMLElement} element
     */
    handleAction(event, element) {
      Espo.Utils.handleAction(this, event, element, {
        actionItems: [...this.buttonList, ...this.actionList],
        className: 'dashlet-action'
      });
    }

    /**
     * @internal
     * @return {Array<module:views/dashlets/abstract/base~action|false>}
     */
    getActionItemDataList() {
      /** @type {Array<module:views/dashlets/abstract/base~action[]>} */
      const groups = [];
      this.actionList.forEach(item => {
        // For bc.
        if (item === false) {
          return;
        }
        const index = (item.groupIndex === undefined ? 9999 : item.groupIndex) + 100;
        if (groups[index] === undefined) {
          groups[index] = [];
        }
        groups[index].push(item);
      });
      const itemList = [];
      groups.forEach(list => {
        list.forEach(it => itemList.push(it));
        itemList.push(false);
      });
      if (itemList.at(itemList.length - 1) === false) {
        itemList.pop();
      }
      return itemList;
    }

    /**
     * @return {string|null}
     * @since 9.0.0
     */
    getColor() {
      return null;
    }
    afterAdding() {}
  }
  var _default = _exports.default = BaseDashletView;
});

define("ui/app-init", ["exports", "jquery"], function (_exports, _jquery) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _jquery = _interopRequireDefault(_jquery);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  function uiAppInit() {
    const $document = (0, _jquery.default)(document);
    const topSpaceHeight = 100;
    $document.on('keydown.espo.button', e => {
      if (e.code !== 'Enter' || e.target.tagName !== 'A' || e.target.getAttribute('role') !== 'button' || e.target.getAttribute('href') || e.ctrlKey || e.altKey || e.metaKey) {
        return;
      }
      (0, _jquery.default)(e.target).click();
      e.preventDefault();
    });
    $document.on('hidden.bs.dropdown', e => {
      (0, _jquery.default)(e.target).removeClass('dropup');
    });
    $document.on('show.bs.dropdown', e => {
      let isUp;

      /** @type {HTMLElement} */
      const target = e.target;
      const $dropdown = (0, _jquery.default)(e.target).find('.dropdown-menu');

      /** @type {HTMLElement} */
      const dropdownElement = $dropdown.get(0);
      if (!dropdownElement) {
        return;
      }
      const height = $dropdown.outerHeight();
      const width = $dropdown.outerWidth();
      {
        const $target = (0, _jquery.default)(target);
        const windowHeight = (0, _jquery.default)(window).height();
        const top = e.target.getBoundingClientRect().bottom;
        const spaceBelow = windowHeight - (top + height);
        isUp = spaceBelow < 0 && top - topSpaceHeight > height;
        if ($target.hasClass('more') || $target.hasClass('tab')) {
          return;
        }
        if (isUp) {
          $target.addClass('dropup');
        } else {
          $target.removeClass('dropup');
        }
      }
      if (dropdownElement.classList.contains('pull-right') && target.getBoundingClientRect().left - width < 0) {
        const maxWidth = target.getBoundingClientRect().right - target.getBoundingClientRect().width / 2;
        dropdownElement.style.maxWidth = maxWidth + 'px';
        const $group = (0, _jquery.default)(target);
        $group.one('hidden.bs.dropdown', () => {
          dropdownElement.style.maxWidth = '';
        });
        return;
      }
      const $dashletBody = (0, _jquery.default)(target).closest('.dashlet-body');
      const fixPosition = e.target.parentElement.classList.contains('fix-position');
      if ($dashletBody.length || fixPosition) {
        let $body = $dashletBody;
        if (fixPosition) {
          $body = (0, _jquery.default)(window);
        }
        (0, _jquery.default)(target).removeClass('dropup');
        const $group = (0, _jquery.default)(target);
        const rect = target.getBoundingClientRect();
        const $ul = $group.find('.dropdown-menu');
        const isRight = target.classList.contains('pull-right');
        const $toggle = $group.find('.dropdown-toggle');
        $body.on('scroll.dd', () => {
          if ($group.hasClass('open')) {
            // noinspection JSUnresolvedReference
            $toggle.dropdown('toggle');
            $body.off('scroll.dd');
          }
        });
        $group.one('hidden.bs.dropdown', () => {
          $body.off('scroll.dd');
        });
        const left = isRight ? rect.left - $ul.outerWidth() + rect.width : rect.left;
        const top = isUp ? rect.top - height : rect.top + target.getBoundingClientRect().height;
        $ul.css({
          position: 'fixed',
          top: top,
          left: left,
          right: 'auto'
        });

        //return;
      }

      /*if (e.target.parentElement.classList.contains('fix-overflow')) {
          $(target).removeClass('dropup');
            const isRight = e.target.classList.contains('pull-right');
            const $ul = $(e.target.parentElement).find('.dropdown-menu');
            const rect = e.target.getBoundingClientRect();
            const parent = $ul.offsetParent().get(0);
            if (!parent) {
              return;
          }
            const scrollTop = parent === window.document.documentElement ?
              (document.documentElement.scrollTop || document.body.scrollTop) :
              parent.scrollTop;
            const top = isUp ?
              rect.top + scrollTop - height :
              rect.top + scrollTop + e.target.getBoundingClientRect().height;
            const left = isRight ?
              rect.left - $ul.outerWidth() + rect.width:
              rect.left
            $ul.css({
              top: top,
              left: left,
              right: 'auto',
          });
      }*/
    });
  }
  var _default = _exports.default = uiAppInit;
});

define("helpers/site/tabs", ["exports"], function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class TabsHelper {
    /**
     * @param {import('models/settings').default} config
     * @param {import('models/preferences').default} preferences
     * @param {import('models/user').default} user
     * @param {import('acl-manager').default} acl
     * @param {import('metadata').default} metadata
     * @param {import('language').default} language
     */
    constructor(config, preferences, user, acl, metadata, language) {
      /** @private */
      this.config = config;
      /** @private */
      this.preferences = preferences;
      /** @private */
      this.user = user;
      /** @private */
      this.acl = acl;
      /** @private */
      this.metadata = metadata;
      /** @private */
      this.language = language;
    }

    /**
     * @typedef {Object} TabsHelper~item
     * @property {string} [url]
     * @property {string} [text]
     * @property {'url'|'divider'} [type]
     * @property {(TabsHelper~item|string)[]} [itemList]
     */

    /**
     * Get the tab list.
     *
     * @return {(TabsHelper~item|string)[]}
     */
    getTabList() {
      let tabList = this.preferences.get('useCustomTabList') && !this.preferences.get('addCustomTabs') ? this.preferences.get('tabList') : this.config.get('tabList');
      if (this.preferences.get('useCustomTabList') && this.preferences.get('addCustomTabs')) {
        tabList = [...tabList, ...(this.preferences.get('tabList') || [])];
      }
      return Espo.Utils.cloneDeep(tabList) || [];
    }

    /**
     * Is a tab a divider.
     *
     * @param {string|{type?: string}} item
     */
    isTabDivider(item) {
      return typeof item === 'object' && item.type === 'divider';
    }

    /**
     * Is a tab more-delimiter.
     *
     * @param {string|{type?: string}} item
     */
    isTabMoreDelimiter(item) {
      return item === '_delimiter_' || item === '_delimiter-ext_';
    }

    /**
     * Is a tab a URL.
     *
     * @param {string|{type?: string}} item
     */
    isTabUrl(item) {
      return typeof item === 'object' && item.type === 'url';
    }

    /**
     * Is a tab a group.
     *
     * @param {string|{type?: string}} item
     */
    isTabGroup(item) {
      if (!this.isTabDivider(item) && !this.isTabUrl(item) && typeof item === 'object') {
        return true;
      }
      return false;
    }

    /**
     * Is a tab a scope.
     *
     * @param {string|{type?: string}} item
     */
    isTabScope(item) {
      if (typeof item === 'object' || this.isTabMoreDelimiter(item) || item === 'Home') {
        return false;
      }
      return true;
    }

    /**
     * Get a translated tab label.
     *
     * @param {{text?: string}|string} item
     */
    getTranslatedTabLabel(item) {
      const translateLabel = label => {
        if (label.indexOf('$') === 0) {
          return this.language.translate(label.slice(1), 'navbarTabs');
        }
        return label;
      };
      if (this.isTabDivider(item) || this.isTabUrl(item) || this.isTabUrl(item) || this.isTabGroup(item)) {
        if (item.text) {
          return translateLabel(item.text);
        }
        return '';
      }
      if (item === 'Home') {
        return this.language.translate('Home');
      }
      if (typeof item === 'object') {
        return '';
      }
      return this.language.translate(item, 'scopeNamesPlural');
    }

    /**
     * Check tab access.
     *
     * @param {Record|string} item
     * @return {boolean}
     */
    checkTabAccess(item) {
      if (this.isTabUrl(item)) {
        if (item.onlyAdmin && !this.user.isAdmin()) {
          return false;
        }
        if (!item.aclScope) {
          return true;
        }
        return this.acl.check(item.aclScope);
      }
      if (item === 'Home' || this.isTabMoreDelimiter(item)) {
        return true;
      }

      /** @type {Record<string, {disabled?: boolean, acl?: boolean, tabAclPermission?: string}>} */
      const scopes = this.metadata.get('scopes') || {};
      if (!scopes[item]) {
        return false;
      }
      const defs = scopes[item] || {};
      if (defs.disabled) {
        return false;
      }
      if (defs.acl) {
        return this.acl.check(item);
      }
      if (defs.tabAclPermission) {
        const level = this.acl.getPermissionLevel(defs.tabAclPermission);
        return level && level !== 'no';
      }
      return true;
    }
  }
  _exports.default = TabsHelper;
});

define("helpers/misc/reactions", ["exports", "di", "models/settings", "metadata"], function (_exports, _di, _settings, _metadata) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _settings = _interopRequireDefault(_settings);
  _metadata = _interopRequireDefault(_metadata);
  var _staticBlock;
  let _initClass, _init_config, _init_extra_config, _init_metadata, _init_extra_metadata;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  let _ReactionsHelper;
  class ReactionsHelper {
    /**
     * @type Settings
     */
    config = _init_config(this);

    /**
     * @type Metadata
     */
    metadata = (_init_extra_config(this), _init_metadata(this));

    /**
     * @private
     * @type {{
     *     type: string,
     *     iconClass: string,
     * }[]}
     */
    list = void _init_extra_metadata(this);

    /**
     * @return {{
     *     type: string,
     *     iconClass: string,
     * }[]}
     */
    getDefinitionList() {
      if (!this.list) {
        this.list = this.metadata.get('app.reactions.list') || [];
      }
      return this.list;
    }

    /**
     * @return {string[]}
     */
    getAvailableReactions() {
      return this.config.get('availableReactions') || [];
    }

    /**
     * @param {string|null} type
     * @return {string|null}
     */
    getIconClass(type) {
      const item = this.getDefinitionList().find(it => it.type === type);
      if (!item) {
        return null;
      }
      return item.iconClass;
    }
    static #_ = _staticBlock = () => ({
      e: [_init_config, _init_extra_config, _init_metadata, _init_extra_metadata],
      c: [_ReactionsHelper, _initClass]
    } = _applyDecs(this, [(0, _di.register)()], [[(0, _di.inject)(_settings.default), 0, "config"], [(0, _di.inject)(_metadata.default), 0, "metadata"]]), _initClass());
  }
  _staticBlock();
  var _default = _exports.default = _ReactionsHelper;
});

define("controllers/base", ["exports", "controller", "views/base"], function (_exports, _controller, _base) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _controller = _interopRequireDefault(_controller);
  _base = _interopRequireDefault(_base);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module controllers/base */

  /**
   * A base controller.
   */
  class BaseController extends _controller.default {
    constructor(params, injections) {
      super(params, injections);
      this.on('logout', () => this._clearAllStoredMainViews());
    }

    /**
     * @private
     */
    _clearAllStoredMainViews() {
      for (const name in this.params) {
        if (!name.startsWith('mainView-')) {
          continue;
        }
        const [, scope, key] = name.split('-', 3);
        const actualKey = `mainView-${scope}-${key}`;
        const view = /** @type {import('view').default} */
        this.get(actualKey);
        if (view) {
          view.remove(true);
        }
        this.unset(actualKey);
      }
    }

    /**
     * Clear a stored main view.
     *
     * @param {string} scope
     */
    clearScopeStoredMainView(scope) {
      for (const key in this.params) {
        if (!key.startsWith(`mainView-${scope}-`)) {
          continue;
        }
        const view = /** @type {import('view').default} */
        this.get(key);
        if (view) {
          view.remove(true);
        }
        this.unset(key);
      }
    }

    /**
     * Log in.
     *
     * @param {{
     *     anotherUser?: string,
     *     username?: string,
     * }} [options]
     */
    login(options) {
      const viewName = this.getConfig().get('loginView') || 'views/login';
      const anotherUser = (options || {}).anotherUser;
      const prefilledUsername = (options || {}).username;
      const viewOptions = {
        anotherUser: anotherUser,
        prefilledUsername: prefilledUsername
      };
      this.entire(viewName, viewOptions, loginView => {
        loginView.render();
        loginView.on('login', (userName, data) => {
          this.trigger('login', this.normalizeLoginData(userName, data));
        });
        loginView.once('redirect', (viewName, headers, userName, password, data) => {
          loginView.remove();
          this.entire(viewName, {
            loginData: data,
            userName: userName,
            password: password,
            anotherUser: anotherUser,
            headers: headers
          }, secondStepView => {
            secondStepView.render();
            secondStepView.once('login', (userName, data) => {
              this.trigger('login', this.normalizeLoginData(userName, data));
            });
            secondStepView.once('back', () => {
              secondStepView.remove();
              this.login();
            });
          });
        });
      });
    }

    /** @private */
    normalizeLoginData(userName, data) {
      return {
        auth: {
          userName: userName,
          token: data.token,
          anotherUser: data.anotherUser
        },
        user: data.user,
        preferences: data.preferences,
        acl: data.acl,
        settings: data.settings,
        appParams: data.appParams,
        language: data.language
      };
    }

    /**
     * Log out.
     */
    logout() {
      const title = this.getConfig().get('applicationName') || 'EspoCRM';
      $('head title').text(title);
      this.trigger('logout');
    }

    /**
     * Clear cache.
     */
    clearCache() {
      this.entire('views/clear-cache', {
        cache: this.getCache()
      }, view => {
        view.render();
      });
    }

    // noinspection JSUnusedGlobalSymbols
    actionLogin() {
      this.login();
    }

    // noinspection JSUnusedGlobalSymbols
    actionLogout() {
      this.logout();
    }

    // noinspection JSUnusedGlobalSymbols
    actionLogoutWait() {
      this.entire('views/base', {
        template: 'logout-wait'
      }, view => {
        view.render().then(() => Espo.Ui.notifyWait());
      });
    }

    // noinspection JSUnusedGlobalSymbols
    actionClearCache() {
      this.clearCache();
    }

    /**
     * Error Not Found.
     */
    error404() {
      const view = new _base.default({
        template: 'errors/404'
      });
      this.entire(view);
    }

    /**
     * Error Forbidden.
     */
    error403() {
      const view = new _base.default({
        template: 'errors/403'
      });
      this.entire(view);
    }

    // noinspection JSUnusedGlobalSymbols
    actionError404() {
      this.error404();
    }

    // noinspection JSUnusedGlobalSymbols
    actionError403() {
      this.error403();
    }
  }
  var _default = _exports.default = BaseController;
});

define("collections/tree", ["exports", "collection"], function (_exports, _collection) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _collection = _interopRequireDefault(_collection);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module collections/tree */

  class TreeCollection extends _collection.default {
    /**
     * @type {string | null}
     */
    parentId;

    /**
     * @type {string|null}
     */
    currentId = null;

    /**
     * @type {string[]|null}
     */
    path;

    /**
     * @type {string[]|null}
     */
    openPath;

    /**
     * @internal
     * @type {string | null}
     */
    currentCategoryId;

    /**
     * @internal
     * @type {string | null}
     */
    currentCategoryName;

    /**
     * @return {TreeCollection}
     */
    createSeed() {
      const seed = new this.constructor();
      seed.url = this.url;
      seed.model = this.model;
      seed.name = this.name;
      seed.entityType = this.entityType;
      seed.defs = this.defs;
      return seed;
    }
    prepareAttributes(response, options) {
      if (Array.isArray(response)) {
        throw new Error("Bad response.");
      }
      const list = super.prepareAttributes(response, options);
      const seed = this.clone();
      seed.reset();
      this.path = response.path;
      this.openPath = response.openPath ?? null;

      /**
       * @type {{
       *     id: string,
       *     name: string,
       *     upperId?: string,
       *     upperName?: string,
       * }|null}
       */
      this.categoryData = response.data || null;
      const prepare = (list, depth) => {
        list.forEach(data => {
          data.depth = depth;
          const childCollection = this.createSeed();
          childCollection.parentId = data.id;
          if (data.childList) {
            if (data.childList.length) {
              prepare(data.childList, depth + 1);
              childCollection.set(data.childList);
              data.childCollection = childCollection;
              return;
            }
            data.childCollection = childCollection;
            return;
          }
          if (data.childList === null) {
            data.childCollection = null;
            return;
          }
          data.childCollection = childCollection;
        });
      };
      prepare(list, 0);
      return list;
    }
    fetch(options) {
      options = options || {};
      options.data = options.data || {};
      if (this.parentId) {
        options.data.parentId = this.parentId;
      }
      if (this.currentId) {
        options.data.currentId = this.currentId;
      }
      return super.fetch(options);
    }
    clone() {
      let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      options = {
        ...options
      };

      // Prevents recurring clone.
      options.withModels = false;
      return super.clone(options);
    }
  }
  var _default = _exports.default = TreeCollection;
});

define("multi-collection", ["exports", "collection", "underscore"], function (_exports, _collection, _underscore) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _collection = _interopRequireDefault(_collection);
  _underscore = _interopRequireDefault(_underscore);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module multi-collection */

  /**
   * A collection that can contain entities of different entity types.
   */
  class MultiCollection extends _collection.default {
    /**
     * A model seed map.
     *
     * @public
     * @type {Object.<string, module:model>}
     */
    seeds = null;

    /** @inheritDoc */
    prepareAttributes(response, options) {
      if (Array.isArray(response)) {
        throw new Error("Bad response.");
      }
      this.total = response.total;
      if (!('list' in response)) {
        throw new Error("No 'list' in response.");
      }

      /** @type {({_scope?: string} & Object.<string, *>)[]} */
      const list = response.list;
      return list.map(attributes => {
        const entityType = attributes._scope;
        if (!entityType) {
          throw new Error("No '_scope' attribute.");
        }
        attributes = _underscore.default.clone(attributes);
        delete attributes['_scope'];
        const model = this.seeds[entityType].clone();
        model.set(attributes);
        return model;
      });
    }

    /** @inheritDoc */
    clone(options) {
      const collection = super.clone(options);
      collection.seeds = this.seeds;
      return collection;
    }
  }

  // noinspection JSUnusedGlobalSymbols
  var _default = _exports.default = MultiCollection;
});

define("app", ["exports", "backbone", "bullbone", "js-base64", "ui", "utils", "acl-manager", "cache", "storage", "models/settings", "language", "metadata", "field-manager", "models/user", "models/preferences", "model-factory", "collection-factory", "controllers/base", "router", "date-time", "layout-manager", "theme-manager", "session-storage", "view-helper", "web-socket-manager", "ajax", "number-util", "page-title", "broadcast-channel", "ui/app-init", "app-params", "di"], function (_exports, _backbone, _bullbone, _jsBase, _ui, _utils, _aclManager, _cache, _storage, _settings, _language, _metadata, _fieldManager, _user, _preferences, _modelFactory, _collectionFactory, _base, _router, _dateTime, _layoutManager, _themeManager, _sessionStorage, _viewHelper, _webSocketManager, _ajax, _numberUtil, _pageTitle, _broadcastChannel, _appInit, _appParams, _di) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _backbone = _interopRequireDefault(_backbone);
  _jsBase = _interopRequireDefault(_jsBase);
  _ui = _interopRequireDefault(_ui);
  _utils = _interopRequireDefault(_utils);
  _aclManager = _interopRequireDefault(_aclManager);
  _cache = _interopRequireDefault(_cache);
  _storage = _interopRequireDefault(_storage);
  _settings = _interopRequireDefault(_settings);
  _language = _interopRequireDefault(_language);
  _metadata = _interopRequireDefault(_metadata);
  _fieldManager = _interopRequireDefault(_fieldManager);
  _user = _interopRequireDefault(_user);
  _preferences = _interopRequireDefault(_preferences);
  _modelFactory = _interopRequireDefault(_modelFactory);
  _collectionFactory = _interopRequireDefault(_collectionFactory);
  _base = _interopRequireDefault(_base);
  _router = _interopRequireDefault(_router);
  _dateTime = _interopRequireDefault(_dateTime);
  _layoutManager = _interopRequireDefault(_layoutManager);
  _themeManager = _interopRequireDefault(_themeManager);
  _sessionStorage = _interopRequireDefault(_sessionStorage);
  _viewHelper = _interopRequireDefault(_viewHelper);
  _webSocketManager = _interopRequireDefault(_webSocketManager);
  _ajax = _interopRequireDefault(_ajax);
  _numberUtil = _interopRequireDefault(_numberUtil);
  _pageTitle = _interopRequireDefault(_pageTitle);
  _broadcastChannel = _interopRequireDefault(_broadcastChannel);
  _appInit = _interopRequireDefault(_appInit);
  _appParams = _interopRequireDefault(_appParams);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module app */

  /**
   * A main application class.
   *
   * @mixes Events
   */
  class App {
    /**
     * @param {module:app~Options} options Options.
     * @param {function(App): void} callback A callback.
     */
    constructor(options, callback) {
      options = options || {};

      /**
       * An application ID.
       *
       * @private
       * @type {string}
       */
      this.id = options.id || 'espocrm';

      /**
       * Use cache.
       *
       * @private
       * @type {boolean}
       */
      this.useCache = options.useCache || this.useCache;
      this.apiUrl = options.apiUrl || this.apiUrl;

      /**
       * A base path.
       *
       * @type {string}
       */
      this.basePath = options.basePath || '';

      /**
       * A default ajax request timeout.
       *
       * @private
       * @type {Number}
       */
      this.ajaxTimeout = options.ajaxTimeout || 0;

      /**
       * A list of internal modules.
       *
       * @private
       * @type {string[]}
       */
      this.internalModuleList = options.internalModuleList || [];

      /**
       * @private
       */
      this.themeName = options.theme || null;

      /**
       * A list of bundled modules.
       *
       * @private
       * @type {string[]}
       */
      this.bundledModuleList = options.bundledModuleList || [];
      this.appTimestamp = options.appTimestamp;
      this.initCache(options).then(async () => {
        await this.init(options);
        callback(this);
      });
      (0, _appInit.default)();
    }

    /**
     * @private
     * @type {boolean}
     */
    useCache = false;

    /**
     * @protected
     * @type {User}
     */
    user = null;

    /**
     * @private
     * @type {Preferences}
     */
    preferences = null;

    /**
     * @protected
     * @type {module:models/settings}
     */
    settings = null;

    /**
     * @private
     * @type {Metadata}
     */
    metadata = null;

    /**
     * @private
     * @type {module:language}
     */
    language = null;

    /**
     * @private
     * @type {module:field-manager}
     */
    fieldManager = null;

    /**
     * @private
     * @type {module:cache|null}
     */
    cache = null;

    /**
     * @private
     * @type {module:storage|null}
     */
    storage = null;

    /**
     * @private
     */
    loader = null;

    /**
     * An API URL.
     *
     * @private
     */
    apiUrl = 'api/v1';

    /**
     * An auth credentials string.
     *
     * @private
     * @type {?string}
     */
    auth = null;

    /**
     * Another user to login as.
     *
     * @private
     * @type {?string}
     */
    anotherUser = null;

    /**
     * A base controller.
     *
     * @private
     * @type {module:controllers/base}
     */
    baseController = null;

    /**
     * @private
     */
    controllers = null;

    /**
     * @private
     * @type {import('router').default}
     */
    router = null;

    /**
     * @private
     * @type {module:model-factory}
     */
    modelFactory = null;

    /**
     * @private
     * @type {module:collection-factory}
     */
    collectionFactory = null;

    /**
     * A view factory.
     *
     * @private
     * @type {BullFactory}
     */
    viewFactory = null;

    /**
     * App params.
     *
     * @private
     * @type {import('app-params').default}
     */
    appParams;

    /**
     * @type {function(string, function(View))}
     * @private
     */
    viewLoader = null;

    /**
     * @private
     * @type {module:view-helper}
     */
    viewHelper = null;

    /**
     * A body view.
     *
     * @protected
     * @type {string}
     */
    masterView = 'views/site/master';

    /**
     * @private
     * @type {Cache|null}
     */
    responseCache = null;

    /**
     * @private
     * @type {module:broadcast-channel|null}
     */
    broadcastChannel = null;

    /**
     * @private
     * @type {module:date-time|null}
     */
    dateTime = null;

    /**
     * @private
     * @type {module:num-util|null}
     */
    numberUtil = null;

    /**
     * @private
     * @type {module:web-socket-manager}
     */
    webSocketManager;

    /**
     * @private
     * @type {AclManager}
     */
    acl;

    /**
     * An application timestamp. Used for asset cache busting and update detection.
     *
     * @private
     * @type {Number|null}
     */
    appTimestamp = null;

    /** @private */
    started = false;

    /** @private */
    aclName = 'acl';

    /**
     * @private
     * @param {module:app~Options} options
     */
    async initCache(options) {
      if (!this.useCache) {
        return;
      }
      const timestamp = options.cacheTimestamp || null;
      this.cache = new _cache.default(timestamp);
      const storedTimestamp = this.cache.getCacheTimestamp();
      timestamp ? this.cache.handleActuality(timestamp) : this.cache.storeTimestamp();
      if (!window.caches) {
        return;
      }
      const deleteCache = !timestamp || !storedTimestamp || timestamp !== storedTimestamp;
      try {
        if (deleteCache) {
          await caches.delete('espo');
        }
        this.responseCache = await caches.open('espo');
      } catch (e) {
        console.error(`Could not open 'espo' cache.`);
      }
    }

    /**
     * @private
     * @param {module:app~Options} options
     */
    async init(options) {
      this.appParams = new _appParams.default();
      this.controllers = {};

      /**
       * @type {Espo.loader}
       * @private
       */
      this.loader = Espo.loader;
      this.loader.setResponseCache(this.responseCache);
      if (this.useCache && !this.loader.getCacheTimestamp() && options.cacheTimestamp) {
        this.loader.setCacheTimestamp(options.cacheTimestamp);
      }
      this.storage = new _storage.default();
      this.sessionStorage = new _sessionStorage.default();
      this.setupAjax();
      this.settings = new _settings.default(null);
      this.language = new _language.default(this.cache);
      this.metadata = new _metadata.default(this.cache);
      this.fieldManager = new _fieldManager.default();
      _di.container.set(_appParams.default, this.appParams);
      _di.container.set(_storage.default, this.storage);
      _di.container.set(_sessionStorage.default, this.sessionStorage);
      _di.container.set(_settings.default, this.settings);
      _di.container.set(_language.default, this.language);
      _di.container.set(_metadata.default, this.metadata);
      _di.container.set(_fieldManager.default, this.fieldManager);
      this.initBroadcastChannel();
      await Promise.all([this.settings.load(), this.language.loadDefault(), this.initTemplateBundles()]);
      this.loader.setIsDeveloperMode(this.settings.get('isDeveloperMode'));
      this.user = new _user.default();
      this.preferences = new _preferences.default();
      this.preferences.setSettings(this.settings);
      this.acl = this.createAclManager();
      this.fieldManager.acl = this.acl;
      this.themeManager = new _themeManager.default(this.settings, this.preferences, this.metadata, this.themeName);
      this.modelFactory = new _modelFactory.default(this.metadata);
      this.collectionFactory = new _collectionFactory.default(this.modelFactory, this.settings, this.metadata);
      this.webSocketManager = new _webSocketManager.default(this.settings);
      _di.container.set(_aclManager.default, this.acl);
      _di.container.set(_user.default, this.user);
      _di.container.set(_preferences.default, this.preferences);
      _di.container.set(_themeManager.default, this.themeManager);
      _di.container.set(_modelFactory.default, this.modelFactory);
      _di.container.set(_collectionFactory.default, this.collectionFactory);
      _di.container.set(_webSocketManager.default, this.webSocketManager);
      this.initUtils();
      this.initView();
      this.initBaseController();
    }

    /**
     * Start the application.
     */
    start() {
      this.initAuth();
      this.started = true;
      if (!this.auth) {
        this.baseController.login();
        return;
      }
      this.initUserData(null, () => this.onAuth());
    }

    /**
     * @private
     * @param {boolean} [afterLogin]
     */
    async onAuth() {
      let afterLogin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
      await this.metadata.load();
      this.fieldManager.defs = this.metadata.get('fields') || {};
      this.fieldManager.metadata = this.metadata;
      this.settings.setDefs(this.metadata.get('entityDefs.Settings') || {});
      this.preferences.setDefs(this.metadata.get('entityDefs.Preferences') || {});
      this.viewHelper.layoutManager.setUserId(this.user.id);
      if (this.themeManager.isUserTheme()) {
        this.loadStylesheet();
      }
      this.applyUserStyle();
      if (this.anotherUser) {
        this.viewHelper.webSocketManager = null;
      }
      if (this.settings.get('useWebSocket') && !this.anotherUser) {
        this.webSocketManager.setEnabled();
      }
      if (this.webSocketManager.isEnabled()) {
        this.webSocketManager.connect(this.auth, this.user.id);
      }
      const promiseList = [];
      const aclImplementationClassMap = {};
      const clientDefs = this.metadata.get('clientDefs') || {};
      Object.keys(clientDefs).forEach(scope => {
        const o = clientDefs[scope];
        const implClassName = (o || {})[this.aclName];
        if (!implClassName) {
          return;
        }
        const promise = new Promise(resolve => {
          this.loader.require(implClassName, Class => {
            aclImplementationClassMap[scope] = Class;
            resolve();
          });
        });
        promiseList.push(promise);
      });
      if (!this.themeManager.isApplied() && this.themeManager.isUserTheme()) {
        const promise = new Promise(resolve => {
          const check = i => {
            if (this.themeManager.isApplied() || i === 50) {
              resolve();
              return;
            }
            i = i || 0;
            setTimeout(() => check(i + 1), 10);
          };
          check();
        });
        promiseList.push(promise);
      }
      const promise = Promise.all(promiseList);
      if (afterLogin) {
        this.broadcastChannel.postMessage('logged-in');
      }
      await promise;
      this.acl.implementationClassMap = aclImplementationClassMap;
      this.initRouter();
      this.webSocketManager.subscribe('appParamsUpdate', () => this.appParams.load());
    }

    /**
     * @private
     */
    initRouter() {
      const routes = this.metadata.get('app.clientRoutes') || {};
      this.router = new _router.default({
        routes: routes
      });
      _di.container.set(_router.default, this.router);
      this.viewHelper.router = this.router;
      this.baseController.setRouter(this.router);
      this.router.confirmLeaveOutMessage = this.language.translate('confirmLeaveOutMessage', 'messages');
      this.router.confirmLeaveOutConfirmText = this.language.translate('Yes');
      this.router.confirmLeaveOutCancelText = this.language.translate('Cancel');
      this.router.on('routed', params => this.doAction(params));
      try {
        _backbone.default.history.start({
          root: window.location.pathname
        });
      } catch (e) {
        _backbone.default.history.loadUrl();
      }
    }

    /**
     * Do an action.
     *
     * @public
     * @param {{
     *   controller?: string,
     *   action: string,
     *   options?: Object.<string,*>,
     *   controllerClassName?: string,
     * }} params
     */
    doAction(params) {
      this.trigger('action', params);
      this.baseController.trigger('action');
      const callback = controller => {
        try {
          controller.doAction(params.action, params.options);
          this.trigger('action:done');
        } catch (e) {
          console.error(e);
          switch (e.name) {
            case 'AccessDenied':
              this.baseController.error403();
              break;
            case 'NotFound':
              this.baseController.error404();
              break;
            default:
              throw e;
          }
        }
      };
      if (params.controllerClassName) {
        this.createController(params.controllerClassName, null, callback);
        return;
      }
      this.getController(params.controller, callback);
    }

    /**
     * @private
     */
    initBaseController() {
      this.baseController = new _base.default({}, this.getControllerInjection());
      this.viewHelper.baseController = this.baseController;
    }

    /**
     * @private
     */
    getControllerInjection() {
      return {
        viewFactory: this.viewFactory,
        modelFactory: this.modelFactory,
        collectionFactory: this.collectionFactory,
        settings: this.settings,
        user: this.user,
        preferences: this.preferences,
        acl: this.acl,
        cache: this.cache,
        router: this.router,
        storage: this.storage,
        metadata: this.metadata,
        dateTime: this.dateTime,
        broadcastChannel: this.broadcastChannel,
        baseController: this.baseController
      };
    }

    /**
     * @param {string} name
     * @param {function(module:controller): void} callback
     * @private
     */
    getController(name, callback) {
      if (!name) {
        callback(this.baseController);
        return;
      }
      if (name in this.controllers) {
        callback(this.controllers[name]);
        return;
      }
      try {
        let className = this.metadata.get(`clientDefs.${name}.controller`);
        if (!className) {
          const module = this.metadata.get(`scopes.${name}.module`);
          if (!/^[A-Za-z0-9]+$/.test(name)) {
            console.error(`Bad controller name ${name}.`);
            this.baseController.error404();
            return;
          }
          className = _utils.default.composeClassName(module, name, 'controllers');
        }
        this.createController(className, name, callback);
      } catch (e) {
        this.baseController.error404();
      }
    }

    /**
     * @private
     * @return {module:controller}
     */
    createController(className, name, callback) {
      Espo.loader.require(className, controllerClass => {
        const injections = this.getControllerInjection();
        const controller = new controllerClass(this.baseController.params, injections);
        controller.name = name;
        controller.masterView = this.masterView;
        this.controllers[name] = controller;
        callback(controller);
      }, () => this.baseController.error404());
    }

    /**
     * @private
     */
    initUtils() {
      this.dateTime = new _dateTime.default();
      this.dateTime.setSettingsAndPreferences(this.settings, this.preferences);
      this.numberUtil = new _numberUtil.default(this.settings, this.preferences);
      _di.container.set(_dateTime.default, this.dateTime);
      _di.container.set(_numberUtil.default, this.numberUtil);
    }

    /**
     * Create an acl-manager.
     *
     * @protected
     * @return {module:acl-manager}
     */
    createAclManager() {
      return new _aclManager.default(this.user, null, this.settings.get('aclAllowDeleteCreated'));
    }

    /**
     * @private
     */
    initView() {
      const helper = this.viewHelper = new _viewHelper.default();
      helper.layoutManager = new _layoutManager.default(this.cache, this.id);
      helper.settings = this.settings;
      helper.config = this.settings;
      helper.user = this.user;
      helper.preferences = this.preferences;
      helper.acl = this.acl;
      helper.modelFactory = this.modelFactory;
      helper.collectionFactory = this.collectionFactory;
      helper.storage = this.storage;
      helper.sessionStorage = this.sessionStorage;
      helper.dateTime = this.dateTime;
      helper.language = this.language;
      helper.metadata = this.metadata;
      helper.fieldManager = this.fieldManager;
      helper.cache = this.cache;
      helper.themeManager = this.themeManager;
      helper.numberUtil = this.numberUtil;
      helper.pageTitle = new _pageTitle.default(this.settings);
      helper.basePath = this.basePath;
      helper.appParams = this.appParams;
      helper.broadcastChannel = this.broadcastChannel;
      helper.webSocketManager = this.settings.get('useWebSocket') ? this.webSocketManager : null;
      _di.container.set(_viewHelper.default, this.viewHelper);
      _di.container.set(_layoutManager.default, helper.layoutManager);
      _di.container.set(_pageTitle.default, helper.pageTitle);
      this.viewLoader = (viewName, callback) => {
        this.loader.require(_utils.default.composeViewClassName(viewName), callback);
      };
      const internalModuleMap = {};
      const isModuleInternal = module => {
        if (!(module in internalModuleMap)) {
          internalModuleMap[module] = this.internalModuleList.indexOf(module) !== -1;
        }
        return internalModuleMap[module];
      };
      const getResourceInnerPath = (type, name) => {
        let path = null;
        switch (type) {
          case 'template':
            if (~name.indexOf('.')) {
              console.warn(name + ': template name should use slashes for a directory separator.');
            }
            path = 'res/templates/' + name.split('.').join('/') + '.tpl';
            break;
          case 'layoutTemplate':
            path = 'res/layout-types/' + name + '.tpl';
            break;
        }
        return path;
      };
      const getResourcePath = (type, name) => {
        if (!name.includes(':')) {
          return 'client/' + getResourceInnerPath(type, name);
        }
        const [mod, path] = name.split(':');
        if (mod === 'custom') {
          return 'client/custom/' + getResourceInnerPath(type, path);
        }
        if (isModuleInternal(mod)) {
          return 'client/modules/' + mod + '/' + getResourceInnerPath(type, path);
        }
        return 'client/custom/modules/' + mod + '/' + getResourceInnerPath(type, path);
      };
      this.viewFactory = new _bullbone.Factory({
        defaultViewName: 'views/base',
        helper: helper,
        viewLoader: this.viewLoader,
        resources: {
          loaders: {
            template: (name, callback) => {
              const path = getResourcePath('template', name);
              this.loader.require('res!' + path, callback);
            },
            layoutTemplate: (name, callback) => {
              if (Espo.layoutTemplates && name in Espo.layoutTemplates) {
                callback(Espo.layoutTemplates[name]);
                return;
              }
              const path = getResourcePath('layoutTemplate', name);
              this.loader.require('res!' + path, callback);
            }
          }
        },
        preCompiledTemplates: Espo.preCompiledTemplates || {}
      });
    }

    /**
     * @typedef {Record} module:app~LoginData
     * @property {Record} user
     * @property {Record} preferences
     * @property {Record} acl
     * @property {Record} settings
     * @property {Record} appParams
     * @property {string} language
     * @property {{
     *    userName: string,
     *    token: string,
     *    anotherUser?: string,
     * }} auth
     */

    /**
     * @public
     */
    initAuth() {
      this.auth = this.storage.get('user', 'auth') || null;
      this.anotherUser = this.storage.get('user', 'anotherUser') || null;
      this.baseController.on('login', /** module:app~LoginData */data => {
        const userId = data.user.id;
        const userName = data.auth.userName;
        const token = data.auth.token;
        const anotherUser = data.auth.anotherUser || null;
        this.auth = _jsBase.default.encode(userName + ':' + token);
        this.anotherUser = anotherUser;
        const lastUserId = this.storage.get('user', 'lastUserId');
        if (lastUserId !== userId) {
          this.metadata.clearCache();
          this.language.clearCache();
        }
        this.storage.set('user', 'auth', this.auth);
        this.storage.set('user', 'lastUserId', userId);
        this.storage.set('user', 'anotherUser', this.anotherUser);
        this.setCookieAuth(userName, token);
        this.initUserData(data, () => this.onAuth(true));
      });
      this.baseController.on('logout', () => this.logout());
    }

    /**
     * @private
     * @param {boolean} [afterFail]
     * @param {boolean} [silent]
     */
    logout(afterFail, silent) {
      let logoutWait = false;
      if (this.auth && !afterFail) {
        const arr = _jsBase.default.decode(this.auth).split(':');
        if (arr.length > 1) {
          logoutWait = this.appParams.get('logoutWait') || false;
          _ajax.default.postRequest('App/destroyAuthToken', {
            token: arr[1]
          }, {
            resolveWithXhr: true
          }).then(/** XMLHttpRequest */xhr => {
            const redirectUrl = xhr.getResponseHeader('X-Logout-Redirect-Url');
            if (redirectUrl) {
              setTimeout(() => window.location.href = redirectUrl, 50);
              return;
            }
            if (logoutWait) {
              this.doAction({
                action: 'login'
              });
            }
          });
        }
      }
      if (this.webSocketManager.isEnabled()) {
        this.webSocketManager.close();
      }
      silent = silent || afterFail && this.auth && this.auth !== this.storage.get('user', 'auth');
      this.auth = null;
      this.anotherUser = null;
      this.user.clear();
      this.preferences.clear();
      this.acl.clear();
      if (!silent) {
        this.storage.clear('user', 'auth');
        this.storage.clear('user', 'anotherUser');
      }
      const action = logoutWait ? 'logoutWait' : 'login';
      this.doAction({
        action: action
      });
      if (!silent) {
        this.unsetCookieAuth();
      }
      if (this.broadcastChannel.object) {
        if (!silent) {
          this.broadcastChannel.postMessage('logged-out');
        }
      }
      if (!silent) {
        this.sendLogoutRequest();
      }
      this.loadStylesheet();
    }

    /**
     * @private
     */
    sendLogoutRequest() {
      const xhr = new XMLHttpRequest();
      xhr.open('GET', this.basePath + this.apiUrl + '/');
      xhr.setRequestHeader('Authorization', 'Basic ' + _jsBase.default.encode('**logout:logout'));
      xhr.send('');
      xhr.abort();
    }

    /**
     * @private
     */
    loadStylesheet() {
      if (!this.metadata.get(['themes'])) {
        return;
      }
      const path = this.basePath + this.themeManager.getStylesheet();
      const element = document.querySelector('#main-stylesheet');
      if (!element) {
        return;
      }
      element.setAttribute('href', path);
    }

    /**
     * @private
     */
    applyUserStyle() {
      const pageContentWidth = this.preferences.get('pageContentWidth');
      if (pageContentWidth) {
        document.body.dataset.contentWidth = pageContentWidth;
      }
    }

    /**
     * @private
     * @param {string} username
     * @param {string} token
     */
    setCookieAuth(username, token) {
      const date = new Date();
      date.setTime(date.getTime() + 1000 * 24 * 60 * 60 * 1000);
      document.cookie = `auth-token=${token}; SameSite=Lax; expires=${date.toUTCString()}; path=/`;
    }

    /**
     * @private
     */
    unsetCookieAuth() {
      document.cookie = `auth-token=; SameSite=Lax; expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/`;
    }

    /**
     * User data.
     *
     * @typedef {Object} module:app~UserData
     * @property {Record} user
     * @property {Record} preferences
     * @property {Record} acl
     * @property {Record} settings
     * @property {Record} appParams
     * @property {string} language
     */

    /**
     * @private
     * @param {module:app~UserData|null} data
     * @param {function} callback
     */
    async initUserData(data, callback) {
      data = data || {};
      if (this.auth === null) {
        return;
      }
      if (!data.user) {
        data = await this.requestUserData();
      }
      this.language.name = data.language;
      await this.language.load();
      this.dateTime.setLanguage(this.language);
      const userData = data.user || null;
      const preferencesData = data.preferences || null;
      const aclData = data.acl || null;
      const settingData = data.settings || {};
      this.user.setMultiple(userData);
      this.preferences.setMultiple(preferencesData);
      this.settings.clear();
      this.settings.setMultiple(settingData);
      this.acl.set(aclData);
      this.appParams.setAll(data.appParams);
      if (!this.auth) {
        return;
      }
      const xhr = new XMLHttpRequest();
      xhr.open('GET', `${this.basePath}${this.apiUrl}/`);
      xhr.setRequestHeader('Authorization', `Basic ${this.auth}`);
      xhr.onreadystatechange = () => {
        if (xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {
          const arr = _jsBase.default.decode(this.auth).split(':');
          this.setCookieAuth(arr[0], arr[1]);
          callback();
        }
        if (xhr.readyState === XMLHttpRequest.DONE && xhr.status === 401) {
          _ui.default.error('Auth error');
        }
      };
      xhr.send('');
    }

    /**
     * @private
     * @return {Promise<module:app~UserData>}
     */
    async requestUserData() {
      return _ajax.default.getRequest('App/user', {}, {
        appStart: true
      });
    }

    /**
     * @private
     */
    setupAjax() {
      var _this = this;
      /**
       * @param {XMLHttpRequest} xhr
       * @param {Object.<string, *>} options
       */
      const beforeSend = (xhr, options) => {
        if (this.auth !== null && !options.login) {
          xhr.setRequestHeader('Authorization', 'Basic ' + this.auth);
          xhr.setRequestHeader('Espo-Authorization', this.auth);
          xhr.setRequestHeader('Espo-Authorization-By-Token', 'true');
        }
        if (this.anotherUser !== null && !options.login) {
          xhr.setRequestHeader('X-Another-User', this.anotherUser);
        }
      };
      let appTimestampChangeProcessed = false;

      /**
       * @param {XMLHttpRequest} xhr
       * @param {Object.<string, *>} options
       */
      const onSuccess = (xhr, options) => {
        const appTimestampHeader = xhr.getResponseHeader('X-App-Timestamp');
        if (!appTimestampHeader || appTimestampChangeProcessed) {
          return;
        }
        const appTimestamp = parseInt(appTimestampHeader);

        // noinspection JSUnresolvedReference
        const bypassAppReload = options.bypassAppReload;
        if (this.appTimestamp &&
        // this.appTimestamp is set to current time if cache disabled.
        appTimestamp > this.appTimestamp && !bypassAppReload) {
          appTimestampChangeProcessed = true;
          _ui.default.confirm(this.language.translate('confirmAppRefresh', 'messages'), {
            confirmText: this.language.translate('Refresh'),
            cancelText: this.language.translate('Cancel'),
            backdrop: 'static',
            confirmStyle: 'success'
          }).then(() => {
            window.location.reload();
            if (this.broadcastChannel) {
              this.broadcastChannel.postMessage('reload');
            }
          });
        }
      };

      /**
       * @param {module:ajax.Xhr} xhr
       * @param {Object.<string, *>} options
       */
      const onError = function (xhr) {
        let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
        setTimeout(() => {
          if (xhr.errorIsHandled) {
            return;
          }
          switch (xhr.status) {
            case 200:
              _ui.default.error(_this.language.translate('Bad server response'));
              console.error('Bad server response: ' + xhr.responseText);
              break;
            case 401:
              // noinspection JSUnresolvedReference
              if (options.login) {
                break;
              }
              if (_this.auth && _this.router && !_this.router.hasConfirmLeaveOut()) {
                _this.logout(true);
                break;
              }
              if (_this.auth && _this.router && _this.router.hasConfirmLeaveOut()) {
                _ui.default.error(_this.language.translate('loggedOutLeaveOut', 'messages'), true);
                _this.router.trigger('logout');
                break;
              }
              if (_this.auth) {
                // noinspection JSUnresolvedReference
                const silent = !options.appStart;
                _this.logout(true, silent);
              }
              console.error('Error 401: Unauthorized.');
              break;
            case 403:
              // noinspection JSUnresolvedReference
              if (options.main) {
                _this.baseController.error403();
                break;
              }
              _this._processErrorAlert(xhr, 'Access denied');
              break;
            case 400:
              _this._processErrorAlert(xhr, 'Bad request');
              break;
            case 409:
              _this._processErrorAlert(xhr, 'Conflict');
              break;
            case 404:
              // noinspection JSUnresolvedReference
              if (options.main) {
                _this.baseController.error404();
                break;
              }
              _this._processErrorAlert(xhr, 'Not found', true);
              break;
            default:
              _this._processErrorAlert(xhr, null);
          }
          const statusReason = xhr.getResponseHeader('X-Status-Reason');
          if (statusReason) {
            console.error('Server side error ' + xhr.status + ': ' + statusReason);
          }
        }, 0);
      };
      const onTimeout = () => {
        _ui.default.error(this.language.translate('Timeout'), true);
      };
      const onOffline = () => {
        _ui.default.error(this.language.translate('No internet'));
      };
      _ajax.default.configure({
        apiUrl: this.basePath + this.apiUrl,
        timeout: this.ajaxTimeout,
        beforeSend: beforeSend,
        onSuccess: onSuccess,
        onError: onError,
        onTimeout: onTimeout,
        onOffline: onOffline
      });
    }

    /**
     * @private
     * @param {XMLHttpRequest} xhr
     * @param {string|null} label
     * @param {boolean} [noDetail]
     */
    _processErrorAlert(xhr, label, noDetail) {
      let msg = '';
      if (!label) {
        if (xhr.status === 0) {
          msg += this.language.translate('Network error');
        } else if (xhr.status === 500) {
          msg += this.language.translate('Internal server error') + '\n\n' + this.language.translate('checkLogsForDetails', 'messages');
        } else {
          msg += this.language.translate('Error') + ' ' + xhr.status;
        }
      } else {
        msg += this.language.translate(label);
      }
      const obj = {
        msg: msg,
        closeButton: true
      };
      let isMessageDone = false;
      if (noDetail) {
        isMessageDone = true;
      }
      if (!isMessageDone && xhr.responseText && xhr.responseText[0] === '{') {
        /** @type {Object.<string, *>|null} */
        let data = null;
        try {
          data = JSON.parse(xhr.responseText);
        } catch (e) {}
        if (data && data.messageTranslation && data.messageTranslation.label) {
          let msgDetail = this.language.translate(data.messageTranslation.label, 'messages', data.messageTranslation.scope);
          const msgData = data.messageTranslation.data || {};
          for (const key in msgData) {
            msgDetail = msgDetail.replace('{' + key + '}', msgData[key]);
          }
          obj.msg += '\n' + msgDetail;
          obj.closeButton = true;
          isMessageDone = true;
        }
        if (!isMessageDone && data && 'message' in data && data.message) {
          obj.msg += '\n' + data.message;
          obj.closeButton = true;
          isMessageDone = true;
        }
      }
      if (!isMessageDone) {
        const statusReason = xhr.getResponseHeader('X-Status-Reason');
        if (statusReason) {
          obj.msg += '\n' + statusReason;
          obj.closeButton = true;
        }
      }
      _ui.default.error(obj.msg, obj.closeButton);
    }

    /**
     * @private
     */
    initBroadcastChannel() {
      this.broadcastChannel = new _broadcastChannel.default();
      this.broadcastChannel.subscribe(event => {
        if (!this.auth && this.started) {
          if (event.data === 'logged-in') {
            // This works if the same instance opened in different tabs.
            // This does not work for different instances on the same domain
            // which may be the case in dev environment.
            window.location.reload();
          }
          return;
        }
        if (event.data === 'update:all') {
          this.metadata.loadSkipCache();
          this.settings.load();
          this.language.loadSkipCache();
          this.viewHelper.layoutManager.clearLoadedData();
          return;
        }
        if (event.data === 'update:metadata') {
          this.metadata.loadSkipCache();
          return;
        }
        if (event.data === 'update:config') {
          this.settings.load();
          return;
        }
        if (event.data === 'update:language') {
          this.language.loadSkipCache();
          return;
        }
        if (event.data === 'update:layout') {
          this.viewHelper.layoutManager.clearLoadedData();
          return;
        }
        if (event.data === 'update:appParams') {
          this.appParams.load();
          return;
        }
        if (event.data === 'reload') {
          window.location.reload();
          return;
        }
        if (event.data === 'logged-out' && this.started) {
          if (this.auth && this.router.hasConfirmLeaveOut()) {
            _ui.default.error(this.language.translate('loggedOutLeaveOut', 'messages'), true);
            this.router.trigger('logout');
            return;
          }
          this.logout(true);
        }
      });
      _di.container.set(_broadcastChannel.default, this.broadcastChannel);
    }

    /**
     * @private
     */
    async initTemplateBundles() {
      if (!this.responseCache) {
        return;
      }
      const key = 'templateBundlesCached';
      if (this.cache.get('app', key)) {
        return;
      }
      const files = ['client/lib/templates.tpl'];
      this.bundledModuleList.forEach(mod => {
        const file = this.internalModuleList.includes(mod) ? `client/modules/${mod}/lib/templates.tpl` : `client/custom/modules/${mod}/lib/templates.tpl`;
        files.push(file);
      });
      const baseUrl = _utils.default.obtainBaseUrl();
      const timestamp = this.loader.getCacheTimestamp();
      const promiseList = files.map(file => {
        const url = new URL(baseUrl + this.basePath + file);
        url.searchParams.append('t', this.appTimestamp);
        return new Promise(resolve => {
          fetch(url).then(response => {
            if (!response.ok) {
              console.error(`Could not fetch ${url}.`);
              resolve();
              return;
            }
            const promiseList = [];
            response.text().then(text => {
              const index = text.indexOf('\n');
              if (index <= 0) {
                resolve();
                return;
              }
              const delimiter = text.slice(0, index + 1);
              text = text.slice(index + 1);
              text.split(delimiter).forEach(item => {
                const index = item.indexOf('\n');
                const file = item.slice(0, index).trim();
                let content = item.slice(index + 1);

                // noinspection RegExpDuplicateCharacterInClass
                content = content.replace(/[\r|\n|\r\n]$/, '');
                const url = baseUrl + this.basePath + 'client/' + file;
                const urlObj = new URL(url);
                urlObj.searchParams.append('r', timestamp);
                promiseList.push(this.responseCache.put(urlObj, new Response(content)));
              });
            });
            Promise.all(promiseList).then(() => resolve());
          });
        });
      });
      await Promise.all(promiseList);
      this.cache.set('app', key, true);
    }
  }

  /**
   * @callback module:app~callback
   * @param {App} app A created application instance.
   */

  /**
   * Application options.
   *
   * @typedef {Object} module:app~Options
   * @property {string} [id] An application ID.
   * @property {string} [basePath] A base path.
   * @property {boolean} [useCache] Use cache.
   * @property {string} [apiUrl] An API URL.
   * @property {Number} [ajaxTimeout] A default ajax request timeout.
   * @property {string} [internalModuleList] A list of internal modules.
   *   Internal modules located in the `client/modules` directory.
   * @property {string} [bundledModuleList] A list of bundled modules.
   * @property {Number|null} [cacheTimestamp] A cache timestamp.
   * @property {Number|null} [appTimestamp] An application timestamp.
   * @property {string|null} [theme] A theme name.
   */

  Object.assign(App.prototype, _bullbone.Events);
  App.extend = _bullbone.View.extend;
  var _default = _exports.default = App;
});

define("action-handler", ["exports", "bullbone"], function (_exports, _bullbone) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module action-handler */

  /**
   * An action handler. To be extended by specific action handlers.
   */
  class ActionHandler {
    /**
     * @param {import('view').default} view A view.
     */
    constructor(view) {
      /**
       * @protected
       */
      this.view = view;
    }
  }
  ActionHandler.extend = _bullbone.View.extend;
  var _default = _exports.default = ActionHandler;
});

define("acl-portal-manager", ["exports", "acl-manager", "acl-portal"], function (_exports, _aclManager, _aclPortal) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _aclManager = _interopRequireDefault(_aclManager);
  _aclPortal = _interopRequireDefault(_aclPortal);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module acl-portal-manager */

  /**
   * An access checking class for a specific scope for portals.
   */
  class AclPortalManager extends _aclManager.default {
    // noinspection JSUnusedGlobalSymbols
    /**
     * Check if a user in an account of a model.
     *
     * @param {module:model} model A model.
     * @returns {boolean|null} True if in an account, null if not clear.
     */
    checkInAccount(model) {
      const impl = /** @type {module:acl-portal} */this.getImplementation(model.entityType);
      return impl.checkInAccount(model);
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * Check if a user is a contact-owner to a model.
     *
     * @param {module:model} model A model.
     * @returns {boolean|null} True if in a contact-owner, null if not clear.
     */
    checkIsOwnContact(model) {
      const impl = /** @type {module:acl-portal} */
      this.getImplementation(model.entityType);
      return impl.checkIsOwnContact(model);
    }

    /**
     * @param {string} scope A scope.
     * @returns {module:acl-portal}
     */
    getImplementation(scope) {
      if (!(scope in this.implementationHash)) {
        let implementationClass = _aclPortal.default;
        if (scope in this.implementationClassMap) {
          implementationClass = this.implementationClassMap[scope];
        }
        const params = {
          aclAllowDeleteCreated: false,
          forbiddenFieldList: this.getScopeForbiddenFieldList(scope)
        };
        this.implementationHash[scope] = new implementationClass(this.getUser(), scope, params, this);
      }
      return this.implementationHash[scope];
    }
  }
  var _default = _exports.default = AclPortalManager;
});

define("views/list-with-categories", ["exports", "views/list", "collections/tree", "ui"], function (_exports, _list, _tree, _ui) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _list = _interopRequireDefault(_list);
  _tree = _interopRequireDefault(_tree);
  _ui = _interopRequireDefault(_ui);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ListWithCategories extends _list.default {
    template = 'list-with-categories';
    quickCreate = true;
    storeViewAfterCreate = true;
    storeViewAfterUpdate = true;
    currentCategoryId = null;
    currentCategoryName = null;
    categoryField = 'category';
    categoryFilterType = 'inCategory';
    isExpanded = false;
    hasExpandedToggler = true;
    expandedTogglerDisabled = false;
    keepCurrentRootUrl = true;
    hasNavigationPanel = false;
    nestedCollectionIsBeingFetched = false;
    data() {
      const data = {};
      data.hasTree = (this.isExpanded || this.hasNavigationPanel) && !this.categoriesDisabled;
      data.hasNestedCategories = !this.categoriesDisabled;
      data.fallback = !data.hasTree && !data.hasNestedCategories;
      return data;
    }
    setup() {
      super.setup();
      this.addActionHandler('toggleExpandedFromNavigation', () => this.actionToggleExpandedFromNavigation());
      this.addActionHandler('manageCategories', () => this.actionManageCategories());
      this.defaultMaxSize = this.collection.maxSize;
      if (!this.categoryScope) {
        this.categoryScope = `${this.scope}Category`;
      }
      this.categoryField = this.getMetadata().get(`scopes.${this.categoryScope}.categoryField`) || this.categoryField;
      this.isCategoryMultiple = this.getMetadata().get(`entityDefs.${this.scope}.fields.${this.categoryField}.type`) === 'linkMultiple';
      this.showEditLink = !!(this.getAcl().check(this.categoryScope, 'edit') || this.getAcl().check(this.categoryScope, 'create'));
      const isExpandedByDefault = this.getMetadata().get(['clientDefs', this.categoryScope, 'isExpandedByDefault']) || false;
      if (isExpandedByDefault) {
        this.isExpanded = true;
      }
      const isCollapsedByDefault = this.getMetadata().get(['clientDefs', this.categoryScope, 'isCollapsedByDefault']) || false;
      if (isCollapsedByDefault) {
        this.isExpanded = false;
      }
      this.categoriesDisabled = this.categoriesDisabled || this.getMetadata().get(['scopes', this.categoryScope, 'disabled']) || !this.getAcl().checkScope(this.categoryScope, 'read');
      if (this.categoriesDisabled) {
        this.isExpanded = true;
        this.hasExpandedToggler = false;
        this.hasNavigationPanel = false;
      } else if (!this.expandedTogglerDisabled) {
        if (!this.getUser().isPortal() && this.hasIsExpandedStoredValue()) {
          this.isExpanded = this.getIsExpandedStoredValue();
        }
        if (this.getUser().isPortal()) {
          this.hasExpandedToggler = false;
          this.isExpanded = false;
        }
      }
      if (this.hasNavigationPanelStoredValue()) {
        this.hasNavigationPanel = this.getNavigationPanelStoredValue();
      } else {
        this.hasNavigationPanel = this.getMetadata().get(`scopes.${this.categoryScope}.showNavigationPanel`) || this.hasNavigationPanel;
      }
      const params = this.options.params || {};
      if ('categoryId' in params) {
        this.currentCategoryId = params.categoryId;
      }
      this.applyCategoryToCollection();
      this.listenTo(this.collection, 'sync', (_c, _d, o) => {
        if (o && o.openCategory) {
          return;
        }
        this.controlListVisibility();
      });
    }
    prepareCreateReturnDispatchParams(params) {
      if (this.currentCategoryId) {
        params.options ??= {};
        params.options.categoryId = this.currentCategoryId;
        params.options.categoryName = this.currentCategoryName;
      }
    }
    setupReuse(params) {
      super.setupReuse(params);
      this.applyRoutingParams(params);
    }
    applyRoutingParams(params) {
      if ('categoryId' in params) {
        if (params.categoryId !== this.currentCategoryId) {
          this.openCategory(params.categoryId, params.categoryName);
        }
      }
      this.selectCurrentCategory();
    }
    hasTextFilter() {
      var _this$collection$wher;
      return !!(this.collection.data.textFilter || (_this$collection$wher = this.collection.where) !== null && _this$collection$wher !== void 0 && _this$collection$wher.find(it => it.type === 'textFilter'));
    }
    hasNavigationPanelStoredValue() {
      return this.getStorage().has('state', `categories-navigation-panel-${this.scope}`);
    }
    getNavigationPanelStoredValue() {
      const value = this.getStorage().get('state', `categories-navigation-panel-${this.scope}`);
      return value === 'true' || value === true;
    }
    setNavigationPanelStoredValue(value) {
      return this.getStorage().set('state', `categories-navigation-panel-${this.scope}`, value);
    }
    hasIsExpandedStoredValue() {
      return this.getStorage().has('state', `categories-expanded-${this.scope}`);
    }
    getIsExpandedStoredValue() {
      const value = this.getStorage().get('state', `categories-expanded-${this.scope}`);
      return value === 'true' || value === true;
    }
    setIsExpandedStoredValue(value) {
      return this.getStorage().set('state', `categories-expanded-${this.scope}`, value);
    }
    afterRender() {
      this.$nestedCategoriesContainer = this.$el.find('.nested-categories-container');
      this.$listContainer = this.$el.find('.list-container');
      if (!this.hasView('list')) {
        if (!this.isExpanded) {
          this.hideListContainer();
        }
        this.loadList();
      } else {
        this.controlListVisibility();
      }
      if (!this.categoriesDisabled && (this.isExpanded || this.hasNavigationPanel) && !this.hasView('categories')) {
        this.loadCategories();
      }
      if (!this.hasView('nestedCategories') && !this.categoriesDisabled) {
        this.loadNestedCategories();
      }
      this.$el.focus();
    }
    clearCategoryViews() {
      this.clearNestedCategoriesView();
      this.clearCategoriesView();
    }
    clearCategoriesView() {
      this.clearView('categories');
    }
    clearNestedCategoriesView() {
      this.clearView('nestedCategories');
    }
    emptyListContainer() {
      this.$listContainer.empty();
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * @private
     */
    async actionExpand() {
      this.isExpanded = true;
      this.setIsExpandedStoredValue(true);
      this.applyCategoryToCollection();
      this.clearNestedCategoriesView();
      if (this.getCategoriesView()) {
        this.getCategoriesView().isExpanded = true;
        this.getCategoriesView().expandToggleInactive = true;
      }
      this.reRender().then(() => {});
      this.emptyListContainer();
      await this.collection.fetch();
      if (this.getCategoriesView()) {
        this.getCategoriesView().expandToggleInactive = false;
        await this.getCategoriesView().reRender();
      }
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * @private
     */
    async actionCollapse() {
      this.isExpanded = false;
      this.setIsExpandedStoredValue(false);
      this.applyCategoryToCollection();
      this.applyCategoryToNestedCategoriesCollection();
      this.clearNestedCategoriesView();
      if (this.getCategoriesView()) {
        this.getCategoriesView().isExpanded = false;
        this.getCategoriesView().expandToggleInactive = true;
      }
      this.reRender().then(() => {});
      this.emptyListContainer();
      await this.collection.fetch();
      if (this.getCategoriesView()) {
        this.getCategoriesView().expandToggleInactive = false;
        await this.getCategoriesView().reRender();
      }
    }

    // noinspection JSUnusedGlobalSymbols
    actionOpenCategory(data) {
      this.openCategory(data.id || null, data.name);
      this.selectCurrentCategory();
      this.navigateToCurrentCategory();
    }
    navigateToCurrentCategory() {
      let url = `#${this.scope}`;
      if (this.currentCategoryId) {
        url += `/list/categoryId=${this.currentCategoryId}`;
        if (this._primaryFilter) {
          url += `&primaryFilter=${this.getHelper().escapeString(this._primaryFilter)}`;
        }
      } else {
        if (this._primaryFilter) {
          url += `/list/primaryFilter=${this.getHelper().escapeString(this._primaryFilter)}`;
        }
      }
      this.getRouter().navigate(url);
      this.updateLastUrl();
    }
    selectCurrentCategory() {
      const categoriesView = this.getCategoriesView();
      if (categoriesView) {
        categoriesView.setSelected(this.currentCategoryId);
        categoriesView.reRender();
      }
    }
    openCategory(id) {
      let name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
      this.getNestedCategoriesView().isLoading = true;
      this.getNestedCategoriesView().reRender();
      this.getNestedCategoriesView().isLoading = false;
      this.nestedCategoriesCollection.reset();
      this.collection.reset();
      this.collection.offset = 0;
      this.collection.maxSize = this.defaultMaxSize;
      this.emptyListContainer();
      this.currentCategoryId = id;
      this.currentCategoryName = name || id;
      this.applyCategoryToNestedCategoriesCollection();
      this.applyCategoryToCollection();
      this.collection.abortLastFetch();
      if (this.nestedCategoriesCollection) {
        this.nestedCategoriesCollection.abortLastFetch();
        this.hideListContainer();
        this.$nestedCategoriesContainer.addClass('hidden');
        Espo.Ui.notifyWait();
        const promises = [this.nestedCategoriesCollection.fetch().then(() => this.updateHeader()), this.collection.fetch({
          openCategory: true
        })];
        Promise.all(promises).then(() => {
          Espo.Ui.notify(false);
          this.controlNestedCategoriesVisibility();
          this.controlListVisibility();
        });
        return;
      }
      this.collection.fetch().then(() => {
        Espo.Ui.notify(false);
      });
    }

    /**
     * @private
     */
    controlListVisibility() {
      if (this.isExpanded) {
        this.showListContainer();
        return;
      }
      if (this.nestedCollectionIsBeingFetched) {
        return;
      }
      if (!this.collection.models.length && this.nestedCategoriesCollection && this.nestedCategoriesCollection.models.length && !this.hasTextFilter()) {
        this.hideListContainer();
        return;
      }
      this.showListContainer();
    }
    controlNestedCategoriesVisibility() {
      this.$nestedCategoriesContainer.removeClass('hidden');
    }
    async getTreeCollection() {
      const collection = await this.getCollectionFactory().create(this.categoryScope);
      if (!(collection instanceof _tree.default)) {
        throw new Error(`Non-tree collection.`);
      }
      collection.url = `${collection.entityType}/action/listTree`;
      collection.setOrder(null, null);

      // @todo Revise. To remove?
      //this.collection.treeCollection = collection;

      await collection.fetch();
      return collection;
    }
    applyCategoryToNestedCategoriesCollection() {
      if (!this.nestedCategoriesCollection) {
        return;
      }
      this.nestedCategoriesCollection.parentId = this.currentCategoryId;
      this.nestedCategoriesCollection.currentCategoryId = this.currentCategoryId;
      this.nestedCategoriesCollection.currentCategoryName = this.currentCategoryName || this.currentCategoryId;
      this.nestedCategoriesCollection.where = [];
    }
    getNestedCategoriesCollection(callback) {
      this.getCollectionFactory().create(this.categoryScope).then(async collection => {
        if (!(collection instanceof _tree.default)) {
          throw new Error(`Non-tree collection.`);
        }
        this.nestedCategoriesCollection = collection;
        collection.setOrder(null, null);
        collection.url = `${collection.entityType}/action/listTree`;
        collection.data.checkIfEmpty = true;
        if (!this.getAcl().checkScope(this.scope, 'create')) {
          collection.data.onlyNotEmpty = true;
        }
        this.applyCategoryToNestedCategoriesCollection();
        this.nestedCollectionIsBeingFetched = true;

        // Needed even in expanded mode to display the header path.
        await collection.fetch();
        this.nestedCollectionIsBeingFetched = false;
        this.controlNestedCategoriesVisibility();
        this.controlListVisibility();
        this.updateHeader();
        callback.call(this, collection);
      });
    }
    getNestedCategoriesView() {
      return this.getView('nestedCategories');
    }
    getCategoriesView() {
      return this.getView('categories');
    }
    loadNestedCategories() {
      this.getNestedCategoriesCollection(collection => {
        this.createView('nestedCategories', 'views/record/list-nested-categories', {
          collection: collection,
          itemCollection: this.collection,
          selector: '.nested-categories-container',
          showEditLink: this.showEditLink,
          isExpanded: this.isExpanded,
          hasExpandedToggler: this.hasExpandedToggler,
          hasNavigationPanel: this.hasNavigationPanel,
          subjectEntityType: this.collection.entityType,
          primaryFilter: this._primaryFilter
        }).then(view => {
          view.render();
        });
      });
    }
    async loadCategories() {
      const collection = await this.getTreeCollection();
      const view = await this.createView('categories', 'views/record/list-tree', {
        collection: collection,
        selector: '.categories-container',
        selectable: true,
        showRoot: true,
        buttonsDisabled: true,
        checkboxes: false,
        showEditLink: this.showEditLink,
        isExpanded: this.isExpanded,
        hasExpandedToggler: this.hasExpandedToggler,
        readOnly: true
      });
      if (this.currentCategoryId) {
        view.setSelected(this.currentCategoryId);
      }
      view.render().then(() => {});
      this.listenTo(view, 'select', model => {
        if (!this.isExpanded) {
          let id = null;
          let name = null;
          if (model && model.id) {
            id = model.id;
            name = model.attributes.name;
          }
          this.openCategory(id, name);
          this.navigateToCurrentCategory();
          return;
        }
        this.currentCategoryId = null;
        this.currentCategoryName = '';
        if (model && model.id) {
          this.currentCategoryId = model.id;
          this.currentCategoryName = model.attributes.name;
        }
        this.collection.offset = 0;
        this.collection.maxSize = this.defaultMaxSize;
        this.collection.reset();
        this.applyCategoryToCollection();
        this.collection.abortLastFetch();
        this.openCategory(this.currentCategoryId, this.currentCategoryName);
        this.navigateToCurrentCategory();
      });
    }

    /**
     * @todo Move to helper. Together with select-records view.
     */
    applyCategoryToCollection() {
      this.collection.whereFunction = () => {
        let filter;
        const isExpanded = this.isExpanded;
        if (!isExpanded && !this.hasTextFilter()) {
          if (this.isCategoryMultiple) {
            if (this.currentCategoryId) {
              filter = {
                attribute: this.categoryField,
                type: 'linkedWith',
                value: [this.currentCategoryId]
              };
            } else {
              filter = {
                attribute: this.categoryField,
                type: 'isNotLinked'
              };
            }
          } else {
            if (this.currentCategoryId) {
              filter = {
                attribute: this.categoryField + 'Id',
                type: 'equals',
                value: this.currentCategoryId
              };
            } else {
              filter = {
                attribute: this.categoryField + 'Id',
                type: 'isNull'
              };
            }
          }
        } else {
          if (this.currentCategoryId) {
            filter = {
              attribute: this.categoryField,
              type: this.categoryFilterType,
              value: this.currentCategoryId
            };
          }
        }
        if (filter) {
          return [filter];
        }
        return [];
      };
    }
    getCreateAttributes() {
      let data;
      if (this.isCategoryMultiple) {
        if (this.currentCategoryId) {
          const names = {};
          names[this.currentCategoryId] = this.getCurrentCategoryName();
          data = {};
          const idsAttribute = this.categoryField + 'Ids';
          const namesAttribute = this.categoryField + 'Names';
          data[idsAttribute] = [this.currentCategoryId];
          data[namesAttribute] = names;
          return data;
        }
        return null;
      }
      const idAttribute = this.categoryField + 'Id';
      const nameAttribute = this.categoryField + 'Name';
      data = {};
      data[idAttribute] = this.currentCategoryId;
      data[nameAttribute] = this.getCurrentCategoryName();
      return data;
    }
    getCurrentCategoryName() {
      if (this.currentCategoryName) {
        return this.currentCategoryName;
      }
      if (this.nestedCategoriesCollection && this.nestedCategoriesCollection.categoryData && this.nestedCategoriesCollection.categoryData.name) {
        return this.nestedCategoriesCollection.categoryData.name;
      }
      return this.currentCategoryId;
    }
    actionManageCategories() {
      this.clearCategoryViews();
      const url = `#${this.categoryScope}`;
      const options = {};
      if (this.currentCategoryId) {
        options.currentId = this.currentCategoryId;
      }
      this.getRouter().navigate(url, {
        trigger: false
      });
      this.getRouter().dispatch(this.categoryScope, 'listTree', options);
    }
    getHeader() {
      var _this$nestedCategorie, _this$nestedCategorie2, _this$nestedCategorie3;
      if (!this.nestedCategoriesCollection) {
        return super.getHeader();
      }
      const path = this.nestedCategoriesCollection.path;
      if (!path || path.length === 0) {
        return super.getHeader();
      }
      let rootUrl = `#${this.scope}`;
      if (this._primaryFilter) {
        const filterPart = this.getHelper().escapeString(this._primaryFilter);
        rootUrl += `/list/primaryFilter=${filterPart}`;
      }
      const root = document.createElement('span');
      root.style.userSelect = 'none';
      const a = document.createElement('a');
      a.href = rootUrl;
      a.textContent = this.translate(this.scope, 'scopeNamesPlural');
      a.dataset.action = 'openCategory';
      a.classList.add('action');
      a.style.userSelect = 'none';
      root.append(a);
      const iconHtml = this.getHeaderIconHtml();
      if (iconHtml) {
        root.insertAdjacentHTML('afterbegin', iconHtml);
      }
      const list = [root];
      const currentName = (_this$nestedCategorie = this.nestedCategoriesCollection.categoryData) === null || _this$nestedCategorie === void 0 ? void 0 : _this$nestedCategorie.name;
      const upperId = (_this$nestedCategorie2 = this.nestedCategoriesCollection.categoryData) === null || _this$nestedCategorie2 === void 0 ? void 0 : _this$nestedCategorie2.upperId;
      const upperName = (_this$nestedCategorie3 = this.nestedCategoriesCollection.categoryData) === null || _this$nestedCategorie3 === void 0 ? void 0 : _this$nestedCategorie3.upperName;
      if (path.length > 2) {
        list.push('...');
      }
      if (upperId) {
        const upperIdPart = this.getHelper().escapeString(upperId);
        let url = `${rootUrl}/list/categoryId=${upperIdPart}`;
        if (this._primaryFilter) {
          const filterPart = this.getHelper().escapeString(this._primaryFilter);
          url += `&primaryFilter=${filterPart}`;
        }
        const folder = document.createElement('a');
        folder.href = url;
        folder.textContent = upperName ?? null;
        folder.classList.add('action');
        folder.dataset.action = 'openCategory';
        folder.dataset.id = upperId;
        folder.dataset.name = upperName;
        folder.style.userSelect = 'none';
        list.push(folder);
      }
      const last = document.createElement('span');
      last.textContent = currentName ?? null;
      last.dataset.action = 'fullRefresh';
      last.style.cursor = 'pointer';
      last.style.userSelect = 'none';
      list.push(last);
      return this.buildHeaderHtml(list);
    }
    updateHeader() {
      var _this$getHeaderView;
      (_this$getHeaderView = this.getHeaderView()) === null || _this$getHeaderView === void 0 || _this$getHeaderView.reRender();
    }
    hideListContainer() {
      this.$listContainer.addClass('hidden');
    }
    showListContainer() {
      this.$listContainer.removeClass('hidden');
    }

    // noinspection JSUnusedGlobalSymbols
    async actionToggleNavigationPanel() {
      this.hasNavigationPanel = !this.hasNavigationPanel;
      this.setNavigationPanelStoredValue(this.hasNavigationPanel);
      await this.reRender();
      this.loadNestedCategories();
    }
    prepareRecordViewOptions(options) {
      super.prepareRecordViewOptions(options);
      options.forceDisplayTopBar = false;
    }
    async actionToggleExpandedFromNavigation() {
      this.isExpanded = !this.isExpanded;
      this.hasNavigationPanel = true;
      this.setNavigationPanelStoredValue(this.hasNavigationPanel);
      const a = this.element.querySelector('a[data-role="expandButtonContainer"]');
      if (a) {
        a.classList.add('disabled');
      }
      _ui.default.notifyWait();
      if (this.isExpanded) {
        await this.actionExpand();
      } else {
        await this.actionCollapse();
      }
      _ui.default.notify();
    }
    async actionFullRefresh() {
      var _this$nestedCategorie4;
      await Promise.all([super.actionFullRefresh(), (_this$nestedCategorie4 = this.nestedCategoriesCollection) === null || _this$nestedCategorie4 === void 0 ? void 0 : _this$nestedCategorie4.fetch()]);
    }
  }
  var _default = _exports.default = ListWithCategories;
});

define("views/global-stream", ["exports", "view", "views/stream/record/list", "views/record/search", "search-manager"], function (_exports, _view, _list, _search, _searchManager) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  _list = _interopRequireDefault(_list);
  _search = _interopRequireDefault(_search);
  _searchManager = _interopRequireDefault(_searchManager);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class GlobalStreamView extends _view.default {
    // language=Handlebars
    templateContent = `
        <div class="page-header">
            <div class="row">
                <div class="col-sm-7 col-xs-5">
                    <h3>
                        <span
                            data-action="fullRefresh"
                            style="user-select: none; cursor: pointer"
                        >{{translate 'GlobalStream' category='scopeNames'}}</span>
                    </h3>
                </div>
                <div class="col-sm-5 col-xs-7"></div>
            </div>
        </div>
        <div class="search-container">{{{search}}}</div>
        <div class="row">
            <div class="col-md-8">
                <div class="list-container list-container-panel">{{{list}}}</div>
            </div>
        </div>
    `;
    collection;
    setup() {
      this.wait((async () => {
        this.collection = await this.getCollectionFactory().create('Note');
        this.collection.url = 'GlobalStream';
        this.collection.maxSize = this.getConfig().get('recordsPerPage');
        this.collection.paginationByNumber = true;
        this.setupSearchManager();
        await this.createSearchView();
      })());
      this.addActionHandler('fullRefresh', () => this.actionFullRefresh());
    }
    setupSearchManager() {
      const searchManager = new _searchManager.default(this.collection);
      searchManager.loadStored();
      this.collection.where = searchManager.getWhere();
      this.searchManager = searchManager;
    }
    createSearchView() {
      this.searchView = new _search.default({
        collection: this.collection,
        searchManager: this.searchManager,
        isWide: true,
        filtersLayoutName: 'filtersGlobal'
      });
      return this.assignView('search', this.searchView, '.search-container');
    }
    afterRender() {
      if (!this.listView) {
        this.fetchAndRender();
      }
    }
    fetchAndRender() {
      Espo.Ui.notifyWait();
      this.collection.fetch().then(() => {
        this.listView = new _list.default({
          collection: this.collection,
          isUserStream: true
        });
        this.assignView('list', this.listView, '.list-container').then(() => {
          Espo.Ui.notify(false);
          this.listView.render();
        });
      });
    }

    /**
     * @private
     */
    async actionFullRefresh() {
      Espo.Ui.notifyWait();
      await this.collection.fetch();
      Espo.Ui.notify();
    }
  }
  var _default = _exports.default = GlobalStreamView;
});

define("views/edit", ["exports", "views/main"], function (_exports, _main) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _main = _interopRequireDefault(_main);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * An edit view.
   */
  class EditView extends _main.default {
    template = 'edit';
    name = 'Edit';
    optionsToPass = ['returnUrl', 'returnDispatchParams', 'attributes', 'rootUrl', 'duplicateSourceId', 'returnAfterCreate', 'highlightFieldList'];

    /**
     * A header view name.
     */
    headerView = 'views/header';

    /**
     * A record view name.
     */
    recordView = 'views/record/edit';

    /**
     * A root breadcrumb item not to be a link.
     */
    rootLinkDisabled = false;

    /**
     * A root URL.
     */

    nameAttribute = 'name';
    setup() {
      var _this$options$params;
      if (!this.model.entityType) {
        throw new Error('No entity type.');
      }
      this.entityType = this.model.entityType;
      this.headerView = this.options.headerView || this.headerView;
      this.recordView = this.options.recordView || this.recordView;
      this.rootUrl = this.options.rootUrl ?? ((_this$options$params = this.options.params) === null || _this$options$params === void 0 ? void 0 : _this$options$params.rootUrl) ?? this.rootUrl ?? `#${this.scope}`;
      if (this.entityType) {
        this.nameAttribute = this.getMetadata().get(`clientDefs.${this.entityType}.nameAttribute`) ?? this.nameAttribute;
      }
      this.setupHeader();
      this.setupRecord();
    }
    setupFinal() {
      super.setupFinal();
      this.wait(this.getHelper().processSetupHandlers(this, 'edit'));
    }

    /**
     * Set up a header.
     */
    setupHeader() {
      this.createView('header', this.headerView, {
        model: this.model,
        fullSelector: '#main > .header',
        scope: this.scope
      });
    }

    /**
     * Set up a record.
     */
    setupRecord() {
      const o = {
        model: this.model,
        fullSelector: '#main > .record',
        scope: this.scope,
        shortcutKeysEnabled: true
      };
      this.optionsToPass.forEach(option => {
        o[option] = this.options[option];
      });
      const params = this.options.params ?? {};
      o.rootUrl = this.rootUrl;
      if (params.rootData) {
        o.rootData = params.rootData;
      }
      if (params.focusForCreate) {
        o.focusForCreate = true;
      }
      return this.createView('record', this.getRecordViewName(), o);
    }
    getRecordView() {
      return this.getView('record');
    }

    /**
     * Get a record view name.
     */
    getRecordViewName() {
      return this.getMetadata().get('clientDefs.' + this.scope + '.recordViews.edit') ?? this.recordView;
    }
    getHeader() {
      const scopeLabel = this.getLanguage().translate(this.scope, 'scopeNamesPlural');
      let root = document.createElement('span');
      root.textContent = scopeLabel;
      root.style.userSelect = 'none';
      if (!this.options.noHeaderLinks && !this.rootLinkDisabled) {
        const a = document.createElement('a');
        a.href = this.rootUrl;
        a.classList.add('action');
        a.dataset.action = 'navigateToRoot';
        a.text = scopeLabel;
        root = document.createElement('span');
        root.style.userSelect = 'none';
        root.append(a);
      }
      const iconHtml = this.getHeaderIconHtml();
      if (iconHtml) {
        root.insertAdjacentHTML('afterbegin', iconHtml);
      }
      if (this.model.isNew()) {
        const create = document.createElement('span');
        create.textContent = this.getLanguage().translate('create');
        create.style.userSelect = 'none';
        return this.buildHeaderHtml([root, create]);
      }
      const name = this.model.attributes[this.nameAttribute] || this.model.id;
      let title = document.createElement('span');
      title.textContent = name;
      if (!this.options.noHeaderLinks) {
        const url = `#${this.scope}/view/${this.model.id}`;
        const a = document.createElement('a');
        a.href = url;
        a.classList.add('action');
        a.append(title);
        title = a;
      }
      return this.buildHeaderHtml([root, title]);
    }
    updatePageTitle() {
      if (this.model.isNew()) {
        const title = this.getLanguage().translate('Create') + ' ' + this.getLanguage().translate(this.scope, 'scopeNames');
        this.setPageTitle(title);
        return;
      }
      const name = this.model.attributes[this.nameAttribute];
      const title = name ? name : this.getLanguage().translate(this.scope, 'scopeNames');
      this.setPageTitle(title);
    }
    setupReuse(params) {
      // noinspection BadExpressionStatementJS
      params;
      const recordView = this.getRecordView();
      if (!recordView) {
        return;
      }
      if (!recordView.setupReuse) {
        return;
      }
      recordView.setupReuse();
    }
  }
  var _default = _exports.default = EditView;
});

define("views/detail", ["exports", "views/main", "views/detail/modes", "ui", "ajax"], function (_exports, _main, _modes, _ui, _ajax) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _main = _interopRequireDefault(_main);
  _modes = _interopRequireDefault(_modes);
  _ui = _interopRequireDefault(_ui);
  _ajax = _interopRequireDefault(_ajax);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * A detail view.
   */
  class DetailView extends _main.default {
    template = 'detail';
    name = 'Detail';
    optionsToPass = ['attributes', 'returnUrl', 'returnDispatchParams', 'rootUrl'];

    /**
     * A header view name.
     */
    headerView = 'views/header';

    /**
     * A record view name.
     */
    recordView = 'views/record/detail';

    /**
     * A root breadcrumb item not to be a link.
     */
    rootLinkDisabled = false;

    /**
     * A root URL.
     */

    /**
     * Is return.
     */
    isReturn = false;

    /**
     * A shortcut-key => action map.
     */
    shortcutKeys = null;

    /**
     * An entity type.
     */

    /**
     * A default view mode.
     */
    defaultViewMode = 'detail';

    /**
     * A view mode.
     */

    hasMultipleModes = false;
    /**
     * A 'detail' view mode.
     */
    MODE_DETAIL = 'detail';

    /**
     * An available view mode list.
     */

    setup() {
      var _this$options$params, _this$options$params2;
      if (!this.model.entityType) {
        throw new Error('No entity type.');
      }
      this.entityType = this.model.entityType;
      this.headerView = this.options.headerView || this.headerView;
      this.recordView = this.options.recordView || this.recordView;
      this.rootUrl = this.options.rootUrl ?? ((_this$options$params = this.options.params) === null || _this$options$params === void 0 ? void 0 : _this$options$params.rootUrl) ?? this.rootUrl ?? `#${this.scope}`;
      this.isReturn = this.options.isReturn || ((_this$options$params2 = this.options.params) === null || _this$options$params2 === void 0 ? void 0 : _this$options$params2.isReturn) || false;
      this.nameAttribute = this.getMetadata().get(`clientDefs.${this.entityType}.nameAttribute`) ?? 'name';
      this.setupModes();
      this.setupHeader();
      this.setupRecord();
      this.setupPageTitle();
      this.initFollowButtons();
      this.initStarButtons();
      this.initRedirect();
      this.addActionHandler('fullRefresh', () => this.actionFullRefresh());
    }
    setupFinal() {
      super.setupFinal();
      this.wait(this.getHelper().processSetupHandlers(this, 'detail'));
    }
    initRedirect() {
      var _this$options$params3;
      if (!((_this$options$params3 = this.options.params) !== null && _this$options$params3 !== void 0 && _this$options$params3.isAfterCreate)) {
        return;
      }
      const redirect = () => {
        _ui.default.success(this.translate('Created'));
        setTimeout(() => {
          this.getRouter().navigate(this.rootUrl, {
            trigger: true
          });
        }, 1000);
      };
      if (this.model.lastSyncPromise && this.model.lastSyncPromise.getStatus() === 403) {
        redirect();
        return;
      }
      this.listenToOnce(this.model, 'fetch-forbidden', () => redirect());
    }

    /**
     * Set up a page title.
     */
    setupPageTitle() {
      this.listenTo(this.model, 'after:save', () => {
        this.updatePageTitle();
      });
      this.listenTo(this.model, 'sync', model => {
        if (model && model.hasChanged(this.nameAttribute)) {
          this.updatePageTitle();
        }
      });
    }

    /**
     * Set up a header.
     */
    setupHeader() {
      this.createView('header', this.headerView, {
        model: this.model,
        fullSelector: '#main > .header',
        scope: this.scope,
        fontSizeFlexible: true
      });
      this.listenTo(this.model, 'sync', model => {
        if (model && model.hasChanged(this.nameAttribute)) {
          var _this$getHeaderView;
          (_this$getHeaderView = this.getHeaderView()) === null || _this$getHeaderView === void 0 || _this$getHeaderView.reRender({
            buffer: true
          });
        }
      });
    }

    /**
     * Set up modes.
     */
    setupModes() {
      this.defaultViewMode = this.options.defaultViewMode || this.getMetadata().get(`clientDefs.${this.scope}.detailDefaultViewMode`) || this.defaultViewMode;
      this.viewMode = this.viewMode || this.defaultViewMode;
      const viewModeList = this.options.viewModeList ?? this.viewModeList ?? this.getMetadata().get(`clientDefs.${this.scope}.detailViewModeList`);
      this.viewModeList = viewModeList ? viewModeList : [this.MODE_DETAIL];
      this.viewModeIsStorable = this.viewModeIsStorable !== undefined ? this.viewModeIsStorable : this.getMetadata().get(`clientDefs.${this.scope}.detailViewModeIsStorable`);
      this.hasMultipleModes = this.viewModeList.length > 1;
      if (this.viewModeIsStorable && this.hasMultipleModes) {
        let viewMode = null;
        const modeKey = this.getViewModeKey();
        if (this.getStorage().has('state', modeKey)) {
          const storedViewMode = this.getStorage().get('state', modeKey);
          if (storedViewMode && this.viewModeList.includes(storedViewMode)) {
            viewMode = storedViewMode;
          }
        }
        if (!viewMode) {
          viewMode = this.defaultViewMode;
        }
        this.viewMode = viewMode;
      }
      if (this.hasMultipleModes) {
        this.addActionHandler('switchMode', (_e, target) => this.switchViewMode(target.dataset.value));
        this.modesView = new _modes.default({
          mode: this.viewMode,
          modeList: this.viewModeList,
          scope: this.scope
        });
        this.assignView('modes', this.modesView, '.modes');
      }
    }
    getViewModeKey() {
      return `detailViewMode-${this.scope}-${this.model.id}}`;
    }

    /**
     * Set up a record.
     */
    async setupRecord() {
      const o = {
        model: this.model,
        fullSelector: '#main > .record',
        scope: this.scope,
        shortcutKeysEnabled: true,
        isReturn: this.isReturn
      };
      this.optionsToPass.forEach(option => {
        o[option] = this.options[option];
      });
      const params = this.options.params ?? {};
      o.rootUrl = this.rootUrl;
      if (params.rootData) {
        var _this$options$params4;
        o.rootData = (_this$options$params4 = this.options.params) === null || _this$options$params4 === void 0 ? void 0 : _this$options$params4.rootData;
      }
      if (this.model.get('deleted')) {
        o.readOnly = true;
      }
      const view = await this.createView('record', this.getRecordViewName(), o);
      this.listenTo(view, 'after:mode-change', mode => {
        // Mode change should also re-render the header what the methods do.
        mode === 'edit' ? this.hideAllHeaderActionItems() : this.showAllHeaderActionItems();
      });
      if (this.modesView) {
        this.listenTo(view, 'after:set-detail-mode', () => this.modesView.enable());
        this.listenTo(view, 'after:set-edit-mode', () => this.modesView.disable());
      }
      return view;
    }

    /**
     * Get a record view name.
     */
    getRecordViewName() {
      return this.getMetadata().get(`clientDefs.${this.scope}.recordViews.${this.viewMode}`) ?? this.recordView;
    }

    /**
     * Switch a view mode.
     *
     * @param mode A mode.
     */
    async switchViewMode(mode) {
      this.clearView('record');
      this.setViewMode(mode, true);
      _ui.default.notifyWait();
      if (this.modesView) {
        this.modesView.changeMode(mode).then(() => {});
      }
      const view = await this.setupRecord();
      await view.render();
      _ui.default.notify();
    }

    /**
     * Set a view mode.
     *
     * @param {string} mode A mode.
     * @param {boolean} [toStore=false] To preserve a mode being set.
     */
    setViewMode(mode) {
      let toStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
      this.viewMode = mode;
      if (toStore && this.viewModeIsStorable) {
        const modeKey = this.getViewModeKey();
        this.getStorage().set('state', modeKey, mode);
      }
    }
    initStarButtons() {
      if (!this.getMetadata().get(`scopes.${this.scope}.stars`)) {
        return;
      }
      this.addStarButtons();
      this.listenTo(this.model, 'change:isStarred', () => this.controlStarButtons());
    }
    addStarButtons() {
      const isStarred = this.model.get('isStarred');
      this.addMenuItem('buttons', {
        name: 'unstar',
        iconHtml: '<span class="fas fa-star fa-sm text-warning"></span>',
        className: 'btn-s-wide',
        text: this.translate('Starred'),
        hidden: !isStarred,
        style: 'text',
        //title: this.translate('Unstar'),
        onClick: () => this.actionUnstar()
      }, true);
      this.addMenuItem('buttons', {
        name: 'star',
        iconHtml: '<span class="far fa-star fa-sm"></span>',
        className: 'btn-s-wide',
        text: this.translate('Star'),
        style: 'text',
        hidden: isStarred || !this.model.has('isStarred'),
        onClick: () => this.actionStar()
      }, true);
    }
    controlStarButtons() {
      const isStarred = this.model.get('isStarred');
      if (isStarred) {
        this.hideHeaderActionItem('star');
        this.showHeaderActionItem('unstar');
        return;
      }
      this.hideHeaderActionItem('unstar');
      this.showHeaderActionItem('star');
    }

    /**
     * Action 'star'.
     */
    actionStar() {
      this.disableMenuItem('star');
      _ajax.default.putRequest(`${this.entityType}/${this.model.id}/starSubscription`).then(() => {
        this.hideHeaderActionItem('star');
        this.model.set('isStarred', true, {
          sync: true
        });
      }).finally(() => this.enableMenuItem('star'));
    }

    /**
     * Action 'unstar'.
     */
    actionUnstar() {
      this.disableMenuItem('unstar');
      _ajax.default.deleteRequest(`${this.entityType}/${this.model.id}/starSubscription`).then(() => {
        this.hideHeaderActionItem('unstar');
        this.model.set('isStarred', false, {
          sync: true
        });
      }).finally(() => this.enableMenuItem('unstar'));
    }
    initFollowButtons() {
      if (!this.getMetadata().get(['scopes', this.scope, 'stream'])) {
        return;
      }
      this.addFollowButtons();
      this.listenTo(this.model, 'change:isFollowed', () => {
        this.controlFollowButtons();
      });
    }
    addFollowButtons() {
      const isFollowed = this.model.get('isFollowed');
      this.addMenuItem('buttons', {
        name: 'unfollow',
        label: 'Followed',
        style: 'text',
        iconHtml: '<span class="fas fa-rss fa-sm text-success"></span>',
        className: 'text-success',
        action: 'unfollow',
        hidden: !isFollowed,
        onClick: () => this.actionUnfollow()
      }, true);
      this.addMenuItem('buttons', {
        name: 'follow',
        label: 'Follow',
        style: 'text',
        iconHtml: '<span class="fas fa-rss fa-sm"></span>',
        text: this.translate('Follow'),
        action: 'follow',
        hidden: isFollowed || !this.model.has('isFollowed') || !this.getAcl().checkModel(this.model, 'stream'),
        onClick: () => this.actionFollow()
      }, true);
    }
    controlFollowButtons() {
      const isFollowed = this.model.get('isFollowed');
      if (isFollowed) {
        this.hideHeaderActionItem('follow');
        this.showHeaderActionItem('unfollow');
        return;
      }
      this.hideHeaderActionItem('unfollow');
      if (this.getAcl().checkModel(this.model, 'stream')) {
        this.showHeaderActionItem('follow');
      }
    }

    /**
     * Action 'follow'.
     */
    actionFollow() {
      this.disableMenuItem('follow');
      _ajax.default.putRequest(`${this.entityType}/${this.model.id}/subscription`).then(() => {
        this.hideHeaderActionItem('follow');
        this.model.set('isFollowed', true, {
          sync: true
        });
        this.enableMenuItem('follow');
      }).catch(() => {
        this.enableMenuItem('follow');
      });
    }

    /**
     * Action 'unfollow'.
     */
    actionUnfollow() {
      this.disableMenuItem('unfollow');
      _ajax.default.deleteRequest(`${this.entityType}/${this.model.id}/subscription`).then(() => {
        this.hideHeaderActionItem('unfollow');
        this.model.set('isFollowed', false, {
          sync: true
        });
        this.enableMenuItem('unfollow');
      }).catch(() => {
        this.enableMenuItem('unfollow');
      });
    }
    getHeader() {
      const name = this.model.attributes[this.nameAttribute] || this.model.id;
      const title = document.createElement('span');
      title.classList.add('font-size-flexible', 'title');
      title.textContent = name;
      if (this.model.attributes.deleted) {
        title.style.textDecoration = 'line-through';
      }
      if (this.getRecordMode() === 'detail') {
        title.title = this.translate('clickToRefresh', 'messages');
        title.dataset.action = 'fullRefresh';
        title.style.cursor = 'pointer';
      }
      const scopeLabel = this.getLanguage().translate(this.scope, 'scopeNamesPlural');
      let root = document.createElement('span');
      root.textContent = scopeLabel;
      root.style.userSelect = 'none';
      if (!this.rootLinkDisabled) {
        const a = document.createElement('a');
        a.href = this.rootUrl;
        a.classList.add('action');
        a.dataset.action = 'navigateToRoot';
        a.text = scopeLabel;
        root = document.createElement('span');
        root.style.userSelect = 'none';
        root.append(a);
      }
      const iconHtml = this.getHeaderIconHtml();
      if (iconHtml) {
        root.insertAdjacentHTML('afterbegin', iconHtml);
      }
      return this.buildHeaderHtml([root, title]);
    }
    updatePageTitle() {
      if (this.model.has(this.nameAttribute)) {
        this.setPageTitle(this.model.attributes[this.nameAttribute] || this.model.id);
        return;
      }
      super.updatePageTitle();
    }
    getRecordView() {
      return this.getView('record');
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * Action 'duplicate'.
     */
    actionDuplicate() {
      _ui.default.notifyWait();
      _ajax.default.postRequest(`${this.scope}/action/getDuplicateAttributes`, {
        id: this.model.id
      }).then(attributes => {
        _ui.default.notify();
        const url = `#${this.scope}/create`;
        this.getRouter().dispatch(this.scope, 'create', {
          attributes: attributes,
          returnUrl: this.getRouter().getCurrentUrl(),
          options: {
            duplicateSourceId: this.model.id
          }
        });
        this.getRouter().navigate(url, {
          trigger: false
        });
      });
    }
    hideAllHeaderActionItems() {
      var _this$getHeaderView2;
      (_this$getHeaderView2 = this.getHeaderView()) === null || _this$getHeaderView2 === void 0 || _this$getHeaderView2.hideAllMenuItems();
    }
    showAllHeaderActionItems() {
      var _this$getHeaderView3;
      (_this$getHeaderView3 = this.getHeaderView()) === null || _this$getHeaderView3 === void 0 || _this$getHeaderView3.showAllActionItems();
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * Hide a view mode.
     *
     * @param {string} mode A mode.
     * @since 8.4.0
     */
    hideViewMode(mode) {
      if (!this.modesView) {
        return;
      }
      this.modesView.hideMode(mode);
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * Show a view mode.
     *
     * @param {string} mode A mode.
     * @since 8.4.0
     */
    showViewMode(mode) {
      if (!this.modesView) {
        return;
      }
      this.modesView.showMode(mode);
    }
    async actionFullRefresh() {
      if (this.getRecordMode() === 'edit') {
        return;
      }
      _ui.default.notifyWait();
      await this.model.fetch();
      this.model.trigger('update-all');
      _ui.default.notify();
    }
    getRecordMode() {
      if (this.getRecordView().getMode) {
        return this.getRecordView().getMode();
      }
      return 'detail';
    }
    setupReuse(params) {
      // noinspection BadExpressionStatementJS
      params;
      const recordView = this.getRecordView();
      if (!recordView) {
        return;
      }
      if (!recordView.setupReuse) {
        return;
      }
      recordView.setupReuse();
    }
  }
  var _default = _exports.default = DetailView;
});

define("views/user/record/detail", ["exports", "views/record/detail"], function (_exports, _detail) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _detail = _interopRequireDefault(_detail);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class UserDetailRecordView extends _detail.default {
    sideView = 'views/user/record/detail-side';
    bottomView = 'views/user/record/detail-bottom';
    editModeDisabled = true;

    /**
     * @name model
     * @type module:models/user
     * @memberOf UserDetailRecordView#
     */

    setup() {
      super.setup();
      this.setupNonAdminFieldsAccess();
      if (this.getUser().isAdmin() && !this.model.isPortal()) {
        this.addButton({
          name: 'access',
          label: 'Access',
          style: 'default',
          onClick: () => this.actionAccess()
        });
      }
      const isPortalUser = this.model.isPortal() || this.model.id === this.getUser().id && this.getUser().isPortal();
      if ((this.model.id === this.getUser().id || this.getUser().isAdmin()) && this.getConfig().get('auth2FA') && (this.model.isRegular() || this.model.isAdmin() || isPortalUser && this.getConfig().get('auth2FAInPortal'))) {
        this.addButton({
          name: 'viewSecurity',
          label: 'Security'
        });
      }
      if (this.model.id === this.getUser().id && !this.model.isApi() && (this.getUser().isAdmin() || !this.getHelper().getAppParam('passwordChangeForNonAdminDisabled'))) {
        this.addDropdownItem({
          name: 'changePassword',
          label: 'Change Password',
          style: 'default'
        });
      }
      if (this.getUser().isAdmin() && (this.model.isRegular() || this.model.isAdmin() || this.model.isPortal()) && !this.model.isSuperAdmin()) {
        this.addDropdownItem({
          name: 'sendPasswordChangeLink',
          label: 'Send Password Change Link',
          action: 'sendPasswordChangeLink',
          hidden: !this.model.get('emailAddress')
        });
        this.addDropdownItem({
          name: 'generateNewPassword',
          label: 'Generate New Password',
          action: 'generateNewPassword',
          hidden: !this.model.get('emailAddress')
        });
        if (!this.model.get('emailAddress')) {
          this.listenTo(this.model, 'sync', () => {
            if (this.model.get('emailAddress')) {
              this.showActionItem('generateNewPassword');
              this.showActionItem('sendPasswordChangeLink');
            } else {
              this.hideActionItem('generateNewPassword');
              this.hideActionItem('sendPasswordChangeLink');
            }
          });
        }
      }
      if (this.model.isPortal() || this.model.isApi()) {
        this.hideActionItem('duplicate');
      }
      if (this.model.id === this.getUser().id) {
        this.listenTo(this.model, 'after:save', () => {
          this.getUser().set(this.model.getClonedAttributes());
        });
      }
      if (this.getUser().isAdmin() && this.model.isRegular() && !this.getConfig().get('authAnotherUserDisabled')) {
        this.addDropdownItem({
          label: 'Log in',
          name: 'login',
          action: 'login'
        });
      }
      this.setupFieldAppearance();
    }
    setupActionItems() {
      super.setupActionItems();
      if (this.model.isApi() && this.getUser().isAdmin()) {
        this.addDropdownItem({
          'label': 'Generate New API Key',
          'name': 'generateNewApiKey'
        });
      }
    }
    setupNonAdminFieldsAccess() {
      if (this.getUser().isAdmin()) {
        return;
      }
      let nonAdminReadOnlyFieldList = ['userName', 'isActive', 'teams', 'roles', 'password', 'portals', 'portalRoles', 'defaultTeam', 'contact', 'accounts', 'type', 'emailAddress'];
      nonAdminReadOnlyFieldList = nonAdminReadOnlyFieldList.filter(item => {
        if (!this.model.hasField(item)) {
          return true;
        }
        const aclDefs = /** @type {Object.<string, *>|null} */
        this.getMetadata().get(['entityAcl', 'User', 'fields', item]);
        if (!aclDefs) {
          return true;
        }
        if (aclDefs.nonAdminReadOnly) {
          return true;
        }
        return false;
      });
      nonAdminReadOnlyFieldList.forEach(field => {
        this.setFieldReadOnly(field, true);
      });
      if (!this.getAcl().checkScope('Team')) {
        this.setFieldReadOnly('defaultTeam', true);
      }
      this.hideField('layoutSet', true);
    }
    setupFieldAppearance() {
      this.controlFieldAppearance();
      this.listenTo(this.model, 'change', () => {
        this.controlFieldAppearance();
      });
    }
    controlFieldAppearance() {
      if (this.model.get('type') === 'portal') {
        this.hideField('roles');
        this.hideField('teams');
        this.hideField('defaultTeam');
        this.showField('portals');
        this.showField('portalRoles');
        this.showField('contact');
        this.showField('accounts');
        this.showPanel('portal');
        this.hideField('title');
      } else {
        this.showField('roles');
        this.showField('teams');
        this.showField('defaultTeam');
        this.hideField('portals');
        this.hideField('portalRoles');
        this.hideField('contact');
        this.hideField('accounts');
        this.hidePanel('portal');
        if (this.model.get('type') === 'api') {
          this.hideField('title');
          this.hideField('emailAddress');
          this.hideField('phoneNumber');
          this.hideField('name');
          this.hideField('gender');
          if (this.model.get('authMethod') === 'Hmac') {
            this.showField('secretKey');
          } else {
            this.hideField('secretKey');
          }
        } else {
          this.showField('title');
        }
      }
      if (this.model.id === this.getUser().id) {
        this.setFieldReadOnly('type');
      } else {
        if (this.model.get('type') === 'admin' || this.model.get('type') === 'regular') {
          this.setFieldNotReadOnly('type');
          this.setFieldOptionList('type', ['regular', 'admin']);
        } else {
          this.setFieldReadOnly('type');
        }
      }
      if (!this.getConfig().get('auth2FA') || !(this.model.isRegular() || this.model.isAdmin())) {
        this.hideField('auth2FA');
      }
    }

    // noinspection JSUnusedGlobalSymbols
    actionChangePassword() {
      Espo.Ui.notifyWait();
      this.createView('changePassword', 'views/modals/change-password', {
        userId: this.model.id
      }, view => {
        view.render();
        Espo.Ui.notify(false);
        this.listenToOnce(view, 'changed', () => {
          setTimeout(() => {
            this.getBaseController().logout();
          }, 2000);
        });
      });
    }

    // noinspection JSUnusedGlobalSymbols
    actionPreferences() {
      this.getRouter().navigate('#Preferences/edit/' + this.model.id, {
        trigger: true
      });
    }

    // noinspection JSUnusedGlobalSymbols
    actionEmailAccounts() {
      this.getRouter().navigate('#EmailAccount/list/userId=' + this.model.id, {
        trigger: true
      });
    }

    // noinspection JSUnusedGlobalSymbols
    actionExternalAccounts() {
      this.getRouter().navigate('#ExternalAccount', {
        trigger: true
      });
    }

    // noinspection JSUnusedGlobalSymbols
    actionAccess() {
      Espo.Ui.notifyWait();
      Espo.Ajax.getRequest(`User/${this.model.id}/acl`).then(aclData => {
        this.createView('access', 'views/user/modals/access', {
          aclData: aclData,
          model: this.model
        }, view => {
          Espo.Ui.notify(false);
          view.render();
        });
      });
    }
    getGridLayout(callback) {
      const layoutName = this.options.layoutName || this.layoutName;
      this.getHelper().layoutManager.get(this.model.entityType, layoutName, simpleLayout => {
        const layout = Espo.Utils.cloneDeep(simpleLayout);
        const hasTab = layout.find(it => it.tabBreak) !== undefined;
        if (!this.getUser().isPortal()) {
          layout.push({
            label: "Teams and Access Control",
            name: "accessControl",
            tabBreak: hasTab,
            tabLabel: this.translate('Settings', 'scopeNames'),
            rows: [[{
              "name": "type"
            }, {
              "name": "isActive"
            }], [{
              "name": "teams"
            }, {
              "name": "defaultTeam"
            }], [{
              "name": "roles"
            }, false]]
          });
          if (this.model.isPortal()) {
            layout.push({
              "label": "Portal",
              "name": "portal",
              "rows": [[{
                "name": "portals"
              }, {
                "name": "accounts"
              }], [{
                "name": "portalRoles"
              }, {
                "name": "contact"
              }]]
            });
            if (this.getUser().isAdmin()) {
              layout.push({
                "label": "Misc",
                "name": "portalMisc",
                "rows": [[{
                  "name": "dashboardTemplate"
                }, false]]
              });
            }
          }
          if (this.model.isAdmin() || this.model.isRegular()) {
            layout.push({
              "label": "Misc",
              "name": "misc",
              "rows": [[{
                "name": "workingTimeCalendar"
              }, {
                "name": "layoutSet"
              }]]
            });
          }
        }
        if (this.getUser().isAdmin() && this.model.isApi()) {
          layout.push({
            "name": "auth",
            "rows": [[{
              "name": "authMethod"
            }, false], [{
              "name": "apiKey"
            }, {
              "name": "secretKey"
            }]]
          });
        }
        this.detailLayout = layout;
        const gridLayout = {
          type: 'record',
          layout: this.convertDetailLayout(layout)
        };
        callback(gridLayout);
      });
    }

    // noinspection JSUnusedGlobalSymbols
    actionGenerateNewApiKey() {
      this.confirm(this.translate('confirmation', 'messages'), () => {
        Espo.Ajax.postRequest('UserSecurity/apiKey/generate', {
          id: this.model.id
        }).then(data => {
          this.model.set(data);
        });
      });
    }

    // noinspection JSUnusedGlobalSymbols
    actionViewSecurity() {
      this.createView('dialog', 'views/user/modals/security', {
        userModel: this.model
      }, view => {
        view.render();
      });
    }

    // noinspection JSUnusedGlobalSymbols
    actionSendPasswordChangeLink() {
      this.confirm({
        message: this.translate('sendPasswordChangeLinkConfirmation', 'messages', 'User'),
        confirmText: this.translate('Send', 'labels', 'Email')
      }).then(() => {
        Espo.Ui.notify(this.translate('pleaseWait', 'messages'));
        Espo.Ajax.postRequest('UserSecurity/password/recovery', {
          id: this.model.id
        }).then(() => {
          Espo.Ui.success(this.translate('Done'));
        });
      });
    }

    // noinspection JSUnusedGlobalSymbols
    actionGenerateNewPassword() {
      this.confirm(this.translate('generateAndSendNewPassword', 'messages', 'User')).then(() => {
        Espo.Ui.notifyWait();
        Espo.Ajax.postRequest('UserSecurity/password/generate', {
          id: this.model.id
        }).then(() => {
          Espo.Ui.success(this.translate('Done'));
        });
      });
    }

    // noinspection JSUnusedGlobalSymbols
    actionLogin() {
      const anotherUser = this.model.get('userName');
      const username = this.getUser().get('userName');
      this.createView('dialog', 'views/user/modals/login-as', {
        model: this.model,
        anotherUser: anotherUser,
        username: username
      }).then(view => view.render());
    }
  }
  var _default = _exports.default = UserDetailRecordView;
});

define("views/user/record/detail-side", ["exports", "views/record/detail-side"], function (_exports, _detailSide) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _detailSide = _interopRequireDefault(_detailSide);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class UserDetailSideRecordView extends _detailSide.default {
    setupPanels() {
      super.setupPanels();
      const userModel = /** @type {import('modules/user').default} */this.model;
      if (userModel.isApi() || userModel.isSystem()) {
        this.hidePanel('activities', true);
        this.hidePanel('history', true);
        this.hidePanel('tasks', true);
        this.hidePanel('stream', true);
        return;
      }
      const showActivities = this.getAcl().checkPermission('userCalendar', userModel);
      if (!showActivities && this.getAcl().getPermissionLevel('userCalendar') === 'team' && !this.model.has('teamsIds')) {
        this.listenToOnce(this.model, 'sync', () => {
          if (!this.getAcl().checkPermission('userCalendar', userModel)) {
            return;
          }
          this.onPanelsReady(() => {
            this.showPanel('activities', 'acl');
            this.showPanel('history', 'acl');
            if (!userModel.isPortal()) {
              this.showPanel('tasks', 'acl');
            }
          });
        });
      }
      if (!showActivities) {
        this.hidePanel('activities', false, 'acl');
        this.hidePanel('history', false, 'acl');
        this.hidePanel('tasks', false, 'acl');
      }
      if (userModel) {
        this.hidePanel('tasks', true);
      }
    }
  }
  _exports.default = UserDetailSideRecordView;
});

define("views/user/modals/select-position", ["exports", "views/modal", "model", "views/record/edit-for-modal", "views/fields/enum"], function (_exports, _modal, _model, _editForModal, _enum) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  _model = _interopRequireDefault(_model);
  _editForModal = _interopRequireDefault(_editForModal);
  _enum = _interopRequireDefault(_enum);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class UserSelectPositionModalView extends _modal.default {
    templateContent = '<div class="record no-side-margin">{{{record}}}</div>';
    className = 'dialog dialog-record';
    shortcutKeys = {
      'Control+Enter': 'apply'
    };

    /**
     * @param {{
     *     positionList: string[],
     *     position: string|null,
     *     name: string,
     *     onApply: function(string|null),
     * }} options
     */
    constructor(options) {
      super(options);

      /** @private */
      this.props = options;
    }
    setup() {
      this.headerText = this.translate('changePosition', 'actions', 'User') + ' · ' + this.props.name;
      this.buttonList = [{
        name: 'save',
        label: 'Save',
        style: 'primary',
        onClick: () => this.apply()
      }, {
        name: 'cancel',
        label: 'Cancel'
      }];
      this.model = new _model.default();
      this.model.setMultiple({
        position: this.props.position
      });
      this.recordView = new _editForModal.default({
        model: this.model,
        detailLayout: [{
          rows: [[{
            view: new _enum.default({
              name: 'position',
              params: {
                options: ['', ...this.props.positionList]
              },
              labelText: this.translate('teamRole', 'fields', 'User')
            })
          }, false]]
        }]
      });
      this.assignView('record', this.recordView, '.record');
    }

    /**
     * @private
     */
    apply() {
      if (this.recordView.validate()) {
        return;
      }
      this.props.onApply(this.model.attributes.position);
      this.close();
    }
    onBackdropClick() {
      if (this.recordView.hasChanged()) {
        return;
      }
      this.close();
    }
  }
  _exports.default = UserSelectPositionModalView;
});

define("views/stream/reactions", ["exports", "view", "views/record/list", "helpers/misc/reactions"], function (_exports, _view, _list, _reactions) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  _list = _interopRequireDefault(_list);
  _reactions = _interopRequireDefault(_reactions);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class NoteReactionsView extends _view.default {
    // language=Handlebars
    templateContent = `
        {{#each dataList}}
            <a
                class="reaction-count small text-soft"
                role="button"
                title="{{label}}"
                data-type="{{type}}"
            >
                <span data-role="icon" class="{{iconClass}} {{#if reacted}} text-warning {{/if}}"></span>
                <span data-role="count">{{count}}</span>
            </a>
        {{/each}}
    `;

    /**
     * @private
     * @type {string[]}
     */
    availableReactions;

    /**
     * @type {Object.<string, string>}
     * @private
     */
    iconClassMap;

    /**
     * @private
     * @type {{destroy: function(), show: function()}}
     */
    popover;

    /**
     * @param {{
     *     model: import('model').default,
     * }} options
     */
    constructor(options) {
      super(options);
    }
    data() {
      /** @type {Record.<string, number>} */
      const counts = this.model.attributes.reactionCounts || {};
      /** @type {string[]} */
      const myReactions = this.model.attributes.myReactions || [];
      return {
        dataList: this.availableReactions.filter(type => counts[type]).map(type => {
          return {
            type: type,
            count: counts[type].toString(),
            label: this.translate('Reactions') + ' · ' + this.translate(type, 'reactions'),
            iconClass: this.iconClassMap[type],
            reacted: myReactions.includes(type)
          };
        })
      };
    }
    setup() {
      const reactionsHelper = new _reactions.default();
      this.availableReactions = reactionsHelper.getAvailableReactions();
      const list = reactionsHelper.getDefinitionList();
      this.iconClassMap = list.reduce((o, it) => {
        o[it.type] = it.iconClass;
        return o;
      }, {});
      this.addHandler('click', 'a.reaction-count', (e, target) => this.showUsers(target.dataset.type));
    }

    /**
     * @private
     * @param {string} type
     */
    async showUsers(type) {
      const a = this.element.querySelector(`a.reaction-count[data-type="${type}"]`);

      /*if (this.popover) {
          this.popover.destroy();
      }*/

      const popover = Espo.Ui.popover(a, {
        placement: 'bottom',
        content: `
                <div class="center-align for-list-view">
                    <span class="fas fa-spinner fa-spin text-soft"></span>
                </div>
            `,
        preventDestroyOnRender: true,
        noToggleInit: true,
        keepElementTitle: true,
        title: this.translate('Reactions') + ' · ' + this.translate(type, 'reactions'),
        onHide: () => {
          this.popover = undefined;
          this.trigger('popover-hidden');
        }
      }, this);
      this.popover = popover;
      const id = popover.show();
      document.querySelector(`#${id}`).classList.add('popover-list-view');
      const selector = `#${id} .popover-content`;

      /** @type {HTMLElement|null} */
      const container = document.querySelector(selector);

      /** @type {import('collection').default} */
      const users = await this.getCollectionFactory().create('User');
      users.url = `Note/${this.model.id}/reactors/${type}`;
      users.maxSize = this.getConfig().get('recordsPerPageSmall') || 5;
      await users.fetch();
      if (!document.body.contains(container)) {
        popover.hide();
        return;
      }
      const listView = new _list.default({
        collection: users,
        listLayout: [{
          name: 'name',
          view: 'views/user/fields/name',
          link: true
        }],
        checkboxes: false,
        displayTotalCount: false,
        headerDisabled: true,
        buttonsDisabled: true,
        rowActionsDisabled: true
      });
      await this.assignView('users', listView);
      listView.setSelector(selector);
      await listView.render();
      this.listenToOnce(listView, 'modal-shown', () => popover.destroy());
    }

    // @todo Prevent popover disappearing.
    reRenderWhenNoPopover() {
      if (this.popover) {
        this.once('popover-hidden', () => this.reRender());
        return;
      }
      this.reRender();
    }
  }
  _exports.default = NoteReactionsView;
});

define("views/stream/panel", ["exports", "views/record/panels/relationship", "underscore", "views/note/fields/post", "view-record-helper", "views/fields/text"], function (_exports, _relationship, _underscore, _post, _viewRecordHelper, _text) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _relationship = _interopRequireDefault(_relationship);
  _underscore = _interopRequireDefault(_underscore);
  _post = _interopRequireDefault(_post);
  _viewRecordHelper = _interopRequireDefault(_viewRecordHelper);
  _text = _interopRequireDefault(_text);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class PanelStreamView extends _relationship.default {
    template = 'stream/panel';
    rowActionsView = 'views/stream/record/row-actions/default';
    postingMode = false;
    postDisabled = false;
    relatedListFiltersDisabled = true;
    layoutName = null;
    filterList = ['all', 'posts', 'updates'];
    /** @type {import('collections/note').default} */
    collection;

    /** @private */
    _justPosted = false;

    /** @type {import('collections/note').default} */
    pinnedCollection;

    /**
     * @protected
     * @type {string}
     */
    placeholderText;

    /**
     * @private
     * @type {import('model').default}
     */
    seed;
    additionalEvents = {
      /** @this PanelStreamView */
      'focus textarea[data-name="post"]': function () {
        this.enablePostingMode(true);
      },
      /** @this PanelStreamView */
      'keydown textarea[data-name="post"]': function (e) {
        if (Espo.Utils.getKeyFromKeyEvent(e) === 'Control+Enter') {
          e.stopPropagation();
          e.preventDefault();
          this.post();
        }

        // Don't hide to be able to focus on the upload button.
        /*if (e.code === 'Tab') {
            let $text = $(e.currentTarget);
              if ($text.val() === '') {
                this.disablePostingMode();
            }
        }*/
      },
      /** @this PanelStreamView */
      'input textarea[data-name="post"]': function () {
        this.controlPreviewButton();
        this.controlPostButtonAvailability(this.postFieldView.getTextAreaElement().value);
      }
    };
    data() {
      const data = super.data();
      data.postDisabled = this.postDisabled;
      data.placeholderText = this.placeholderText;
      data.allowInternalNotes = this.allowInternalNotes;
      data.hasPinned = this.hasPinned;
      return data;
    }
    controlPreviewButton() {
      this.$previewButton = this.$previewButton || this.$el.find('.stream-post-preview');
      if (this.postFieldView.getTextAreaElement().value === '') {
        this.$previewButton.addClass('hidden');
      } else {
        this.$previewButton.removeClass('hidden');
      }
    }

    /**
     * @private
     * @param {boolean} [byFocus]
     */
    enablePostingMode(byFocus) {
      this.$el.find('.buttons-panel').removeClass('hide');
      if (!this.postingMode) {
        if (this.postFieldView.getTextAreaElement().value) {
          this.postFieldView.controlTextareaHeight();
        }
        let isClicked = false;
        $('body').on('click.stream-panel', e => {
          if (byFocus && !isClicked) {
            isClicked = true;
            return;
          }
          const $target = $(e.target);
          if ($target.parent().hasClass('remove-attachment')) {
            return;
          }
          if ($.contains(this.$postContainer.get(0), e.target)) {
            return;
          }
          if (this.postFieldView.getTextAreaElement().value !== '') {
            return;
          }
          if ($(e.target).closest('.popover-content').get(0)) {
            return;
          }
          const attachmentsIds = this.seed.get('attachmentsIds') || [];
          if (!attachmentsIds.length && (!this.getAttachmentsFieldView() || !this.getAttachmentsFieldView().isUploading)) {
            this.disablePostingMode();
          }
        });
      }
      this.postingMode = true;
      this.controlPreviewButton();
    }
    disablePostingMode() {
      this.postingMode = false;
      this.setPostText(null);
      if (this.getAttachmentsFieldView()) {
        this.getAttachmentsFieldView().empty();
      }
      this.$el.find('.buttons-panel').addClass('hide');
      $('body').off('click.stream-panel');
      this.postFieldView.getTextAreaElement().rows = 1;
    }
    setup() {
      this.events = {
        ...this.additionalEvents,
        ...this.events
      };
      this.addHandler('click', 'button.post', () => this.post());
      this.addActionHandler('switchInternalMode', () => this.switchInternalMode());
      this.addActionHandler('preview', () => this.preview());
      this.entityType = this.model.entityType;
      this.filter = this.getStoredFilter();
      this.setupTitle();
      this.placeholderText = this.placeholderText || this.translate('writeYourCommentHere', 'messages');
      this.allowInternalNotes = false;
      if (!this.getUser().isPortal()) {
        this.allowInternalNotes = this.getMetadata().get(['streamDefs', this.entityType, 'allowInternalNotes']);
      }
      this.hasPinned = this.model.entityType !== 'User';
      this.isInternalNoteMode = false;
      this.storageTextKey = `stream-post-${this.model.entityType}-${this.model.id}`;
      this.storageAttachmentsKey = `stream-post-attachments-${this.model.entityType}-${this.model.id}`;
      this.storageIsInernalKey = `stream-post-is-internal-${this.model.entityType}-${this.model.id}`;
      this.on('remove', () => {
        this.storeControl();
        $(window).off('beforeunload.stream-' + this.cid);
      });
      $(window).off(`beforeunload.stream-${this.cid}`);
      $(window).on(`beforeunload.stream-${this.cid}`, () => {
        this.storeControl();
      });

      /** @private */
      this.formRecordHelper = new _viewRecordHelper.default();
      const storedAttachments = this.getSessionStorage().get(this.storageAttachmentsKey);
      this.setupActions();
      const promise = this.getModelFactory().create('Note', model => {
        this.seed = model;
        if (storedAttachments) {
          this.hasStoredAttachments = true;
          this.seed.set({
            attachmentsIds: storedAttachments.idList,
            attachmentsNames: storedAttachments.names,
            attachmentsTypes: storedAttachments.types
          });
        }
        if (this.allowInternalNotes) {
          if (this.getMetadata().get(['entityDefs', 'Note', 'fields', 'isInternal', 'default'])) {
            this.isInternalNoteMode = true;
          }
          if (this.getSessionStorage().has(this.storageIsInernalKey)) {
            this.isInternalNoteMode = this.getSessionStorage().get(this.storageIsInernalKey);
          }
        }
        if (this.isInternalNoteMode) {
          this.seed.set('isInternal', true);
        }
        this.postFieldView = new _post.default({
          name: 'post',
          mode: 'edit',
          params: {
            required: true,
            rowsMin: 1,
            preview: false,
            attachmentField: 'attachments'
          },
          model: this.seed,
          placeholderText: this.placeholderText,
          noResize: true,
          recordHelper: this.formRecordHelper
        });
        this.assignView('postField', this.postFieldView, '.textarea-container').then(view => {
          this.initPostEvents(view);
        });
        this.wait(this.createCollection().then(() => this.setupPinned()));
        this.listenTo(this.seed, 'change:attachmentsIds', () => {
          this.controlPostButtonAvailability();
        });
      });
      this.wait(promise);
      if (!this.defs.hidden) {
        this.subscribeToWebSocket();
      }
      this.once('show', () => {
        if (!this.isSubscribedToWebSocket) {
          this.subscribeToWebSocket();
        }
      });
      this.on('remove', () => {
        if (this.isSubscribedToWebSocket) {
          this.unsubscribeFromWebSocket();
        }
      });
    }
    switchInternalMode() {
      this.isInternalNoteMode = !this.isInternalNoteMode;
      if (this.internalModeButtonElement) {
        this.isInternalNoteMode ? this.internalModeButtonElement.classList.add('enabled') : this.internalModeButtonElement.classList.remove('enabled');
      }
    }
    subscribeToWebSocket() {
      if (!this.webSocketManager.isEnabled()) {
        return;
      }
      if (this.model.entityType === 'User') {
        return;
      }
      const topic = `streamUpdate.${this.model.entityType}.${this.model.id}`;
      this.streamUpdateWebSocketTopic = topic;
      this.isSubscribedToWebSocket = true;
      this.webSocketManager.subscribe(topic, (t, /** Record */data) => {
        if (data.createdById === this.getUser().id && this._justPosted) {
          return;
        }
        if (data.noteId) {
          const model = this.collection.get(data.noteId);
          if (model) {
            model.fetch().then(() => this.syncPinnedModel(model, true));
          }
          if (!data.pin) {
            return;
          }
        }
        this.collection.fetchNew();
      });
    }
    unsubscribeFromWebSocket() {
      this.webSocketManager.unsubscribe(this.streamUpdateWebSocketTopic);
    }
    setupTitle() {
      this.title = this.getHelper().escapeString(this.translate('Stream'));
      this.titleHtml = this.title;
      if (this.filter && this.filter !== 'all') {
        const filterPart = this.getHelper().escapeString(this.translate(this.filter, 'filters', 'Note'));
        this.titleHtml += ' &middot; ' + filterPart;
      }
    }

    /**
     * @private
     */
    storeControl() {
      let isNotEmpty = false;
      if (this.isRendered()) {
        const text = /** @type {string} */this.seed.attributes.post;
        if (text && text.length) {
          this.getSessionStorage().set(this.storageTextKey, text);
          isNotEmpty = true;
        } else if (this.hasStoredText) {
          this.getSessionStorage().clear(this.storageTextKey);
        }
      }
      const attachmentIdList = this.seed.get('attachmentsIds') || [];
      if (attachmentIdList.length) {
        this.getSessionStorage().set(this.storageAttachmentsKey, {
          idList: attachmentIdList,
          names: this.seed.get('attachmentsNames') || {},
          types: this.seed.get('attachmentsTypes') || {}
        });
        isNotEmpty = true;
      } else {
        if (this.hasStoredAttachments) {
          this.getSessionStorage().clear(this.storageAttachmentsKey);
        }
      }
      if (isNotEmpty) {
        this.getSessionStorage().set(this.storageIsInernalKey, this.isInternalNoteMode);
      } else {
        this.getSessionStorage().clear(this.storageIsInernalKey);
      }
    }

    /**
     * @private
     * @return {Promise}
     */
    createCollection() {
      return this.getCollectionFactory().create('Note', collection => {
        this.collection = collection;
        collection.url = `${this.model.entityType}/${this.model.id}/stream`;
        collection.maxSize = this.getConfig().get('recordsPerPageSmall') || 5;
        this.setFilter(this.filter);
      });
    }

    /** @private */
    initPostEvents(view) {
      this.listenTo(this.formRecordHelper, 'upload-files:attachments', () => {
        if (!this.postingMode) {
          this.enablePostingMode();
        }
      });
      this.listenTo(view, 'add-files', files => {
        this.getAttachmentsFieldView().uploadFiles(files);
        if (!this.postingMode) {
          this.enablePostingMode();
        }
      });
    }

    /**
     * @private
     * @param {string|null} text
     */
    setPostText(text) {
      this.seed.set('post', text, {
        silent: true
      });
      this.postFieldView.getTextAreaElement().value = text || '';
    }

    /**
     * @private
     */
    onSync() {
      if (this.hasPinned) {
        this.pinnedCollection.add(this.collection.pinnedList);
        this.createView('pinnedList', 'views/stream/record/list', {
          selector: '> .list-container[data-role="pinned"]',
          collection: this.pinnedCollection,
          model: this.model,
          noDataDisabled: true
        }, view => {
          view.render();
          this.listenTo(this.pinnedCollection, 'change', (/** import('model').default */model, /** Record */o) => {
            if (o.userReaction) {
              this.syncPinnedModel(model, false);
            }
          });
          this.listenTo(view, 'after:save', /** import('model').default */model => {
            this.syncPinnedModel(model, false);
          });
          this.listenTo(view, 'after:delete', /** import('model').default */model => {
            this.collection.remove(model.id);
            this.collection.trigger('update-sync');
          });
          this.listenTo(view, 'quote-reply', /** string */quoted => this.quoteReply(quoted));
        });
      }
      this.createView('list', 'views/stream/record/list', {
        selector: '> .list-container[data-role="stream"]',
        collection: this.collection,
        model: this.model
      }, view => {
        view.render();
        if (this.pinnedCollection) {
          this.listenTo(view, 'after:delete', /** import('model').default */model => {
            this.pinnedCollection.remove(model.id);
            this.pinnedCollection.trigger('update-sync');
          });
          this.listenTo(view, 'after:save', /** import('model').default */model => {
            this.syncPinnedModel(model, true);
          });
          this.listenTo(this.collection, 'change', (/** import('model').default */model, /** Record */o) => {
            if (o.userReaction) {
              this.syncPinnedModel(model, true);
            }
          });
          this.listenTo(view, 'quote-reply', /** string */quoted => this.quoteReply(quoted));
        }
      });
      this.stopListening(this.model, 'all');
      this.stopListening(this.model, 'destroy');
      setTimeout(() => {
        this.listenTo(this.model, 'all', event => {
          if (!['sync', 'after:relate'].includes(event)) {
            return;
          }
          this.collection.fetchNew();
        });
        this.listenTo(this.model, 'destroy', () => {
          this.stopListening(this.model, 'all');
        });
      }, 500);
    }
    afterRender() {
      this.$attachments = this.$el.find('div.attachments');
      this.$postContainer = this.$el.find('.post-container');
      this.$postButton = this.$el.find('button.post');
      const storedText = this.getSessionStorage().get(this.storageTextKey);
      if (storedText && storedText.length) {
        this.hasStoredText = true;
        this.setPostText(storedText);
      }
      this.controlPostButtonAvailability(storedText);
      if (this.allowInternalNotes) {
        this.internalModeButtonElement = /** @type {HTMLAnchorElement} */
        this.element.querySelector('.action[data-action="switchInternalMode"]');
      }
      if (this.isInternalNoteMode) {
        this.internalModeButtonElement.classList.add('enabled');
      }
      if (!this.defs.hidden) {
        this.collection.fetch().then(() => this.onSync());
      } else {
        this.once('show', () => {
          this.collection.fetch().then(() => this.onSync());
        });
      }
      const $a = this.$el.find('.buttons-panel a.stream-post-info');
      const text1 = this.translate('infoMention', 'messages', 'Stream');
      const text2 = this.translate('infoSyntax', 'messages', 'Stream');
      const syntaxItemList = [['code', '`{text}`'], ['multilineCode', '```{text}```'], ['strongText', '**{text}**'], ['emphasizedText', '*{text}*'], ['deletedText', '~~{text}~~'], ['blockquote', '> {text}'], ['link', '[{text}](url)']];
      const messageItemList = [];
      syntaxItemList.forEach(item => {
        const text = this.translate(item[0], 'syntaxItems', 'Stream');
        const result = item[1].replace('{text}', text);
        messageItemList.push(result);
      });
      const $ul = $('<ul>').append(messageItemList.map(text => $('<li>').text(text)));
      const messageHtml = this.getHelper().transformMarkdownInlineText(text1) + '<br><br>' + this.getHelper().transformMarkdownInlineText(text2) + ':<br>' + $ul.get(0).outerHTML;
      Espo.Ui.popover($a, {
        content: messageHtml
      }, this);
      this.createView('attachments', 'views/stream/fields/attachment-multiple', {
        model: this.seed,
        mode: 'edit',
        selector: 'div.attachments-container',
        name: 'attachments',
        recordHelper: this.formRecordHelper
      }, view => {
        view.render();
      });
    }

    /**
     * @private
     * @param {import('model').default} model
     * @param {boolean} toPinned
     */
    syncPinnedModel(model, toPinned) {
      if (toPinned && !this.pinnedCollection) {
        return;
      }
      const cModel = toPinned ? this.pinnedCollection.get(model.id) : this.collection.get(model.id);
      if (!cModel) {
        return;
      }
      cModel.setMultiple({
        post: model.attributes.post,
        attachmentsIds: model.attributes.attachmentsIds,
        attachmentsNames: model.attributes.attachmentsNames,
        attachmentsTypes: model.attributes.attachmentsTypes,
        data: model.attributes.data,
        reactionCounts: model.attributes.reactionCounts,
        myReactions: model.attributes.myReactions
      });
    }

    /**
     * @private
     */
    afterPost() {
      this.postFieldView.getTextAreaElement().rows = 1;
    }

    /**
     * @private
     * @return {import('views/fields/attachment-multiple').default}
     */
    getAttachmentsFieldView() {
      return this.getView('attachments');
    }

    /**
     * @private
     */
    async post() {
      this.postFieldView.fetchToModel();

      /** @type {string} */
      const message = this.seed.attributes.post || '';
      const textAreaElement = this.postFieldView.getTextAreaElement();
      this.disablePostButton();
      textAreaElement.disabled = true;
      const model = await this.getModelFactory().create('Note');
      if (this.getAttachmentsFieldView().validateReady()) {
        textAreaElement.disabled = false;
        this.enablePostButton();
        return;
      }

      /** @type {string[]} */
      const attachmentIds = this.seed.get('attachmentsIds') || [];
      if (message.trim() === '' && attachmentIds.length === 0) {
        Espo.Ui.error(this.translate('Post cannot be empty'));
        textAreaElement.disabled = false;
        this.controlPostButtonAvailability();
        textAreaElement.focus();
        return;
      }
      model.set('post', message || null);
      model.set('attachmentsIds', [...attachmentIds]);
      model.set('type', 'Post');
      model.set('isInternal', this.isInternalNoteMode);
      this.prepareNoteForPost(model);
      this._justPosted = true;
      setTimeout(() => this._justPosted = false, 1000);
      Espo.Ui.notifyWait();
      try {
        await model.save(null);
      } catch (e) {
        this.postFieldView.getTextAreaElement().disabled = false;
        this.controlPostButtonAvailability();
        return;
      }
      Espo.Ui.success(this.translate('Posted'));
      this.collection.fetchNew().then(() => this.afterPostAndFetch(model));
      textAreaElement.disabled = false;
      this.disablePostingMode();
      this.afterPost();
      if (this.getPreferences().get('followEntityOnStreamPost')) {
        this.model.set('isFollowed', true);
      }
      this.getSessionStorage().clear(this.storageTextKey);
      this.getSessionStorage().clear(this.storageAttachmentsKey);
      this.getSessionStorage().clear(this.storageIsInernalKey);
    }

    /**
     * @private
     * @param {import('model').default} model
     */
    afterPostAndFetch(model) {
      const rowView = this.getListView().getView(model.id);
      if (!rowView) {
        return;
      }
      const postView = rowView.getView('post');
      if (!(postView instanceof _text.default)) {
        console.error('Post field not obtained.');
        return;
      }
      postView.seeMore();
    }

    /**
     * @protected
     * @param {import('model').default} model
     */
    prepareNoteForPost(model) {
      model.set('parentId', this.model.id);
      model.set('parentType', this.model.entityType);
    }
    getButtonList() {
      return [];
    }
    setupActions() {
      this.actionList = [];
      this.actionList.push({
        action: 'viewPostList',
        text: this.translate('View Posts', 'labels', 'Note'),
        onClick: () => this.actionViewPostList(),
        iconClass: 'far fa-comments'
      });
      if (this.model.entityType !== 'User') {
        this.actionList.push({
          action: 'viewAttachmentList',
          text: this.translate('View Attachments', 'labels', 'Note'),
          onClick: () => this.actionViewAttachmentList(),
          iconClass: 'fas fa-paperclip'
        });
      }
      if (this.model.entityType === 'User') {
        this.actionList.push({
          action: 'viewUserActivity',
          text: this.translate('View Activity', 'labels', 'Note'),
          onClick: () => this.actionViewUserActivity()
        });
      }
      this.actionList.push(false);
      this.filterList.forEach(item => {
        let selected;
        selected = item === 'all' ? !this.filter : item === this.filter;
        this.actionList.push({
          action: 'selectFilter',
          html: $('<span>').append($('<span>').addClass('check-icon fas fa-check pull-right').addClass(!selected ? ' hidden' : ''), $('<div class="item-text">').text(this.translate(item, 'filters', 'Note'))).get(0).innerHTML,
          data: {
            name: item
          }
        });
      });
    }
    actionViewPostList() {
      const url = this.model.entityType + '/' + this.model.id + '/posts';
      const data = {
        entityType: 'Note',
        viewOptions: {
          url: url,
          title: `${this.translate('Stream')} @right ${this.translate('posts', 'filters', 'Note')}`,
          forceSelectAllAttributes: true,
          forcePagination: true,
          rowActionsView: 'views/stream/record/row-actions/detached'
        }
      };
      this.actionViewRelatedList(data);
    }

    /**
     * @private
     */
    actionViewAttachmentList() {
      const url = `${this.model.entityType}/${this.model.id}/streamAttachments`;
      const title = `${this.translate('Stream')} @right ${this.translate('Attachment', 'scopeNamesPlural')}`;
      const options = {
        model: this.model,
        link: 'streamAttachments',
        entityType: 'Attachment',
        title: title,
        layoutName: 'listForStream',
        defaultOrder: 'desc',
        defaultOrderBy: 'createdAt',
        url: url,
        listViewName: this.listViewName,
        createDisabled: true,
        selectDisabled: true,
        unlinkDisabled: true,
        removeDisabled: true,
        rowActionsView: null,
        filtersDisabled: true,
        searchPanelDisabled: true,
        massActionRemoveDisabled: true
      };
      Espo.Ui.notifyWait();
      this.createView('modal', 'views/modals/related-list', options, view => {
        Espo.Ui.notify();
        view.render();
        this.listenTo(view, 'action', (event, element) => {
          Espo.Utils.handleAction(this, event, element);
        });
      });
    }
    actionViewUserActivity() {
      const url = `User/${this.model.id}/stream/own`;
      const data = {
        entityType: 'Note',
        viewOptions: {
          url: url,
          title: this.translate('Stream') + ' @right ' + this.translate('activity', 'filters', 'Note'),
          forceSelectAllAttributes: true,
          filtersLayoutName: 'filtersGlobal',
          forcePagination: true,
          rowActionsView: 'views/stream/record/row-actions/detached'
        }
      };
      this.actionViewRelatedList(data);
    }
    getStoredFilter() {
      return this.getStorage().get('state', 'streamPanelFilter' + this.entityType) || null;
    }
    storeFilter(filter) {
      if (filter) {
        this.getStorage().set('state', 'streamPanelFilter' + this.entityType, filter);
      } else {
        this.getStorage().clear('state', 'streamPanelFilter' + this.entityType);
      }
    }
    setFilter(filter) {
      this.filter = filter;
      this.collection.data.filter = null;
      if (filter) {
        this.collection.data.filter = filter;
      }
    }

    /**
     * @return {import('views/stream/record/list').default}
     */
    getListView() {
      return this.getView('list');
    }
    async actionRefresh() {
      if (!this.getListView()) {
        return;
      }
      Espo.Ui.notifyWait();
      await this.getListView().showNewRecords();
      Espo.Ui.notify();
    }
    preview() {
      this.postFieldView.preview();
    }

    /**
     * @private
     * @param {string} [postEntered]
     */
    controlPostButtonAvailability(postEntered) {
      const attachmentsIdList = this.seed.get('attachmentsIds') || [];
      let post = this.seed.get('post');
      if (typeof postEntered !== 'undefined') {
        post = postEntered;
      }
      const isEmpty = !post && !attachmentsIdList.length;
      if (isEmpty) {
        if (this.$postButton.hasClass('disabled')) {
          return;
        }
        this.disablePostButton();
        return;
      }
      if (!this.$postButton.hasClass('disabled')) {
        return;
      }
      this.enablePostButton();
    }

    /**
     * @private
     */
    disablePostButton() {
      this.$postButton.addClass('disabled').attr('disabled', 'disabled');
    }

    /**
     * @private
     */
    enablePostButton() {
      this.$postButton.removeClass('disabled').removeAttr('disabled');
    }

    /**
     * @private
     */
    setupPinned() {
      if (!this.hasPinned) {
        return;
      }
      const promise = this.getCollectionFactory().create('Note').then(/** import('collections/note').default */collection => {
        this.pinnedCollection = collection;
        this.listenTo(this.collection, 'sync', () => {
          if (!this.collection.pinnedList) {
            return;
          }
          if (_underscore.default.isEqual(this.collection.pinnedList, this.pinnedCollection.models.map(m => m.attributes))) {
            return;
          }
          this.pinnedCollection.reset();
          this.pinnedCollection.add(this.collection.pinnedList);
          this.pinnedCollection.trigger('sync', this.pinnedCollection, {}, {});
        });
        this.listenTo(this.pinnedCollection, 'pin unpin', () => {
          this.collection.fetchNew();
        });
        this.listenTo(this.pinnedCollection, 'pin', id => {
          const model = this.collection.get(id);
          if (!model) {
            return;
          }
          model.set('isPinned', true);
        });
        this.listenTo(this.pinnedCollection, 'unpin', id => {
          const model = this.collection.get(id);
          if (!model) {
            return;
          }
          model.set('isPinned', false);
        });
      });
      this.wait(promise);
    }

    /**
     * @private
     * @param {string} quoted
     */
    quoteReply(quoted) {
      const quote = '> ' + quoted.split(/\r?\n|\r|\n/g).join('\n> ');
      let post = this.seed.attributes.post || '';
      if (post !== '') {
        post += '\n';
      }
      post += quote + '\n\n';
      this.setPostText(post);
      this.controlPreviewButton();
      this.controlPostButtonAvailability();
      this.postFieldView.controlTextareaHeight();
      this.enablePostingMode();
      setTimeout(() => {
        const textArea = this.postFieldView.getTextAreaElement();
        textArea.focus();
        textArea.setSelectionRange(textArea.value.length, textArea.value.length);
      }, 1);
    }
  }
  var _default = _exports.default = PanelStreamView;
});

define("views/stream/record/row-actions/default", ["exports", "views/record/row-actions/default", "helpers/misc/reactions", "views/stream/record/row-actions/reactions/reactions"], function (_exports, _default2, _reactions, _reactions2) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _default2 = _interopRequireDefault(_default2);
  _reactions = _interopRequireDefault(_reactions);
  _reactions2 = _interopRequireDefault(_reactions2);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class StreamDefaultNoteRowActionsView extends _default2.default {
    pinnedMaxCount;
    isDetached = false;

    /**
     * @private
     * @type {string[]}
     */
    availableReactions;

    /**
     * @private
     * @type {ReactionsHelper}
     */
    reactionHelper;
    setup() {
      super.setup();

      /** @type import('model').default */
      this.parentModel = this.options.parentModel;
      if (this.options.isThis && this.parentModel) {
        this.listenTo(this.model, 'change:isPinned', () => this.reRender());
        this.listenToOnce(this.parentModel, 'acl-edit-ready', () => this.reRender());
        this.pinnedMaxCount = this.getConfig().get('notePinnedMaxCount');
      }

      // @todo Use service.
      this.reactionHelper = new _reactions.default();
      this.availableReactions = this.reactionHelper.getAvailableReactions();
    }
    getActionList() {
      const list = [];
      if (this.options.acl.edit && this.options.isEditable) {
        list.push({
          action: 'quickEdit',
          label: 'Edit',
          data: {
            id: this.model.id
          },
          groupIndex: 0,
          iconClass: _default2.default.ICON_CLASS_EDIT
        });
      }
      if (this.options.acl.edit && this.options.isRemovable) {
        list.push({
          action: 'quickRemove',
          label: 'Remove',
          data: {
            id: this.model.id
          },
          groupIndex: 0,
          iconClass: _default2.default.ICON_CLASS_REMOVE
        });
      }
      if (this.options.isThis && ['Post', 'EmailReceived', 'EmailSent'].includes(this.model.attributes.type) && this.parentModel && this.getAcl().checkModel(this.parentModel, 'edit') && !this.isDetached) {
        if (this.model.attributes.isPinned) {
          list.push({
            action: 'unpin',
            label: 'Unpin',
            data: {
              id: this.model.id
            },
            groupIndex: 2
          });
        } else if (this.pinnedMaxCount > 0) {
          list.push({
            action: 'pin',
            label: 'Pin',
            data: {
              id: this.model.id
            },
            groupIndex: 2,
            iconClass: 'fas fa-map-pin'
          });
        }
      }
      if (this.options.isThis && this.model.attributes.type === 'Post' && this.model.attributes.post && !this.isDetached) {
        list.push({
          action: 'quoteReply',
          label: 'Quote Reply',
          data: {
            id: this.model.id
          },
          groupIndex: 1
        });
      }
      if (this.hasReactions()) {
        this.getReactionItems().forEach(item => list.push(item));
      }
      return list;
    }

    /**
     * @private
     * @return {boolean}
     */
    hasReactions() {
      return this.model.attributes.type === 'Post' && this.availableReactions.length && !this.options.isNotification;
    }
    async prepareRender() {
      if (!this.hasReactions() || this.availableReactions.length === 1) {
        return;
      }
      const reactionsView = new _reactions2.default({
        reactions: this.availableReactions.map(type => {
          return {
            type: type,
            iconClass: this.reactionHelper.getIconClass(type),
            label: this.translate(type, 'reactions'),
            isReacted: this.isUserReacted(type)
          };
        })
      });
      await this.assignView('reactions', reactionsView, '[data-view-key="reactions"]');
    }

    /**
     * @private
     * @param {string} type
     * @return {boolean}
     */
    isUserReacted(type) {
      /** @type {string[]} */
      const myReactions = this.model.attributes.myReactions || [];
      return myReactions.includes(type);
    }

    /**
     * @private
     * @return {module:views/record/row-actions/actions~item[]}
     */
    getReactionItems() {
      const list = [];
      if (this.availableReactions.length > 1) {
        return [{
          viewKey: 'reactions',
          groupIndex: 11
        }];
      }
      this.availableReactions.forEach(type => {
        const iconClass = this.reactionHelper.getIconClass(type);
        const label = this.getHelper().escapeString(this.translate(type, 'reactions'));
        let html = iconClass ? `<span class="${iconClass} text-soft item-icon reaction-icon"></span><span class="item-text">${label}</span>` : label;
        const reacted = this.isUserReacted(type);
        if (reacted) {
          html = `<span class="check-icon fas fa-check pull-right"></span>` + `<div>${html}</div>`;
        }
        list.push({
          action: reacted ? 'unReact' : 'react',
          html: html,
          data: {
            id: this.model.id,
            type: type
          },
          groupIndex: 3
        });
      });
      return list;
    }
  }
  var _default = _exports.default = StreamDefaultNoteRowActionsView;
});

define("views/stream/notes/relate", ["exports", "views/stream/note"], function (_exports, _note) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _note = _interopRequireDefault(_note);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class RelateNoteStreamView extends _note.default {
    template = 'stream/notes/create-related';
    messageName = 'relate';
    data() {
      return {
        ...super.data(),
        relatedTypeString: this.translateEntityType(this.entityType),
        iconHtml: this.getIconHtml(this.entityType, this.entityId)
      };
    }
    init() {
      if (this.getUser().isAdmin()) {
        this.isRemovable = true;
      }
      super.init();
    }
    setup() {
      const data = this.model.get('data') || {};
      this.entityType = this.model.get('relatedType') || data.entityType || null;
      this.entityId = this.model.get('relatedId') || data.entityId || null;
      this.entityName = this.model.get('relatedName') || data.entityName || null;
      this.messageData['relatedEntityType'] = this.translateEntityType(this.entityType);
      if (this.model.attributes.relatedId) {
        this.messageData['relatedEntity'] = 'field:related';
      } else {
        // bc
        this.messageData['relatedEntity'] = $('<a>').attr('href', `#${this.entityType}/view/${this.entityId}`).text(this.entityName).attr('data-scope', this.entityType).attr('data-id', this.entityId);
      }
      this.createMessage();
    }
  }
  var _default = _exports.default = RelateNoteStreamView;
});

define("views/stream/notes/email-received", ["exports", "views/stream/note", "views/email/fields/body", "views/fields/attachment-multiple"], function (_exports, _note, _body, _attachmentMultiple) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _note = _interopRequireDefault(_note);
  _body = _interopRequireDefault(_body);
  _attachmentMultiple = _interopRequireDefault(_attachmentMultiple);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EmailReceivedNoteStreamView extends _note.default {
    template = 'stream/notes/email-received';

    /**
     * @protected
     * @type {boolean}
     */
    isRemovable = false;

    /**
     * @protected
     * @type {boolean}
     */
    isSystemAvatar = true;

    /**
     * @private
     * @type {boolean}
     */
    detailsIsShown = false;

    /**
     * @private
     * @type {import('views/fields/base').default}
     */
    bodyFieldView;

    /**
     * @private
     * @type {import('views/fields/attachment-multiple').default}
     */
    attachmentsFieldView;

    /**
     * @private
     * @type {import('model').default}
     */
    formModel;

    /**
     * @private
     * @type {string}
     */
    emailId;

    /**
     * @private
     * @type {boolean}
     */
    emailNotLoaded = false;
    data() {
      return {
        ...super.data(),
        emailId: this.emailId,
        emailName: this.emailName,
        hasPost: this.hasPost && (!this.detailsIsShown || !this.bodyFieldView),
        mutedPost: this.hasPost && this.detailsIsShown && !this.bodyFieldView && !this.emailNotLoaded,
        hasAttachments: this.hasAttachments,
        emailIconClassName: this.getMetadata().get(['clientDefs', 'Email', 'iconClass']) || '',
        isPinned: this.isThis && this.model.get('isPinned') && this.model.collection && !this.model.collection.pinnedList,
        detailsIsShown: this.detailsIsShown,
        hasExpand: !this.options.isNotification
      };
    }
    setup() {
      this.addActionHandler('expandDetails', () => this.toggleDetails());
      const data =
      /**
       * @type {{
       *      emailId: string,
       *      emailName: string,
       *      personEntityType?: string,
       *      personEntityId?: string,
       *      personEntityName?: string,
       *      isInitial?: boolean,
       * }} */
      this.model.get('data') || {};
      this.emailId = data.emailId;
      this.emailName = data.emailName;
      if (this.parentModel && this.model.attributes.parentType === this.parentModel.entityType && this.model.attributes.parentId === this.parentModel.id) {
        if (this.model.attributes.post) {
          this.createField('post', null, null, 'views/stream/fields/post');
          this.hasPost = true;
        }
        if ((this.model.attributes.attachmentsIds || []).length) {
          this.createField('attachments', 'attachmentMultiple', {}, 'views/stream/fields/attachment-multiple', {
            previewSize: this.options.isNotification || this.options.isUserStream ? 'small' : 'medium'
          });
          this.hasAttachments = true;
        }
      }
      this.messageData['email'] = $('<a>').attr('href', `#Email/view/${data.emailId}`).text(data.emailName).attr('data-scope', 'Email').attr('data-id', data.emailId);
      this.setupEmailMessage(data);
      if (this.isThis) {
        this.messageName += 'This';
      }
      this.createMessage();
    }

    /**
     * @return {import('views/fields/text').default}
     */
    getPostView() {
      return this.getView('post');
    }

    /**
     * @protected
     * @param {Record} data
     */
    setupEmailMessage(data) {
      this.messageName = 'emailReceived';
      if (data.isInitial) {
        this.messageName += 'Initial';
      }
      if (data.personEntityId) {
        this.messageName += 'From';
        this.messageData['from'] = $('<a>').attr('href', `#${data.personEntityType}/view/${data.personEntityId}`).text(data.personEntityName).attr('data-scope', data.personEntityType).attr('data-id', data.personEntityId);
      }
      if (this.model.attributes.parentType === data.personEntityType && this.model.attributes.parentId === data.personEntityId) {
        this.isThis = true;
      }
    }

    /**
     * @private
     */
    async toggleDetails() {
      this.detailsIsShown = !this.detailsIsShown;
      if (!this.detailsIsShown && this.formModel) {
        this.formModel.abortLastFetch();
        Espo.Ui.notify();
      }
      const postView = this.getPostView();
      await this.reRender();
      if (!this.detailsIsShown || !this.emailId) {
        return;
      }
      if (postView) {
        postView.seeMoreText = false;
      }
      if (this.bodyFieldView) {
        this.bodyFieldView.toShowQuotePart = false;
        await this.bodyFieldView.reRender();
        return;
      }
      this.formModel = await this.getModelFactory().create('Email');
      this.formModel.id = this.emailId;
      Espo.Ui.notifyWait();
      try {
        await this.formModel.fetch();
      } catch (e) {
        this.emailNotLoaded = true;
        await this.reRender();
        return;
      }
      this.bodyFieldView = new _body.default({
        name: 'body',
        model: this.formModel,
        mode: 'detail',
        readOnly: true
      });
      await this.assignView('bodyField', this.bodyFieldView, '[data-name="body"]');
      if (!this.hasAttachments && this.formModel.attributes.attachmentsIds && this.formModel.attributes.attachmentsIds.length) {
        this.attachmentsFieldView = new _attachmentMultiple.default({
          name: 'attachments',
          model: this.formModel,
          mode: 'detail',
          readOnly: true
        });
        await this.assignView('attachmentsField', this.attachmentsFieldView, '[data-name="attachments"]');
      }
      Espo.Ui.notify();
      const minHeight = postView && postView.element ? postView.element.offsetHeight : null;
      await this.reRender();
      if (minHeight) {
        const bodyContainer = this.bodyFieldView.element;
        if (bodyContainer) {
          bodyContainer.style.minHeight = minHeight + 'px';
          setTimeout(() => bodyContainer.style.minHeight = '', 200);
        }
      }
    }
  }
  var _default = _exports.default = EmailReceivedNoteStreamView;
});

define("views/stream/modals/view-audit-log", ["exports", "views/modal", "views/stream/record/list", "jquery"], function (_exports, _modal, _list, _jquery) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  _list = _interopRequireDefault(_list);
  _jquery = _interopRequireDefault(_jquery);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class StreamViewAuditLogModalView extends _modal.default {
    templateContent = '<div class="record list-container">{{{record}}}</div>';
    backdrop = true;

    /**
     * @param {{model: import('model').default}} options
     */
    constructor(options) {
      super(options);
    }
    setup() {
      const name = this.model.get('name') || this.model.id;
      this.$header = (0, _jquery.default)('<span>').append((0, _jquery.default)('<span>').text(name), ' <span class="chevron-right"></span> ', (0, _jquery.default)('<span>').text(this.translate('Audit Log')));
      this.buttonList = [{
        name: 'close',
        label: 'Close',
        onClick: dialog => {
          dialog.close();
        }
      }];
      this.wait(this.getCollectionFactory().create('Note').then(collection => {
        collection.url = `${this.model.entityType}/${this.model.id}/updateStream`;
        collection.maxSize = this.getConfig().get('recordsPerPage');
        const listView = new _list.default({
          collection: collection,
          model: this.model,
          // Prevents 'No Data' being displayed.
          skipBuildRows: true,
          type: 'listAuditLog'
        });
        Espo.Ui.notifyWait();
        return this.assignView('record', listView, '.record').then(() => {
          collection.fetch().then(() => Espo.Ui.notify(false));
        });
      }));
    }
  }
  var _default = _exports.default = StreamViewAuditLogModalView;
});

define("views/site/navbar", ["exports", "view", "jquery", "helpers/site/tabs"], function (_exports, _view, _jquery, _tabs) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  _jquery = _interopRequireDefault(_jquery);
  _tabs = _interopRequireDefault(_tabs);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class NavbarSiteView extends _view.default {
    template = 'site/navbar';

    /**
     * @private
     * @type {string|false|null}
     */
    currentTab = null;

    /**
     * @private
     * @type {HTMLElement}
     */
    navbarHeaderElement;
    events = {
      /** @this NavbarSiteView */
      'click .navbar-collapse.in a.nav-link': function (e) {
        const $a = (0, _jquery.default)(e.currentTarget);
        const href = $a.attr('href');
        if (href) {
          this.xsCollapse();
        }
      },
      /** @this NavbarSiteView */
      'click a.nav-link': function () {
        if (this.isSideMenuOpened) {
          this.closeSideMenu();
        }
      },
      /** @this NavbarSiteView */
      'click a.navbar-brand.nav-link': function () {
        this.xsCollapse();
      },
      /** @this NavbarSiteView */
      'click a.minimizer': function () {
        this.switchMinimizer();
      },
      /** @this NavbarSiteView */
      'click a.side-menu-button': function () {
        this.switchSideMenu();
      },
      /** @this NavbarSiteView */
      'click [data-action="toggleCollapsable"]': function () {
        this.toggleCollapsable();
      },
      /** @this NavbarSiteView */
      'click li.show-more a': function (e) {
        e.stopPropagation();
        this.showMoreTabs();
      },
      /** @this NavbarSiteView */
      'click .not-in-more > .nav-link-group': function (e) {
        this.handleGroupDropdownClick(e);
      },
      /** @this NavbarSiteView */
      'click .in-more .nav-link-group': function (e) {
        this.handleGroupDropdownClick(e);
      }
    };
    data() {
      return {
        tabDefsList1: this.tabDefsList.filter(item => !item.isInMore),
        tabDefsList2: this.tabDefsList.filter(item => item.isInMore),
        title: this.options.title,
        menuDataList: this.menuDataList,
        userId: this.getUser().id,
        logoSrc: this.getLogoSrc(),
        itemDataList: this.getItemDataList()
      };
    }

    /**
     * @private
     */
    handleGroupDropdownClick(e) {
      const $target = (0, _jquery.default)(e.currentTarget).parent();
      if ($target.parent().hasClass('more-dropdown-menu')) {
        e.stopPropagation();
        if ($target.hasClass('open')) {
          $target.removeClass('open');
          return;
        }
        this.handleGroupDropdownInMoreOpen($target);
        return;
      }
      if ($target.hasClass('open')) {
        return;
      }
      this.handleGroupDropdownOpen($target);
    }

    /**
     * @private
     */
    handleGroupMenuPosition($menu, $target) {
      if (this.navbarAdjustmentHandler && this.navbarAdjustmentHandler.handleGroupMenuPosition()) {
        this.handleGroupMenuPosition($menu, $target);
        return;
      }
      const rectItem = $target.get(0).getBoundingClientRect();
      const windowHeight = window.innerHeight;
      const isSide = this.isSide();
      if (!isSide && !$target.parent().hasClass('more-dropdown-menu')) {
        const maxHeight = windowHeight - rectItem.bottom;
        this.handleGroupMenuScrolling($menu, $target, maxHeight);
        return;
      }
      const itemCount = $menu.children().length;
      const tabHeight = isSide ? this.$tabs.find('> .tab:not(.tab-divider)').height() : this.$tabs.find('.tab-group > ul > li:visible').height();
      const menuHeight = tabHeight * itemCount;
      let top = rectItem.top - 1;
      if (top + menuHeight > windowHeight) {
        top = windowHeight - menuHeight - 2;
        if (top < 0) {
          top = 0;
        }
      }
      $menu.css({
        top: top + 'px'
      });
      const maxHeight = windowHeight - top;
      this.handleGroupMenuScrolling($menu, $target, maxHeight);
    }

    /**
     * @private
     */
    handleGroupMenuScrolling($menu, $target, maxHeight) {
      $menu.css({
        maxHeight: maxHeight + 'px'
      });
      const $window = (0, _jquery.default)(window);
      $window.off('scroll.navbar-tab-group');
      $window.on('scroll.navbar-tab-group', () => {
        if (!$menu.get(0) || !$target.get(0)) {
          return;
        }
        if (!$target.hasClass('open')) {
          return;
        }
        $menu.scrollTop($window.scrollTop());
      });
    }

    /**
     * @private
     */
    handleGroupDropdownOpen($target) {
      const $menu = $target.find('.dropdown-menu');
      this.handleGroupMenuPosition($menu, $target);
      setTimeout(() => {
        this.adjustBodyMinHeight();
      }, 50);
      $target.off('hidden.bs.dropdown');
      $target.on('hidden.bs.dropdown', () => {
        this.adjustBodyMinHeight();
      });
    }

    /**
     * @private
     */
    handleGroupDropdownInMoreOpen($target) {
      this.$el.find('.tab-group.tab.dropdown').removeClass('open');
      const $parentDropdown = this.$el.find('.more-dropdown-menu');
      $target.addClass('open');
      const $menu = $target.find('.dropdown-menu');
      const rectDropdown = $parentDropdown.get(0).getBoundingClientRect();
      const left = rectDropdown.right;
      $menu.css({
        left: left + 'px'
      });
      this.handleGroupMenuPosition($menu, $target);
      this.adjustBodyMinHeight();
      if (!this.isSide()) {
        if (left + $menu.width() > window.innerWidth) {
          $menu.css({
            left: rectDropdown.left - $menu.width() - 2
          });
        }
      }
    }

    /**
     * @private
     */
    isCollapsibleVisible() {
      return this.$el.find('.navbar-body').hasClass('in');
    }

    /**
     * @private
     */
    toggleCollapsable() {
      if (this.isCollapsibleVisible()) {
        this.hideCollapsable();
      } else {
        this.showCollapsable();
      }
    }

    /**
     * @private
     */
    hideCollapsable() {
      this.$el.find('.navbar-body').removeClass('in');
    }

    /**
     * @private
     */
    showCollapsable() {
      this.$el.find('.navbar-body').addClass('in');
    }

    /**
     * @private
     */
    xsCollapse() {
      this.hideCollapsable();
    }

    /**
     * @private
     * @return {boolean}
     */
    isMinimized() {
      return document.body.classList.contains('minimized');
    }
    switchSideMenu() {
      if (!this.isMinimized()) return;
      if (this.isSideMenuOpened) {
        this.closeSideMenu();
      } else {
        this.openSideMenu();
      }
    }
    openSideMenu() {
      this.isSideMenuOpened = true;
      document.body.classList.add('side-menu-opened');
      this.$sideMenuBackdrop = (0, _jquery.default)('<div>').addClass('side-menu-backdrop').click(() => this.closeSideMenu()).appendTo(document.body);
      this.$sideMenuBackdrop2 = (0, _jquery.default)('<div>').addClass('side-menu-backdrop').click(() => this.closeSideMenu()).appendTo(this.$navbarRightContainer);
    }

    /**
     * @private
     */
    closeSideMenu() {
      this.isSideMenuOpened = false;
      document.body.classList.remove('side-menu-opened');
      this.$sideMenuBackdrop.remove();
      this.$sideMenuBackdrop2.remove();
    }

    /**
     * @private
     */
    switchMinimizer() {
      if (this.isMinimized()) {
        if (this.isSideMenuOpened) {
          this.closeSideMenu();
        }
        document.body.classList.remove('minimized');
        this.getStorage().set('state', 'siteLayoutState', 'expanded');
      } else {
        document.body.classList.add('minimized');
        this.getStorage().set('state', 'siteLayoutState', 'collapsed');
      }
      if (window.Event) {
        try {
          window.dispatchEvent(new Event('resize'));
        } catch (e) {}
      }
    }
    getLogoSrc() {
      const companyLogoId = this.getConfig().get('companyLogoId');
      if (!companyLogoId) {
        return this.getBasePath() + (this.getThemeManager().getParam('logo') || 'client/img/logo.svg');
      }
      return `${this.getBasePath()}?entryPoint=LogoImage&id=${companyLogoId}`;
    }

    /**
     * @return {(Object|string)[]}
     */
    getTabList() {
      const tabList = this.tabsHelper.getTabList();
      if (this.isSide()) {
        tabList.unshift('Home');
      }
      return tabList;
    }
    setup() {
      this.addHandler('click', 'a.action', (/** MouseEvent */event, target) => {
        let actionData;
        const name = target.dataset.name;
        if (name) {
          const item = this.menuDataList.find(it => it.name === name);
          if (item.handler && item.actionFunction) {
            actionData = {
              handler: item.handler,
              actionFunction: item.actionFunction
            };
          }
        }
        Espo.Utils.handleAction(this, event, target, actionData);
      });
      this.getRouter().on('routed', e => {
        if (e.controller) {
          this.selectTab(e.controller);
          return;
        }
        this.selectTab(false);
      });

      /** @private */
      this.tabsHelper = new _tabs.default(this.getConfig(), this.getPreferences(), this.getUser(), this.getAcl(), this.getMetadata(), this.getLanguage());
      const itemDefs = this.getMetadata().get('app.clientNavbar.items') || {};

      /** @type {string[]} */
      this.itemList = Object.keys(itemDefs).filter(name => !itemDefs[name].disabled).sort((name1, name2) => {
        const order1 = itemDefs[name1].order || 0;
        const order2 = itemDefs[name2].order || 0;
        return order1 - order2;
      });
      const setup = () => {
        this.setupTabDefsList();
        return Promise.all(this.itemList.map(item => this.createItemView(item)));
      };
      const update = () => {
        setup().then(() => this.reRender());
      };
      setup();
      this.listenTo(this.getHelper().settings, 'sync', () => update());
      this.listenTo(this.getHelper().language, 'sync', () => update());
      this.listenTo(this.getHelper().preferences, 'update', (/** string[] */attributeList) => {
        if (!attributeList) {
          return;
        }
        if (attributeList.includes('tabList') || attributeList.includes('addCustomTabs') || attributeList.includes('useCustomTabList')) {
          update();
        }
      });
      this.once('remove', () => {
        (0, _jquery.default)(window).off('resize.navbar');
        (0, _jquery.default)(window).off('scroll.navbar');
        (0, _jquery.default)(window).off('scroll.navbar-tab-group');
        document.body.classList.remove('has-navbar');
      });
      this.setupMenu();
    }
    getItemDataList() {
      const defsMap = {};
      this.itemList.forEach(name => {
        defsMap[name] = this.getItemDefs(name);
      });
      return this.itemList.filter(name => {
        const item = defsMap[name];
        if (!item) {
          return false;
        }
        if (item.accessDataList && !Espo.Utils.checkAccessDataList(item.accessDataList, this.getAcl(), this.getUser())) {
          return false;
        }
        const view = this.getView(name + 'Item');
        if ('isAvailable' in view) {
          return view.isAvailable();
        }
        return true;
      }).map(name => {
        return {
          key: name + 'Item',
          name: name,
          class: defsMap[name].class || ''
        };
      });
    }

    /**
     *
     * @param {string} name
     * @return {{
     *     view: string,
     *     class: string,
     *     accessDataList?: import('utils').AccessDefs[],
     * }}
     */
    getItemDefs(name) {
      return this.getMetadata().get(['app', 'clientNavbar', 'items', name]);
    }

    /**
     * @param {string} name
     * @return {Promise}
     */
    createItemView(name) {
      const defs = this.getItemDefs(name);
      if (!defs || !defs.view) {
        return Promise.resolve();
      }
      const key = name + 'Item';
      return this.createView(key, defs.view, {
        selector: `[data-item="${name}"]`
      });
    }

    /**
     * @private
     */
    adjustTop() {
      const smallScreenWidth = this.getThemeManager().getParam('screenWidthXs');
      const navbarHeight = this.getNavbarHeight();
      const $window = (0, _jquery.default)(window);
      const $tabs = this.$tabs;
      const $more = this.$more;
      const $moreDropdown = this.$moreDropdown;
      $window.off('scroll.navbar');
      $window.off('resize.navbar');
      this.$moreDropdown.off('shown.bs.dropdown.navbar');
      this.off('show-more-tabs');
      $window.on('resize.navbar', () => updateWidth());
      $window.on('scroll.navbar', () => {
        if (!this.isMoreDropdownShown) {
          return;
        }
        $more.scrollTop($window.scrollTop());
      });
      this.$moreDropdown.on('shown.bs.dropdown.navbar', () => {
        $more.scrollTop($window.scrollTop());
      });
      this.on('show-more-tabs', () => {
        $more.scrollTop($window.scrollTop());
      });
      const updateMoreHeight = () => {
        const windowHeight = window.innerHeight;
        const windowWidth = window.innerWidth;
        if (windowWidth < smallScreenWidth) {
          $more.css('max-height', '');
          $more.css('overflow-y', '');
        } else {
          $more.css('overflow-y', 'hidden');
          $more.css('max-height', windowHeight - navbarHeight + 'px');
        }
      };
      $window.on('resize.navbar', () => updateMoreHeight());
      updateMoreHeight();
      const hideOneTab = () => {
        const count = $tabs.children().length;
        if (count <= 1) {
          return;
        }
        const $one = $tabs.children().eq(count - 2);
        $one.prependTo($more);
      };
      const unhideOneTab = () => {
        const $one = $more.children().eq(0);
        if ($one.length) {
          $one.insertBefore($moreDropdown);
        }
      };
      const $navbar = (0, _jquery.default)('#navbar .navbar');
      if (window.innerWidth >= smallScreenWidth) {
        $tabs.children('li').each(() => {
          hideOneTab();
        });
        $navbar.css('max-height', 'unset');
        $navbar.css('overflow', 'visible');
      }
      const navbarBaseWidth = this.navbarHeaderElement.clientWidth + this.$navbarRight.width();
      const tabCount = this.tabList.length;
      const navbarNeededHeight = navbarHeight + 1;
      this.adjustBodyMinHeightMethodName = 'adjustBodyMinHeightTop';
      const $moreDd = (0, _jquery.default)('#nav-more-tabs-dropdown');
      const $moreLi = $moreDd.closest('li');
      const updateWidth = () => {
        const windowWidth = window.innerWidth;
        const moreWidth = $moreLi.width();
        $more.children('li.not-in-more').each(() => {
          unhideOneTab();
        });
        if (windowWidth < smallScreenWidth) {
          return;
        }
        $navbar.css('max-height', navbarHeight + 'px');
        $navbar.css('overflow', 'hidden');
        $more.parent().addClass('hidden');
        const headerWidth = this.$el.width();
        const maxWidth = headerWidth - navbarBaseWidth - moreWidth;
        let width = $tabs.width();
        let i = 0;
        while (width > maxWidth) {
          hideOneTab();
          width = $tabs.width();
          i++;
          if (i >= tabCount) {
            setTimeout(() => updateWidth(), 100);
            break;
          }
        }
        $navbar.css('max-height', 'unset');
        $navbar.css('overflow', 'visible');
        if ($more.children().length > 0) {
          $moreDropdown.removeClass('hidden');
        }
      };
      const processUpdateWidth = isRecursive => {
        if ($navbar.height() > navbarNeededHeight) {
          updateWidth();
          setTimeout(() => processUpdateWidth(true), 200);
          return;
        }
        if (!isRecursive) {
          updateWidth();
          setTimeout(() => processUpdateWidth(true), 10);
        }
        setTimeout(() => processUpdateWidth(true), 1000);
      };
      if ($navbar.height() <= navbarNeededHeight && $more.children().length === 0) {
        $more.parent().addClass('hidden');
      }
      processUpdateWidth();
    }

    /**
     * @private
     */
    adjustSide() {
      const smallScreenWidth = this.getThemeManager().getParam('screenWidthXs');
      const $window = (0, _jquery.default)(window);
      const $tabs = this.$tabs;
      const $more = this.$more;

      /** @type {HTMLElement} */
      const tabsElement = this.$tabs.get(0);

      /** @type {HTMLElement} */
      const moreElement = this.$more.get(0);
      this.adjustBodyMinHeightMethodName = 'adjustBodyMinHeightSide';
      if ($more.children().length === 0) {
        $more.parent().addClass('hidden');
      }
      $window.off('scroll.navbar');
      $window.off('resize.navbar');
      this.$moreDropdown.off('shown.bs.dropdown.navbar');
      this.off('show-more-tabs');
      $window.on('scroll.navbar', () => {
        $window.scrollTop() ? this.$navbarRight.addClass('shadowed') : this.$navbarRight.removeClass('shadowed');
        $tabs.scrollTop($window.scrollTop());
        if (!this.isMoreDropdownShown) {
          return;
        }
        $more.scrollTop($window.scrollTop());
      });
      this.$moreDropdown.on('shown.bs.dropdown.navbar', () => {
        $more.scrollTop($window.scrollTop());
      });
      this.on('show-more-tabs', () => {
        $more.scrollTop($window.scrollTop());
      });
      const updateSizeForSide = () => {
        const windowHeight = window.innerHeight;
        const windowWidth = window.innerWidth;
        const navbarStaticItemsHeight = this.getStaticItemsHeight();
        this.$minimizer.removeClass('hidden');
        if (windowWidth < smallScreenWidth) {
          tabsElement.style.height = 'auto';
          if (moreElement) {
            moreElement.style.maxHeight = '';
          }
          return;
        }
        tabsElement.style.height = windowHeight - navbarStaticItemsHeight + 'px';
        if (moreElement) {
          moreElement.style.maxHeight = windowHeight + 'px';
        }
      };
      $window.on('resize.navbar', () => {
        updateSizeForSide();
        this.adjustBodyMinHeight();
      });
      updateSizeForSide();
      this.adjustBodyMinHeight();
    }

    /**
     * @private
     * @return {number}
     */
    getNavbarHeight() {
      return this.getFontSizeFactor() * (this.getThemeManager().getParam('navbarHeight') || 43);
    }

    /**
     * @private
     * @return {boolean}
     */
    isSide() {
      return this.getThemeManager().getParam('navbar') === 'side';
    }

    /**
     * @private
     * @return {number}
     */
    getStaticItemsHeight() {
      return this.getFontSizeFactor() * (this.getThemeManager().getParam('navbarStaticItemsHeight') || 97);
    }

    /**
     * @private
     */
    getFontSizeFactor() {
      return this.getThemeManager().getFontSizeFactor();
    }

    /**
     * @private
     */
    adjustBodyMinHeight() {
      if (!this.adjustBodyMinHeightMethodName) {
        return;
      }
      this[this.adjustBodyMinHeightMethodName]();
    }

    /**
     * @private
     */
    adjustBodyMinHeightSide() {
      let minHeight = this.$tabs.get(0).scrollHeight + this.getStaticItemsHeight();
      let moreHeight = 0;
      this.$more.find('> li:visible').each((i, el) => {
        const $el = (0, _jquery.default)(el);
        moreHeight += $el.outerHeight(true);
      });
      minHeight = Math.max(minHeight, moreHeight);
      const tabHeight = this.$tabs.find('> .tab:not(.tab-divider)').height();
      this.tabList.forEach((item, i) => {
        if (typeof item !== 'object') {
          return;
        }
        const $li = this.$el.find('li.tab[data-name="group-' + i + '"]');
        if (!$li.hasClass('open')) {
          return;
        }
        const tabCount = (item.itemList || []).length;
        const menuHeight = tabHeight * tabCount;
        if (menuHeight > minHeight) {
          minHeight = menuHeight;
        }
      });
      document.body.style.minHeight = minHeight + 'px';
    }

    /**
     * @private
     */
    adjustBodyMinHeightTop() {
      let minHeight = this.getNavbarHeight();
      this.$more.find('> li').each((i, el) => {
        const $el = (0, _jquery.default)(el);
        if (!this.isMoreTabsShown) {
          if ($el.hasClass('after-show-more')) {
            return;
          }
        } else {
          if ($el.hasClass('show-more')) {
            return;
          }
        }
        minHeight += $el.height();
      });
      const tabHeight = this.$tabs.find('.tab-group > ul > li:visible').height();
      this.tabList.forEach((item, i) => {
        if (typeof item !== 'object') {
          return;
        }
        const $li = this.$el.find('li.tab[data-name="group-' + i + '"]');
        if (!$li.hasClass('open')) {
          return;
        }
        const tabCount = (item.itemList || []).length;
        const menuHeight = tabHeight * tabCount;
        if (menuHeight > minHeight) {
          minHeight = menuHeight;
        }
      });
      document.body.style.minHeight = minHeight + 'px';
    }
    afterRender() {
      this.$tabs = this.$el.find('ul.tabs');
      this.$more = this.$tabs.find('li.more > ul');
      this.$minimizer = this.$el.find('a.minimizer');
      document.body.classList.add('has-navbar');
      const $moreDd = this.$moreDropdown = this.$tabs.find('li.more');
      $moreDd.on('shown.bs.dropdown', () => {
        this.isMoreDropdownShown = true;
        this.adjustBodyMinHeight();
      });
      $moreDd.on('hidden.bs.dropdown', () => {
        this.isMoreDropdownShown = false;
        this.hideMoreTabs();
        this.adjustBodyMinHeight();
      });
      this.selectTab(this.getRouter().getLast().controller);
      let layoutState = this.getStorage().get('state', 'siteLayoutState');
      if (!layoutState) {
        layoutState = (0, _jquery.default)(window).width() > 1320 ? 'expanded' : 'collapsed';
      }
      let layoutMinimized = false;
      if (layoutState === 'collapsed') {
        layoutMinimized = true;
      }
      if (layoutMinimized) {
        document.body.classList.add('minimized');
      }
      this.$navbar = this.$el.find('> .navbar');
      this.$navbarRightContainer = this.$navbar.find('> .navbar-body > .navbar-right-container');
      this.$navbarRight = this.$navbarRightContainer.children();
      this.navbarHeaderElement = this.element.querySelector('.navbar-header');
      const handlerClassName = this.getThemeManager().getParam('navbarAdjustmentHandler');
      if (handlerClassName) {
        Espo.loader.require(handlerClassName, Handler => {
          const handler = new Handler(this);
          this.navbarAdjustmentHandler = handler;
          handler.process();
        });
        return;
      }
      if (this.getThemeManager().getParam('skipDefaultNavbarAdjustment')) {
        return;
      }
      this.adjustAfterRender();
    }

    /**
     * @private
     */
    adjustAfterRender() {
      if (this.isSide()) {
        const processSide = () => {
          if (this.$navbar.height() < (0, _jquery.default)(window).height() / 2) {
            setTimeout(() => processSide(), 50);
            return;
          }
          if (this.getThemeManager().isUserTheme()) {
            setTimeout(() => this.adjustSide(), 10);
            return;
          }
          this.adjustSide();
        };
        processSide();
        return;
      }
      const process = () => {
        if (this.$el.width() < (0, _jquery.default)(window).width() / 2) {
          setTimeout(() => process(), 50);
          return;
        }
        if (this.getThemeManager().isUserTheme()) {
          setTimeout(() => this.adjustTop(), 10);
          return;
        }
        this.adjustTop();
      };
      process();
    }

    /**
     * @param {string|false} name
     */
    selectTab(name) {
      const $tabs = this.$el.find('ul.tabs');
      $tabs.find('li.active').removeClass('active');
      if (name) {
        $tabs.find(`li[data-name="${name}"]`).addClass('active');
      }
      this.currentTab = name;
      const url = this.getRouter().getCurrentUrl();
      this.urlList.filter(item => url.startsWith(item.url)).forEach(item => {
        $tabs.find(`li[data-name="${item.name}"]`).addClass('active');
      });
    }

    /**
     * @private
     */
    setupTabDefsList() {
      /** @type {{url: string, name: string}[]} */
      this.urlList = [];
      const allTabList = this.getTabList();
      this.tabList = allTabList.filter((item, i) => {
        if (!item) {
          return false;
        }
        if (typeof item !== 'object') {
          return this.tabsHelper.checkTabAccess(item);
        }
        if (this.tabsHelper.isTabDivider(item)) {
          if (!this.isSide()) {
            return false;
          }
          if (i === allTabList.length - 1) {
            return false;
          }
          return true;
        }
        if (this.tabsHelper.isTabUrl(item)) {
          return this.tabsHelper.checkTabAccess(item);
        }

        /** @type {(Record|string)[]} */
        let itemList = (item.itemList || []).filter(item => {
          if (this.tabsHelper.isTabDivider(item)) {
            return true;
          }
          return this.tabsHelper.checkTabAccess(item);
        });
        itemList = itemList.filter((item, i) => {
          if (!this.tabsHelper.isTabDivider(item)) {
            return true;
          }
          const nextItem = itemList[i + 1];
          if (!nextItem) {
            return true;
          }
          if (this.tabsHelper.isTabDivider(nextItem)) {
            return false;
          }
          return true;
        });
        itemList = itemList.filter((item, i) => {
          if (!this.tabsHelper.isTabDivider(item)) {
            return true;
          }
          if (i === 0 || i === itemList.length - 1) {
            return false;
          }
          return true;
        });
        item.itemList = itemList;
        return !!itemList.length;
      });
      let moreIsMet = false;
      this.tabList = this.tabList.filter((item, i) => {
        const nextItem = this.tabList[i + 1];
        const prevItem = this.tabList[i - 1];
        if (this.tabsHelper.isTabMoreDelimiter(item)) {
          moreIsMet = true;
        }
        if (!this.tabsHelper.isTabDivider(item)) {
          return true;
        }
        if (!nextItem) {
          return true;
        }
        if (this.tabsHelper.isTabDivider(nextItem)) {
          return false;
        }
        if (this.tabsHelper.isTabDivider(prevItem) && this.tabsHelper.isTabMoreDelimiter(nextItem) && moreIsMet) {
          return false;
        }
        return true;
      });
      if (moreIsMet) {
        let end = this.tabList.length;
        for (let i = this.tabList.length - 1; i >= 0; i--) {
          const item = this.tabList[i];
          if (!this.tabsHelper.isTabDivider(item)) {
            break;
          }
          end = this.tabList.length - 1;
        }
        this.tabList = this.tabList.slice(0, end);
      }
      const tabDefsList = [];
      const colorsDisabled = this.getConfig().get('scopeColorsDisabled') || this.getConfig().get('tabColorsDisabled');
      const tabIconsDisabled = this.getConfig().get('tabIconsDisabled');
      const params = {
        colorsDisabled: colorsDisabled,
        tabIconsDisabled: tabIconsDisabled
      };
      const vars = {
        moreIsMet: false,
        isHidden: false
      };
      this.tabList.forEach((tab, i) => {
        if (this.tabsHelper.isTabMoreDelimiter(tab)) {
          if (!vars.moreIsMet) {
            vars.moreIsMet = true;
            return;
          }
          if (i === this.tabList.length - 1) {
            return;
          }
          vars.isHidden = true;
          tabDefsList.push({
            name: 'show-more',
            isInMore: true,
            className: 'show-more',
            html: '<span class="fas fa-ellipsis-h more-icon"></span>'
          });
          return;
        }
        tabDefsList.push(this.prepareTabItemDefs(params, tab, i, vars));
      });
      this.tabDefsList = tabDefsList;
    }

    /**
     * @private
     * @param {{
     *     colorsDisabled: boolean,
     *     tabIconsDisabled: boolean,
     * }} params
     * @param {Record|string} tab
     * @param {number} i
     * @param {Object} vars
     * @return {{
     *     isAfterShowMore: boolean,
     *     isDivider: boolean,
     *     color: null,
     *     link: string,
     *     name: string,
     *     isInMore: boolean,
     *     shortLabel: string,
     *     label: string,
     *     isGroup: boolean,
     *     aClassName: string,
     *     iconClass: null,
     *     openInNewTab: boolean,
     * }}
     */
    prepareTabItemDefs(params, tab, i, vars) {
      let link;
      let iconClass = null;
      let color = null;
      let isGroup = false;
      let isDivider = false;
      let isUrl = false;
      let name = tab;
      let aClassName = 'nav-link';
      let openInNewTab = false;
      const label = this.tabsHelper.getTranslatedTabLabel(tab);
      if (tab === 'Home') {
        link = '#';
      } else if (this.tabsHelper.isTabDivider(tab)) {
        isDivider = true;
        aClassName = 'nav-divider-text';
        name = `divider-${i}`;
      } else if (this.tabsHelper.isTabUrl(tab)) {
        isUrl = true;
        name = `url-${i}`;
        link = tab.url || '#';
        color = tab.color;
        iconClass = tab.iconClass;
        openInNewTab = tab.openInNewTab ?? false;
        this.urlList.push({
          name: name,
          url: link
        });
      } else if (this.tabsHelper.isTabGroup(tab)) {
        isGroup = true;
        color = tab.color;
        iconClass = tab.iconClass;
        name = `group-${i}`;
        link = null;
        aClassName = 'nav-link-group';
      } else {
        link = '#' + tab;
      }
      const shortLabel = label.substring(0, 2);
      if (!params.colorsDisabled && !isGroup && !isDivider && !isUrl) {
        color = this.getMetadata().get(['clientDefs', tab, 'color']);
      }
      if (color && !/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(color)) {
        color = null;
      }
      if (!params.tabIconsDisabled && !isGroup && !isDivider && !isUrl) {
        iconClass = this.getMetadata().get(['clientDefs', tab, 'iconClass']);
      }
      const o = {
        link: link,
        label: label,
        shortLabel: shortLabel,
        name: name,
        isInMore: vars.moreIsMet,
        color: color,
        iconClass: iconClass,
        isAfterShowMore: vars.isHidden,
        aClassName: aClassName,
        isGroup: isGroup,
        isDivider: isDivider,
        openInNewTab
      };
      if (isGroup) {
        o.itemList = tab.itemList.map((tab, i) => {
          return this.prepareTabItemDefs(params, tab, i, vars);
        });
      }
      if (vars.isHidden) {
        o.className = 'after-show-more';
      }
      if (color && !iconClass) {
        o.colorIconClass = 'color-icon fas fa-square';
      }
      return o;
    }

    /**
     * @typedef {Object} MenuDataItem
     * @property {string} [link]
     * @property {string} [name]
     * @property {string} [html]
     * @property {string} [handler]
     * @property {string} [actionFunction]
     * @property {true} [divider]
     * @property {string} [iconClass]
     */

    /**
     * @private
     */
    setupMenu() {
      /** @type {MenuDataItem[]} */
      this.menuDataList = [{
        link: `#User/view/${this.getUser().id}`,
        html: this.composeUserMenuItemHtml()
      }, {
        divider: true
      }];

      /**
       * @type {Record<string, {
       *     order?: number,
       *     groupIndex?: number,
       *     link?: string,
       *     labelTranslation?: string,
       *     configCheck?: string,
       *     disabled:? boolean,
       *     handler?: string,
       *     actionFunction?: string,
       *     accessDataList?: import('utils').AccessDefs[],
       *     iconClass?: string,
       * }>} items
       */
      const items = this.getMetadata().get('app.clientNavbar.menuItems') || {};
      const nameList = Object.keys(items).sort((n1, n2) => {
        const o1 = items[n1].order;
        const o2 = items[n2].order;
        const g1 = items[n1].groupIndex;
        const g2 = items[n2].groupIndex;
        if (g2 === g1) {
          return o1 - o2;
        }
        return g1 - g2;
      });
      let currentGroup = 0;
      for (const name of nameList) {
        const item = items[name];
        if (item.groupIndex !== currentGroup) {
          currentGroup = item.groupIndex;
          this.menuDataList.push({
            divider: true
          });
        }
        if (item.disabled) {
          continue;
        }
        if (item.configCheck && !Espo.Utils.checkActionAvailability(this.getHelper(), item)) {
          continue;
        }
        if (item.accessDataList && !Espo.Utils.checkAccessDataList(item.accessDataList, this.getAcl(), this.getUser())) {
          continue;
        }
        this.menuDataList.push({
          name: name,
          link: item.link,
          label: this.getLanguage().translatePath(item.labelTranslation),
          handler: item.handler,
          actionFunction: item.actionFunction,
          iconClass: item.iconClass
        });
      }
    }

    /**
     * @private
     * @return {string}
     */
    composeUserMenuItemHtml() {
      const avatarHtml = this.getHelper().getAvatarHtml(this.getUser().id, 'small', 20, 'avatar-link');
      const part = this.getHelper().escapeString(this.getUser().attributes.name);
      return '<span class="item-user-profile text-medium">' + avatarHtml + part + '</span>';
    }
    showMoreTabs() {
      this.$el.find('.tab-group.tab.dropdown').removeClass('open');
      this.isMoreTabsShown = true;
      this.$more.addClass('more-expanded');
      this.adjustBodyMinHeight();
      this.trigger('show-more-tabs');
    }
    hideMoreTabs() {
      if (!this.isMoreTabsShown) {
        return;
      }
      this.$more.removeClass('more-expanded');
      this.adjustBodyMinHeight();
      this.isMoreTabsShown = false;
    }
  }
  var _default = _exports.default = NavbarSiteView;
});

define("views/site/master", ["exports", "view", "jquery", "views/collapsed-modal-bar", "di", "helpers/site/shortcut-manager"], function (_exports, _view, _jquery, _collapsedModalBar, _di, _shortcutManager) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  _jquery = _interopRequireDefault(_jquery);
  _collapsedModalBar = _interopRequireDefault(_collapsedModalBar);
  _shortcutManager = _interopRequireDefault(_shortcutManager);
  var _staticBlock;
  let _init_shortcutManager, _init_extra_shortcutManager;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  /** @module views/site/master */
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  class MasterSiteView extends _view.default {
    constructor() {
      super(...arguments);
      _init_extra_shortcutManager(this);
    }
    template = 'site/master';
    views = {
      header: {
        id: 'header',
        view: 'views/site/header'
      },
      main: {
        id: 'main',
        view: false
      },
      footer: {
        fullSelector: 'body > footer',
        view: 'views/site/footer'
      }
    };

    /**
     * @type {string}
     */
    currentViewKey;

    /**
     * @type {string}
     */
    currentName;

    /**
     * @internal
     * @type {CollapsedModalBarView}
     */
    collapsedModalBarView;

    /**
     * Injected to be loaded early.
     *
     * @private
     * @type {ShortcutManager}
     */
    shortcutManager = _init_shortcutManager(this);
    showLoadingNotification() {
      Espo.Ui.notifyWait();
    }
    hideLoadingNotification() {
      Espo.Ui.notify(false);
    }
    setup() {
      (0, _jquery.default)(window).on('resize.' + this.cid, () => {
        this.adjustContent();
      });
      this.collapsedModalBarView = new _collapsedModalBar.default();
      this.assignView('collapsedModalBar', this.collapsedModalBarView, '> .collapsed-modal-bar');
    }

    /**
     * @return {Bull.View|null}
     */
    getMainView() {
      return this.getView('main');
    }
    onRemove() {
      (0, _jquery.default)(window).off('resize.' + this.cid);
    }
    afterRender() {
      /** @type {Object.<string, Record>} */
      const params = this.getThemeManager().getParam('params');
      const body = document.body;
      for (const param of Object.keys(params)) {
        body.dataset[param] = this.getThemeManager().getParam(param);
      }
      body.dataset.isDark = this.getThemeManager().getParam('isDark') ?? false;
      body.dataset.themeName = this.getThemeManager().getName();
      const footerView = this.getView('footer');
      if (footerView) {
        const html = footerView.$el.html() || '';
        if ((html.match(/espocrm/gi) || []).length < 2) {
          const text = 'PHAgY2xhc3M9ImNyZWRpdCBzbWFsbCI+JmNvcHk7IDxhIGhyZWY9Imh0dHA6Ly93d3cuZXNwb2Nyb' + 'S5jb20iPkVzcG9DUk08L2E+PC9wPg==';
          let decText;
          if (typeof window.atob === "function") {
            decText = window.atob(text);
          } else if (typeof atob === "function") {
            decText = atob(text);
          }
          if (decText) {
            footerView.$el.html(decText);
          }
        }
      }
      this.$content = this.$el.find('> #content');
      this.adjustContent();
      const extensions = this.getHelper().getAppParam('extensions') || [];
      if (this.getConfig().get('maintenanceMode')) {
        this.createView('dialog', 'views/modal', {
          templateContent: '<div class="text-danger">{{complexText viewObject.options.message}}</div>',
          headerText: this.translate('maintenanceMode', 'fields', 'Settings'),
          backdrop: true,
          message: this.translate('maintenanceMode', 'messages'),
          buttonList: [{
            name: 'close',
            label: this.translate('Close')
          }]
        }, view => {
          view.render();
        });
      } else if (this.getHelper().getAppParam('auth2FARequired')) {
        this.createView('dialog', 'views/modals/auth2fa-required', {}, view => {
          view.render();
        });
      } else if (extensions.length !== 0) {
        this.processExtensions(extensions);
      }
    }
    adjustContent() {
      if (!this.isRendered()) {
        return;
      }
      if (window.innerWidth < this.getThemeManager().getParam('screenWidthXs')) {
        this.isSmallScreen = true;
        let height = window.innerHeight - this.$content.get(0).getBoundingClientRect().top;
        const $navbarCollapse = (0, _jquery.default)('#navbar .navbar-body');
        if ($navbarCollapse.hasClass('in') || $navbarCollapse.hasClass('collapsing')) {
          height += $navbarCollapse.height();
        }
        const footerHeight = (0, _jquery.default)('#footer').height() || 26;
        height -= footerHeight;
        if (height <= 0) {
          this.$content.css('minHeight', '');
          return;
        }
        this.$content.css('minHeight', height + 'px');
        return;
      }
      if (this.isSmallScreen) {
        this.$content.css('minHeight', '');
      }
      this.isSmallScreen = false;
    }

    /**
     * @param {{
     *     name: string,
     *     licenseStatus: string,
     *     licenseStatusMessage:? string,
     *     notify: boolean,
     * }[]} list
     */
    processExtensions(list) {
      const messageList = [];
      list.forEach(item => {
        if (!item.notify) {
          return;
        }
        const message = item.licenseStatusMessage ?? 'extensionLicense' + Espo.Utils.upperCaseFirst(Espo.Utils.hyphenToCamelCase(item.licenseStatus.toLowerCase()));
        messageList.push(this.translate(message, 'messages').replace('{name}', item.name));
      });
      if (!messageList.length) {
        return;
      }
      let message = messageList.join('\n\n');
      message = this.getHelper().transformMarkdownText(message);
      const dialog = new Espo.Ui.Dialog({
        backdrop: 'static',
        buttonList: [{
          name: 'close',
          text: this.translate('Close'),
          className: 'btn-s-wide',
          onClick: () => dialog.close()
        }],
        className: 'dialog-confirm text-danger',
        body: message.toString()
      });
      dialog.show();
    }
    static #_ = _staticBlock = () => [_init_shortcutManager, _init_extra_shortcutManager] = _applyDecs(this, [], [[(0, _di.inject)(_shortcutManager.default), 0, "shortcutManager"]], 0, void 0, _view.default).e;
  }
  _staticBlock();
  var _default = _exports.default = MasterSiteView;
});

define("views/site/header", ["exports", "view"], function (_exports, _view) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class HeaderSiteView extends _view.default {
    template = 'site/header';
    title = 'EspoCRM';
    navbarView = 'views/site/navbar';
    customViewPath = ['clientDefs', 'App', 'navbarView'];
    data = {
      title: this.title
    };
    setup() {
      const navbarView = this.getMetadata().get(this.customViewPath) || this.navbarView;
      this.createView('navbar', navbarView, {
        fullSelector: '#navbar',
        title: this.title
      });
    }
  }
  var _default = _exports.default = HeaderSiteView;
});

define("views/site/navbar/item", ["exports", "view"], function (_exports, _view) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * A navbar item.
   *
   * @abstract
   */
  class SiteNavbarItemView extends _view.default {
    /**
     * Whether this item is available.
     *
     * @return {boolean}
     */
    isAvailable() {
      return true;
    }
  }
  var _default = _exports.default = SiteNavbarItemView;
});

define("views/record/detail-bottom", ["exports", "views/record/panels-container"], function (_exports, _panelsContainer) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _panelsContainer = _interopRequireDefault(_panelsContainer);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/record/detail-bottom */

  /**
   * A detail-bottom record view.
   */
  class DetailBottomRecordView extends _panelsContainer.default {
    /** @inheritDoc */
    template = 'record/bottom';

    /** @inheritDoc */
    mode = 'detail';
    streamPanel = true;
    relationshipPanels = true;
    readOnly = false;
    portalLayoutDisabled = false;
    name = 'bottom';

    /** @inheritDoc */
    setupPanels() {
      const scope = this.scope;
      this.panelList = this.getMetadata().get(['clientDefs', scope, 'bottomPanels', this.type]) || this.panelList || [];
      this.panelList = [...this.panelList].map(item => {
        if ('reference' in item && item.reference) {
          // noinspection UnnecessaryLocalVariableJS
          /** @type {module:views/record/panels-container~panel} */
          const newItem = {
            ...this.getMetadata().get(`app.clientRecord.panels.${item.reference}`),
            ...item
          };
          return newItem;
        }
        return item;
      });
      this.panelList.forEach(item => {
        if ('index' in item) {
          return;
        }
        if ('order' in item) {
          item.index = item.order;
        }
      });
      if (this.streamPanel && this.getMetadata().get(['scopes', scope, 'stream'])) {
        this.setupStreamPanel();
      }
    }

    /**
     * Set up a stream panel.
     */
    setupStreamPanel() {
      let streamAllowed = this.getAcl().checkModel(this.model, 'stream', true);
      if (streamAllowed === null) {
        this.listenToOnce(this.model, 'sync', () => {
          streamAllowed = this.getAcl().checkModel(this.model, 'stream', true);
          if (streamAllowed) {
            this.onPanelsReady(() => {
              this.showPanel('stream', 'acl');
            });
          }
        });
      }
      if (streamAllowed !== false) {
        this.panelList.push({
          name: 'stream',
          label: 'Stream',
          view: this.getMetadata().get(['clientDefs', this.scope, 'streamPanelView']) || 'views/stream/panel',
          sticked: false,
          hidden: !streamAllowed,
          index: 2
        });
        if (!streamAllowed) {
          this.recordHelper.setPanelStateParam('stream', 'hiddenAclLocked', true);
        }
      }
    }
    init() {
      this.recordHelper = this.options.recordHelper;
      this.scope = this.entityType = this.model.name;
      this.readOnlyLocked = this.options.readOnlyLocked || this.readOnly;
      this.readOnly = this.options.readOnly || this.readOnly;
      this.inlineEditDisabled = this.options.inlineEditDisabled || this.inlineEditDisabled;
      this.portalLayoutDisabled = this.options.portalLayoutDisabled || this.portalLayoutDisabled;
      this.recordViewObject = this.options.recordViewObject;
    }
    setup() {
      this.type = this.mode;
      if ('type' in this.options) {
        this.type = this.options.type;
      }
      this.panelList = [];
      this.setupInitial();
      this.setupPanels();
      this.wait(true);
      Promise.all([new Promise(resolve => {
        this.getHelper().layoutManager.get(this.scope, 'bottomPanels' + Espo.Utils.upperCaseFirst(this.type), layoutData => {
          this.layoutData = layoutData;
          resolve();
        });
      })]).then(() => {
        const panelNameList = [];
        this.panelList = this.panelList.filter(p => {
          panelNameList.push(p.name);
          if (p.aclScope) {
            if (!this.getAcl().checkScope(p.aclScope)) {
              return;
            }
          }
          if (p.accessDataList) {
            if (!Espo.Utils.checkAccessDataList(p.accessDataList, this.getAcl(), this.getUser())) {
              return false;
            }
          }
          return true;
        });
        if (this.relationshipPanels) {
          const linkDefs = (this.model.defs || {}).links || {};
          if (this.layoutData) {
            for (const name in this.layoutData) {
              if (!linkDefs[name]) {
                continue;
              }
              const p = this.layoutData[name];
              if (!~panelNameList.indexOf(name) && !p.disabled) {
                this.addRelationshipPanel(name, p);
              }
            }
          }
        }
        this.panelList = this.panelList.map(p => {
          const item = Espo.Utils.clone(p);
          if (this.recordHelper.getPanelStateParam(p.name, 'hidden') !== null) {
            item.hidden = this.recordHelper.getPanelStateParam(p.name, 'hidden');
          } else {
            this.recordHelper.setPanelStateParam(p.name, 'hidden', item.hidden || false);
          }
          return item;
        });
        this.panelList.forEach(item => {
          item.actionsViewKey = item.name + 'Actions';
        });
        this.alterPanels();
        this.setupPanelsFinal();
        this.setupPanelViews();
        this.wait(false);
      });
    }

    /**
     * Set read-only.
     */
    setReadOnly() {
      this.readOnly = true;
    }

    /** @private */
    addRelationshipPanel(name, item) {
      const scope = this.scope;
      const scopesDefs = this.getMetadata().get('scopes') || {};
      let p;
      if (typeof item === 'string' || item instanceof String) {
        p = {
          name: item
        };
      } else {
        p = Espo.Utils.clone(item || {});
      }
      p.name = p.name || name;
      if (!p.name) {
        return;
      }
      if (typeof p.order === 'undefined') p.order = 5;
      name = p.name;
      const links = (this.model.defs || {}).links || {};
      if (!(name in links)) {
        return;
      }
      const foreignScope = links[name].entity;
      if ((scopesDefs[foreignScope] || {}).disabled) {
        return;
      }
      if (!this.getAcl().check(foreignScope, 'read')) {
        return;
      }
      let defs = this.getMetadata().get(['clientDefs', scope, 'relationshipPanels', name]) || {};
      defs = Espo.Utils.clone(defs);
      for (const i in defs) {
        if (i in p) {
          continue;
        }
        p[i] = defs[i];
      }
      if (!p.view) {
        p.view = 'views/record/panels/relationship';
      }
      if (this.recordHelper.getPanelStateParam(p.name, 'hidden') !== null) {
        p.hidden = this.recordHelper.getPanelStateParam(p.name, 'hidden');
      } else {
        this.recordHelper.setPanelStateParam(p.name, 'hidden', p.hidden || false);
      }
      this.panelList.push(p);
    }
  }
  var _default = _exports.default = DetailBottomRecordView;
});

define("views/record/row-actions/relationship", ["exports", "views/record/row-actions/default"], function (_exports, _default2) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _default2 = _interopRequireDefault(_default2);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class RelationshipRowActionsView extends _default2.default {
    getActionList() {
      const list = [{
        action: 'quickView',
        label: 'View',
        data: {
          id: this.model.id
        },
        link: '#' + this.model.entityType + '/view/' + this.model.id,
        groupIndex: 0,
        iconClass: _default2.default.ICON_CLASS_VIEW
      }];
      if (this.options.acl.edit && !this.options.editDisabled) {
        list.push({
          action: 'quickEdit',
          label: 'Edit',
          data: {
            id: this.model.id
          },
          link: '#' + this.model.entityType + '/edit/' + this.model.id,
          groupIndex: 0,
          iconClass: _default2.default.ICON_CLASS_EDIT
        });
      }
      if (!this.options.unlinkDisabled) {
        list.push({
          action: 'unlinkRelated',
          label: 'Unlink',
          data: {
            id: this.model.id
          },
          groupIndex: 1
        });
      }
      this.getAdditionalActionList().forEach(item => list.push(item));
      if (this.options.acl.delete && !this.options.removeDisabled) {
        list.push({
          action: 'removeRelated',
          label: 'Remove',
          data: {
            id: this.model.id
          },
          groupIndex: 0,
          iconClass: _default2.default.ICON_CLASS_REMOVE
        });
      }
      return list;
    }
  }
  var _default = _exports.default = RelationshipRowActionsView;
});

define("views/record/panels/default-side", ["exports", "views/record/panels/side"], function (_exports, _side) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _side = _interopRequireDefault(_side);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * A default side panel.
   */
  class DefaultSidePanelView extends _side.default {
    /**
     * @protected
     * @type {boolean}
     */
    complexCreatedDisabled;

    /**
     * @protected
     * @type {boolean}
     */
    complexModifiedDisabled;

    /**
     * @protected
     * @type {boolean}
     */
    hasIsLocked;
    data() {
      const data = super.data();
      if (this.complexCreatedDisabled && this.complexModifiedDisabled || !this.hasComplexCreated && !this.hasComplexModified) {
        data.complexDateFieldsDisabled = true;
      }
      data.hasComplexCreated = this.hasComplexCreated;
      data.hasComplexModified = this.hasComplexModified;
      return data;
    }
    setup() {
      this.fieldList = Espo.Utils.cloneDeep(this.fieldList);
      const allFieldList = this.getFieldManager().getEntityTypeFieldList(this.model.entityType);
      this.hasComplexCreated = allFieldList.includes('createdAt') || allFieldList.includes('createdBy');
      this.hasComplexModified = allFieldList.includes('modifiedAt') || allFieldList.includes('modifiedBy');
      this.hasIsLocked = this.getMetadata().get(`scopes.${this.model.entityType}.lockable`) === true;
      super.setup();
    }
    setupFields() {
      super.setupFields();
      if (this.hasIsLocked) {
        this.fieldList.push({
          name: 'isLocked',
          view: 'views/global/fields/is-locked'
        });
        this.controlIsLockedField();
        this.listenTo(this.model, 'change:isLocked', () => this.controlIsLockedField());
      }
      if (!this.complexCreatedDisabled) {
        if (this.hasComplexCreated) {
          this.fieldList.push({
            name: 'complexCreated',
            labelText: this.translate('Created'),
            isAdditional: true,
            view: 'views/fields/complex-created',
            readOnly: true
          });
          if (!this.model.get('createdById') && !this.model.get('createdAt')) {
            this.recordViewObject.hideField('complexCreated');
          }
        }
      } else {
        this.recordViewObject.hideField('complexCreated');
      }
      if (!this.complexModifiedDisabled) {
        if (this.hasComplexModified) {
          this.fieldList.push({
            name: 'complexModified',
            labelText: this.translate('Modified'),
            isAdditional: true,
            view: 'views/fields/complex-created',
            readOnly: true,
            options: {
              baseName: 'modified'
            }
          });
          if (!this.isModifiedVisible()) {
            this.recordViewObject.hideField('complexModified');
          }
        }
      } else {
        this.recordViewObject.hideField('complexModified');
      }
      if (!this.complexCreatedDisabled && this.hasComplexCreated) {
        this.listenTo(this.model, 'change', () => {
          if (!this.model.hasChanged('createdById') && !this.model.hasChanged('createdAt')) {
            return;
          }
          if (!this.model.get('createdById') && !this.model.get('createdAt')) {
            return;
          }
          this.recordViewObject.showField('complexCreated');
        });
      }
      if (!this.complexModifiedDisabled && this.hasComplexModified) {
        this.listenTo(this.model, 'change', () => {
          if (!this.model.hasChanged('modifiedById') && !this.model.hasChanged('modifiedAt')) {
            return;
          }
          if (!this.isModifiedVisible()) {
            return;
          }
          this.recordViewObject.showField('complexModified');
        });
      }
      if (this.getMetadata().get(['scopes', this.model.entityType, 'stream']) && !this.getUser().isPortal()) {
        this.fieldList.push({
          name: 'followers',
          labelText: this.translate('Followers'),
          isAdditional: true,
          view: 'views/fields/followers',
          readOnly: true
        });
        this.controlFollowersField();
        this.listenTo(this.model, 'change:followersIds', () => this.controlFollowersField());
      }
    }

    /**
     * @private
     * @return {boolean}
     */
    isModifiedVisible() {
      if (!this.hasComplexModified) {
        return false;
      }
      if (!this.model.get('modifiedById') && !this.model.get('modifiedAt')) {
        return false;
      }
      if (!this.model.get('modifiedById') && this.model.get('modifiedAt') === this.model.get('createdAt')) {
        return false;
      }
      return true;
    }
    controlFollowersField() {
      if (this.model.get('followersIds') && this.model.get('followersIds').length) {
        this.recordViewObject.showField('followers');
        return;
      }
      this.recordViewObject.hideField('followers');
    }

    /**
     * @private
     */
    controlIsLockedField() {
      if (this.model.attributes.isLocked) {
        this.recordViewObject.showField('isLocked');
      } else {
        this.recordViewObject.hideField('isLocked');
      }
    }
  }
  var _default = _exports.default = DefaultSidePanelView;
});

define("views/record/kanban/pipeline-dropdown", ["exports", "view", "di", "theme-manager"], function (_exports, _view, _di, _themeManager) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  _themeManager = _interopRequireDefault(_themeManager);
  var _staticBlock;
  let _init_themeManager, _init_extra_themeManager;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  class KanbanPipelineDropdownView extends _view.default {
    // language=Handlebars
    templateContent = `
        <button
            class="btn btn-text dropdown-toggle btn-s-wide"
            data-toggle="dropdown"
            title="{{translate 'pipeline' category='fields'}}"
        >
            {{~#if 0}}{{/if~}}
            <span
                class="color-icon fas fa-square text-soft"
                style=" {{#if color}} color: {{color}} {{/if}} "
            ></span>
            <span>{{name}}</span>
            <span class="caret"></span>
        </button>
        <ul class="dropdown-menu">
            {{#each pipelines}}
                <li>
                    <a
                        role="button"
                        data-id="{{id}}"
                        data-action="selectPipeline"
                    >

                        {{#if selected}}
                            <span class="fas fa-check check-icon pull-right"></span>
                        {{/if}}
                        <div class="{{#if active}} text-bold text-soft{{/if}}">
                            {{~#if 0}}{{/if~}}
                            <span
                                class="color-icon fas fa-square text-soft"
                                style="
                                    {{#if color}} color: {{color}}; {{/if}}
                                    padding-right: var(--4px);
                                "
                            ></span>
                            {{name}}
                        </div>
                    </a>
                </li>
            {{/each}}
        </ul>
    `;

    /**
     * @private
     * @type {ThemeManager}
     */
    themeManager = _init_themeManager(this);

    /**
     * @private
     * @type {Record<string, number|null>}
     */
    colorMap = void _init_extra_themeManager(this);

    /**
     *
     * @param {{
     *     state: {
     *         pipelineId: string,
     *         pipelines: {
     *             id: string,
     *             name: string,
     *             color: number|null,
     *         }[],
     *     },
     *     onChange: function(string),
     * }} options
     */
    constructor(options) {
      super(options);
      this.options = options;

      /** @private */
      this.state = options.state;
    }
    data() {
      var _this$state$pipelines;
      const id = this.state.pipelineId;
      const name = (_this$state$pipelines = this.state.pipelines.find(it => it.id === id)) === null || _this$state$pipelines === void 0 ? void 0 : _this$state$pipelines.name;
      const color = id ? this.colorMap[id] : null;
      const pipelines = this.state.pipelines.map(it => ({
        ...it,
        selected: id === it.id,
        color: this.colorMap[it.id] ?? null
      }));
      return {
        name: name ?? id,
        pipelines: pipelines,
        color: color ?? null
      };
    }
    setup() {
      this.addActionHandler('selectPipeline', (e, target) => this.selectPipeline(target.dataset.id));

      /** @type {string[]} */
      const colors = this.themeManager.getParam('chartColorList') || [];
      this.colorMap = this.state.pipelines.reduce((o, it) => {
        let color = null;
        if (it.color != null) {
          color = colors[it.color] ?? null;
        }
        o[it.id] = color;
        return o;
      }, {});
    }

    /**
     * @private
     * @param {string} id
     */
    selectPipeline(id) {
      if (this.state.pipelineId === id) {
        return;
      }
      this.options.onChange(id);
    }
    static #_ = _staticBlock = () => [_init_themeManager, _init_extra_themeManager] = _applyDecs(this, [], [[(0, _di.inject)(_themeManager.default), 0, "themeManager"]], 0, void 0, _view.default).e;
  }
  _exports.default = KanbanPipelineDropdownView;
  _staticBlock();
});

define("views/notification/items/base", ["exports", "view"], function (_exports, _view) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/notification/items/base */

  class BaseNotificationItemView extends _view.default {
    /** @type {string} */
    messageName;
    /** @type {string} */
    messageTemplate;
    messageData = null;
    isSystemAvatar = false;
    data() {
      return {
        avatar: this.getAvatarHtml()
      };
    }
    init() {
      this.createField('createdAt', null, null, 'views/fields/datetime-short');
      this.messageData = {};
    }
    createField(name, type, params, view) {
      type = type || this.model.getFieldType(name) || 'base';
      this.createView(name, view || this.getFieldManager().getViewName(type), {
        model: this.model,
        defs: {
          name: name,
          params: params || {}
        },
        selector: '.cell-' + name,
        mode: 'list'
      });
    }
    createMessage() {
      const parentType = this.model.get('relatedParentType') || null;
      if (!this.messageTemplate && this.messageName) {
        this.messageTemplate = this.translate(this.messageName, 'notificationMessages', parentType) || '';
      }
      if (this.messageTemplate.indexOf('{entityType}') === 0 && typeof this.messageData.entityType === 'string') {
        this.messageData.entityTypeUcFirst = Espo.Utils.upperCaseFirst(this.messageData.entityType);
        this.messageTemplate = this.messageTemplate.replace('{entityType}', '{entityTypeUcFirst}');
      }
      this.createView('message', 'views/stream/message', {
        messageTemplate: this.messageTemplate,
        selector: '.message',
        model: this.model,
        messageData: this.messageData
      });
    }
    getAvatarHtml() {
      let id = this.userId;
      if (this.isSystemAvatar || !id) {
        id = this.getHelper().getAppParam('systemUserId');
      }
      return this.getHelper().getAvatarHtml(id, 'small', 20);
    }

    /**
     * @param {string} entityType
     * @param {boolean} [isPlural]
     * @return {string}
     */
    translateEntityType(entityType, isPlural) {
      let string = isPlural ? this.translate(entityType, 'scopeNamesPlural') || '' : this.translate(entityType, 'scopeNames') || '';
      string = string.toLowerCase();
      if (this.toUpperCaseFirstLetter()) {
        string = Espo.Utils.upperCaseFirst(string);
      }
      return string;
    }

    /**
     * @property
     * @return {boolean}
     */
    toUpperCaseFirstLetter() {
      const language = this.getPreferences().get('language') || this.getConfig().get('language');
      return ['de_DE', 'nl_NL'].includes(language);
    }

    /**
     * @protected
     * @param entityType
     * @param id
     * @return {string|null}
     */
    getIconHtml(entityType, id) {
      const iconClass = this.getMetadata().get(`clientDefs.${entityType}.iconClass`);
      const color = this.getMetadata().get(`clientDefs.${entityType}.color`);
      if (!iconClass) {
        return null;
      }
      const span = document.createElement('span');
      span.className = `action text-muted icon ${iconClass}`;
      span.style.cursor = 'pointer';
      span.style.color = color ? color : '';
      span.title = this.translate('View');
      span.dataset.action = 'quickView';
      span.dataset.id = id;
      span.dataset.scope = entityType;
      return span.outerHTML;
    }
  }
  var _default = _exports.default = BaseNotificationItemView;
});

define("views/notification/fields/container", ["exports", "views/fields/base", "views/notification/record/list", "views/notification/panel", "ajax", "ui"], function (_exports, _base, _list, _panel, _ajax, _ui) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  _list = _interopRequireDefault(_list);
  _panel = _interopRequireDefault(_panel);
  _ajax = _interopRequireDefault(_ajax);
  _ui = _interopRequireDefault(_ui);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class NotificationContainerFieldView extends _base.default {
    type = 'notification';
    listTemplate = 'notification/fields/container';
    detailTemplate = 'notification/fields/container';

    /**
     * @private
     * @type {string[]}
     */
    types = ['Assign', 'EmailReceived', 'EntityRemoved', 'Message', 'System', 'UserReaction', 'Collaborating'];
    inlineEditDisabled = true;

    /**
     * @private
     * @type {boolean}
     */
    isGroupExpanded = false;

    /**
     * @private
     * @type {boolean}
     */
    groupingEnabled;
    data() {
      const count = this.model.attributes.groupedCount ?? 0;
      return {
        hasGrouped: count > 1 || count < 0,
        isGroupExpanded: this.isGroupExpanded,
        hasMarkGroupRead: this.groupingEnabled && !this.model.attributes.read
      };
    }
    setup() {
      this.groupingEnabled = this.options.groupingEnabled ?? false;
      if (this.model.attributes.groupType) {
        this.wait(this.processGroup());
      } else {
        switch (this.model.attributes.type) {
          case 'Note':
            this.processNote(this.model.attributes.noteData);
            break;
          case 'MentionInPost':
            this.processMentionInPost(this.model.attributes.noteData);
            break;
          default:
            this.process();
        }
      }
      this.addActionHandler('showGrouped', () => this.showGrouped());
      this.addActionHandler('markGroupRead', () => this.markGroupRead());
      if (this.model.collection) {
        this.listenTo(this.model.collection, 'all-read', () => {
          this.removeMarkGroupRead();
        });
      }
    }

    /**
     * @private
     */
    removeMarkGroupRead() {
      var _this$element;
      if (!this.isRendered()) {
        return;
      }
      const element = (_this$element = this.element) === null || _this$element === void 0 ? void 0 : _this$element.querySelector('[data-action="markGroupRead"]');
      element === null || element === void 0 || element.remove();
    }
    process() {
      let type = this.model.get('type');
      if (!type) {
        return;
      }
      type = Espo.Utils.upperCaseFirst(type.replace(/ /g, ''));
      let viewName = this.getMetadata().get(`clientDefs.Notification.itemViews.${type}`);
      if (!viewName) {
        if (!this.types.includes(type)) {
          return;
        }
        viewName = 'views/notification/items/' + Espo.Utils.camelCaseToHyphen(type);
      }
      const parentSelector = this.options.containerSelector ?? this.getSelector();
      this.createView('notification', viewName, {
        model: this.model,
        fullSelector: `${parentSelector} li[data-id="${this.model.id}"]`
      });
    }

    /**
     * @private
     */
    async processGroup() {
      const groupType = this.model.attributes.groupType;
      let viewName;
      if (groupType === 'Record') {
        viewName = 'views/notification/items/group-note';
      } else if (groupType === 'EmailReceived') {
        viewName = 'views/notification/items/group-email-received';
      }
      if (!viewName) {
        return;
      }
      const parentSelector = this.options.containerSelector ?? this.getSelector();
      await this.createView('notification', viewName, {
        model: this.model,
        fullSelector: `${parentSelector} li[data-id="${this.model.id}"]`
      });
    }

    /**
     * @private
     * @param {Record} data
     */
    processNote(data) {
      if (!data) {
        return;
      }
      this.wait(true);
      this.getModelFactory().create('Note', model => {
        model.set(data);
        let viewName = this.getMetadata().get(`clientDefs.Note.itemViews.${data.type}`);
        if (!viewName) {
          // @todo Check if type exists.
          viewName = 'views/stream/notes/' + Espo.Utils.camelCaseToHyphen(data.type);
        }
        const parentSelector = this.options.containerSelector ?? this.getSelector();
        this.createView('notification', viewName, {
          model: model,
          isUserStream: true,
          fullSelector: `${parentSelector} li[data-id="${this.model.id}"] .cell[data-name="data"]`,
          onlyContent: true,
          isNotification: true,
          isInGroup: this.options.isInGroup ?? false
        });
        this.wait(false);
      });
    }

    /**
     * @private
     * @param {Record} data
     */
    processMentionInPost(data) {
      if (!data) {
        return;
      }
      this.wait(true);
      this.getModelFactory().create('Note', model => {
        model.set(data);
        const viewName = 'views/stream/notes/mention-in-post';
        const parentSelector = this.options.containerSelector ?? this.getSelector();
        this.createView('notification', viewName, {
          model: model,
          userId: this.model.get('userId'),
          isUserStream: true,
          fullSelector: `${parentSelector} li[data-id="${this.model.id}"]`,
          onlyContent: true,
          isNotification: true
        });
        this.wait(false);
      });
    }

    /**
     * @private
     */
    async showGrouped() {
      const collection = await this.getCollectionFactory().create('Notification');
      if (this.model.attributes.groupType) {
        collection.url = `Notification/group?type=${this.model.attributes.groupType}&id=` + this.model.id;
        collection.maxSize = this.getConfig().get('recordsPerPageSmall');
      } else {
        collection.url = `Notification/${this.model.id}/group`;
      }
      const button = this.element.querySelector('a[data-action="showGrouped"]');
      if (button instanceof HTMLElement) {
        button.classList.add('disabled');
      }
      _ui.default.notifyWait();
      try {
        await collection.fetch();
      } catch (e) {
        await this.reRender();
        return;
      }
      _ui.default.notify();
      this.isGroupExpanded = true;
      const view = new _list.default({
        collection: collection,
        showCount: false,
        selector: '.notification-grouped',
        listLayout: {
          rows: [[{
            name: 'data',
            view: 'views/notification/fields/container',
            options: {
              isInGroup: true
            }
          }]]
        }
      });
      await this.assignView('groupedList', view);
      await this.reRender();
      this.triggerUpdateRead();
      if (this.model.collection) {
        view.listenTo(this.model.collection, 'all-read', () => {
          collection.models.forEach(model => {
            model.set('read', true, {
              sync: true
            });
          });
        });
      }
    }

    /**
     * @private
     */
    async markGroupRead() {
      await _ajax.default.postRequest(`Notification/group/${this.model.id}/markRead`);
      this.model.set('read', true, {
        sync: true
      });
      await this.reRender();
      this.triggerUpdateRead();
    }

    /**
     * @internal
     */
    triggerUpdateRead() {
      let viewPointer = this;
      while (true) {
        viewPointer = viewPointer.getParentView();
        if (!viewPointer || viewPointer instanceof _panel.default) {
          break;
        }
      }
      if (viewPointer instanceof _panel.default) {
        viewPointer.trigger('collection-fetched');
      }
    }
  }
  var _default = _exports.default = NotificationContainerFieldView;
});

define("views/modals/related-list", ["exports", "views/modal", "search-manager", "jquery", "helpers/record/select-related", "helpers/record/create-related", "utils"], function (_exports, _modal, _searchManager, _jquery, _selectRelated, _createRelated, _utils) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  _searchManager = _interopRequireDefault(_searchManager);
  _jquery = _interopRequireDefault(_jquery);
  _selectRelated = _interopRequireDefault(_selectRelated);
  _createRelated = _interopRequireDefault(_createRelated);
  _utils = _interopRequireDefault(_utils);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/modals/related-records */

  /**
   * A related-list modal.
   *
   * @todo JSDocs constructor options.
   */
  class RelatedListModalView extends _modal.default {
    template = 'modals/related-list';
    className = 'dialog dialog-record';
    searchPanel = true;
    scope = '';
    noCreateScopeList = ['User', 'Team', 'Role', 'Portal'];
    backdrop = true;
    fixedHeaderHeight = true;
    mandatorySelectAttributeList = null;
    layoutName = 'listSmall';

    /** @inheritDoc */
    shortcutKeys = {
      /** @this RelatedListModalView */
      'Control+Space': function (e) {
        this.handleShortcutKeyCtrlSpace(e);
      },
      /** @this RelatedListModalView */
      'Control+Slash': function (e) {
        this.handleShortcutKeyCtrlSlash(e);
      },
      /** @this RelatedListModalView */
      'Control+Comma': function (e) {
        this.handleShortcutKeyCtrlComma(e);
      },
      /** @this RelatedListModalView */
      'Control+Period': function (e) {
        this.handleShortcutKeyCtrlPeriod(e);
      },
      /** @this RelatedListModalView */
      'Control+ArrowLeft': function (e) {
        this.handleShortcutKeyControlArrowLeft(e);
      },
      /** @this RelatedListModalView */
      'Control+ArrowRight': function (e) {
        this.handleShortcutKeyControlArrowRight(e);
      }
    };
    events = {
      /** @this RelatedListModalView */
      'click button[data-action="createRelated"]': function () {
        this.actionCreateRelated();
      },
      /** @this RelatedListModalView */
      'click .action': function (e) {
        const isHandled = Espo.Utils.handleAction(this, e.originalEvent, e.currentTarget);
        if (isHandled) {
          return;
        }
        this.trigger('action', e.originalEvent, e.currentTarget);
      }
    };
    setup() {
      this.primaryFilterName = this.options.primaryFilterName || null;
      this.buttonList = [{
        name: 'cancel',
        label: 'Close'
      }];
      this.scope = this.options.scope || this.options.entityType || this.scope;
      this.defaultOrderBy = this.options.defaultOrderBy;
      this.defaultOrder = this.options.defaultOrder;
      this.panelName = this.options.panelName;
      this.link = this.options.link;
      this.defs = this.options.defs || {};
      this.filterList = this.options.filterList;
      this.filter = this.options.filter;
      this.layoutName = this.options.layoutName || this.layoutName;
      this.url = this.options.url;
      this.listViewName = this.options.listViewName;
      this.rowActionsView = this.options.rowActionsView;
      this.createDisabled = this.options.createDisabled || this.createDisabled;
      this.selectDisabled = this.options.selectDisabled || this.selectDisabled;
      this.massUnlinkDisabled = this.options.massUnlinkDisabled || this.massUnlinkDisabled;
      this.massActionRemoveDisabled = this.options.massActionRemoveDisabled || this.massActionRemoveDisabled;
      this.massActionMassUpdateDisabled = this.options.massActionMassUpdateDisabled || this.massActionMassUpdateDisabled;
      this.panelCollection = this.options.panelCollection;
      if (this.options.searchPanelDisabled) {
        this.searchPanel = false;
      }
      if (this.panelCollection) {
        this.listenTo(this.panelCollection, 'sync', (c, r, o) => {
          if (o.skipCollectionSync) {
            return;
          }
          this.collection.fetch();
        });

        // Sync changing models.
        this.listenTo(this.panelCollection, 'change', (m, o) => {
          // Prevent change after save.
          if (o.xhr || !m.id) {
            return;
          }
          const model = this.collection.get(m.id);
          if (!model) {
            return;
          }
          const attributes = {};
          for (const name in m.attributes) {
            if (m.hasChanged(name)) {
              attributes[name] = m.attributes[name];
            }
          }
          model.set(attributes);
        });
        if (this.model) {
          this.listenTo(this.model, 'after:unrelate', () => {
            this.panelCollection.fetch({
              skipCollectionSync: true
            });
          });
        }
      } else if (this.model) {
        this.listenTo(this.model, 'after:relate', () => {
          this.collection.fetch();
        });
      }
      if (this.noCreateScopeList.indexOf(this.scope) !== -1) {
        this.createDisabled = true;
      }
      this.primaryFilterName = this.filter;
      if (!this.createDisabled) {
        if (!this.getAcl().check(this.scope, 'create') || this.getMetadata().get(['clientDefs', this.scope, 'createDisabled'])) {
          this.createDisabled = true;
        }
      }
      this.unlinkDisabled = this.unlinkDisabled || this.options.unlinkDisabled || this.defs.unlinkDisabled;
      if (!this.massUnlinkDisabled) {
        if (this.unlinkDisabled || this.defs.massUnlinkDisabled || this.defs.unlinkDisabled) {
          this.massUnlinkDisabled = true;
        }
        if (!this.getAcl().check(this.model, 'edit')) {
          this.massUnlinkDisabled = true;
        }
      }
      if (!this.selectDisabled) {
        this.buttonList.unshift({
          name: 'selectRelated',
          label: 'Select',
          pullLeft: true
        });
      }
      if (!this.createDisabled) {
        this.buttonList.unshift({
          name: 'createRelated',
          label: 'Create',
          pullLeft: true
        });
      }
      this.$header = (0, _jquery.default)('<span>');
      if (this.model) {
        if (this.model.get('name')) {
          this.$header.append((0, _jquery.default)('<span>').text(this.model.get('name')), ' <span class="chevron-right"></span> ');
        }
      }
      let title = this.options.title;
      if (title) {
        title = this.getHelper().escapeString(this.options.title).replace(/@right/, '<span class="chevron-right"></span>');
      }
      this.$header.append(title || (0, _jquery.default)('<span>').text(this.getLanguage().translate(this.link, 'links', this.scope)));
      if (this.options.listViewUrl) {
        this.$header = (0, _jquery.default)('<a>').attr('href', this.options.listViewUrl).append(this.$header);
      }
      if (!this.options.listViewUrl && (!this.defs.fullFormDisabled && this.link && this.model.hasLink(this.link) || this.options.fullFormUrl)) {
        const url = this.options.fullFormUrl || '#' + this.model.entityType + '/related/' + this.model.id + '/' + this.link;
        this.buttonList.unshift({
          name: 'fullForm',
          label: 'Full Form',
          onClick: () => this.getRouter().navigate(url, {
            trigger: true
          })
        });
        this.$header = (0, _jquery.default)('<a>').attr('href', url).append(this.$header);
      }
      const iconHtml = this.getHelper().getScopeColorIconHtml(this.scope);
      if (iconHtml) {
        this.$header = (0, _jquery.default)('<span>').append(iconHtml).append(this.$header);
      }
      this.waitForView('list');
      if (this.searchPanel) {
        this.waitForView('search');
      }
      this.getCollectionFactory().create(this.scope, collection => {
        collection.maxSize = this.options.maxSize || this.getConfig().get('recordsPerPage');
        collection.url = this.url;
        collection.setOrder(this.defaultOrderBy, this.defaultOrder, true);
        collection.parentModel = this.model;
        this.collection = collection;
        if (this.panelCollection) {
          this.listenTo(collection, 'change', model => {
            const panelModel = this.panelCollection.get(model.id);
            if (panelModel) {
              panelModel.set(model.attributes);
            }
          });
          this.listenTo(collection, 'after:mass-remove', () => {
            this.panelCollection.fetch({
              skipCollectionSync: true
            });
          });
        }
        this.setupSearch();
        this.setupList();
      });

      // If the list not yet loaded.
      this.once('close', () => {
        if (this.collection.lastSyncPromise && this.collection.lastSyncPromise.getStatus() < 4) {
          Espo.Ui.notify(false);
        }
        this.collection.abortLastFetch();
      });
    }
    setFilter(filter) {
      this.searchManager.setPrimary(filter);
    }

    /**
     * @protected
     * @return {module:views/record/search}
     */
    getSearchView() {
      return this.getView('search');
    }

    /**
     * @protected
     * @return {module:views/record/list}
     */
    getRecordView() {
      return this.getView('list');
    }
    setupSearch() {
      this.searchManager = new _searchManager.default(this.collection, {
        emptyOnReset: true
      });
      const primaryFilterName = this.primaryFilterName;
      if (primaryFilterName) {
        this.searchManager.setPrimary(primaryFilterName);
      }
      this.collection.where = this.searchManager.getWhere();
      let filterList = Espo.Utils.clone(this.getMetadata().get(['clientDefs', this.scope, 'filterList']) || []);
      if (this.options.noDefaultFilters) {
        filterList = [];
      }
      if (this.filterList) {
        this.filterList.forEach(item1 => {
          let isFound = false;
          const name1 = item1.name || item1;
          if (!name1 || name1 === 'all') {
            return;
          }
          filterList.forEach(item2 => {
            const name2 = item2.name || item2;
            if (name1 === name2) {
              isFound = true;
            }
          });
          if (!isFound) {
            filterList.push(item1);
          }
        });
      }
      if (this.options.filtersDisabled) {
        filterList = [];
      }
      if (this.searchPanel) {
        this.createView('search', 'views/record/search', {
          collection: this.collection,
          fullSelector: this.containerSelector + ' .search-container',
          searchManager: this.searchManager,
          disableSavePreset: true,
          filterList: filterList,
          filtersLayoutName: this.options.filtersLayoutName
        }, view => {
          this.listenTo(view, 'reset', () => {});
        });
      }
    }
    setupList() {
      const viewName = this.listViewName || this.getMetadata().get(['clientDefs', this.scope, 'recordViews', 'listRelated']) || this.getMetadata().get(['clientDefs', this.scope, 'recordViews', 'list']) || 'views/record/list';

      // noinspection JSUnresolvedReference
      const rowActionList = this.defs.rowActionList;
      const promise = this.createView('list', viewName, {
        collection: this.collection,
        fullSelector: this.containerSelector + ' .list-container',
        rowActionsView: this.rowActionsView,
        listLayout: this.options.listLayout,
        layoutName: this.layoutName,
        searchManager: this.searchManager,
        buttonsDisabled: true,
        skipBuildRows: true,
        model: this.model,
        unlinkMassAction: !this.massUnlinkDisabled,
        massActionsDisabled: this.options.massActionsDisabled,
        massActionRemoveDisabled: this.massActionRemoveDisabled,
        massActionMassUpdateDisabled: this.massActionMassUpdateDisabled,
        mandatorySelectAttributeList: this.mandatorySelectAttributeList,
        additionalRowActionList: rowActionList,
        rowActionsOptions: {
          unlinkDisabled: this.unlinkDisabled,
          editDisabled: this.defs.editDisabled,
          removeDisabled: this.defs.removeDisabled
        },
        removeDisabled: this.defs.removeDisabled,
        forcePagination: this.options.forcePagination,
        pagination: this.getConfig().get('listPagination') || this.getMetadata().get(['clientDefs', this.scope, 'listPagination']) || null
      }, /** import('views/record/list').default */view => {
        this.listenTo(view, 'after:paginate', () => this.bodyElement.scrollTop = 0);
        this.listenTo(view, 'sort', () => this.bodyElement.scrollTop = 0);
        this.listenToOnce(view, 'select', model => {
          this.trigger('select', model);
          this.close();
        });
        if (this.multiple) {
          this.listenTo(view, 'check', () => {
            view.checkedList.length ? this.enableButton('select') : this.disableButton('select');
          });
          this.listenTo(view, 'select-all-results', () => this.enableButton('select'));
        }
        const fetch = () => {
          this.whenRendered().then(() => {
            Espo.Ui.notifyWait();
            this.collection.fetch().then(() => Espo.Ui.notify(false));
          });
          // Timeout to make notify work.
          /*setTimeout(() => {
              Espo.Ui.notifyWait();
                this.collection.fetch()
                  .then(() => Espo.Ui.notify(false));
          }, 1);*/
        };
        if (this.options.forceSelectAllAttributes || this.forceSelectAllAttributes) {
          fetch();
          return;
        }
        view.getSelectAttributeList(selectAttributeList => {
          if (!~selectAttributeList.indexOf('name')) {
            selectAttributeList.push('name');
          }
          const mandatorySelectAttributeList = this.options.mandatorySelectAttributeList || this.mandatorySelectAttributeList || [];
          mandatorySelectAttributeList.forEach(attribute => {
            if (!~selectAttributeList.indexOf(attribute)) {
              selectAttributeList.push(attribute);
            }
          });
          if (selectAttributeList) {
            this.collection.data.select = selectAttributeList.join(',');
          }
          fetch();
        });
      });
      this.wait(promise);
    }

    // noinspection JSUnusedGlobalSymbols
    actionUnlinkRelated(data) {
      const id = data.id;
      this.confirm({
        message: this.translate('unlinkRecordConfirmation', 'messages'),
        confirmText: this.translate('Unlink')
      }, () => {
        Espo.Ui.notifyWait();
        Espo.Ajax.deleteRequest(this.collection.url, {
          id: id
        }).then(() => {
          Espo.Ui.success(this.translate('Unlinked'));
          this.collection.fetch();
          this.model.trigger('after:unrelate');
          this.model.trigger('after:unrelate:' + this.link);
        });
      });
    }

    /**
     * @private
     */
    actionCreateRelated() {
      // noinspection JSUnresolvedReference
      const actionName = this.defs.createAction || 'createRelated';
      if (actionName === 'createRelated') {
        const helper = new _createRelated.default(this);
        helper.process(this.model, this.link);
        return;
      }
      const methodName = 'action' + Espo.Utils.upperCaseFirst(actionName);
      let p = this.getParentView();
      let view = null;
      while (p) {
        if (p[methodName]) {
          view = p;
          break;
        }
        p = p.getParentView();
      }
      p[methodName]({
        link: this.link,
        scope: this.scope
      });
    }

    // noinspection JSUnusedGlobalSymbols
    actionSelectRelated() {
      // noinspection JSUnresolvedReference
      const actionName = this.defs.selectAction || 'selectRelated';
      if (actionName === 'selectRelated') {
        const helper = new _selectRelated.default(this);
        helper.process(this.model, this.link);
        return;
      }
      const methodName = 'action' + Espo.Utils.upperCaseFirst(actionName);
      let p = this.getParentView();
      let view = null;
      while (p) {
        if (p[methodName]) {
          view = p;
          break;
        }
        p = p.getParentView();
      }
      p[methodName]({
        link: this.link,
        primaryFilterName: this.defs.selectPrimaryFilterName,
        boolFilterList: this.defs.selectBoolFilterList,
        massSelect: this.defs.massSelect
      });
    }

    // noinspection JSUnusedGlobalSymbols
    actionRemoveRelated(data) {
      const id = data.id;
      this.confirm({
        message: this.translate('removeRecordConfirmation', 'messages'),
        confirmText: this.translate('Remove')
      }, () => {
        const model = this.collection.get(id);
        Espo.Ui.notifyWait();
        model.destroy().then(() => {
          Espo.Ui.success(this.translate('Removed'));
          this.collection.fetch();
          this.model.trigger('after:unrelate');
          this.model.trigger('after:unrelate:' + this.link);
        });
      });
    }

    /**
     * @protected
     * @param {KeyboardEvent} e
     */
    handleShortcutKeyCtrlSlash(e) {
      if (!this.searchPanel) {
        return;
      }
      const $search = this.$el.find('input.text-filter').first();
      if (!$search.length) {
        return;
      }
      e.preventDefault();
      e.stopPropagation();
      $search.focus();
    }

    /**
     * @protected
     * @param {KeyboardEvent} e
     */
    handleShortcutKeyCtrlSpace(e) {
      if (this.createDisabled) {
        return;
      }
      if (this.buttonList.findIndex(item => item.name === 'createRelated' && !item.hidden && !item.disabled) === -1) {
        return;
      }
      e.preventDefault();
      e.stopPropagation();
      this.actionCreateRelated();
    }

    /**
     * @protected
     */
    handleShortcutKeyCtrlComma() {
      if (!this.getSearchView()) {
        return;
      }
      this.getSearchView().selectPreviousPreset();
    }

    /**
     * @protected
     */
    handleShortcutKeyCtrlPeriod() {
      if (!this.getSearchView()) {
        return;
      }
      this.getSearchView().selectNextPreset();
    }

    /**
     * @protected
     * @param {KeyboardEvent} e
     */
    handleShortcutKeyControlArrowLeft(e) {
      if (_utils.default.isKeyEventInTextInput(e)) {
        return;
      }
      this.getRecordView().trigger('request-page', 'previous');
    }

    /**
     * @protected
     * @param {KeyboardEvent} e
     */
    handleShortcutKeyControlArrowRight(e) {
      if (_utils.default.isKeyEventInTextInput(e)) {
        return;
      }
      this.getRecordView().trigger('request-page', 'next');
    }
  }
  var _default = _exports.default = RelatedListModalView;
});

define("views/modals/mass-update", ["exports", "views/modal", "helpers/mass-action", "ui/select"], function (_exports, _modal, _massAction, _select) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  _massAction = _interopRequireDefault(_massAction);
  _select = _interopRequireDefault(_select);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class MassUpdateModalView extends _modal.default {
    template = 'modals/mass-update';
    cssName = 'mass-update';
    className = 'dialog dialog-record';
    layoutName = 'massUpdate';
    ACTION_UPDATE = 'update';

    /**
     * @type {string[]}
     */
    fieldList;
    data() {
      return {
        scope: this.scope,
        fieldList: this.fieldList,
        entityType: this.entityType
      };
    }
    setup() {
      this.addActionHandler('addField', (e, target) => this.addField(target.dataset.name));
      this.addActionHandler('reset', () => this.reset());
      this.buttonList = [{
        name: 'update',
        label: 'Update',
        style: 'danger',
        disabled: true,
        onClick: () => this.actionUpdate()
      }, {
        name: 'cancel',
        label: 'Cancel'
      }];
      this.entityType = this.options.entityType || this.options.scope;
      this.scope = this.options.scope || this.entityType;
      this.ids = this.options.ids;
      this.where = this.options.where;
      this.searchParams = this.options.searchParams;
      this.byWhere = this.options.byWhere;
      this.hasActionMap = {};
      const totalCount = this.options.totalCount;
      this.helper = new _massAction.default(this);
      this.idle = this.byWhere && this.helper.checkIsIdle(totalCount);
      this.headerText = this.translate('Mass Update') + ' · ' + this.translate(this.scope, 'scopeNamesPlural');
      this.wait(this.load());

      /** @type {string[]} */
      this.addedFieldList = [];
    }

    /**
     * @private
     */
    async load() {
      this.model = await this.getModelFactory().create(this.entityType);
      const forbiddenList = this.getAcl().getScopeForbiddenFieldList(this.entityType, 'edit') || [];
      return new Promise(resolve => {
        this.getHelper().layoutManager.get(this.entityType, this.layoutName, layout => {
          layout = layout || [];
          this.fieldList = [];
          layout.forEach(field => {
            if (forbiddenList.includes(field) || this.getMetadata().get(`entityDefs.${this.entityType}.fields.${field}.disabled`)) {
              return;
            }
            if (this.model.hasField(field)) {
              this.fieldList.push(field);
            }
          });
          resolve();
        });
      });
    }

    /**
     * @private
     * @param {string} name
     */
    addField(name) {
      this.$el.find('[data-action="reset"]').removeClass('hidden');
      this.$el.find(`ul.filter-list li[data-name="${name}"]`).addClass('hidden');
      if (this.$el.find('ul.filter-list li:not(.hidden)').length === 0) {
        this.$el.find('button.select-field').addClass('disabled').attr('disabled', 'disabled');
      }
      this.addedFieldList.push(name);
      const label = this.getHelper().escapeString(this.translate(name, 'fields', this.entityType));
      const $cell = $('<div>').addClass('cell form-group').attr('data-name', name).append($('<label>').addClass('control-label').text(label)).append($('<div>').addClass('field').attr('data-name', name));
      const $row = $('<div>').addClass('item grid-auto-fill-md').attr('data-name', name).append($cell);
      this.$el.find('.fields-container').append($row);
      const type = this.model.getFieldType(name);
      const viewName = this.model.getFieldParam(name, 'view') || this.getFieldManager().getViewName(type);
      const actionList = this.getMetadata().get(['entityDefs', this.entityType, name, 'massUpdateActionList']) || this.getMetadata().get(['fields', type, 'massUpdateActionList']);
      const hasActionDropdown = actionList !== null;
      this.hasActionMap[name] = hasActionDropdown;
      this.disableButton('update');
      this.createView(name, viewName, {
        model: this.model,
        selector: '.field[data-name="' + name + '"]',
        defs: {
          name: name
        },
        mode: 'edit'
      }, view => {
        this.enableButton('update');
        view.render();
      });
      if (hasActionDropdown) {
        const $select = $('<select>').addClass('item-action form-control').attr('data-name', name);
        actionList.forEach(action => {
          const label = this.translate(Espo.Utils.upperCaseFirst(action));
          $select.append($('<option>').text(label).val(action));
        });
        const $cellAction = $('<div>').addClass('cell call-action form-group').attr('data-name', name).append($('<label>').addClass('control-label hidden-xs').html('&nbsp;')).append($('<div>').addClass('field').attr('data-name', name).append($select));
        $row.append($cellAction);
        _select.default.init($select.get(0));
      }
    }

    /**
     * @param {string} field
     * @return {module:views/fields/base}
     */
    getFieldView(field) {
      return this.getView(field);
    }

    /**
     * @private
     * @return {Promise<void>}
     */
    async actionUpdate() {
      if (this.byWhere) {
        await this.confirm(this.translate('confirmMassUpdate', 'messages'));
      }
      this.disableButton('update');
      const attributes = {};
      const actions = {};
      this.addedFieldList.forEach(field => {
        const action = this.fetchAction(field);
        const itemAttributes = this.getFieldView(field).fetch();
        const itemActualAttributes = {};
        this.getFieldManager().getEntityTypeFieldActualAttributeList(this.entityType, field).forEach(attribute => {
          actions[attribute] = action;
          itemActualAttributes[attribute] = itemAttributes[attribute];
        });
        Object.assign(attributes, itemActualAttributes);
      });
      this.model.set(attributes);
      let notValid = false;
      this.addedFieldList.forEach(field => {
        const view = this.getFieldView(field);
        notValid = view.validate() || notValid;
      });
      if (notValid) {
        Espo.Ui.error(this.translate('Not valid'));
        this.enableButton('update');
        return;
      }
      Espo.Ui.notify(this.translate('saving', 'messages'));
      let result;
      try {
        result = await Espo.Ajax.postRequest('MassAction', {
          action: 'update',
          entityType: this.entityType,
          params: {
            ids: this.ids || null,
            where: !this.ids || this.ids.length === 0 ? this.options.where : null,
            searchParams: !this.ids || this.ids.length === 0 ? this.options.searchParams : null
          },
          data: {
            values: attributes,
            actions: actions
          },
          idle: this.idle
        });
      } catch (e) {
        this.enableButton('update');
        return;
      }
      if (result.id) {
        const view = await this.helper.process(result.id, 'update');
        this.listenToOnce(view, 'close', () => this.close());
        this.listenToOnce(view, 'success', result => {
          this.trigger('after:update', {
            count: result.count,
            idle: true
          });
        });
        return;
      }
      this.trigger('after:update', {
        count: result.count
      });
    }

    /**
     * @private
     * @param {string} name
     * @return {string}
     */
    fetchAction(name) {
      if (!this.hasActionMap[name]) {
        return this.ACTION_UPDATE;
      }
      const $dropdown = this.$el.find(`select.item-action[data-name="${name}"]`);
      return $dropdown.val() || this.ACTION_UPDATE;
    }

    /**
     * @private
     */
    reset() {
      this.addedFieldList.forEach(field => {
        this.clearView(field);
        this.$el.find(`.item[data-name="${field}"]`).remove();
      });
      this.addedFieldList = [];
      this.hasActionMap = {};
      this.model.clear();
      this.$el.find('[data-action="reset"]').addClass('hidden');
      this.$el.find('button.select-field').removeClass('disabled').removeAttr('disabled');
      this.$el.find('ul.filter-list').find('li').removeClass('hidden');
      this.disableButton('update');
    }
  }
  var _default = _exports.default = MassUpdateModalView;
});

define("views/modals/mass-convert-currency", ["exports", "views/modal", "model", "helpers/mass-action"], function (_exports, _modal, _model, _massAction) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  _model = _interopRequireDefault(_model);
  _massAction = _interopRequireDefault(_massAction);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class MassConvertCurrencyModalView extends _modal.default {
    template = 'modals/mass-convert-currency';
    className = 'dialog dialog-record';
    buttonList = [{
      name: 'cancel',
      label: 'Cancel'
    }];
    data() {
      return {};
    }
    setup() {
      this.$header = $('<span>').append($('<span>').text(this.translate(this.options.entityType, 'scopeNamesPlural')), ' <span class="chevron-right"></span> ', $('<span>').text(this.translate('convertCurrency', 'massActions')));
      this.addButton({
        name: 'convert',
        text: this.translate('Update'),
        style: 'danger'
      }, true);
      const model = this.model = new _model.default();
      model.set('currency', this.getConfig().get('defaultCurrency'));
      model.set('baseCurrency', this.getConfig().get('baseCurrency'));
      model.set('currencyRates', this.getConfig().get('currencyRates'));
      model.set('currencyList', this.getConfig().get('currencyList'));
      this.createView('currency', 'views/fields/enum', {
        model: model,
        params: {
          options: this.getConfig().get('currencyList')
        },
        name: 'currency',
        selector: '.field[data-name="currency"]',
        mode: 'edit',
        labelText: this.translate('Convert to')
      });
      this.createView('baseCurrency', 'views/fields/enum', {
        model: model,
        params: {
          options: this.getConfig().get('currencyList')
        },
        name: 'baseCurrency',
        selector: '.field[data-name="baseCurrency"]',
        mode: 'detail',
        labelText: this.translate('baseCurrency', 'fields', 'Settings'),
        readOnly: true
      });
      this.createView('currencyRates', 'views/currency/fields/currency-rates', {
        model: model,
        name: 'currencyRates',
        selector: '.field[data-name="currencyRates"]',
        mode: 'edit',
        labelText: this.translate('currencyRates', 'fields', 'Settings')
      });
    }

    /**
     * @param {string} field
     * @return {module:views/fields/base}
     */
    getFieldView(field) {
      return this.getView(field);
    }

    // noinspection JSUnusedGlobalSymbols
    actionConvert() {
      this.disableButton('convert');
      this.getFieldView('currency').fetchToModel();
      this.getFieldView('currencyRates').fetchToModel();
      const currency = this.model.get('currency');
      const currencyRates = this.model.get('currencyRates');
      const hasWhere = !this.options.ids || this.options.ids.length === 0;
      const helper = new _massAction.default(this);
      const idle = hasWhere && helper.checkIsIdle(this.options.totalCount);
      Espo.Ajax.postRequest('MassAction', {
        entityType: this.options.entityType,
        action: 'convertCurrency',
        params: {
          ids: this.options.ids || null,
          where: hasWhere ? this.options.where : null,
          searchParams: hasWhere ? this.options.searchParams : null
        },
        data: {
          fieldList: this.options.fieldList || null,
          currency: currency,
          targetCurrency: currency,
          rates: currencyRates
        },
        idle: idle
      }).then(result => {
        if (result.id) {
          helper.process(result.id, 'convertCurrency').then(view => {
            this.listenToOnce(view, 'close', () => this.close());
            this.listenToOnce(view, 'success', result => {
              this.trigger('after:update', {
                count: result.count,
                idle: true
              });
            });
          });
          return;
        }
        this.trigger('after:update', {
          count: result.count
        });
        this.close();
      }).catch(() => {
        this.enableButton('convert');
      });
    }
  }
  var _default = _exports.default = MassConvertCurrencyModalView;
});

define("views/modals/detail", ["exports", "views/modal", "helpers/action-item-setup", "backbone", "helpers/record-modal", "utils", "underscore"], function (_exports, _modal, _actionItemSetup, _backbone, _recordModal, _utils, _underscore) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  _actionItemSetup = _interopRequireDefault(_actionItemSetup);
  _backbone = _interopRequireDefault(_backbone);
  _recordModal = _interopRequireDefault(_recordModal);
  _utils = _interopRequireDefault(_utils);
  _underscore = _interopRequireDefault(_underscore);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/modals/detail */

  /**
   * A quick view modal.
   */
  class DetailModalView extends _modal.default {
    template = 'modals/detail';
    cssName = 'detail-modal';
    className = 'dialog dialog-record';
    editDisabled = false;
    fullFormDisabled = false;
    detailView = null;
    removeDisabled = true;
    backdrop = true;
    fitHeight = true;
    sideDisabled = false;
    bottomDisabled = false;
    fixedHeaderHeight = true;
    flexibleHeaderFontSize = true;
    duplicateAction = false;

    /**
     * @private
     * @type {string}
     */
    nameAttribute;
    shortcutKeys = {
      /** @this DetailModalView */
      'Control+Space': function (e) {
        if (this.editDisabled) {
          return;
        }
        if (_utils.default.isKeyEventInTextInput(e)) {
          return;
        }
        if (this.buttonList.findIndex(item => item.name === 'edit') === -1) {
          return;
        }
        e.stopPropagation();
        e.preventDefault();
        this.actionEdit().then(view => {
          view.$el.find('.form-control:not([disabled])').first().focus();
        });
      },
      /** @this DetailModalView */
      'Control+Backslash': function (e) {
        this.getRecordView().handleShortcutKeyControlBackslash(e);
      },
      /** @this DetailModalView */
      'Control+ArrowLeft': function (e) {
        this.handleShortcutKeyControlArrowLeft(e);
      },
      /** @this DetailModalView */
      'Control+ArrowRight': function (e) {
        this.handleShortcutKeyControlArrowRight(e);
      }
    };

    /**
     * @typedef {Record} module:views/modals/detail~options
     *
     * @property {string} entityType An entity type.
     * @property {string} [id] An ID.
     * @property {string} [layoutName] A layout name.
     * @property {import('view-record-helper')} [recordHelper] A record helper.
     * @property {boolean} [editDisabled] Disable edit.
     * @property {boolean} [removeDisabled] Disable remove.
     * @property {boolean} [fullFormDisabled] Disable full-form.
     * @property {boolean} [quickEditDisabled] Disable quick edit.
     * @property {string} [rootUrl] A root URL.
     * @property {string} [fullFormUrl] A full-form URL. As of v9.0.
     */

    /**
     * @param {module:views/modals/detail~options} options
     */
    constructor(options) {
      super(options);
    }
    setup() {
      this.scope = this.scope || this.options.scope || this.options.entityType;
      this.entityType = this.options.entityType || this.scope;
      this.id = this.options.id;
      this.buttonList = [];
      if ('editDisabled' in this.options) {
        this.editDisabled = this.options.editDisabled;
      }
      if (this.options.removeDisabled !== undefined) {
        this.removeDisabled = this.options.removeDisabled;
      }
      this.editDisabled = this.getMetadata().get(['clientDefs', this.entityType, 'editDisabled']) || this.editDisabled;
      this.removeDisabled = this.getMetadata().get(['clientDefs', this.entityType, 'removeDisabled']) || this.removeDisabled;
      this.nameAttribute = this.getMetadata().get(`clientDefs.${this.entityType}.nameAttribute`) || 'name';
      this.fullFormDisabled = this.options.fullFormDisabled || this.fullFormDisabled;
      this.layoutName = this.options.layoutName || this.layoutName;
      this.setupRecordButtons();
      if (this.model) {
        this.controlRecordButtonsVisibility();
      }
      if (!this.fullFormDisabled) {
        this.buttonList.push({
          name: 'fullForm',
          label: 'Full Form'
        });
      }
      this.buttonList.push({
        name: 'cancel',
        label: 'Close',
        title: 'Esc'
      });
      if (this.model && this.model.collection && !this.navigateButtonsDisabled) {
        this.buttonList.push({
          name: 'previous',
          html: '<span class="fas fa-chevron-left"></span>',
          title: this.translate('Previous Entry'),
          position: 'right',
          className: 'btn-icon margin-left',
          style: 'text',
          disabled: true
        });
        this.buttonList.push({
          name: 'next',
          html: '<span class="fas fa-chevron-right"></span>',
          title: this.translate('Next Entry'),
          position: 'right',
          className: 'btn-icon',
          style: 'text',
          disabled: true
        });
        this.indexOfRecord = this.model.collection.indexOf(this.model);
      } else {
        this.navigateButtonsDisabled = true;
      }
      this.waitForView('record');
      this.sourceModel = this.model;
      this.getModelFactory().create(this.entityType).then(async model => {
        if (!this.sourceModel) {
          this.model = model;
          this.model.id = this.id;
          this.setupAfterModelCreated();
          this.listenTo(this.model, 'sync', () => {
            this.controlRecordButtonsVisibility();
            this.trigger('model-sync');
          });
          this.listenToOnce(this.model, 'sync', () => {
            this.setupActionItems();
            this.createRecordView();
          });
          await this.setupLate();
          await this.model.fetch();
          return;
        }
        this.cloneSourceModel();
        this.setupAfterModelCreated();
        this.listenTo(this.model, 'change', () => {
          this.sourceModel.set(this.model.getClonedAttributes());
        });
        this.listenTo(this.model, 'sync', () => {
          this.controlRecordButtonsVisibility();
          this.trigger('model-sync');
        });
        this.once('after:render', () => {
          this.model.fetch();
        });
        this.setupActionItems();
        this.createRecordView();
      });
      this.listenToOnce(this.getRouter(), 'routed', () => {
        this.remove();
      });
      if (this.duplicateAction && this.getAcl().checkScope(this.entityType, 'create')) {
        this.addDropdownItem({
          name: 'duplicate',
          label: 'Duplicate',
          groupIndex: 0,
          iconClass: 'far fa-copy'
        });
      }
    }

    /**
     * @private
     */
    cloneSourceModel() {
      this.model = this.sourceModel.clone();
      const sourceCollection = this.sourceModel.collection;
      if (!sourceCollection) {
        return;
      }
      this.model.collection = sourceCollection.clone();
      this.listenTo(this.model.collection, 'update-source', () => sourceCollection.fetch());
    }

    /**
     * Additional setup with the model ready.
     *
     * @protected
     * @since 9.3.0
     */
    async setupLate() {}

    /** @private */
    setupActionItems() {
      const actionItemSetup = new _actionItemSetup.default();
      actionItemSetup.setup({
        view: this,
        type: 'modalDetailActionList',
        waitFunc: promise => this.wait(promise),
        addFunc: item => this.addDropdownItem(item),
        showFunc: name => this.showActionItem(name),
        hideFunc: name => this.hideActionItem(name),
        listenToViewModelSync: true
      });
    }

    /**
     * @protected
     */
    setupAfterModelCreated() {}

    /**
     * @protected
     */
    setupRecordButtons() {
      if (!this.removeDisabled) {
        this.addRemoveButton();
      }
      if (!this.editDisabled) {
        this.addEditButton();
      }
    }

    /**
     * @protected
     */
    controlRecordButtonsVisibility() {
      if (this.getAcl().check(this.model, 'edit')) {
        this.showButton('edit');
      } else {
        this.hideButton('edit');
      }
      if (this.getAcl().check(this.model, 'delete')) {
        this.showActionItem('remove');
      } else {
        this.hideActionItem('remove');
      }
    }
    addEditButton() {
      this.addButton({
        name: 'edit',
        label: 'Edit',
        title: 'Ctrl+Space'
      }, true);
    }

    // noinspection JSUnusedGlobalSymbols
    removeEditButton() {
      this.removeButton('edit');
    }
    addRemoveButton() {
      this.addDropdownItem({
        name: 'remove',
        label: 'Remove',
        groupIndex: 0,
        iconClass: 'fas fa-times'
      });
    }

    // noinspection JSUnusedGlobalSymbols
    removeRemoveButton() {
      this.removeButton('remove');
    }

    /**
     * @internal Used. Do not remove.
     */
    getScope() {
      return this.scope;
    }
    createRecordView(callback) {
      const model = this.model;
      const scope = this.getScope();
      this.headerHtml = '';
      this.headerHtml += $('<span>').text(this.getLanguage().translate(scope, 'scopeNames')).get(0).outerHTML;
      if (model.attributes[this.nameAttribute]) {
        this.headerHtml += ' ' + $('<span>').addClass('chevron-right').get(0).outerHTML;
        this.headerHtml += ' ' + $('<span>').text(model.attributes[this.nameAttribute]).get(0).outerHTML;
      }
      if (!this.fullFormDisabled) {
        const url = this.options.fullFormUrl || `#${scope}/view/${this.id}`;
        this.headerHtml = $('<a>').attr('href', url).addClass('action font-size-flexible').attr('title', this.translate('Full Form')).attr('data-action', 'fullForm').append(this.headerHtml).get(0).outerHTML;
      }
      this.headerHtml = this.getHelper().getScopeColorIconHtml(this.entityType) + this.headerHtml;
      if (!this.editDisabled) {
        const editAccess = this.getAcl().check(model, 'edit', true);
        if (editAccess) {
          this.showButton('edit');
        } else {
          this.hideButton('edit');
          if (editAccess === null) {
            this.listenToOnce(model, 'sync', () => {
              if (this.getAcl().check(model, 'edit')) {
                this.showButton('edit');
              }
            });
          }
        }
      }
      if (!this.removeDisabled) {
        const removeAccess = this.getAcl().check(model, 'delete', true);
        if (removeAccess) {
          this.showActionItem('remove');
        } else {
          this.hideActionItem('remove');
          if (removeAccess === null) {
            this.listenToOnce(model, 'sync', () => {
              if (this.getAcl().check(model, 'delete')) {
                this.showActionItem('remove');
              }
            });
          }
        }
      }
      const viewName = this.detailView || this.getMetadata().get(['clientDefs', model.entityType, 'recordViews', 'detailSmall']) || this.getMetadata().get(['clientDefs', model.entityType, 'recordViews', 'detailQuick']) || 'views/record/detail-small';
      const options = {
        model: model,
        fullSelector: this.containerSelector + ' .record-container',
        type: 'detailSmall',
        layoutName: this.layoutName || 'detailSmall',
        buttonsDisabled: true,
        inlineEditDisabled: true,
        sideDisabled: this.sideDisabled,
        bottomDisabled: this.bottomDisabled,
        recordHelper: this.options.recordHelper,
        exit: function () {}
      };
      this.createView('record', viewName, options, callback);
    }

    /**
     * @return {import('views/record/detail').default}
     */
    getRecordView() {
      return /** @type {import('views/record/detail').default} */this.getView('record');
    }
    afterRender() {
      super.afterRender();
      setTimeout(() => {
        this.$el.children().first().scrollTop(0);
      }, 50);
      if (!this.navigateButtonsDisabled) {
        this.controlNavigationButtons();
      }
    }
    controlNavigationButtons() {
      const recordView = this.getRecordView();
      if (!recordView) {
        return;
      }
      const collection = this.model.collection;
      const indexOfRecord = this.indexOfRecord;
      let previousButtonEnabled = false;
      let nextButtonEnabled = false;
      if (indexOfRecord > 0 || collection.offset > 0) {
        previousButtonEnabled = true;
      }
      if (indexOfRecord < collection.total - 1 - collection.offset) {
        nextButtonEnabled = true;
      } else if (collection.total === -1) {
        nextButtonEnabled = true;
      } else if (collection.total === -2 && indexOfRecord < collection.length - 1 - collection.offset) {
        nextButtonEnabled = true;
      }
      if (previousButtonEnabled) {
        this.enableButton('previous');
      } else {
        this.disableButton('previous');
      }
      if (nextButtonEnabled) {
        this.enableButton('next');
      } else {
        this.disableButton('next');
      }
    }
    switchToModelByIndex(indexOfRecord) {
      if (!this.model.collection) {
        return;
      }
      const previousModel = this.model;
      const previousCollection = this.model.collection;
      this.sourceModel = this.model.collection.at(indexOfRecord);
      if (!this.sourceModel) {
        throw new Error("Model is not found in collection by index.");
      }
      this.indexOfRecord = indexOfRecord;
      this.id = this.sourceModel.id;
      this.scope = this.sourceModel.entityType;
      this.cloneSourceModel();
      this.stopListening(previousModel, 'change');
      this.stopListening(previousModel, 'sync');
      if (previousCollection) {
        this.stopListening(previousCollection, 'update-source');
      }
      this.listenTo(this.model, 'change', () => {
        this.sourceModel.set(this.model.getClonedAttributes());
      });
      this.listenTo(this.model, 'sync', () => {
        this.controlRecordButtonsVisibility();
        this.trigger('model-sync');
      });
      this.createRecordView(() => {
        this.reRender().then(() => {
          this.model.fetch();
        });
      });
      this.controlNavigationButtons();
      this.trigger('switch-model', this.model, previousModel);
    }
    actionPrevious() {
      if (!this.model.collection) {
        return;
      }
      const collection = this.model.collection;
      if (this.indexOfRecord <= 0 && !collection.offset) {
        return;
      }
      if (this.indexOfRecord === 0 && collection.offset > 0 && collection.maxSize) {
        collection.offset = Math.max(0, collection.offset - collection.maxSize);
        collection.fetch().then(() => {
          // Restore as it can be removed by fetch.
          this.model.collection = collection;
          const indexOfRecord = collection.length - 1;
          if (indexOfRecord < 0) {
            return;
          }
          this.switchToModelByIndex(indexOfRecord);
        });
        return;
      }
      const indexOfRecord = this.indexOfRecord - 1;
      this.switchToModelByIndex(indexOfRecord);
    }
    actionNext() {
      if (!this.model.collection) {
        return;
      }
      const collection = this.model.collection;
      if (!(this.indexOfRecord < collection.total - 1 - collection.offset) && this.model.collection.total >= 0) {
        return;
      }
      if (collection.total === -2 && this.indexOfRecord >= collection.length - 1 - collection.offset) {
        return;
      }
      const indexOfRecord = this.indexOfRecord + 1;
      if (indexOfRecord <= collection.length - 1 - collection.offset) {
        this.switchToModelByIndex(indexOfRecord);
        return;
      }
      collection.fetch({
        more: true,
        remove: false
      }).then(() => {
        this.switchToModelByIndex(indexOfRecord);
      });
    }

    /**
     * @return {Promise<import('views/modals/edit').default>}
     */
    async actionEdit() {
      if (this.options.quickEditDisabled) {
        const options = {
          id: this.id,
          model: this.model,
          returnUrl: this.getRouter().getCurrentUrl()
        };
        if (this.options.rootUrl) {
          options.rootUrl = this.options.rootUrl;
        }
        this.getRouter().navigate(`#${this.scope}/edit/${this.id}`, {
          trigger: false
        });
        this.getRouter().dispatch(this.scope, 'edit', options);
        return Promise.reject();
      }
      const helper = new _recordModal.default();

      // noinspection UnnecessaryLocalVariableJS
      const modalView = await helper.showEdit(this, {
        entityType: this.entityType,
        id: this.id,
        fullFormDisabled: this.fullFormDisabled,
        collapseDisabled: true,
        beforeSave: (model, o) => {
          this.trigger('before:save', model, o);
        },
        afterSave: (model, o) => {
          this.model.set(model.getClonedAttributes());
          this.trigger('after:save', model, o);
          this.controlRecordButtonsVisibility();
          this.trigger('model-sync');

          // Triggers stream panel update.
          this.model.trigger('sync', this.model, null, {});
        },
        beforeRender: view => {
          this.listenToOnce(view, 'remove', () => this.dialog.show());
          this.listenToOnce(view, 'leave', () => this.remove());
        }
      });

      // Not to be hidden as it interferes with the collapsible modal.
      //this.dialog.hide();

      return modalView;
    }

    // noinspection JSUnusedGlobalSymbols
    actionRemove() {
      const model = this.getRecordView().model;
      this.confirm(this.translate('removeRecordConfirmation', 'messages'), () => {
        const $buttons = $(this.dialog.getElement()).find('.modal-footer button');
        $buttons.addClass('disabled').attr('disabled', 'disabled');
        this.trigger('before:delete', model);
        model.destroy().then(() => {
          this.trigger('after:delete', model);
          this.trigger('after:destroy', model); // For bc.

          this.dialog.close();
          Espo.Ui.success(this.translate('Removed'));
        }).catch(() => {
          $buttons.removeClass('disabled').removeAttr('disabled');
        });
      });
    }

    // noinspection JSUnusedGlobalSymbols
    actionFullForm() {
      let url;
      const router = this.getRouter();
      const scope = this.getScope();
      url = '#' + scope + '/view/' + this.id;
      let attributes = this.getRecordView().fetch();
      const model = this.getRecordView().model;
      attributes = _underscore.default.extend(attributes, model.getClonedAttributes());
      const options = {
        attributes: attributes,
        returnUrl: _backbone.default.history.fragment,
        model: this.sourceModel || this.model,
        id: this.id
      };
      if (this.options.rootUrl) {
        options.rootUrl = this.options.rootUrl;
      }
      setTimeout(() => {
        router.dispatch(scope, 'view', options);
        router.navigate(url, {
          trigger: false
        });
      }, 10);
      this.trigger('leave');
      this.dialog.close();
    }

    // noinspection JSUnusedGlobalSymbols
    actionDuplicate() {
      Espo.Ui.notifyWait();
      Espo.Ajax.postRequest(this.scope + '/action/getDuplicateAttributes', {
        id: this.model.id
      }).then(attributes => {
        Espo.Ui.notify(false);
        const url = '#' + this.scope + '/create';
        this.getRouter().dispatch(this.scope, 'create', {
          attributes: attributes,
          returnUrl: this.getRouter().getCurrentUrl(),
          options: {
            duplicateSourceId: this.model.id,
            returnAfterCreate: true
          }
        });
        this.getRouter().navigate(url, {
          trigger: false
        });
      });
    }

    /**
     * @protected
     * @param {KeyboardEvent} e
     */
    handleShortcutKeyControlArrowLeft(e) {
      if (!this.model.collection) {
        return;
      }
      if (this.buttonList.findIndex(item => item.name === 'previous' && !item.disabled) === -1) {
        return;
      }
      if (_utils.default.isKeyEventInTextInput(e)) {
        return;
      }
      e.preventDefault();
      e.stopPropagation();
      this.actionPrevious();
    }

    /**
     * @protected
     * @param {KeyboardEvent} e
     */
    handleShortcutKeyControlArrowRight(e) {
      if (!this.model.collection) {
        return;
      }
      if (this.buttonList.findIndex(item => item.name === 'next' && !item.disabled) === -1) {
        return;
      }
      if (_utils.default.isKeyEventInTextInput(e)) {
        return;
      }
      e.preventDefault();
      e.stopPropagation();
      this.actionNext();
    }
  }
  var _default = _exports.default = DetailModalView;
});

define("views/main/header-buttons", ["exports", "view", "bullbone", "components/controls", "language", "di"], function (_exports, _view, _bullbone, _controls, _language, _di) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  _language = _interopRequireDefault(_language);
  var _staticBlock;
  let _init_language, _init_extra_language;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  class HeaderButtonsView extends _view.default {
    constructor() {
      super(...arguments);
      _init_extra_language(this);
    }
    useVirtualDom = true;
    language = _init_language(this);
    content() {
      const data = this.options.dataProvider();
      const buttons = data.buttons.filter(it => !it.hidden);
      const actions = data.actions.filter(it => !it.hidden);
      const dropdown = data.dropdown.filter(it => it === false || !it.hidden).filter((it, i, list) => {
        if (it === false && (i === 0 || i === list.length - 1)) {
          return false;
        }
        if (it === false && list[i - 1] === false) {
          return false;
        }
        return true;
      });
      const elements = [];
      let lastButtonIsText = false;
      buttons.forEach(it => {
        const className = ('btn-xs-wide main-header-manu-action ' + (it.className ?? '')).trim();
        if (!it.hidden) {
          lastButtonIsText = it.style === 'text';
        }
        elements.push(new _controls.ButtonComponent({
          scope: this.options.scope,
          name: it.name ?? null,
          action: it.action ?? it.name,
          link: it.link,
          text: it.text,
          label: it.label,
          labelTranslation: it.labelTranslation,
          style: it.style,
          hidden: it.hidden,
          disabled: it.disabled,
          data: it.data,
          title: it.title,
          iconClass: it.iconClass,
          iconHtml: it.iconHtml,
          html: it.html,
          className: className
        }).node());
      });
      if (actions.length) {
        const button = (0, _bullbone.h)('button', {
          key: '_actions-dropdown-button',
          attrs: {
            type: 'button'
          },
          props: {
            className: 'btn btn-default dropdown-toggle'
          },
          dataset: {
            toggle: 'dropdown'
          }
        }, [this.language.translate('Actions'), ' ', (0, _bullbone.h)('span', {
          props: {
            className: 'caret'
          }
        })]);
        const dropdownItems = [];
        actions.forEach(it => {
          dropdownItems.push(new _controls.DropdownItemComponent({
            name: it.name ?? null,
            action: it.action ?? it.name,
            scope: this.options.scope,
            link: it.link,
            label: it.label,
            labelTranslation: it.labelTranslation,
            title: it.title,
            text: it.text,
            className: 'main-header-manu-action',
            hidden: it.hidden,
            disabled: it.disabled,
            iconClass: it.iconClass
          }).node());
        });
        const ul = (0, _bullbone.h)('ul', {
          props: {
            className: 'dropdown-menu pull-right'
          }
        }, dropdownItems);
        elements.push((0, _bullbone.h)('div', {
          props: {
            className: 'btn-group',
            role: 'group'
          }
        }, [button, ul]));
      }
      if (dropdown.length) {
        const button = (0, _bullbone.h)('button', {
          key: '_menu-dropdown-button',
          attrs: {
            type: 'button'
          },
          props: {
            className: 'btn btn-default dropdown-toggle' + (lastButtonIsText ? ' radius-left' : '')
          },
          dataset: {
            toggle: 'dropdown'
          }
        }, (0, _bullbone.h)('span', {
          props: {
            className: 'fas fa-ellipsis-h'
          }
        }));
        const dropdownItems = [];
        dropdown.forEach(it => {
          if (it === false) {
            dropdownItems.push((0, _bullbone.h)('li', {
              class: {
                'divider': true
              }
            }));
            return;
          }
          dropdownItems.push(new _controls.DropdownItemComponent({
            name: it.name ?? null,
            action: it.action ?? it.name,
            scope: this.options.scope,
            link: it.link,
            label: it.label,
            labelTranslation: it.labelTranslation,
            title: it.title,
            text: it.text,
            className: 'main-header-manu-action',
            hidden: it.hidden,
            disabled: it.disabled,
            iconClass: it.iconClass
          }).node());
        });
        const ul = (0, _bullbone.h)('ul', {
          props: {
            className: 'dropdown-menu pull-right'
          }
        }, dropdownItems);
        elements.push((0, _bullbone.h)('div', {
          props: {
            className: 'btn-group',
            role: 'group'
          }
        }, [button, ul]));
      }
      return (0, _bullbone.h)('div', {
        props: {
          className: 'header-buttons btn-group pull-right'
        },
        class: {
          'hidden': data.hidden
        }
      }, elements);
    }
    static #_ = _staticBlock = () => [_init_language, _init_extra_language] = _applyDecs(this, [], [[(0, _di.inject)(_language.default), 0, "language"]], 0, void 0, _view.default).e;
  }
  _exports.default = HeaderButtonsView;
  _staticBlock();
});

define("views/lead-capture/form", ["exports", "view", "views/record/edit", "model"], function (_exports, _view, _edit, _model) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  _edit = _interopRequireDefault(_edit);
  _model = _interopRequireDefault(_model);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class LeadCaptureFormView extends _view.default {
    // language=Handlebars
    templateContent = `
        <div class="block-center-5 margin-top">
            {{#if isPosted}}
                <div class="panel paned-default">
                    <div class="panel-body">
                        <div class="complex-text">{{complexText successText}}</div>
                    </div>
                </div>
            {{else}}
                <div class="record">{{{record}}}</div>
                <div class="button-container center-align">
                    <button
                        class="btn btn-primary btn-x-wide"
                        data-action="submit"
                    >{{translate 'Submit'}}</button>
                </div>
            {{/if}}
        </div>
    `;

    /**
     * @private
     * @type {boolean}
     */
    isPosted = false;

    /**
     * @private
     * @type {boolean}
     */
    isPosting = false;

    /**
     * @private
     * @type {HTMLElement}
     */
    submitButtonElement;

    /**
     * @param {{
     *     formData: {
     *         requestUrl: string,
     *         detailLayout: module:views/record/detail~panelDefs[],
     *         fieldDefs: Record,
     *         metadata: Record,
     *         language: Record.<string, Record>,
     *         successText: string,
     *         text: string|null,
     *         config: Record,
     *         appParams: Record,
     *         captchaKey: boolean,
     *         isDark: boolean,
     *         title: string|null,
     *     },
     * }} options
     */
    constructor(options) {
      super();
      this.formData = options.formData;
    }
    data() {
      return {
        isPosted: this.isPosted,
        successText: this.formData.successText
      };
    }
    setup() {
      this.getMetadata().setData(this.formData.metadata);
      this.getConfig().setMultiple(this.formData.config);
      this.getHelper().appParams.setAll(this.formData.appParams);
      this.getHelper().fieldManager.defs = this.getMetadata().get('fields');
      this.getDateTime().setSettingsAndPreferences(this.getConfig(), this.getPreferences());
      if (this.formData.captchaKey) {
        // noinspection JSUnresolvedReference
        grecaptcha.ready(() => {
          // noinspection SpellCheckingInspection
          /** @type {HTMLElement|null} */
          const badge = document.querySelector('.grecaptcha-badge');
          if (badge) {
            badge.style.zIndex = '4';
          }
        });
      }
      for (const it in this.formData.language) {
        this.getLanguage().setScopeData(it, this.formData.language[it]);
      }
      this.model = new _model.default({}, {
        defs: {
          fields: this.formData.fieldDefs
        },
        entityType: 'Lead'
      });
      this.model.url = this.formData.requestUrl;
      const detailLayout = [...(this.formData.text ? [{
        noteText: this.formData.text,
        noteStyle: 'default',
        rows: []
      }] : []), ...this.formData.detailLayout];
      this.recordView = new CustomEditView({
        model: this.model,
        detailLayout: detailLayout,
        sideView: null,
        bottomView: null,
        isWide: true,
        shortcutKeysEnabled: true,
        buttonsDisabled: true
      });
      this.assignView('record', this.recordView, '.record');
      this.whenReady().then(() => this.initAutocomplete());
      this.listenTo(this.recordView, 'save', () => this.actionCreate());
      this.addActionHandler('submit', () => this.actionCreate());
    }
    afterRender() {
      const subContainer = this.element.querySelector('.detail-button-container .sub-container');
      if (subContainer) {
        subContainer.classList.add('sub-container-center-5');
      }
      this.submitButtonElement = this.element.querySelector('button[data-action="submit"]');
    }
    async actionCreate() {
      if (this.isPosting) {
        return;
      }
      if (this.recordView.validate()) {
        Espo.Ui.error(this.translate('Not valid'));
        return;
      }
      this.isPosting = true;
      this.recordView.disableActionItems();
      this.submitButtonElement.classList.add('disabled');
      this.submitButtonElement.setAttribute('disabled', 'disabled');
      Espo.Ui.notifyWait();
      const token = await this.processCaptcha();
      const headers = token ? {
        'X-Captcha-Token': token
      } : undefined;

      /** @type {{redirectUrl: string|null}} */
      let result;
      try {
        result = await Espo.Ajax.postRequest(this.model.url, this.model.attributes, {
          headers: headers
        });
      } catch (e) {
        this.recordView.enableActionItems();
        this.submitButtonElement.classList.remove('disabled');
        this.submitButtonElement.removeAttribute('disabled');
        this.isPosting = false;
        return;
      }
      Espo.Ui.notify();
      this.isPosted = true;
      this.isPosting = false;
      this.recordView.remove();
      await this.reRender();
      if (result.redirectUrl) {
        document.location.href = result.redirectUrl;
      }
    }

    /**
     * @return {Promise<string|null>}
     */
    async processCaptcha() {
      if (!this.formData.captchaKey) {
        return null;
      }
      return new Promise(resolve => {
        // noinspection JSUnresolvedReference
        grecaptcha.ready(async () => {
          // noinspection JSUnresolvedReference
          const token = await grecaptcha.execute(this.formData.captchaKey, {
            action: 'leadCaptureSubmit'
          });
          resolve(token);
        });
      });
    }

    /**
     * @private
     */
    initAutocomplete() {
      const emailAddressView = this.recordView.getFieldView('emailAddress');
      if (emailAddressView) {
        this.listenTo(emailAddressView, 'after:render', () => {
          /** @type {HTMLInputElement} */
          const element = emailAddressView.element.querySelector('input');
          if (element) {
            element.autocomplete = 'email';
          }
        });
      }
      const phoneNumberView = this.recordView.getFieldView('phoneNumber');
      if (phoneNumberView) {
        this.listenTo(phoneNumberView, 'after:render', () => {
          /** @type {HTMLInputElement} */
          const element = phoneNumberView.element.querySelector('input');
          if (element) {
            element.autocomplete = 'tel';
          }
        });
      }
      const nameView = this.recordView.getFieldView('name');
      this.listenTo(nameView, 'after:render', () => {
        /** @type {HTMLInputElement} */
        const elementFirst = nameView.element.querySelector('input[data-name="firstName"]');
        if (elementFirst) {
          elementFirst.autocomplete = 'given-name';
        }

        /** @type {HTMLInputElement} */
        const elementLast = nameView.element.querySelector('input[data-name="lastName"]');
        if (elementLast) {
          elementLast.autocomplete = 'family-name';
        }
      });
      const firstName = this.recordView.getFieldView('firstName');
      if (firstName) {
        this.listenTo(firstName, 'after:render', () => {
          /** @type {HTMLInputElement} */
          const element = firstName.element.querySelector('input');
          if (element) {
            element.autocomplete = 'given-name';
          }
        });
      }
      const lastName = this.recordView.getFieldView('lastName');
      if (lastName) {
        this.listenTo(lastName, 'after:render', () => {
          /** @type {HTMLInputElement} */
          const element = lastName.element.querySelector('input');
          if (element) {
            element.autocomplete = 'family-name';
          }
        });
      }
    }
  }
  _exports.default = LeadCaptureFormView;
  class CustomEditView extends _edit.default {
    handleShortcutKeyCtrlEnter(e) {
      this.trigger('save');
    }
  }
});

define("views/fields/user-with-avatar", ["exports", "views/fields/user"], function (_exports, _user) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _user = _interopRequireDefault(_user);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class UserWithAvatarFieldView extends _user.default {
    listTemplate = 'fields/user-with-avatar/list';
    detailTemplate = 'fields/user-with-avatar/detail';
    data() {
      const data = super.data();
      if (this.mode === this.MODE_DETAIL || this.mode === this.MODE_LIST) {
        data.avatar = this.getAvatarHtml();
        data.isOwn = this.model.get(this.idName) === this.getUser().id;
      }
      return data;
    }
    getAvatarHtml() {
      const size = this.mode === this.MODE_DETAIL ? 18 : 16;
      return this.getHelper().getAvatarHtml(this.model.get(this.idName), 'small', size, 'avatar-link');
    }
    afterRender() {
      super.afterRender();
      if (this.isEditMode()) {
        this.controlEditModeAvatar();
      }
    }
    setup() {
      super.setup();
      this.addHandler('keydown', `input[data-name="${this.nameName}"]`, (/** KeyboardEvent */e, target) => {
        if (e.code === 'Enter') {
          return;
        }
        target.classList.add('being-typed');
      });
      this.addHandler('change', `input[data-name="${this.nameName}"]`, (e, target) => {
        setTimeout(() => target.classList.remove('being-typed'), 200);
      });
      this.addHandler('blur', `input[data-name="${this.nameName}"]`, (e, target) => {
        target.classList.remove('being-typed');
      });
      this.on('change', () => {
        if (!this.isEditMode()) {
          return;
        }
        const img = this.element.querySelector('img.avatar');
        if (img) {
          img.parentNode.removeChild(img);
        }
        this.controlEditModeAvatar();
      });
    }

    /**
     * @private
     */
    controlEditModeAvatar() {
      const nameElement = this.element.querySelector(`input[data-name="${this.nameName}"]`);
      nameElement.classList.remove('being-typed');
      const userId = this.model.attributes[this.idName];
      if (!userId) {
        return;
      }
      const avatarHtml = this.getHelper().getAvatarHtml(userId, 'small', 18, 'avatar-link');
      if (!avatarHtml) {
        return;
      }
      const img = new DOMParser().parseFromString(avatarHtml, 'text/html').body.childNodes[0];
      if (!(img instanceof HTMLImageElement)) {
        return;
      }
      img.classList.add('avatar-in-input');
      img.draggable = false;
      const input = this.element.querySelector('.input-group > input');
      if (!input) {
        return;
      }
      input.after(img);
    }
  }
  var _default = _exports.default = UserWithAvatarFieldView;
});

define("views/fields/url", ["exports", "views/fields/varchar"], function (_exports, _varchar) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _varchar = _interopRequireDefault(_varchar);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/fields/url */

  /**
   * Parameters.
   */

  /**
   * A URL field.
   *
   */
  class UrlFieldView extends _varchar.default {
    type = 'url';
    listTemplate = 'fields/url/list';
    detailTemplate = 'fields/url/detail';
    defaultProtocol = 'https:';
    validations = ['required', 'valid', 'maxLength'];
    noSpellCheck = true;
    optionalProtocol = true;
    DEFAULT_MAX_LENGTH = 255;
    data() {
      const data = super.data();
      data.url = this.getUrl();
      return data;
    }
    setup() {
      super.setup();
      if (this.params.protocolRequired) {
        this.optionalProtocol = false;
      }
    }
    afterRender() {
      super.afterRender();
      if (this.isEditMode()) {
        var _this$$element;
        (_this$$element = this.$element) === null || _this$$element === void 0 || _this$$element.on('change', () => {
          var _this$$element2, _this$$element3;
          const value = ((_this$$element2 = this.$element) === null || _this$$element2 === void 0 ? void 0 : _this$$element2.val()) || '';
          const parsedValue = this.parse(value);
          if (parsedValue === value) {
            return;
          }
          const decoded = parsedValue ? this.decodeURI(parsedValue) : '';
          (_this$$element3 = this.$element) === null || _this$$element3 === void 0 || _this$$element3.val(decoded);
        });
      }
    }
    getValueForDisplay() {
      const value = this.model.get(this.name);
      return value ? this.decodeURI(value) : null;
    }
    decodeURI(value) {
      try {
        return decodeURI(value);
      } catch (e) {
        console.warn(`Malformed URI ${value}.`);
        return value;
      }
    }
    parse(value) {
      value = value.trim();
      if (this.params.strip && !this.params.protocolRequired) {
        value = this.strip(value);
      }
      try {
        if (value === decodeURI(value)) {
          value = encodeURI(value);
        }
      } catch (e) {
        console.warn(`Malformed URI ${value}.`);
        return value;
      }
      return value;
    }
    strip(value) {
      if (value.indexOf('//') !== -1) {
        value = value.substring(value.indexOf('//') + 2);
      }
      value = value.replace(/\/+$/, '');
      return value;
    }
    getUrl() {
      let url = this.model.get(this.name);
      if (url && url !== '') {
        if (url.indexOf('//') === -1) {
          url = this.defaultProtocol + '//' + url;
        }
        return url;
      }
      return url;
    }
    validateValid() {
      const value = this.model.get(this.name);
      if (!value) {
        return false;
      }
      if (this.isValid(value)) {
        return false;
      }
      const msg = this.translate('fieldInvalid', 'messages').replace('{field}', this.getLabelText());
      this.showValidationMessage(msg);
      return true;
    }
    isValid(value) {
      if (!this.optionalProtocol) {
        try {
          new URL(value);
          return true;
        } catch (e) {
          return false;
        }
      }
      const pattern = this.getMetadata().get(['app', 'regExpPatterns', 'uriOptionalProtocol', 'pattern']);
      const regExp = new RegExp('^' + pattern + '$');
      if (regExp.test(value)) {
        return true;
      }
      return false;
    }

    // noinspection JSUnusedGlobalSymbols
    validateMaxLength() {
      const maxLength = this.params.maxLength || this.DEFAULT_MAX_LENGTH;
      const value = this.model.get(this.name);
      if (!value || !value.length) {
        return false;
      }
      if (value.length <= maxLength) {
        return false;
      }
      const msg = this.translate('fieldUrlExceedsMaxLength', 'messages').replace('{maxLength}', maxLength.toString()).replace('{field}', this.getLabelText());
      this.showValidationMessage(msg);
      return true;
    }
    fetch() {
      const data = super.fetch();
      const value = data[this.name];
      if (!value) {
        return data;
      }
      data[this.name] = this.parse(value);
      return data;
    }
  }
  var _default = _exports.default = UrlFieldView;
});

define("views/fields/url-multiple", ["exports", "views/fields/array"], function (_exports, _array) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _array = _interopRequireDefault(_array);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * A Url-Multiple field.
   */
  class UrlMultipleFieldView extends _array.default {
    type = 'urlMultiple';
    maxItemLength = 255;
    displayAsList = true;
    defaultProtocol = 'https:';
    setup() {
      super.setup();
      this.noEmptyString = true;
      this.params.pattern = '$uriOptionalProtocol';
    }
    addValueFromUi(value) {
      value = value.trim();
      if (this.params.strip) {
        value = this.strip(value);
      }
      try {
        if (value === decodeURI(value)) {
          value = encodeURI(value);
        }
      } catch (e) {
        console.warn(`Malformed URI ${value}.`);
      }
      super.addValueFromUi(value);
    }
    decodeURI(value) {
      try {
        return decodeURI(value);
      } catch (e) {
        console.warn(`Malformed URI ${value}.`);
        return value;
      }
    }
    strip(value) {
      if (value.indexOf('//') !== -1) {
        value = value.substring(value.indexOf('//') + 2);
      }
      value = value.replace(/\/+$/, '');
      return value;
    }
    prepareUrl(url) {
      if (url.indexOf('//') === -1) {
        url = this.defaultProtocol + '//' + url;
      }
      return url;
    }
    getValueForDisplay() {
      const $list = this.selected.map(value => {
        return $('<a>').attr('href', this.prepareUrl(value)).attr('target', '_blank').text(this.decodeURI(value));
      });
      return $list.map($item => {
        var _$$addClass$append$ge;
        return (_$$addClass$append$ge = $('<div>').addClass('multi-enum-item-container').append($item).get(0)) === null || _$$addClass$append$ge === void 0 ? void 0 : _$$addClass$append$ge.outerHTML;
      }).join('');
    }
    getItemHtml(value) {
      var _$item$get;
      const html = super.getItemHtml(value);
      const $item = $(html);
      $item.find('span.text').html($('<a>').attr('href', this.prepareUrl(value)).css('user-drag', 'none').attr('target', '_blank').text(this.decodeURI(value)));
      return (_$item$get = $item.get(0)) === null || _$item$get === void 0 ? void 0 : _$item$get.outerHTML;
    }
  }
  var _default = _exports.default = UrlMultipleFieldView;
});

define("views/fields/range-float", ["exports", "views/fields/range-int", "views/fields/float"], function (_exports, _rangeInt, _float) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _rangeInt = _interopRequireDefault(_rangeInt);
  _float = _interopRequireDefault(_float);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class RangeFloatFieldView extends _rangeInt.default {
    type = 'rangeFloat';
    validations = ['required', 'float', 'range', 'order'];
    decimalPlacesRawValue = 10;
    setupAutoNumericOptions() {
      this.autoNumericOptions = {
        digitGroupSeparator: this.thousandSeparator || '',
        decimalCharacter: this.decimalMark,
        modifyValueOnWheel: false,
        selectOnFocus: false,
        decimalPlaces: this.decimalPlacesRawValue,
        decimalPlacesRawValue: this.decimalPlacesRawValue,
        allowDecimalPadding: false,
        showWarnings: false,
        formulaMode: true
      };
    }

    // noinspection JSUnusedGlobalSymbols
    validateFloat() {
      const validate = name => {
        if (isNaN(this.model.get(name))) {
          const msg = this.translate('fieldShouldBeFloat', 'messages').replace('{field}', this.getLabelText());
          this.showValidationMessage(msg, '[data-name="' + name + '"]');
          return true;
        }
      };
      let result = false;
      result = validate(this.fromField) || result;
      result = validate(this.toField) || result;
      return result;
    }
    parse(value) {
      return _float.default.prototype.parse.call(this, value);
    }
    formatNumber(value) {
      return _float.default.prototype.formatNumberDetail.call(this, value);
    }
  }
  var _default = _exports.default = RangeFloatFieldView;
});

define("views/fields/phone", ["exports", "views/fields/varchar", "ui/select", "intl-tel-input", "intl-tel-input-utils", "intl-tel-input-globals"], function (_exports, _varchar, _select, _intlTelInput, _intlTelInputUtils, _intlTelInputGlobals) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _varchar = _interopRequireDefault(_varchar);
  _select = _interopRequireDefault(_select);
  _intlTelInput = _interopRequireDefault(_intlTelInput);
  _intlTelInputUtils = _interopRequireDefault(_intlTelInputUtils);
  _intlTelInputGlobals = _interopRequireDefault(_intlTelInputGlobals);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  // @ts-ignore

  // @ts-ignore

  /**
   * Parameters.
   */

  /**
   * Options.
   */

  /**
   * Phone number field.
   */
  class PhoneFieldView extends _varchar.default {
    type = 'phone';
    editTemplate = 'fields/phone/edit';
    detailTemplate = 'fields/phone/detail';
    listTemplate = 'fields/phone/list';
    validations = ['required', 'phoneData'];
    maxExtensionLength = 6;
    maxCount = null;
    validateRequired() {
      if (!this.isRequired()) {
        return false;
      }
      if (!this.model.get(this.name)) {
        const msg = this.translate('fieldIsRequired', 'messages').replace('{field}', this.getLabelText());
        this.showValidationMessage(msg, 'div.phone-number-block:nth-child(1) input.phone-number');
        return true;
      }
      return false;
    }

    // noinspection JSUnusedGlobalSymbols
    validatePhoneData() {
      const data = this.model.get(this.dataFieldName);
      if (!data || !data.length) {
        return false;
      }
      const pattern = '^' + this.getMetadata().get('app.regExpPatterns.phoneNumberLoose.pattern') + '$';
      this.validationRegExp = new RegExp(pattern);
      const numberList = [];
      let notValid = false;
      data.forEach((row, i) => {
        const number = row.phoneNumber;
        if (this.itemValidate(row, i)) {
          notValid = true;
        }
        const numberClean = String(number).replace(/[\s+]/g, '');
        if (numberList.includes(numberClean)) {
          const msg = this.translate('fieldValueDuplicate', 'messages').replace('{field}', this.getLabelText());
          this.showValidationMessage(msg, 'div.phone-number-block:nth-child(' + (i + 1).toString() + ') input.phone-number');
          notValid = true;
          return;
        }
        numberList.push(numberClean);
      });
      return notValid;
    }
    validateMaxCount() {
      const maxCount = this.maxCount;
      if (!maxCount) {
        return false;
      }
      const items = this.model.attributes[this.dataFieldName] || [];
      if (items.length <= maxCount) {
        return false;
      }
      const msg = this.translate('fieldExceedsMaxCount', 'messages').replace('{maxCount}', maxCount.toString());
      this.showValidationMessage(msg, 'div.phone-number-block:last-child input.phone-number');
      return true;
    }

    /**
     * @param item A data item.
     * @param i An index.
     * @internal Called in an extension. Do not change the signature.
     */
    itemValidate(item, i) {
      const number = item.number;
      const n = (i + 1).toString();
      const selector = `div.phone-number-block:nth-child(${n}) input.phone-number`;
      let notValid = false;
      if (!this.validationRegExp.test(number)) {
        notValid = true;
        const msg = this.translate('fieldPhoneInvalidCharacters', 'messages').replace('{field}', this.getLabelText());
        this.showValidationMessage(msg, selector);
      }
      if (!this.useInternational) {
        return notValid;
      }
      const element = this.$el.find(selector).get(0);
      if (!element) {
        return notValid;
      }
      const intlObj = this.intlTelInputMap.get(element);
      const isPossible = intlObj && intlObj.isPossibleNumber();
      if (intlObj && !isPossible) {
        notValid = true;
        const code = intlObj.getValidationError();
        const key = ['fieldPhoneInvalid', 'fieldPhoneInvalidCode', 'fieldPhoneTooShort', 'fieldPhoneTooLong'][code || 0] || 'fieldPhoneInvalid';
        const msg = this.translate(key, 'messages').replace('{field}', this.getLabelText());
        this.showValidationMessage(msg, selector);
      }
      if (intlObj && isPossible && this.allowExtensions && intlObj.getExtension() && intlObj.getExtension().length > this.maxExtensionLength) {
        const msg = this.translate('fieldPhoneExtensionTooLong', 'messages').replace('{maxLength}', this.maxExtensionLength.toString()).replace('{field}', this.getLabelText());
        this.showValidationMessage(msg, selector);
        notValid = true;
      }
      return notValid;
    }
    data() {
      const number = this.model.get(this.name);
      let phoneNumberData;
      if (this.mode === this.MODE_EDIT) {
        phoneNumberData = Espo.Utils.cloneDeep(this.model.get(this.dataFieldName));
        if (this.model.isNew() || !this.model.get(this.name)) {
          if (!phoneNumberData || !phoneNumberData.length) {
            let optOut;
            if (this.model.isNew()) {
              optOut = this.phoneNumberOptedOutByDefault && this.model.entityType !== 'User';
            } else {
              optOut = this.model.get(this.isOptedOutFieldName);
            }
            phoneNumberData = [{
              phoneNumber: this.model.get(this.name) || '',
              primary: true,
              type: this.defaultType,
              optOut: optOut,
              invalid: false
            }];
          }
        }
      } else {
        phoneNumberData = this.model.get(this.dataFieldName) || false;
      }
      if (phoneNumberData) {
        phoneNumberData = Espo.Utils.cloneDeep(phoneNumberData);
        phoneNumberData.forEach(item => {
          const number = item.phoneNumber || '';
          item.erased = number.indexOf(this.erasedPlaceholder) === 0;
          if (!item.erased) {
            item.valueForLink = this.formatForLink(number);
            if (this.isReadMode()) {
              item.phoneNumber = this.formatNumber(item.phoneNumber);
            }
          }
          item.lineThrough = item.optOut || item.invalid || this.model.get('doNotCall');
        });
      }
      if ((!phoneNumberData || phoneNumberData.length === 0) && this.model.get(this.name)) {
        const o = {
          phoneNumber: this.formatNumber(number),
          primary: true,
          valueForLink: this.formatForLink(number)
        };
        if (this.isReadMode()) {
          o.phoneNumber = this.formatNumber(o.phoneNumber);
        }
        if (this.mode === 'edit' && this.model.isNew()) {
          o.type = this.defaultType;
        }
        phoneNumberData = [o];
      }
      const data = {
        ...super.data(),
        phoneNumberData: phoneNumberData,
        doNotCall: this.model.get('doNotCall'),
        lineThrough: this.model.get('doNotCall') || this.model.get(this.isOptedOutFieldName)
      };
      if (this.isReadMode()) {
        data.isOptedOut = this.model.get(this.isOptedOutFieldName);
        data.isInvalid = this.model.get(this.isInvalidFieldName);
        if (this.model.get(this.name)) {
          data.isErased = this.model.get(this.name).indexOf(this.erasedPlaceholder) === 0;
          if (!data.isErased) {
            data.valueForLink = this.formatForLink(this.model.get(this.name));
          }
        }
        data.valueIsSet = this.model.has(this.name);
        data.value = this.formatNumber(data.value);
      }
      data.itemMaxLength = this.itemMaxLength;
      data.onlyPrimary = this.params.onlyPrimary;

      // noinspection JSValidateTypes
      return data;
    }
    formatForLink(number) {
      if (this.allowExtensions && this.useInternational) {
        if (number.includes(' ext. ')) {
          number = number.replace(' ext. ', ',');
        }
        return number;
      }
      return number.replace(/ /g, '');
    }
    focusOnLast(cursorAtEnd) {
      const $item = this.$el.find('input.form-control').last();
      $item.focus();
      if (cursorAtEnd && $item[0]) {
        // noinspection JSUnresolvedReference
        $item[0].setSelectionRange($item[0].value.length, $item[0].value.length);
      }
    }
    removePhoneNumber($block) {
      if ($block.parent().children().length === 1) {
        $block.find('input.phone-number').val('');
      } else {
        this.removePhoneNumberBlock($block);
      }
      this.trigger('change');
    }
    formatNumber(value) {
      if (!value || value === '' || !this.useInternational) {
        return value;
      }
      return _intlTelInputUtils.default.formatNumber(value, null, _intlTelInputUtils.default.numberFormat.INTERNATIONAL);
    }
    addPhoneNumber() {
      const data = Espo.Utils.cloneDeep(this.fetchPhoneNumberData());
      const o = {
        phoneNumber: '',
        primary: !data.length,
        type: this.defaultType,
        optOut: this.phoneNumberOptedOutByDefault,
        invalid: false
      };
      data.push(o);
      this.model.set(this.dataFieldName, data, {
        silent: true
      });
      this.reRender().then(() => this.focusOnLast());
    }
    afterRender() {
      super.afterRender();
      this.manageButtonsVisibility();
      this.manageAddButton();
      if (this.mode === this.MODE_EDIT) {
        this.$el.find('select').toArray().forEach(selectElement => {
          _select.default.init(selectElement);
        });
      }
    }
    afterRenderEdit() {
      super.afterRenderEdit();
      if (this.useInternational) {
        const inputElements = this.element.querySelectorAll('input.phone-number');
        inputElements.forEach(inputElement => {
          // noinspection JSUnusedGlobalSymbols
          const obj = (0, _intlTelInput.default)(inputElement, {
            nationalMode: false,
            autoInsertDialCode: false,
            separateDialCode: true,
            showFlags: false,
            preferredCountries: this.preferredCountryList,
            localizedCountries: this._codeNames,
            customPlaceholder: placeholder => {
              return placeholder.replace(/[0-9]/g, '0');
            }
          });
          this.intlTelInputMap.set(inputElement, obj);
          inputElement.addEventListener('blur', () => {
            if (!obj.isPossibleNumber()) {
              return;
            }
            let number = obj.getNumber();
            const ext = obj.getExtension();
            if (this.allowExtensions && ext) {
              number += ' ext. ' + ext;
            }
            obj.setNumber(number);
          });
        });
      }
    }
    removePhoneNumberBlock($block) {
      let changePrimary = false;
      if ($block.find('button[data-property-type="primary"]').hasClass('active')) {
        changePrimary = true;
      }
      $block.remove();
      if (changePrimary) {
        this.$el.find('button[data-property-type="primary"]').first().addClass('active').children().removeClass('text-muted');
      }
      this.manageButtonsVisibility();
      this.manageAddButton();
    }
    manageAddButton() {
      const $input = this.$el.find('input.phone-number');
      let c = 0;
      $input.each((_i, input) => {
        if (input.value !== '') {
          c++;
        }
      });
      if (c === $input.length) {
        this.$el.find('[data-action="addPhoneNumber"]').removeClass('disabled').removeAttr('disabled');
        return;
      }
      this.$el.find('[data-action="addPhoneNumber"]').addClass('disabled').attr('disabled', 'disabled');
    }
    manageButtonsVisibility() {
      const $primary = this.$el.find('button[data-property-type="primary"]');
      const $remove = this.$el.find('button[data-action="removePhoneNumber"]');
      const $container = this.$el.find('.phone-number-block-container');
      if ($primary.length > 1) {
        $primary.removeClass('hidden');
        $remove.removeClass('hidden');
        $container.addClass('many');
        return;
      }
      $container.removeClass('many');
      $primary.addClass('hidden');
      $remove.addClass('hidden');
    }
    setup() {
      this.addActionHandler('switchPhoneProperty', (_e, target) => this.switchPhoneProperty(target));
      this.addActionHandler('removePhoneNumber', (_e, target) => this.removePhoneNumberHandler(target));
      this.addHandler('change', 'input.phone-number', (_e, target) => this.inputChangeHandler(target));
      this.addHandler('keypress', 'input.phone-number', () => this.manageAddButton());
      this.addHandler('paste', 'input.phone-number', () => setTimeout(() => this.manageAddButton(), 10));
      this.addActionHandler('addPhoneNumber', () => this.addPhoneNumber());
      this.addHandler('keydown', 'input.phone-number', (e, target) => {
        this.inputKeydownHandler(e, target);
      });
      this.dataFieldName = this.name + 'Data';
      this.defaultType = this.defaultType || this.getMetadata().get(`entityDefs.${this.model.entityType}.fields.${this.name}.defaultType`);
      this.isOptedOutFieldName = this.name + 'IsOptedOut';
      this.isInvalidFieldName = this.name + 'IsInvalid';
      this.phoneNumberOptedOutByDefault = this.getConfig().get('phoneNumberIsOptedOutByDefault');
      this.useInternational = this.getConfig().get('phoneNumberInternational') || false;
      this.allowExtensions = this.getConfig().get('phoneNumberExtensions') || false;
      this.preferredCountryList = this.getConfig().get('phoneNumberPreferredCountryList') || [];
      this.maxCount = this.getConfig().get('phoneNumberMaxCount');
      if (this.useInternational && !this.isListMode() && !this.isSearchMode()) {
        this._codeNames = _intlTelInputGlobals.default.getCountryData().reduce((map, item) => {
          map[item.iso2] = item.iso2.toUpperCase();
          return map;
        }, {});
      }
      if (this.model.has('doNotCall')) {
        this.listenTo(this.model, 'change:doNotCall', (_m, _v, o) => {
          if (this.mode !== 'detail' && this.mode !== 'list') {
            return;
          }
          if (!o.ui) {
            return;
          }
          this.reRender();
        });
      }
      this.erasedPlaceholder = 'ERASED:';
      this.itemMaxLength = this.getMetadata().get(['entityDefs', 'PhoneNumber', 'fields', 'name', 'maxLength']);
      this.intlTelInputMap = new Map();
      this.once('remove', () => {
        for (const obj of this.intlTelInputMap.values()) {
          obj.destroy();
        }
        this.intlTelInputMap.clear();
      });
      this.validations.push(() => this.validateMaxCount());
      this.isNumeric = this.getConfig().get('phoneNumberNumericSearch');
    }
    fetchPhoneNumberData() {
      const $list = this.$el.find('div.phone-number-block');
      if (!$list.length) {
        return [];
      }
      const data = [];
      $list.each((_i, itemElement) => {
        const row = {};
        const $d = $(itemElement);
        const inputElement = $d.find('input.phone-number').get(0);
        if (!inputElement) {
          return;
        }
        row.phoneNumber = inputElement.value.trim();
        if (this.intlTelInputMap.has(inputElement)) {
          row.phoneNumber = this.intlTelInputMap.get(inputElement).getNumber();
          const ext = this.intlTelInputMap.get(inputElement).getExtension() || null;
          if (this.allowExtensions && ext) {
            row.phoneNumber += ' ext. ' + ext;
          }
        }
        if (row.phoneNumber === '') {
          return;
        }
        row.primary = $d.find('button[data-property-type="primary"]').hasClass('active');
        row.type = $d.find('select[data-property-type="type"]').val();
        row.optOut = $d.find('button[data-property-type="optOut"]').hasClass('active');
        row.invalid = $d.find('button[data-property-type="invalid"]').hasClass('active');
        data.push(row);
      });
      return data;
    }
    fetch() {
      const data = {};
      const addressData = this.fetchPhoneNumberData();
      if (this.params.onlyPrimary) {
        if (addressData.length > 0) {
          data[this.name] = addressData[0].phoneNumber;
          data[this.dataFieldName] = [{
            phoneNumber: addressData[0].phoneNumber,
            primary: true
          }];
        } else {
          data[this.name] = null;
          data[this.dataFieldName] = null;
        }
        return data;
      }
      data[this.dataFieldName] = addressData;
      data[this.name] = null;
      data[this.isOptedOutFieldName] = false;
      data[this.isInvalidFieldName] = false;
      let primaryIndex = 0;
      addressData.forEach((item, i) => {
        if (item.primary) {
          primaryIndex = i;
          if (item.optOut) {
            data[this.isOptedOutFieldName] = true;
          }
          if (item.invalid) {
            data[this.isInvalidFieldName] = true;
          }
        }
      });
      if (addressData.length && primaryIndex > 0) {
        const t = addressData[0];
        addressData[0] = addressData[primaryIndex];
        addressData[primaryIndex] = t;
      }
      if (addressData.length) {
        data[this.name] = addressData[0].phoneNumber;
      } else {
        data[this.isOptedOutFieldName] = null;
        data[this.isInvalidFieldName] = null;
      }
      return data;
    }
    fetchSearch() {
      var _this$$element;
      const type = this.fetchSearchType() || 'startsWith';
      const name = this.isNumeric ? this.name + 'Numeric' : this.name;
      if (['isEmpty', 'isNotEmpty'].includes(type)) {
        if (type === 'isEmpty') {
          return {
            type: 'isNull',
            attribute: name,
            data: {
              type: type
            }
          };
        }
        return {
          type: 'isNotNull',
          attribute: name,
          data: {
            type: type
          }
        };
      }
      let value = (_this$$element = this.$element) === null || _this$$element === void 0 || (_this$$element = _this$$element.val()) === null || _this$$element === void 0 || (_this$$element = _this$$element.toString()) === null || _this$$element === void 0 ? void 0 : _this$$element.trim();
      const originalValue = value;
      if (this.isNumeric && value) {
        value = value.replace(/[^0-9]/g, '');
      }
      if (!value) {
        return null;
      }
      return {
        type: type,
        value: value,
        attribute: name,
        data: {
          type: type,
          value: originalValue
        }
      };
    }
    focusOnInlineEdit() {
      const input = this.element.querySelector('input.phone-number');
      if (!input) {
        return;
      }
      input.focus({
        preventScroll: true
      });
    }
    switchPhoneProperty(target) {
      const $target = $(target);
      const $block = $(target).closest('div.phone-number-block');
      const property = $target.data('property-type');
      const $input = $block.find('input.phone-number');
      if (property === 'primary') {
        if (!$target.hasClass('active')) {
          if ($input.val() !== '') {
            this.$el.find('button.phone-property[data-property-type="primary"]').removeClass('active').children().addClass('text-muted');
            $target.addClass('active').children().removeClass('text-muted');
          }
        }
        this.trigger('change');
        return;
      }
      let active = false;
      if ($target.hasClass('active')) {
        $target.removeClass('active').children().addClass('text-muted');
      } else {
        $target.addClass('active').children().removeClass('text-muted');
        active = true;
      }
      if (property === 'optOut') {
        active ? $input.addClass('text-strikethrough') : $input.removeClass('text-strikethrough');
      }
      if (property === 'invalid') {
        active ? $input.addClass('text-danger') : $input.removeClass('text-danger');
      }
      this.trigger('change');
    }
    removePhoneNumberHandler(target) {
      const $block = $(target).closest('div.phone-number-block');
      this.removePhoneNumber($block);
      this.trigger('change');
      const $last = this.$el.find('.phone-number').last();
      if ($last.length) {
        $last[0].focus({
          preventScroll: true
        });
      }
    }
    inputChangeHandler(target) {
      const input = target;
      const $block = $(input).closest('div.phone-number-block');
      if (this._itemJustRemoved) {
        return;
      }
      if (input.value === '' && $block.length) {
        this.removePhoneNumber($block);
      } else {
        this.trigger('change');
      }
      this.manageAddButton();
    }
    inputKeydownHandler(e, target) {
      const key = Espo.Utils.getKeyFromKeyEvent(e);
      const $target = $(target);
      if (key === 'Enter') {
        if (!this.$el.find('[data-action="addPhoneNumber"]').hasClass('disabled')) {
          this.addPhoneNumber();
          e.stopPropagation();
        }
        return;
      }
      if (key === 'Backspace' && $target.val() === '') {
        const $block = $target.closest('div.phone-number-block');
        this._itemJustRemoved = true;
        setTimeout(() => this._itemJustRemoved = false, 100);
        e.stopPropagation();
        this.removePhoneNumber($block);
        setTimeout(() => this.focusOnLast(true), 50);
      }
    }
  }
  var _default = _exports.default = PhoneFieldView;
});

define("views/fields/person-name", ["exports", "views/fields/varchar", "ui/select"], function (_exports, _varchar, _select) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _varchar = _interopRequireDefault(_varchar);
  _select = _interopRequireDefault(_select);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/fields/person-name */

  /**
   * Parameters.
   */

  /**
   * Options.
   */

  /**
   * A person name field.
   */
  class PersonNameFieldView extends _varchar.default {
    type = 'personName';
    detailTemplate = 'fields/person-name/detail';
    editTemplate = 'fields/person-name/edit';
    // noinspection JSUnusedGlobalSymbols
    editTemplateLastFirst = 'fields/person-name/edit-last-first';
    // noinspection JSUnusedGlobalSymbols
    editTemplateLastFirstMiddle = 'fields/person-name/edit-last-first-middle';
    // noinspection JSUnusedGlobalSymbols
    editTemplateFirstMiddleLast = 'fields/person-name/edit-first-middle-last';
    validations = ['required', 'pattern'];

    /**
     * @since 9.3.0
     */

    data() {
      const data = super.data();
      data.ucName = Espo.Utils.upperCaseFirst(this.name);
      data.salutationValue = this.model.get(this.salutationField);
      data.firstValue = this.model.get(this.firstField);
      data.lastValue = this.model.get(this.lastField);
      data.middleValue = this.model.get(this.middleField);
      data.salutationOptions = this.salutationOptions;
      data.salutationField = this.salutationField;
      if (this.isEditMode()) {
        data.firstMaxLength = this.model.getFieldParam(this.firstField, 'maxLength');
        data.lastMaxLength = this.model.getFieldParam(this.lastField, 'maxLength');
        data.middleMaxLength = this.model.getFieldParam(this.middleField, 'maxLength');
      }
      data.valueIsSet = this.model.has(this.firstField) || this.model.has(this.lastField);
      if (this.isDetailMode()) {
        data.isNotEmpty = !!data.firstValue || !!data.lastValue || !!data.salutationValue || !!data.middleValue;
      } else if (this.isListMode()) {
        data.isNotEmpty = !!data.firstValue || !!data.lastValue || !!data.middleValue;
      }
      if (data.isNotEmpty && this.isDetailMode() || this.isListMode()) {
        data.formattedValue = this.getFormattedValue();
      }
      return data;
    }
    setup() {
      super.setup();
      this.searchTypeList = this.searchTypeList.filter(it => !['anyOf', 'noneOf'].includes(it));
      const ucName = Espo.Utils.upperCaseFirst(this.name);
      this.salutationField = 'salutation' + ucName;
      this.firstField = 'first' + ucName;
      this.lastField = 'last' + ucName;
      this.middleField = 'middle' + ucName;
      this.salutationOptions = this.model.getFieldParam(this.salutationField, 'options');
    }
    afterRender() {
      super.afterRender();
      if (this.isEditMode()) {
        this.$salutation = this.$el.find('[data-name="' + this.salutationField + '"]');
        this.$first = this.$el.find('[data-name="' + this.firstField + '"]');
        this.$last = this.$el.find('[data-name="' + this.lastField + '"]');
        if (this.formatHasMiddle()) {
          this.$middle = this.$el.find('[data-name="' + this.middleField + '"]');
        }
        this.$salutation.on('change', () => {
          this.trigger('change');
        });
        this.$first.on('change', () => {
          this.trigger('change');
        });
        this.$last.on('change', () => {
          this.trigger('change');
        });
        _select.default.init(this.$salutation);
      }
    }
    getFormattedValue() {
      let salutation = this.model.get(this.salutationField);
      const first = this.model.get(this.firstField);
      const last = this.model.get(this.lastField);
      const middle = this.model.get(this.middleField);
      if (salutation) {
        salutation = this.getLanguage().translateOption(salutation, 'salutationName', this.model.entityType);
      }
      return this.formatName({
        salutation: salutation,
        first: first,
        middle: middle,
        last: last
      });
    }

    /**
     * @internal
     */
    _getTemplateName() {
      if (this.isEditMode()) {
        const prop = 'editTemplate' + Espo.Utils.upperCaseFirst(this.getFormat().toString());
        if (prop in this) {
          // @ts-ignore
          return this[prop];
        }
      }
      return super._getTemplateName();
    }
    getFormat() {
      this.format = this.format || this.getConfig().get('personNameFormat') || 'firstLast';
      return this.format;
    }
    formatHasMiddle() {
      const format = this.getFormat();
      return format === 'firstMiddleLast' || format === 'lastFirstMiddle';
    }
    validateRequired() {
      const isRequired = this.isRequired();
      const validate = name => {
        if (this.model.isRequired(name)) {
          if (!this.model.get(name)) {
            const msg = this.translate('fieldIsRequired', 'messages').replace('{field}', this.translate(name, 'fields', this.model.entityType));
            this.showValidationMessage(msg, '[data-name="' + name + '"]');
            return true;
          }
        }
      };
      if (isRequired) {
        if (!this.model.get(this.firstField) && !this.model.get(this.lastField)) {
          const msg = this.translate('fieldIsRequired', 'messages').replace('{field}', this.getLabelText());
          this.showValidationMessage(msg, '[data-name="' + this.lastField + '"]');
          return true;
        }
      }
      let result = false;
      result = validate(this.salutationField) || result;
      result = validate(this.firstField) || result;
      result = validate(this.lastField) || result;
      result = validate(this.middleField) || result;
      return result;
    }
    validatePattern() {
      let result = false;
      result = this.fieldValidatePattern(this.firstField) || result;
      result = this.fieldValidatePattern(this.lastField) || result;
      result = this.fieldValidatePattern(this.middleField) || result;
      return result;
    }
    hasRequiredMarker() {
      if (this.isRequired()) {
        return true;
      }
      return this.model.getFieldParam(this.salutationField, 'required') || this.model.getFieldParam(this.firstField, 'required') || this.model.getFieldParam(this.middleField, 'required') || this.model.getFieldParam(this.lastField, 'required');
    }
    fetch() {
      const data = {};
      data[this.salutationField] = this.$salutation.val() || null;
      data[this.firstField] = this.$first.val().trim() || null;
      data[this.lastField] = this.$last.val().trim() || null;
      if (this.formatHasMiddle()) {
        data[this.middleField] = this.$middle.val().trim() || null;
      }
      data[this.name] = this.formatName({
        first: data[this.firstField],
        last: data[this.lastField],
        middle: data[this.middleField]
      });
      return data;
    }
    fetchSearch() {
      if (this.fetchSearchType() === 'isNotEmpty') {
        return {
          type: 'isNotNull',
          attribute: this.name,
          value: null,
          data: {
            type: 'isNotEmpty'
          }
        };
      }
      return super.fetchSearch();
    }
    formatName(data) {
      let name;
      const format = this.getFormat();
      const arr = [];
      arr.push(data.salutation);
      if (format === 'firstLast') {
        arr.push(data.first);
        arr.push(data.last);
      } else if (format === 'lastFirst') {
        arr.push(data.last);
        arr.push(data.first);
      } else if (format === 'firstMiddleLast') {
        arr.push(data.first);
        arr.push(data.middle);
        arr.push(data.last);
      } else if (format === 'lastFirstMiddle') {
        arr.push(data.last);
        arr.push(data.first);
        arr.push(data.middle);
      } else {
        arr.push(data.first);
        arr.push(data.last);
      }
      name = arr.filter(item => !!item).join(' ').trim();
      if (name === '') {
        name = null;
      }
      return name;
    }
    focusOnInlineEdit() {
      const input = this.element.querySelector('input.form-control[type="text"]');
      if (!input) {
        return;
      }
      input.focus({
        preventScroll: true
      });
    }
  }
  var _default = _exports.default = PersonNameFieldView;
});

define("views/fields/password", ["exports", "views/fields/base"], function (_exports, _base) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class PasswordFieldView extends _base.default {
    type = 'password';
    detailTemplate = 'fields/password/detail';
    editTemplate = 'fields/password/edit';
    validations = ['required', 'confirm'];
    changePassword() {
      this.$el.find('[data-action="change"]').addClass('hidden');
      this.$element.removeClass('hidden');
      this.changing = true;
    }
    data() {
      return {
        isNew: this.model.isNew(),
        ...super.data()
      };
    }
    setup() {
      super.setup();
      this.addActionHandler('change', () => this.changePassword());
    }

    // noinspection JSUnusedGlobalSymbols
    validateConfirm() {
      if (!this.model.has(this.name + 'Confirm')) {
        return;
      }
      if (this.model.get(this.name) !== this.model.get(this.name + 'Confirm')) {
        const msg = this.translate('fieldBadPasswordConfirm', 'messages').replace('{field}', this.getLabelText());
        this.showValidationMessage(msg);
        return true;
      }
    }
    afterRender() {
      super.afterRender();
      this.changing = false;
      if (this.params.readyToChange) {
        this.changePassword();
      }
    }
    fetch() {
      if (!this.model.isNew() && !this.changing) {
        return {};
      }
      return super.fetch();
    }
  }
  var _default = _exports.default = PasswordFieldView;
});

define("views/fields/multi-enum", ["exports", "views/fields/array", "helpers/reg-exp-pattern", "ui/multi-select"], function (_exports, _array, _regExpPattern, _multiSelect) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _array = _interopRequireDefault(_array);
  _regExpPattern = _interopRequireDefault(_regExpPattern);
  _multiSelect = _interopRequireDefault(_multiSelect);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * A multi-enum field.
   */
  class MultiEnumFieldView extends _array.default {
    type = 'multiEnum';
    listTemplate = 'fields/array/list';
    detailTemplate = 'fields/array/detail';
    editTemplate = 'fields/multi-enum/edit';
    MAX_ITEM_LENGTH = 100;
    restoreOnBackspace = false;
    validationElementSelector = '.selectize-control';
    allowCustomOptions = false;
    data() {
      // noinspection JSValidateTypes
      return {
        ...super.data(),
        optionList: this.params.options || []
      };
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * @deprecated As of v8.3.0.
     * @todo Remove in v11.0.
     */
    getTranslatedOptions() {
      return (this.params.options ?? []).map(item => {
        if (this.translatedOptions !== null && item in this.translatedOptions) {
          return this.translatedOptions[item];
        }
        return item;
      });
    }
    translateValueToEditLabel(value) {
      let label = value;
      const options = this.params.options ?? [];
      if (options.includes(value)) {
        label = this.getLanguage().translateOption(value, this.name, this.entityType);
      }
      if (this.translatedOptions) {
        if (value in this.translatedOptions) {
          label = this.translatedOptions[value];
        }
      }
      if (label === '') {
        label = this.translate('None');
      }
      return label;
    }
    setupFieldEvents() {}
    afterRender() {
      if (this.isSearchMode()) {
        this.renderSearch();
        return;
      }
      if (this.isEditMode()) {
        var _this$$element, _this$$element2;
        this.$element = this.$el.find('[data-name="' + this.name + '"]');
        const items = [];
        const valueList = Espo.Utils.clone(this.selected);
        for (const i in valueList) {
          let value = valueList[i];
          const originalValue = value;
          if (value === '') {
            value = valueList[i] = '__emptystring__';
          }
          const options = this.params.options ?? [];
          if (!~options.indexOf(value)) {
            items.push({
              value: value,
              text: this.translateValueToEditLabel(originalValue)
            });
          }
        }
        (_this$$element = this.$element) === null || _this$$element === void 0 || _this$$element.val(valueList.join(this.itemDelimiter));
        (this.params.options ?? []).forEach(value => {
          const originalValue = value;
          if (value === '') {
            value = '__emptystring__';
          }
          items.push({
            value: value,
            text: this.translateValueToEditLabel(originalValue),
            style: this.styleMap[value] || undefined
          });
        });
        const multiSelectOptions = {
          items: items,
          delimiter: this.itemDelimiter,
          matchAnyWord: this.matchAnyWord,
          draggable: true,
          allowCustomOptions: this.allowCustomOptions,
          restoreOnBackspace: this.restoreOnBackspace,
          create: input => this.createCustomOptionCallback(input)
        };
        _multiSelect.default.init(this.$element, multiSelectOptions);
        (_this$$element2 = this.$element) === null || _this$$element2 === void 0 || _this$$element2.on('change', () => {
          this.trigger('change');
        });
      }
    }
    createCustomOptionCallback(input) {
      if (input.length > this.MAX_ITEM_LENGTH) {
        const message = this.translate('arrayItemMaxLength', 'messages').replace('{max}', this.MAX_ITEM_LENGTH.toString());
        this.showValidationMessage(message, '.selectize-control');
        return null;
      }
      if (this.params.pattern) {
        const helper = new _regExpPattern.default();
        const result = helper.validate(this.params.pattern, input, this.name, this.entityType);
        if (result) {
          this.showValidationMessage(result.message, '.selectize-control');
          return null;
        }
      }
      return {
        value: input,
        text: input
      };
    }
    focusOnInlineEdit() {
      _multiSelect.default.focus(this.$element);
    }
    fetch() {
      var _this$$element3;
      let list = (((_this$$element3 = this.$element) === null || _this$$element3 === void 0 ? void 0 : _this$$element3.val()) ?? '').split(this.itemDelimiter);
      if (list.length === 1 && list[0] === '') {
        list = [];
      }
      for (const i in list) {
        if (list[i] === '__emptystring__') {
          list[i] = '';
        }
      }
      const translatedOptions = this.translatedOptions;
      if (this.params.isSorted && translatedOptions) {
        list = list.sort((v1, v2) => {
          return (translatedOptions[v1] || v1).localeCompare(translatedOptions[v2] || v2);
        });
      }
      return {
        [this.name]: list
      };
    }
    validateRequired() {
      if (!this.isRequired()) {
        return false;
      }
      const value = this.model.get(this.name);
      if (!value || value.length === 0) {
        const msg = this.translate('fieldIsRequired', 'messages').replace('{field}', this.getLabelText());
        this.showValidationMessage(msg, '.selectize-control');
        return true;
      }
      return false;
    }
    validateMaxCount() {
      if (!this.params.maxCount) {
        return false;
      }
      const itemList = this.model.get(this.name) || [];
      if (itemList.length > this.params.maxCount) {
        const msg = this.translate('fieldExceedsMaxCount', 'messages').replace('{field}', this.getLabelText()).replace('{maxCount}', this.params.maxCount.toString());
        this.showValidationMessage(msg, '.selectize-control');
        return true;
      }
      return false;
    }
  }
  var _default = _exports.default = MultiEnumFieldView;
});

define("views/fields/link-parent", ["exports", "views/fields/base", "helpers/record-modal", "ui/select", "ui/autocomplete", "ajax", "ui", "utils"], function (_exports, _base, _recordModal, _select, _autocomplete, _ajax, _ui, _utils) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  _recordModal = _interopRequireDefault(_recordModal);
  _select = _interopRequireDefault(_select);
  _autocomplete = _interopRequireDefault(_autocomplete);
  _ajax = _interopRequireDefault(_ajax);
  _ui = _interopRequireDefault(_ui);
  _utils = _interopRequireDefault(_utils);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * Parameters.
   */

  /**
   * Options.
   */

  /**
   * A link-parent field (belongs-to-parent relation).
   */
  class LinkParentFieldView extends _base.default {
    type = 'linkParent';
    listTemplate = 'fields/link-parent/list';
    detailTemplate = 'fields/link-parent/detail';
    editTemplate = 'fields/link-parent/edit';
    searchTemplate = 'fields/link-parent/search';
    listLinkTemplate = 'fields/link-parent/list-link';

    /**
     * A name attribute name.
     */

    /**
     * An ID attribute name.
     */

    /**
     * A type attribute name.
     */

    /**
     * A current foreign entity type.
     */
    foreignScope = null;

    /**
     * A foreign entity type list.
     */

    /**
     * Autocomplete disabled.
     */
    autocompleteDisabled = false;

    /**
     * A select-record view.
     */
    selectRecordsView = 'views/modals/select-records';

    /**
     * Create disabled.
     */
    createDisabled = false;

    /**
     * A search type list.
     */
    searchTypeList = ['is', 'isEmpty', 'isNotEmpty'];

    /**
     * A select primary filter.
     */
    selectPrimaryFilterName = null;

    /**
     * A select bool filter list.
     */
    selectBoolFilterList = null;

    /**
     * An autocomplete max record number.
     */
    autocompleteMaxCount = null;

    /**
     * Select all attributes.
     */
    forceSelectAllAttributes = false;

    /**
     * Mandatory select attributes.
     */
    mandatorySelectAttributeList = null;

    /**
     * @inheritDoc
     * @internal
     */
    initialSearchIsNotIdle = true;

    /**
     * Trigger autocomplete on empty input.
     */

    displayScopeColorInListMode = true;
    data() {
      let nameValue = this.model.get(this.nameName);
      if (!nameValue && this.model.get(this.idName) && this.model.get(this.typeName)) {
        nameValue = this.translate(this.model.get(this.typeName), 'scopeNames');
      }
      let iconHtml = null;
      if ((this.mode === this.MODE_DETAIL || this.mode === this.MODE_LIST && this.displayScopeColorInListMode) && this.foreignScope) {
        iconHtml = this.getHelper().getScopeColorIconHtml(this.foreignScope);
      }
      let linkClass = null;
      if (this.isDetailMode()) {
        linkClass = 'text-record';
      } else if (this.isListMode()) {
        linkClass = 'text-default';
      }
      return {
        ...super.data(),
        idName: this.idName,
        nameName: this.nameName,
        typeName: this.typeName,
        idValue: this.model.get(this.idName),
        nameValue: nameValue,
        typeValue: this.model.get(this.typeName),
        foreignScope: this.foreignScope,
        foreignScopeList: this.foreignScopeList,
        valueIsSet: this.model.has(this.idName) || this.model.has(this.typeName),
        iconHtml: iconHtml,
        displayEntityType: this.displayEntityType && this.model.get(this.typeName),
        linkClass: linkClass
      };
    }

    /**
     * Get advanced filters (field filters) to be applied when select a record.
     * Can be extended.
     */
    getSelectFilters() {
      return null;
    }

    /**
     * Get a select bool filter list. Applied when select a record.
     * Can be extended.
     */
    getSelectBoolFilterList() {
      return this.selectBoolFilterList;
    }

    /**
     * Get a select primary filter. Applied when select a record.
     * Can be extended.
     */
    getSelectPrimaryFilterName() {
      return this.selectPrimaryFilterName;
    }

    /**
     * Attributes to pass to a model when creating a new record.
     * Can be extended.
     */
    getCreateAttributes() {
      return null;
    }
    setup() {
      this.addHandler('auxclick', 'a[href]:not([role="button"])', e => {
        this.onAuxClickLink(e);
      });
      this.nameName = this.name + 'Name';
      this.typeName = this.name + 'Type';
      this.idName = this.name + 'Id';
      this.foreignScopeList = this.options.foreignScopeList || this.foreignScopeList;
      this.foreignScopeList = this.foreignScopeList || this.params.entityList || this.model.getLinkParam(this.name, 'entityList') || [];
      this.foreignScopeList = _utils.default.clone(this.foreignScopeList).filter(item => {
        if (!this.getMetadata().get(['scopes', item, 'disabled'])) {
          return true;
        }
      });
      this.foreignScope = this.model.get(this.typeName) || this.foreignScopeList[0];
      if (this.foreignScope && !~this.foreignScopeList.indexOf(this.foreignScope)) {
        this.foreignScopeList.unshift(this.foreignScope);
      }
      this.listenTo(this.model, `change:${this.typeName}`, () => {
        this.foreignScope = this.model.get(this.typeName) || this.foreignScopeList[0];
      });
      this.autocompleteOnEmpty = this.params.autocompleteOnEmpty || this.autocompleteOnEmpty;
      if ('createDisabled' in this.options) {
        this.createDisabled = this.options.createDisabled;
      }
      if (!this.isListMode()) {
        this.addActionHandler('selectLink', () => this.actionSelect());
        this.addActionHandler('clearLink', () => this.actionClearLink());
        this.addHandler('change', `select[data-name="${this.typeName}"]`, (_, target) => {
          var _this$$elementName, _this$$elementId;
          this.foreignScope = target.value;
          (_this$$elementName = this.$elementName) === null || _this$$elementName === void 0 || _this$$elementName.val('');
          (_this$$elementId = this.$elementId) === null || _this$$elementId === void 0 || _this$$elementId.val('');
        });
      }
    }
    actionClearLink() {
      if (this.foreignScopeList.length) {
        this.foreignScope = this.foreignScopeList[0];
        _select.default.setValue(this.$elementType, this.foreignScope);
      }
      this.$elementName.val('');
      this.$elementId.val('');
      this.trigger('change');
    }
    async actionSelect() {
      const viewName = this.getMetadata().get(`clientDefs.${this.foreignScope}.modalViews.select`) || this.selectRecordsView;
      const createButton = !this.createDisabled && this.isEditMode();
      const options = {
        scope: this.foreignScope,
        createButton: createButton,
        filters: this.getSelectFilters(),
        boolFilterList: this.getSelectBoolFilterList(),
        primaryFilterName: this.getSelectPrimaryFilterName(),
        createAttributes: createButton ? this.getCreateAttributes() : null,
        mandatorySelectAttributeList: this.getMandatorySelectAttributeList(),
        forceSelectAllAttributes: this.isForceSelectAllAttributes(),
        layoutName: this.getSelectLayout(),
        onSelect: models => {
          this.select(models[0]);
        }
      };
      _ui.default.notifyWait();
      const view = await this.createView('modal', viewName, options);
      await view.render();
      _ui.default.notify();
    }
    setupSearch() {
      const type = this.getSearchParamsData().type;
      if (type === 'is' || !type) {
        var _this$searchParams, _this$searchParams2, _this$searchParams3;
        this.searchData.idValue = this.getSearchParamsData().idValue ?? ((_this$searchParams = this.searchParams) === null || _this$searchParams === void 0 ? void 0 : _this$searchParams.valueId);
        this.searchData.nameValue = this.getSearchParamsData().nameValue ?? ((_this$searchParams2 = this.searchParams) === null || _this$searchParams2 === void 0 ? void 0 : _this$searchParams2.valueName);
        this.searchData.typeValue = this.getSearchParamsData().typeValue ?? ((_this$searchParams3 = this.searchParams) === null || _this$searchParams3 === void 0 ? void 0 : _this$searchParams3.valueType);
      }
      this.addHandler('change', 'select.search-type', (_, target) => {
        this.handleSearchType(target.value);
      });
    }

    /**
     * Handle a search type.
     *
     * @param type A type.
     */
    handleSearchType(type) {
      if (['is'].includes(type)) {
        this.$el.find('div.primary').removeClass('hidden');
      } else {
        this.$el.find('div.primary').addClass('hidden');
      }
    }

    /**
     * Select.
     *
     * {module:model} model A model.
     */
    select(model) {
      var _this$$elementName2, _this$$elementId2;
      (_this$$elementName2 = this.$elementName) === null || _this$$elementName2 === void 0 || _this$$elementName2.val(model.get('name') ?? model.id);
      (_this$$elementId2 = this.$elementId) === null || _this$$elementId2 === void 0 || _this$$elementId2.val(model.id);
      this.trigger('change');
    }

    /**
     * Attributes to select regardless availability on a list layout.
     * Can be extended.
     */
    getMandatorySelectAttributeList() {
      return this.mandatorySelectAttributeList;
    }

    /**
     * Select all attributes. Can be extended.
     */
    isForceSelectAllAttributes() {
      return this.forceSelectAllAttributes;
    }

    /**
     * Get an autocomplete max record number. Can be extended.
     */
    getAutocompleteMaxCount() {
      if (this.autocompleteMaxCount) {
        return this.autocompleteMaxCount;
      }
      return this.getConfig().get('recordsPerPage');
    }

    /**
     * Compose an autocomplete URL. Can be extended.
     *
     * @param q A query.
     */
    getAutocompleteUrl(q) {
      // noinspection BadExpressionStatementJS
      q;
      let url = this.foreignScope + '?maxSize=' + this.getAutocompleteMaxCount();
      if (!this.isForceSelectAllAttributes()) {
        let select = ['id', 'name'];
        const mandatory = this.getMandatorySelectAttributeList();
        if (mandatory) {
          select = select.concat(mandatory);
        }
        url += '&select=' + select.join(',');
      }
      const boolList = this.getSelectBoolFilterList();
      if (boolList) {
        url += '&' + $.param({
          'boolFilterList': boolList
        });
      }
      const primary = this.getSelectPrimaryFilterName();
      if (primary) {
        url += '&' + $.param({
          'primaryFilter': primary
        });
      }
      const advanced = this.getSelectFilters();
      if (advanced && Object.keys(advanced).length) {
        url += '&' + $.param({
          'where': advanced
        });
      }
      return url;
    }
    afterRender() {
      if (this.isEditMode() || this.isSearchMode()) {
        this.$elementId = this.$el.find(`input[data-name="${this.idName}"]`);
        this.$elementName = this.$el.find(`input[data-name="${this.nameName}"]`);
        this.$elementType = this.$el.find(`select[data-name="${this.typeName}"]`);
        this.$elementName.on('change', () => {
          if (this.$elementName.val() === '') {
            this.$elementName.val('');
            this.$elementId.val('');
            this.trigger('change');
          }
        });
        this.$elementType.on('change', () => {
          this.$elementName.val('');
          this.$elementId.val('');
          this.trigger('change');
        });
        this.$elementName.on('blur', e => {
          setTimeout(() => {
            if (this.mode === this.MODE_EDIT) {
              e.currentTarget.value = this.model.get(this.nameName) || '';
            }
          }, 100);
        });
        if (!this.autocompleteDisabled) {
          var _this$$elementName3;
          let lastAjaxPromise;
          const autocomplete = new _autocomplete.default((_this$$elementName3 = this.$elementName) === null || _this$$elementName3 === void 0 ? void 0 : _this$$elementName3.get(0), {
            name: this.name,
            focusOnSelect: true,
            handleFocusMode: 2,
            autoSelectFirst: true,
            triggerSelectOnValidInput: false,
            forceHide: true,
            minChars: this.autocompleteOnEmpty ? 0 : 1,
            onSelect: async item => {
              var _this$$elementName4;
              const entityType = this.foreignScope;
              if (!entityType) {
                throw new Error("No entity type selected.");
              }
              const model = await this.getModelFactory().create(entityType);
              model.setMultiple(item.attributes);
              this.select(model);
              (_this$$elementName4 = this.$elementName) === null || _this$$elementName4 === void 0 || _this$$elementName4.trigger('focus');
            },
            lookupFunction: async query => {
              const url = await this.getAutocompleteUrl(query);
              if (lastAjaxPromise && lastAjaxPromise.getReadyState() < 4) {
                lastAjaxPromise.abort();
              }
              lastAjaxPromise = _ajax.default.getRequest(url, {
                q: query
              });
              const response = await lastAjaxPromise;
              return response.list.map(item => ({
                value: item.name,
                attributes: item
              }));
            }
          });
          this.once('render remove', () => autocomplete.dispose());
          _select.default.init(this.$elementType, {});
          this.$elementType.on('change', () => autocomplete.clear());
        }
      }
      if (this.isSearchMode()) {
        const type = this.$el.find('select.search-type').val();
        this.handleSearchType(type);
        this.$el.find('select.search-type').on('change', () => {
          this.trigger('change');
        });
      }
    }
    getValueForDisplay() {
      return this.model.get(this.nameName);
    }
    validateRequired() {
      if (this.isRequired()) {
        if (this.model.get(this.idName) === null || !this.model.get(this.typeName)) {
          const msg = this.translate('fieldIsRequired', 'messages').replace('{field}', this.getLabelText());
          this.showValidationMessage(msg);
          return true;
        }
      }
      return false;
    }
    fetch() {
      const data = {};
      data[this.typeName] = this.$elementType.val() || null;
      data[this.nameName] = this.$elementName.val() || null;
      data[this.idName] = this.$elementId.val() || null;
      if (data[this.idName] === null) {
        data[this.typeName] = null;
      }
      return data;
    }
    fetchSearch() {
      const type = this.$el.find('select.search-type').val();
      if (type === 'isEmpty') {
        return {
          type: 'isNull',
          field: this.idName,
          data: {
            type: type
          }
        };
      }
      if (type === 'isNotEmpty') {
        return {
          type: 'isNotNull',
          field: this.idName,
          data: {
            type: type
          }
        };
      }
      const entityType = this.$elementType.val();
      const entityName = this.$elementName.val();
      const entityId = this.$elementId.val();
      if (!entityType) {
        return null;
      }
      if (entityId) {
        return {
          type: 'and',
          attribute: this.idName,
          value: [{
            type: 'equals',
            field: this.idName,
            value: entityId
          }, {
            type: 'equals',
            field: this.typeName,
            value: entityType
          }],
          data: {
            type: 'is',
            idValue: entityId,
            nameValue: entityName,
            typeValue: entityType
          }
        };
      }
      return {
        type: 'and',
        attribute: this.idName,
        value: [{
          type: 'isNotNull',
          field: this.idName
        }, {
          type: 'equals',
          field: this.typeName,
          value: entityType
        }],
        data: {
          type: 'is',
          typeValue: entityType
        }
      };
    }
    getSearchType() {
      var _this$searchParams4;
      return this.getSearchParamsData().type ?? ((_this$searchParams4 = this.searchParams) === null || _this$searchParams4 === void 0 ? void 0 : _this$searchParams4.typeFront) ?? null;
    }
    quickView() {
      const id = this.model.get(this.idName);
      const entityType = this.model.get(this.typeName);
      if (!id || !entityType) {
        return;
      }
      const helper = new _recordModal.default();
      helper.showDetail(this, {
        id: id,
        entityType: entityType
      });
    }

    /**
     * @since 9.1.0
     */
    getSelectLayout() {
      return undefined;
    }
    onAuxClickLink(e) {
      if (!this.isReadMode()) {
        return;
      }
      const isCombination = e.button === 1 && (e.ctrlKey || e.metaKey);
      if (!isCombination) {
        return;
      }
      e.preventDefault();
      e.stopPropagation();
      this.quickView();
    }
  }
  var _default = _exports.default = LinkParentFieldView;
});

define("views/fields/link-multiple-with-role", ["exports", "views/fields/link-multiple", "ui/select"], function (_exports, _linkMultiple, _select) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _linkMultiple = _interopRequireDefault(_linkMultiple);
  _select = _interopRequireDefault(_select);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * A link-multiple field with a relation column.
   * @deprecated Prefer using `link-multiple-with-columns` instead.
   */
  class LinkMultipleWithRoleFieldView extends _linkMultiple.default {
    /**
     * A role field type.
     */
    roleType = 'enum';
    /**
     * A relation column name.
     */
    columnName = 'role';
    /**
     * The role field is defined in a foreign entity.
     */
    roleFieldIsForeign = true;
    /**
     * A value to fetch for an empty role.
     */
    emptyRoleValue = null;
    /**
     * A role placeholder text.
     */
    rolePlaceholderText = null;
    /**
     * A role value max length.
     * @protected
     */
    roleMaxLength = 50;
    /**
     * @protected
     */
    forceRoles = false;

    /** @const */
    ROLE_TYPE_ENUM = 'enum';
    // noinspection JSUnusedGlobalSymbols
    /** @const */
    ROLE_TYPE_VARCHAR = 'varchar';

    /**
     * @type {Record}
     * @protected
     */
    columns;
    setup() {
      super.setup();
      this.columnsName = this.name + 'Columns';
      this.columns = Espo.Utils.cloneDeep(this.model.get(this.columnsName) || {});
      this.listenTo(this.model, 'change:' + this.columnsName, () => {
        this.columns = Espo.Utils.cloneDeep(this.model.get(this.columnsName) || {});
      });
      this.roleField = this.getMetadata().get(['entityDefs', this.model.entityType, 'fields', this.name, 'columns', this.columnName]);
      this.displayRoleAsLabel = this.getMetadata().get(['entityDefs', this.model.entityType, 'fields', this.roleField, 'displayAsLabel']);
      this.roleFieldScope = this.roleFieldIsForeign ? this.foreignScope : this.model.entityType;
      if (this.roleType === this.ROLE_TYPE_ENUM && !this.forceRoles) {
        this.roleList = this.getMetadata().get(['entityDefs', this.roleFieldScope, 'fields', this.roleField, 'options']);
        if (!this.roleList) {
          this.roleList = [];
          this.skipRoles = true;
        }
      }
      if (this.roleType === this.ROLE_TYPE_ENUM) {
        this.styleMap = /** @type {Record<string>}*/this.getMetadata().get(['entityDefs', this.model.entityType, 'fields', this.roleField, 'style']) || {};
      }
    }
    getAttributeList() {
      const list = super.getAttributeList();
      list.push(this.name + 'Columns');
      return list;
    }
    getDetailLinkHtml(id, name) {
      // Do not use the `html` method to avoid XSS.

      name = name || this.nameHash[id] || id;
      if (!name && id) {
        name = this.translate(this.foreignScope, 'scopeNames');
      }
      let role = (this.columns[id] || {})[this.columnName] || '';
      if (this.emptyRoleValue && role === this.emptyRoleValue) {
        role = '';
      }
      const $a = $('<a>').attr('href', `#${this.foreignScope}/view/${id}`).attr('data-id', id).text(name);
      if (this.mode === this.MODE_LIST) {
        $a.addClass('text-default');
      } else {
        $a.addClass(this.linkClass ?? 'text-record');
      }
      const $el = $('<div>').append($a);
      if (this.isDetailMode()) {
        const iconHtml = this.getIconHtml(id);
        if (iconHtml) {
          $el.prepend(iconHtml);
        }
      }
      if (role) {
        let style = this.styleMap[role];
        let className = 'text';
        if (this.displayRoleAsLabel && style && style !== 'default') {
          className = 'label label-sm label';
          if (style === 'muted') {
            style = 'default';
          }
        } else {
          style = style || 'muted';
        }
        className = className + '-' + style;
        const text = this.roleType === this.ROLE_TYPE_ENUM ? this.getLanguage().translateOption(role, this.roleField, this.roleFieldScope) : role;
        $el.append($('<span>').text(' '), $('<span>').addClass('text-muted middle-dot'), $('<span>').text(' '), $('<span>').text(text).addClass('small').addClass(className));
      }
      return $el.get(0).outerHTML;
    }
    getValueForDisplay() {
      if (this.isDetailMode() || this.isListMode()) {
        const names = [];
        this.ids.forEach(id => {
          names.push(this.getDetailLinkHtml(id));
        });
        return names.join('');
      }
    }
    deleteLink(id) {
      this.trigger('delete-link', id);
      this.trigger('delete-link:' + id);
      this.deleteLinkHtml(id);
      const index = this.ids.indexOf(id);
      if (index > -1) {
        this.ids.splice(index, 1);
      }
      delete this.nameHash[id];
      delete this.columns[id];
      this.afterDeleteLink(id);
      this.trigger('change');
    }
    addLink(id, name) {
      if (!~this.ids.indexOf(id)) {
        this.ids.push(id);
        this.nameHash[id] = name;
        this.columns[id] = {};
        this.columns[id][this.columnName] = null;
        this.addLinkHtml(id, name);
        this.trigger('add-link', id);
        this.trigger('add-link:' + id);
      }
      this.trigger('change');
    }

    /**
     * Build a role select element.
     *
     * @param {string} id
     * @param {string|null} roleValue
     * @return {JQuery}
     */
    getJQSelect(id, roleValue) {
      // Do not use the `html` method to avoid XSS.

      const $role = $('<select>').addClass('role form-control input-sm').attr('data-id', id);
      this.roleList.forEach(role => {
        const text = this.getLanguage().translateOption(role, this.roleField, this.roleFieldScope);
        const $option = $('<option>').val(role).text(text);
        if (role === (roleValue || '')) {
          $option.attr('selected', 'selected');
        }
        const style = this.styleMap[role];
        if (style) {
          $option.addClass('text-' + style);
        }
        $role.append($option);
      });
      return $role;
    }

    /**
     * @inheritDoc
     */
    addLinkHtml(id, name) {
      // Do not use the `html` method to avoid XSS.

      name = name || id;
      if (this.isSearchMode() || this.skipRoles) {
        return super.addLinkHtml(id, name);
      }
      const $container = this.$el.find('.link-container');
      const itemElement = this.prepareEditItemElement(id, name);
      $container.append(itemElement);
      const $el = $(itemElement);
      let $role;
      if (this.roleType === this.ROLE_TYPE_ENUM) {
        $role = $el.find('select.role');
      } else {
        $role = $el.find('input.role');
      }
      if ($role && $role.get(0) && $role.get(0).tagName === 'SELECT') {
        _select.default.init($role);
      }
      if (this.isEditMode() && $role) {
        const fetch = $target => {
          if (!$target || !$target.length) {
            return;
          }
          if ($target.val() === null) {
            return;
          }
          let value = $target.val().toString().trim();
          const id = $target.data('id');
          if (value === '') {
            value = null;
          }
          this.columns[id] = this.columns[id] || {};
          this.columns[id][this.columnName] = value;
        };
        $role.on('change', e => {
          fetch($(e.currentTarget));
          this.trigger('change');
        });
        fetch($role);
      }
      return $el;
    }

    /**
     * @inheritDoc
     */
    prepareEditItemElement(id, name) {
      if (this.isSearchMode() || this.skipRoles) {
        return super.prepareEditItemElement(id, name);
      }
      const role = (this.columns[id] || {})[this.columnName];
      const $el = $('<div>').addClass('form-inline clearfix').addClass('list-group-item link-with-role link-group-item-with-columns').addClass('link-' + id);
      const $remove = $('<a>').attr('role', 'button').attr('tabindex', '0').attr('data-id', id).attr('data-action', 'clearLink').addClass('pull-right').append($('<span>').addClass('fas fa-times'));
      const $left = $('<div>').addClass('pull-left');
      const $right = $('<div>').append($remove);
      const $name = $('<div>').addClass('link-item-name').text(name).append('&nbsp;');
      let $role;
      if (this.roleType === this.ROLE_TYPE_ENUM) {
        $role = this.getJQSelect(id, role);
      } else {
        const text = this.rolePlaceholderText || this.translate(this.roleField, 'fields', this.roleFieldScope);
        $role = $('<input>').addClass('role form-control input-sm').attr('maxlength', this.roleMaxLength) // @todo Get the value from metadata.
        .attr('placeholder', text).attr('data-id', id).attr('value', role || '');
      }
      if ($role) {
        $left.append($('<span>').addClass('link-item-column').addClass('link-item-column-' + $role.get(0).tagName.toLowerCase()).append($role));
      }
      $left.append($name);
      $el.append($left).append($right);
      return $el.get(0);
    }
    fetch() {
      const data = super.fetch();
      if (!this.skipRoles) {
        data[this.columnsName] = Espo.Utils.cloneDeep(this.columns);
      }
      return data;
    }
  }

  // noinspection JSDeprecatedSymbols
  var _default = _exports.default = LinkMultipleWithRoleFieldView;
});

define("views/fields/link-multiple-with-primary", ["exports", "views/fields/link-multiple"], function (_exports, _linkMultiple) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _linkMultiple = _interopRequireDefault(_linkMultiple);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * A link-multiple field with a primary.
   */
  class LinkMultipleWithPrimaryFieldView extends _linkMultiple.default {
    /**
     * @protected
     * @type {string}
     */
    primaryLink;
    switchPrimary(id) {
      const $switch = this.$el.find(`[data-id="${id}"][data-action="switchPrimary"]`);
      if (!$switch.hasClass('active')) {
        this.$el.find('button[data-action="switchPrimary"]').removeClass('active').children().addClass('text-muted');
        $switch.addClass('active').children().removeClass('text-muted');
        this.setPrimaryId(id);
        this.trigger('change');
      }
    }

    /**
     * @inheritDoc
     */
    getAttributeList() {
      const list = super.getAttributeList();
      list.push(this.primaryIdAttribute);
      list.push(this.primaryNameAttribute);
      return list;
    }
    setup() {
      this.primaryLink = this.options.primaryLink || this.primaryLink || this.model.getFieldParam(this.name, 'primaryLink');
      this.primaryIdAttribute = this.primaryLink + 'Id';
      this.primaryNameAttribute = this.primaryLink + 'Name';
      super.setup();
      this.primaryId = this.model.get(this.primaryIdAttribute);
      this.primaryName = this.model.get(this.primaryNameAttribute);
      this.listenTo(this.model, 'change:' + this.primaryIdAttribute, () => {
        this.primaryId = this.model.get(this.primaryIdAttribute);
        this.primaryName = this.model.get(this.primaryNameAttribute);
      });
      this.events['click [data-action="switchPrimary"]'] = e => {
        const $target = $(e.currentTarget);
        const id = $target.data('id');
        this.switchPrimary(id);
      };
    }

    /**
     * @protected
     * @param {string|null} id An ID.
     */
    setPrimaryId(id) {
      this.primaryId = id;
      this.primaryName = id ? this.nameHash[id] : null;
    }

    /**
     * @protected
     */
    renderLinks() {
      if (this.primaryId) {
        this.addLinkHtml(this.primaryId, this.primaryName);
      }
      this.ids.forEach(id => {
        if (id !== this.primaryId) {
          this.addLinkHtml(id, this.nameHash[id]);
        }
      });
    }

    /**
     * @inheritDoc
     */
    getValueForDisplay() {
      if (this.isDetailMode() || this.isListMode()) {
        const itemList = [];
        if (this.primaryId) {
          itemList.push(this.getDetailLinkHtml(this.primaryId, this.primaryName));
        }
        if (!this.ids.length) {
          return;
        }
        this.ids.forEach(id => {
          if (id !== this.primaryId) {
            itemList.push(this.getDetailLinkHtml(id));
          }
        });
        return itemList.map(item => $('<div>').addClass('link-multiple-item').append(item).get(0).outerHTML).join('');
      }
    }

    /**
     * @inheritDoc
     */
    deleteLink(id) {
      if (id === this.primaryId) {
        this.setPrimaryId(null);
      }
      super.deleteLink(id);
    }

    /**
     * @inheritDoc
     */
    deleteLinkHtml(id) {
      super.deleteLinkHtml(id);
      this.managePrimaryButton();
    }

    /**
     * @inheritDoc
     */
    addLinkHtml(id, name) {
      // Do not use the `html` method to avoid XSS.

      name = name || id;
      if (this.isSearchMode()) {
        return super.addLinkHtml(id, name);
      }
      const $container = this.$el.find('.link-container');
      const $el = $('<div>').addClass('form-inline clearfix ').addClass('list-group-item link-with-role link-group-item-with-primary').addClass('link-' + id).attr('data-id', id);
      const $name = $('<div>').text(name).append('&nbsp;');
      const $remove = $('<a>').attr('role', 'button').attr('tabindex', '0').attr('data-id', id).attr('data-action', 'clearLink').addClass('pull-right').append($('<span>').addClass('fas fa-times'));
      const $left = $('<div>');
      const $right = $('<div>');
      $left.append($name);
      $right.append($remove);
      $el.append($left);
      $el.append($right);
      const isPrimary = id === this.primaryId;
      const $star = $('<span>').addClass('fas fa-star fa-sm').addClass(!isPrimary ? 'text-muted' : '');
      const $button = $('<button>').attr('type', 'button').addClass('btn btn-link btn-sm pull-right hidden').attr('title', this.translate('Primary')).attr('data-action', 'switchPrimary').attr('data-id', id).append($star);
      $button.insertBefore($el.children().first().children().first());
      $container.append($el);
      this.managePrimaryButton();
      return $el;
    }

    /**
     * @protected
     */
    managePrimaryButton() {
      const $primary = this.$el.find('button[data-action="switchPrimary"]');
      if ($primary.length > 1) {
        $primary.removeClass('hidden');
      } else {
        $primary.addClass('hidden');
      }
      if ($primary.filter('.active').length === 0) {
        const $first = $primary.first();
        if ($first.length) {
          $first.addClass('active').children().removeClass('text-muted');
          const id = $first.data('id');
          this.setPrimaryId(id);
          if (id !== this.primaryId) {
            this.trigger('change');
          }
        }
      }
    }
    fetch() {
      const data = super.fetch();
      data[this.primaryIdAttribute] = this.primaryId;
      data[this.primaryNameAttribute] = this.primaryName;

      // noinspection JSValidateTypes
      return data;
    }
  }
  var _default = _exports.default = LinkMultipleWithPrimaryFieldView;
});

define("views/fields/link-multiple-with-columns", ["exports", "views/fields/link-multiple", "helpers/reg-exp-pattern", "ui/select", "ui/autocomplete"], function (_exports, _linkMultiple, _regExpPattern, _select, _autocomplete) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _linkMultiple = _interopRequireDefault(_linkMultiple);
  _regExpPattern = _interopRequireDefault(_regExpPattern);
  _select = _interopRequireDefault(_select);
  _autocomplete = _interopRequireDefault(_autocomplete);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/fields/link-multiple-with-columns */

  /**
   * A link-multiple field with relation column(s).
   */
  class LinkMultipleWithColumnsFieldView extends _linkMultiple.default {
    /** @const */
    COLUMN_TYPE_VARCHAR = 'varchar';
    /** @const */
    COLUMN_TYPE_ENUM = 'enum';
    /** @const */
    COLUMN_TYPE_BOOL = 'bool';

    /** @inheritDoc */
    setup() {
      super.setup();
      const columnsDefsInitial = this.columnsDefs || {};
      this.validations.push('columnPattern');

      /**
       * @type {Object.<string,*>}
       */
      this.columnsDefs = {};
      this.columnsName = this.name + 'Columns';
      this.columns = Espo.Utils.cloneDeep(this.model.get(this.columnsName) || {});
      this.listenTo(this.model, 'change:' + this.columnsName, () => {
        this.columns = Espo.Utils.cloneDeep(this.model.get(this.columnsName) || {});
      });
      const columns = this.getMetadata().get(['entityDefs', this.model.entityType, 'fields', this.name, 'columns']) || {};

      /** @type {string[]} */
      this.columnList = this.columnList || Object.keys(columns);
      this.columnList.forEach(column => {
        if (column in columnsDefsInitial) {
          this.columnsDefs[column] = Espo.Utils.cloneDeep(columnsDefsInitial[column]);
          return;
        }
        if (column in columns) {
          const field = columns[column];
          const o = {};
          o.field = field;
          o.scope = this.foreignScope;
          if (!this.getMetadata().get(['entityDefs', this.foreignScope, 'fields', field, 'type']) && this.getMetadata().get(['entityDefs', this.model.entityType, 'fields', field, 'type'])) {
            o.scope = this.model.entityType;
          }
          const fieldDefs = this.getMetadata().get(['entityDefs', o.scope, 'fields', field]) || {};
          o.type = fieldDefs.type;
          if (o.type === this.COLUMN_TYPE_ENUM || o.type === this.COLUMN_TYPE_VARCHAR) {
            o.options = fieldDefs.options;
          }
          if ('default' in fieldDefs) {
            o.default = fieldDefs.default;
          }
          if ('maxLength' in fieldDefs) {
            o.maxLength = fieldDefs.maxLength;
          }
          if ('pattern' in fieldDefs) {
            o.pattern = fieldDefs.pattern;
          }
          this.columnsDefs[column] = o;
        }
      });
      if (this.isEditMode() || this.isDetailMode()) {
        this.events['click a[data-action="toggleBoolColumn"]'] = e => {
          const id = $(e.currentTarget).data('id');
          const column = $(e.currentTarget).data('column');
          this.toggleBoolColumn(id, column);
        };
      }
      this.on('render', this.disposeColumnAutocompletes, this);
      this.once('remove', this.disposeColumnAutocompletes, this);
    }
    toggleBoolColumn(id, column) {
      this.columns[id][column] = !this.columns[id][column];
      this.reRender();
    }

    /** @inheritDoc */
    getAttributeList() {
      return [...super.getAttributeList(), this.name + 'Columns'];
    }

    /**
     * Get an item HTML for detail mode.
     *
     * @param {string} id An ID.
     * @param {string} [name] An name.
     * @return {string}
     */
    getDetailLinkHtml(id, name) {
      // Do not use the `html` method to avoid XSS.

      name = name || this.nameHash[id] || id;
      const $a = $('<a>').attr('href', '#' + this.foreignScope + '/view/' + id).attr('data-id', id).text(name);
      if (this.mode === this.MODE_LIST) {
        $a.addClass('text-default');
      } else {
        $a.addClass(this.linkClass ?? 'text-record');
      }
      const $el = $('<div>').append($a);
      if (this.isDetailMode()) {
        const iconHtml = this.getIconHtml(id);
        if (iconHtml) {
          $el.prepend(iconHtml);
        }
      }
      this.columnList.forEach(column => {
        const value = (this.columns[id] || {})[column] || '';
        const type = this.columnsDefs[column].type;
        const field = this.columnsDefs[column].field;
        const scope = this.columnsDefs[column].scope;
        if (type !== this.COLUMN_TYPE_ENUM && type !== this.COLUMN_TYPE_VARCHAR) {
          return;
        }
        const text = type === this.COLUMN_TYPE_ENUM ? this.getLanguage().translateOption(value, field, scope) : value;
        if (!text) {
          return;
        }
        $el.append($('<span>').text(' '), $('<span>').addClass('text-muted middle-dot'), $('<span>').text(' '), $('<span>').text(text).addClass('text-muted small'));
      });
      return $el.get(0).innerHTML;
    }

    /** @inheritDoc */
    getValueForDisplay() {
      if (this.isDetailMode() || this.isListMode()) {
        const itemList = [];
        this.ids.forEach(id => {
          itemList.push(this.getDetailLinkHtml(id));
        });
        return itemList.map(item => {
          return $('<div>').addClass('link-multiple-item').html(item).get(0).outerHTML;
        }).join('');
      }
    }

    /** @inheritDoc */
    deleteLink(id) {
      this.trigger('delete-link', id);
      this.trigger('delete-link:' + id);
      this.deleteLinkHtml(id);
      const index = this.ids.indexOf(id);
      if (index > -1) {
        this.ids.splice(index, 1);
      }
      delete this.nameHash[id];
      delete this.columns[id];
      this.afterDeleteLink(id);
      this.trigger('change');
    }

    /**
     * Get a column values.
     *
     * @param {string} id An ID.
     * @param {string} column A column.
     * @return {*}
     */
    getColumnValue(id, column) {
      return (this.columns[id] || {})[column];
    }
    addLink(id, name) {
      if (!~this.ids.indexOf(id)) {
        this.ids.push(id);
        this.nameHash[id] = name;
        this.columns[id] = {};
        this.columnList.forEach(column => {
          this.columns[id][column] = null;
          if ('default' in this.columnsDefs[column]) {
            this.columns[id][column] = this.columnsDefs[column].default;
          }
        });
        this.addLinkHtml(id, name);
        this.afterAddLink(id);
        this.trigger('add-link', id);
        this.trigger('add-link:' + id);
      }
      this.trigger('change');
    }

    /**
     * @param {string} column
     * @param {string} id
     * @param {*} value
     * @return {JQuery}
     */
    getJQSelect(column, id, value) {
      // Do not use the `html` method to avoid XSS.

      const field = this.columnsDefs[column].field;
      const scope = this.columnsDefs[column].scope;
      const options = this.columnsDefs[column].options || [];
      const $select = $('<select>').addClass('role form-control input-sm').attr('data-id', id).attr('data-column', column);
      options.forEach(itemValue => {
        const text = this.getLanguage().translateOption(itemValue, field, scope);
        const $option = $('<option>').val(itemValue).text(text);
        if (itemValue === (value || '')) {
          $option.attr('selected', 'selected');
        }
        $select.append($option);
      });
      return $select;
    }

    /**
     * @param {string} column
     * @param {string} id
     * @param {*} value
     * @return {JQuery}
     */
    getJQInput(column, id, value) {
      // Do not use the `html` method to avoid XSS.

      const field = this.columnsDefs[column].field;
      const scope = this.columnsDefs[column].scope;
      const maxLength = this.columnsDefs[column].maxLength;
      const text = this.translate(field, 'fields', scope);
      const $input = $('<input>').addClass('role form-control input-sm').attr('data-column', column).attr('placeholder', text).attr('data-id', id).attr('value', value || '');
      if (maxLength) {
        $input.attr('maxlength', maxLength);
      }
      return $input;
    }

    /**
     * @param {string} column
     * @param {string} id
     * @param {*} value
     * @return {JQuery}
     */
    getJQLi(column, id, value) {
      // Do not use the `html` method to avoid XSS.

      const field = this.columnsDefs[column].field;
      const scope = this.columnsDefs[column].scope;
      const text = this.translate(field, 'fields', scope);
      return $('<li>').append($('<a>').attr('role', 'button').attr('tabindex', '0').attr('data-action', 'toggleBoolColumn').attr('data-column', column).attr('data-id', id).append($('<span>').addClass('check-icon fas fa-check pull-right').addClass(!value ? 'hidden' : '')).append($('<div>').text(text)));
    }

    /** @inheritDoc */
    addLinkHtml(id, name) {
      if (this.isSearchMode()) {
        return super.addLinkHtml(id, name);
      }

      // Do not use the `html` method to avoid XSS.

      const $container = this.$el.find('.link-container');
      const $el = $('<div>').addClass('form-inline clearfix').addClass('list-group-item link-with-role link-group-item-with-columns').addClass('link-' + id).attr('data-id', id);
      const $remove = $('<a>').attr('role', 'button').attr('tabindex', '0').attr('data-id', id).attr('data-action', 'clearLink').addClass('pull-right').append($('<span>').addClass('fas fa-times'));
      const $name = $('<div>').addClass('link-item-name').text(name).append('&nbsp;');
      const $columnList = [];
      const $liList = [];
      this.columnList.forEach(column => {
        const value = (this.columns[id] || {})[column];
        const type = this.columnsDefs[column].type;
        if (type === this.COLUMN_TYPE_ENUM) {
          $columnList.push(this.getJQSelect(column, id, value));
          return;
        }
        if (type === this.COLUMN_TYPE_VARCHAR) {
          $columnList.push(this.getJQInput(column, id, value));
          return;
        }
        if (type === this.COLUMN_TYPE_BOOL) {
          $liList.push(this.getJQLi(column, id, value));
        }
      });
      const $left = $('<div>');
      const $right = $('<div>');
      $columnList.forEach($item => $left.append($('<span>').addClass('link-item-column').addClass('link-item-column-' + $item.get(0).tagName.toLowerCase()).append($item)));
      if ($liList.length) {
        const $ul = $('<ul>').addClass('dropdown-menu');
        $liList.forEach($item => $ul.append($item));
        $left.append($('<div>').addClass('btn-group pull-right').append($('<button>').attr('type', 'button').attr('data-toggle', 'dropdown').addClass('btn btn-link btn-sm dropdown-toggle').append($('<span>').addClass('caret'))).append($ul));
      }
      $left.append($name);
      $right.append($remove);
      $el.append($left);
      $el.append($right);
      $container.append($el);
      if (this.isEditMode()) {
        $columnList.forEach($column => {
          if ($column.get(0) && $column.get(0).tagName === 'SELECT') {
            _select.default.init($column);
          }
          const fetch = $target => {
            if (!$target || !$target.length) {
              return;
            }
            const column = $target.data('column');
            let value = $target.val().toString().trim();
            const id = $target.data('id');
            if (value === '') {
              value = null;
            }
            this.columns[id] = this.columns[id] || {};
            this.columns[id][column] = value;
          };
          $column.on('change', e => {
            const $target = $(e.currentTarget);
            fetch($target);
            this.trigger('change');
          });
          fetch($column);
        });
        this.initAutocomplete(id);
      }
      return $el;
    }
    initAutocomplete(id) {
      if (!this._autocompleteList) {
        /** @type {Autocomplete[]} */
        this._autocompleteList = [];
      }
      this.columnList.forEach(column => {
        const type = this.columnsDefs[column].type;
        if (type !== this.COLUMN_TYPE_VARCHAR) {
          return;
        }
        const options = this.columnsDefs[column].options;
        if (!(options && options.length)) {
          return;
        }
        const $element = this.$el.find(`[data-column="${column}"][data-id="${id}"]`);
        if (!$element.length) {
          return;
        }
        const autocomplete = new _autocomplete.default($element.get(0), {
          name: this.name + 'Column' + id,
          triggerSelectOnValidInput: true,
          autoSelectFirst: true,
          handleFocusMode: 1,
          focusOnSelect: true,
          onSelect: () => {
            this.trigger('change');
            $element.trigger('change');
          },
          lookup: options
        });
        this._autocompleteList.push(autocomplete);
        this.once('delete-link:' + id, () => autocomplete.dispose());
      });
    }
    disposeColumnAutocompletes() {
      if (this._autocompleteList && this._autocompleteList.length) {
        this._autocompleteList.forEach(autocomplete => {
          autocomplete.dispose();
        });
        this._autocompleteList = [];
      }
    }

    // noinspection JSUnusedGlobalSymbols
    validateColumnPattern() {
      let result = false;
      const columnList = this.columnList.filter(column => this.columnsDefs[column].type === this.COLUMN_TYPE_VARCHAR).filter(column => this.columnsDefs[column].pattern);
      for (const column of columnList) {
        for (const id of this.ids) {
          const value = this.getColumnValue(id, column);
          if (!value) {
            continue;
          }
          if (this.validateColumnPatternValue(id, column, value)) {
            result = true;
          }
        }
      }
      return result;
    }
    validateColumnPatternValue(id, column, value) {
      const pattern = this.columnsDefs[column].pattern;
      const field = this.columnsDefs[column].field;
      const scope = this.columnsDefs[column].scope;
      const helper = new _regExpPattern.default();
      const result = helper.validate(pattern, value, field, scope);
      if (!result) {
        return false;
      }
      this.showValidationMessage(result.message, '[data-column="' + column + '"][data-id="' + id + '"]');
      return true;
    }
    fetch() {
      const data = super.fetch();
      data[this.columnsName] = Espo.Utils.cloneDeep(this.columns);

      // noinspection JSValidateTypes
      return data;
    }
  }
  var _default = _exports.default = LinkMultipleWithColumnsFieldView;
});

define("views/fields/image", ["exports", "views/fields/file"], function (_exports, _file) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _file = _interopRequireDefault(_file);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ImageFieldView extends _file.default {
    type = 'image';
    showPreview = true;
    accept = ['image/*'];
    defaultType = 'image/jpeg';
    previewSize = 'small';
  }
  var _default = _exports.default = ImageFieldView;
});

define("views/fields/foreign-array", ["exports", "views/fields/array", "views/fields/foreign-enum", "helpers/misc/foreign-field"], function (_exports, _array, _foreignEnum, _foreignField) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _array = _interopRequireDefault(_array);
  _foreignEnum = _interopRequireDefault(_foreignEnum);
  _foreignField = _interopRequireDefault(_foreignField);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ForeignArrayFieldView extends _array.default {
    type = 'foreign';

    /**
     * @private
     * @type {string}
     */
    foreignEntityType;
    setup() {
      const helper = new _foreignField.default(this);
      const foreignParams = helper.getForeignParams();
      for (const param in foreignParams) {
        this.params[param] = foreignParams[param];
      }
      this.foreignEntityType = helper.getEntityType();
      super.setup();
    }
    setupOptions() {
      _foreignEnum.default.prototype.setupOptions.call(this);
    }
  }
  var _default = _exports.default = ForeignArrayFieldView;
});

define("views/fields/enum-int", ["exports", "views/fields/enum"], function (_exports, _enum) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _enum = _interopRequireDefault(_enum);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EnumIntFieldView extends _enum.default {
    type = 'enumInt';
    listTemplate = 'fields/enum/list';
    detailTemplate = 'fields/enum/detail';
    editTemplate = 'fields/enum/edit';
    searchTemplate = 'fields/enum/search';
    validations = [];
    setup() {
      super.setup();
      this.setupNumericTranslatedOptionsFallback();
    }

    /**
     * @private
     */
    setupNumericTranslatedOptionsFallback() {
      if (this.translatedOptions !== null) {
        return;
      }
      this.translatedOptions = {};
      (this.params.options || []).forEach(value => {
        if (value == null || value === '') {
          return;
        }
        const valueStr = String(value);
        this.translatedOptions[valueStr] = valueStr;
      });
    }
    fetch() {
      const raw = this.$element.val();
      if (raw === '') {
        return {
          [this.name]: null
        };
      }
      const value = parseInt(raw);
      const data = {};
      data[this.name] = value;
      return data;
    }
    parseItemForSearch(item) {
      return parseInt(item);
    }
  }
  var _default = _exports.default = EnumIntFieldView;
});

define("views/fields/entity-type", ["exports", "views/fields/enum"], function (_exports, _enum) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _enum = _interopRequireDefault(_enum);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EntityTypeFieldView extends _enum.default {
    /**
     * @type {Record<string, Record>}
     * @protected
     */
    scopesMetadataDefs;

    /**
     * @param {string} entityType
     * @return {boolean}
     */
    checkAvailability(entityType) {
      const defs = this.scopesMetadataDefs[entityType] || {};
      if (defs.entity && defs.object) {
        return true;
      }
    }
    setupOptions() {
      const scopes = this.scopesMetadataDefs = this.getMetadata().get('scopes');
      this.params.options = Object.keys(scopes).filter(scope => {
        if (this.checkAvailability(scope)) {
          return true;
        }
      }).sort((v1, v2) => {
        return this.translate(v1, 'scopeNames').localeCompare(this.translate(v2, 'scopeNames'));
      });
      this.params.options.unshift('');
    }
    setup() {
      this.params.translation = 'Global.scopeNames';
      this.setupOptions();
      super.setup();
    }
  }
  var _default = _exports.default = EntityTypeFieldView;
});

define("views/fields/email", ["exports", "views/fields/varchar", "helpers/misc/mailto", "ui/autocomplete", "ui", "ajax"], function (_exports, _varchar, _mailto, _autocomplete, _ui, _ajax) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _varchar = _interopRequireDefault(_varchar);
  _mailto = _interopRequireDefault(_mailto);
  _autocomplete = _interopRequireDefault(_autocomplete);
  _ui = _interopRequireDefault(_ui);
  _ajax = _interopRequireDefault(_ajax);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * Parameters.
   */

  /**
   * Options.
   */

  class EmailFieldView extends _varchar.default {
    type = 'email';
    editTemplate = 'fields/email/edit';
    detailTemplate = 'fields/email/detail';
    listTemplate = 'fields/email/list';
    validations = ['required', 'emailData'];
    maxCount = null;
    data() {
      let emailAddressData;
      if (this.mode === this.MODE_EDIT) {
        emailAddressData = Espo.Utils.clone(this.model.get(this.dataFieldName));
        if (this.model.isNew() || !this.model.get(this.name)) {
          if (!emailAddressData || !emailAddressData.length) {
            let optOut;
            if (this.model.isNew()) {
              optOut = this.emailAddressOptedOutByDefault && this.model.entityType !== 'User';
            } else {
              optOut = this.model.get(this.isOptedOutFieldName);
            }
            emailAddressData = [{
              emailAddress: this.model.get(this.name) || '',
              primary: true,
              optOut: optOut,
              invalid: false
            }];
          }
        }
      } else {
        emailAddressData = this.model.get(this.dataFieldName) || false;
      }
      if ((!emailAddressData || emailAddressData.length === 0) && this.model.get(this.name)) {
        emailAddressData = [{
          emailAddress: this.model.get(this.name),
          primary: true,
          optOut: false,
          invalid: false
        }];
      }
      if (emailAddressData) {
        emailAddressData = Espo.Utils.cloneDeep(emailAddressData);
        emailAddressData.forEach(item => {
          const address = item.emailAddress || '';
          item.erased = address.indexOf(this.erasedPlaceholder) === 0;
          item.lineThrough = item.optOut || item.invalid;
        });
      }
      const data = {
        ...super.data(),
        emailAddressData: emailAddressData
      };
      if (this.isReadMode()) {
        data.isOptedOut = this.model.get(this.isOptedOutFieldName);
        data.isInvalid = this.model.get(this.isInvalidFieldName);
        if (this.model.get(this.name)) {
          data.isErased = this.model.get(this.name).indexOf(this.erasedPlaceholder) === 0;
        }
        data.valueIsSet = this.model.has(this.name);
      }
      data.itemMaxLength = this.itemMaxLength;
      data.onlyPrimary = this.params.onlyPrimary;
      return data;
    }
    getAutocompleteMaxCount() {
      if (this.autocompleteMaxCount) {
        return this.autocompleteMaxCount;
      }
      return this.getConfig().get('recordsPerPage');
    }

    // noinspection JSUnusedGlobalSymbols
    validateEmailData() {
      const data = this.model.get(this.dataFieldName);
      if (!data || !data.length) {
        return false;
      }
      const addressList = [];
      const regExp = new RegExp(/^[-!#$%&'*+/=?^_`{|}~A-Za-z0-9]+(?:\.[-!#$%&'*+/=?^_`{|}~A-Za-z0-9]+)*/.source + /@([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])?\.)+[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9]/.source);
      let notValid = false;
      data.forEach((row, i) => {
        const address = row.emailAddress || '';
        const addressLowerCase = String(address).toLowerCase();
        if (!regExp.test(addressLowerCase) && address.indexOf(this.erasedPlaceholder) !== 0) {
          const msg = this.translate('fieldShouldBeEmail', 'messages').replace('{field}', this.getLabelText());
          this.reRender();
          this.showValidationMessage(msg, 'div.email-address-block:nth-child(' + (i + 1).toString() + ') input');
          notValid = true;
          return false;
        }
        if (addressList.includes(addressLowerCase)) {
          const msg = this.translate('fieldValueDuplicate', 'messages').replace('{field}', this.getLabelText());
          this.showValidationMessage(msg, 'div.email-address-block:nth-child(' + (i + 1).toString() + ') input');
          notValid = true;
          return false;
        }
        addressList.push(addressLowerCase);
      });
      if (notValid) {
        return true;
      }
      return false;
    }
    focusOnLast(cursorAtEnd) {
      const $item = this.$el.find('input.form-control').last();
      $item.focus();
      if (cursorAtEnd && $item[0]) {
        // Not supported for email inputs.
        // $item[0].setSelectionRange($item[0].value.length, $item[0].value.length);
      }
    }
    removeEmailAddress($block) {
      if ($block.parent().children().length === 1) {
        $block.find('input.email-address').val('');
      } else {
        this.removeEmailAddressBlock($block);
      }
      this.trigger('change');
    }
    addEmailAddress() {
      const data = Espo.Utils.cloneDeep(this.fetchEmailAddressData());
      const o = {
        emailAddress: '',
        primary: !data.length,
        optOut: this.emailAddressOptedOutByDefault,
        invalid: false,
        lower: ''
      };
      data.push(o);
      this.model.set(this.dataFieldName, data, {
        silent: true
      });
      this.reRender().then(() => this.focusOnLast());
    }
    removeEmailAddressBlock($block) {
      let changePrimary = false;
      if ($block.find('button[data-property-type="primary"]').hasClass('active')) {
        changePrimary = true;
      }
      $block.remove();
      if (changePrimary) {
        this.$el.find('button[data-property-type="primary"]').first().addClass('active').children().removeClass('text-muted');
      }
      this.manageButtonsVisibility();
      this.manageAddButton();
    }
    setup() {
      this.addActionHandler('mailTo', (_e, target) => this.mailTo(target.dataset.emailAddress));
      this.addActionHandler('switchEmailProperty', (_e, target) => this.switchEmailProperty(target));
      this.addActionHandler('removeEmailAddress', (_e, target) => this.removeEmailAddressHandler(target));
      this.addHandler('change', 'input.email-address', (_e, target) => this.inputChangeHandler(target));
      this.addHandler('keypress', 'input.email-address', () => this.manageAddButton());
      this.addHandler('paste', 'input.email-address', () => setTimeout(() => this.manageAddButton(), 10));
      this.addActionHandler('addEmailAddress', () => this.addEmailAddress());
      this.addHandler('keydown', 'input.email-address', (e, target) => this.inputKeydownHandler(e, target));
      this.dataFieldName = `${this.name}Data`;
      this.isOptedOutFieldName = `${this.name}IsOptedOut`;
      this.isInvalidFieldName = `${this.name}IsInvalid`;
      this.erasedPlaceholder = 'ERASED:';
      this.emailAddressOptedOutByDefault = this.getConfig().get('emailAddressIsOptedOutByDefault');
      this.maxCount = this.getConfig().get('emailAddressMaxCount');
      this.itemMaxLength = this.getMetadata().get(['entityDefs', 'EmailAddress', 'fields', 'name', 'maxLength']) || 255;
      this.validations.push(() => this.validateMaxCount());
    }
    afterRender() {
      super.afterRender();
      this.manageButtonsVisibility();
      this.manageAddButton();
      if (this.mode === this.MODE_SEARCH) {
        var _this$$element;
        const autocomplete = new _autocomplete.default((_this$$element = this.$element) === null || _this$$element === void 0 ? void 0 : _this$$element.get(0), {
          name: this.name,
          autoSelectFirst: true,
          triggerSelectOnValidInput: true,
          focusOnSelect: true,
          minChars: 1,
          forceHide: true,
          handleFocusMode: 1,
          onSelect: item => {
            var _this$$element2;
            (_this$$element2 = this.$element) === null || _this$$element2 === void 0 || _this$$element2.val(item.emailAddress);
          },
          formatResult: item => {
            return this.getHelper().escapeString(item.name) + ' &#60;' + this.getHelper().escapeString(item.id) + '&#62;';
          },
          lookupFunction: async query => {
            const response = await _ajax.default.getRequest('EmailAddress/search', {
              q: query,
              maxSize: this.getAutocompleteMaxCount(),
              entityType: this.entityType
            });
            return response.map(item => {
              return {
                id: item.emailAddress,
                name: item.entityName,
                emailAddress: item.emailAddress,
                entityId: item.entityId,
                entityName: item.entityName,
                entityType: item.entityType,
                data: item.emailAddress,
                value: item.emailAddress
              };
            });
          }
        });
        this.once('render remove', () => autocomplete.dispose());
      }
    }
    validateRequired() {
      if (this.isRequired()) {
        if (!this.model.get(this.name)) {
          const msg = this.translate('fieldIsRequired', 'messages').replace('{field}', this.getLabelText());
          this.showValidationMessage(msg, 'div.email-address-block:nth-child(1) input');
          return true;
        }
      }
      return false;
    }
    validateMaxCount() {
      const maxCount = this.maxCount;
      if (!maxCount) {
        return false;
      }
      const items = this.model.attributes[this.dataFieldName] || [];
      if (items.length <= maxCount) {
        return false;
      }
      const msg = this.translate('fieldExceedsMaxCount', 'messages').replace('{maxCount}', maxCount.toString());
      this.showValidationMessage(msg, 'div.email-address-block:last-child input');
      return true;
    }
    manageAddButton() {
      const $input = this.$el.find('input.email-address');
      let c = 0;
      $input.each((_i, input) => {
        if (input.value !== '') {
          c++;
        }
      });
      if (c === $input.length) {
        this.$el.find('[data-action="addEmailAddress"]').removeClass('disabled').removeAttr('disabled');
        return;
      }
      this.$el.find('[data-action="addEmailAddress"]').addClass('disabled').attr('disabled', 'disabled');
    }
    manageButtonsVisibility() {
      const $primary = this.$el.find('button[data-property-type="primary"]');
      const $remove = this.$el.find('button[data-action="removeEmailAddress"]');
      if ($primary.length > 1) {
        $primary.removeClass('hidden');
        $remove.removeClass('hidden');
      } else {
        $primary.addClass('hidden');
        $remove.addClass('hidden');
      }
    }
    mailTo(emailAddress) {
      var _this$model$collectio;
      const attributes = {
        status: 'Draft',
        to: emailAddress
      };
      const scope = this.model.entityType;
      switch (scope) {
        case 'Account':
        case 'Lead':
          attributes.parentType = scope;
          attributes.parentName = this.model.get('name');
          attributes.parentId = this.model.id;
          break;
        case 'Contact':
          if (this.getConfig().get('b2cMode')) {
            attributes.parentType = 'Contact';
            attributes.parentName = this.model.get('name');
            attributes.parentId = this.model.id;
          } else {
            if (this.model.get('accountId')) {
              attributes.parentType = 'Account';
              attributes.parentName = this.model.get('accountName');
              attributes.parentId = this.model.get('accountId');
            }
          }
          break;
      }
      const parentModel = (_this$model$collectio = this.model.collection) === null || _this$model$collectio === void 0 ? void 0 : _this$model$collectio.parentModel;
      if (parentModel !== null && parentModel !== void 0 && parentModel.entityType && this.checkParentTypeAvailability(parentModel.entityType)) {
        attributes.parentType = parentModel.entityType;
        attributes.parentId = parentModel.id;
        attributes.parentName = parentModel.get('name');
      }
      if (!attributes.parentId) {
        if (this.model.entityType && this.checkParentTypeAvailability(this.model.entityType)) {
          attributes.parentType = this.model.entityType;
          attributes.parentId = this.model.id;
          attributes.parentName = this.model.get('name');
        }
      } else {
        if (attributes.parentType && !this.checkParentTypeAvailability(attributes.parentType)) {
          attributes.parentType = null;
          attributes.parentId = null;
          attributes.parentName = null;
        }
      }
      if (this.model.entityType && ['Contact', 'Lead', 'Account'].includes(this.model.entityType)) {
        attributes.nameHash = {};
        attributes.nameHash[emailAddress] = this.model.get('name');
      }
      const helper = new _mailto.default();
      if (helper.toUse()) {
        document.location.href = helper.composeLink(attributes);
        return;
      }
      const viewName = 'views/modals/compose-email';
      _ui.default.notifyWait();
      this.createView('quickCreate', viewName, {
        attributes: attributes
      }).then(view => {
        view.render();
        _ui.default.notify();
      });
    }
    checkParentTypeAvailability(parentType) {
      const entityTypeList = this.getMetadata().get(['entityDefs', 'Email', 'fields', 'parent', 'entityList']) ?? [];
      return entityTypeList.includes(parentType);
    }
    inputKeydownHandler(e, target) {
      const key = Espo.Utils.getKeyFromKeyEvent(e);
      const $target = $(target);
      if (key === 'Enter') {
        if (!this.$el.find('[data-action="addEmailAddress"]').hasClass('disabled')) {
          this.addEmailAddress();
          e.stopPropagation();
        }
        return;
      }
      if (key === 'Backspace' && $target.val() === '') {
        const $block = $target.closest('div.email-address-block');
        this._itemJustRemoved = true;
        setTimeout(() => this._itemJustRemoved = false, 100);
        e.stopPropagation();
        this.removeEmailAddress($block);
        setTimeout(() => this.focusOnLast(true), 50);
      }
    }
    inputChangeHandler(target) {
      const input = target;
      const $block = $(target).closest('div.email-address-block');
      if (this._itemJustRemoved) {
        return;
      }
      if (input.value === '' && $block.length) {
        this.removeEmailAddress($block);
      } else {
        this.trigger('change');
      }
      this.trigger('change');
      this.manageAddButton();
    }
    removeEmailAddressHandler(target) {
      const $block = $(target).closest('div.email-address-block');
      this.removeEmailAddress($block);
      const $last = this.$el.find('.email-address').last();
      if ($last.length) {
        // noinspection JSUnresolvedReference
        $last[0].focus({
          preventScroll: true
        });
      }
    }
    switchEmailProperty(target) {
      const $target = $(target);
      const $block = $(target).closest('div.email-address-block');
      const property = $target.data('property-type');
      const $input = $block.find('input.email-address');
      if (property === 'primary') {
        if (!$target.hasClass('active')) {
          if ($input.val() !== '') {
            this.$el.find('button.email-property[data-property-type="primary"]').removeClass('active').children().addClass('text-muted');
            $target.addClass('active').children().removeClass('text-muted');
          }
        }
        this.trigger('change');
        return;
      }
      let active = false;
      if ($target.hasClass('active')) {
        $target.removeClass('active').children().addClass('text-muted');
      } else {
        $target.addClass('active').children().removeClass('text-muted');
        active = true;
      }
      if (property === 'optOut') {
        active ? $input.addClass('text-strikethrough') : $input.removeClass('text-strikethrough');
      }
      if (property === 'invalid') {
        active ? $input.addClass('text-danger') : $input.removeClass('text-danger');
      }
      this.trigger('change');
    }

    /**
     * @return {{
     *     emailAddress: string,
     *     primary: boolean,
     *     optOut: boolean,
     *     invalid: boolean,
     *     lower: string,
     * }[]}
     */
    fetchEmailAddressData() {
      const data = [];
      const $list = this.$el.find('div.email-address-block');
      if ($list.length) {
        $list.each((_i, itemElement) => {
          const row = {};
          const $d = $(itemElement);
          row.emailAddress = $d.find('input.email-address').val().trim();
          if (row.emailAddress === '') {
            return;
          }
          row.primary = $d.find('button[data-property-type="primary"]').hasClass('active');
          row.optOut = $d.find('button[data-property-type="optOut"]').hasClass('active');
          row.invalid = $d.find('button[data-property-type="invalid"]').hasClass('active');
          row.lower = row.emailAddress.toLowerCase();
          data.push(row);
        });
      }
      return data;
    }
    fetch() {
      const data = {};
      const addressData = this.fetchEmailAddressData();
      if (this.params.onlyPrimary) {
        if (addressData.length > 0) {
          data[this.name] = addressData[0].emailAddress;
          data[this.dataFieldName] = [{
            emailAddress: addressData[0].emailAddress,
            lower: addressData[0].lower,
            primary: true
          }];
        } else {
          data[this.name] = null;
          data[this.dataFieldName] = null;
        }
        return data;
      }
      data[this.dataFieldName] = addressData;
      data[this.name] = null;
      data[this.isOptedOutFieldName] = false;
      data[this.isInvalidFieldName] = false;
      let primaryIndex = 0;
      addressData.forEach((item, i) => {
        if (item.primary) {
          primaryIndex = i;
          if (item.optOut) {
            data[this.isOptedOutFieldName] = true;
          }
          if (item.invalid) {
            data[this.isInvalidFieldName] = true;
          }
        }
      });
      if (addressData.length && primaryIndex > 0) {
        const t = addressData[0];
        addressData[0] = addressData[primaryIndex];
        addressData[primaryIndex] = t;
      }
      if (addressData.length) {
        data[this.name] = addressData[0].emailAddress;
      } else {
        data[this.isOptedOutFieldName] = null;
        data[this.isInvalidFieldName] = null;
      }
      return data;
    }
    fetchSearch() {
      const type = this.fetchSearchType();
      if (['isEmpty', 'isNotEmpty'].includes(type)) {
        return {
          type: type === 'isEmpty' ? 'isNull' : 'isNotNull',
          attribute: this.name,
          data: {
            type: type
          }
        };
      }
      return super.fetchSearch();
    }
  }
  var _default = _exports.default = EmailFieldView;
});

define("views/fields/decimal", ["exports", "views/fields/int"], function (_exports, _int) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _int = _interopRequireDefault(_int);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/fields/decimal */

  /**
   * A decimal field.
   */
  class DecimalFieldView extends _int.default {
    type = 'decimal';
    editTemplate = 'fields/float/edit';
    decimalMark = '.';
    decimalPlacesRawValue = 10;
    validations = ['required', 'range'];
    setup() {
      super.setup();
      if (this.getPreferences().has('decimalMark')) {
        this.decimalMark = this.getPreferences().get('decimalMark');
      } else if (this.getConfig().has('decimalMark')) {
        this.decimalMark = this.getConfig().get('decimalMark');
      }
      if (!this.decimalMark) {
        this.decimalMark = '.';
      }
      if (this.decimalMark === this.thousandSeparator) {
        this.thousandSeparator = '';
      }
      this.decimalPlaces = this.params.decimalPlaces ?? null;
    }
    setupAutoNumericOptions() {
      // noinspection JSValidateTypes
      this.autoNumericOptions = {
        digitGroupSeparator: this.thousandSeparator || '',
        decimalCharacter: this.decimalMark,
        modifyValueOnWheel: false,
        selectOnFocus: false,
        decimalPlaces: this.decimalPlaces ?? undefined,
        decimalPlacesRawValue: this.decimalPlacesRawValue,
        allowDecimalPadding: true,
        showWarnings: false,
        // @ts-ignore
        formulaMode: true
      };
      if (this.decimalPlaces === null) {
        this.autoNumericOptions.decimalPlaces = this.decimalPlacesRawValue;
        this.autoNumericOptions.decimalPlacesRawValue = this.decimalPlacesRawValue;
        this.autoNumericOptions.allowDecimalPadding = false;
      }
    }
    getValueForDisplay() {
      const value = isNaN(this.model.get(this.name)) ? null : this.model.get(this.name);
      return this.formatNumber(value);
    }
    formatNumber(value) {
      if (this.disableFormatting) {
        return (value === null || value === void 0 ? void 0 : value.toString()) ?? null;
      }
      return this.formatNumberDetail(value);
    }
    formatNumberDetail(value) {
      if (value === null) {
        return '';
      }
      const decimalPlaces = this.decimalPlaces;
      const parts = value.toString().split('.');
      parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, this.thousandSeparator);
      if (decimalPlaces === 0) {
        return parts[0];
      }
      if (decimalPlaces) {
        let decimalPartLength = 0;
        if (parts.length > 1) {
          parts[1] = parts[1].replace(/0+$/, '');
          decimalPartLength = parts[1].length;
        } else {
          parts[1] = '';
        }
        if (decimalPlaces && decimalPartLength < decimalPlaces) {
          const limit = decimalPlaces - decimalPartLength;
          for (let i = 0; i < limit; i++) {
            parts[1] += '0';
          }
        }
      }
      return parts.join(this.decimalMark);
    }
    parse(input) {
      let value = input !== '' ? input : null;
      if (value === null) {
        return null;
      }
      value = value.split(this.thousandSeparator).join('').split(this.decimalMark).join('.');
      return value;
    }
    fetch() {
      var _this$mainInputElemen;
      const rawValue = ((_this$mainInputElemen = this.mainInputElement) === null || _this$mainInputElemen === void 0 ? void 0 : _this$mainInputElemen.value) ?? null;
      const value = this.parse(rawValue);
      return {
        [this.name]: value
      };
    }

    // noinspection JSUnusedGlobalSymbols
    validateRange() {
      const value = this.model.get(this.name);
      if (value === null) {
        return false;
      }
      const minValue = this.params.min;
      const maxValue = this.params.max;
      if (minValue != null && maxValue != null) {
        if (Number(value) < Number(minValue) || Number(value) > Number(maxValue)) {
          const msg = this.translate('fieldShouldBeBetween', 'messages').replace('{field}', this.getLabelText()).replace('{min}', minValue.toString()).replace('{max}', maxValue.toString());
          this.showValidationMessage(msg);
          return true;
        }
        return false;
      }
      if (minValue != null) {
        if (Number(value) < Number(minValue)) {
          const msg = this.translate('fieldShouldBeGreater', 'messages').replace('{field}', this.getLabelText()).replace('{value}', minValue.toString());
          this.showValidationMessage(msg);
          return true;
        }
      } else if (maxValue != null) {
        if (Number(value) > Number(maxValue)) {
          const msg = this.translate('fieldShouldBeLess', 'messages').replace('{field}', this.getLabelText()).replace('{value}', maxValue.toString());
          this.showValidationMessage(msg);
          return true;
        }
      }
      return false;
    }
  }
  var _default = _exports.default = DecimalFieldView;
});

define("views/fields/datetime-short", ["exports", "views/fields/datetime", "moment"], function (_exports, _datetime, _moment) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _datetime = _interopRequireDefault(_datetime);
  _moment = _interopRequireDefault(_moment);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/fields/datetime-short */

  class DatetimeShortFieldView extends _datetime.default {
    /**
     * @protected
     * @type {boolean}
     */
    shortInListMode = true;

    /**
     * @protected
     * @type {boolean}
     */
    shortInDetailMode = true;
    data() {
      const data = super.data();
      if (this.toApplyShort()) {
        data.titleDateValue = super.getDateStringValue();
      }
      return data;
    }

    /**
     * @private
     * @return {boolean}
     */
    toApplyShort() {
      return this.shortInListMode && this.mode === this.MODE_LIST || this.shortInDetailMode && this.mode === this.MODE_DETAIL;
    }
    getDateStringValue() {
      if (!this.toApplyShort()) {
        return super.getDateStringValue();
      }
      const value = this.model.get(this.name);
      if (!value) {
        return super.getDateStringValue();
      }
      let timeFormat = this.getDateTime().timeFormat;
      if (this.params.hasSeconds) {
        timeFormat = timeFormat.replace(/:mm/, ':mm:ss');
      }
      const m = this.getDateTime().toMoment(value);
      const now = (0, _moment.default)().tz(this.getDateTime().timeZone || 'UTC');
      const dt = now.clone().startOf('day');
      const ranges = {
        'today': [dt.unix(), dt.add(1, 'days').unix()],
        'tomorrow': [dt.unix(), dt.add(1, 'days').unix()],
        'yesterday': [dt.add(-3, 'days').unix(), dt.add(1, 'days').unix()]
      };
      if (m.unix() > ranges['yesterday'][0] && m.unix() < ranges['yesterday'][1] && this.getLanguage().has('yesterdayShort', 'strings', 'Global')) {
        return this.translate('yesterdayShort', 'strings') + ' ' + m.format(timeFormat);
      }
      if (m.unix() > now.clone().startOf('day').unix() && m.unix() < now.clone().add(1, 'days').startOf('day').unix()) {
        return m.format(timeFormat);
      }
      const readableFormat = this.getDateTime().getReadableShortDateFormat();
      return m.format('YYYY') === now.format('YYYY') ? m.format(readableFormat) : m.format(readableFormat + ', YY');
    }
  }

  // noinspection JSUnusedGlobalSymbols
  var _default = _exports.default = DatetimeShortFieldView;
});

define("views/fields/currency-converted", ["exports", "views/fields/currency"], function (_exports, _currency) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _currency = _interopRequireDefault(_currency);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class CurrencyConvertedFieldView extends _currency.default {
    data() {
      let data = super.data();
      const currencyValue = this.getConfig().get('defaultCurrency');
      data.currencyValue = currencyValue;
      data.currencySymbol = this.getMetadata().get(['app', 'currency', 'symbolMap', currencyValue]) || '';
      return data;
    }
  }
  var _default = _exports.default = CurrencyConvertedFieldView;
});

define("views/fields/checklist", ["exports", "views/fields/array"], function (_exports, _array) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _array = _interopRequireDefault(_array);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ChecklistFieldView extends _array.default {
    type = 'checklist';
    listTemplate = 'fields/array/list';
    detailTemplate = 'fields/checklist/detail';
    editTemplate = 'fields/checklist/edit';
    isInversed = false;
    data() {
      return {
        optionDataList: this.getOptionDataList(),
        ...super.data()
      };
    }
    setup() {
      super.setup();
      this.params.options = this.params.options ?? [];
      this.isInversed = this.options.isInversed ?? this.isInversed;
    }
    setupFieldEvents() {}
    afterRender() {
      if (this.isSearchMode()) {
        this.renderSearch();
      }
      if (this.isEditMode()) {
        this.$el.find('input').on('change', () => {
          this.trigger('change');
        });
      }
    }
    getOptionDataList() {
      const valueList = this.model.get(this.name) ?? [];
      const list = [];
      (this.params.options ?? []).forEach(item => {
        var _this$translatedOptio;
        let isChecked = valueList.includes(item);
        const dataName = item;
        const id = this.cid + '-' + Espo.Utils.camelCaseToHyphen(item.replace(/\s+/g, '-'));
        if (this.isInversed) {
          isChecked = !isChecked;
        }
        list.push({
          name: item,
          isChecked: isChecked,
          dataName: dataName,
          id: id,
          label: ((_this$translatedOptio = this.translatedOptions) === null || _this$translatedOptio === void 0 ? void 0 : _this$translatedOptio[item]) || item
        });
      });
      return list;
    }
    fetch() {
      const list = [];
      (this.params.options ?? []).forEach(item => {
        const $item = this.$el.find(`input[data-name="${item}"]`);
        let isChecked = $item.get(0) && $item.get(0).checked;
        if (this.isInversed) {
          isChecked = !isChecked;
        }
        if (isChecked) {
          list.push(item);
        }
      });
      return {
        [this.name]: list
      };
    }
    validateRequired() {
      if (!this.isRequired()) {
        return false;
      }
      const value = this.model.get(this.name);
      if (!value || value.length === 0) {
        const msg = this.translate('fieldIsRequired', 'messages').replace('{field}', this.getLabelText());
        this.showValidationMessage(msg, '.checklist-item-container:last-child input');
        return true;
      }
      return false;
    }
    validateMaxCount() {
      if (!this.params.maxCount) {
        return false;
      }
      const itemList = this.model.get(this.name) ?? [];
      if (itemList.length > this.params.maxCount) {
        const msg = this.translate('fieldExceedsMaxCount', 'messages').replace('{field}', this.getLabelText()).replace('{maxCount}', this.params.maxCount.toString());
        this.showValidationMessage(msg, '.checklist-item-container:last-child input');
        return true;
      }
      return false;
    }
  }
  var _default = _exports.default = ChecklistFieldView;
});

define("views/email-template/record/detail", ["exports", "views/record/detail"], function (_exports, _detail) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _detail = _interopRequireDefault(_detail);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _detail.default {
    duplicateAction = true;
    saveAndContinueEditingAction = true;
    setup() {
      super.setup();
      this.listenToInsertField();
      this.hideField('insertField');
      this.on('before:set-edit-mode', () => this.showField('insertField'));
      this.on('before:set-detail-mode', () => this.hideField('insertField'));
    }
    listenToInsertField() {
      this.listenTo(this.model, 'insert-field', /** {entityType: string, field: string} */o => {
        const tag = `{${o.entityType}.${o.field}}`;
        const bodyView = /** @type {import('views/fields/wysiwyg').default} */
        this.getFieldView('body');
        if (!bodyView) {
          return;
        }
        if (this.model.attributes.isHtml) {
          const $anchor = $(window.getSelection().anchorNode);
          if (!$anchor.closest('.note-editing-area').length) {
            return;
          }
          bodyView.insertText(tag);
          return;
        }
        const $body = $(bodyView.element.querySelector('textarea.main-element'));
        let text = $body.val();
        text += tag;
        $body.val(text);
      });
    }
  }
  _exports.default = _default;
});

define("views/email/record/list", ["exports", "views/record/list", "helpers/mass-action"], function (_exports, _list, _massAction) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _list = _interopRequireDefault(_list);
  _massAction = _interopRequireDefault(_massAction);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/email/record/list */

  class EmailListRecordView extends _list.default {
    rowActionsView = 'views/email/record/row-actions/default';
    massActionList = ['remove', 'massUpdate'];

    /**
     * @type {string[]}
     * @private
     */
    toRemoveIdList;
    collectionEventSyncList = ['moving-to-trash', 'retrieving-from-trash', 'moving-to-archive'];
    setup() {
      super.setup();
      if (this.collection.url === this.entityType) {
        this.addMassAction({
          name: 'retrieveFromTrash',
          groupIndex: -6
        }, false);
        this.addMassAction({
          name: 'moveToTrash',
          groupIndex: -5,
          iconClass: 'far fa-trash-can'
        }, false);
        this.addMassAction({
          name: 'moveToArchive',
          groupIndex: -5,
          iconClass: 'far fa-caret-square-down'
        }, false);
        this.addMassAction({
          name: 'moveToFolder',
          groupIndex: -5,
          iconClass: 'far fa-folder'
        }, true);
        this.addMassAction({
          name: 'markAsImportant',
          groupIndex: -4,
          iconClass: 'far fa-star'
        }, false);
        this.addMassAction({
          name: 'markAsNotImportant',
          groupIndex: -4
        }, false);
        this.addMassAction({
          name: 'markAsRead',
          groupIndex: -3,
          iconClass: 'far far fa-envelope-open'
        }, false);
        this.addMassAction({
          name: 'markAsNotRead',
          groupIndex: -3
        }, false);
        this.dropdownItemList.push({
          name: 'markAllAsRead',
          label: 'Mark all as read',
          iconClass: 'far fa-envelope-open'
        });
        this.controlEmailMassActionsVisibility();
        this.listenTo(this.collection, 'select-folder', () => this.controlEmailMassActionsVisibility());
      }
      this.listenTo(this.collection, 'moving-to-trash', (id, keep) => {
        const model = this.collection.get(id);
        if (model) {
          model.attributes.groupFolderId ? model.set('groupFolderStatus', 'Trash') : model.set('inTrash', true);
        }
        if (this.rootData.selectedFolderId !== 'trash' && this.rootData.selectedFolderId !== 'all') {
          if (keep) {
            this.toRemoveIdList.push(id);
            return;
          }
          this.removeRecordFromList(id);
        }
      });
      this.listenTo(this.collection, 'retrieving-from-trash', (id, keep) => {
        const model = this.collection.get(id);
        if (model) {
          model.attributes.groupFolderId ? model.set('groupFolderStatus', null) : model.set('inTrash', false);
        }
        if (this.rootData.selectedFolderId === 'all') {
          return;
        }
        if (this.rootData.selectedFolderId === 'trash') {
          if (keep) {
            this.toRemoveIdList.push(id);
            return;
          }
          this.removeRecordFromList(id);
        }
      });
      this.listenTo(this.collection, 'moving-to-archive', (id, keep) => {
        const model = this.collection.get(id);
        if (model) {
          model.attributes.groupFolderId ? model.set('groupFolderStatus', 'Archive') : model.set('inArchive', true);
        }
        if (this.rootData.selectedFolderId === 'sent' || this.rootData.selectedFolderId === 'all') {
          return;
        }
        if (this.rootData.selectedFolderId !== 'archive') {
          if (keep) {
            this.toRemoveIdList.push(id);
            return;
          }
          this.removeRecordFromList(id);
        }
      });
      this.toRemoveIdList = [];
    }

    /**
     * @internal
     */
    removeQueuedRecord() {
      this.toRemoveIdList.forEach(id => this.removeRecordFromList(id));
    }

    // noinspection JSUnusedGlobalSymbols
    massActionMarkAsRead() {
      const ids = [];
      for (const i in this.checkedList) {
        ids.push(this.checkedList[i]);
      }
      Espo.Ajax.postRequest('Email/inbox/read', {
        ids: ids
      });
      ids.forEach(id => {
        const model = this.collection.get(id);
        if (model) {
          model.set('isRead', true);
        }
      });
    }

    // noinspection JSUnusedGlobalSymbols
    massActionMarkAsNotRead() {
      const ids = [];
      for (const i in this.checkedList) {
        ids.push(this.checkedList[i]);
      }
      Espo.Ajax.deleteRequest('Email/inbox/read', {
        ids: ids
      });
      ids.forEach(id => {
        const model = this.collection.get(id);
        if (model) {
          model.set('isRead', false);
        }
      });
    }
    massActionMarkAsImportant() {
      const ids = [];
      for (const i in this.checkedList) {
        ids.push(this.checkedList[i]);
      }
      Espo.Ajax.postRequest('Email/inbox/important', {
        ids: ids
      });
      ids.forEach(id => {
        const model = this.collection.get(id);
        if (model) {
          model.set('isImportant', true);
        }
      });
    }
    massActionMarkAsNotImportant() {
      const ids = [];
      for (const i in this.checkedList) {
        ids.push(this.checkedList[i]);
      }
      Espo.Ajax.deleteRequest('Email/inbox/important', {
        ids: ids
      });
      ids.forEach(id => {
        const model = this.collection.get(id);
        if (model) {
          model.set('isImportant', false);
        }
      });
    }

    // noinspection JSUnusedGlobalSymbols
    massActionMoveToTrash() {
      const ids = [];
      for (const i in this.checkedList) {
        ids.push(this.checkedList[i]);
      }
      Espo.Ajax.postRequest('Email/inbox/inTrash', {
        ids: ids
      }).then(() => {
        Espo.Ui.warning(this.translate('Moved to Trash', 'labels', 'Email'));
      });
      if (this.rootData.selectedFolderId === 'trash') {
        return;
      }
      ids.forEach(id => {
        this.collection.trigger('moving-to-trash', id);
        this.uncheckRecord(id, true);
      });
    }

    // noinspection JSUnusedGlobalSymbols
    massActionRetrieveFromTrash() {
      const ids = [];
      for (const i in this.checkedList) {
        ids.push(this.checkedList[i]);
      }
      Espo.Ajax.deleteRequest('Email/inbox/inTrash', {
        ids: ids
      }).then(() => {
        Espo.Ui.success(this.translate('Done'));
      });
      if (this.rootData.selectedFolderId !== 'trash') {
        return;
      }
      ids.forEach(id => {
        this.collection.trigger('retrieving-from-trash', id);
        this.uncheckRecord(id, true);
      });
    }

    /**
     * @param {string} folderId
     */
    async massMoveToFolder(folderId) {
      const params = this.getMassActionSelectionPostData();
      const helper = new _massAction.default(this);
      const idle = !!params.searchParams && helper.checkIsIdle();
      Espo.Ui.notify(this.translate('pleaseWait', 'messages'));

      /** @type {{id?: string, count?: number}} */
      const result = await Espo.Ajax.postRequest('MassAction', {
        entityType: this.entityType,
        action: 'moveToFolder',
        params: params,
        idle: idle,
        data: {
          folderId: folderId
        }
      });
      Espo.Ui.notify();
      if (result.id) {
        const view = await helper.process(result.id, 'moveToFolder');
        this.listenToOnce(view, 'close:success', async () => {
          await this.collection.fetch();
          Espo.Ui.success(this.translate('Done'));
        });
        return;
      }
      if (result.count === 0) {
        Espo.Ui.warning(this.translate('No Records Moved', 'labels', 'Email'));
        return;
      }
      if (folderId === 'archive') {
        [...this.checkedList].forEach(id => {
          this.collection.trigger('moving-to-archive', id);
          this.uncheckRecord(id, true);
        });
        Espo.Ui.info(this.translate('Moved to Archive', 'labels', 'Email'));
        return;
      }
      await this.collection.fetch();
      Espo.Ui.success(this.translate('Done'));
    }

    /**
     * @private
     * @return {string|null|undefined}
     */
    getSelectedFolderId() {
      return this.rootData.selectedFolderId;
    }

    // noinspection JSUnusedGlobalSymbols
    massActionMoveToFolder() {
      const selectedFolderId = this.getSelectedFolderId();
      this.createView('dialog', 'views/email-folder/modals/select-folder', {
        headerText: this.translate('Move to Folder', 'labels', 'Email'),
        isGroup: selectedFolderId && (selectedFolderId.startsWith('group:') || selectedFolderId === 'all'),
        noArchive: selectedFolderId === 'all',
        currentFolderId: this.rootData.selectedFolderId
      }, view => {
        view.render();
        this.listenToOnce(view, 'select', async folderId => {
          this.clearView('dialog');
          if (this.allResultIsChecked) {
            await this.confirm(this.translate('confirmation', 'messages'));
          }
          await this.massMoveToFolder(folderId);
        });
      });
    }

    // noinspection JSUnusedGlobalSymbols
    massActionMoveToArchive() {
      this.massMoveToFolder('archive');
    }
    actionMarkAsImportant(data) {
      data = data || {};
      const id = data.id;
      Espo.Ajax.postRequest('Email/inbox/important', {
        id: id
      });
      const model = this.collection.get(id);
      if (model) {
        model.set('isImportant', true);
      }
    }
    actionMarkAsNotImportant(data) {
      data = data || {};
      const id = data.id;
      Espo.Ajax.deleteRequest('Email/inbox/important', {
        id: id
      });
      const model = this.collection.get(id);
      if (model) {
        model.set('isImportant', false);
      }
    }
    actionMarkAllAsRead() {
      Espo.Ajax.postRequest('Email/inbox/read', {
        all: true
      });
      this.collection.forEach(model => {
        model.set('isRead', true);
      });
      this.collection.trigger('all-marked-read');
    }

    // noinspection JSUnusedGlobalSymbols
    actionMoveToArchive(data) {
      const id = data.id;
      Espo.Ui.notifyWait();
      Espo.Ajax.postRequest('Email/inbox/folders/archive', {
        id: id
      }).then(() => {
        Espo.Ui.info(this.translate('Moved to Archive', 'labels', 'Email'));
        this.collection.trigger('moving-to-archive', id);
      });
    }
    actionMoveToTrash(data) {
      const id = data.id;
      Espo.Ui.notifyWait();
      Espo.Ajax.postRequest('Email/inbox/inTrash', {
        id: id
      }).then(() => {
        Espo.Ui.warning(this.translate('Moved to Trash', 'labels', 'Email'));
        this.collection.trigger('moving-to-trash', id);
      });
    }

    // noinspection JSUnusedGlobalSymbols
    actionRetrieveFromTrash(data) {
      const id = data.id;
      Espo.Ui.notifyWait();
      this.retrieveFromTrash(id).then(() => {
        Espo.Ui.warning(this.translate('Retrieved from Trash', 'labels', 'Email'));
        this.collection.trigger('retrieving-from-trash', id);
      });
    }

    /**
     * @param {string} id
     * @return {Promise}
     */
    retrieveFromTrash(id) {
      return Espo.Ajax.deleteRequest('Email/inbox/inTrash', {
        id: id
      });
    }
    massRetrieveFromTrashMoveToFolder(folderId) {
      const ids = [];
      for (const i in this.checkedList) {
        ids.push(this.checkedList[i]);
      }
      Espo.Ajax.deleteRequest('Email/inbox/inTrash', {
        ids: ids
      }).then(() => {
        ids.forEach(id => {
          this.collection.trigger('retrieving-from-trash', id);
        });
        return Espo.Ajax.postRequest(`Email/inbox/folders/${folderId}`, {
          ids: ids
        }).then(() => {
          Espo.Ui.success(this.translate('Done'));
        });
      });
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * @todo Use one API request.
     */
    actionRetrieveFromTrashMoveToFolder(data) {
      const id = data.id;
      const folderId = data.folderId;
      Espo.Ui.notifyWait();
      this.retrieveFromTrash(id).then(() => {
        return this.moveToFolder(id, folderId);
      }).then(() => {
        this.collection.fetch().then(() => {
          Espo.Ui.success(this.translate('Done'));
        });
      });
    }

    /**
     * @param {string} id
     * @param {string} folderId
     * @return {Promise}
     */
    moveToFolder(id, folderId) {
      return Espo.Ajax.postRequest(`Email/inbox/folders/${folderId}`, {
        id: id
      });
    }
    actionMoveToFolder(data) {
      const id = data.id;
      const folderId = data.folderId;
      if (folderId) {
        Espo.Ui.notifyWait();
        this.moveToFolder(id, folderId).then(() => {
          if (folderId === 'archive') {
            this.collection.trigger('moving-to-archive', id);
            Espo.Ui.info(this.translate('Moved to Archive', 'labels', 'Email'));
            return;
          }
          this.collection.fetch().then(() => Espo.Ui.success(this.translate('Done')));
        });
        return;
      }
      const model = this.collection.get(id);
      if (!model) {
        return;
      }
      const currentFolderId = this.rootData.selectedFolderId;
      this.createView('dialog', 'views/email-folder/modals/select-folder', {
        headerText: this.translate('Move to Folder', 'labels', 'Email'),
        isGroup: !!model.attributes.groupFolderId || !model.attributes.isUsers,
        noArchive: !model.attributes.groupFolderId && !model.attributes.isUsers,
        currentFolderId: currentFolderId
      }, view => {
        view.render();
        this.listenToOnce(view, 'select', folderId => {
          this.clearView('dialog');
          Espo.Ui.notifyWait();
          this.moveToFolder(id, folderId).then(() => {
            this.collection.fetch().then(() => {
              Espo.Ui.success(this.translate('Done'));
            });
          });
        });
      });
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * @private
     * @param {{id: string}} data
     */
    actionMarkAsRead(data) {
      const id = data.id;
      const model = this.collection.get(id);
      Espo.Ajax.postRequest('Email/inbox/read', {
        ids: [id]
      });
      if (model) {
        model.set('isRead', true);
      }
    }

    // noinspection JSUnusedGlobalSymbols
    actionSend(data) {
      const id = data.id;
      this.confirm({
        message: this.translate('sendConfirm', 'messages', 'Email'),
        confirmText: this.translate('Send', 'labels', 'Email')
      }).then(() => {
        const model = this.collection.get(id);
        if (!model) {
          return;
        }
        Espo.Ui.notify(this.translate('Sending...', 'labels', 'Email'));
        model.save({
          status: 'Sending'
        }).then(() => {
          Espo.Ui.success(this.translate('emailSent', 'messages', 'Email'));
          if (this.rootData.selectedFolderId === 'drafts') {
            this.removeRecordFromList(id);
            this.uncheckRecord(id, true);
            this.collection.trigger('draft-sent');
          }
        });
      });
    }

    // noinspection JSUnusedGlobalSymbols
    toggleMassMarkAsImportant() {
      const allImportant = !this.checkedList.map(id => this.collection.get(id)).find(m => !m.get('isImportant'));
      if (allImportant) {
        this.massActionMarkAsNotImportant();
        return;
      }
      this.massActionMarkAsImportant();
    }

    /**
     * @private
     */
    controlEmailMassActionsVisibility() {
      const moveToArchive = this.rootData.selectedFolderId !== 'trash' && this.rootData.selectedFolderId !== 'archive' && this.rootData.selectedFolderId !== 'all';
      const moveToTrash = this.rootData.selectedFolderId !== 'trash' && this.rootData.selectedFolderId !== 'all';
      const markAsImportant = this.rootData.selectedFolderId !== 'important' && this.rootData.selectedFolderId !== 'all';
      const markAsNotRead = this.rootData.selectedFolderId !== 'all';
      moveToArchive ? this.showMassAction('moveToArchive') : this.hideMassAction('moveToArchive');
      moveToTrash ? this.showMassAction('moveToTrash') : this.hideMassAction('moveToTrash');
      markAsImportant ? this.showMassAction('markAsImportant') : this.hideMassAction('markAsImportant');
      markAsNotRead ? this.showMassAction('markAsNotRead') : this.hideMassAction('markAsNotRead');
      if (this.rootData.selectedFolderId === 'trash') {
        this.showMassAction('retrieveFromTrash');
      } else {
        this.hideMassAction('retrieveFromTrash');
      }
    }
  }
  var _default = _exports.default = EmailListRecordView;
});

define("views/email/record/edit", ["exports", "views/record/edit", "views/email/record/detail"], function (_exports, _edit, _detail) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _edit = _interopRequireDefault(_edit);
  _detail = _interopRequireDefault(_detail);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/email/record/edit */

  class EmailEditRecordView extends _edit.default {
    init() {
      super.init();
      _detail.default.prototype.layoutNameConfigure.call(this);
    }
    setup() {
      super.setup();
      if (['Archived', 'Sent'].includes(this.model.get('status'))) {
        this.shortcutKeyCtrlEnterAction = 'save';
      }
      this.addDropdownItem({
        name: 'send',
        label: 'Send',
        onClick: () => this.actionSend()
      });
      this.controlSendButton();
      if (this.model.get('status') === 'Draft') {
        this.setFieldReadOnly('dateSent');

        // Not implemented for detail view yet.
        this.hideField('selectTemplate');
      }
      this.handleAttachmentField();
      this.handleCcField();
      this.handleBccField();
      this.listenTo(this.model, 'change:attachmentsIds', () => this.handleAttachmentField());
      this.listenTo(this.model, 'change:cc', () => this.handleCcField());
      this.listenTo(this.model, 'change:bcc', () => this.handleBccField());
    }
    handleAttachmentField() {
      if ((this.model.get('attachmentsIds') || []).length === 0 && !this.isNew && this.model.get('status') !== 'Draft') {
        this.hideField('attachments');
        return;
      }
      this.showField('attachments');
    }
    handleCcField() {
      if (!this.model.get('cc') && this.model.get('status') !== 'Draft') {
        this.hideField('cc');
      } else {
        this.showField('cc');
      }
    }
    handleBccField() {
      if (!this.model.get('bcc') && this.model.get('status') !== 'Draft') {
        this.hideField('bcc');
      } else {
        this.showField('bcc');
      }
    }
    controlSendButton() {
      const status = this.model.get('status');
      if (status === 'Draft') {
        this.showActionItem('send');
        return;
      }
      this.hideActionItem('send');
    }

    // noinspection JSUnusedGlobalSymbols
    actionSaveDraft() {
      this.actionSaveAndContinueEditing();
    }

    // noinspection JSUnusedGlobalSymbols
    actionSend() {
      _detail.default.prototype.send.call(this).then(() => this.exit()).catch(() => {});
    }

    /**
     * @protected
     * @param {KeyboardEvent} e
     */
    handleShortcutKeyCtrlS(e) {
      if (this.inlineEditModeIsOn || this.buttonsDisabled) {
        return;
      }
      e.preventDefault();
      e.stopPropagation();
      if (this.mode !== this.MODE_EDIT) {
        return;
      }
      if (!this.saveAndContinueEditingAction) {
        return;
      }
      if (!this.hasAvailableActionItem('saveAndContinueEditing')) {
        return;
      }
      this.actionSaveAndContinueEditing();
    }
  }
  var _default = _exports.default = EmailEditRecordView;
});

define("views/email/modals/schedule-send", ["exports", "views/modal", "model", "views/record/edit-for-modal", "views/fields/datetime", "moment"], function (_exports, _modal, _model, _editForModal, _datetime, _moment) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  _model = _interopRequireDefault(_model);
  _editForModal = _interopRequireDefault(_editForModal);
  _datetime = _interopRequireDefault(_datetime);
  _moment = _interopRequireDefault(_moment);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  // noinspection JSUnusedGlobalSymbols
  class EmailScheduleSendModalView extends _modal.default {
    // language=Handlebars
    templateContent = `<div class="record no-side-margin">{{{record}}}</div>`;

    /**
     * @type {Model}
     */
    formModel;

    /**
     * @type {EditForModalRecordView}
     */
    recordView;

    /**
     * @param {{
     *     model: import('model').default,
     *     onSave: function(): void,
     * }} options
     */
    constructor(options) {
      super(options);
      this.onSave = options.onSave;
    }
    setup() {
      this.headerText = this.translate('Schedule Send', 'labels', 'Email');
      this.buttonList.push({
        name: 'schedule',
        label: 'Schedule',
        style: 'danger',
        onClick: () => this.actionSchedule()
      });
      this.buttonList.push({
        name: 'cancel',
        label: 'Cancel',
        onClick: () => this.close()
      });
      this.formModel = new _model.default({
        now: this.getDateTime().getNow(),
        sendAt: this.getSendAt()
      });
      this.recordView = new _editForModal.default({
        model: this.formModel,
        detailLayout: [{
          rows: [[{
            view: new _datetime.default({
              name: 'sendAt',
              labelText: this.translate('sendAt', 'fields', 'Email'),
              params: {
                required: true,
                after: 'now'
              },
              otherFieldLabelText: this.translate('Now')
            })
          }, false]]
        }]
      });
      this.assignView('record', this.recordView, '.record');
    }

    /**
     * @private
     * @return {string}
     */
    getSendAt() {
      const sendAtMoment = _moment.default.utc(this.getDateTime().getNow(10));
      if (sendAtMoment.isBefore((0, _moment.default)().add(1, 'minutes'))) {
        sendAtMoment.add(10, 'minutes');
      }
      return sendAtMoment.format(this.getDateTime().internalDateTimeFormat);
    }
    async actionSchedule() {
      if (this.recordView.validate()) {
        return;
      }
      this.disableButton('schedule');
      Espo.Ui.notifyWait();
      this.model.set({
        status: 'Draft',
        sendAt: this.formModel.attributes.sendAt
      });
      try {
        await this.model.save();
      } catch (e) {
        this.enableButton('schedule');
        return;
      }
      const name = this.model.attributes.subject;
      const url = `#Email/view/${this.model.id}`;
      const message = this.translate('Scheduled') + '\n' + `[${name}](${url})`;
      Espo.Ui.notify(message, 'success', 4000);
      this.onSave();
    }
  }
  _exports.default = EmailScheduleSendModalView;
});

define("views/email/modals/import-eml", ["exports", "views/modal", "views/record/edit-for-modal", "model", "views/fields/file"], function (_exports, _modal, _editForModal, _model, _file) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  _editForModal = _interopRequireDefault(_editForModal);
  _model = _interopRequireDefault(_model);
  _file = _interopRequireDefault(_file);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ImportEmlModal extends _modal.default {
    // language=Handlebars
    templateContent = `
        <div class="record no-side-margin">{{{record}}}</div>
    `;
    setup() {
      this.headerText = this.translate('Import EML', 'labels', 'Email');
      this.addButton({
        name: 'import',
        label: 'Proceed',
        style: 'danger',
        onClick: () => this.actionImport()
      });
      this.addButton({
        name: 'cancel',
        label: 'Cancel',
        onClick: () => this.close()
      });
      this.model = new _model.default({}, {
        entityType: 'ImportEml'
      });
      this.recordView = new _editForModal.default({
        model: this.model,
        detailLayout: [{
          rows: [[{
            view: new _file.default({
              name: 'file',
              params: {
                required: true,
                accept: ['.eml']
              },
              labelText: this.translate('file', 'otherFields', 'Email')
            })
          }]]
        }]
      });
      this.assignView('record', this.recordView, '.record');
    }
    actionImport() {
      if (this.recordView.validate()) {
        return;
      }
      this.disableButton('import');
      Espo.Ui.notifyWait();
      Espo.Ajax.postRequest('Email/importEml', {
        fileId: this.model.attributes.fileId
      }).then(/** {id: string} */response => {
        Espo.Ui.notify(false);
        this.getRouter().navigate(`Email/view/${response.id}`, {
          trigger: true
        });
      }).catch(() => this.enableButton('import'));
    }
  }
  var _default = _exports.default = ImportEmlModal;
});

define("views/email/fields/person-string-data", ["exports", "views/fields/varchar"], function (_exports, _varchar) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _varchar = _interopRequireDefault(_varchar);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _varchar.default {
    listTemplate = 'email/fields/person-string-data/list';
    getAttributeList() {
      return ['personStringData', 'isReplied'];
    }
    data() {
      const data = super.data();
      data.isReplied = this.model.get('isReplied');
      return data;
    }
  }
  _exports.default = _default;
});

define("views/email/fields/from-address-varchar", ["exports", "views/fields/base", "views/email/fields/email-address", "helpers/record-modal", "email-helper"], function (_exports, _base, _emailAddress, _recordModal, _emailHelper) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  _emailAddress = _interopRequireDefault(_emailAddress);
  _recordModal = _interopRequireDefault(_recordModal);
  _emailHelper = _interopRequireDefault(_emailHelper);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EmailFromAddressVarchar extends _base.default {
    // language=Handlebars
    listTemplateContent = `
        {{#if value}}{{{value}}}{{/if}}
    `;
    detailTemplate = 'email/fields/email-address-varchar/detail';
    validations = ['required', 'email'];
    skipCurrentInAutocomplete = true;
    emailAddressRegExp = new RegExp(/^[-!#$%&'*+/=?^_`{|}~A-Za-z0-9]+(?:\.[-!#$%&'*+/=?^_`{|}~A-Za-z0-9]+)*/.source + /@([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])?\.)+[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9]/.source);
    setup() {
      super.setup();
      this.erasedPlaceholder = 'ERASED:';
      this.on('render', () => {
        if (this.mode === this.MODE_SEARCH) {
          return;
        }
        this.initAddressList();
      });
    }
    events = {
      /** @this EmailFromAddressVarchar */
      'click [data-action="createContact"]': function (e) {
        const address = $(e.currentTarget).data('address');
        this.createPerson('Contact', address);
      },
      /** @this EmailFromAddressVarchar */
      'click [data-action="createLead"]': function (e) {
        const address = $(e.currentTarget).data('address');
        this.createPerson('Lead', address);
      },
      /** @this EmailFromAddressVarchar */
      'click [data-action="addToContact"]': function (e) {
        const address = $(e.currentTarget).data('address');
        this.addToPerson('Contact', address);
      },
      /** @this EmailFromAddressVarchar */
      'click [data-action="addToLead"]': function (e) {
        const address = $(e.currentTarget).data('address');
        this.addToPerson('Lead', address);
      },
      /** @this EmailFromAddressVarchar */
      'auxclick a[href][data-scope][data-id]': function (e) {
        const isCombination = e.button === 1 && (e.ctrlKey || e.metaKey);
        if (!isCombination) {
          return;
        }
        const $target = $(e.currentTarget);
        const id = $target.attr('data-id');
        const scope = $target.attr('data-scope');
        e.preventDefault();
        e.stopPropagation();
        this.quickView({
          id: id,
          scope: scope
        });
      }
    };

    // noinspection JSCheckFunctionSignatures
    data() {
      const data = super.data();
      const address = this.model.get(this.name);
      if (address && !(address in this.idHash) && this.model.get('parentId')) {
        if (this.getAcl().check('Contact', 'edit')) {
          data.showCreate = true;
        }
      }
      data.valueIsSet = this.model.has(this.name);
      return data;
    }
    afterRender() {
      super.afterRender();
      if (this.mode === this.MODE_SEARCH && this.getAcl().check('Email', 'create')) {
        _emailAddress.default.prototype.initSearchAutocomplete.call(this);
      }
      if (this.mode === this.MODE_EDIT && this.getAcl().check('Email', 'create')) {
        _emailAddress.default.prototype.initSearchAutocomplete.call(this);
      }
      if (this.mode === this.MODE_SEARCH) {
        this.$input.on('input', () => {
          this.trigger('change');
        });
      }
    }

    // noinspection JSUnusedGlobalSymbols
    getAutocompleteMaxCount() {
      return _emailAddress.default.prototype.getAutocompleteMaxCount.call(this);
    }
    initAddressList() {
      this.nameHash = {};
      this.typeHash = this.model.get('typeHash') || {};
      this.idHash = this.model.get('idHash') || {};
      _.extend(this.nameHash, this.model.get('nameHash') || {});
    }
    getAttributeList() {
      const list = super.getAttributeList();
      list.push('nameHash');
      list.push('idHash');
      list.push('accountId');
      return list;
    }
    getValueForDisplay() {
      if (this.mode === this.MODE_DETAIL || this.mode === this.MODE_LIST) {
        const address = this.model.get(this.name);
        return this.getDetailAddressHtml(address);
      }
      return super.getValueForDisplay();
    }

    /**
     * @protected
     * @param {string} address
     * @return {string}
     */
    getDetailAddressHtml(address) {
      if (!address) {
        return '';
      }
      const fromString = this.model.get('fromString') || this.model.get('fromName');
      const name = this.nameHash[address] || this.parseNameFromStringAddress(fromString) || null;
      const entityType = this.typeHash[address] || null;
      const id = this.idHash[address] || null;
      if (id) {
        let avatarHtml = '';
        if (entityType === 'User') {
          const size = this.mode === this.MODE_DETAIL ? 18 : 16;
          avatarHtml = this.getHelper().getAvatarHtml(id, 'small', size, 'avatar-link');
        } else if (entityType) {
          avatarHtml = this.getHelper().getScopeColorIconHtml(entityType);
        }
        const title = this.mode === this.MODE_LIST ? name : null;
        const className = this.mode === this.MODE_LIST ? 'text-default' : 'text-record';
        const $item = $('<div class="email-address-detail-item">').append(avatarHtml, $('<a>').attr('href', `#${entityType}/view/${id}`).attr('data-scope', entityType).attr('data-id', id).attr('title', title).addClass(className).text(name));
        if (this.mode === this.MODE_DETAIL) {
          $item.append(' ', $('<span>').addClass('text-muted middle-dot'), ' ', $('<span>').text(address));
        }
        return $item.get(0).outerHTML;
      }
      const $div = $('<div>');
      $div.addClass('email-address-lines-container');
      if (this.mode !== this.MODE_LIST && (this.getAcl().check('Contact', 'create') || this.getAcl().check('Lead', 'create'))) {
        $div.append(this.getCreateHtml(address));
      }
      if (name) {
        const $span = $('<span>').addClass('email-address-line').text(name);
        if (this.mode === this.MODE_DETAIL) {
          $span.append(' ', $('<span>').addClass('text-muted middle-dot'), ' ', $('<span>').text(address));
        }
        $div.append($span);
        return $div.get(0).outerHTML;
      }
      $div.append($('<span>').addClass('email-address-line').text(address));
      return $div.get(0).outerHTML;
    }
    getCreateHtml(address) {
      const $ul = $('<ul>').addClass('dropdown-menu').attr('role', 'menu');
      const $container = $('<span>').addClass('dropdown email-address-create-dropdown pull-right').append($('<button>').addClass('dropdown-toggle btn btn-link btn-sm').attr('data-toggle', 'dropdown').append($('<span>').addClass('caret text-muted')), $ul);
      if (this.getAcl().check('Contact', 'create')) {
        $ul.append($('<li>').append($('<a>').attr('role', 'button').attr('tabindex', '0').attr('data-action', 'createContact').attr('data-address', address).append((() => {
          const span = document.createElement('span');
          span.className = 'item-icon fas fa-plus';
          return span;
        })()).append((() => {
          const span = document.createElement('span');
          span.className = 'item-text';
          span.textContent = this.translate('Create Contact', 'labels', 'Email');
          return span;
        })())));
      }
      if (this.getAcl().check('Lead', 'create')) {
        $ul.append($('<li>').append($('<a>').attr('role', 'button').attr('tabindex', '0').attr('data-action', 'createLead').attr('data-address', address).append((() => {
          const span = document.createElement('span');
          span.className = 'item-icon fas fa-plus';
          return span;
        })()).append((() => {
          const span = document.createElement('span');
          span.className = 'item-text';
          span.textContent = this.translate('Create Lead', 'labels', 'Email');
          return span;
        })())));
      }
      if (this.getAcl().check('Contact', 'edit')) {
        $ul.append($('<li>').append($('<a>').attr('role', 'button').attr('tabindex', '0').attr('data-action', 'addToContact').attr('data-address', address).append((() => {
          const span = document.createElement('span');
          span.className = 'item-icon far fa-square-plus';
          return span;
        })()).append((() => {
          const span = document.createElement('span');
          span.className = 'item-text';
          span.textContent = this.translate('Add to Contact', 'labels', 'Email');
          return span;
        })())));
      }
      if (this.getAcl().check('Lead', 'edit')) {
        $ul.append($('<li>').append($('<a>').attr('role', 'button').attr('tabindex', '0').attr('data-action', 'addToLead').attr('data-address', address).append((() => {
          const span = document.createElement('span');
          span.className = 'item-icon far fa-square-plus';
          return span;
        })()).append((() => {
          const span = document.createElement('span');
          span.className = 'item-text';
          span.textContent = this.translate('Add to Lead', 'labels', 'Email');
          return span;
        })())));
      }
      if (this.name === 'from' && this.getAcl().check('EmailFilter', 'create')) {
        if ($ul.children().length) {
          $ul.append(`<li class="divider"></li>`);
        }
        const url = '#EmailFilter/create?from=' + encodeURI(address) + '&returnUrl=' + encodeURI(this.getRouter().getCurrentUrl());
        $ul.append($('<li>').append($('<a>').attr('tabindex', '0').attr('href', url)
        /*.append(
            (() => {
                const span = document.createElement('span');
                span.className = 'item-icon fas fa-plus';
                return span;
            })()
        )*/.append((() => {
          const span = document.createElement('span');
          span.className = 'item-text';
          span.textContent = this.translate('Create EmailFilter', 'labels', 'EmailFilter');
          return span;
        })())));
      }
      return $container.get(0).outerHTML;
    }

    /**
     * @param {string} value
     * @return {string|null}
     */
    parseNameFromStringAddress(value) {
      value = value || '';
      const emailHelper = new _emailHelper.default();
      return emailHelper.parseNameFromStringAddress(value);
    }

    /**
     * @internal Called with a different context from another view.
     * @param {string} scope
     * @param {string} address
     */
    createPerson(scope, address) {
      const fromString = this.model.get('fromString') || this.model.get('fromName');

      /** @type {string|null} */
      let name = this.nameHash[address] || null;
      if (!name && this.name === 'from' && fromString) {
        const emailHelper = new _emailHelper.default();
        name = emailHelper.parseNameFromStringAddress(fromString);
      }
      if (name) {
        name = EmailFromAddressVarchar.stripQuotesFromName(name);
      }
      const attributes = {
        emailAddress: address
      };
      if (this.model.get('accountId') && scope === 'Contact') {
        attributes.accountId = this.model.get('accountId');
        attributes.accountName = this.model.get('accountName');
      }
      if (name) {
        const firstName = name.split(' ').slice(0, -1).join(' ');
        const lastName = name.split(' ').slice(-1).join(' ');
        attributes.firstName = firstName;
        attributes.lastName = lastName;
      }
      const helper = new _recordModal.default();
      helper.showCreate(this, {
        entityType: scope,
        attributes: attributes,
        afterSave: model => {
          const nameHash = Espo.Utils.clone(this.model.get('nameHash') || {});
          const typeHash = Espo.Utils.clone(this.model.get('typeHash') || {});
          const idHash = Espo.Utils.clone(this.model.get('idHash') || {});
          idHash[address] = model.id;
          nameHash[address] = model.attributes.name;
          typeHash[address] = scope;
          this.idHash = idHash;
          this.nameHash = nameHash;
          this.typeHash = typeHash;
          const attributes = {
            nameHash: nameHash,
            idHash: idHash,
            typeHash: typeHash
          };
          setTimeout(() => {
            this.model.set(attributes);
            if (this.model.attributes.icsContents) {
              this.model.fetch();
            }
          }, 50);
        }
      });
    }

    /**
     * @internal Called with a different context from another view.
     * @param {string} scope
     * @param {string} address
     */
    async addToPerson(scope, address) {
      const fromString = this.model.get('fromString') || this.model.get('fromName');
      let name = this.nameHash[address] || null;
      if (!name && this.name === 'from' && fromString) {
        const emailHelper = new _emailHelper.default();
        name = emailHelper.parseNameFromStringAddress(fromString);
      }
      if (name) {
        name = EmailFromAddressVarchar.stripQuotesFromName(name);
      }
      const attributes = {
        emailAddress: address
      };
      if (this.model.get('accountId') && scope === 'Contact') {
        attributes.accountId = this.model.get('accountId');
        attributes.accountName = this.model.get('accountName');
      }
      const filters = {};
      if (name) {
        filters['name'] = {
          type: 'equals',
          field: 'name',
          value: name
        };
      }
      const afterSave = /** import('model').default */model => {
        const nameHash = Espo.Utils.clone(this.model.get('nameHash') || {});
        const typeHash = Espo.Utils.clone(this.model.get('typeHash') || {});
        const idHash = Espo.Utils.clone(this.model.get('idHash') || {});
        idHash[address] = model.id;
        nameHash[address] = model.attributes.name;
        typeHash[address] = scope;
        this.idHash = idHash;
        this.nameHash = nameHash;
        this.typeHash = typeHash;
        const attributes = {
          nameHash: nameHash,
          idHash: idHash,
          typeHash: typeHash
        };
        setTimeout(() => {
          this.model.set(attributes);
          if (this.model.attributes.icsContents) {
            this.model.fetch();
          }
        }, 50);
      };
      const viewName = this.getMetadata().get(`clientDefs.${scope}.modalViews.select`) || 'views/modals/select-records';

      /** @type {module:views/modals/select-records~Options} */
      const options = {
        entityType: scope,
        createButton: false,
        filters: filters,
        onSelect: async models => {
          const model = models[0];
          if (!model.attributes.emailAddress) {
            await model.save({
              emailAddress: address
            }, {
              patch: true
            });
            afterSave(model);
            return;
          }
          await model.fetch();
          const emailAddressData = [...(model.attributes.emailAddressData || [])];
          emailAddressData.push({
            emailAddress: address,
            primary: emailAddressData.length === 0
          });
          await model.save({
            emailAddressData: emailAddressData
          }, {
            patch: true
          });
          afterSave(model);
        }
      };
      Espo.Ui.notifyWait();
      const view = await this.createView('modal', viewName, options);
      await view.render();
      Espo.Ui.notify();
    }

    /**
     * @private
     * @param {string} name
     * @return {string}
     */
    static stripQuotesFromName(name) {
      if (name && /^(['"]).*\1$/.test(name)) {
        name = name.substring(1, name.length - 1);
      }
      return name;
    }
    fetchSearch() {
      const value = this.$element.val().trim();
      if (value) {
        return {
          type: 'equals',
          value: value
        };
      }
      return null;
    }

    // noinspection JSUnusedGlobalSymbols
    validateEmail() {
      const address = this.model.get(this.name);
      if (!address) {
        return;
      }
      const addressLowerCase = String(address).toLowerCase();
      if (!this.emailAddressRegExp.test(addressLowerCase) && address.indexOf(this.erasedPlaceholder) !== 0) {
        const msg = this.translate('fieldShouldBeEmail', 'messages').replace('{field}', this.getLabelText());
        this.showValidationMessage(msg);
        return true;
      }
    }
    quickView(data) {
      const helper = new _recordModal.default();
      helper.showDetail(this, {
        id: data.id,
        entityType: data.scope
      });
    }
  }
  var _default = _exports.default = EmailFromAddressVarchar;
});

define("views/dashlets/options/base", ["exports", "views/modal", "model", "views/record/edit-for-modal"], function (_exports, _modal, _model, _editForModal) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  _model = _interopRequireDefault(_model);
  _editForModal = _interopRequireDefault(_editForModal);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class BaseDashletOptionsModalView extends _modal.default {
    template = 'dashlets/options/base';
    cssName = 'options-modal';
    className = 'dialog dialog-record';

    /**
     * @protected
     * @type {string}
     */
    name;

    /**
     * @protected
     * @type {boolean}
     */
    escapeDisabled = true;

    /**
     * @protected
     * @type {boolean}
     */
    saveDisabled = false;
    buttonList = [{
      name: 'save',
      label: 'Apply',
      style: 'primary',
      title: 'Ctrl+Enter'
    }, {
      name: 'cancel',
      label: 'Cancel',
      title: 'Esc'
    }];
    shortcutKeys = {
      /** @this BaseDashletOptionsModalView */
      'Control+Enter': function (e) {
        this.handleShortcutKeyCtrlEnter(e);
      },
      /** @this BaseDashletOptionsModalView */
      'Escape': function (e) {
        if (this.saveDisabled) {
          return;
        }
        e.stopPropagation();
        e.preventDefault();
        const focusedFieldView = this.getRecordView().getFocusedFieldView();
        if (focusedFieldView) {
          this.model.set(focusedFieldView.fetch(), {
            skipReRender: true
          });
        }
        if (this.getRecordView().hasChanged()) {
          this.confirm(this.translate('confirmLeaveOutMessage', 'messages')).then(() => this.actionClose());
          return;
        }
        this.actionClose();
      }
    };
    data() {
      return {
        options: this.optionsData
      };
    }
    getDetailLayout() {
      let layout = this.getMetadata().get(['dashlets', this.name, 'options', 'layout']);
      if (layout) {
        return layout;
      }
      layout = [{
        rows: []
      }];
      let i = 0;
      let row = [];
      for (const field in this.fields) {
        if (!(i % 2)) {
          row = [];
          layout[0].rows.push(row);
        }
        row.push({
          name: field
        });
        i++;
      }
      return layout;
    }
    init() {
      super.init();
      this.fields = Espo.Utils.cloneDeep(this.options.fields);
      this.fieldList = Object.keys(this.fields);
      this.optionsData = this.options.optionsData;
      this.name = this.options.name;
    }
    setup() {
      this.id = 'dashlet-options';
      const model = this.model = new _model.default();
      model.name = 'DashletOptions';
      model.setDefs({
        fields: this.fields
      });
      model.set(this.optionsData);
      this.dataObject = {
        dashletName: this.name,
        userId: this.options.userId
      };
      model.dashletName = this.name;
      model.userId = this.options.userId;
      this.middlePanelDefs = {};
      this.middlePanelDefsList = [];
      this.setupBeforeFinal();
      this.recordView = new _editForModal.default({
        model: model,
        detailLayout: this.getDetailLayout(),
        dataObject: this.dataObject
      });
      this.assignView('record', this.recordView, '.record');
      this.$header = $('<span>').append($('<span>').text(this.getLanguage().translate('Dashlet Options')), ' &middot; ', $('<span>').text(this.getLanguage().translate(this.name, 'dashlets')));
    }
    setupBeforeFinal() {}
    onBackdropClick() {
      if (this.getRecordView().hasChanged()) {
        return;
      }
      this.close();
    }

    /**
     * @return {import('views/record/edit').default}
     */
    getRecordView() {
      return this.recordView;
    }

    /**
     * @return {Object|null}
     */
    fetchAttributes() {
      const attributes = this.getRecordView().fetch();
      if (this.getRecordView().validate()) {
        return null;
      }
      return attributes;
    }
    actionSave() {
      const attributes = this.fetchAttributes();
      if (attributes == null) {
        return;
      }
      this.trigger('save', attributes);
    }
    getFieldViews(withHidden) {
      if (!this.hasView('record')) {
        return {};
      }
      return this.getRecordView().getFieldViews(withHidden);
    }
    getFieldView(name) {
      return (this.getFieldViews(true) || {})[name] || null;
    }
    hideField(name, locked) {
      if (!this.getRecordView()) {
        this.whenRendered().then(() => this.hideField(name), locked);
        return;
      }
      this.getRecordView().hideField(name, locked);
    }
    showField(name) {
      if (!this.getRecordView()) {
        this.whenRendered().then(() => this.showField(name));
        return;
      }
      this.getRecordView().showField(name);
    }

    /**
     * @protected
     * @param {KeyboardEvent} e
     */
    handleShortcutKeyCtrlEnter(e) {
      e.preventDefault();
      e.stopPropagation();
      if (document.activeElement instanceof HTMLInputElement) {
        document.activeElement.dispatchEvent(new Event('change', {
          bubbles: true
        }));
      }
      this.actionSave();
    }
  }
  var _default = _exports.default = BaseDashletOptionsModalView;
});

define("views/dashlets/fields/records/expanded-layout/modals/edit-item", ["exports", "views/modal", "views/record/edit-for-modal", "model", "views/fields/bool"], function (_exports, _modal, _editForModal, _model, _bool) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  _editForModal = _interopRequireDefault(_editForModal);
  _model = _interopRequireDefault(_model);
  _bool = _interopRequireDefault(_bool);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ExpandedLayoutEditItemModalFieldView extends _modal.default {
    // language=Handlebars
    templateContent = `
        <div class="record-container no-side-margin">{{{record}}}</div>
    `;

    /**
     * @private
     * @type {EditForModalRecordView}
     */
    recordView;

    /**
     * @private
     * @type {Model}
     */
    formModel;

    /**
     * @param {{
     *     onApply: function({soft: boolean, small: boolean}),
     *     label: string,
     *     data: {
     *         soft: boolean,
     *         small: boolean,
     *     },
     * }} options
     */
    constructor(options) {
      super();
      this.options = options;
    }
    setup() {
      this.headerText = this.translate('Edit') + ' · ' + this.options.label;
      this.formModel = new _model.default();
      this.formModel.setMultiple({
        ...this.options.data
      });
      this.recordView = new _editForModal.default({
        model: this.formModel,
        detailLayout: [{
          rows: [[{
            view: new _bool.default({
              name: 'soft',
              labelText: this.translate('soft', 'otherFields', 'DashletOptions')
            })
          }, {
            view: new _bool.default({
              name: 'small',
              labelText: this.translate('small', 'otherFields', 'DashletOptions')
            })
          }]]
        }]
      });
      this.assignView('record', this.recordView);
      this.buttonList = [{
        name: 'apply',
        style: 'danger',
        label: 'Apply',
        onClick: () => this.actionApply()
      }, {
        name: 'cancel',
        label: 'Cancel',
        onClick: () => this.actionClose()
      }];
    }

    /**
     * @private
     */
    actionApply() {
      if (this.recordView.validate()) {
        return;
      }
      this.options.onApply({
        soft: this.formModel.attributes.soft,
        small: this.formModel.attributes.small
      });
      this.close();
    }
  }
  _exports.default = ExpandedLayoutEditItemModalFieldView;
});

define("views/dashlets/abstract/record-list", ["exports", "views/dashlets/abstract/base", "search-manager", "helpers/record-modal"], function (_exports, _base, _searchManager, _recordModal) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  _searchManager = _interopRequireDefault(_searchManager);
  _recordModal = _interopRequireDefault(_recordModal);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class RecordListDashletView extends _base.default {
    templateContent = '<div class="list-container">{{{list}}}</div>';

    /**
     * @protected
     * @type {string[]}
     */
    additionalRowActionList = undefined;

    /**
     * A scope.
     * @type {string}
     */
    scope;
    listView = null;
    listViewColumn = 'views/record/list';
    listViewExpanded = 'views/record/list-expanded';
    layoutType = 'expanded';
    optionsFields = {
      title: {
        type: 'varchar',
        required: true
      },
      autorefreshInterval: {
        type: 'enumFloat',
        options: [0, 0.5, 1, 2, 5, 10]
      },
      displayRecords: {
        type: 'enumInt',
        options: [3, 4, 5, 10, 15]
      }
    };
    rowActionsView = 'views/record/row-actions/view-and-edit';

    /**
     * @protected
     * @type {boolean}
     */
    hasCollaborators;
    init() {
      this.name = this.options.name || this.name;
      this.scope = this.getMetadata().get(`dashlets.${this.name}.entityType`) || this.scope;
      this.additionalRowActionList = this.getMetadata().get(`dashlets.${this.name}.rowActionList`) || this.additionalRowActionList;
      this.hasCollaborators = !!this.getMetadata().get(`scopes.${this.scope}.collaborators`);
      super.init();
    }
    checkAccess() {
      return this.getAcl().check(this.scope, 'read');
    }

    /**
     * @return {module:search-manager~data}
     */
    getSearchData() {
      /** @type {module:search-manager~data} */
      const data = Espo.Utils.cloneDeep(this.getOption('searchData'));
      if (!this.hasCollaborators) {
        return data;
      }
      if (this.getOption('includeShared')) {
        if (!data.bool) {
          data.bool = {};
        }
        data.bool.shared = true;
      }
      return data;
    }
    afterRender() {
      this.getCollectionFactory().create(this.scope, collection => {
        const searchData = this.getSearchData();
        this.searchManager = new _searchManager.default(collection, {
          defaultData: searchData
        });
        if (!this.scope) {
          this.$el.find('.list-container').html(this.translate('selectEntityType', 'messages', 'DashletOptions'));
          return;
        }
        if (!this.checkAccess()) {
          this.$el.find('.list-container').html(this.translate('No Access'));
          return;
        }
        if (this.collectionUrl) {
          collection.url = this.collectionUrl;
        }
        this.collection = collection;
        collection.orderBy = this.getOption('orderBy') || this.getOption('sortBy') || this.collection.orderBy;
        if (this.getOption('orderBy')) {
          collection.order = 'asc';
        }
        if (this.hasOption('asc')) {
          collection.order = this.getOption('asc') ? 'asc' : false;
        }
        if (this.getOption('sortDirection') === 'asc') {
          collection.order = 'asc';
        } else if (this.getOption('sortDirection') === 'desc') {
          collection.order = 'desc';
        }
        if (this.getOption('order') === 'asc') {
          collection.order = 'asc';
        } else if (this.getOption('order') === 'desc') {
          collection.order = 'desc';
        }
        collection.maxSize = this.getOption('displayRecords');
        collection.where = this.searchManager.getWhere();
        const viewName = this.listView || (this.layoutType === 'expanded' ? this.listViewExpanded : this.listViewColumn);
        this.createView('list', viewName, {
          collection: collection,
          selector: '.list-container',
          pagination: !!this.getOption('pagination'),
          type: 'listDashlet',
          rowActionsView: this.rowActionsView,
          checkboxes: false,
          showMore: true,
          listLayout: this.getOption(this.layoutType + 'Layout'),
          skipBuildRows: true,
          additionalRowActionList: this.additionalRowActionList
        }, view => {
          view.getSelectAttributeList(selectAttributeList => {
            if (selectAttributeList) {
              collection.data.select = selectAttributeList.join(',');
            }
            collection.fetch();
          });
        });
      });
    }
    setupActionList() {
      if (this.scope && this.getAcl().checkScope(this.scope, 'create')) {
        this.actionList.unshift({
          name: 'create',
          text: this.translate('Create ' + this.scope, 'labels', this.scope),
          iconClass: 'fas fa-plus',
          url: `#${this.scope}/create`
        });
      }
    }
    actionRefresh() {
      this.refreshInternal();
    }
    autoRefresh() {
      this.refreshInternal({
        skipNotify: true
      });
    }

    /**
     * @private
     * @param {{skipNotify?: boolean}} [options]
     * @return {Promise<void>}
     */
    async refreshInternal() {
      let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      if (!this.collection) {
        return;
      }
      if (!options.skipNotify) {
        Espo.Ui.notifyWait();
      }
      this.collection.where = this.searchManager.getWhere();
      await this.collection.fetch({
        previousDataList: this.collection.models.map(model => {
          return Espo.Utils.cloneDeep(model.attributes);
        })
      });
      if (!options.skipNotify) {
        Espo.Ui.notify();
      }
    }

    // noinspection JSUnusedGlobalSymbols
    actionCreate() {
      const attributes = this.getCreateAttributes() || {};
      if (this.getOption('populateAssignedUser')) {
        if (this.getMetadata().get(['entityDefs', this.scope, 'fields', 'assignedUsers'])) {
          attributes['assignedUsersIds'] = [this.getUser().id];
          attributes['assignedUsersNames'] = {};
          attributes['assignedUsersNames'][this.getUser().id] = this.getUser().get('name');
        } else {
          attributes['assignedUserId'] = this.getUser().id;
          attributes['assignedUserName'] = this.getUser().get('name');
        }
      }
      const helper = new _recordModal.default();
      helper.showCreate(this, {
        entityType: this.scope,
        attributes: attributes,
        afterSave: () => this.actionRefresh()
      });
    }
    getCreateAttributes() {}
    getColor() {
      if (!this.scope) {
        return null;
      }
      return this.getMetadata().get(`clientDefs.${this.scope}.color`);
    }
  }
  var _default = _exports.default = RecordListDashletView;
});

define("views/attachment/modals/select-one", ["exports", "views/modal"], function (_exports, _modal) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class SelectOneAttachmentModalView extends _modal.default {
    backdrop = true;

    // language=Handlebars
    templateContent = `<ul class="list-group no-side-margin">
            {{#each viewObject.options.dataList}}
                <li
                    class="list-group-item"
                ><a
                    role="button"
                    class="action"
                    data-action="select"
                    data-id="{{id}}"
                >{{name}}</a></li>
            {{/each}}
        </ul>
        `;

    /**
     *
     * @param {{
     *     fieldLabel?: string,
     *     dataList: {id: string, name: string}[],
     *     onSelect: function(string),
     * }} options
     */
    constructor(options) {
      super(options);
      this.options = options;
    }
    setup() {
      this.headerText = this.translate('Select');
      if (this.options.fieldLabel) {
        this.headerText += ' · ' + this.options.fieldLabel;
      }
      this.addActionHandler('select', (e, target) => {
        this.options.onSelect(target.dataset.id);
        this.close();
      });
    }
  }
  _exports.default = SelectOneAttachmentModalView;
});

define("ui/timepicker", ["exports", "jquery"], function (_exports, _jquery) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _jquery = _interopRequireDefault(_jquery);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * A timepicker.
   */
  class Timepicker {
    /**
     * @param {HTMLElement} element
     * @param {{
     *     step: number,
     *     timeFormat: string,
     *     scrollDefaultNow?: boolean,
     * }} options
     */
    constructor(element, options) {
      /**
       * @private
       */
      this.$element = (0, _jquery.default)(element);
      const modalBodyElement = element.closest('.modal-body');
      this.$element.timepicker({
        step: options.step,
        timeFormat: options.timeFormat,
        appendTo: modalBodyElement ? (0, _jquery.default)(modalBodyElement) : 'body',
        scrollDefaultNow: options.scrollDefaultNow || false
      });
    }

    /**
     * Set the min time.
     *
     * @param {string|null} minTime
     */
    setMinTime(minTime) {
      this.$element.timepicker('option', 'minTime', minTime);
    }

    /**
     * Set the max time.
     *
     * @param {string|null} maxTime
     */
    setMaxTime(maxTime) {
      this.$element.timepicker('option', 'maxTime', maxTime);
    }

    /**
     * Add a 'change' event listener.
     *
     * @param {function} callback
     */
    addChangeEventListener(callback) {
      this.$element.on('change', callback);
    }

    /**
     * Show.
     */
    show() {
      this.$element.timepicker('show');
    }

    /**
     * Destroy.
     */
    destroy() {
      if (!this.$element[0]) {
        return;
      }
      this.$element.timepicker('remove');
    }
  }
  var _default = _exports.default = Timepicker;
});

define("helpers/assignment", ["exports", "di", "metadata"], function (_exports, _di, _metadata) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _metadata = _interopRequireDefault(_metadata);
  var _staticBlock;
  let _init_metadata, _init_extra_metadata;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  /**
   * @since 10.0.0
   */
  class AssignmentHelper {
    constructor() {
      _init_extra_metadata(this);
    }
    /**
     * @private
     * @type {Metadata}
     */
    metadata = _init_metadata(this);

    /**
     * @param {string} entityType
     * @return {boolean}
     */
    hasAssignedUserField(entityType) {
      return this.metadata.get(`entityDefs.${entityType}.fields.assignedUser.type`) === 'link' && !this.metadata.get(`entityDefs.${entityType}.fields.assignedUser.disabled`) && this.metadata.get(`entityDefs.${entityType}.links.assignedUser.entity`) === 'User';
    }

    /**
     * @param {string} entityType
     * @return {boolean}
     */
    hasAssignedUsersField(entityType) {
      return this.metadata.get(`entityDefs.${entityType}.fields.assignedUsers.type`) === 'linkMultiple' && this.metadata.get(`entityDefs.${entityType}.links.assignedUsers.entity`) === 'User';
    }

    /**
     * @param {string} entityType
     * @return {boolean}
     */
    hasCollaboratorsField(entityType) {
      if (!this.metadata.get(`scopes.${entityType}.collaborators`)) {
        return false;
      }
      return this.metadata.get(`entityDefs.${entityType}.fields.collaborators.type`) === 'linkMultiple' && this.metadata.get(`entityDefs.${entityType}.links.collaborators.entity`) === 'User';
    }
    static #_ = _staticBlock = () => [_init_metadata, _init_extra_metadata] = _applyDecs(this, [], [[(0, _di.inject)(_metadata.default), 0, "metadata"]]).e;
  }
  _exports.default = AssignmentHelper;
  _staticBlock();
});

define("helpers/site/window-panel-helper", ["exports", "di", "theme-manager"], function (_exports, _di, _themeManager) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _themeManager = _interopRequireDefault(_themeManager);
  var _staticBlock;
  let _init_themeManager, _init_extra_themeManager;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  class WindowPanelHelper {
    /**
     * @type {import('view').default}
     * @private
     */
    view;

    /**
     * @private
     * @type {boolean}
     */
    overflowWasHidden = false;

    /**
     * @private
     */
    onResizeBind;

    /**
     * @private
     * @type {ThemeManager}
     */
    themeManager = _init_themeManager(this);

    /**
     * @param {import('view').default} view
     */
    constructor(view) {
      _init_extra_themeManager(this);
      this.view = view;
      view.listenToOnce(view, 'remove', () => {
        window.removeEventListener('resize', this.onResizeBind);
        if (this.overflowWasHidden) {
          document.body.style.overflow = 'unset';
          this.overflowWasHidden = false;
        }
      });
      this.onResizeBind = this.onResize.bind(this);
      window.addEventListener('resize', this.onResizeBind);
      this.navbarPanelHeightSpace = this.themeManager.getParam('navbarPanelHeightSpace') ?? 100;
      this.navbarPanelBodyMaxHeight = this.themeManager.getParam('navbarPanelBodyMaxHeight') ?? 600;
      this.xsWidth = this.themeManager.getParam('screenWidthXs');
      this.onResize();
    }

    /**
     * @private
     */
    onResize() {
      var _this$view$element, _this$view$element2;
      const windowHeight = window.innerHeight;
      const windowWidth = window.innerWidth;
      const panelBody = (_this$view$element = this.view.element) === null || _this$view$element === void 0 ? void 0 : _this$view$element.querySelector('.panel-body');
      const heading = (_this$view$element2 = this.view.element) === null || _this$view$element2 === void 0 ? void 0 : _this$view$element2.querySelector('.panel-heading');
      if (!(panelBody instanceof HTMLElement)) {
        return;
      }
      const diffHeight = (heading === null || heading === void 0 ? void 0 : heading.outerHeight) ?? 0;
      const cssParams = {};
      if (windowWidth <= this.xsWidth) {
        cssParams.height = windowHeight - diffHeight + 'px';
        cssParams.overflow = 'auto';
        document.body.style.overflow = 'hidden';
        this.overflowWasHidden = true;
      } else {
        cssParams.height = 'unset';
        cssParams.overflow = 'none';
        if (this.overflowWasHidden) {
          panelBody.style.overflow = 'unset';
          this.overflowWasHidden = false;
        }
        if (windowHeight - this.navbarPanelBodyMaxHeight < this.navbarPanelHeightSpace) {
          const maxHeight = windowHeight - this.navbarPanelHeightSpace;
          cssParams.maxHeight = maxHeight + 'px';
        }
      }
      for (const [param, value] of Object.entries(cssParams)) {
        panelBody.style[param] = value;
      }
    }
    static #_ = _staticBlock = () => [_init_themeManager, _init_extra_themeManager] = _applyDecs(this, [], [[(0, _di.inject)(_themeManager.default), 0, "themeManager"]]).e;
  }
  _exports.default = WindowPanelHelper;
  _staticBlock();
});

define("helpers/misc/field-language", ["exports"], function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module helpers/misc/field-language */

  /**
   * A field-language util.
   */
  class FieldLanguage {
    /**
     * @param {module:metadata} metadata A metadata.
     * @param {module:language} language A language.
     */
    constructor(metadata, language) {
      /**
       * @private
       * @type {module:metadata}
       */
      this.metadata = metadata;

      /**
       * @private
       * @type {module:language}
       */
      this.language = language;
    }

    /**
     * Translate an attribute.
     *
     * @param {string} scope A scope.
     * @param {string} name An attribute name.
     * @returns {string}
     */
    translateAttribute(scope, name) {
      let label = this.language.translate(name, 'fields', scope);
      if (name.indexOf('Id') === name.length - 2) {
        const baseField = name.slice(0, name.length - 2);
        if (this.metadata.get(['entityDefs', scope, 'fields', baseField])) {
          label = this.language.translate(baseField, 'fields', scope) + ' (' + this.language.translate('id', 'fields') + ')';
        }
      } else if (name.indexOf('Name') === name.length - 4) {
        const baseField = name.slice(0, name.length - 4);
        if (this.metadata.get(['entityDefs', scope, 'fields', baseField])) {
          label = this.language.translate(baseField, 'fields', scope) + ' (' + this.language.translate('name', 'fields') + ')';
        }
      } else if (name.indexOf('Type') === name.length - 4) {
        const baseField = name.slice(0, name.length - 4);
        if (this.metadata.get(['entityDefs', scope, 'fields', baseField])) {
          label = this.language.translate(baseField, 'fields', scope) + ' (' + this.language.translate('type', 'fields') + ')';
        }
      }
      if (name.indexOf('Ids') === name.length - 3) {
        const baseField = name.slice(0, name.length - 3);
        if (this.metadata.get(['entityDefs', scope, 'fields', baseField])) {
          label = this.language.translate(baseField, 'fields', scope) + ' (' + this.language.translate('ids', 'fields') + ')';
        }
      } else if (name.indexOf('Names') === name.length - 5) {
        const baseField = name.slice(0, name.length - 5);
        if (this.metadata.get(['entityDefs', scope, 'fields', baseField])) {
          label = this.language.translate(baseField, 'fields', scope) + ' (' + this.language.translate('names', 'fields') + ')';
        }
      } else if (name.indexOf('Types') === name.length - 5) {
        const baseField = name.slice(0, name.length - 5);
        if (this.metadata.get(['entityDefs', scope, 'fields', baseField])) {
          label = this.language.translate(baseField, 'fields', scope) + ' (' + this.language.translate('types', 'fields') + ')';
        }
      }
      return label;
    }
  }
  var _default = _exports.default = FieldLanguage;
});

define("helpers/list/misc/list-tree-draggable", ["exports", "@shopify/draggable", "di", "language"], function (_exports, _draggable, _di, _language) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _language = _interopRequireDefault(_language);
  var _staticBlock;
  let _init_language, _init_extra_language;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  /**
   * @internal
   */
  class ListTreeDraggableHelper {
    /**
     * @type {Language}
     */
    language = _init_language(this);

    /**
     * @private
     * @type {boolean}
     */
    blockDraggable = (_init_extra_language(this), false);

    /**
     * @private
     * {Draggable}
     */
    draggable;

    /**
     * @param {import('views/record/list-tree').default} view
     */
    constructor(view) {
      this.view = view;
    }
    destroy() {
      if (this.draggable) {
        this.draggable.destroy();
      }
    }
    init() {
      if (this.draggable) {
        this.draggable.destroy();
      }
      const draggable = this.draggable = new _draggable.Draggable(this.view.element, {
        distance: 8,
        draggable: '.list-group-item > .cell > [data-role="moveHandle"]',
        mirror: {
          cursorOffsetX: 5,
          cursorOffsetY: 5,
          appendTo: 'body'
        }
      });

      /** @type {HTMLElement[]} */
      let rows;
      /** @type {Map<HTMLElement, number>} */
      let levelMap;
      /** @type {HTMLElement|null} */
      let movedHandle = null;
      /** @type {HTMLElement|null} */
      let movedLink = null;
      /** @type {HTMLElement|null} */
      let movedFromLi = null;
      draggable.on('mirror:created', event => {
        const mirror = event.mirror;
        const source = event.source;
        const originalSource = event.originalSource;
        originalSource.style.display = '';
        source.style.display = 'none';
        mirror.style.display = 'block';
        mirror.style.cursor = 'grabbing';
        mirror.classList.add('draggable-helper', 'draggable-helper-transparent', 'text-info');
        mirror.classList.remove('link');
        mirror.style.pointerEvents = 'auto';
        mirror.removeAttribute('href');
        mirror.style.textDecoration = 'none';
        mirror.innerText = mirror.dataset.title;
      });
      draggable.on('mirror:move', event => {
        event.mirror.style.pointerEvents = 'auto';
      });
      draggable.on('drag:start', event => {
        if (this.blockDraggable) {
          event.cancel();
          return;
        }
        rows = Array.from(this.view.element.querySelectorAll('.list-group-tree > .list-group-item'));
        levelMap = new Map();
        rows.forEach(row => {
          let depth = 0;
          let current = row;
          while (current && current !== this.view.element) {
            current = current.parentElement;
            depth++;
          }
          levelMap.set(row, depth);
        });
        rows.sort((a, b) => levelMap.get(b) - levelMap.get(a));
        this.view.movedId = event.source.dataset.id;
        movedHandle = event.originalSource;
        movedFromLi = movedHandle.parentElement.parentElement;
        movedLink = movedHandle.parentElement.querySelector(`:scope > a.link`);
        movedLink.classList.add('text-info');
      });
      let overId = null;
      let overParentId = null;
      let isAfter = false;
      let wasOutOfSelf = false;
      draggable.on('drag:move', event => {
        isAfter = false;
        overId = null;
        let rowFound = null;
        for (const row of rows) {
          const rect = row.getBoundingClientRect();
          const isIn = rect.left < event.sensorEvent.clientX && rect.right > event.sensorEvent.clientX && rect.top < event.sensorEvent.clientY && rect.bottom >= event.sensorEvent.clientY;
          if (!isIn) {
            continue;
          }
          let itemId = row.dataset.id ?? null;
          let itemParentId = null;
          if (!itemId) {
            const parent = row.closest(`.list-group-item[data-id]`);
            if (parent instanceof HTMLElement) {
              // Over a plus row.
              itemParentId = parent.dataset.id;
            }
          }
          const itemIsAfter = event.sensorEvent.clientY - rect.top >= rect.bottom - event.sensorEvent.clientY;
          if (itemParentId && itemIsAfter) {
            continue;
          }
          if (itemId === this.view.movedId) {
            break;
          }
          if (movedFromLi.contains(row)) {
            break;
          }
          if (!itemId && !itemParentId) {
            continue;
          }
          if (itemParentId) {
            const parent = row.closest(`.list-group-item[data-id]`);
            if (parent) {
              /** @type {NodeListOf<HTMLElement>} */
              const items = parent.querySelectorAll(':scope > .children > .list > .list-group > [data-id]');
              if (items.length) {
                itemId = Array.from(items).pop().dataset.id;
                itemParentId = null;
              }
            }
          }
          isAfter = itemIsAfter;
          overParentId = itemParentId;
          overId = itemId;
          rowFound = row;
          break;
        }
        for (const row of rows) {
          row.classList.remove('border-top-highlighted');
          row.classList.remove('border-bottom-highlighted');
        }
        if (!rowFound) {
          return;
        }
        if (isAfter) {
          rowFound.classList.add('border-bottom-highlighted');
          rowFound.classList.remove('border-top-highlighted');
        } else {
          rowFound.classList.add('border-top-highlighted');
          rowFound.classList.remove('border-bottom-highlighted');
        }
      });
      draggable.on('drag:stop', async () => {
        const finalize = () => {
          if (movedLink) {
            movedLink.classList.remove('text-info');
          }
          rows.forEach(row => {
            row.classList.remove('border-bottom-highlighted');
            row.classList.remove('border-top-highlighted');
          });
          rows = undefined;
        };
        let moveType;
        let referenceId = overId;
        if (overParentId || overId) {
          if (overParentId) {
            moveType = 'into';
            referenceId = overParentId;
          } else if (isAfter) {
            moveType = 'after';
          } else {
            moveType = 'before';
          }
        }
        if (moveType) {
          this.blockDraggable = true;
          const movedId = this.view.movedId;
          const affectedId = referenceId;
          Espo.Ui.notifyWait();
          Espo.Ajax.postRequest(`${this.view.entityType}/action/move`, {
            id: this.view.movedId,
            referenceId: referenceId,
            type: moveType
          }).then(async () => {
            const promises = [];
            if (movedId) {
              promises.push(this.updateAfter(this.view, movedId));
            }
            if (affectedId) {
              promises.push(this.updateAfter(this.view, affectedId));
            }
            await Promise.all(promises);
            Espo.Ui.success(this.language.translate('Done'));
          }).finally(() => {
            this.blockDraggable = false;
            finalize();
          });
        }
        if (!moveType) {
          finalize();
        }
        this.view.movedId = null;
        movedHandle = null;
        movedFromLi = null;
        levelMap = undefined;
        overParentId = null;
        overId = null;
        isAfter = false;
        wasOutOfSelf = false;
      });
    }

    /**
     * @private
     * @param {ListTreeRecordView} view
     * @param {string} movedId
     * @return {Promise}
     */
    async updateAfter(view, movedId) {
      if (view.collection.has(movedId)) {
        const unfoldedIds = view.getItemViews().filter(view => view.isUnfolded && view.model).map(view => view.model.id);
        await view.collection.fetch({
          noRebuild: false
        });
        view.getItemViews().filter(view => view && view.model && unfoldedIds.includes(view.model.id)).forEach(view => view.unfold());
        return;
      }
      for (const subView of view.getItemViews()) {
        if (!subView.getChildrenView()) {
          continue;
        }
        await this.updateAfter(subView.getChildrenView(), movedId);
      }
    }
    static #_ = _staticBlock = () => [_init_language, _init_extra_language] = _applyDecs(this, [], [[(0, _di.inject)(_language.default), 0, "language"]]).e;
  }
  _exports.default = ListTreeDraggableHelper;
  _staticBlock();
});

define("helpers/field/options-provider", ["exports", "di", "metadata", "language"], function (_exports, _di, _metadata, _language) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _metadata = _interopRequireDefault(_metadata);
  _language = _interopRequireDefault(_language);
  var _staticBlock;
  let _init_metadata, _init_extra_metadata, _init_language, _init_extra_language;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  /**
   * @since 10.0.0
   */
  class OptionsProvider {
    constructor() {
      _init_extra_language(this);
    }
    /**
     * @private
     * @type {Metadata}
     */
    metadata = _init_metadata(this);

    /**
     * @private
     * @type {Language}
     */
    language = (_init_extra_metadata(this), _init_language(this));

    /**
     * @param {string} entityType
     * @param {string} field
     * @return {{
     *     name: string,
     *     label: string,
     *     style: string|null,
     * }[]}
     */
    get(entityType, field) {
      /**
       * @type {{
       *     options?: string[],
       *     style?: Record<string, string>,
       *     optionsReference?: string|null,
       *     optionsPath?: string|null
       * }} */
      const params = this.metadata.get(`entityDefs.${entityType}.fields.${field}`);
      if (!params) {
        return [];
      }
      let sourceEntityType = entityType;
      let sourceField = field;
      let styleMap = params.style ?? {};
      let optionsPath = params.optionsPath;
      if (!optionsPath && params.optionsReference) {
        const [refEntityType, refField] = params.optionsReference.split('.');
        optionsPath = `entityDefs.${refEntityType}.fields.${refField}.options`;
        sourceEntityType = refEntityType;
        sourceField = refField;
        styleMap = this.metadata.get(`entityDefs.${refEntityType}.fields.${refField}.style`) ?? {};
      }
      let options = params.options;
      if (optionsPath) {
        options = this.metadata.get(optionsPath);
      }
      return options.map(it => {
        return {
          name: it,
          label: this.language.translateOption(it, sourceField, sourceEntityType),
          style: styleMap[it] ?? null
        };
      });
    }
    static #_ = _staticBlock = () => [_init_metadata, _init_extra_metadata, _init_language, _init_extra_language] = _applyDecs(this, [], [[(0, _di.inject)(_metadata.default), 0, "metadata"], [(0, _di.inject)(_language.default), 0, "language"]]).e;
  }
  _exports.default = OptionsProvider;
  _staticBlock();
});

define("handlers/select-related", ["exports"], function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * Prepares filters for selecting records to relate.
   * Use the interface directly rather than extending this class.
   */
  class SelectRelatedHandler {
    /**
     * @internal
     */

    /**
     * @internal
     */
    constructor(viewHelper) {
      this.viewHelper = viewHelper;
    }

    /**
     * @inheritDoc
     *
     * @param model A model.
     * @return {Promise<SelectRelatedFilters>} Filters.
     */
    async getFilters(model) {
      // noinspection BadExpressionStatementJS
      model;
      return {};
    }
  }
  var _default = _exports.default = SelectRelatedHandler;
});

define("handlers/row-action", ["exports"], function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module handlers/row-action */

  /**
   * @abstract
   */
  class RowActionHandler {
    /**
     * @param {module:views/record/list} view
     */
    constructor(view) {
      // noinspection JSUnusedGlobalSymbols
      /** @protected */
      this.view = view;

      /**
       * @protected
       * @type {module:collection}
       */
      this.collection = this.view.collection;
    }

    /**
     * @param {module:model} model A model.
     * @param {string} action An action.
     * @return {boolean}
     */
    isAvailable(model, action) {
      return true;
    }

    /**
     * @param {module:model} model A model.
     * @param {string} action An action.
     */
    process(model, action) {}
  }
  var _default = _exports.default = RowActionHandler;
});

define("handlers/login", ["exports"], function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module handlers/login */

  /**
   * Custom login handling. To be extended.
   *
   * @abstract
   */
  class LoginHandler {
    /**
     * @param {module:views/login} loginView A login view.
     * @param {Object.<string, *>} data Additional metadata.
     */
    constructor(loginView, data) {
      /**
       * A login view.
       * @protected
       * @type {module:views/login}
       */
      this.loginView = loginView;

      /**
       * Additional metadata.
       * @protected
       * @type {Object.<string, *>}
       */
      this.data = data;
    }

    /**
     * Process. Called on 'Sign in' button click.
     *
     * @public
     * @abstract
     * @return {Promise<Object.<string, string>>} Resolved with headers to be sent to the `App/user` endpoint.
     */
    process() {
      return Promise.resolve({});
    }
  }
  var _default = _exports.default = LoginHandler;
});

define("handlers/model/defaults-preparator", ["exports"], function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * @abstract
   */
  class DefaultsPreparator {
    /**
     * @param {import('view-helper').default} viewHelper
     */
    constructor(viewHelper) {
      /** @protected */
      this.viewHelper = viewHelper;
    }

    // noinspection JSUnusedLocalSymbols
    /**
     * Prepare default attributes.
     *
     * @param {import('model').default} model A model.
     * @return {Promise<Object.<string, *>>}
     */
    prepare(model) {
      return Promise.resolve({});
    }
  }

  // noinspection JSUnusedGlobalSymbols
  var _default = _exports.default = DefaultsPreparator;
});

define("handlers/map/renderer", ["exports"], function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * @module handlers/map/renderer
   */

  /**
   * A map renderer.
   *
   * @abstract
   */
  class MapRenderer {
    /**
     * @typedef {Object} module:handlers/map/renderer~addressData
     * @property {string|null} street
     * @property {string|null} city
     * @property {string|null} country
     * @property {string|null} state
     * @property {string|null} postalCode
     */

    /**
     * @param {import('views/fields/map').default} view A field view.
     */
    constructor(view) {
      this.view = view;
    }

    /**
     * @param {module:handlers/map/renderer~addressData} addressData
     * @abstract
     */
    render(addressData) {}
  }
  var _default = _exports.default = MapRenderer;
});

define("controllers/record", ["exports", "controller", "helpers/model/defaults-populator"], function (_exports, _controller, _defaultsPopulator) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _controller = _interopRequireDefault(_controller);
  _defaultsPopulator = _interopRequireDefault(_defaultsPopulator);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module controllers/record */

  /**
   * A record controller.
   * @template {module:model} TModel
   */
  class RecordController extends _controller.default {
    /** @inheritDoc */
    defaultAction = 'list';
    constructor(params, injections) {
      super(params, injections);

      /**
       * @private
       * @type {Object}
       */
      this.collectionMap = {};
    }

    /** @inheritDoc */
    checkAccess(action) {
      if (this.getAcl().check(this.name, action)) {
        return true;
      }
      return false;
    }

    /**
     * Get a view name/path.
     *
     * @protected
     * @param {'list'|'detail'|'edit'|'create'|'listRelated'|string} type A type.
     * @returns {string}
     */
    getViewName(type) {
      return this.getMetadata().get(['clientDefs', this.name, 'views', type]) || 'views/' + Espo.Utils.camelCaseToHyphen(type);
    }

    // noinspection JSUnusedGlobalSymbols
    beforeList() {
      this.handleCheckAccess('read');
    }

    /**
     * @param {{
     *     isReturn?: boolean,
     *     primaryFilter?: string,
     * } | Record} options
     */
    actionList(options) {
      const isReturn = options.isReturn || this.getRouter().backProcessed;
      let key = 'list';
      if (options.primaryFilter) {
        key += 'Filter' + Espo.Utils.upperCaseFirst(options.primaryFilter);
      }
      if (!isReturn && this.getStoredMainView(key)) {
        this.clearStoredMainView(key);
      }
      this.getCollection().then(collection => {
        const mediator = {};
        const abort = () => {
          collection.abortLastFetch();
          mediator.abort = true;
          Espo.Ui.notify(false);
        };
        this.listenToOnce(this.baseController, 'action', abort);
        this.listenToOnce(collection, 'sync', () => this.stopListening(this.baseController, 'action', abort));
        const viewOptions = {
          scope: this.name,
          collection: collection,
          params: options,
          mediator: mediator
        };
        const viewName = this.getViewName('list');
        const params = {
          useStored: isReturn,
          key: key
        };
        this.main(viewName, viewOptions, null, params);
      });
    }
    beforeView() {
      this.handleCheckAccess('read');
    }

    /**
     * @protected
     * @param {{
     *     returnUrl?: string,
     *     returnDispatchParams?: Record,
     * } | Record} options
     * @param {module:model} model
     * @param {string|null} [view]
     */
    createViewView(options, model, view) {
      view = view || this.getViewName('detail');
      this.main(view, {
        scope: this.name,
        model: model,
        returnUrl: options.returnUrl,
        returnDispatchParams: options.returnDispatchParams,
        params: options
      });
    }

    /**
     * @protected
     * @param {module:model} model
     * @param {Record} options
     */
    prepareModelView(model, options) {}

    // noinspection JSUnusedGlobalSymbols
    /**
     * @param {{
     *     model?: module:model,
     *     id?: string,
     *     isReturn?: boolean,
     *     isAfterCreate?: boolean,
     * } | Record} options
     */
    actionView(options) {
      const id = options.id;
      const isReturn = this.getRouter().backProcessed;
      if (isReturn) {
        if (this.lastViewActionOptions && this.lastViewActionOptions.id === id) {
          options = Espo.Utils.clone(this.lastViewActionOptions);
          if (options.model && options.model.get('deleted')) {
            delete options.model;
          }
        }
        options.isReturn = true;
      } else {
        delete this.lastViewActionOptions;
      }
      this.lastViewActionOptions = options;
      const createView = model => {
        this.prepareModelView(model, options);
        this.createViewView.call(this, options, model);
      };
      if ('model' in options) {
        const model = options.model;
        createView(model);
        this.showLoadingNotification();
        model.fetch().then(() => this.hideLoadingNotification()).catch(xhr => {
          if (xhr.status === 403 && options.isAfterCreate) {
            this.hideLoadingNotification();
            xhr.errorIsHandled = true;
            model.trigger('fetch-forbidden');
          }
        });
        this.listenToOnce(this.baseController, 'action', () => {
          model.abortLastFetch();
          this.hideLoadingNotification();
        });
        return;
      }
      this.getModel().then(model => {
        model.id = id;
        this.showLoadingNotification();
        model.fetch({
          main: true
        }).then(() => {
          this.hideLoadingNotification();
          if (model.get('deleted')) {
            this.listenToOnce(model, 'after:restore-deleted', () => {
              createView(model);
            });
            this.prepareModelView(model, options);
            this.createViewView(options, model, 'views/deleted-detail');
            return;
          }
          createView(model);
        });
        this.listenToOnce(this.baseController, 'action', () => {
          model.abortLastFetch();
        });
      });
    }

    // noinspection JSUnusedGlobalSymbols
    beforeCreate() {
      this.handleCheckAccess('create');
    }

    // noinspection JSUnusedLocalSymbols
    /**
     * @protected
     * @param {module:model} model
     * @param {Record} options
     */
    prepareModelCreate(model, options) {
      this.listenToOnce(model, 'before:save', () => {
        const key = 'list';
        const stored = this.getStoredMainView(key);
        if (!stored) {
          return;
        }
        if (!('storeViewAfterCreate' in stored) || !stored.storeViewAfterCreate) {
          this.clearStoredMainView(key);
        }
      });
      this.listenToOnce(model, 'after:save', () => {
        const key = 'list';
        const stored = this.getStoredMainView(key);
        if (!stored) {
          return;
        }
        if (!('storeViewAfterCreate' in stored) || !stored.storeViewAfterCreate) {
          return;
        }
        if (!('collection' in stored) || !stored.collection) {
          return;
        }
        this.listenToOnce(stored, 'after:render', () => stored.collection.fetch());
      });
    }

    /**
     * @param {{
     *     options?: Record,
     *     relate?: import('model').SetRelateItem | import('model').SetRelateItem [],
     *     returnUrl?: string,
     *     returnDispatchParams?: Record,
     *     attributes?: Record,
     * } | Record} [options]
     */
    async create() {
      let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      const optionsOptions = options.options || {};
      const model = await this.getModel();
      if (options.relate) {
        model.setRelate(options.relate);
      }
      const o = {
        scope: this.name,
        model: model,
        returnUrl: options.returnUrl,
        returnDispatchParams: options.returnDispatchParams,
        params: options
      };
      for (const k in optionsOptions) {
        o[k] = optionsOptions[k];
      }
      await new _defaultsPopulator.default().populate(model);
      if (options.attributes) {
        model.set(options.attributes);
      }
      this.prepareModelCreate(model, options);
      this.main(this.getViewName('edit'), o);
    }

    /**
     * @param {{
     *     options?: Record,
     *     relate?: import('model').SetRelateItem | import('model').SetRelateItem [],
     *     returnUrl?: string,
     *     returnDispatchParams?: Record,
     *     options?: Record,
     *     attributes?: Record,
     * } | Record} [options]
     */
    actionCreate(options) {
      this.create(options);
    }

    // noinspection JSUnusedGlobalSymbols
    beforeEdit() {
      this.handleCheckAccess('edit');
    }

    // noinspection JSUnusedLocalSymbols
    /**
     * @protected
     * @param {module:model} model
     * @param {Record} options
     */
    prepareModelEdit(model, options) {
      this.listenToOnce(model, 'before:save', () => {
        const key = 'list';
        const stored = this.getStoredMainView(key);
        if (!stored) {
          return;
        }
        if (!('storeViewAfterUpdate' in stored) || !stored.storeViewAfterUpdate) {
          this.clearStoredMainView(key);
        }
      });
    }

    /**
     * @param {{
     *     id: string,
     *     options?: Record,
     *     model?: import('model').default,
     *     returnUrl?: string,
     *     attributes?: Record,
     *     highlightFieldList?: string[],
     *     returnDispatchParams?: Record,
     * }} options
     */
    actionEdit(options) {
      const id = options.id;
      const optionsOptions = options.options || {};
      this.getModel().then(model => {
        model.id = id;
        if (options.model) {
          model = options.model;
        }
        this.prepareModelEdit(model, options);
        this.showLoadingNotification();
        model.fetch({
          main: true
        }).then(() => {
          this.hideLoadingNotification();
          const o = {
            scope: this.name,
            model: model,
            returnUrl: options.returnUrl,
            returnDispatchParams: options.returnDispatchParams,
            params: options
          };
          for (const k in optionsOptions) {
            o[k] = optionsOptions[k];
          }
          if (options.attributes) {
            o.attributes = options.attributes;
          }
          if (options.highlightFieldList) {
            o.highlightFieldList = options.highlightFieldList;
          }
          this.main(this.getViewName('edit'), o);
        });
        this.listenToOnce(this.baseController, 'action', () => {
          model.abortLastFetch();
        });
      });
    }

    // noinspection JSUnusedGlobalSymbols
    beforeMerge() {
      this.handleCheckAccess('edit');
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * @param {{
     *     ids: string,
     *     collection: import('collection').default,
     * }} options
     */
    actionMerge(options) {
      const ids = options.ids.split(',');
      this.getModel().then(model => {
        const models = [];
        const proceed = () => {
          this.main('views/merge', {
            models: models,
            scope: this.name,
            collection: options.collection
          });
        };
        let i = 0;
        ids.forEach(id => {
          const current = model.clone();
          current.id = id;
          models.push(current);
          this.listenToOnce(current, 'sync', () => {
            i++;
            if (i === ids.length) {
              proceed();
            }
          });
          current.fetch();
        });
      });
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * @param {{
     *     id: string,
     *     link: string,
     * }} options
     */
    actionRelated(options) {
      const id = options.id;
      const link = options.link;
      const viewName = this.getViewName('listRelated');
      let model;
      this.getModel().then(m => {
        model = m;
        model.id = id;
        return model.fetch({
          main: true
        });
      }).then(() => {
        const foreignEntityType = model.getLinkParam(link, 'entity');
        if (!foreignEntityType) {
          this.baseController.error404();
          throw new Error(`Bad link '${link}'.`);
        }
        return this.collectionFactory.create(foreignEntityType);
      }).then(collection => {
        collection.url = model.entityType + '/' + id + '/' + link;
        this.main(viewName, {
          scope: this.name,
          model: model,
          collection: collection,
          link: link
        });
      });
    }

    /**
     * Get a collection for the current controller.
     *
     * @protected
     * @param {boolean} [usePreviouslyFetched=false] Use a previously fetched. @todo Revise.
     * @return {Promise<module:collection>}
     */
    getCollection(usePreviouslyFetched) {
      if (!this.name) {
        throw new Error('No collection for unnamed controller');
      }
      const entityType = this.entityType || this.name;
      if (usePreviouslyFetched && entityType in this.collectionMap) {
        const collection = this.collectionMap[entityType];
        return Promise.resolve(collection);
      }
      return this.collectionFactory.create(entityType, collection => {
        this.collectionMap[entityType] = collection;
        this.listenTo(collection, 'sync', () => collection.isFetched = true);
      });
    }

    /**
     * Get a model for the current controller.
     *
     * @protected
     * @param {Function} [callback]
     * @param {Object} [context]
     * @return {Promise<module:model>}
     */
    getModel(callback, context) {
      context = context || this;
      if (!this.name) {
        throw new Error('No collection for unnamed controller');
      }
      const modelName = this.entityType || this.name;
      return this.modelFactory.create(modelName, model => {
        if (callback) {
          callback.call(context, model);
        }
      });
    }
  }
  var _default = _exports.default = RecordController;
});

define("collections/note", ["exports", "collection"], function (_exports, _collection) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _collection = _interopRequireDefault(_collection);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module collections/note */

  class NoteCollection extends _collection.default {
    /**
     * @type {boolean}
     */
    paginationByNumber = false;

    /**
     * @private
     * @type {string|null}
     */
    reactionsCheckDate = null;

    /**
     * @type {Record[]}
     */
    pinnedList;

    /**
     * @type {number}
     */
    reactionsCheckMaxSize = 0;
    prepareAttributes(response, params) {
      if (Array.isArray(response)) {
        throw new Error("Bad response.");
      }
      const total = this.total;
      const list = super.prepareAttributes(response, params);
      if (params.data && params.data.after) {
        this.total = total >= 0 && response.total >= 0 ? total + response.total : total;
      }
      if (response.pinnedList) {
        this.pinnedList = Espo.Utils.cloneDeep(response.pinnedList);
      }
      this.reactionsCheckDate = response.reactionsCheckDate;

      /** @type {Record[]} */
      const updatedReactions = response.updatedReactions;
      if (updatedReactions) {
        updatedReactions.forEach(item => {
          const model = this.get(item.id);
          if (!model) {
            return;
          }
          model.set(item);
        });
      }
      return list;
    }

    /**
     * Fetch new records.
     *
     * @param {Object} [options] Options.
     * @returns {Promise}
     */
    fetchNew(options) {
      options = options || {};
      options.data = options.data || {};
      options.fetchNew = true;
      options.noRebuild = true;
      options.lengthBeforeFetch = this.length;
      if (this.length) {
        options.data.after = this.models[0].get('createdAt');
        options.remove = false;
        options.at = 0;
        options.maxSize = null;
        if (this.reactionsCheckMaxSize) {
          options.data.reactionsAfter = this.reactionsCheckDate || options.data.after;
          options.data.reactionsCheckNoteIds = this.models.filter(model => model.attributes.type === 'Post').map(model => model.id).slice(0, this.reactionsCheckMaxSize).join(',');
        }
      }
      return this.fetch(options);
    }
    fetch(options) {
      options = {
        ...options
      };
      if (this.paginationByNumber && options.more) {
        options.more = false;
        options.data = options.data || {};
        const lastModel = this.models.at(this.length - 1);
        if (lastModel) {
          options.data.beforeNumber = lastModel.get('number');
        }
      }
      return super.fetch(options);
    }
  }
  var _default = _exports.default = NoteCollection;
});

define("views/settings/fields/theme", ["exports", "views/fields/enum", "theme-manager", "ui/select"], function (_exports, _enum, _themeManager, _select) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _enum = _interopRequireDefault(_enum);
  _themeManager = _interopRequireDefault(_themeManager);
  _select = _interopRequireDefault(_select);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ThemeSettingsFieldView extends _enum.default {
    // language=Handlebars
    editTemplateContent = `
        <div class="grid-auto-fit-xxs">
            <div>
                <select data-name="{{name}}" class="form-control main-element">
                    {{options
                        params.options value
                        scope=scope
                        field=name
                        translatedOptions=translatedOptions
                        includeMissingOption=true
                        styleMap=params.style
                    }}
                </select>
            </div>
            {{#if navbarOptionList.length}}
            <div>
                <select data-name="themeNavbar" class="form-control">
                    {{options navbarOptionList navbar translatedOptions=navbarTranslatedOptions}}
                </select>
            </div>
            {{/if}}
        </div>
    `;
    data() {
      const data = super.data();
      data.navbarOptionList = this.getNavbarOptionList();
      data.navbar = this.getNavbarValue() || this.getDefaultNavbar();
      data.navbarTranslatedOptions = {};
      data.navbarOptionList.forEach(item => {
        data.navbarTranslatedOptions[item] = this.translate(item, 'themeNavbars');
      });
      return data;
    }
    setup() {
      super.setup();
      this.initThemeManager();
      this.model.on('change:theme', (m, v, o) => {
        this.initThemeManager();
        if (o.ui) {
          this.reRender().then(() => _select.default.focus(this.$element, {
            noTrigger: true
          }));
        }
      });
    }
    afterRenderEdit() {
      this.$navbar = this.$el.find('[data-name="themeNavbar"]');
      this.$navbar.on('change', () => this.trigger('change'));
      _select.default.init(this.$navbar);
    }

    /**
     * @protected
     * @return {string}
     */
    getNavbarValue() {
      const params = this.model.get('themeParams') || {};
      return params.navbar;
    }

    /**
     * @protected
     * @return {Record|null}
     */
    getNavbarDefs() {
      if (!this.themeManager) {
        return null;
      }
      const params = this.themeManager.getParam('params');
      if (!params || !params.navbar) {
        return null;
      }
      return Espo.Utils.cloneDeep(params.navbar);
    }

    /**
     * @private
     * @return {string[]}
     */
    getNavbarOptionList() {
      const defs = this.getNavbarDefs();
      if (!defs) {
        return [];
      }
      const optionList = defs.options || [];
      if (!optionList.length || optionList.length === 1) {
        return [];
      }
      return optionList;
    }

    /**
     * @protected
     * @return {string|null}
     */
    getDefaultNavbar() {
      const defs = this.getNavbarDefs() || {};
      return defs.default || null;
    }

    /**
     * @private
     */
    initThemeManager() {
      const theme = this.model.get('theme');
      if (!theme) {
        this.themeManager = null;
        return;
      }
      this.themeManager = new _themeManager.default(this.getConfig(), this.getPreferences(), this.getMetadata(), theme);
    }
    getAttributeList() {
      return [this.name, 'themeParams'];
    }
    setupOptions() {
      this.params.options = Object.keys(this.getMetadata().get('themes') || {}).sort((v1, v2) => {
        if (v2 === 'EspoRtl') {
          return -1;
        }
        return this.translate(v1, 'theme').localeCompare(this.translate(v2, 'theme'));
      });
    }
    fetch() {
      const data = super.fetch();
      const params = {};
      if (this.$navbar.length) {
        params.navbar = this.$navbar.val();
      }
      data.themeParams = params;
      return data;
    }
  }
  _exports.default = ThemeSettingsFieldView;
});

define("views/settings/fields/tab-list", ["exports", "views/fields/array"], function (_exports, _array) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _array = _interopRequireDefault(_array);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class TabListFieldView extends _array.default {
    addItemModalView = 'views/settings/modals/tab-list-field-add';
    noGroups = false;
    noDelimiters = false;
    setup() {
      super.setup();
      this.selected.forEach(item => {
        if (item && typeof item === 'object') {
          if (!item.id) {
            item.id = this.generateItemId();
          }
        }
      });
      this.addActionHandler('editGroup', (e, target) => {
        this.editGroup(target.dataset.value);
      });
    }
    generateItemId() {
      return Math.floor(Math.random() * 1000000 + 1).toString();
    }
    setupOptions() {
      this.params.options = Object.keys(this.getMetadata().get('scopes')).filter(scope => {
        if (this.getMetadata().get(`scopes.${scope}.disabled`)) {
          return false;
        }
        if (!this.getAcl().checkScope(scope)) {
          return false;
        }
        return this.getMetadata().get(`scopes.${scope}.tab`);
      }).sort((v1, v2) => {
        return this.translate(v1, 'scopeNamesPlural').localeCompare(this.translate(v2, 'scopeNamesPlural'));
      });
      if (!this.noDelimiters) {
        this.params.options.push('_delimiter_');
        this.params.options.push('_delimiter-ext_');
      }
      this.translatedOptions = {};
      this.params.options.forEach(item => {
        this.translatedOptions[item] = this.translate(item, 'scopeNamesPlural');
      });
      this.translatedOptions['_delimiter_'] = '. . .';
      this.translatedOptions['_delimiter-ext_'] = '. . .';
    }
    addValue(value) {
      if (value && typeof value === 'object') {
        if (!value.id) {
          value.id = this.generateItemId();
        }
        const html = this.getItemHtml(value);
        this.$list.append(html);
        this.selected.push(value);
        this.trigger('change');
        return;
      }
      super.addValue(value);
    }
    removeValue(value) {
      const index = this.getGroupIndexById(value);
      if (~index) {
        this.$list.children(`[data-value="${value}"]`).remove();
        this.selected.splice(index, 1);
        this.trigger('change');
        return;
      }
      super.removeValue(value);
    }
    getItemHtml(value) {
      if (value && typeof value === 'object') {
        return this.getGroupItemHtml(value);
      }
      return super.getItemHtml(value);
    }

    /**
     *
     * @param {{id: string, text?: string|null, type: string}} item
     * @return {string | jQuery}
     */
    getGroupItemHtml(item) {
      const labelElement = document.createElement('span');
      labelElement.textContent = item.text ?? '';
      let icon;
      if (item.type === 'group') {
        icon = document.createElement('span');
        icon.className = 'far fa-list-alt text-muted';
      }
      if (item.type === 'url') {
        icon = document.createElement('span');
        icon.className = 'fas fa-link fa-sm text-muted';
      }
      if (item.type === 'divider') {
        labelElement.classList.add('text-soft', 'text-italic');
      }
      const itemElement = document.createElement('span');
      itemElement.append(labelElement);
      itemElement.className = 'text';
      if (icon) {
        icon.style.marginRight = 'var(--4px)';
        itemElement.prepend(icon);
      }
      const div = document.createElement('div');
      div.className = 'list-group-item';
      div.dataset.value = item.id;
      div.style.cursor = 'default';
      div.append((() => {
        const span = document.createElement('span');
        span.className = 'drag-handle';
        span.append((() => {
          const span = document.createElement('span');
          span.className = 'fas fa-grip fa-sm';
          return span;
        })());
        return span;
      })(), (() => {
        const span = document.createElement('span');
        span.className = 'item-button';
        span.append((() => {
          const a = document.createElement('a');
          a.role = 'button';
          a.tabIndex = 0;
          a.dataset.value = item.id;
          a.dataset.action = 'editGroup';
          a.append((() => {
            const span = document.createElement('span');
            span.className = 'fas fa-pencil-alt fa-sm';
            return span;
          })());
          return a;
        })());
        return span;
      })(), itemElement, (() => {
        const a = document.createElement('a');
        a.role = 'button';
        a.tabIndex = 0;
        a.classList.add('pull-right');
        a.dataset.value = item.id;
        a.dataset.action = 'removeValue';
        a.append((() => {
          const span = document.createElement('span');
          span.className = 'fas fa-times';
          return span;
        })());
        return a;
      })());
      return div.outerHTML;
    }
    fetchFromDom() {
      const selected = [];
      this.$el.find('.list-group .list-group-item').each((i, el) => {
        const value = $(el).data('value').toString();
        const groupItem = this.getGroupValueById(value);
        if (groupItem) {
          selected.push(groupItem);
          return;
        }
        selected.push(value);
      });
      this.selected = selected;
    }
    getGroupIndexById(id) {
      for (let i = 0; i < this.selected.length; i++) {
        const item = this.selected[i];
        if (item && typeof item === 'object') {
          if (item.id === id) {
            return i;
          }
        }
      }
      return -1;
    }
    getGroupValueById(id) {
      for (const item of this.selected) {
        if (item && typeof item === 'object') {
          if (item.id === id) {
            return item;
          }
        }
      }
      return null;
    }
    editGroup(id) {
      const item = Espo.Utils.cloneDeep(this.getGroupValueById(id) || {});
      const index = this.getGroupIndexById(id);
      const tabList = Espo.Utils.cloneDeep(this.selected);
      const view = {
        divider: 'views/settings/modals/edit-tab-divider',
        url: 'views/settings/modals/edit-tab-url'
      }[item.type] || 'views/settings/modals/edit-tab-group';
      this.createView('dialog', view, {
        itemData: item,
        parentType: this.model.entityType
      }, view => {
        view.render();
        this.listenToOnce(view, 'apply', itemData => {
          for (const a in itemData) {
            tabList[index][a] = itemData[a];
          }
          this.model.set(this.name, tabList);
          view.close();
        });
      });
    }
    getAddItemModalOptions() {
      return {
        ...super.getAddItemModalOptions(),
        noGroups: this.noGroups
      };
    }
    getValueForDisplay() {
      const labels = this.translatedOptions || {};

      /** @var {string[]} */
      const list = this.selected.map(item => {
        if (typeof item !== 'string') {
          return ' - ' + (item.text || '?');
        }
        return labels[item] || item;
      });
      return list.map(text => {
        return $('<div>').addClass('multi-enum-item-container').text(text).get(0).outerHTML;
      }).join('');
    }
  }
  var _default = _exports.default = TabListFieldView;
});

define("views/email-account/modals/reset-fetch-data", ["exports", "views/modal", "ajax", "views/record/edit-for-modal", "model", "date-time", "di", "views/fields/date", "ui"], function (_exports, _modal, _ajax, _editForModal, _model, _dateTime, _di, _date, _ui) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  _ajax = _interopRequireDefault(_ajax);
  _editForModal = _interopRequireDefault(_editForModal);
  _model = _interopRequireDefault(_model);
  _dateTime = _interopRequireDefault(_dateTime);
  _date = _interopRequireDefault(_date);
  _ui = _interopRequireDefault(_ui);
  var _staticBlock;
  let _init_dateTime, _init_extra_dateTime;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  class ResetFetchDataModalView extends _modal.default {
    constructor() {
      super(...arguments);
      _init_extra_dateTime(this);
    }
    templateContent = `
        <div
            class="alert alert-warning"
        >{{translate 'resetFetchData' category='messages' scope='EmailAccount'}}</div>
        <div class="record-container no-side-margin">{{{record}}}</div>
    `;
    dateTime = _init_dateTime(this);
    setup() {
      this.buttonList = [{
        name: 'reset',
        label: 'Reset',
        style: 'danger',
        onClick: () => this.processReset()
      }, {
        name: 'cancel',
        label: 'Cancel',
        onClick: () => this.close()
      }];
      this.formModel = new _model.default({
        fetchSince: this.dateTime.getToday()
      });
      this.recordView = new _editForModal.default({
        model: this.formModel,
        detailLayout: [{
          rows: [[{
            view: new _date.default({
              name: 'fetchSince',
              labelText: this.translate('fetchSince', 'fields', 'EmailAccount'),
              params: {
                required: true
              }
            })
          }, false]]
        }]
      });
      this.assignView('record', this.recordView);
    }
    async processReset() {
      if (this.recordView.validate()) {
        return;
      }
      await this.confirm({
        message: this.translate('confirmation', 'messages')
      });
      _ui.default.notifyWait();
      this.disableButton('reset');
      let response;
      try {
        response = await _ajax.default.postRequest(`${this.model.entityType}/${this.model.id}/resetFetchData`, {
          fetchSince: this.formModel.attributes.fetchSince
        });
      } catch (e) {
        this.enableButton('reset');
        return;
      }
      this.model.setMultiple(response, {
        sync: true
      });
      _ui.default.success(this.translate('Done'));
      this.close();
    }
    static #_ = _staticBlock = () => [_init_dateTime, _init_extra_dateTime] = _applyDecs(this, [], [[(0, _di.inject)(_dateTime.default), 0, "dateTime"]], 0, void 0, _modal.default).e;
  }
  _exports.default = ResetFetchDataModalView;
  _staticBlock();
});

define("app-portal", ["exports", "app", "acl-portal-manager"], function (_exports, _app, _aclPortalManager) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _app = _interopRequireDefault(_app);
  _aclPortalManager = _interopRequireDefault(_aclPortalManager);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module app-portal */

  /**
   * A portal application class.
   */
  class AppPortal extends _app.default {
    aclName = 'aclPortal';
    masterView = 'views/site-portal/master';
    createAclManager() {
      return new _aclPortalManager.default(this.user, null, this.settings.get('aclAllowDeleteCreated'));
    }
  }
  var _default = _exports.default = AppPortal;
});

define("views/stream", ["exports", "view"], function (_exports, _view) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class StreamView extends _view.default {
    template = 'stream';
    filterList = ['all', 'posts', 'updates'];
    filter = false;
    events = {
      /** @this StreamView */
      'click button[data-action="refresh"]': function () {
        this.actionRefresh();
      },
      /** @this StreamView */
      'click button[data-action="selectFilter"]': function (e) {
        const data = $(e.currentTarget).data();
        this.actionSelectFilter(data);
      }
    };
    data() {
      let filter = this.filter;
      if (filter === false) {
        filter = 'all';
      }
      const hasGlobalStreamAccess = this.getAcl().checkScope('GlobalStream');
      return {
        displayTitle: this.options.displayTitle,
        filterList: this.filterList,
        filter: filter,
        hasMenu: hasGlobalStreamAccess,
        hasGlobalStreamAccess: hasGlobalStreamAccess
      };
    }
    setup() {
      this.filter = this.options.filter || this.filter;
      this.addActionHandler('createPost', () => this.actionCreatePost());
      this.addHandler('keydown.stream', '', /** KeyboardEvent */event => this.onKeyDown(event));
      this.addActionHandler('fullRefresh', () => this.actionFullRefresh());
    }
    afterRender() {
      Espo.Ui.notifyWait();
      this.getCollectionFactory().create('Note', collection => {
        this.collection = collection;
        collection.url = 'Stream';
        this.setFilter(this.filter);
        collection.fetch().then(() => {
          this.createView('list', 'views/stream/record/list', {
            selector: '.list-container',
            collection: collection,
            isUserStream: true
          }, view => {
            view.notify(false);
            view.render().then(view => {
              view.$el.find('> .list > .list-group');
            });
          });
        });
      });
      this.element.querySelector('.button-container').focus({
        preventScroll: true
      });
    }

    /**
     * @return {module:views/stream/record/list}
     */
    getRecordView() {
      return this.getView('list');
    }
    async actionSelectFilter(data) {
      const name = data.name;
      const filter = name;
      let internalFilter = name;
      if (filter === 'all') {
        internalFilter = false;
      }
      this.filter = internalFilter;
      this.setFilter(this.filter);
      this.filterList.forEach(item => {
        const $el = this.$el.find('.button-container button[data-action="selectFilter"][data-name="' + item + '"]');
        if (item === filter) {
          $el.addClass('active');
        } else {
          $el.removeClass('active');
        }
      });
      let url = '#Stream';
      if (this.filter) {
        url += '/' + filter;
      }
      this.getRouter().navigate(url);
      Espo.Ui.notifyWait();
      this.getRecordView().element.innerHTML = '';
      this.collection.abortLastFetch();
      this.collection.reset();
      try {
        await this.collection.fetch();
      } catch (e) {
        return;
      }
      Espo.Ui.notify(false);
    }
    setFilter(filter) {
      this.collection.data.filter = null;
      if (filter) {
        this.collection.data.filter = filter;
      }
      this.collection.offset = 0;
      this.collection.maxSize = this.getConfig().get('recordsPerPage') || this.collection.maxSize;
    }
    actionCreatePost() {
      this.createView('dialog', 'views/stream/modals/create-post', {}, view => {
        view.render();
        this.listenToOnce(view, 'after:save', () => {
          view.close();
          this.getRecordView().showNewRecords();
        });
      });
    }
    actionRefresh() {
      if (!this.getRecordView()) {
        return;
      }
      const iconEl = this.element.querySelector('button[data-action="refresh"] .icon');
      if (iconEl) {
        iconEl.classList.add('animation-spin-fast');
        setTimeout(() => iconEl.classList.remove('animation-spin-fast'), 500);
      }
      Espo.Ui.notifyWait();
      this.getRecordView().showNewRecords().then(() => Espo.Ui.notify(false));
    }

    /**
     * @private
     * @param {KeyboardEvent} event
     */
    onKeyDown(event) {
      const key = Espo.Utils.getKeyFromKeyEvent(event);
      if (key === 'Control+Space') {
        event.stopPropagation();
        event.preventDefault();
        this.actionCreatePost();
      }
    }

    /**
     * @private
     */
    async actionFullRefresh() {
      Espo.Ui.notifyWait();
      await this.collection.fetch();
      Espo.Ui.notify();
    }
  }
  var _default = _exports.default = StreamView;
});

define("views/merge", ["exports", "views/main"], function (_exports, _main) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _main = _interopRequireDefault(_main);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class MergeView extends _main.default {
    template = 'merge';
    name = 'Merge';
    headerView = 'views/header';
    recordView = 'views/record/merge';
    setup() {
      this.models = this.options.models;
      this.setupHeader();
      this.setupRecord();
    }
    setupHeader() {
      this.createView('header', this.headerView, {
        model: this.model,
        fullSelector: '#main > .page-header'
      });
    }
    setupRecord() {
      this.createView('body', this.recordView, {
        fullSelector: '#main > .body',
        models: this.models,
        collection: this.collection
      });
    }
    getHeader() {
      return this.buildHeaderHtml([$('<a>').attr('href', '#' + this.models[0].entityType).text(this.getLanguage().translate(this.models[0].entityType, 'scopeNamesPlural')), $('<span>').text(this.getLanguage().translate('Merge'))]);
    }
    updatePageTitle() {
      this.setPageTitle(this.getLanguage().translate('Merge'));
    }
  }
  var _default = _exports.default = MergeView;
});

define("views/login", ["exports", "view", "js-base64", "jquery"], function (_exports, _view, _jsBase, _jquery) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  _jsBase = _interopRequireDefault(_jsBase);
  _jquery = _interopRequireDefault(_jquery);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/login */

  class LoginView extends _view.default {
    /** @inheritDoc */
    template = 'login';

    /** @inheritDoc */
    views = {
      footer: {
        fullSelector: 'body > footer',
        view: 'views/site/footer'
      }
    };

    /**
     * @type {string|null}
     * @private
     */
    anotherUser = null;

    /** @private */
    isPopoverDestroyed = false;

    /**
     * @type {module:handlers/login}
     * @private
     */
    handler = null;

    /**
     * @type {boolean}
     * @private
     */
    fallback = false;

    /**
     * @type {string|null}
     * @private
     */
    method = null;

    /** @inheritDoc */
    events = {
      /** @this LoginView */
      'submit #login-form': function (e) {
        e.preventDefault();
        this.login();
      },
      /** @this LoginView */
      'click #sign-in': function () {
        this.signIn();
      },
      /** @this LoginView */
      'click a[data-action="passwordChangeRequest"]': function () {
        this.showPasswordChangeRequest();
      },
      /** @this LoginView */
      'click a[data-action="showFallback"]': function () {
        this.showFallback();
      },
      /** @this LoginView */
      'keydown': function (e) {
        if (Espo.Utils.getKeyFromKeyEvent(e) === 'Control+Enter') {
          e.preventDefault();
          if (this.handler && (!this.fallback || !this.$username.val())) {
            this.signIn();
            return;
          }
          this.login();
        }
      }
    };

    /** @inheritDoc */
    data() {
      return {
        logoSrc: this.getLogoSrc(),
        showForgotPassword: this.getConfig().get('passwordRecoveryEnabled'),
        anotherUser: this.anotherUser,
        hasSignIn: !!this.handler,
        hasFallback: !!this.handler && this.fallback,
        method: this.method,
        signInText: this.signInText,
        logInText: this.logInText
      };
    }

    /** @inheritDoc */
    setup() {
      this.addActionHandler('toggleShowPassword', () => this.toggleShowPassword());
      this.anotherUser = this.options.anotherUser || null;
      const loginData = this.getConfig().get('loginData') || {};
      this.fallback = !!loginData.fallback;
      this.method = loginData.method;
      if (loginData.handler) {
        this.wait(Espo.loader.requirePromise(loginData.handler).then(Handler => {
          this.handler = new Handler(this, loginData.data || {});
        }));
        this.signInText = this.getLanguage().has(this.method, 'signInLabels', 'Global') ? this.translate(this.method, 'signInLabels') : this.translate('Sign in');
      }
      this.wait(this.getHelper().processSetupHandlers(this, 'login'));
      if (this.getLanguage().has('Log in', 'labels', 'Global')) {
        this.logInText = this.translate('Log in');
      }
      this.logInText = this.getLanguage().has('Log in', 'labels', 'Global') ? this.translate('Log in') : this.translate('Login');
    }

    /**
     * @private
     * @return {string}
     */
    getLogoSrc() {
      const companyLogoId = this.getConfig().get('companyLogoId');
      if (!companyLogoId) {
        return this.getBasePath() + (this.getConfig().get('logoSrc') || 'client/img/logo.svg');
      }
      return this.getBasePath() + '?entryPoint=LogoImage&id=' + companyLogoId;
    }

    /** @inheritDoc */
    afterRender() {
      this.$submit = this.$el.find('#btn-login');
      this.$signIn = this.$el.find('#sign-in');
      this.$username = this.$el.find('#field-userName');
      this.$password = this.$el.find('#field-password');
      if (this.options.prefilledUsername) {
        this.$username.val(this.options.prefilledUsername);
      }
      if (this.handler) {
        this.$username.closest('.cell').addClass('hidden');
        this.$password.closest('.cell').addClass('hidden');
        this.$submit.closest('.cell').addClass('hidden');
      }
    }

    /** @private */
    signIn() {
      this.disableForm();
      this.handler.process().then(headers => {
        this.proceed(headers, this.options.prefilledUsername);
      }).catch(() => {
        this.undisableForm();
      });
    }

    /** @private */
    login() {
      let authString;
      let userName = this.$username.val();
      const password = this.$password.val();
      const trimmedUserName = userName.trim();
      if (trimmedUserName !== userName) {
        this.$username.val(trimmedUserName);
        userName = trimmedUserName;
      }
      if (userName === '') {
        this.processEmptyUsername();
        return;
      }
      this.disableForm();
      try {
        authString = _jsBase.default.encode(userName + ':' + password);
      } catch (e) {
        Espo.Ui.error(this.translate('Error') + ': ' + e.message, true);
        this.undisableForm();
        throw e;
      }
      const headers = {
        'Authorization': 'Basic ' + authString,
        'Espo-Authorization': authString
      };
      this.proceed(headers, userName, password);
    }

    /**
     * @private
     * @param {Object.<string, string>} headers
     * @param {string} [userName]
     * @param {string} [password]
     */
    proceed(headers, userName, password) {
      headers = Espo.Utils.clone(headers);
      const initialHeaders = Espo.Utils.clone(headers);
      headers['Espo-Authorization-By-Token'] = 'false';
      headers['Espo-Authorization-Create-Token-Secret'] = 'true';
      if (this.anotherUser !== null) {
        headers['X-Another-User'] = this.anotherUser;
      }
      this.notifyLoading();
      Espo.Ajax.getRequest('App/user', null, {
        login: true,
        headers: headers
      }).then(data => {
        Espo.Ui.notify(false);
        this.triggerLogin(userName, data);
      }).catch(xhr => {
        this.undisableForm();
        if (xhr.status === 401) {
          const data = xhr.responseJSON || {};
          const statusReason = xhr.getResponseHeader('X-Status-Reason');
          if (statusReason === 'second-step-required') {
            xhr.errorIsHandled = true;
            this.onSecondStepRequired(initialHeaders, userName, password, data);
            return;
          }
          if (statusReason === 'error') {
            this.onError();
            return;
          }
          this.onWrongCredentials();
        }
      });
    }

    /**
     * Trigger login to proceed to the application.
     *
     * @private
     * @param {string|null} userName A username.
     * @param {Object.<string, *>} data Data returned from the `App/user` request.
     */
    triggerLogin(userName, data) {
      if (this.anotherUser) {
        data.anotherUser = this.anotherUser;
      }
      if (!userName) {
        userName = (data.user || {}).userName;
      }
      this.trigger('login', userName, data);
    }

    /** @private */
    processEmptyUsername() {
      this.isPopoverDestroyed = false;
      const $el = this.$username;
      const message = this.getLanguage().translate('userCantBeEmpty', 'messages', 'User');
      $el.popover({
        placement: 'bottom',
        container: 'body',
        content: message,
        trigger: 'manual'
      }).popover('show');
      const $cell = $el.closest('.form-group');
      $cell.addClass('has-error');
      $el.one('mousedown click', () => {
        $cell.removeClass('has-error');
        if (this.isPopoverDestroyed) {
          return;
        }
        $el.popover('destroy');
        this.isPopoverDestroyed = true;
      });
    }

    /** @private */
    disableForm() {
      this.$submit.addClass('disabled').attr('disabled', 'disabled');
      this.$signIn.addClass('disabled').attr('disabled', 'disabled');
    }

    /** @private */
    undisableForm() {
      this.$submit.removeClass('disabled').removeAttr('disabled');
      this.$signIn.removeClass('disabled').removeAttr('disabled');
    }

    /**
     * @private
     * @param {Object.<string, string>} headers
     * @param {string} userName
     * @param {string} password
     * @param {Object.<string, *>} data
     */
    onSecondStepRequired(headers, userName, password, data) {
      const view = data.view || 'views/login-second-step';
      this.trigger('redirect', view, headers, userName, password, data);
    }

    /** @private */
    onError() {
      this.onFail('loginError');
    }

    /** @private */
    onWrongCredentials() {
      const msg = this.handler ? 'failedToLogIn' : 'wrongUsernamePassword';
      this.onFail(msg);
    }

    /** @private */
    onFail(msg) {
      const $cell = (0, _jquery.default)('#login .form-group');
      $cell.addClass('has-error');
      this.$el.one('mousedown click', () => {
        $cell.removeClass('has-error');
      });
      Espo.Ui.error(this.translate(msg, 'messages', 'User'));
    }

    /** @private */
    showFallback() {
      this.$el.find('[data-action="showFallback"]').addClass('hidden');
      this.$el.find('.panel-body').addClass('fallback-shown');
      this.$username.closest('.cell').removeClass('hidden');
      this.$password.closest('.cell').removeClass('hidden');
      this.$submit.closest('.cell').removeClass('hidden');
    }

    /** @private */
    notifyLoading() {
      Espo.Ui.notifyWait();
    }

    /** @private */
    showPasswordChangeRequest() {
      this.notifyLoading();
      this.createView('passwordChangeRequest', 'views/modals/password-change-request', {
        url: window.location.href
      }, view => {
        view.render();
        Espo.Ui.notify(false);
      });
    }

    /**
     * @private
     */
    toggleShowPassword() {
      const input = this.element.querySelector('[id="field-password"]');
      const button = this.element.querySelector('[data-action="toggleShowPassword"]');
      const icon = button.children[0];
      if (!(input instanceof HTMLInputElement)) {
        return;
      }
      if (input.type === 'password') {
        input.type = 'text';

        //button.classList.remove('text-soft');
        //button.classList.add('text-primary');

        icon.classList.remove('fa-eye');
        icon.classList.add('fa-eye-slash');
      } else {
        input.type = 'password';

        //button.classList.remove('text-primary');
        //button.classList.add('text-soft');

        icon.classList.remove('fa-eye-slash');
        icon.classList.add('fa-eye');
      }
      input.focus();
      input.setSelectionRange(input.value.length, input.value.length);
    }
  }
  var _default = _exports.default = LoginView;
});

define("views/login-second-step", ["exports", "view", "js-base64", "jquery"], function (_exports, _view, _jsBase, _jquery) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  _jsBase = _interopRequireDefault(_jsBase);
  _jquery = _interopRequireDefault(_jquery);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class LoginSecondStepView extends _view.default {
    /** @inheritDoc */
    template = 'login-second-step';

    /** @inheritDoc */
    views = {
      footer: {
        fullSelector: 'body > footer',
        view: 'views/site/footer'
      }
    };

    /**
     * @type {string|null}
     * @private
     */
    anotherUser = null;

    /**
     * Response from the first step.
     *
     * @type {Object.<string, *>}
     * @private
     */
    loginData = null;

    /**
     * Headers composed in the first step.
     *
     * @type {Object.<string, string>}
     * @private
     */
    headers = null;

    /** @private */
    isPopoverDestroyed = false;

    /** @inheritDoc */
    events = {
      /** @this LoginSecondStepView */
      'submit #login-form': function (e) {
        e.preventDefault();
        this.send();
      },
      /** @this LoginSecondStepView */
      'click [data-action="backToLogin"]': function () {
        this.trigger('back');
      },
      /** @this LoginSecondStepView */
      'keydown': function (e) {
        if (Espo.Utils.getKeyFromKeyEvent(e) === 'Control+Enter') {
          e.preventDefault();
          this.send();
        }
      }
    };

    /** @inheritDoc */
    data() {
      return {
        message: this.message
      };
    }

    /** @inheritDoc */
    setup() {
      this.message = this.translate(this.options.loginData.message, 'messages', 'User');
      this.anotherUser = this.options.anotherUser || null;
      this.headers = this.options.headers || {};
      this.loginData = this.options.loginData;
    }

    /** @inheritDoc */
    afterRender() {
      this.$code = (0, _jquery.default)('[data-name="field-code"]');
      this.$submit = this.$el.find('#btn-send');
      this.$code.focus();
    }

    /** @private */
    send() {
      const code = this.$code.val().trim().replace(/\s/g, '');
      const userName = this.options.userName;
      const token = this.loginData.token;
      const headers = Espo.Utils.clone(this.headers);
      if (code === '') {
        this.processEmptyCode();
        return;
      }
      this.disableForm();
      if (userName && token) {
        const authString = _jsBase.default.encode(userName + ':' + token);
        headers['Authorization'] = 'Basic ' + authString;
        headers['Espo-Authorization'] = authString;
      }
      headers['Espo-Authorization-Code'] = code;
      headers['Espo-Authorization-Create-Token-Secret'] = 'true';
      if (this.anotherUser !== null) {
        headers['X-Another-User'] = this.anotherUser;
      }
      this.notifyLoading();
      Espo.Ajax.getRequest('App/user', null, {
        login: true,
        headers: headers
      }).then(data => {
        Espo.Ui.notify(false);
        this.triggerLogin(userName, data);
      }).catch(xhr => {
        this.undisableForm();
        if (xhr.status === 401) {
          const statusReason = xhr.getResponseHeader('X-Status-Reason');
          if (statusReason === 'error') {
            this.onError();
            return;
          }
          this.onWrongCredentials();
        }
      });
    }

    /**
     * Trigger login to proceed to the application.
     *
     * @private
     * @param {string} userName A username.
     * @param {Object.<string, *>} data Data returned from the `App/user` request.
     */
    triggerLogin(userName, data) {
      if (this.anotherUser) {
        data.anotherUser = this.anotherUser;
      }
      if (!userName) {
        userName = (data.user || {}).userName;
      }
      this.trigger('login', userName, data);
    }

    /** @private */
    processEmptyCode() {
      this.isPopoverDestroyed = false;
      const message = this.getLanguage().translate('codeIsRequired', 'messages', 'User');
      const $el = this.$code;
      $el.popover({
        placement: 'bottom',
        container: 'body',
        content: message,
        trigger: 'manual'
      }).popover('show');
      const $cell = $el.closest('.form-group');
      $cell.addClass('has-error');
      $el.one('mousedown click', () => {
        $cell.removeClass('has-error');
        if (this.isPopoverDestroyed) {
          return;
        }
        $el.popover('destroy');
        this.isPopoverDestroyed = true;
      });
    }

    /** @private */
    onFail(msg) {
      const $cell = (0, _jquery.default)('#login .form-group');
      $cell.addClass('has-error');
      this.$el.one('mousedown click', () => {
        $cell.removeClass('has-error');
      });
      Espo.Ui.error(this.translate(msg, 'messages', 'User'));
    }

    /** @private */
    onError() {
      this.onFail('loginError');
    }

    /** @private */
    onWrongCredentials() {
      this.onFail('wrongCode');
    }

    /** @private */
    notifyLoading() {
      Espo.Ui.notifyWait();
    }

    /** @private */
    disableForm() {
      this.$submit.addClass('disabled').attr('disabled', 'disabled');
    }

    /** @private */
    undisableForm() {
      this.$submit.removeClass('disabled').removeAttr('disabled');
    }
  }

  // noinspection JSUnusedGlobalSymbols
  var _default = _exports.default = LoginSecondStepView;
});

define("views/list-tree", ["exports", "views/list"], function (_exports, _list) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _list = _interopRequireDefault(_list);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ListTreeView extends _list.default {
    searchPanel = false;
    createButton = false;
    name = 'listTree';
    getRecordViewName() {
      return this.getMetadata().get(['clientDefs', this.scope, 'recordViews', 'listTree']) || 'views/record/list-tree';
    }
  }
  var _default = _exports.default = ListTreeView;
});

define("views/list-related", ["exports", "views/main", "search-manager", "helpers/record/create-related", "ui", "ajax", "utils"], function (_exports, _main, _searchManager, _createRelated, _ui, _ajax, _utils) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _main = _interopRequireDefault(_main);
  _searchManager = _interopRequireDefault(_searchManager);
  _createRelated = _interopRequireDefault(_createRelated);
  _ui = _interopRequireDefault(_ui);
  _ajax = _interopRequireDefault(_ajax);
  _utils = _interopRequireDefault(_utils);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * A list-related view.
   */
  class ListRelatedView extends _main.default {
    template = 'list';
    name = 'ListRelated';

    /**
     * A header view name.
     */
    headerView = 'views/header';

    /**
     * A search view name.
     */
    searchView = 'views/record/search';

    /**
     * A record/list view name.
     */
    recordView = 'views/record/list';

    /**
     * Has a search panel.
     */
    searchPanel = true;

    /**
     * A search manager.
     */
    searchManager = null;
    optionsToPass = [];

    /**
     * Use a current URL as a root URL when open a record. To be able to return to the same URL.
     */
    keepCurrentRootUrl = false;

    /**
     * A view mode. 'list', 'kanban'.
     */

    /**
     * An available view mode list.
     */

    /**
     * A default view mode.
     */
    defaultViewMode = 'list';
    MODE_LIST = 'list';
    rowActionsView = 'views/record/row-actions/relationship';

    /**
     * A create button.
     *
     */
    createButton = true;
    unlinkDisabled = false;
    filtersDisabled = false;
    /**
     * Disable select-all-result.
     *
     */
    allResultDisabled = false;
    shortcutKeys = {
      'Control+Space': function (e) {
        this.handleShortcutKeyCtrlSpace(e);
      },
      'Control+Slash': function (e) {
        this.handleShortcutKeyCtrlSlash(e);
      },
      'Control+Comma': function (e) {
        this.handleShortcutKeyCtrlComma(e);
      },
      'Control+Period': function (e) {
        this.handleShortcutKeyCtrlPeriod(e);
      }
    };
    setup() {
      var _this$options$params;
      if (!this.options.link) {
        console.error(`Link not passed.`);
        throw new Error();
      }
      this.link = this.options.link;
      if (!this.model) {
        console.error(`Model not passed.`);
        throw new Error();
      }
      if (!this.collection) {
        console.error(`Collection not passed.`);
        throw new Error();
      }
      this.rootUrl = this.options.rootUrl ?? ((_this$options$params = this.options.params) === null || _this$options$params === void 0 ? void 0 : _this$options$params.rootUrl) ?? `#${this.scope}`;
      this.nameAttribute = this.getMetadata().get(`clientDefs.${this.scope}.nameAttribute`) ?? 'name';
      this.panelDefs = this.getMetadata().get(['clientDefs', this.scope, 'relationshipPanels', this.link]) ?? {};
      if (this.panelDefs.fullFormDisabled) {
        console.error(`Full-form disabled.`);
        throw new Error();
      }
      this.collection.maxSize = this.getConfig().get('recordsPerPage') || this.collection.maxSize;
      this.collectionUrl = this.collection.url;
      this.collectionMaxSize = this.collection.maxSize;
      if (this.panelDefs.primaryFilter) {
        this.collection.data.primaryFilter = this.panelDefs.primaryFilter;
      }
      if (!this.collection.entityType) {
        console.error(`Not foreign entity type.`);
        throw new Error();
      }
      this.foreignScope = this.collection.entityType;
      this.setupModes();
      this.setViewMode(this.viewMode);
      if (this.getMetadata().get(['clientDefs', this.foreignScope, 'searchPanelDisabled'])) {
        this.searchPanel = false;
      }
      if (this.getUser().isPortal() && this.getMetadata().get(['clientDefs', this.foreignScope, 'searchPanelInPortalDisabled'])) {
        this.searchPanel = false;
      }
      if (this.getMetadata().get(['clientDefs', this.foreignScope, 'createDisabled'])) {
        this.createButton = false;
      }

      // noinspection JSUnresolvedReference
      if (this.panelDefs.create === false || this.panelDefs.createDisabled || this.panelDefs.createAction) {
        this.createButton = false;
      }
      this.entityType = this.collection.entityType;
      this.headerView = this.options.headerView || this.headerView;
      this.recordView = this.options.recordView || this.recordView;
      this.searchView = this.options.searchView || this.searchView;
      this.setupHeader();
      this.defaultOrderBy = this.panelDefs.orderBy || this.collection.orderBy;
      this.defaultOrder = this.panelDefs.orderDirection || this.collection.order;
      if (this.panelDefs.orderBy && !this.panelDefs.orderDirection) {
        this.defaultOrder = 'asc';
      }
      this.collection.setOrder(this.defaultOrderBy, this.defaultOrder, true);
      if (this.searchPanel) {
        this.setupSearchManager();
      }
      this.setupSorting();
      if (this.searchPanel) {
        this.setupSearchPanel();
      }
      if (this.createButton) {
        this.setupCreateButton();
      }
      if (this.options.params && this.options.params.fromAdmin) {
        this.keepCurrentRootUrl = true;
      }
      this.wait(this.getHelper().processSetupHandlers(this, 'list'));
      this.addActionHandler('fullRefresh', () => this.actionFullRefresh());
      this.addActionHandler('removeRelated', (_e, target) => this.actionRemoveRelated({
        id: target.dataset.id
      }));
    }

    /**
     * Set up modes.
     */
    setupModes() {
      this.defaultViewMode = this.options.defaultViewMode ?? this.getMetadata().get(['clientDefs', this.foreignScope, 'listRelatedDefaultViewMode']) ?? this.defaultViewMode;
      this.viewMode = this.viewMode || this.defaultViewMode;
      const viewModeList = this.options.viewModeList || this.viewModeList || this.getMetadata().get(['clientDefs', this.foreignScope, 'listRelatedViewModeList']);
      this.viewModeList = viewModeList ? viewModeList : [this.MODE_LIST];
      if (this.viewModeList.length > 1) {
        let viewMode = null;
        const modeKey = 'listRelatedViewMode' + this.scope + this.link;
        if (this.getStorage().has('state', modeKey)) {
          const storedViewMode = this.getStorage().get('state', modeKey);
          if (storedViewMode && this.viewModeList.includes(storedViewMode)) {
            viewMode = storedViewMode;
          }
        }
        if (!viewMode) {
          viewMode = this.defaultViewMode;
        }
        this.viewMode = viewMode;
      }
    }

    /**
     * Set up a header.
     */
    setupHeader() {
      this.createView('header', this.headerView, {
        collection: this.collection,
        fullSelector: '#main > .page-header',
        scope: this.scope,
        isXsSingleRow: true
      });
    }

    /**
     * Set up a create button.
     */
    setupCreateButton() {
      this.addMenuItem('buttons', {
        action: 'quickCreate',
        iconHtml: '<span class="fas fa-plus fa-sm"></span>',
        text: this.translate('Create ' + this.foreignScope, 'labels', this.foreignScope),
        style: 'default',
        acl: 'create',
        aclScope: this.foreignScope,
        title: 'Ctrl+Space'
      });
    }

    /**
     * Set up a search panel.
     */
    setupSearchPanel() {
      this.createSearchView();
    }

    /**
     * Create a search view.
     *
     */
    async createSearchView() {
      let filterList = _utils.default.clone(this.getMetadata().get(['clientDefs', this.foreignScope, 'filterList']) || []);
      if (this.panelDefs.filterList) {
        this.panelDefs.filterList.forEach(item1 => {
          let isFound = false;
          const name1 = item1.name || item1;
          if (!name1 || name1 === 'all') {
            return;
          }
          filterList.forEach(item2 => {
            const name2 = item2.name || item2;
            if (name1 === name2) {
              isFound = true;
            }
          });
          if (!isFound) {
            filterList.push(item1);
          }
        });
      }
      if (this.filtersDisabled) {
        filterList = [];
      }
      const view = await this.createView('search', this.searchView, {
        collection: this.collection,
        fullSelector: '#main > .search-container',
        searchManager: this.searchManager,
        scope: this.foreignScope,
        viewMode: this.viewMode,
        viewModeList: this.viewModeList,
        isWide: true,
        filterList: filterList
      });
      if (this.viewModeList.length > 1) {
        this.listenTo(view, 'change-view-mode', mode => this.switchViewMode(mode));
      }
      return view;
    }

    /**
     * Switch a view mode.
     *
     * @param {string} mode
     */
    switchViewMode(mode) {
      this.clearView('list');
      this.collection.isFetched = false;
      this.collection.reset();
      this.setViewMode(mode, true);
      this.loadList();
    }

    /**
     * Set a view mode.
     *
     * @param mode A mode.
     * @param toStore To preserve a mode being set.
     */
    setViewMode(mode) {
      let toStore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
      this.viewMode = mode;
      this.collection.url = this.collectionUrl;
      this.collection.maxSize = this.collectionMaxSize;
      if (toStore) {
        const modeKey = 'listViewMode' + this.scope + this.link;
        this.getStorage().set('state', modeKey, mode);
      }
      if (this.searchView && this.getView('search')) {
        this.getSearchView().setViewMode(mode);
      }
      const methodName = 'setViewMode' + _utils.default.upperCaseFirst(this.viewMode);

      // @ts-ignore
      if (this[methodName]) {
        // @ts-ignore
        this[methodName]();
      }
    }

    /**
     * Set up a search manager.
     */
    setupSearchManager() {
      const collection = this.collection;
      const searchManager = new _searchManager.default(collection, {
        scope: this.foreignScope
      });
      if (this.panelDefs.primaryFilter) {
        searchManager.setPrimary(this.panelDefs.primaryFilter);
      }
      collection.where = searchManager.getWhere();
      this.searchManager = searchManager;
    }

    /**
     * Set up sorting.
     */
    setupSorting() {}
    getSearchView() {
      return this.getView('search');
    }
    getRecordView() {
      return this.getView('list');
    }

    /**
     * Get a record view name.
     */
    getRecordViewName() {
      if (this.viewMode === this.MODE_LIST) {
        return this.panelDefs.recordListView ?? this.getMetadata().get(['clientDefs', this.foreignScope, 'recordViews', this.MODE_LIST]) ?? this.recordView;
      }
      const propertyName = 'record' + _utils.default.upperCaseFirst(this.viewMode) + 'View';
      return this.getMetadata().get(['clientDefs', this.foreignScope, 'recordViews', this.viewMode]) ||
      // @ts-ignore
      this[propertyName];
    }
    afterRender() {
      _ui.default.notify();
      if (!this.hasView('list')) {
        this.loadList();
      }

      // noinspection JSUnresolvedReference
      this.$el.get(0).focus({
        preventScroll: true
      });
    }

    /**
     * Load a record list view.
     */
    loadList() {
      if ('isFetched' in this.collection && this.collection.isFetched) {
        this.createListRecordView(false);
        return;
      }
      _ui.default.notifyWait();
      this.createListRecordView(true);
    }

    /**
     * Prepare record view options. Options can be modified in an extended method.
     *
     * @param options Options
     */
    prepareRecordViewOptions(options) {
      // noinspection BadExpressionStatementJS
      options;
    }

    /**
     * Create a record list view.
     *
     * @param fetch To fetch after creation.
     */
    async createListRecordView() {
      let fetch = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
      let o = {
        collection: this.collection,
        selector: '.list-container',
        scope: this.foreignScope,
        skipBuildRows: true,
        shortcutKeysEnabled: true
      };
      this.optionsToPass.forEach(option => {
        o[option] = this.options[option];
      });
      if (this.keepCurrentRootUrl) {
        o.keepCurrentRootUrl = true;
      }
      if (this.panelDefs.layout && typeof this.panelDefs.layout === 'string') {
        o.layoutName = this.panelDefs.layout;
      }
      o.rowActionsView = this.panelDefs.readOnly ? false : this.panelDefs.rowActionsView || this.rowActionsView;
      if (this.getConfig().get('listPagination') || this.getMetadata().get(['clientDefs', this.foreignScope, 'listPagination'])) {
        o.pagination = true;
      }
      const massUnlinkDisabled = this.panelDefs.massUnlinkDisabled || this.panelDefs.unlinkDisabled || this.unlinkDisabled;
      o = {
        unlinkMassAction: !massUnlinkDisabled,
        skipBuildRows: true,
        buttonsDisabled: true,
        forceDisplayTopBar: true,
        rowActionsOptions: {
          unlinkDisabled: this.panelDefs.unlinkDisabled || this.unlinkDisabled,
          editDisabled: this.panelDefs.editDisabled,
          removeDisabled: this.panelDefs.removeDisabled
        },
        additionalRowActionList: this.panelDefs.rowActionList,
        ...o,
        settingsEnabled: true,
        removeDisabled: this.panelDefs.removeDisabled
      };
      if (this.getHelper().isXsScreen()) {
        o.type = 'listSmall';
      }
      const foreignLink = this.model.getLinkParam(this.link, 'foreign');
      if (!this.allResultDisabled && !this.panelDefs.allResultDisabled && foreignLink) {
        o.forceAllResultSelectable = true;
        o.allResultWhereItem = {
          type: 'linkedWith',
          attribute: foreignLink,
          value: [this.model.id]
        };
      }
      this.prepareRecordViewOptions(o);
      const listViewName = this.getRecordViewName();
      const promise = this.createView('list', listViewName, o).then(async view => {
        if (!this.hasParentView()) {
          view.undelegateEvents();
          return view;
        }
        this.listenTo(view, 'after:paginate', () => window.scrollTo({
          top: 0
        }));
        this.listenTo(view, 'sort', () => window.scrollTo({
          top: 0
        }));
        this.listenToOnce(view, 'after:render', () => {
          if (!this.hasParentView()) {
            view.undelegateEvents();
            this.clearView('list');
          }
        });
        if (!fetch) {
          await view.render();
          return view;
        }
        const selectAttributes = await view.getSelectAttributeList();
        if (this.options.mediator && this.options.mediator.abort) {
          return view;
        }
        if (selectAttributes) {
          this.collection.data.select = selectAttributes.join(',');
        }
        _ui.default.notifyWait();
        await this.collection.fetch({
          main: true
        });
        _ui.default.notify();
        return view;
      });
      return promise;
    }

    /**
     * A quick-create action.
     */
    async actionQuickCreate(data) {
      data = data ?? {};
      const link = this.link;
      const helper = new _createRelated.default(this);
      return helper.process(this.model, link, {
        focusForCreate: data.focusForCreate,
        afterSave: () => {
          this.collection.fetch();
        }
      });
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * An `unlink-related` action.
     */
    async actionUnlinkRelated(data) {
      const id = data.id;
      await this.confirm({
        message: this.translate('unlinkRecordConfirmation', 'messages'),
        confirmText: this.translate('Unlink')
      });
      _ui.default.notifyWait();
      await _ajax.default.deleteRequest(this.collection.url, {
        id: id
      });
      _ui.default.success(this.translate('Unlinked'));
      this.collection.fetch();
      this.model.trigger('after:unrelate');
      this.model.trigger(`after:unrelate:${this.link}`);
    }
    getHeader() {
      const name = this.model.attributes[this.nameAttribute] || this.model.id;
      const recordUrl = `#${this.scope}/view/${this.model.id}`;
      const title = document.createElement('a');
      title.href = recordUrl;
      title.classList.add('font-size-flexible', 'title');
      title.textContent = name;
      title.style.userSelect = 'none';
      if (this.model.attributes.deleted) {
        title.style.textDecoration = 'line-through';
      }
      const scopeLabel = this.getLanguage().translate(this.scope, 'scopeNamesPlural');
      let root = document.createElement('span');
      root.textContent = scopeLabel;
      root.style.userSelect = 'none';
      if (!this.rootLinkDisabled) {
        const a = document.createElement('a');
        if (this.rootUrl) {
          a.href = this.rootUrl;
        }
        a.classList.add('action');
        a.dataset.action = 'navigateToRoot';
        a.text = scopeLabel;
        root = document.createElement('span');
        root.style.userSelect = 'none';
        root.append(a);
      }
      const iconHtml = this.getHeaderIconHtml();
      if (iconHtml) {
        root.insertAdjacentHTML('afterbegin', iconHtml);
      }
      const link = document.createElement('span');
      link.textContent = this.translate(this.link, 'links', this.scope);
      link.title = this.translate('clickToRefresh', 'messages');
      link.dataset.action = 'fullRefresh';
      link.style.cursor = 'pointer';
      link.style.userSelect = 'none';
      return this.buildHeaderHtml([root, title, link]);
    }
    updatePageTitle() {
      this.setPageTitle(this.getLanguage().translate(this.link, 'links', this.scope));
    }

    /**
     * Create attributes for an entity being created.
     */
    getCreateAttributes() {
      return null;
    }
    handleShortcutKeyCtrlSpace(e) {
      if (!this.createButton) {
        return;
      }
      if (!this.getAcl().checkScope(this.foreignScope, 'create')) {
        return;
      }
      e.preventDefault();
      e.stopPropagation();
      this.actionQuickCreate({
        focusForCreate: true
      });
    }
    handleShortcutKeyCtrlSlash(e) {
      if (!this.searchPanel) {
        return;
      }
      const $search = this.$el.find('input.text-filter').first();
      if (!$search.length) {
        return;
      }
      e.preventDefault();
      e.stopPropagation();
      $search.focus();
    }
    handleShortcutKeyCtrlComma(event) {
      // noinspection BadExpressionStatementJS
      event;
      if (!this.getSearchView()) {
        return;
      }
      this.getSearchView().selectPreviousPreset();
    }
    handleShortcutKeyCtrlPeriod(event) {
      // noinspection BadExpressionStatementJS
      event;
      if (!this.getSearchView()) {
        return;
      }
      this.getSearchView().selectNextPreset();
    }
    async actionFullRefresh() {
      _ui.default.notifyWait();
      await this.collection.fetch();
      _ui.default.notify();
    }
    async actionRemoveRelated(data) {
      const id = data.id;
      await this.confirm({
        message: this.translate('removeRecordConfirmation', 'messages'),
        confirmText: this.translate('Remove')
      });
      const model = this.collection.get(id);
      if (!model) {
        return;
      }
      _ui.default.notifyWait();
      await model.destroy();
      _ui.default.success(this.translate('Removed'));
      this.collection.fetch().then(() => {});
      this.model.trigger('after:unrelate');
      this.model.trigger(`after:unrelate:${this.link}`);
    }
  }
  var _default = _exports.default = ListRelatedView;
});

define("views/home", ["exports", "view"], function (_exports, _view) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class HomeView extends _view.default {
    template = 'home';
    setup() {
      const viewName = this.getMetadata().get(['clientDefs', 'Home', 'view']) || 'views/dashboard';
      this.createView('content', viewName, {
        selector: '> .home-content'
      });
    }
  }
  var _default = _exports.default = HomeView;
});

define("views/header", ["exports", "view", "views/main/header-buttons"], function (_exports, _view, _headerButtons) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  _headerButtons = _interopRequireDefault(_headerButtons);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/header */

  class HeaderView extends _view.default {
    template = 'header';

    /**
     * @type {string}
     * @private
     */
    scope;
    data() {
      const data = {};
      if ('getHeader' in this.getParentMainView()) {
        data.header = this.getParentMainView().getHeader();
      }
      data.scope = this.scope || this.getParentMainView().scope;
      data.items = this.getItems();
      const dropdown = (data.items || {}).dropdown || [];
      data.hasVisibleDropdownItems = false;
      dropdown.forEach(item => {
        if (!item.hidden) {
          data.hasVisibleDropdownItems = true;
        }
      });
      data.noBreakWords = this.options.fontSizeFlexible;
      data.isXsSingleRow = this.options.isXsSingleRow;
      data.menuItemsHidden = this.menuItemsHidden;
      if ((data.items.buttons || []).length < 2) {
        data.isHeaderAdditionalSpace = true;
      }
      return data;
    }
    setup() {
      this.scope = this.options.scope;
      this.setupButtons();
      if (this.model) {
        this.listenTo(this.model, 'after:save', () => {
          if (this.isRendered()) {
            this.reRender({
              buffer: true
            });
          }
        });
      }
      this.wasRendered = false;
      if (this.options.fontSizeFlexible) {
        this.on('action-item-update', () => {
          if (this.isRendered()) {
            this.adjustFontSize();
          }
        });
      }
    }

    /**
     * Hide all menu items.
     *
     * @return {Promise}
     */
    async hideAllMenuItems() {
      this.menuItemsHidden = true;
      await this.reRenderButtons();
      this.adjustFontSize();
    }

    /**
     * Show all menu items.
     *
     * @return {Promise}
     */
    async showAllActionItems() {
      this.menuItemsHidden = false;
      await this.reRenderButtons();
      this.adjustFontSize();
    }
    afterRender() {
      if (this.options.fontSizeFlexible) {
        /** @private */
        this.$headerBreadcrumps = this.$el.find('.header-breadcrumbs');
        this._titleIsInitiated = false;
        this.adjustFontSize();
      }
      if (this.wasRendered) {
        this.getParentMainView().trigger('header-rendered');
      }
      this.wasRendered = true;
    }

    /**
     * @private
     * @param {number} step
     */
    adjustFontSize() {
      let step = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
      if (!step) {
        this.fontSizePercentage = 100;
      }
      const $container = this.$headerBreadcrumps;
      const containerWidth = $container.width();
      let childrenWidth = 0;
      $container.children().each((i, el) => {
        childrenWidth += $(el).outerWidth(true);
      });
      if (containerWidth >= childrenWidth) {
        return;
      }
      if (step > 7) {
        if (this._titleIsInitiated) {
          return;
        }
        this._titleIsInitiated = true;
        $container.addClass('overlapped');
        this.$el.find('.title').each((i, el) => {
          const $el = $(el);
          const text = $(el).text();
          $el.attr('title', text);
          let isInitialized = false;
          $el.on('touchstart', () => {
            if (!isInitialized) {
              $el.attr('title', '');
              isInitialized = true;
              Espo.Ui.popover($el, {
                content: text,
                noToggleInit: true
              }, this);
            }
            $el.popover('toggle');
          });
        });
        return;
      }
      this.fontSizePercentage -= 4;
      const $flexible = this.$el.find('.font-size-flexible');
      $flexible.css('font-size', this.fontSizePercentage + '%');
      $flexible.css('position', 'relative');
      if (step > 6) {
        $flexible.css('top', '-1px');
      } else if (step > 4) {
        $flexible.css('top', '-1px');
      }
      this.adjustFontSize(step + 1);
    }

    /**
     * @private
     * @returns {{
     *     buttons?: import('views/main').MenuItem[],
     *     dropdown?: import('views/main').MenuItem[],
     *     actions?: import('views/main').MenuItem[],
     * }}
     */
    getItems() {
      return this.getParentMainView().getMenu() || {};
    }

    /**
     * @return {import('views/main').default}
     */
    getParentMainView() {
      return /** @type {import('views/main').default} */this.getParentView();
    }

    /**
     * @private
     */
    setupButtons() {
      var _this$model;
      const view = new _headerButtons.default({
        scope: this.scope ?? ((_this$model = this.model) === null || _this$model === void 0 ? void 0 : _this$model.entityType) ?? null,
        dataProvider: () => {
          const items = this.getItems();
          return {
            buttons: items.buttons ?? [],
            actions: items.actions ?? [],
            dropdown: items.dropdown ?? [],
            hidden: this.menuItemsHidden
          };
        }
      });
      this.assignView('buttons', view);
    }

    /**
     * @private
     * @return {HeaderButtonsView}
     */
    getButtonsView() {
      return this.getView('buttons');
    }

    /**
     * Re-render buttons.
     *
     * @since 10.0.0
     */
    async reRenderButtons() {
      var _this$getButtonsView;
      if (!this.isReady) {
        return;
      }
      await ((_this$getButtonsView = this.getButtonsView()) === null || _this$getButtonsView === void 0 ? void 0 : _this$getButtonsView.reRender({
        buffer: true
      }));
    }
  }
  var _default = _exports.default = HeaderView;
});

define("views/deleted-detail", ["exports", "views/detail"], function (_exports, _detail) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _detail = _interopRequireDefault(_detail);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class DeletedDetailView extends _detail.default {
    recordView = 'views/record/deleted-detail';
    menuDisabled = true;
    setup() {
      super.setup();
      if (this.model.get('deleted')) {
        this.menuDisabled = true;
      }
    }
    getRecordViewName() {
      return this.recordView;
    }
  }

  // noinspection JSUnusedGlobalSymbols
  var _default = _exports.default = DeletedDetailView;
});

define("views/dashlet", ["exports", "view"], function (_exports, _view) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/dashlet */

  /**
   * A dashlet container view.
   */
  class DashletView extends _view.default {
    /** @inheritDoc */
    template = 'dashlet';

    /**
     * A dashlet name.
     *
     * @type {string}
     */
    name;

    /**
     * A dashlet ID.
     *
     * @type {string}
     */
    id;

    /**
     * An options view name.
     *
     * @protected
     * @type {string|null}
     */
    optionsView = null;

    /** @inheritDoc */
    data() {
      const bodyView = this.getBodyView();
      return {
        name: this.name,
        id: this.id,
        title: this.getTitle(),
        actionList: bodyView ? bodyView.getActionItemDataList() : [],
        buttonList: bodyView ? bodyView.buttonList : [],
        noPadding: bodyView ? bodyView.noPadding : false,
        color: bodyView ? bodyView.getColor() : null
      };
    }

    /** @inheritDoc */
    events = {
      /** @this DashletView */
      'click .action': function (e) {
        const isHandled = Espo.Utils.handleAction(this, e.originalEvent, e.currentTarget);
        if (isHandled) {
          return;
        }
        this.getBodyView().handleAction(e.originalEvent, e.currentTarget);
      },
      /** @this DashletView */
      'mousedown .panel-heading .dropdown-menu': function (e) {
        // Prevent dragging.
        e.stopPropagation();
      },
      /** @this DashletView */
      'shown.bs.dropdown .panel-heading .btn-group': function (e) {
        this.controlDropdownShown($(e.currentTarget).parent());
      },
      /** @this DashletView */
      'hide.bs.dropdown .panel-heading .btn-group': function () {
        this.controlDropdownHide();
      }
    };
    controlDropdownShown($dropdownContainer) {
      const $panel = this.$el.children().first();
      const dropdownBottom = $dropdownContainer.find('.dropdown-menu').get(0).getBoundingClientRect().bottom;
      const panelBottom = $panel.get(0).getBoundingClientRect().bottom;
      if (dropdownBottom < panelBottom) {
        return;
      }
      $panel.addClass('has-dropdown-opened');
    }
    controlDropdownHide() {
      this.$el.children().first().removeClass('has-dropdown-opened');
    }

    /** @inheritDoc */
    setup() {
      this.name = this.options.name;
      this.id = this.options.id;
      this.on('resize', () => {
        const bodyView = this.getView('body');
        if (!bodyView) {
          return;
        }
        bodyView.trigger('resize');
      });
      const viewName = this.getMetadata().get(['dashlets', this.name, 'view']) || 'views/dashlets/' + Espo.Utils.camelCaseToHyphen(this.name);
      this.createView('body', viewName, {
        selector: '.dashlet-body',
        id: this.id,
        name: this.name,
        readOnly: this.options.readOnly,
        locked: this.options.locked
      });
    }

    /**
     * Refresh.
     */
    refresh() {
      this.getBodyView().actionRefresh();
    }
    actionRefresh() {
      this.refresh();
    }
    actionOptions() {
      const optionsView = this.getMetadata().get(['dashlets', this.name, 'options', 'view']) || this.optionsView || 'views/dashlets/options/base';
      Espo.Ui.notifyWait();
      this.createView('options', optionsView, {
        name: this.name,
        optionsData: this.getOptionsData(),
        fields: this.getBodyView().optionsFields
      }, view => {
        view.render();
        Espo.Ui.notify(false);
        this.listenToOnce(view, 'save', attributes => {
          const id = this.id;
          Espo.Ui.notify(this.translate('saving', 'messages'));
          this.getPreferences().once('sync', () => {
            this.getPreferences().trigger('update');
            Espo.Ui.notify(false);
            view.close();
            this.trigger('change');
          });
          const o = this.getPreferences().get('dashletsOptions') || {};
          o[id] = attributes;
          this.getPreferences().save({
            dashletsOptions: o
          }, {
            patch: true
          });
        });
      });
    }

    /**
     * Get options data.
     *
     * @returns {Object}
     */
    getOptionsData() {
      return this.getBodyView().optionsData;
    }

    /**
     * Get an option value.
     *
     * @param {string} key A option name.
     * @returns {*}
     */
    getOption(key) {
      return this.getBodyView().getOption(key);
    }

    /**
     * Get a dashlet title.
     *
     * @returns {string}
     */
    getTitle() {
      return this.getBodyView().getTitle();
    }

    /**
     * @return {module:views/dashlets/abstract/base}
     */
    getBodyView() {
      return this.getView('body');
    }

    // noinspection JSUnusedGlobalSymbols
    actionRemove() {
      this.confirm(this.translate('confirmation', 'messages'), () => {
        this.trigger('remove-dashlet');
        this.$el.remove();
        this.remove();
      });
    }
  }
  var _default = _exports.default = DashletView;
});

define("views/dashboard", ["exports", "view", "gridstack", "underscore"], function (_exports, _view, _gridstack, _underscore) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  _gridstack = _interopRequireDefault(_gridstack);
  _underscore = _interopRequireDefault(_underscore);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/dashboard */

  class DashboardView extends _view.default {
    template = 'dashboard';
    dashboardLayout = null;
    currentTab = null;

    /**
     * @private
     * @type {number}
     */
    cellHeight;
    WIDTH_MULTIPLIER = 3;
    HEIGHT_MULTIPLIER = 4;

    /**
     * @private
     * @type {Object.<string, import('views/dashlet').default>|null}
     */
    preservedDashletViews = null;

    /**
     * @private
     * @type {Object.<string, HTMLElement>|null}
     */
    preservedDashletElements = null;
    events = {
      /** @this DashboardView */
      'click button[data-action="selectTab"]': function (e) {
        const tab = parseInt($(e.currentTarget).data('tab'));
        this.selectTab(tab);
      },
      /** @this DashboardView */
      'click .dashboard-buttons [data-action="addDashlet"]': function () {
        this.createView('addDashlet', 'views/modals/add-dashlet', {}, view => {
          view.render();
          this.listenToOnce(view, 'add', name => this.addDashlet(name));
        });
      },
      /** @this DashboardView */
      'click .dashboard-buttons [data-action="editTabs"]': function () {
        this.editTabs();
      }
    };
    data() {
      return {
        displayTitle: this.options.displayTitle,
        currentTab: this.currentTab,
        tabCount: this.dashboardLayout.length,
        dashboardLayout: this.dashboardLayout,
        layoutReadOnly: this.layoutReadOnly,
        hasAdd: !this.layoutReadOnly && !this.getPreferences().get('dashboardLocked')
      };
    }
    generateId() {
      return Math.floor(Math.random() * 10000001).toString();
    }
    setupCurrentTabLayout() {
      if (!this.dashboardLayout) {
        const defaultLayout = [{
          "name": "My Espo",
          "layout": []
        }];
        if (this.getConfig().get('forcedDashboardLayout')) {
          this.dashboardLayout = this.getConfig().get('forcedDashboardLayout') || [];
        } else if (this.getUser().get('portalId')) {
          this.dashboardLayout = this.getConfig().get('dashboardLayout') || [];
        } else {
          this.dashboardLayout = this.getPreferences().get('dashboardLayout') || defaultLayout;
        }
        if (this.dashboardLayout.length === 0 || Object.prototype.toString.call(this.dashboardLayout) !== '[object Array]') {
          this.dashboardLayout = defaultLayout;
        }
      }
      const dashboardLayout = this.dashboardLayout || [];
      if (dashboardLayout.length <= this.currentTab) {
        this.currentTab = 0;
      }
      let tabLayout = dashboardLayout[this.currentTab].layout || [];
      tabLayout = _gridstack.default.Utils.sort(tabLayout);
      this.currentTabLayout = tabLayout;
    }

    /**
     * @param {number} tab
     */
    storeCurrentTab(tab) {
      this.getStorage().set('state', 'dashboardTab', tab);
    }

    /**
     * @param {number} tab
     */
    selectTab(tab) {
      this.$el.find('.page-header button[data-action="selectTab"]').removeClass('active');
      this.$el.find(`.page-header button[data-action="selectTab"][data-tab="${tab}"]`).addClass('active');
      this.currentTab = tab;
      this.storeCurrentTab(tab);
      this.setupCurrentTabLayout();
      this.dashletIdList.forEach(id => this.clearView(`dashlet-${id}`));
      this.dashletIdList = [];
      this.reRender();
    }
    setup() {
      this.currentTab = this.getStorage().get('state', 'dashboardTab') || 0;
      this.setupCurrentTabLayout();
      this.cellHeight = this.getThemeManager().getParam('dashboardCellHeight');
      this.dashletIdList = [];
      this.screenWidthXs = this.getThemeManager().getParam('screenWidthXs');
      if (this.getUser().isPortal()) {
        this.layoutReadOnly = true;
        this.dashletsReadOnly = true;
      } else {
        const forbiddenPreferencesFieldList = this.getAcl().getScopeForbiddenFieldList('Preferences', 'edit');
        if (forbiddenPreferencesFieldList.includes('dashboardLayout')) {
          this.layoutReadOnly = true;
        }
        if (forbiddenPreferencesFieldList.includes('dashletsOptions')) {
          this.dashletsReadOnly = true;
        }
      }
      this.once('remove', () => {
        if (this.grid) {
          this.grid.destroy();
        }
        if (this.fallbackModeTimeout) {
          clearTimeout(this.fallbackModeTimeout);
        }
        $(window).off('resize.dashboard');
      });
    }
    afterRender() {
      this.$dashboard = this.$el.find('> .dashlets');
      if (window.innerWidth >= this.screenWidthXs) {
        this.initGridstack();
      } else {
        this.initFallbackMode();
      }
      $(window).off('resize.dashboard');
      $(window).on('resize.dashboard', this.onResize.bind(this));
    }
    onResize() {
      if (this.isFallbackMode() && window.innerWidth >= this.screenWidthXs) {
        this.initGridstack();
      } else if (!this.isFallbackMode() && window.innerWidth < this.screenWidthXs) {
        this.initFallbackMode();
      }
    }
    isFallbackMode() {
      return this.$dashboard.hasClass('fallback');
    }
    preserveDashletViews() {
      this.preservedDashletViews = {};
      this.preservedDashletElements = {};
      this.currentTabLayout.forEach(o => {
        const key = `dashlet-${o.id}`;
        const view = this.getView(key);
        this.unchainView(key);
        this.preservedDashletViews[o.id] = view;
        const element = view.element;
        this.preservedDashletElements[o.id] = element;
        const parent = element.parentNode;
        parent.removeChild(element);
      });
    }

    /**
     * @param {string} id
     */
    async addPreservedDashlet(id) {
      /** @type {import('view').default} */
      const view = this.preservedDashletViews[id];
      /** @type {HTMLElement} */
      const element = this.preservedDashletElements[id];
      if (!element || !view) {
        return;
      }
      const container = this.element.querySelector(`.dashlet-container[data-id="${id}"]`);
      if (!container) {
        return;
      }
      container.append(...element.childNodes);
      view.element = undefined;
      await this.setView(`dashlet-${id}`, view);
    }
    clearPreservedDashlets() {
      this.preservedDashletViews = null;
      this.preservedDashletElements = null;
    }
    hasPreservedDashlets() {
      return !!this.preservedDashletViews;
    }
    initFallbackMode() {
      if (this.grid) {
        this.grid.destroy(false);
        this.grid = null;
        this.preserveDashletViews();
      }
      this.$dashboard.empty();
      const $dashboard = this.$dashboard;
      $dashboard.addClass('fallback');
      this.currentTabLayout.forEach(o => {
        const $item = this.prepareFallbackItem(o);
        $dashboard.append($item);
      });
      this.currentTabLayout.forEach(o => {
        if (!o.id || !o.name) {
          return;
        }
        if (!this.getMetadata().get(`dashlets.${o.name}`)) {
          console.error(`Dashlet ${o.name} doesn't exist or not available.`);
          return;
        }
        if (this.hasPreservedDashlets()) {
          this.addPreservedDashlet(o.id);
          return;
        }
        this.createDashletView(o.id, o.name);
      });
      this.clearPreservedDashlets();
      if (this.fallbackModeTimeout) {
        clearTimeout(this.fallbackModeTimeout);
      }
      this.$dashboard.css('height', '');
      this.fallbackControlHeights();
    }
    fallbackControlHeights() {
      this.currentTabLayout.forEach(o => {
        const $container = this.$dashboard.find(`.dashlet-container[data-id="${o.id}"]`);
        const headerHeight = $container.find('.panel-heading').outerHeight();
        const $body = $container.find('.dashlet-body');
        const bodyEl = $body.get(0);
        if (!bodyEl) {
          return;
        }
        if (bodyEl.scrollHeight > bodyEl.offsetHeight) {
          const height = bodyEl.scrollHeight + headerHeight;
          $container.css('height', `${height}px`);
        }
      });
      this.fallbackModeTimeout = setTimeout(() => this.fallbackControlHeights(), 300);
    }
    initGridstack() {
      if (this.isFallbackMode()) {
        this.preserveDashletViews();
      }
      this.$dashboard.empty();
      const $gridstack = this.$gridstack = this.$dashboard;
      $gridstack.removeClass('fallback');
      if (this.fallbackModeTimeout) {
        clearTimeout(this.fallbackModeTimeout);
      }
      let disableDrag = false;
      let disableResize = false;
      if (this.getUser().isPortal() || this.getPreferences().get('dashboardLocked')) {
        disableDrag = true;
        disableResize = true;
      }
      const paramCellHeight = this.cellHeight;
      const paramCellMargin = this.getThemeManager().getParam('dashboardCellMargin');
      const factor = this.getThemeManager().getFontSizeFactor();
      const cellHeight = Math.ceil(factor * paramCellHeight * 1.14);
      const margin = Math.round(factor * paramCellMargin / 2);
      const grid = this.grid = _gridstack.default.init({
        cellHeight: cellHeight,
        margin: margin,
        column: 12,
        handle: '.panel-heading',
        disableDrag: disableDrag,
        disableResize: disableResize,
        disableOneColumnMode: true,
        draggable: {
          distance: 10
        },
        dragInOptions: {
          scroll: false
        },
        float: false,
        animate: false,
        scroll: false
      }, $gridstack.get(0));
      grid.removeAll();
      this.currentTabLayout.forEach(o => {
        const $item = this.prepareGridstackItem(o.id, o.name);
        if (!this.getMetadata().get(['dashlets', o.name])) {
          return;
        }
        grid.addWidget($item.get(0), {
          x: o.x * this.WIDTH_MULTIPLIER,
          y: o.y * this.HEIGHT_MULTIPLIER,
          w: o.width * this.WIDTH_MULTIPLIER,
          h: o.height * this.HEIGHT_MULTIPLIER
        });
      });
      $gridstack.find('.grid-stack-item').css('position', 'absolute');
      this.currentTabLayout.forEach(o => {
        if (!o.id || !o.name) {
          return;
        }
        if (!this.getMetadata().get(`dashlets.${o.name}`)) {
          console.error(`Dashlet ${o.name} doesn't exist or not available.`);
          return;
        }
        if (this.hasPreservedDashlets()) {
          this.addPreservedDashlet(o.id);
          return;
        }
        this.createDashletView(o.id, o.name);
      });
      this.clearPreservedDashlets();
      this.grid.on('change', () => {
        this.fetchLayout();
        this.saveLayout();
      });

      // noinspection SpellCheckingInspection
      this.grid.on('resizestop', e => {
        const id = $(e.target).data('id');
        const view = this.getView(`dashlet-${id}`);
        if (!view) {
          return;
        }
        view.trigger('resize');
      });
    }
    fetchLayout() {
      this.dashboardLayout[this.currentTab].layout = _underscore.default.map(this.$gridstack.find('.grid-stack-item'), el => {
        const $el = $(el);
        const x = $el.attr('gs-x');
        const y = $el.attr('gs-y');
        const h = $el.attr('gs-h');
        const w = $el.attr('gs-w');
        return {
          id: $el.data('id'),
          name: $el.data('name'),
          x: x / this.WIDTH_MULTIPLIER,
          y: y / this.HEIGHT_MULTIPLIER,
          width: w / this.WIDTH_MULTIPLIER,
          height: h / this.HEIGHT_MULTIPLIER
        };
      });
    }

    /**
     * @param {string} id
     * @param {string} name
     * @return {JQuery}
     */
    prepareGridstackItem(id, name) {
      const $item = $('<div>').addClass('grid-stack-item');
      const $container = $('<div class="grid-stack-item-content dashlet-container"></div>');
      $container.attr('data-id', id);
      $container.attr('data-name', name);
      $item.attr('data-id', id);
      $item.attr('data-name', name);
      $item.append($container);
      return $item;
    }

    /**
     * @param {Record} o
     * @return {JQuery}
     */
    prepareFallbackItem(o) {
      const $item = $('<div>');
      const $container = $('<div class="dashlet-container">');
      $container.attr('data-id', o.id);
      $container.attr('data-name', o.name);
      $container.attr('data-x', o.x);
      $container.attr('data-y', o.y);
      $container.attr('data-height', o.height);
      $container.attr('data-width', o.width);
      $container.css('height', o.height * this.cellHeight * this.HEIGHT_MULTIPLIER + 'px');
      $item.attr('data-id', o.id);
      $item.attr('data-name', o.name);
      $item.append($container);
      return $item;
    }

    /**
     * @param {Record} [attributes]
     */
    saveLayout(attributes) {
      if (this.layoutReadOnly) {
        return;
      }
      attributes = {
        ...(attributes || {}),
        ...{
          dashboardLayout: this.dashboardLayout
        }
      };
      this.getPreferences().save(attributes, {
        patch: true
      });
      this.getPreferences().trigger('update');
    }

    /**
     * @param {string} id
     */
    removeDashlet(id) {
      let revertToFallback = false;
      if (this.isFallbackMode()) {
        this.initGridstack();
        revertToFallback = true;
      }
      const $item = this.$gridstack.find('.grid-stack-item[data-id="' + id + '"]');

      // noinspection JSUnresolvedReference
      this.grid.removeWidget($item.get(0), true);
      const layout = this.dashboardLayout[this.currentTab].layout;
      layout.forEach((o, i) => {
        if (o.id === id) {
          layout.splice(i, 1);
        }
      });
      const o = {};
      o.dashletsOptions = this.getPreferences().get('dashletsOptions') || {};
      delete o.dashletsOptions[id];
      o.dashboardLayout = this.dashboardLayout;
      if (this.layoutReadOnly) {
        return;
      }
      this.getPreferences().save(o, {
        patch: true
      });
      this.getPreferences().trigger('update');
      const index = this.dashletIdList.indexOf(id);
      if (~index) {
        this.dashletIdList.splice(index, index);
      }
      this.clearView('dashlet-' + id);
      this.setupCurrentTabLayout();
      if (revertToFallback) {
        this.initFallbackMode();
      }
    }

    /**
     * @param {string} name
     */
    addDashlet(name) {
      let revertToFallback = false;
      if (this.isFallbackMode()) {
        this.initGridstack();
        revertToFallback = true;
      }
      const id = 'd' + Math.floor(Math.random() * 1000001).toString();
      const $item = this.prepareGridstackItem(id, name);
      this.grid.addWidget($item.get(0), {
        x: 0,
        y: 0,
        w: 2 * this.WIDTH_MULTIPLIER,
        h: 2 * this.HEIGHT_MULTIPLIER
      });
      this.createDashletView(id, name, name, view => {
        this.fetchLayout();
        this.saveLayout();
        this.setupCurrentTabLayout();
        if (view.getBodyView() && view.getBodyView().afterAdding) {
          view.getBodyView().afterAdding();
        }
        if (revertToFallback) {
          this.initFallbackMode();
        }
      });
    }

    /**
     * @param {string} id
     * @param {string} name
     * @param {string} [label]
     * @param {function(import('views/dashlet').default)} [callback]
     * @return {Promise<import('views/dashlet').default>}
     */
    createDashletView(id, name, label, callback) {
      const o = {
        id: id,
        name: name
      };
      if (label) {
        o.label = label;
      }
      return this.createView(`dashlet-${id}`, 'views/dashlet', {
        label: name,
        name: name,
        id: id,
        selector: `> .dashlets .dashlet-container[data-id="${id}"]`,
        readOnly: this.dashletsReadOnly,
        locked: this.getPreferences().get('dashboardLocked')
      }, view => {
        this.dashletIdList.push(id);
        view.render();
        this.listenToOnce(view, 'change', () => {
          this.clearView(id);
          this.createDashletView(id, name, label);
        });
        this.listenToOnce(view, 'remove-dashlet', () => {
          this.removeDashlet(id);
        });
        if (callback) {
          callback.call(this, view);
        }
      });
    }
    editTabs() {
      const dashboardLocked = this.getPreferences().get('dashboardLocked');
      this.createView('editTabs', 'views/modals/edit-dashboard', {
        dashboardLayout: this.dashboardLayout,
        dashboardLocked: dashboardLocked,
        fromDashboard: true
      }, view => {
        view.render();
        this.listenToOnce(view, 'after:save', data => {
          view.close();
          const dashboardLayout = [];
          data.dashboardTabList.forEach(name => {
            let layout = [];
            let id = null;
            this.dashboardLayout.forEach(d => {
              if (d.name === name) {
                layout = d.layout;
                id = d.id;
              }
            });
            if (name in data.renameMap) {
              name = data.renameMap[name];
            }
            const o = {
              name: name,
              layout: layout
            };
            if (id) {
              o.id = id;
            }
            dashboardLayout.push(o);
          });
          this.dashletIdList.forEach(item => {
            this.clearView(`dashlet-${item}`);
          });
          this.dashboardLayout = dashboardLayout;
          this.saveLayout({
            dashboardLocked: data.dashboardLocked
          });
          this.storeCurrentTab(0);
          this.currentTab = 0;
          this.setupCurrentTabLayout();
          this.reRender();
        });
      });
    }
  }
  var _default = _exports.default = DashboardView;
});

define("views/clear-cache", ["exports", "view"], function (_exports, _view) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ClearCacheView extends _view.default {
    template = 'clear-cache';
    el = '> body';
    events = {
      /** @this ClearCacheView */
      'click .action[data-action="clearLocalCache"]': function () {
        this.clearLocalCache();
      },
      /** @this ClearCacheView */
      'click .action[data-action="returnToApplication"]': function () {
        this.returnToApplication();
      }
    };
    data() {
      return {
        cacheIsEnabled: !!this.options.cache
      };
    }
    clearLocalCache() {
      this.options.cache.clear();
      this.$el.find('.action[data-action="clearLocalCache"]').remove();
      this.$el.find('.message-container').removeClass('hidden');
      this.$el.find('.message-container span').html(this.translate('Cache has been cleared'));
      this.$el.find('.action[data-action="returnToApplication"]').removeClass('hidden');
    }
    returnToApplication() {
      this.getRouter().navigate('', {
        trigger: true
      });
    }
  }
  var _default = _exports.default = ClearCacheView;
});

define("views/about", ["exports", "view"], function (_exports, _view) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class AboutView extends _view.default {
    template = 'about';
    data() {
      return {
        version: this.version,
        text: this.getHelper().transformMarkdownText(this.text)
      };
    }
    setup() {
      this.wait(Espo.Ajax.getRequest('App/about').then(data => {
        this.text = data.text;
        this.version = data.version;
      }));
    }
  }
  var _default = _exports.default = AboutView;
});

define("views/wysiwyg/modals/insert-link", ["exports", "views/modal"], function (_exports, _modal) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class WysiwygInsertLinkModal extends _modal.default {
    className = 'dialog dialog-record';
    template = 'wysiwyg/modals/insert-link';
    events = {
      /** @this {WysiwygInsertLinkModal} */
      'input [data-name="url"]': function () {
        this.controlInputs();
      },
      /** @this {WysiwygInsertLinkModal} */
      'paste [data-name="url"]': function () {
        this.controlInputs();
      }
    };
    shortcutKeys = {
      /** @this {WysiwygInsertLinkModal} */
      'Control+Enter': function () {
        if (this.hasAvailableActionItem('insert')) {
          this.actionInsert();
        }
      }
    };
    data() {
      return {
        labels: this.options.labels || {}
      };
    }
    setup() {
      const labels = this.options.labels || {};
      this.headerText = labels.insert;
      this.buttonList = [{
        name: 'insert',
        text: this.translate('Insert'),
        style: 'primary',
        disabled: true
      }];
      this.linkInfo = this.options.linkInfo || {};
      if (this.linkInfo.url) {
        this.enableButton('insert');
      }
    }
    afterRender() {
      this.$url = this.$el.find('[data-name="url"]');
      this.$text = this.$el.find('[data-name="text"]');
      this.$openInNewWindow = this.$el.find('[data-name="openInNewWindow"]');
      const linkInfo = this.linkInfo;
      this.$url.val(linkInfo.url || '');
      this.$text.val(linkInfo.text || '');
      if ('isNewWindow' in linkInfo) {
        this.$openInNewWindow.get(0).checked = !!linkInfo.isNewWindow;
      }
    }
    controlInputs() {
      const url = this.$url.val().trim();
      if (url) {
        this.enableButton('insert');
      } else {
        this.disableButton('insert');
      }
    }
    actionInsert() {
      const url = this.$url.val().trim();
      const text = this.$text.val().trim();
      const openInNewWindow = this.$openInNewWindow.get(0).checked;
      const data = {
        url: url,
        text: text || url,
        isNewWindow: openInNewWindow,
        range: this.linkInfo.range
      };
      this.trigger('insert', data);
      this.close();
    }
  }
  _exports.default = WysiwygInsertLinkModal;
});

define("views/wysiwyg/modals/insert-image", ["exports", "views/modal"], function (_exports, _modal) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class WysiwygInsertImageModal extends _modal.default {
    className = 'dialog dialog-record';
    template = 'wysiwyg/modals/insert-image';
    events = {
      /** @this {WysiwygInsertImageModal} */
      'click [data-action="insert"]': function () {
        this.actionInsert();
      },
      /** @this {WysiwygInsertImageModal} */
      'input [data-name="url"]': function () {
        this.controlInsertButton();
      },
      /** @this {WysiwygInsertImageModal} */
      'paste [data-name="url"]': function () {
        this.controlInsertButton();
      }
    };
    shortcutKeys = {
      /** @this {WysiwygInsertImageModal} */
      'Control+Enter': function () {
        if (!this.$el.find('[data-name="insert"]').hasClass('disabled')) {
          this.actionInsert();
        }
      }
    };
    data() {
      return {
        labels: this.options.labels || {}
      };
    }
    setup() {
      const labels = this.options.labels || {};
      this.headerText = labels.insert;
      this.buttonList = [];
    }
    afterRender() {
      const $files = this.$el.find('[data-name="files"]');
      $files.replaceWith($files.clone().on('change', e => {
        this.trigger('upload', e.target.files || e.target.value);
        this.close();
      }).val(''));
    }
    controlInsertButton() {
      const value = this.$el.find('[data-name="url"]').val().trim();
      const $button = this.$el.find('[data-name="insert"]');
      if (value) {
        $button.removeClass('disabled').removeAttr('disabled');
      } else {
        $button.addClass('disabled').attr('disabled', 'disabled');
      }
    }
    actionInsert() {
      const url = this.$el.find('[data-name="url"]').val().trim();
      this.trigger('insert', url);
      this.close();
    }
  }
  _exports.default = WysiwygInsertImageModal;
});

define("views/working-time-range/fields/users", ["exports", "views/fields/link-multiple"], function (_exports, _linkMultiple) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _linkMultiple = _interopRequireDefault(_linkMultiple);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _linkMultiple.default {
    getSelectPrimaryFilterName() {
      return 'active';
    }
  }
  _exports.default = _default;
});

define("views/working-time-range/fields/date-end", ["exports", "views/fields/date", "moment"], function (_exports, _date, _moment) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _date = _interopRequireDefault(_date);
  _moment = _interopRequireDefault(_moment);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _date.default {
    setup() {
      super.setup();
      this.validations.push(() => this.validateAfterOrSame());
    }
    validateAfterOrSame() {
      const field = 'dateStart';
      const value = this.model.get(this.name);
      const otherValue = this.model.get(field);
      if (value && otherValue) {
        if ((0, _moment.default)(value).unix() < (0, _moment.default)(otherValue).unix()) {
          const msg = this.translate('fieldShouldAfter', 'messages').replace('{field}', this.getLabelText()).replace('{otherField}', this.translate(field, 'fields', this.model.entityType));
          this.showValidationMessage(msg);
          return true;
        }
      }
      return false;
    }
  }
  _exports.default = _default;
});

define("views/working-time-calendar/fields/time-ranges", ["exports", "views/fields/base"], function (_exports, _base) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _base.default {
    // language=Handlebars
    listTemplateContent = `
        <div class="item-list">
        {{#each itemDataList}}
            <span class="item" data-key="{{key}}"
            >{{{var viewKey ../this}}}</span>{{#unless isLast}} &nbsp;&middot;&nbsp; {{/unless}}
        {{/each}}
        </div>
        {{#unless itemDataList.length}}
        <span class="none-value">{{translate 'None'}}</span>
        {{/unless}}
    `;

    // language=Handlebars
    detailTemplateContent = `
        <div class="item-list">
        {{#each itemDataList}}
            <div class="item" data-key="{{key}}">
                {{{var viewKey ../this}}}
            </div>
        {{/each}}
        </div>
        {{#unless itemDataList.length}}
        <span class="none-value">{{translate 'None'}}</span>
        {{/unless}}
    `;

    // language=Handlebars
    editTemplateContent = `
        <div class="item-list">
        {{#each itemDataList}}
            <div class="item" data-key="{{key}}">
                {{{var viewKey ../this}}}
            </div>
        {{/each}}
        </div>
        <div class="add-item-container margin-top-sm">
            <a
                role="button"
                tabindex="0"
                class="add-item"
                title="{{translate 'Add'}}"
            ><span class="fas fa-plus"></span></a>
        </div>
    `;

    // noinspection JSCheckFunctionSignatures
    data() {
      const data = super.data();
      data.itemDataList = this.itemKeyList.map((key, i) => {
        return {
          key: key.toString(),
          viewKey: this.composeViewKey(key),
          isLast: i === this.itemKeyList.length - 1
        };
      });

      // noinspection JSValidateTypes
      return data;
    }
    setup() {
      super.setup();
      this.validations = [() => this.validateRequired(), () => this.validateValid()];
      this.addHandler('click', '.add-item', () => this.addItem());
      this.addHandler('click', '.remove-item', (e, target) => {
        this.removeItem(parseInt(target.dataset.key));
      });
    }
    prepare() {
      this.initItems();
      return this.createItemViews();
    }
    initItems() {
      this.itemKeyList = [];
      this.getItemListFromModel().forEach((item, i) => {
        this.itemKeyList.push(i);
      });
    }

    /**
     * @returns {Promise}
     */
    createItemView(item, key) {
      const viewName = this.isEditMode() ? 'views/working-time-calendar/fields/time-ranges/item-edit' : 'views/working-time-calendar/fields/time-ranges/item-detail';
      return this.createView(this.composeViewKey(key), viewName, {
        value: item,
        selector: `.item[data-key="${key}"]`,
        key: key
      }).then(view => {
        this.listenTo(view, 'change', () => {
          this.trigger('change');
        });
        return view;
      });
    }

    /**
     * @returns {Promise}
     */
    createItemViews() {
      this.itemKeyList.forEach(key => {
        this.clearView(this.composeViewKey(key));
      });
      if (!this.model.has(this.name)) {
        return Promise.resolve();
      }
      const itemList = this.getItemListFromModel();
      const promiseList = [];
      this.itemKeyList.forEach((key, i) => {
        const item = itemList[i];
        const promise = this.createItemView(item, key);
        promiseList.push(promise);
      });
      return Promise.all(promiseList);
    }

    /**
     * @param {string} key
     * @return {import('./time-ranges/item-edit').default}
     */
    getItemView(key) {
      // noinspection JSValidateTypes
      return this.getView(this.composeViewKey(key));
    }
    composeViewKey(key) {
      return `item-${key}`;
    }

    /**
     * @return {[string|null, string|null][]}
     */
    getItemListFromModel() {
      return Espo.Utils.cloneDeep(this.model.get(this.name) || []);
    }
    addItem() {
      const itemList = this.getItemListFromModel();
      let value = null;
      if (itemList.length) {
        value = itemList[itemList.length - 1][1];
      }
      const item = [value, null];
      itemList.push(item);
      let key = this.itemKeyList[this.itemKeyList.length - 1];
      if (typeof key === 'undefined') {
        key = 0;
      }
      key++;
      this.itemKeyList.push(key);
      this.$el.find('.item-list').append($('<div>').addClass('item').attr('data-key', key));
      this.createItemView(item, key).then(view => view.render()).then(() => {
        this.trigger('change');
      });
    }
    removeItem(key) {
      const index = this.itemKeyList.indexOf(key);
      if (key === -1) {
        return;
      }
      const itemList = this.getItemListFromModel();
      this.itemKeyList.splice(index, 1);
      itemList.splice(index, 1);
      this.model.set(this.name, itemList, {
        ui: true
      });
      this.clearView(this.composeViewKey(key));
      this.$el.find(`.item[data-key="${key}"`).remove();
      this.trigger('change');
    }
    fetch() {
      const itemList = [];
      this.itemKeyList.forEach(key => {
        itemList.push(this.getItemView(key).fetch());
      });
      const data = {};
      data[this.name] = Espo.Utils.cloneDeep(itemList);
      if (data[this.name].length === 0) {
        data[this.name] = null;
      }
      return data;
    }
    validateRequired() {
      if (!this.isRequired()) {
        return false;
      }
      if (this.getItemListFromModel().length) {
        return false;
      }
      const msg = this.translate('fieldIsRequired', 'messages').replace('{field}', this.getLabelText());
      this.showValidationMessage(msg, '.add-item-container');
      return true;
    }
    validateValid() {
      if (!this.isRangesInvalid()) {
        return false;
      }
      const msg = this.translate('fieldInvalid', 'messages').replace('{field}', this.getLabelText());
      this.showValidationMessage(msg, '.add-item-container');
      return true;
    }
    isRangesInvalid() {
      const itemList = this.getItemListFromModel();
      for (let i = 0; i < itemList.length; i++) {
        const item = itemList[i];
        if (this.isRangeInvalid(item[0], item[1], true)) {
          return true;
        }
        if (i === 0) {
          continue;
        }
        const prevItem = itemList[i - 1];
        if (this.isRangeInvalid(prevItem[1], item[0])) {
          return true;
        }
        if (prevItem[1] === '00:00') {
          return true;
        }
      }
      return false;
    }

    /**
     * @param {string|null} from
     * @param {string|null} to
     * @param {boolean} [isRange]
     */
    isRangeInvalid(from, to) {
      let isRange = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
      if (from === null || to === null) {
        return true;
      }
      const fromNumber = parseFloat(from.replace(':', '.'));
      const toNumber = parseFloat(to.replace(':', '.'));
      if (isRange && fromNumber === toNumber && to !== '00:00') {
        return true;
      }
      if (isRange && to === '00:00' && fromNumber) {
        return false;
      }
      return fromNumber > toNumber;
    }
  }
  _exports.default = _default;
});

define("views/working-time-calendar/fields/time-ranges/item-edit", ["exports", "view", "moment", "ui/timepicker"], function (_exports, _view, _moment, _timepicker) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  _moment = _interopRequireDefault(_moment);
  _timepicker = _interopRequireDefault(_timepicker);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class TimeRangeItemEdit extends _view.default {
    // language=Handlebars
    templateContent = `
        <div class="row">
            <div class="start-container col-xs-5">
                <input
                    class="form-control numeric-text"
                    type="text"
                    data-name="start"
                    value="{{start}}"
                    autocomplete="espo-start"
                    spellcheck="false"
                >
            </div>
            <div class="start-container col-xs-1 center-align">
                <span class="field-row-text-item">&nbsp;–&nbsp;</span>
            </div>
            <div class="end-container col-xs-5">
                <input
                    class="form-control numeric-text"
                    type="text"
                    data-name="end"
                    value="{{end}}"
                    autocomplete="espo-end"
                    spellcheck="false"
                >
            </div>
            <div class="col-xs-1 center-align">
                <a
                    role="button"
                    tabindex="0"
                    class="remove-item field-row-text-item"
                    data-key="{{key}}"
                    title="{{translate 'Remove'}}"
                ><span class="fas fa-times"></span></a>
            </div>
        </div>
    `;
    timeFormatMap = {
      'HH:mm': 'H:i',
      'hh:mm A': 'h:i A',
      'hh:mm a': 'h:i a',
      'hh:mmA': 'h:iA',
      'hh:mma': 'h:ia'
    };
    minuteStep = 30;

    /**
     * @private
     * @type {HTMLInputElement}
     */
    startElement;

    /**
     * @private
     * @type {HTMLInputElement}
     */
    endElement;

    /**
     * @private
     * @type {import('ui/timepicker').default}
     */
    startTimepicker;

    /**
     * @private
     * @type {import('ui/timepicker').default}
     */
    endTimepicker;
    data() {
      const data = {};
      data.start = this.convertTimeToDisplay(this.value[0]);
      data.end = this.convertTimeToDisplay(this.value[1]);
      data.key = this.key;
      return data;
    }
    setup() {
      this.value = this.options.value || [null, null];
      this.key = this.options.key;
      this.on('remove', () => this.destroyTimepickers());
    }
    convertTimeToDisplay(value) {
      if (!value) {
        return '';
      }
      const m = (0, _moment.default)(value, 'HH:mm');
      if (!m.isValid()) {
        return '';
      }
      return m.format(this.getDateTime().timeFormat);
    }

    /**
     * @param {string} value
     * @return {string|null}
     */
    convertTimeFromDisplay(value) {
      if (!value) {
        return null;
      }
      const m = (0, _moment.default)(value, this.getDateTime().timeFormat);
      if (!m.isValid()) {
        return null;
      }
      return m.format('HH:mm');
    }
    afterRender() {
      this.startElement = this.element.querySelector('[data-name="start"]');
      this.endElement = this.element.querySelector('[data-name="end"]');
      if (this.startElement) {
        this.startTimepicker = this.initTimepicker(this.startElement);
        this.endTimepicker = this.initTimepicker(this.endElement);
        this.setMinTime();
        this.startTimepicker.addChangeEventListener(() => this.setMinTime());
      }
    }
    setMinTime() {
      const value = this.startElement.value;
      const parsedValue = this.convertTimeFromDisplay(value);
      if (parsedValue !== '00:00') {
        this.endTimepicker.setMaxTime(this.convertTimeToDisplay('24:00'));
      } else {
        this.endTimepicker.setMaxTime(null);
      }
      if (!value) {
        this.endTimepicker.setMinTime(null);
        return;
      }
      const minValue = (0, _moment.default)(parsedValue, 'HH:mm').add(this.minuteStep, 'minute').format(this.getDateTime().timeFormat);
      this.endTimepicker.setMinTime(minValue);
    }

    /**
     * @private
     * @param {HTMLInputElement} element
     * @return {Timepicker}
     */
    initTimepicker(element) {
      const timepicker = new _timepicker.default(element, {
        step: this.minuteStep,
        timeFormat: this.timeFormatMap[this.getDateTime().timeFormat]
      });
      timepicker.addChangeEventListener(() => this.trigger('change'));
      element.setAttribute('autocomplete', 'espo-time-range-item');
      return timepicker;
    }
    destroyTimepickers() {
      if (this.startTimepicker) {
        this.startTimepicker.destroy();
      }
      if (this.endTimepicker) {
        this.endTimepicker.destroy();
      }
    }
    fetch() {
      return [this.convertTimeFromDisplay(this.startElement.value), this.convertTimeFromDisplay(this.endElement.value)];
    }
  }
  _exports.default = TimeRangeItemEdit;
});

define("views/working-time-calendar/fields/time-ranges/item-detail", ["exports", "view", "moment"], function (_exports, _view, _moment) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  _moment = _interopRequireDefault(_moment);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _view.default {
    templateContent = `
        {{start}}
        &nbsp;–&nbsp;
        {{end}}
    `;
    data() {
      return {
        start: this.convertTimeToDisplay(this.value[0]),
        end: this.convertTimeToDisplay(this.value[1])
      };
    }
    setup() {
      this.value = this.options.value;
    }
    convertTimeToDisplay(value) {
      if (!value) {
        return '';
      }
      const m = (0, _moment.default)(value, 'HH:mm');
      if (!m.isValid()) {
        return '';
      }
      return m.format(this.getDateTime().timeFormat);
    }
  }
  _exports.default = _default;
});

define("views/webhook/record/list", ["exports", "views/record/list"], function (_exports, _list) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _list = _interopRequireDefault(_list);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _list.default {
    massActionList = ['remove', 'massUpdate', 'export'];
  }
  _exports.default = _default;
});

define("views/webhook/fields/user", ["exports", "views/fields/link"], function (_exports, _link) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _link = _interopRequireDefault(_link);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _link.default {
    selectPrimaryFilterName = 'activeApi';
  }
  _exports.default = _default;
});

define("views/webhook/fields/event", ["exports", "views/fields/varchar"], function (_exports, _varchar) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _varchar = _interopRequireDefault(_varchar);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _varchar.default {
    setupOptions() {
      const itemList = [];
      const scopeList = this.getMetadata().getScopeObjectList().sort((v1, v2) => v1.localeCompare(v2));
      scopeList.forEach(scope => {
        itemList.push(`${scope}.create`);
        itemList.push(`${scope}.update`);
        itemList.push(`${scope}.delete`);
      });
      this.params.options = itemList;
    }
  }
  _exports.default = _default;
});

define("views/user-security/modals/two-factor-sms", ["exports", "views/modal", "model"], function (_exports, _modal, _model) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  _model = _interopRequireDefault(_model);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  // noinspection JSUnusedGlobalSymbols
  class TwoFactorSmsModalView extends _modal.default {
    template = 'user-security/modals/two-factor-sms';
    className = 'dialog dialog-record';
    shortcutKeys = {
      'Control+Enter': 'apply'
    };
    setup() {
      this.addActionHandler('sendCode', () => this.actionSendCode());
      this.buttonList = [{
        name: 'apply',
        label: 'Apply',
        style: 'danger',
        hidden: true,
        onClick: () => this.actionApply()
      }, {
        name: 'cancel',
        label: 'Cancel'
      }];
      this.headerHtml = '&nbsp';
      const codeLength = this.getConfig().get('auth2FASmsCodeLength') || 7;
      const model = new _model.default();
      model.name = 'UserSecurity';
      model.set('phoneNumber', null);
      model.setDefs({
        fields: {
          'code': {
            type: 'varchar',
            required: true,
            maxLength: codeLength
          },
          'phoneNumber': {
            type: 'enum',
            required: true
          }
        }
      });
      this.internalModel = model;
      this.wait(Espo.Ajax.postRequest('UserSecurity/action/getTwoFactorUserSetupData', {
        id: this.model.id,
        password: this.model.get('password'),
        auth2FAMethod: this.model.get('auth2FAMethod'),
        reset: this.options.reset
      }).then(data => {
        this.phoneNumberList = data.phoneNumberList;
        this.createView('record', 'views/record/edit-for-modal', {
          scope: 'None',
          selector: '.record',
          model: model,
          detailLayout: [{
            rows: [[{
              name: 'phoneNumber',
              labelText: this.translate('phoneNumber', 'fields', 'User')
            }, false], [{
              name: 'code',
              labelText: this.translate('Code', 'labels', 'User')
            }, false]]
          }]
        }, view => {
          view.setFieldOptionList('phoneNumber', this.phoneNumberList);
          if (this.phoneNumberList.length) {
            model.set('phoneNumber', this.phoneNumberList[0]);
          }
          view.hideField('code');
        });
      }));
    }
    afterRender() {
      this.$sendCode = this.$el.find('[data-action="sendCode"]');
      this.$pInfo = this.$el.find('p.p-info');
      this.$pButton = this.$el.find('p.p-button');
      this.$pInfoAfter = this.$el.find('p.p-info-after');
    }
    actionSendCode() {
      this.$sendCode.attr('disabled', 'disabled').addClass('disabled');
      Espo.Ajax.postRequest('TwoFactorSms/action/sendCode', {
        id: this.model.id,
        phoneNumber: this.internalModel.get('phoneNumber')
      }).then(() => {
        this.showActionItem('apply');
        this.$pInfo.addClass('hidden');
        this.$pButton.addClass('hidden');
        this.$pInfoAfter.removeClass('hidden');
        this.getRecordView().setFieldReadOnly('phoneNumber');
        this.getRecordView().showField('code');
      }).catch(() => {
        this.$sendCode.removeAttr('disabled').removeClass('disabled');
      });
    }

    /**
     * @return {import('views/record/edit').default}
     */
    getRecordView() {
      return this.getView('record');
    }
    actionApply() {
      const data = this.getRecordView().processFetch();
      if (!data) {
        return;
      }
      this.model.set('code', data.code);
      this.hideActionItem('apply');
      this.hideActionItem('cancel');
      Espo.Ui.notify(this.translate('pleaseWait', 'messages'));
      this.model.save().then(() => {
        Espo.Ui.notify(false);
        this.trigger('done');
      }).catch(() => {
        this.showActionItem('apply');
        this.showActionItem('cancel');
      });
    }
  }
  _exports.default = TwoFactorSmsModalView;
});

define("views/user-security/modals/two-factor-email", ["exports", "views/modal", "model"], function (_exports, _modal, _model) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  _model = _interopRequireDefault(_model);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  // noinspection JSUnusedGlobalSymbols
  class TwoFactorEmailModalView extends _modal.default {
    template = 'user-security/modals/two-factor-email';
    className = 'dialog dialog-record';
    shortcutKeys = {
      'Control+Enter': 'apply'
    };
    setup() {
      this.addActionHandler('sendCode', () => this.actionSendCode());
      this.buttonList = [{
        name: 'apply',
        label: 'Apply',
        style: 'danger',
        hidden: true,
        onClick: () => this.actionApply()
      }, {
        name: 'cancel',
        label: 'Cancel'
      }];
      this.headerHtml = '&nbsp';
      const codeLength = this.getConfig().get('auth2FAEmailCodeLength') || 7;
      const model = new _model.default();
      model.entityType = model.name = 'UserSecurity';
      model.set('emailAddress', null);
      model.setDefs({
        fields: {
          'code': {
            type: 'varchar',
            required: true,
            maxLength: codeLength
          },
          'emailAddress': {
            type: 'enum',
            required: true
          }
        }
      });
      this.internalModel = model;
      this.wait(Espo.Ajax.postRequest('UserSecurity/action/getTwoFactorUserSetupData', {
        id: this.model.id,
        password: this.model.get('password'),
        auth2FAMethod: this.model.get('auth2FAMethod'),
        reset: this.options.reset
      }).then(data => {
        this.emailAddressList = data.emailAddressList;
        this.createView('record', 'views/record/edit-for-modal', {
          scope: 'None',
          selector: '.record',
          model: model,
          detailLayout: [{
            rows: [[{
              name: 'emailAddress',
              labelText: this.translate('emailAddress', 'fields', 'User')
            }, false], [{
              name: 'code',
              labelText: this.translate('Code', 'labels', 'User')
            }, false]]
          }]
        }, view => {
          view.setFieldOptionList('emailAddress', this.emailAddressList);
          if (this.emailAddressList.length) {
            model.set('emailAddress', this.emailAddressList[0]);
          }
          view.hideField('code');
        });
      }));
    }
    afterRender() {
      this.$sendCode = this.$el.find('[data-action="sendCode"]');
      this.$pInfo = this.$el.find('p.p-info');
      this.$pButton = this.$el.find('p.p-button');
      this.$pInfoAfter = this.$el.find('p.p-info-after');
    }
    actionSendCode() {
      this.$sendCode.attr('disabled', 'disabled').addClass('disabled');
      Espo.Ajax.postRequest('TwoFactorEmail/action/sendCode', {
        id: this.model.id,
        emailAddress: this.internalModel.get('emailAddress')
      }).then(() => {
        this.showActionItem('apply');
        this.$pInfo.addClass('hidden');
        this.$pButton.addClass('hidden');
        this.$pInfoAfter.removeClass('hidden');
        this.getRecordView().setFieldReadOnly('emailAddress');
        this.getRecordView().showField('code');
      }).catch(() => {
        this.$sendCode.removeAttr('disabled').removeClass('disabled');
      });
    }

    /**
     * @return {import('views/record/edit').default}
     */
    getRecordView() {
      return this.getView('record');
    }
    actionApply() {
      const data = this.getRecordView().processFetch();
      if (!data) {
        return;
      }
      this.model.set('code', data.code);
      this.hideActionItem('apply');
      this.hideActionItem('cancel');
      Espo.Ui.notify(this.translate('pleaseWait', 'messages'));
      this.model.save().then(() => {
        Espo.Ui.notify(false);
        this.trigger('done');
      }).catch(() => {
        this.showActionItem('apply');
        this.showActionItem('cancel');
      });
    }
  }
  _exports.default = TwoFactorEmailModalView;
});

define("views/user-security/modals/totp", ["exports", "views/modal", "model"], function (_exports, _modal, _model) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  _model = _interopRequireDefault(_model);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class TotpModalView extends _modal.default {
    template = 'user-security/modals/totp';
    className = 'dialog dialog-record';
    shortcutKeys = {
      'Control+Enter': 'apply'
    };
    setup() {
      this.buttonList = [{
        name: 'apply',
        label: 'Apply',
        style: 'danger',
        onClick: () => this.actionApply()
      }, {
        name: 'cancel',
        label: 'Cancel'
      }];
      this.headerHtml = '&nbsp';
      const model = new _model.default();
      model.name = 'UserSecurity';
      this.wait(Espo.Ajax.postRequest('UserSecurity/action/getTwoFactorUserSetupData', {
        id: this.model.id,
        password: this.model.get('password'),
        auth2FAMethod: this.model.get('auth2FAMethod'),
        reset: this.options.reset
      }).then(/** Record */data => {
        this.label = data.label;
        this.secret = data.auth2FATotpSecret;
        model.set('secret', data.auth2FATotpSecret);
      }));
      model.setDefs({
        fields: {
          code: {
            type: 'varchar',
            required: true,
            maxLength: 7
          },
          secret: {
            type: 'varchar',
            readOnly: true
          }
        }
      });
      this.createView('record', 'views/record/edit-for-modal', {
        scope: 'None',
        selector: '.record',
        model: model,
        detailLayout: [{
          rows: [[{
            name: 'secret',
            labelText: this.translate('Secret', 'labels', 'User')
          }, false], [{
            name: 'code',
            labelText: this.translate('Code', 'labels', 'User')
          }, false]]
        }]
      });
      Espo.loader.requirePromise('lib!qrcodejs').then(lib => {
        QRCode = lib;
      });
    }
    afterRender() {
      new QRCode(this.$el.find('.qrcode').get(0), {
        text: `otpauth://totp/${this.label}?secret=${this.secret}`,
        width: 256,
        height: 256,
        colorDark: '#000000',
        colorLight: '#ffffff',
        correctLevel: QRCode.CorrectLevel.H
      });
    }

    /**
     * @return {import('views/record/edit').default}
     */
    getRecordView() {
      return this.getView('record');
    }
    actionApply() {
      const data = this.getRecordView().processFetch();
      if (!data) {
        return;
      }
      this.model.set('code', data.code);
      this.hideActionItem('apply');
      this.hideActionItem('cancel');
      Espo.Ui.notify(this.translate('pleaseWait', 'messages'));
      this.model.save().then(() => {
        Espo.Ui.notify(false);
        this.trigger('done');
      }).catch(() => {
        this.showActionItem('apply');
        this.showActionItem('cancel');
      });
    }
  }
  _exports.default = TotpModalView;
});

define("views/user/password-change-request", ["exports", "view", "model"], function (_exports, _view, _model) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  _model = _interopRequireDefault(_model);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _view.default {
    template = 'user/password-change-request';
    data() {
      return {
        requestId: this.options.requestId,
        notFound: this.options.notFound,
        notFoundMessage: this.notFoundMessage
      };
    }
    setup() {
      this.addHandler('click', '#btn-submit', () => this.submit());
      const model = this.model = new _model.default();
      model.entityType = model.name = 'User';
      this.createView('password', 'views/user/fields/password', {
        model: model,
        mode: 'edit',
        selector: '.field[data-name="password"]',
        defs: {
          name: 'password',
          params: {
            required: true,
            maxLength: 255
          }
        },
        strengthParams: this.options.strengthParams
      });
      this.createView('passwordConfirm', 'views/fields/password', {
        model: model,
        mode: 'edit',
        selector: '.field[data-name="passwordConfirm"]',
        defs: {
          name: 'passwordConfirm',
          params: {
            required: true,
            maxLength: 255
          }
        }
      });
      this.createView('generatePassword', 'views/user/fields/generate-password', {
        model: model,
        mode: 'detail',
        readOnly: true,
        selector: '.field[data-name="generatePassword"]',
        defs: {
          name: 'generatePassword'
        },
        strengthParams: this.options.strengthParams
      });
      this.createView('passwordPreview', 'views/fields/base', {
        model: model,
        mode: 'detail',
        readOnly: true,
        selector: '.field[data-name="passwordPreview"]',
        defs: {
          name: 'passwordPreview'
        }
      });
      this.model.on('change:passwordPreview', () => this.reRender());
      const url = this.baseUrl = window.location.href.split('?')[0];
      this.notFoundMessage = this.translate('passwordChangeRequestNotFound', 'messages', 'User').replace('{url}', url);
    }

    /**
     * @param {string} name
     * @return {import('views/fields/base').default}
     */
    getFieldView(name) {
      return /** @type {import('views/fields/base').default} */this.getView(name);
    }
    submit() {
      this.getFieldView('password').fetchToModel();
      this.getFieldView('passwordConfirm').fetchToModel();
      const notValid = this.getFieldView('password').validate() || this.getFieldView('passwordConfirm').validate();
      const password = this.model.get('password');
      if (notValid) {
        return;
      }
      const $submit = this.$el.find('.btn-submit');
      $submit.addClass('disabled');
      Espo.Ajax.postRequest('User/changePasswordByRequest', {
        requestId: this.options.requestId,
        password: password
      }).then(data => {
        this.$el.find('.password-change').remove();
        const url = data.url || this.baseUrl;
        const a = document.createElement('a');
        a.href = url;
        a.innerText = this.translate('Login', 'labels', 'User');
        const message = this.translate('passwordChangedByRequest', 'messages', 'User');
        const html = this.getHelper().escapeString(message) + ' ' + a.outerHTML;
        this.$el.find('.msg-box').removeClass('hidden').html('<span class="text-success">' + html + '</span>');
      }).catch(() => {
        return $submit.removeClass('disabled');
      });
    }
  }
  _exports.default = _default;
});

define("views/user/list", ["exports", "views/list"], function (_exports, _list) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _list = _interopRequireDefault(_list);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _list.default {
    storeViewAfterUpdate = false;
  }
  _exports.default = _default;
});

define("views/user/detail", ["exports", "views/detail"], function (_exports, _detail) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _detail = _interopRequireDefault(_detail);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _detail.default {
    setup() {
      super.setup();
      if (this.getUser().isPortal()) {
        this.rootLinkDisabled = true;
      }
      if (this.model.id === this.getUser().id || this.getUser().isAdmin()) {
        if (this.getUserModel().isRegular() || this.getUserModel().isAdmin() || this.getUserModel().isPortal()) {
          this.addMenuItem('dropdown', {
            name: 'preferences',
            label: 'Preferences',
            action: 'preferences',
            link: `#Preferences/edit/${this.model.id}`,
            onClick: () => this.actionPreferences()
          });
        }
        if (this.getUserModel().isRegular() || this.getUserModel().isAdmin()) {
          if (this.getAcl().check('EmailAccountScope') && this.model.id === this.getUser().id || this.getUser().isAdmin()) {
            this.addMenuItem('dropdown', {
              name: 'emailAccounts',
              label: "Email Accounts",
              action: 'emailAccounts',
              link: `#EmailAccount/list/userId=${this.model.id}` + `&userName=${encodeURIComponent(this.model.attributes.name)}`,
              onClick: () => this.actionEmailAccounts()
            });
          }
          if (this.model.id === this.getUser().id && this.getAcl().checkScope('ExternalAccount')) {
            this.addMenuItem('buttons', {
              name: 'externalAccounts',
              label: 'External Accounts',
              action: 'externalAccounts',
              link: '#ExternalAccount',
              onClick: () => this.actionExternalAccounts()
            });
          }
        }
      }
      if (this.getAcl().checkScope('Calendar') && (this.getUserModel().isRegular() || this.getUserModel().isAdmin())) {
        const showActivities = this.getAcl().checkPermission('userCalendar', this.getUserModel());
        if (!showActivities && this.getAcl().getPermissionLevel('userCalendar') === 'team' && !this.model.has('teamsIds')) {
          this.listenToOnce(this.model, 'sync', () => {
            if (this.getAcl().checkPermission('userCalendar', this.getUserModel())) {
              this.showHeaderActionItem('calendar');
            }
          });
        }
        this.addMenuItem('buttons', {
          name: 'calendar',
          iconHtml: '<span class="far fa-calendar-alt"></span>',
          text: this.translate('Calendar', 'scopeNames'),
          link: `#Calendar/show/userId=${this.model.id}` + `&userName=${encodeURIComponent(this.model.attributes.name)}`,
          hidden: !showActivities
        });
      }
    }

    /**
     * @type {import('models/user').default}
     */
    getUserModel() {
      return /** @type {import('models/user').default} */this.model;
    }
    actionPreferences() {
      this.getRouter().navigate(`#Preferences/edit/${this.model.id}`, {
        trigger: true
      });
    }
    actionEmailAccounts() {
      this.getRouter().navigate(`#EmailAccount/list/userId=${this.model.id}&userName=${encodeURIComponent(this.model.attributes.name)}`, {
        trigger: true
      });
    }
    actionExternalAccounts() {
      this.getRouter().navigate('#ExternalAccount', {
        trigger: true
      });
    }
  }
  _exports.default = _default;
});

define("views/user/record/list", ["exports", "views/record/list"], function (_exports, _list) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _list = _interopRequireDefault(_list);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class UserListRecordView extends _list.default {
    rowActionsView = 'views/user/record/row-actions/default';
    quickEditDisabled = true;
    massActionList = ['remove', 'massUpdate', 'export'];
    checkAllResultMassActionList = ['massUpdate', 'export'];
    setupMassActionItems() {
      super.setupMassActionItems();
      if (this.scope === 'ApiUser') {
        this.removeMassAction('massUpdate');
        this.removeMassAction('export');
        this.layoutName = 'listApi';
      }
      if (this.scope === 'PortalUser') {
        this.layoutName = 'listPortal';
      }
      if (!this.getUser().isAdmin()) {
        this.removeMassAction('massUpdate');
        this.removeMassAction('export');
      }
    }
    getModelScope(id) {
      const model = /** @type {import('models/user').default} */
      this.collection.get(id);
      if (model.isPortal()) {
        return 'PortalUser';
      }
      return this.scope;
    }
  }
  _exports.default = UserListRecordView;
});

define("views/user/record/edit", ["exports", "views/record/edit", "views/user/record/detail"], function (_exports, _edit, _detail) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _edit = _interopRequireDefault(_edit);
  _detail = _interopRequireDefault(_detail);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class UserEditRecordView extends _edit.default {
    /**
     * @name model
     * @type module:models/user
     * @memberOf UserEditRecordView#
     */

    setup() {
      super.setup();
      this.setupNonAdminFieldsAccess();
      if (this.model.id === this.getUser().id) {
        this.listenTo(this.model, 'after:save', () => {
          this.getUser().set(this.model.getClonedAttributes());
        });
      }
      this.hideField('sendAccessInfo');
      this.passwordInfoMessage = this.getPasswordSendingMessage();
      if (!this.passwordInfoMessage) {
        this.hideField('passwordInfo');
      }
      let passwordChanged = false;
      this.listenToOnce(this.model, 'change:password', () => {
        passwordChanged = true;
        if (this.model.isNew()) {
          this.controlSendAccessInfoFieldForNew();
          return;
        }
        this.controlSendAccessInfoField();
      });
      this.listenTo(this.model, 'change', model => {
        if (!this.model.isNew() && !passwordChanged) {
          return;
        }
        if (!model.hasChanged('emailAddress') && !model.hasChanged('portalsIds') && !model.hasChanged('password')) {
          return;
        }
        if (this.model.isNew()) {
          this.controlSendAccessInfoFieldForNew();
          return;
        }
        this.controlSendAccessInfoField();
      });
      _detail.default.prototype.setupFieldAppearance.call(this);
      this.hideField('passwordPreview');
      this.listenTo(this.model, 'change:passwordPreview', (model, value) => {
        value = value || '';
        if (value.length) {
          this.showField('passwordPreview');
        } else {
          this.hideField('passwordPreview');
        }
      });
      this.listenTo(this.model, 'after:save', () => {
        this.model.unset('password', {
          silent: true
        });
        this.model.unset('passwordConfirm', {
          silent: true
        });
      });
    }
    controlSendAccessInfoField() {
      if (this.isPasswordSendable() && this.model.get('password')) {
        this.showField('sendAccessInfo');
        return;
      }
      this.hideField('sendAccessInfo');
      if (!this.model.has('sendAccessInfo')) {
        return;
      }
      this.model.set('sendAccessInfo', false);
    }
    controlSendAccessInfoFieldForNew() {
      const skipSettingTrue = this.recordHelper.getFieldStateParam('sendAccessInfo', 'hidden') === false;
      if (this.isPasswordSendable()) {
        this.showField('sendAccessInfo');
        if (!skipSettingTrue) {
          this.model.set('sendAccessInfo', true);
        }
        return;
      }
      this.hideField('sendAccessInfo');
      this.model.set('sendAccessInfo', false);
    }

    // noinspection SpellCheckingInspection
    isPasswordSendable() {
      if (this.model.isPortal()) {
        if (!(this.model.get('portalsIds') || []).length) {
          return false;
        }
      }
      if (!this.model.get('emailAddress')) {
        return false;
      }
      return true;
    }
    setupNonAdminFieldsAccess() {
      _detail.default.prototype.setupNonAdminFieldsAccess.call(this);
    }

    // noinspection JSUnusedGlobalSymbols
    controlFieldAppearance() {
      _detail.default.prototype.controlFieldAppearance.call(this);
    }
    getGridLayout(callback) {
      this.getHelper().layoutManager.get(this.model.entityType, this.options.layoutName || this.layoutName, simpleLayout => {
        /** @type {module:views/record/detail~panelDefs[]} */
        const layout = Espo.Utils.cloneDeep(simpleLayout);

        /** @type {module:views/record/detail~panelDefs[]} */
        const panels = [];
        panels.push({
          "label": "Teams and Access Control",
          "name": "accessControl",
          "rows": [[{
            "name": "type"
          }, {
            "name": "isActive"
          }], [{
            "name": "teams"
          }, {
            "name": "defaultTeam"
          }], [{
            "name": "roles"
          }, false]]
        });
        panels.push({
          "label": "Portal",
          "name": "portal",
          "rows": [[{
            "name": "portals"
          }, {
            "name": "accounts"
          }], [{
            "name": "portalRoles"
          }, {
            "name": "contact"
          }]]
        });
        if (this.getUser().isAdmin() && this.model.isPortal()) {
          panels.push({
            "label": "Misc",
            "name": "portalMisc",
            "rows": [[{
              "name": "dashboardTemplate"
            }, false]]
          });
        }
        if (this.model.isAdmin() || this.model.isRegular()) {
          panels.push({
            "label": "Misc",
            "name": "misc",
            "rows": [[{
              "name": "workingTimeCalendar"
            }, {
              "name": "layoutSet"
            }]]
          });
        }
        if (this.type === this.TYPE_EDIT && this.getUser().isAdmin() && !this.model.isApi()) {
          panels.push({
            label: 'Password',
            rows: [[{
              name: 'password',
              type: 'password',
              params: {
                required: false,
                readyToChange: true
              },
              view: 'views/user/fields/password'
            }, {
              name: 'generatePassword',
              view: 'views/user/fields/generate-password',
              customLabel: ''
            }], [{
              name: 'passwordConfirm',
              type: 'password',
              params: {
                required: false,
                readyToChange: true
              }
            }, {
              name: 'passwordPreview',
              view: 'views/fields/base',
              params: {
                readOnly: true
              }
            }], [{
              name: 'sendAccessInfo'
            }, {
              name: 'passwordInfo',
              type: 'text',
              customLabel: '',
              customCode: this.passwordInfoMessage
            }]]
          });
        }
        if (this.getUser().isAdmin() && this.model.isApi()) {
          panels.push({
            "name": "auth",
            "rows": [[{
              "name": "authMethod"
            }, false]]
          });
        }
        let hasTab = false;
        for (const [i, panel] of layout.entries()) {
          if (panel.tabBreak && i > 0) {
            layout.splice(i, 0, ...panels);
            hasTab = true;
            break;
          }
        }
        if (!hasTab) {
          layout.push(...panels);
        }
        this.detailLayout = layout;
        const gridLayout = {
          type: 'record',
          layout: this.convertDetailLayout(layout)
        };
        callback(gridLayout);
      });
    }
    getPasswordSendingMessage() {
      if (this.getConfig().get('outboundEmailFromAddress')) {
        return '';
      }
      let msg = this.translate('setupSmtpBefore', 'messages', 'User').replace('{url}', '#Admin/outboundEmails');
      msg = this.getHelper().transformMarkdownInlineText(msg);
      return msg;
    }
    fetch() {
      const data = super.fetch();
      if (!this.isNew) {
        if ('password' in data && (data['password'] === '' || data['password'] == null)) {
          delete data['password'];
          delete data['passwordConfirm'];
          this.model.unset('password');
          this.model.unset('passwordConfirm');
        }
      }
      return data;
    }
    exit(after) {
      if (after === 'create' || after === 'save') {
        this.model.unset('sendAccessInfo', {
          silent: true
        });
      }
      super.exit(after);
    }

    // noinspection JSUnusedGlobalSymbols
    errorHandlerUserNameExists() {
      Espo.Ui.error(this.translate('userNameExists', 'messages', 'User'));
    }
  }
  var _default = _exports.default = UserEditRecordView;
});

define("views/user/record/edit-quick", ["exports", "views/record/edit", "views/user/record/detail"], function (_exports, _edit, _detail) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _edit = _interopRequireDefault(_edit);
  _detail = _interopRequireDefault(_detail);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _edit.default {
    sideView = 'views/record/edit-side';
    setup() {
      super.setup();
      _detail.default.prototype.setupNonAdminFieldsAccess.call(this);
      _detail.default.prototype.setupFieldAppearance.call(this);
    }

    // noinspection JSUnusedGlobalSymbols
    controlFieldAppearance() {
      _detail.default.prototype.controlFieldAppearance.call(this);
    }
  }
  _exports.default = _default;
});

define("views/user/record/detail-quick", ["exports", "views/record/detail", "views/user/record/detail"], function (_exports, _detail, _detail2) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _detail = _interopRequireDefault(_detail);
  _detail2 = _interopRequireDefault(_detail2);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _detail.default {
    sideView = 'views/user/record/detail-quick-side';
    bottomView = null;
    setup() {
      super.setup();
      _detail2.default.prototype.setupNonAdminFieldsAccess.call(this);
      _detail2.default.prototype.setupFieldAppearance.call(this);
    }

    // noinspection JSUnusedGlobalSymbols
    controlFieldAppearance() {
      _detail2.default.prototype.controlFieldAppearance.call(this);
    }
  }
  _exports.default = _default;
});

define("views/user/record/detail-quick-side", ["exports", "views/record/detail-side", "views/user/record/detail-side"], function (_exports, _detailSide, _detailSide2) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _detailSide = _interopRequireDefault(_detailSide);
  _detailSide2 = _interopRequireDefault(_detailSide2);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  // noinspection JSUnusedGlobalSymbols
  class _default extends _detailSide.default {
    setupPanels() {
      _detailSide2.default.prototype.setupPanels.call(this);
    }
  }
  _exports.default = _default;
});

define("views/user/record/detail-bottom", ["exports", "views/record/detail-bottom"], function (_exports, _detailBottom) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _detailBottom = _interopRequireDefault(_detailBottom);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class UserDetailBottomRecordView extends _detailBottom.default {
    setupPanels() {
      super.setupPanels();
      const userModel = /** @type {import('models/user').default} */this.model;
      const streamAllowed = this.getAcl().checkPermission('user', userModel);
      if (!streamAllowed && this.getAcl().getPermissionLevel('user') === 'team' && !this.model.has('teamsIds')) {
        this.listenToOnce(this.model, 'sync', () => {
          if (this.getAcl().checkPermission('user', userModel)) {
            this.onPanelsReady(() => {
              this.showPanel('stream', 'acl');
            });
          }
        });
      }
      this.panelList.push({
        "name": "stream",
        "label": "Stream",
        "view": "views/user/record/panels/stream",
        "sticked": false,
        "hidden": !streamAllowed
      });
      if (!streamAllowed) {
        this.recordHelper.setPanelStateParam('stream', 'hiddenAclLocked', true);
      }
    }
  }
  var _default = _exports.default = UserDetailBottomRecordView;
});

define("views/user/record/row-actions/relationship-followers", ["exports", "views/record/row-actions/relationship"], function (_exports, _relationship) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _relationship = _interopRequireDefault(_relationship);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  // noinspection JSUnusedGlobalSymbols
  class UserRelationshipFollowersRowActionsView extends _relationship.default {
    getActionList() {
      const list = [];
      const model = /** @type {import('models/user').default} */this.model;
      list.push({
        action: 'quickView',
        label: 'View',
        data: {
          id: this.model.id
        },
        link: `#${this.model.entityType}/view/${this.model.id}`
      });
      if (this.getUser().isAdmin() || this.getAcl().getPermissionLevel('followerManagementPermission') !== 'no' || model.isPortal() && this.getAcl().getPermissionLevel('portalPermission') === 'yes' || this.model.id === this.getUser().id) {
        list.push({
          action: 'unlinkRelated',
          label: 'Unlink',
          data: {
            id: this.model.id
          }
        });
      }
      return list;
    }
  }
  _exports.default = UserRelationshipFollowersRowActionsView;
});

define("views/user/record/row-actions/default", ["exports", "views/record/row-actions/default"], function (_exports, _default) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _default = _interopRequireDefault(_default);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class UserDefaultRowActionsView extends _default.default {
    getActionList() {
      let scope = 'User';
      const model = /** @type {import('models/user').default} */this.model;
      if (model.isPortal()) {
        scope = 'PortalUser';
      } else if (model.isApi()) {
        scope = 'ApiUser';
      }
      const list = [{
        action: 'quickView',
        label: 'View',
        data: {
          id: this.model.id,
          scope: scope
        },
        link: `#${scope}/view/${this.model.id}`
      }];
      if (this.options.acl.edit) {
        list.push({
          action: 'quickEdit',
          label: 'Edit',
          data: {
            id: this.model.id,
            scope: scope
          },
          link: `#${scope}/edit/${this.model.id}`
        });
      }
      this.getAdditionalActionList().forEach(item => list.push(item));
      return list;
    }
  }
  _exports.default = UserDefaultRowActionsView;
});

define("views/user/record/panels/stream", ["exports", "views/stream/panel"], function (_exports, _panel) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _panel = _interopRequireDefault(_panel);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _panel.default {
    setup() {
      const model = /** @type import('models/user').default */this.model;
      if (this.model.id === this.getUser().id) {
        this.placeholderText = this.translate('writeMessageToSelf', 'messages');
      } else {
        this.placeholderText = this.translate('writeMessageToUser', 'messages').replace('{user}', this.model.get('name'));
      }
      super.setup();
      this.setupPermission(model);
    }

    /**
     * @private
     * @param {import('models/user').default} model
     */
    setupPermission(model) {
      const permission = this.getAcl().checkPermission('message', model);
      if (permission) {
        return;
      }
      this.postDisabled = true;
      if (permission !== null) {
        return;
      }
      this.listenToOnce(this.model, 'sync', async () => {
        if (!this.getAcl().checkPermission('message', model)) {
          return;
        }
        this.postDisabled = false;
        await this.whenRendered();
        const container = this.element.querySelector('.post-container');
        if (container) {
          container.classList.remove('hidden');
        }
      });
    }
    prepareNoteForPost(model) {
      const userIdList = [this.model.id];
      const userNames = {};
      userNames[userIdList] = this.model.get('name');
      model.set('usersIds', userIdList);
      model.set('usersNames', userNames);
      model.set('targetType', 'users');
    }
  }
  _exports.default = _default;
});

define("views/user/record/panels/default-side", ["exports", "views/record/panels/default-side"], function (_exports, _defaultSide) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _defaultSide = _interopRequireDefault(_defaultSide);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _defaultSide.default {
    complexCreatedDisabled = true;
    complexModifiedDisabled = true;
  }
  _exports.default = _default;
});

define("views/user/modals/select-followers", ["exports", "views/modals/select-records"], function (_exports, _selectRecords) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _selectRecords = _interopRequireDefault(_selectRecords);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _selectRecords.default {
    setup() {
      this.filterList = ['active'];
      if (this.getAcl().getPermissionLevel('portalPermission')) {
        this.filterList.push('activePortal');
      }
      super.setup();
    }
  }
  _exports.default = _default;
});

define("views/user/modals/security", ["exports", "views/modal", "model"], function (_exports, _modal, _model) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  _model = _interopRequireDefault(_model);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class UserSecurityModalView extends _modal.default {
    templateContent = '<div class="record no-side-margin">{{{record}}}</div>';
    className = 'dialog dialog-record';
    shortcutKeys = {
      'Control+Enter': 'apply'
    };
    setup() {
      this.buttonList = [{
        name: 'apply',
        label: 'Apply',
        hidden: true,
        style: 'danger',
        onClick: () => this.apply()
      }, {
        name: 'cancel',
        label: 'Close'
      }];
      this.dropdownItemList = [{
        name: 'reset',
        text: this.translate('Reset 2FA'),
        hidden: true,
        onClick: () => this.reset()
      }];
      this.userModel = this.options.userModel;
      this.$header = $('<span>').append($('<span>').text(this.translate('Security')), ' <span class="chevron-right"></span> ', $('<span>').text(this.userModel.get('userName')));
      const model = this.model = new _model.default();
      model.name = 'UserSecurity';
      model.id = this.userModel.id;
      model.url = 'UserSecurity/' + this.userModel.id;
      const auth2FAMethodList = this.getConfig().get('auth2FAMethodList') || [];
      model.setDefs({
        fields: {
          'auth2FA': {
            type: 'bool',
            labelText: this.translate('auth2FAEnable', 'fields', 'User')
          },
          'auth2FAMethod': {
            type: 'enum',
            options: auth2FAMethodList,
            translation: 'Settings.options.auth2FAMethodList'
          }
        }
      });
      this.wait(model.fetch().then(() => {
        this.initialAttributes = Espo.Utils.cloneDeep(model.attributes);
        if (model.get('auth2FA')) {
          this.showActionItem('reset');
        }
        this.createView('record', 'views/record/edit-for-modal', {
          scope: 'None',
          selector: '.record',
          model: this.model,
          detailLayout: [{
            rows: [[{
              name: 'auth2FA',
              labelText: this.translate('auth2FAEnable', 'fields', 'User')
            }, {
              name: 'auth2FAMethod',
              labelText: this.translate('auth2FAMethod', 'fields', 'User')
            }]]
          }]
        }, view => {
          this.controlFieldsVisibility(view);
          this.listenTo(this.model, 'change:auth2FA', () => {
            this.controlFieldsVisibility(view);
          });
        });
      }));
      this.listenTo(this.model, 'change', () => {
        if (this.initialAttributes) {
          this.isChanged() ? this.showActionItem('apply') : this.hideActionItem('apply');
        }
      });
    }
    controlFieldsVisibility(view) {
      if (this.model.get('auth2FA')) {
        view.showField('auth2FAMethod');
        view.setFieldRequired('auth2FAMethod');
      } else {
        view.hideField('auth2FAMethod');
        view.setFieldNotRequired('auth2FAMethod');
      }
    }
    isChanged() {
      return this.initialAttributes.auth2FA !== this.model.get('auth2FA') || this.initialAttributes.auth2FAMethod !== this.model.get('auth2FAMethod');
    }
    reset() {
      this.confirm(this.translate('security2FaResetConfirmation', 'messages', 'User'), () => {
        this.apply(true);
      });
    }

    /**
     * @return {module:views/record/edit}
     */
    getRecordView() {
      return this.getView('record');
    }
    apply(reset) {
      const data = this.getRecordView().processFetch();
      if (!data) {
        return;
      }
      this.hideActionItem('apply');
      new Promise(resolve => {
        this.createView('dialog', 'views/user/modals/password', {}, passwordView => {
          passwordView.render();
          this.listenToOnce(passwordView, 'cancel', () => this.showActionItem('apply'));
          this.listenToOnce(passwordView, 'proceed', data => {
            this.model.set('password', data.password);
            passwordView.close();
            resolve();
          });
        });
      }).then(() => this.processApply(reset));
    }
    processApply(reset) {
      if (this.model.get('auth2FA')) {
        const auth2FAMethod = this.model.get('auth2FAMethod');
        const view = this.getMetadata().get(['app', 'authentication2FAMethods', auth2FAMethod, 'userApplyView']);
        if (view) {
          Espo.Ui.notifyWait();
          this.createView('dialog', view, {
            model: this.model,
            reset: reset
          }, view => {
            Espo.Ui.notify(false);
            view.render();
            this.listenToOnce(view, 'cancel', () => {
              this.close();
            });
            this.listenToOnce(view, 'apply', () => {
              view.close();
              this.processSave();
            });
            this.listenToOnce(view, 'done', () => {
              Espo.Ui.success(this.translate('Done'));
              this.trigger('done');
              view.close();
              this.close();
            });
          });
          return;
        }
        if (reset) {
          this.model.set('auth2FA', false);
        }
        this.processSave();
        return;
      }
      this.processSave();
    }
    processSave() {
      this.hideActionItem('apply');
      this.model.save().then(() => {
        this.close();
        Espo.Ui.success(this.translate('Done'));
      }).catch(() => this.showActionItem('apply'));
    }
  }
  var _default = _exports.default = UserSecurityModalView;
});

define("views/user/modals/password", ["exports", "views/modal", "model"], function (_exports, _modal, _model) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  _model = _interopRequireDefault(_model);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _modal.default {
    templateContent = '<div class="record no-side-margin">{{{record}}}</div>';
    className = 'dialog dialog-record';
    shortcutKeys = {
      'Control+Enter': 'apply'
    };
    setup() {
      this.buttonList = [{
        name: 'apply',
        label: 'Apply',
        style: 'danger',
        onClick: () => this.actionApply()
      }, {
        name: 'cancel',
        label: 'Cancel'
      }];
      this.headerHtml = '&nbsp';
      this.userModel = this.options.userModel;
      const model = this.model = new _model.default();
      model.name = 'UserSecurity';
      model.setDefs({
        fields: {
          'password': {
            type: 'password',
            required: true
          }
        }
      });
      this.createView('record', 'views/record/edit-for-modal', {
        scope: 'None',
        selector: '.record',
        model: this.model,
        detailLayout: [{
          rows: [[{
            name: 'password',
            labelText: this.translate('yourPassword', 'fields', 'User'),
            params: {
              readyToChange: true
            }
          }, false]]
        }]
      });
    }

    /**
     * @return {import('views/record/edit').default}
     */
    getRecordView() {
      return this.getView('record');
    }
    actionApply() {
      const data = this.getRecordView().processFetch();
      if (!data) {
        return;
      }
      this.trigger('proceed', data);
    }
  }
  _exports.default = _default;
});

define("views/user/modals/mass-update", ["exports", "views/modals/mass-update"], function (_exports, _massUpdate) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _massUpdate = _interopRequireDefault(_massUpdate);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _massUpdate.default {
    setup() {
      if (this.options.scope === 'ApiUser') {
        this.layoutName = 'massUpdateApi';
      } else if (this.options.scope === 'PortalUser') {
        this.layoutName = 'massUpdatePortal';
      }
      super.setup();
    }
  }
  _exports.default = _default;
});

define("views/user/modals/login-as", ["exports", "views/modal"], function (_exports, _modal) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _modal.default {
    backdrop = true;

    // language=Handlebars
    templateContent = `
        <div class="well">
            {{translate 'loginAs' category='messages' scope='User'}}
        </div>
        <a href="{{viewObject.url}}" class="text-large">{{translate 'Login Link' scope='User'}}</a>
    `;
    setup() {
      this.$header = $('<span>').append($('<span>').text(this.model.get('name')), ' ', $('<span>').addClass('chevron-right'), ' ', $('<span>').text(this.translate('Login')));
      this.url = `?entryPoint=loginAs&anotherUser=${this.options.anotherUser}&username=${this.options.username}`;
    }
  }
  _exports.default = _default;
});

define("views/user/modals/detail", ["exports", "views/modals/detail"], function (_exports, _detail) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _detail = _interopRequireDefault(_detail);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _detail.default {
    editDisabled = true;
    getScope() {
      const model = /** @type {import('models/user').default} */this.model;
      if (model.isPortal()) {
        return 'PortalUser';
      }
      return 'User';
    }
  }
  _exports.default = _default;
});

define("views/user/modals/access", ["exports", "views/modal"], function (_exports, _modal) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _modal.default {
    cssName = 'user-access';
    multiple = false;
    template = 'user/modals/access';
    backdrop = true;
    styleMap = {
      yes: 'success',
      all: 'success',
      account: 'info',
      contact: 'info',
      team: 'info',
      own: 'warning',
      no: 'danger',
      enabled: 'success',
      disabled: 'danger',
      'not-set': 'default'
    };
    data() {
      return {
        valuePermissionDataList: this.getValuePermissionList(),
        levelListTranslation: this.getLanguage().get('Role', 'options', 'levelList') || {},
        styleMap: this.styleMap
      };
    }
    getValuePermissionList() {
      const list = this.getMetadata().get(['app', 'acl', 'valuePermissionList'], []);
      const dataList = [];
      list.forEach(item => {
        const o = {};
        o.name = item;
        o.value = this.options.aclData[item];
        dataList.push(o);
      });
      return dataList;
    }
    setup() {
      this.buttonList = [{
        name: 'cancel',
        label: 'Cancel'
      }];
      const fieldTable = Espo.Utils.cloneDeep(this.options.aclData.fieldTable || {});
      for (const scope in fieldTable) {
        const scopeData = fieldTable[scope] || {};
        for (const field in scopeData) {
          if (this.getMetadata().get(['app', 'acl', 'mandatory', 'scopeFieldLevel', scope, field]) !== null) {
            delete scopeData[field];
          }
          if (scopeData[field] && this.getMetadata().get(['entityDefs', scope, 'fields', field, 'readOnly'])) {
            if (scopeData[field].edit === 'no' && scopeData[field].read === 'yes') {
              delete scopeData[field];
            }
          }
        }
      }
      this.createView('table', 'views/role/record/table', {
        acl: {
          data: this.options.aclData.table,
          fieldData: fieldTable
        },
        final: true,
        selector: '.user-access-table'
      });
      this.headerText = this.translate('Access');
    }
  }
  _exports.default = _default;
});

define("views/user/fields/user-name", ["exports", "views/fields/varchar"], function (_exports, _varchar) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _varchar = _interopRequireDefault(_varchar);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _varchar.default {
    setup() {
      super.setup();
      this.validations.push(() => this.validateUserName());
    }
    afterRender() {
      super.afterRender();
      const userNameRegularExpression = this.getUserNameRegularExpression();
      if (this.isEditMode()) {
        this.$element.on('change', () => {
          let value = this.$element.val();
          const re = new RegExp(userNameRegularExpression, 'gi');
          value = value.replace(re, '').replace(/[\s]/g, '_').toLowerCase();
          this.$element.val(value);
          this.trigger('change');
        });
      }
    }
    getUserNameRegularExpression() {
      return this.getConfig().get('userNameRegularExpression') || '[^a-z0-9\-@_\.\s]';
    }
    validateUserName() {
      const value = this.model.get(this.name);
      if (!value) {
        return;
      }
      const userNameRegularExpression = this.getUserNameRegularExpression();
      const re = new RegExp(userNameRegularExpression, 'gi');
      if (!re.test(value)) {
        return;
      }
      const msg = this.translate('fieldInvalid', 'messages').replace('{field}', this.getLabelText());
      this.showValidationMessage(msg);
      return true;
    }
  }
  _exports.default = _default;
});

define("views/user/fields/teams", ["exports", "views/fields/link-multiple-with-role"], function (_exports, _linkMultipleWithRole) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _linkMultipleWithRole = _interopRequireDefault(_linkMultipleWithRole);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _linkMultipleWithRole.default {
    forceRoles = true;
    setup() {
      super.setup();
      this.roleListMap = {};
      this.loadRoleList(() => {
        if (this.isEditMode()) {
          if (this.isRendered() || this.isBeingRendered()) {
            this.reRender();
          }
        }
      });
      this.listenTo(this.model, 'change:teamsIds', () => {
        let toLoad = false;
        this.ids.forEach(id => {
          if (!(id in this.roleListMap)) {
            toLoad = true;
          }
        });
        if (toLoad) {
          this.loadRoleList(() => {
            this.reRender();
          });
        }
      });
    }
    loadRoleList(callback, context) {
      if (!this.getAcl().checkScope('Team', 'read')) {
        return;
      }
      const ids = this.ids || [];
      if (ids.length === 0) {
        return;
      }
      this.getCollectionFactory().create('Team', teams => {
        teams.maxSize = 50;
        teams.where = [{
          type: 'in',
          field: 'id',
          value: ids
        }];
        this.listenToOnce(teams, 'sync', () => {
          teams.models.forEach(model => {
            this.roleListMap[model.id] = model.get('positionList') || [];
          });
          callback.call(context);
        });
        teams.fetch();
      });
    }
    getDetailLinkHtml(id, name) {
      name = name || this.nameHash[id] || id;
      let role = (this.columns[id] || {})[this.columnName] || '';
      const $el = $('<div>').append($('<a>').attr('href', '#' + this.foreignScope + '/view/' + id).attr('data-id', id).text(name));
      if (role) {
        role = this.getHelper().escapeString(role);
        $el.append($('<span>').text(' '), $('<span>').addClass('text-muted middle-dot'), $('<span>').text(' '), $('<span>').addClass('text-muted').text(role));
      }
      return $el.get(0).outerHTML;
    }
    getJQSelect(id, roleValue) {
      /** @var {string[]} */
      const roleList = Espo.Utils.clone(this.roleListMap[id] || []);
      if (!roleList.length && !roleValue) {
        return null;
      }
      roleList.unshift('');
      if (roleValue && roleList.indexOf(roleValue) === -1) {
        roleList.push(roleValue);
      }
      const $role = $('<select>').addClass('role form-control input-sm pull-right').attr('data-id', id);
      roleList.forEach(role => {
        const $option = $('<option>').val(role).text(role);
        if (role === (roleValue || '')) {
          $option.attr('selected', 'selected');
        }
        $role.append($option);
      });
      return $role;
    }
  }
  _exports.default = _default;
});

define("views/user/fields/record-access-level", ["exports", "views/fields/bool"], function (_exports, _bool) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _bool = _interopRequireDefault(_bool);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _bool.default {
    getValueForDisplay() {
      /** @type {Record<string, string>} */
      const levels = this.model.attributes.recordAccessLevels || {};
      const action = this.name.substring('recordAccessLevel'.length);
      return levels[action] || false;
    }
  }
  _exports.default = _default;
});

define("views/user/fields/password", ["exports", "views/fields/password"], function (_exports, _password) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _password = _interopRequireDefault(_password);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class UserPasswordFieldView extends _password.default {
    validations = ['required', 'strength', 'confirm'];
    init() {
      const tooltipItemList = [];
      this.strengthParams = this.options.strengthParams || {
        passwordStrengthLength: this.getConfig().get('passwordStrengthLength'),
        passwordStrengthLetterCount: this.getConfig().get('passwordStrengthLetterCount'),
        passwordStrengthNumberCount: this.getConfig().get('passwordStrengthNumberCount'),
        passwordStrengthBothCases: this.getConfig().get('passwordStrengthBothCases'),
        passwordStrengthSpecialCharacterCount: this.getConfig().get('passwordStrengthSpecialCharacterCount')
      };
      const minLength = this.strengthParams.passwordStrengthLength;
      if (minLength) {
        tooltipItemList.push('* ' + this.translate('passwordStrengthLength', 'messages', 'User').replace('{length}', minLength.toString()));
      }
      const requiredLetterCount = this.strengthParams.passwordStrengthLetterCount;
      if (requiredLetterCount) {
        tooltipItemList.push('* ' + this.translate('passwordStrengthLetterCount', 'messages', 'User').replace('{count}', requiredLetterCount.toString()));
      }
      const requiredNumberCount = this.strengthParams.passwordStrengthNumberCount;
      if (requiredNumberCount) {
        tooltipItemList.push('* ' + this.translate('passwordStrengthNumberCount', 'messages', 'User').replace('{count}', requiredNumberCount.toString()));
      }
      const bothCases = this.strengthParams.passwordStrengthBothCases;
      if (bothCases) {
        tooltipItemList.push('* ' + this.translate('passwordStrengthBothCases', 'messages', 'User'));
      }
      if (this.strengthParams.passwordStrengthSpecialCharacterCount) {
        tooltipItemList.push('* ' + this.translate('passwordStrengthSpecialCharacterCount', 'messages', 'User').replace('{count}', this.strengthParams.passwordStrengthSpecialCharacterCount.toString()));
      }
      if (tooltipItemList.length) {
        this.tooltip = true;
        this.tooltipText = this.translate('Requirements', 'labels', 'User') + ':\n' + tooltipItemList.join('\n');
      }
      super.init();
    }

    // noinspection JSUnusedGlobalSymbols
    validateStrength() {
      if (!this.model.get(this.name)) {
        return;
      }
      const password = this.model.get(this.name);
      const minLength = this.strengthParams.passwordStrengthLength;
      if (minLength) {
        if (password.length < minLength) {
          const msg = this.translate('passwordStrengthLength', 'messages', 'User').replace('{length}', minLength.toString());
          this.showValidationMessage(msg);
          return true;
        }
      }
      const requiredLetterCount = this.strengthParams.passwordStrengthLetterCount;
      if (requiredLetterCount) {
        let letterCount = 0;
        password.split('').forEach(c => {
          if (c.toLowerCase() !== c.toUpperCase()) {
            letterCount++;
          }
        });
        if (letterCount < requiredLetterCount) {
          const msg = this.translate('passwordStrengthLetterCount', 'messages', 'User').replace('{count}', requiredLetterCount.toString());
          this.showValidationMessage(msg);
          return true;
        }
      }
      const requiredNumberCount = this.strengthParams.passwordStrengthNumberCount;
      if (requiredNumberCount) {
        let numberCount = 0;
        password.split('').forEach(c => {
          if (c >= '0' && c <= '9') {
            numberCount++;
          }
        });
        if (numberCount < requiredNumberCount) {
          const msg = this.translate('passwordStrengthNumberCount', 'messages', 'User').replace('{count}', requiredNumberCount.toString());
          this.showValidationMessage(msg);
          return true;
        }
      }
      const bothCases = this.strengthParams.passwordStrengthBothCases;
      if (bothCases) {
        let ucCount = 0;
        password.split('').forEach(c => {
          if (c.toLowerCase() !== c.toUpperCase() && c === c.toUpperCase()) {
            ucCount++;
          }
        });
        let lcCount = 0;
        password.split('').forEach(c => {
          if (c.toLowerCase() !== c.toUpperCase() && c === c.toLowerCase()) {
            lcCount++;
          }
        });
        if (!ucCount || !lcCount) {
          const msg = this.translate('passwordStrengthBothCases', 'messages', 'User');
          this.showValidationMessage(msg);
          return true;
        }
      }
      const requiredSpecialCharacterCount = this.strengthParams.passwordStrengthSpecialCharacterCount;
      if (requiredSpecialCharacterCount) {
        let count = 0;
        password.split('').forEach(c => {
          if ("'-!\"#$%&()*,./:;?@[]^_`{|}~+<=>".includes(c)) {
            count++;
          }
        });
        if (count < requiredSpecialCharacterCount) {
          const msg = this.translate('passwordStrengthSpecialCharacterCount', 'messages', 'User').replace('{count}', requiredSpecialCharacterCount.toString());
          this.showValidationMessage(msg);
          return true;
        }
      }
    }
  }
  var _default = _exports.default = UserPasswordFieldView;
});

define("views/user/fields/name", ["exports", "views/fields/person-name"], function (_exports, _personName) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _personName = _interopRequireDefault(_personName);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _personName.default {
    listTemplate = 'user/fields/name/list-link';
    listLinkTemplate = 'user/fields/name/list-link';
    data() {
      const model = /** @type {import('models/user').default} */this.model;

      // noinspection JSValidateTypes
      return {
        ...super.data(),
        avatar: this.getAvatarHtml(),
        frontScope: model.isPortal() ? 'PortalUser' : 'User',
        isOwn: this.model.id === this.getUser().id
      };
    }
    getAvatarHtml() {
      return this.getHelper().getAvatarHtml(this.model.id, 'small', 20, 'avatar-link');
    }
  }
  _exports.default = _default;
});

define("views/user/fields/generate-password", ["exports", "views/fields/base"], function (_exports, _base) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class UserGeneratePasswordFieldView extends _base.default {
    templateContent = `
        <button
            type="button"
            class="btn btn-default"
            data-action="generatePassword"
        >{{translate 'Generate' scope='User'}}</button>`;
    events = {
      /** @this {UserGeneratePasswordFieldView} */
      'click [data-action="generatePassword"]': function () {
        this.actionGeneratePassword();
      }
    };
    setup() {
      super.setup();
      this.listenTo(this.model, 'change:password', (model, value, o) => {
        if (o.isGenerated) {
          return;
        }
        if (value !== undefined) {
          this.model.set('passwordPreview', null);
          return;
        }
        this.model.unset('passwordPreview');
      });
      this.strengthParams = this.options.strengthParams || {};
      this.passwordStrengthLength = this.strengthParams.passwordStrengthLength ?? this.getConfig().get('passwordStrengthLength') ?? null;
      this.passwordStrengthLetterCount = this.strengthParams.passwordStrengthLetterCount ?? this.getConfig().get('passwordStrengthLetterCount') ?? null;
      this.passwordStrengthNumberCount = this.strengthParams.passwordStrengthNumberCount ?? this.getConfig().get('passwordStrengthNumberCount') ?? null;
      this.passwordStrengthSpecialCharacterCount = this.strengthParams.passwordStrengthSpecialCharacterCount ?? this.getConfig().get('passwordStrengthSpecialCharacterCount') ?? null;
      this.passwordGenerateLength = this.strengthParams.passwordGenerateLength ?? this.getConfig().get('passwordGenerateLength') ?? null;
      this.passwordGenerateLetterCount = this.strengthParams.passwordGenerateLetterCount ?? this.getConfig().get('passwordGenerateLetterCount') ?? null;
      this.passwordGenerateNumberCount = this.strengthParams.passwordGenerateNumberCount ?? this.getConfig().get('passwordGenerateNumberCount') ?? null;
    }
    fetch() {
      return {};
    }
    actionGeneratePassword() {
      let length = this.passwordStrengthLength;
      let letterCount = this.passwordStrengthLetterCount;
      let numberCount = this.passwordStrengthNumberCount;
      const specialCharacterCount = this.passwordStrengthSpecialCharacterCount;
      const generateLength = this.passwordGenerateLength || 10;
      const generateLetterCount = this.passwordGenerateLetterCount || 4;
      const generateNumberCount = this.passwordGenerateNumberCount || 2;
      length = typeof length === 'undefined' ? generateLength : length;
      letterCount = typeof letterCount === 'undefined' ? generateLetterCount : letterCount;
      numberCount = typeof numberCount === 'undefined' ? generateNumberCount : numberCount;
      if (length < generateLength) {
        length = generateLength;
      }
      if (letterCount < generateLetterCount) {
        letterCount = generateLetterCount;
      }
      if (numberCount < generateNumberCount) {
        numberCount = generateNumberCount;
      }
      const password = this.generatePassword(length, letterCount, numberCount, true, specialCharacterCount);
      this.model.set({
        password: password,
        passwordConfirm: password,
        passwordPreview: password
      }, {
        isGenerated: true
      });
    }

    /**
     * @private
     * @param {number} length
     * @param {number} letters
     * @param {number} numbers
     * @param {boolean} bothCases
     * @param {number} specialCharacters
     * @return {string}
     */
    generatePassword(length, letters, numbers, bothCases, specialCharacters) {
      const chars = ['ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', '0123456789', 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz', "'-!\"#$%&()*,./:;?@[]^_`{|}~+<=>"];
      let upperCase = 0;
      let lowerCase = 0;
      if (bothCases) {
        upperCase = 1;
        lowerCase = 1;
        if (letters >= 2) {
          letters = letters - 2;
        } else {
          letters = 0;
        }
      }
      let either = length - (letters + numbers + upperCase + lowerCase + specialCharacters);
      if (either < 0) {
        either = 0;
      }
      const setList = [letters, numbers, either, upperCase, lowerCase, specialCharacters];
      const shuffle = function (array) {
        let currentIndex = array.length;
        while (0 !== currentIndex) {
          const randomArray = new Uint32Array(1);
          crypto.getRandomValues(randomArray);
          const randomIndex = Math.floor(randomArray[0] / (0xFFFFFFFF + 1) * currentIndex);
          currentIndex -= 1;
          const tempValue = array[currentIndex];
          array[currentIndex] = array[randomIndex];
          array[randomIndex] = tempValue;
        }
        return array;
      };
      const array = setList.map((len, i) => {
        return Array(len).fill(chars[i]).map(x => {
          const randomArray = new Uint32Array(1);
          crypto.getRandomValues(randomArray);
          const randomIndex = Math.floor(randomArray[0] / (0xFFFFFFFF + 1) * x.length);
          return x[randomIndex];
        }).join('');
      }).concat();
      return shuffle(array).join('');
    }
  }
  var _default = _exports.default = UserGeneratePasswordFieldView;
});

define("views/user/fields/default-team", ["exports", "views/fields/link"], function (_exports, _link) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _link = _interopRequireDefault(_link);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class UserDefaultTeamFieldView extends _link.default {
    setup() {
      super.setup();
      this.validations.push('isUsers');
    }
    getOnEmptyAutocomplete() {
      const names = this.model.get('teamsNames') || {};
      const list = this.model.getTeamIdList().map(id => ({
        id: id,
        name: names[id] || id
      }));
      return Promise.resolve(list);
    }

    // noinspection JSUnusedGlobalSymbols
    validateIsUsers() {
      const id = this.model.get('defaultTeamId');
      if (!id) {
        return false;
      }
      if (!this.model.has('teamsIds')) {
        // Mass update.
        return false;
      }
      if (this.model.getTeamIdList().includes(id)) {
        return false;
      }
      const msg = this.translate('defaultTeamIsNotUsers', 'messages', 'User');
      this.showValidationMessage(msg);
      return true;
    }
  }
  var _default = _exports.default = UserDefaultTeamFieldView;
});

define("views/user/fields/contact", ["exports", "views/fields/link"], function (_exports, _link) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _link = _interopRequireDefault(_link);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _link.default {
    select(model) {
      super.select(model);
      const attributes = {};
      if (model.get('accountId')) {
        const names = {};
        names[model.get('accountId')] = model.get('accountName');
        attributes.accountsIds = [model.get('accountId')];
        attributes.accountsNames = names;
      }
      attributes.firstName = model.get('firstName');
      attributes.lastName = model.get('lastName');
      attributes.salutationName = model.get('salutationName');
      attributes.emailAddress = model.get('emailAddress');
      attributes.emailAddressData = model.get('emailAddressData');
      attributes.phoneNumber = model.get('phoneNumber');
      attributes.phoneNumberData = model.get('phoneNumberData');
      if (this.model.isNew() && !this.model.get('userName') && attributes.emailAddress) {
        attributes.userName = attributes.emailAddress;
      }
      this.model.set(attributes);
    }
  }
  _exports.default = _default;
});

define("views/user/fields/avatar", ["exports", "views/fields/image", "model", "views/fields/colorpicker"], function (_exports, _image, _model, _colorpicker) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _image = _interopRequireDefault(_image);
  _model = _interopRequireDefault(_model);
  _colorpicker = _interopRequireDefault(_colorpicker);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class UserAvatarFieldView extends _image.default {
    getAttributeList() {
      if (this.isEditMode()) {
        return [...super.getAttributeList(), 'avatarColor'];
      }
      return [];
    }
    setup() {
      super.setup();
      this.on('after:inline-save', () => {
        this.suspendCache = true;
        this.reRender();
      });
      this.setupSub();
    }
    setupSub() {
      this.subModel = new _model.default();
      const syncModels = () => {
        this.subModel.set({
          color: this.model.attributes.avatarColor
        });
      };
      syncModels();
      this.listenTo(this.model, 'change:avatarColor', (m, v, o) => {
        if (o.fromView !== this) {
          syncModels();
        }
      });
      this.listenTo(this.subModel, 'change', (m, o) => {
        if (o.ui) {
          this.trigger('change');
        }
      });
    }
    onEditModeSet() {
      if (!this.hasColor()) {
        return;
      }
      this.colorView = new _colorpicker.default({
        name: 'color',
        model: this.subModel,
        labelText: this.translate('avatarColor', 'fields', 'User'),
        mode: 'edit'
      });
      return this.assignView('colorField', this.colorView, '[data-sub-field="color"]');
    }
    afterRender() {
      super.afterRender();
      if (this.isEditMode()) {
        const colorEl = document.createElement('div');
        colorEl.setAttribute('data-sub-field', 'color');
        colorEl.classList.add('avatar-field-color');

        // noinspection JSCheckFunctionSignatures
        this.element.appendChild(colorEl);
        if (this.colorView) {
          this.colorView.render().then(() => {
            const el = this.colorView.element.querySelector('input');
            el.placeholder = this.translate('avatarColor', 'fields', 'User');
          });
        }
      }
    }
    hasColor() {
      if (this.recordHelper && this.recordHelper.getFieldStateParam('avatarColor', 'readOnly')) {
        return false;
      }
      const userType = this.model.get('type');
      return ['regular', 'admin', 'api'].includes(userType);
    }
    fetch() {
      if (!this.hasColor()) {
        return super.fetch();
      }

      // noinspection JSValidateTypes
      return {
        ...super.fetch(),
        avatarColor: this.subModel.attributes.color
      };
    }

    /**
     * @protected
     * @param {File} file
     * @return {Promise<unknown>}
     */
    handleUploadingFile(file) {
      return new Promise((resolve, reject) => {
        const fileReader = new FileReader();
        fileReader.onload = e => {
          this.createView('crop', 'views/modals/image-crop', {
            contents: e.target.result
          }).then(view => {
            view.render();
            let cropped = false;
            this.listenToOnce(view, 'crop', dataUrl => {
              cropped = true;
              setTimeout(() => {
                fetch(dataUrl).then(result => result.blob()).then(blob => {
                  resolve(new File([blob], 'avatar.jpg', {
                    type: 'image/jpeg'
                  }));
                });
              }, 10);
            });
            this.listenToOnce(view, 'remove', () => {
              if (!cropped) {
                setTimeout(() => this.render(), 10);
                reject();
              }
              this.clearView('crop');
            });
          });
        };
        fileReader.readAsDataURL(file);
      });
    }
    getValueForDisplay() {
      if (!this.isReadMode()) {
        return '';
      }
      const id = this.model.get(this.idName);
      const userId = this.model.id;
      let t = this.cacheTimestamp = this.cacheTimestamp || Date.now();
      if (this.suspendCache) {
        t = Date.now();
      }
      const src = this.getBasePath() + '?entryPoint=avatar&size=' + this.previewSize + '&id=' + userId + '&t=' + t + '&attachmentId=' + (id || 'false');

      // noinspection HtmlRequiredAltAttribute,RequiredAttributes
      const $img = $('<img>').attr('src', src).attr('alt', this.labelText).css({
        maxWidth: (this.imageSizes[this.previewSize] || {})[0],
        maxHeight: (this.imageSizes[this.previewSize] || {})[1]
      });
      if (!this.isDetailMode()) {
        if (this.getCache()) {
          t = this.getCache().get('app', 'timestamp');
        }
        const src = `${this.getBasePath()}?entryPoint=avatar&size=${this.previewSize}&id=${userId}&t=${t}`;
        $img.attr('width', '16').attr('src', src).css('maxWidth', '16px');
      }
      if (!id) {
        return $img.get(0).outerHTML;
      }
      return $('<a>').attr('data-id', id).attr('data-action', 'showImagePreview').attr('href', this.getBasePath() + '?entryPoint=image&id=' + id).append($img).get(0).outerHTML;
    }
  }
  var _default = _exports.default = UserAvatarFieldView;
});

define("views/user/fields/auto-follow-entity-type-list", ["exports", "views/fields/multi-enum"], function (_exports, _multiEnum) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _multiEnum = _interopRequireDefault(_multiEnum);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  // noinspection JSUnusedGlobalSymbols
  class _default extends _multiEnum.default {
    setup() {
      this.params.options = Object.keys(this.getMetadata().get('scopes')).filter(scope => {
        return this.getMetadata().get(`scopes.${scope}.entity`) && this.getMetadata().get(`scopes.${scope}.stream`);
      }).sort((v1, v2) => {
        return this.translate(v1, 'scopeNamesPlural').localeCompare(this.translate(v2, 'scopeNamesPlural'));
      });
      super.setup();
    }
  }
  _exports.default = _default;
});

define("views/template/record/edit", ["exports", "views/record/edit"], function (_exports, _edit) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _edit = _interopRequireDefault(_edit);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _edit.default {
    saveAndContinueEditingAction = true;
    setup() {
      super.setup();
      if (!this.model.isNew()) {
        this.setFieldReadOnly('entityType');
      }
      if (this.model.get('entityType')) {
        this.showField('variables');
      } else {
        this.hideField('variables');
      }
      if (this.model.isNew()) {
        const storedData = {};
        this.listenTo(this.model, 'change:entityType', () => {
          const entityType = this.model.get('entityType');
          if (!entityType) {
            this.model.set('header', null);
            this.model.set('body', null);
            this.model.set('footer', null);
            this.hideField('variables');
            return;
          }
          this.showField('variables');
          if (entityType in storedData) {
            this.model.set('header', storedData[entityType].header);
            this.model.set('body', storedData[entityType].body);
            this.model.set('footer', storedData[entityType].footer);
            this.model.set('style', storedData[entityType].style);
            return;
          }
          let header, body, footer;
          let sourceType = null;
          let style = null;
          if (this.getMetadata().get(['entityDefs', 'Template', 'defaultTemplates', entityType])) {
            sourceType = entityType;
          } else {
            const scopeType = this.getMetadata().get(['scopes', entityType, 'type']);
            if (scopeType && this.getMetadata().get(['entityDefs', 'Template', 'defaultTemplates', scopeType])) {
              sourceType = scopeType;
            }
          }
          if (sourceType) {
            header = this.getMetadata().get(['entityDefs', 'Template', 'defaultTemplates', sourceType, 'header']);
            body = this.getMetadata().get(['entityDefs', 'Template', 'defaultTemplates', sourceType, 'body']);
            footer = this.getMetadata().get(['entityDefs', 'Template', 'defaultTemplates', sourceType, 'footer']);
            style = this.getMetadata().get(['entityDefs', 'Template', 'defaultTemplates', sourceType, 'style']);
          }
          body = body || null;
          header = header || null;
          footer = footer || null;
          this.model.set('body', body);
          this.model.set('header', header);
          this.model.set('footer', footer);
          this.model.set('style', style);
        });
        this.listenTo(this.model, 'change', (e, o) => {
          if (!o.ui) {
            return;
          }
          if (!this.model.hasChanged('header') && !this.model.hasChanged('body') && !this.model.hasChanged('footer') && !this.model.hasChanged('style')) {
            return;
          }
          const entityType = this.model.get('entityType');
          if (!entityType) {
            return;
          }
          storedData[entityType] = {
            header: this.model.get('header'),
            body: this.model.get('body'),
            footer: this.model.get('footer'),
            style: this.model.get('style')
          };
        });
      }
    }
  }
  _exports.default = _default;
});

define("views/template/record/detail", ["exports", "views/record/detail"], function (_exports, _detail) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _detail = _interopRequireDefault(_detail);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _detail.default {
    saveAndContinueEditingAction = true;
    setup() {
      super.setup();
      this.hideField('variables');
      this.on('after:set-edit-mode', () => this.showField('variables'));
      this.on('after:set-detail-mode', () => this.hideField('variables'));
    }
  }
  _exports.default = _default;
});

define("views/template/fields/variables", ["exports", "views/fields/base", "ui/select"], function (_exports, _base, _select) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  _select = _interopRequireDefault(_select);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _base.default {
    inlineEditDisabled = true;
    detailTemplate = 'template/fields/variables/detail';
    editTemplate = 'template/fields/variables/edit';

    // noinspection JSCheckFunctionSignatures
    data() {
      // noinspection JSValidateTypes
      return {
        attributeList: this.attributeList,
        entityType: this.model.get('entityType'),
        translatedOptions: this.translatedOptions
      };
    }
    setup() {
      this.addHandler('change', '[data-name="variables"]', () => {
        const attribute = this.$el.find('[data-name="variables"]').val();
        const $copy = this.$el.find('[data-name="copy"]');
        if (attribute !== '') {
          if (this.textVariables[attribute]) {
            $copy.val('{{{' + attribute + '}}}');
          } else {
            $copy.val('{{' + attribute + '}}');
          }
        } else {
          $copy.val('');
        }
      });
      this.setupAttributeList();
      this.setupTranslatedOptions();
      this.listenTo(this.model, 'change:entityType', () => {
        this.setupAttributeList();
        this.setupTranslatedOptions();
        this.reRender();
      });
    }
    setupAttributeList() {
      this.translatedOptions = {};
      const entityType = this.model.get('entityType');
      const fieldList = this.getFieldManager().getEntityTypeFieldList(entityType);
      const ignoreFieldList = [];
      fieldList.forEach(field => {
        const aclDefs = /** @type {Record} */
        this.getMetadata().get(['entityAcl', entityType, 'fields', field]) || {};
        const fieldDefs = /** @type {Record} */
        this.getMetadata().get(['entityDefs', entityType, 'fields', field]) || {};
        if (aclDefs.onlyAdmin || aclDefs.forbidden || aclDefs.internal || fieldDefs.disabled || fieldDefs.utility || fieldDefs.directAccessDisabled && !fieldDefs.loaderClassName || fieldDefs.templatePlaceholderDisabled) {
          ignoreFieldList.push(field);
        }
      });
      let attributeList = this.getFieldManager().getEntityTypeAttributeList(entityType) || [];
      const forbiddenList = Espo.Utils.clone(this.getAcl().getScopeForbiddenAttributeList(entityType));
      ignoreFieldList.forEach(field => {
        this.getFieldManager().getEntityTypeFieldAttributeList(entityType, field).forEach(attribute => {
          forbiddenList.push(attribute);
        });
      });
      attributeList = attributeList.filter(item => {
        if (~forbiddenList.indexOf(item)) {
          return;
        }
        const fieldType = this.getMetadata().get(['entityDefs', entityType, 'fields', item, 'type']);
        if (fieldType === 'map') {
          return;
        }
        return true;
      });
      attributeList.push('id');
      if (this.getMetadata().get(`entityDefs.${entityType}.fields.name.type`) === 'personName') {
        if (!~attributeList.indexOf('name')) {
          attributeList.unshift('name');
        }
      }
      this.addAdditionalPlaceholders(entityType, attributeList);
      attributeList = attributeList.sort((v1, v2) => {
        return this.translate(v1, 'fields', entityType).localeCompare(this.translate(v2, 'fields', entityType));
      });
      this.attributeList = attributeList;
      this.textVariables = {};
      this.attributeList.forEach(item => {
        if (~['text', 'wysiwyg'].indexOf(this.getMetadata().get(['entityDefs', entityType, 'fields', item, 'type']))) {
          this.textVariables[item] = true;
        }
      });
      if (!~this.attributeList.indexOf('now')) {
        this.attributeList.unshift('now');
      }
      if (!~this.attributeList.indexOf('today')) {
        this.attributeList.unshift('today');
      }

      // noinspection SpellCheckingInspection
      attributeList.unshift('pagebreak');
      this.attributeList.unshift('');
      const links = /** @type {Record<string, Record>} */this.getMetadata().get(`entityDefs.${entityType}.links`) || {};
      const linkList = Object.keys(links).sort((v1, v2) => {
        return this.translate(v1, 'links', entityType).localeCompare(this.translate(v2, 'links', entityType));
      });
      linkList.forEach(link => {
        const type = links[link].type;
        if (type !== 'belongsTo' && type !== 'hasOne') {
          return;
        }
        const scope = links[link].entity;
        if (!scope) {
          return;
        }
        if (links[link].disabled || links[link].utility) {
          return;
        }
        if (this.getMetadata().get(['entityAcl', entityType, 'links', link, 'onlyAdmin']) || this.getMetadata().get(['entityAcl', entityType, 'links', link, 'forbidden']) || this.getMetadata().get(['entityAcl', entityType, 'links', link, 'internal'])) {
          return;
        }
        const fieldList = this.getFieldManager().getEntityTypeFieldList(scope);
        const ignoreFieldList = [];
        fieldList.forEach(field => {
          const aclDefs = /** @type {Record} */
          this.getMetadata().get(['entityAcl', scope, 'fields', field]) || {};
          const fieldDefs = /** @type {Record} */
          this.getMetadata().get(['entityDefs', scope, 'fields', field]) || {};
          if (aclDefs.onlyAdmin || aclDefs.forbidden || aclDefs.internal || fieldDefs.disabled || fieldDefs.utility || fieldDefs.directAccessDisabled || fieldDefs.templatePlaceholderDisabled) {
            ignoreFieldList.push(field);
          }
        });
        let attributeList = this.getFieldManager().getEntityTypeAttributeList(scope) || [];
        const forbiddenList = Espo.Utils.clone(this.getAcl().getScopeForbiddenAttributeList(scope));
        ignoreFieldList.forEach(field => {
          this.getFieldManager().getEntityTypeFieldAttributeList(scope, field).forEach(attribute => {
            forbiddenList.push(attribute);
          });
        });
        attributeList = attributeList.filter(item => {
          if (~forbiddenList.indexOf(item)) {
            return;
          }
          const fieldType = this.getMetadata().get(['entityDefs', scope, 'fields', item, 'type']);
          if (fieldType === 'map') {
            return;
          }
          return true;
        });
        attributeList.push('id');
        if (this.getMetadata().get(`entityDefs.${scope}.fields.name.type`) === 'personName') {
          attributeList.unshift('name');
        }
        const originalAttributeList = Espo.Utils.clone(attributeList);
        this.addAdditionalPlaceholders(scope, attributeList, link, entityType);
        attributeList.sort((v1, v2) => {
          return this.translate(v1, 'fields', scope).localeCompare(this.translate(v2, 'fields', scope));
        });
        attributeList.forEach(item => {
          if (~originalAttributeList.indexOf(item)) {
            this.attributeList.push(`${link}.${item}`);
          } else {
            this.attributeList.push(item);
          }
        });
        attributeList.forEach(item => {
          const variable = `${link}.${item}`;
          if (~['text', 'wysiwyg'].indexOf(this.getMetadata().get(['entityDefs', scope, 'fields', item, 'type']))) {
            this.textVariables[variable] = true;
          }
        });
      });
      return this.attributeList;
    }
    addAdditionalPlaceholders(entityType, attributeList, link, superEntityType) {
      let value;
      function removeItem(attributeList, item) {
        for (let i = 0; i < attributeList.length; i++) {
          if (attributeList[i] === item) {
            attributeList.splice(i, 1);
          }
        }
      }
      const fieldDefs = this.getMetadata().get(['entityDefs', entityType, 'fields']) || {};
      for (const field in fieldDefs) {
        const fieldType = fieldDefs[field].type;
        let item = field;
        if (link) {
          item = `${link}.${item}`;
        }
        if (fieldType === 'image') {
          removeItem(attributeList, field + 'Name');
          removeItem(attributeList, field + 'Id');
          value = 'imageTag ' + item + 'Id';
          attributeList.push(value);
          this.translatedOptions[value] = this.translate(field, 'fields', entityType);
          if (link) {
            this.translatedOptions[value] = this.translate(link, 'links', superEntityType) + ' . ' + this.translatedOptions[value];
          }
        } else if (fieldType === 'barcode') {
          removeItem(attributeList, field);
          const barcodeType = this.getMetadata().get(['entityDefs', entityType, 'fields', field, 'codeType']);
          value = `barcodeImage ${item} type='${barcodeType}'`;
          attributeList.push(value);
          this.translatedOptions[value] = this.translate(field, 'fields', entityType);
          if (link) {
            this.translatedOptions[value] = this.translate(link, 'links', superEntityType) + ' . ' + this.translatedOptions[value];
          }
        }
      }
    }
    setupTranslatedOptions() {
      const entityType = this.model.get('entityType');
      this.attributeList.forEach(item => {
        const link = item.split('.')[0];

        // noinspection SpellCheckingInspection
        if (~['today', 'now', 'pagebreak'].indexOf(item)) {
          if (!this.getMetadata().get(['entityDefs', entityType, 'fields', item])) {
            this.translatedOptions[item] = this.getLanguage().translateOption(item, 'placeholders', 'Template');
            return;
          }
        }
        let field = item;
        let scope = entityType;
        let isForeign = false;
        if (~item.indexOf('.')) {
          isForeign = true;
          field = item.split('.')[1];
          scope = this.getMetadata().get(`entityDefs.${entityType}.links.${link}.entity`);
        }
        if (this.translatedOptions[item]) {
          return;
        }
        this.translatedOptions[item] = this.translate(field, 'fields', scope);
        if (field.indexOf('Id') === field.length - 2) {
          const baseField = field.substr(0, field.length - 2);
          if (this.getMetadata().get(['entityDefs', scope, 'fields', baseField])) {
            this.translatedOptions[item] = this.translate(baseField, 'fields', scope) + ' (' + this.translate('id', 'fields') + ')';
          }
        } else if (field.indexOf('Name') === field.length - 4) {
          const baseField = field.substr(0, field.length - 4);
          if (this.getMetadata().get(['entityDefs', scope, 'fields', baseField])) {
            this.translatedOptions[item] = this.translate(baseField, 'fields', scope) + ' (' + this.translate('name', 'fields') + ')';
          }
        } else if (field.indexOf('Type') === field.length - 4) {
          const baseField = field.substr(0, field.length - 4);
          if (this.getMetadata().get(['entityDefs', scope, 'fields', baseField])) {
            this.translatedOptions[item] = this.translate(baseField, 'fields', scope) + ' (' + this.translate('type', 'fields') + ')';
          }
        }
        if (field.indexOf('Ids') === field.length - 3) {
          const baseField = field.substr(0, field.length - 3);
          if (this.getMetadata().get(['entityDefs', scope, 'fields', baseField])) {
            this.translatedOptions[item] = this.translate(baseField, 'fields', scope) + ' (' + this.translate('ids', 'fields') + ')';
          }
        } else if (field.indexOf('Names') === field.length - 5) {
          const baseField = field.substr(0, field.length - 5);
          if (this.getMetadata().get(['entityDefs', scope, 'fields', baseField])) {
            this.translatedOptions[item] = this.translate(baseField, 'fields', scope) + ' (' + this.translate('names', 'fields') + ')';
          }
        } else if (field.indexOf('Types') === field.length - 5) {
          const baseField = field.substr(0, field.length - 5);
          if (this.getMetadata().get(['entityDefs', scope, 'fields', baseField])) {
            this.translatedOptions[item] = this.translate(baseField, 'fields', scope) + ' (' + this.translate('types', 'fields') + ')';
          }
        }
        if (isForeign) {
          this.translatedOptions[item] = this.translate(link, 'links', entityType) + ' . ' + this.translatedOptions[item];
        }
      });
    }
    afterRender() {
      super.afterRender();
      if (this.mode === this.MODE_EDIT) {
        _select.default.init(this.$el.find('[data-name="variables"]'));
      }
    }
    fetch() {
      return {};
    }
  }
  _exports.default = _default;
});

define("views/template/fields/style", ["exports", "views/fields/text"], function (_exports, _text) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _text = _interopRequireDefault(_text);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * @type {{
   *     edit: import('ace-builds').edit,
   *     require: import('ace-builds').require,
   * }}
   */
  let ace;
  class TemplateStyleFieldView extends _text.default {
    // language=Handlebars
    detailTemplateContent = `
        {{#if isNotEmpty}}
            <div id="{{containerId}}">{{value}}</div>
        {{else}}
            <span class="none-value">{{translate 'None'}}</span>
        {{/if}}
    `;

    // language=Handlebars
    editTemplateContent = `
        <div id="{{containerId}}">{{value}}</div>
    `;
    height = 46;
    maxLineDetailCount = 80;
    maxLineEditCount = 200;
    setup() {
      super.setup();
      this.height = this.options.height || this.params.height || this.height;
      this.maxLineDetailCount = this.options.maxLineDetailCount || this.params.maxLineDetailCount || this.maxLineDetailCount;
      this.maxLineEditCount = this.options.maxLineEditCount || this.params.maxLineEditCount || this.maxLineEditCount;
      this.containerId = 'editor-' + Math.floor(Math.random() * 10000 + 1).toString();
      if (this.mode === this.MODE_EDIT || this.mode === this.MODE_DETAIL) {
        this.wait(this.requireAce());
      }
      this.on('remove', () => {
        if (this.editor) {
          this.editor.destroy();
        }
      });
    }
    requireAce() {
      return Espo.loader.requirePromise('lib!ace').then(lib => {
        ace = lib;
        const list = [Espo.loader.requirePromise('lib!ace-ext-language_tools'), Espo.loader.requirePromise('lib!ace-mode-css')];
        if (this.getThemeManager().getParam('isDark')) {
          list.push(Espo.loader.requirePromise('lib!ace-theme-tomorrow_night'));
        }
        return Promise.all(list);
      });
    }
    data() {
      const data = super.data();
      data.containerId = this.containerId;
      return data;
    }
    afterRender() {
      super.afterRender();
      this.$editor = this.$el.find('#' + this.containerId);
      if (this.$editor.length && (this.mode === this.MODE_EDIT || this.mode === this.MODE_DETAIL || this.mode === this.MODE_LIST)) {
        this.$editor.css('fontSize', 'var(--font-size-base)');
        if (this.mode === this.MODE_EDIT) {
          this.$editor.css('minHeight', this.height + 'px');
        }
        const editor = this.editor = ace.edit(this.containerId);
        editor.setOptions({
          fontFamily: 'var(--font-family-monospace)'
        });
        editor.setFontSize('var(--font-size-base)');
        editor.container.style.lineHeight = 'var(--line-height-computed)';
        editor.renderer.updateFontSize();
        editor.setOptions({
          maxLines: this.mode === this.MODE_EDIT ? this.maxLineEditCount : this.maxLineDetailCount,
          enableLiveAutocompletion: true
        });
        if (this.getThemeManager().getParam('isDark')) {
          editor.setOptions({
            theme: 'ace/theme/tomorrow_night'
          });
        }
        if (this.isEditMode()) {
          editor.getSession().on('change', () => {
            this.trigger('change', {
              ui: true
            });
          });
          editor.getSession().setUseWrapMode(true);
        }
        if (this.isReadMode()) {
          editor.setReadOnly(true);
          editor.renderer.$cursorLayer.element.style.display = 'none';
          editor.renderer.setShowGutter(false);
        }
        editor.setShowPrintMargin(false);
        editor.getSession().setUseWorker(false);
        editor.commands.removeCommand('find');
        editor.setHighlightActiveLine(false);
        const Mode = ace.require('ace/mode/css').Mode;
        editor.session.setMode(new Mode());
      }
    }
    fetch() {
      const data = {};
      data[this.name] = this.editor.getValue() || null;
      return data;
    }
  }
  var _default = _exports.default = TemplateStyleFieldView;
});

define("views/template/fields/font-face", ["exports", "views/fields/enum"], function (_exports, _enum) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _enum = _interopRequireDefault(_enum);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  // noinspection JSUnusedGlobalSymbols
  class _default extends _enum.default {
    setupOptions() {
      const engine = this.getConfig().get('pdfEngine') || 'Dompdf';
      let fontFaceList = this.getMetadata().get(['app', 'pdfEngines', engine, 'fontFaceList']) || [];
      fontFaceList = Espo.Utils.clone(fontFaceList);
      fontFaceList.unshift('');
      this.params.options = fontFaceList;
    }
  }
  _exports.default = _default;
});

define("views/template/fields/entity-type", ["exports", "views/fields/entity-type"], function (_exports, _entityType) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _entityType = _interopRequireDefault(_entityType);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _entityType.default {
    checkAvailability(entityType) {
      const defs = this.scopesMetadataDefs[entityType] || {};
      if (defs.pdfTemplate) {
        return true;
      }
      if (defs.entity && defs.object) {
        return true;
      }
      return false;
    }
  }
  _exports.default = _default;
});

define("views/template/fields/body", ["exports", "views/fields/wysiwyg"], function (_exports, _wysiwyg) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _wysiwyg = _interopRequireDefault(_wysiwyg);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class BodyTemplateFieldView extends _wysiwyg.default {
    htmlPurificationForEditDisabled = true;
    noStylesheet = true;
    useIframe = true;
    tableClassName = 'bordered';
    handlebars = true;
  }
  var _default = _exports.default = BodyTemplateFieldView;
});

define("views/team/record/list", ["exports", "views/record/list"], function (_exports, _list) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _list = _interopRequireDefault(_list);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _list.default {
    quickDetailDisabled = true;
    quickEditDisabled = true;
    checkAllResultDisabled = true;
  }
  _exports.default = _default;
});

define("views/team/record/edit", ["exports", "views/record/edit"], function (_exports, _edit) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _edit = _interopRequireDefault(_edit);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _edit.default {}
  _exports.default = _default;
});

define("views/team/record/detail", ["exports", "views/record/detail"], function (_exports, _detail) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _detail = _interopRequireDefault(_detail);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _detail.default {}
  _exports.default = _default;
});

define("views/team/modals/detail", ["exports", "views/modals/detail"], function (_exports, _detail) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _detail = _interopRequireDefault(_detail);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _detail.default {
    editDisabled = true;
  }
  _exports.default = _default;
});

define("views/stream/message", ["exports", "view"], function (_exports, _view) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class MessageStreamView extends _view.default {
    data() {
      return this.dataForTemplate;
    }
    setup() {
      let template = this.options.messageTemplate;
      const data = Espo.Utils.clone(this.options.messageData || {});
      this.dataForTemplate = {};
      for (let key in data) {
        const value = data[key] || '';
        if (key.indexOf('html:') === 0) {
          key = key.substring(5);
          this.dataForTemplate[key] = value;
          template = template.replace('{' + key + '}', '{{{' + key + '}}}');
          continue;
        }
        if (value instanceof jQuery) {
          this.dataForTemplate[key] = value.get(0).outerHTML;
          template = template.replace('{' + key + '}', '{{{' + key + '}}}');
          continue;
        }
        if (value instanceof Element) {
          this.dataForTemplate[key] = value.outerHTML;
          template = template.replace('{' + key + '}', '{{{' + key + '}}}');
          continue;
        }
        if (!value.indexOf) {
          continue;
        }
        if (value.indexOf('field:') === 0) {
          const field = value.substring(6);
          this.createField(key, field);
          const keyEscaped = this.getHelper().escapeString(key);
          template = template.replace('{' + key + '}', `<span data-key="${keyEscaped}">\{\{\{${key}\}\}\}</span>`);
          continue;
        }
        this.dataForTemplate[key] = value;
        template = template.replace(`{${key}}`, `{{${key}}}`);
      }
      this.templateContent = template;
    }
    createField(key, name, type, params) {
      type = type || this.model.getFieldType(name) || 'base';
      this.createView(key, this.getFieldManager().getViewName(type), {
        model: this.model,
        defs: {
          name: name,
          params: params || {}
        },
        mode: 'detail',
        readOnly: true,
        selector: `[data-key="${key}"]`
      });
    }
  }
  var _default = _exports.default = MessageStreamView;
});

define("views/stream/record/edit", ["exports", "views/record/base"], function (_exports, _base) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EditStreamView extends _base.default {
    template = 'stream/record/edit';
    postingMode = false;
    dependencyDefs = {
      'targetType': {
        map: {
          'users': [{
            action: 'hide',
            fields: ['teams', 'portals']
          }, {
            action: 'show',
            fields: ['users']
          }, {
            action: 'setNotRequired',
            fields: ['teams', 'portals']
          }, {
            action: 'setRequired',
            fields: ['users']
          }],
          'teams': [{
            action: 'hide',
            fields: ['users', 'portals']
          }, {
            action: 'show',
            fields: ['teams']
          }, {
            action: 'setRequired',
            fields: ['teams']
          }, {
            action: 'setNotRequired',
            fields: ['users', 'portals']
          }],
          'portals': [{
            action: 'hide',
            fields: ['users', 'teams']
          }, {
            action: 'show',
            fields: ['portals']
          }, {
            action: 'setRequired',
            fields: ['portals']
          }, {
            action: 'setNotRequired',
            fields: ['users', 'teams']
          }]
        },
        default: [{
          action: 'hide',
          fields: ['teams', 'users', 'portals']
        }, {
          action: 'setNotRequired',
          fields: ['teams', 'users', 'portals']
        }]
      }
    };
    setup() {
      super.setup();
      this.seed = this.model.clone();
      const optionList = ['self'];
      this.model.set('type', 'Post');
      this.model.set('targetType', 'self');
      const messagePermission = this.getAcl().getPermissionLevel('message');
      const portalPermission = this.getAcl().getPermissionLevel('portal');
      if (messagePermission === 'team' || messagePermission === 'all') {
        optionList.push('users');
        optionList.push('teams');
      }
      if (messagePermission === 'all') {
        optionList.push('all');
      }
      if (portalPermission === 'yes') {
        optionList.push('portals');
        if (!~optionList.indexOf('users')) {
          optionList.push('users');
        }
      }
      this.createField('targetType', 'views/fields/enum', {
        options: optionList
      });
      this.createField('users', 'views/note/fields/users', {});
      this.createField('teams', 'views/fields/teams', {});
      this.createField('portals', 'views/fields/link-multiple', {});
      this.createField('post', 'views/note/fields/post', {
        required: true,
        rowsMin: 1,
        noResize: true
      });
      this.createField('attachments', 'views/stream/fields/attachment-multiple', {});
      this.listenTo(this.model, 'change', () => {
        if (this.postingMode) {
          this.setConfirmLeaveOut(true);
        }
      });
    }
    disablePostingMode() {
      this.postingMode = false;
      this.$el.find('.post-control').addClass('hidden');
      this.setConfirmLeaveOut(false);
      $('body').off('click.stream-create-post');
      this.getFieldView('post').$element.prop('rows', 1);
    }
    enablePostingMode() {
      this.$el.find('.post-control').removeClass('hidden');
      if (!this.postingMode) {
        const $body = $('body');
        $body.off('click.stream-create-post');
        $body.on('click.stream-create-post', e => {
          if ($.contains(window.document.body, e.target) && !$.contains(this.$el.get(0), e.target) && !$(e.target).closest('.modal-dialog').length) {
            if (this.getFieldView('post') && this.getFieldView('post').$element.val() === '') {
              if (!(this.model.get('attachmentsIds') || []).length) {
                this.disablePostingMode();
              }
            }
          }
        });
      }
      this.postingMode = true;
    }
    afterRender() {
      this.$postButton = this.$el.find('button.post');
      const postView = this.getFieldView('post');
      if (postView) {
        this.stopListening(postView, 'add-files');
        this.listenTo(postView, 'add-files', files => {
          this.enablePostingMode();
          const attachmentsView = /** @type module:views/fields/attachment-multiple */
          this.getFieldView('attachments');
          if (!attachmentsView) {
            return;
          }
          attachmentsView.uploadFiles(files);
        });
      }
    }
    validate() {
      let notValid = super.validate();
      const message = this.model.get('post') || '';
      if (message.trim() === '' && !(this.model.get('attachmentsIds') || []).length) {
        notValid = true;
      }
      return notValid;
    }
    post() {
      this.save();
    }
    beforeBeforeSave() {
      this.disablePostButton();
    }
    beforeSave() {
      Espo.Ui.notifyWait();
    }
    afterSave() {
      Espo.Ui.success(this.translate('Posted'));
    }
    afterNotValid() {
      this.enablePostButton();
    }
    disablePostButton() {
      this.trigger('disable-post-button');
      this.$postButton.addClass('disable').attr('disabled', 'disabled');
    }
    enablePostButton() {
      this.trigger('enable-post-button');
      this.$postButton.removeClass('disable').removeAttr('disabled');
    }
  }
  var _default = _exports.default = EditStreamView;
});

define("views/stream/record/row-actions/update", ["exports", "views/stream/record/row-actions/default"], function (_exports, _default2) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _default2 = _interopRequireDefault(_default2);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class StreamUpdateNoteRowActionsView extends _default2.default {
    setup() {
      super.setup();
      this.addActionHandler('restore', () => this.actionRestore());
    }
    getActionList() {
      const list = super.getActionList();
      if (this.hasRestore()) {
        list.unshift({
          label: 'Restore',
          data: {
            id: this.model.id
          },
          action: 'restore'
        });
      }
      return list;
    }
    hasRestore() {
      if (this.options.listType !== 'listAuditLog') {
        return false;
      }
      const entityType = this.model.get('parentType');
      if (this.getMetadata().get(`clientDefs.${entityType}.editDisabled`)) {
        return false;
      }
      if (!this.getAcl().checkScope(entityType, 'edit')) {
        return false;
      }
      const fieldList = this.getFieldList();
      if (!fieldList.length) {
        return false;
      }
      for (const field of fieldList) {
        if (!this.getAcl().checkField(entityType, field, 'edit')) {
          return false;
        }
      }
      return true;
    }
    async actionRestore() {
      await this.confirm({
        message: this.translate('confirmRestoreFromAudit', 'messages'),
        confirmText: this.translate('Proceed')
      });
      const entityType = this.model.get('parentType');
      const entityId = this.model.get('parentId');
      this.getRouter().dispatch(entityType, 'edit', {
        id: entityId,
        attributes: this.getPreviousAttributes(),
        highlightFieldList: this.getFieldList()
      });
      this.getRouter().navigate(`#${entityType}/edit/${entityId}`, {
        trigger: false
      });
    }

    /**
     * @return {string[]}
     */
    getFieldList() {
      const data = /** @type {Record} */this.model.get('data') || {};
      return /** @type {string[]} */data.fields || [];
    }

    /**
     * @return {Record}
     */
    getPreviousAttributes() {
      const data = /** @type {Record} */this.model.get('data') || {};
      const attributes = /** @type {Record} */data.attributes || {};
      return attributes.was || {};
    }
  }
  var _default = _exports.default = StreamUpdateNoteRowActionsView;
});

define("views/stream/record/row-actions/detached", ["exports", "views/stream/record/row-actions/default"], function (_exports, _default2) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _default2 = _interopRequireDefault(_default2);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  // noinspection JSUnusedGlobalSymbols
  class _default extends _default2.default {
    isDetached = true;
  }
  _exports.default = _default;
});

define("views/stream/notes/update", ["exports", "views/stream/note"], function (_exports, _note) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _note = _interopRequireDefault(_note);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class UpdateNoteStreamView extends _note.default {
    template = 'stream/notes/update';
    messageName = 'update';
    rowActionsView = 'views/stream/record/row-actions/update';
    statusText;
    statusStyle;

    /**
     * @private
     * @type {boolean}
     */
    isExpanded = false;
    data() {
      const fieldsString = this.fieldDataList.map(it => it.label).join(', ');
      return {
        ...super.data(),
        fieldDataList: this.fieldDataList,
        parentType: this.model.get('parentType'),
        iconHtml: this.getIconHtml(),
        fieldsString: fieldsString,
        statusText: this.statusText,
        statusStyle: this.statusStyle
      };
    }
    init() {
      if (this.getUser().isAdmin()) {
        this.isRemovable = true;
      }
      super.init();
    }
    afterRender() {
      super.afterRender();
      if (this.isExpanded) {
        this.isExpanded = false;
        this.toggleDetails();
      }
    }
    setup() {
      this.addActionHandler('expandDetails', () => this.toggleDetails());
      this.createMessage();

      /** @type {Record} */
      const data = this.model.attributes.data;
      const parentType = this.model.attributes.parentType;
      if (data.value != null) {
        const statusField = this.statusField = this.getMetadata().get(`scopes.${parentType}.statusField`) ?? '';
        const statusValue = data.value;
        this.statusStyle = this.getMetadata().get(`entityDefs.${parentType}.fields.${statusField}.style.${statusValue}`) || 'default';
        this.statusText = this.getLanguage().translateOption(statusValue, statusField, this.model.attributes.parentType);
      }
      this.wait(true);
      this.getModelFactory().create(parentType).then(model => {
        const modelWas = model;
        const modelBecame = model.clone();
        data.attributes = data.attributes || {};
        modelWas.set(data.attributes.was);
        modelBecame.set(data.attributes.became);
        this.fieldDataList = [];
        const fields = this.fieldList = data.fields ?? [];
        fields.forEach(field => {
          const type = model.getFieldType(field) || 'base';
          const viewName = model.getFieldParam(field, 'auditView') ?? model.getFieldParam(field, 'view') ?? this.getFieldManager().getViewName(type);
          const attributeList = this.getFieldManager().getEntityTypeFieldAttributeList(model.entityType, field);
          let hasValue = false;
          for (const attribute of attributeList) {
            if (attribute in data.attributes.was) {
              hasValue = true;
              break;
            }
          }
          if (!hasValue) {
            this.fieldDataList.push({
              field: field,
              noValues: true,
              label: this.translate(field, 'fields', this.model.attributes.parentType)
            });
            return;
          }
          this.createView(field + 'Was', viewName, {
            model: modelWas,
            name: field,
            readOnly: true,
            mode: 'detail',
            inlineEditDisabled: true,
            selector: `.row[data-name="${field}"] .cell-was`,
            auditData: {
              type: 'was'
            }
          });
          this.createView(field + 'Became', viewName, {
            model: modelBecame,
            name: field,
            readOnly: true,
            mode: 'detail',
            inlineEditDisabled: true,
            selector: `.row[data-name="${field}"] .cell-became`,
            auditData: {
              type: 'became'
            }
          });
          this.fieldDataList.push({
            field: field,
            was: field + 'Was',
            became: field + 'Became',
            label: this.translate(field, 'fields', this.model.attributes.parentType)
          });
        });
        this.wait(false);
      });
    }
    toggleDetails() {
      const target = this.element.querySelector('[data-action="expandDetails"]');
      const detailsElement = this.element.querySelector(':scope > .details');
      const fieldElement = this.element.querySelector(':scope > .stream-details-container > .fields');
      const iconElement = target.querySelector('[data-role="icon"]');
      if (!this.isExpanded) {
        detailsElement.classList.remove('hidden');
        fieldElement === null || fieldElement === void 0 || fieldElement.classList.add('hidden');
        this.fieldList.forEach(field => {
          const wasField = this.getView(field + 'Was');
          const becomeField = this.getView(field + 'Became');
          if (wasField && becomeField) {
            wasField.trigger('panel-show-propagated');
            becomeField.trigger('panel-show-propagated');
          }
        });
        iconElement.classList.remove('fa-chevron-down');
        iconElement.classList.add('fa-chevron-up');
        this.isExpanded = true;
        return;
      }
      detailsElement.classList.add('hidden');
      fieldElement === null || fieldElement === void 0 || fieldElement.classList.remove('hidden');
      iconElement.classList.remove('fa-chevron-up');
      iconElement.classList.add('fa-chevron-down');
      this.isExpanded = false;
    }
  }
  var _default = _exports.default = UpdateNoteStreamView;
});

define("views/stream/notes/unrelate", ["exports", "views/stream/notes/relate"], function (_exports, _relate) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _relate = _interopRequireDefault(_relate);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class UnrelateNoteStreamView extends _relate.default {
    template = 'stream/notes/create-related';
    messageName = 'unrelate';
  }
  var _default = _exports.default = UnrelateNoteStreamView;
});

define("views/stream/notes/status", ["exports", "views/stream/note"], function (_exports, _note) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _note = _interopRequireDefault(_note);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * Legacy as of v9.2.0.
   */
  class StatusNoteStreamView extends _note.default {
    template = 'stream/notes/status';
    messageName = 'status';
    data() {
      return {
        ...super.data(),
        style: this.style,
        statusText: this.statusText,
        iconHtml: this.getIconHtml()
      };
    }
    init() {
      if (this.getUser().isAdmin()) {
        this.isRemovable = true;
      }
      super.init();
    }
    setup() {
      const data = this.model.get('data');
      const parentType = this.model.attributes.parentType;
      const field = this.getMetadata().get(`scopes.${parentType}.statusField`) ?? '';
      const value = data.value;
      this.style = data.style || 'default';
      this.statusText = this.getLanguage().translateOption(value, field, parentType);
      this.statusStyle = this.getMetadata().get(`entityDefs.${parentType}.fields.${field}.style.${value}`) || 'default';
      let fieldLabel = this.translate(field, 'fields', parentType);
      if (!this.isToUpperCaseStringItems()) {
        fieldLabel = fieldLabel.toLowerCase();
      }
      this.messageData['field'] = fieldLabel;
      this.createMessage();
    }
  }
  var _default = _exports.default = StatusNoteStreamView;
});

define("views/stream/notes/post", ["exports", "views/stream/note", "views/stream/reactions"], function (_exports, _note, _reactions) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _note = _interopRequireDefault(_note);
  _reactions = _interopRequireDefault(_reactions);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class PostNoteStreamView extends _note.default {
    template = 'stream/notes/post';
    messageName = 'post';
    isEditable = true;
    isRemovable = true;
    data() {
      const data = super.data();
      data.showAttachments = !!(this.model.get('attachmentsIds') || []).length;
      data.showPost = !!this.model.get('post');
      data.isInternal = this.isInternal;
      data.isPinned = this.isThis && this.model.get('isPinned') && this.model.collection && !this.model.collection.pinnedList;
      return data;
    }
    setup() {
      this.addActionHandler('react', (e, target) => this.react(target.dataset.type));
      this.addActionHandler('unReact', (e, target) => this.unReact(target.dataset.type));
      this.createField('post', null, null, 'views/stream/fields/post');
      this.createField('attachments', 'attachmentMultiple', {}, 'views/stream/fields/attachment-multiple', {
        previewSize: this.options.isNotification || this.options.isUserStream ? 'small' : 'medium'
      });
      this.isInternal = this.model.get('isInternal');
      this.setupReactions();
      if (!this.model.get('post') && this.model.get('parentId')) {
        this.messageName = 'attach';
        if (this.isThis) {
          this.messageName += 'This';
        }
      }
      this.listenTo(this.model, 'change', () => {
        if (this.model.hasChanged('post') || this.model.hasChanged('attachmentsIds')) {
          this.reRender();
        }
      });
      if (this.messageName === 'postThis') {
        this.messageTemplate = '{user}';
      }
      if (this.model.get('parentId')) {
        this.createMessage();
        return;
      }
      if (this.model.get('isGlobal')) {
        this.messageName = 'postTargetAll';
        this.createMessage();
        return;
      }
      if (this.model.has('teamsIds') && this.model.get('teamsIds').length) {
        const teamIdList = this.model.get('teamsIds');
        const teamNameHash = this.model.get('teamsNames') || {};
        this.messageName = 'postTargetTeam';
        if (teamIdList.length > 1) {
          this.messageName = 'postTargetTeams';
        }
        const teamHtmlList = [];
        teamIdList.forEach(teamId => {
          const teamName = teamNameHash[teamId];
          if (!teamName) {
            return;
          }
          teamHtmlList.push($('<a>').attr('href', '#Team/view/' + teamId).text(teamName).get(0).outerHTML);
        });
        this.messageData['html:target'] = teamHtmlList.join(', ');
        this.createMessage();
        return;
      }
      if (this.model.has('portalsIds') && this.model.get('portalsIds').length) {
        const portalIdList = this.model.get('portalsIds');
        const portalNameHash = this.model.get('portalsNames') || {};
        this.messageName = 'postTargetPortal';
        if (portalIdList.length > 1) {
          this.messageName = 'postTargetPortals';
        }
        const portalHtmlList = [];
        portalIdList.forEach(portalId => {
          const portalName = portalNameHash[portalId];
          if (!portalName) {
            return;
          }
          portalHtmlList.push($('<a>').attr('href', '#Portal/view/' + portalId).text(portalName).get(0).outerHTML);
        });
        this.messageData['html:target'] = portalHtmlList.join(', ');
        this.createMessage();
        return;
      }
      if (!this.model.has('usersIds') || !this.model.get('usersIds').length) {
        this.createMessage();
        return;
      }
      const userIdList = this.model.get('usersIds');
      const userNameHash = this.model.get('usersNames') || {};
      this.messageName = 'postTarget';
      if (userIdList.length === 1 && userIdList[0] === this.model.get('createdById')) {
        this.messageName = 'postTargetSelf';
        this.createMessage();
        return;
      }
      const userHtmlList = [];
      userIdList.forEach(userId => {
        if (userId === this.getUser().id) {
          this.messageName = 'postTargetYou';
          if (userIdList.length > 1) {
            if (userId === this.model.get('createdById')) {
              this.messageName = 'postTargetSelfAndOthers';
            } else {
              this.messageName = 'postTargetYouAndOthers';
            }
          }
          return;
        }
        if (userId === this.model.get('createdById')) {
          this.messageName = 'postTargetSelfAndOthers';
          return;
        }
        const userName = userNameHash[userId];
        if (!userName) {
          return;
        }
        userHtmlList.push($('<a>').attr('href', '#User/view/' + userId).attr('data-scope', 'User').attr('data-id', userId).text(userName).get(0).outerHTML);
      });
      this.messageData['html:target'] = userHtmlList.join(', ');
      this.createMessage();
    }

    /**
     * @private
     * @param {string} type
     */
    async react(type) {
      Espo.Ui.notifyWait();
      const previousMyReactions = this.model.attributes.myReactions;
      const previousReactionCounts = this.model.attributes.reactionCounts;
      const reactionCounts = {
        ...previousReactionCounts
      };
      if (!(type in reactionCounts)) {
        reactionCounts[type] = 0;
      }
      reactionCounts[type]++;
      this.model.set({
        myReactions: [type],
        reactionCounts: reactionCounts
      }, {
        userReaction: true
      });
      try {
        await Espo.Ajax.postRequest(`Note/${this.model.id}/myReactions/${type}`);
      } catch (e) {
        this.model.set({
          myReactions: previousMyReactions,
          reactionCounts: previousReactionCounts
        }, {
          userReaction: true
        });
        return;
      }
      Espo.Ui.success(this.translate('Reacted') + ' · ' + this.translate(type, 'reactions'));
      await this.model.fetch({
        userReaction: true,
        keepRowActions: true
      });
    }

    /**
     * @private
     * @param {string} type
     */
    async unReact(type) {
      Espo.Ui.notifyWait();
      const previousMyReactions = this.model.attributes.myReactions;
      const previousReactionCounts = this.model.attributes.reactionCounts;
      const reactionCounts = {
        ...previousReactionCounts
      };
      if (!(type in reactionCounts)) {
        reactionCounts[type] = 0;
      }
      reactionCounts[type]--;
      this.model.set({
        myReactions: [],
        reactionCounts: reactionCounts
      }, {
        userReaction: true
      });
      try {
        await Espo.Ajax.deleteRequest(`Note/${this.model.id}/myReactions/${type}`);
      } catch (e) {
        this.model.set({
          myReactions: previousMyReactions,
          reactionCounts: previousReactionCounts
        }, {
          userReaction: true
        });
        return;
      }
      Espo.Ui.warning(this.translate('Reaction Removed'));
      await this.model.fetch({
        userReaction: true,
        keepRowActions: true
      });
    }

    /**
     * @private
     */
    setupReactions() {
      const view = new _reactions.default({
        model: this.model
      });
      this.assignView('reactions', view, '.reactions-container');
      this.listenTo(this.model, 'change:reactionCounts change:myReactions', () => view.reRenderWhenNoPopover());
    }
  }
  var _default = _exports.default = PostNoteStreamView;
});

define("views/stream/notes/mention-in-post", ["exports", "views/stream/note"], function (_exports, _note) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _note = _interopRequireDefault(_note);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class MentionInPostNoteStreamView extends _note.default {
    template = 'stream/notes/post';
    messageName = 'mentionInPost';
    data() {
      return {
        ...super.data(),
        showAttachments: !!(this.model.get('attachmentsIds') || []).length,
        showPost: !!this.model.get('post')
      };
    }
    setup() {
      if (this.model.get('post')) {
        this.createField('post', null, null, 'views/stream/fields/post');
      }
      if ((this.model.get('attachmentsIds') || []).length) {
        this.createField('attachments', 'attachmentMultiple', {}, 'views/stream/fields/attachment-multiple', {
          previewSize: this.options.isNotification ? 'small' : null
        });
      }
      this.messageData['mentioned'] = this.options.userId;
      if (!this.model.get('parentId')) {
        this.messageName = 'mentionInPostTarget';
      }
      if (!this.options.isNotification && (!this.isUserStream || this.options.userId !== this.getUser().id)) {
        this.createMessage();
        return;
      }
      if (this.model.get('parentId')) {
        this.messageName = 'mentionYouInPost';
        this.createMessage();
        return;
      }
      this.messageName = 'mentionYouInPostTarget';
      if (this.model.get('isGlobal')) {
        this.messageName = 'mentionYouInPostTargetAll';
        this.createMessage();
        return;
      }
      this.messageName = 'mentionYouInPostTarget';
      if (this.model.has('teamsIds') && this.model.get('teamsIds').length) {
        const teamIdList = this.model.get('teamsIds');
        const teamNameHash = this.model.get('teamsNames') || {};
        const teamHtmlList = [];
        teamIdList.forEach(teamId => {
          const teamName = teamNameHash[teamId];
          if (!teamName) {
            return;
          }
          teamHtmlList.push($('<a>').attr('href', '#Team/view/' + teamId).text(teamName).get(0).outerHTML);
        });
        this.messageData['html:target'] = teamHtmlList.join(', ');
        this.createMessage();
        return;
      }
      if (this.model.has('usersIds') && this.model.get('usersIds').length) {
        const userIdList = this.model.get('usersIds');
        const userNameHash = this.model.get('usersNames') || {};
        if (userIdList.length === 1 && userIdList[0] === this.model.get('createdById')) {
          this.messageName = 'mentionYouInPostTargetNoTarget';
          this.createMessage();
          return;
        }
        const userHtmlList = [];
        userIdList.forEach(userId => {
          const userName = userNameHash[userId];
          if (!userName) {
            return;
          }
          userHtmlList.push($('<a>').attr('href', '#User/view/' + userId).text(userName).get(0).outerHTML);
        });
        this.messageData['html:target'] = userHtmlList.join(', ');
        this.createMessage();
        return;
      }
      if (this.model.get('targetType') === 'self') {
        this.messageName = 'mentionYouInPostTargetNoTarget';
      }
      this.createMessage();
    }
  }

  // noinspection JSUnusedGlobalSymbols
  var _default = _exports.default = MentionInPostNoteStreamView;
});

define("views/stream/notes/email-sent", ["exports", "views/stream/notes/email-received"], function (_exports, _emailReceived) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _emailReceived = _interopRequireDefault(_emailReceived);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EmailSentNoteStreamView extends _emailReceived.default {
    isSystemAvatar = false;
    setupEmailMessage(data) {
      this.messageName = 'emailSent';
      this.messageData['by'] = $('<a>').attr('href', `#${data.personEntityType}/view/${data.personEntityId}`).text(data.personEntityName).attr('data-scope', data.personEntityType).attr('data-id', data.personEntityId);
    }
  }
  var _default = _exports.default = EmailSentNoteStreamView;
});

define("views/stream/notes/create", ["exports", "views/stream/note"], function (_exports, _note) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _note = _interopRequireDefault(_note);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/stream/notes/create */

  class CreateNoteStreamView extends _note.default {
    template = 'stream/notes/create';
    assigned = false;
    messageName = 'create';
    isRemovable = false;
    data() {
      return {
        ...super.data(),
        statusText: this.statusText,
        statusStyle: this.statusStyle,
        iconHtml: this.getIconHtml()
      };
    }
    setup() {
      if (this.model.get('data')) {
        this.setupData();
      }
      this.createMessage();
    }

    /**
     * @typedef {{
     *    assignedUserId?: string,
     *     assignedUserName?: string,
     *     assignedUsers?: {id: string, name: string|null}[],
     *     statusField?: string,
     *     statusValue?: string|null,
     *     statusStyle?: string|null,
     * }} module:views/stream/notes/create~data
     */

    setupData() {
      /** @type {module:views/stream/notes/create~data} */
      const data = this.model.get('data') || {};
      this.setupUsersData();
      const parentType = this.model.attributes.parentType;
      if (data.statusValue != null) {
        const statusField = this.statusField = this.getMetadata().get(`scopes.${parentType}.statusField`) ?? '';
        const statusValue = data.statusValue;
        this.statusStyle = this.getMetadata().get(`entityDefs.${parentType}.fields.${statusField}.style.${statusValue}`) || 'default';
        this.statusText = this.getLanguage().translateOption(statusValue, statusField, parentType);
      }
    }
    setupUsersData() {
      /** @type {module:views/stream/notes/create~data} */
      const data = this.model.get('data') || {};
      this.assignedUserId = data.assignedUserId || null;
      this.assignedUserName = data.assignedUserName || data.assignedUserId || null;
      if (data.assignedUsers) {
        if (data.assignedUsers.length === 1) {
          this.assignedUserId = data.assignedUsers[0].id;
          this.assignedUserName = data.assignedUsers[0].name;
        } else if (data.assignedUsers.length > 1) {
          this.setupUsersDataMulti();
          if (this.isThis) {
            this.messageName += 'This';
          }
          return;
        }
      }
      this.messageData['assignee'] = $('<span>').addClass('nowrap name-avatar').append(this.getHelper().getAvatarHtml(this.assignedUserId, 'small', 16, 'avatar-link'), $('<a>').attr('href', `#User/view/${this.assignedUserId}`).text(this.assignedUserName).attr('data-scope', 'User').attr('data-id', this.assignedUserId));
      let isYou = false;
      if (this.isUserStream) {
        if (this.assignedUserId === this.getUser().id) {
          isYou = true;
        }
      }
      if (this.assignedUserId) {
        this.messageName = 'createAssigned';
        if (this.isThis) {
          this.messageName += 'This';
          if (this.assignedUserId === this.model.attributes.createdById) {
            this.messageName += 'Self';
          }
        } else {
          if (this.assignedUserId === this.model.attributes.createdById) {
            this.messageName += 'Self';
          } else if (isYou) {
            this.messageName += 'You';
          }
        }
      }
    }
    setupUsersDataMulti() {
      this.messageName = 'createAssigned';

      /** @type {module:views/stream/notes/create~data} */
      const data = this.model.get('data') || {};
      this.messageData['assignee'] = this.createUsersElement(data.assignedUsers);
    }

    /**
     * @private
     * @param {{id: string, name: ?string}[]} users
     * @return {HTMLElement}
     */
    createUsersElement(users) {
      const wrapper = document.createElement('span');
      users.forEach((it, i) => {
        const a = document.createElement('a');
        a.href = `#User/view/${it.id}`;
        a.text = it.name || it.id;
        a.dataset.id = it.id;
        a.dataset.scope = 'User';
        const span = document.createElement('span');
        span.className = 'nowrap name-avatar';
        span.innerHTML = this.getHelper().getAvatarHtml(it.id, 'small', 16, 'avatar-link');
        span.appendChild(a);
        wrapper.appendChild(span);
        if (i < users.length - 1) {
          wrapper.appendChild(document.createTextNode(', '));
        }
      });
      return wrapper;
    }
  }
  var _default = _exports.default = CreateNoteStreamView;
});

define("views/stream/notes/create-related", ["exports", "views/stream/note"], function (_exports, _note) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _note = _interopRequireDefault(_note);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class CreateRelatedNoteStreamView extends _note.default {
    template = 'stream/notes/create-related';
    messageName = 'createRelated';
    data() {
      return {
        ...super.data(),
        relatedTypeString: this.translateEntityType(this.entityType),
        iconHtml: this.getIconHtml(this.entityType, this.entityId)
      };
    }
    init() {
      if (this.getUser().isAdmin()) {
        this.isRemovable = true;
      }
      super.init();
    }
    setup() {
      const data = this.model.get('data') || {};
      this.entityType = this.model.get('relatedType') || data.entityType || null;
      this.entityId = this.model.get('relatedId') || data.entityId || null;
      this.entityName = this.model.get('relatedName') || data.entityName || null;
      this.messageData['relatedEntityType'] = this.translateEntityType(this.entityType);
      if (this.model.attributes.relatedId) {
        this.messageData['relatedEntity'] = 'field:related';
      } else {
        // bc
        this.messageData['relatedEntity'] = $('<a>').attr('href', `#${this.entityType}/view/${this.entityId}`).text(this.entityName).attr('data-scope', this.entityType).attr('data-id', this.entityId);
      }
      this.createMessage();
    }
  }
  var _default = _exports.default = CreateRelatedNoteStreamView;
});

define("views/stream/notes/assign", ["exports", "views/stream/note"], function (_exports, _note) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _note = _interopRequireDefault(_note);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/stream/notes/assign */

  class AssignNoteStreamView extends _note.default {
    template = 'stream/notes/assign';
    messageName = 'assign';
    init() {
      if (this.getUser().isAdmin()) {
        this.isRemovable = true;
      }
      super.init();
    }
    data() {
      return {
        ...super.data(),
        iconHtml: this.getIconHtml()
      };
    }

    /**
     * @typedef {{
     *    assignedUserId?: string,
     *     assignedUserName?: string,
     *     addedAssignedUsers?: {id: string, name: string|null}[],
     *     removedAssignedUsers?: {id: string, name: string|null}[],
     * }} module:views/stream/notes/assign~data
     */

    setup() {
      this.setupData();
      this.createMessage();
    }
    setupData() {
      /** @type {module:views/stream/notes/assign~data} */
      const data = this.model.get('data') || {};
      this.assignedUserId = data.assignedUserId || null;
      this.assignedUserName = data.assignedUserName || data.assignedUserId || null;
      if (data.addedAssignedUsers) {
        this.setupDataMulti(data);
        if (this.isThis) {
          this.messageName += 'This';
        }
        return;
      }
      this.messageData['assignee'] = $('<span>').addClass('nowrap name-avatar').append(this.getHelper().getAvatarHtml(data.assignedUserId, 'small', 16, 'avatar-link'), $('<a>').attr('href', `#User/view/${data.assignedUserId}`).text(this.assignedUserName).attr('data-scope', 'User').attr('data-id', data.assignedUserId));
      if (this.isUserStream) {
        if (this.assignedUserId) {
          if (this.assignedUserId === this.model.get('createdById')) {
            this.messageName += 'Self';
          } else {
            if (this.assignedUserId === this.getUser().id) {
              this.messageName += 'You';
            }
          }
        } else {
          this.messageName += 'Void';
        }
        return;
      }
      if (this.assignedUserId) {
        if (this.assignedUserId === this.model.get('createdById')) {
          this.messageName += 'Self';
        }
        return;
      }
      this.messageName += 'Void';
    }

    /**
     * @private
     * @param {module:views/stream/notes/assign~data} data
     */
    setupDataMulti(data) {
      this.messageName = 'assignMultiAdd';
      const added = data.addedAssignedUsers;
      const removed = data.removedAssignedUsers;
      if (!added || !removed) {
        return;
      }
      if (added.length && removed.length) {
        this.messageName = 'assignMultiAddRemove';
      } else if (removed.length) {
        this.messageName = 'assignMultiRemove';
      }
      if (added.length) {
        this.messageData['assignee'] = this.createUsersElement(added);
      }
      if (removed.length) {
        this.messageData['removedAssignee'] = this.createUsersElement(removed);
      }
    }

    /**
     * @private
     * @param {{id: string, name: ?string}[]} users
     * @return {HTMLElement}
     */
    createUsersElement(users) {
      const wrapper = document.createElement('span');
      users.forEach((it, i) => {
        const a = document.createElement('a');
        a.href = `#User/view/${it.id}`;
        a.text = it.name || it.id;
        a.dataset.id = it.id;
        a.dataset.scope = 'User';
        const span = document.createElement('span');
        span.className = 'nowrap name-avatar';
        span.innerHTML = this.getHelper().getAvatarHtml(it.id, 'small', 16, 'avatar-link');
        span.appendChild(a);
        wrapper.appendChild(span);
        if (i < users.length - 1) {
          wrapper.appendChild(document.createTextNode(', '));
        }
      });
      return wrapper;
    }
  }
  var _default = _exports.default = AssignNoteStreamView;
});

define("views/stream/modals/create-post", ["exports", "views/modal"], function (_exports, _modal) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class CreatePostModalView extends _modal.default {
    templateContent = `
        <div class="record no-side-margin">{{{record}}}</div>
    `;
    shortcutKeys = {
      'Control+Enter': 'post'
    };
    setup() {
      this.headerText = this.translate('Create Post');
      this.buttonList = [{
        name: 'post',
        label: 'Post',
        style: 'primary',
        title: 'Ctrl+Enter',
        onClick: () => this.post()
      }, {
        name: 'cancel',
        label: 'Cancel',
        title: 'Esc',
        onClick: dialog => {
          dialog.close();
        }
      }];
      this.wait(true);
      this.getModelFactory().create('Note', model => {
        this.createView('record', 'views/stream/record/edit', {
          model: model,
          selector: '.record'
        }, view => {
          this.listenTo(view, 'after:save', () => {
            this.trigger('after:save');
          });
          this.listenTo(view, 'disable-post-button', () => this.disableButton('post'));
          this.listenTo(view, 'enable-post-button', () => this.enableButton('post'));
        });
        this.wait(false);
      });
    }

    /**
     * @return {module:views/record/edit}
     */
    getRecordView() {
      return this.getView('record');
    }
    post() {
      this.getRecordView().save();
    }
  }
  var _default = _exports.default = CreatePostModalView;
});

define("views/stream/fields/post", ["exports", "views/fields/text"], function (_exports, _text) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _text = _interopRequireDefault(_text);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class StreamPostFieldView extends _text.default {
    data() {
      const data = super.data();
      if (this.isDetailMode() || this.isListMode()) {
        data.htmlValue = this.getTransformedValue();
      }
      return data;
    }

    /**
     * @private
     * @return {Handlebars.SafeString|string}
     */
    getTransformedValue() {
      let text = super.getValueForDisplay();
      if (typeof text !== 'string' && !(text instanceof String)) {
        return '';
      }

      /** @type {Record} */
      const data = this.model.attributes.data || {};
      const mentionData = /** @type {Record.<string, {id: string, name: string}>} */
      data.mentions || {};
      const items = Object.keys(mentionData).sort((a, b) => b.length - a.length);
      if (!items.length) {
        return this.getHelper().transformMarkdownText(text);
      }
      items.forEach(item => {
        const name = mentionData[item].name;
        const id = mentionData[item].id;
        const part = `[${name}](#User/view/${id})`;
        text = text.replace(new RegExp(item, 'g'), part);
      });
      let html = this.getHelper().transformMarkdownText(text).toString();
      const body = new DOMParser().parseFromString(html, 'text/html').body;
      items.forEach(item => {
        const id = mentionData[item].id;
        const url = `#User/view/${id}`;
        const avatarHtml = this.getHelper().getAvatarHtml(id, 'small', 16, 'avatar-link');
        if (!avatarHtml) {
          return;
        }
        const img = new DOMParser().parseFromString(avatarHtml, 'text/html').body.childNodes[0];
        body.querySelectorAll(`a[href="${url}"]`).forEach(a => {
          if (id === this.getUser().id) {
            a.classList.add('text-warning');
          } else {
            a.classList.add('text-default');
          }
          const span = document.createElement('span');
          span.classList.add('nowrap', 'name-avatar');
          span.append(img.cloneNode());
          a.parentNode.replaceChild(span, a);
          span.append(a);
        });
      });
      html = body.innerHTML;
      return html;
    }
  }
  _exports.default = StreamPostFieldView;
});

define("views/stream/fields/attachment-multiple", ["exports", "views/fields/attachment-multiple"], function (_exports, _attachmentMultiple) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _attachmentMultiple = _interopRequireDefault(_attachmentMultiple);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _attachmentMultiple.default {
    showPreviews = true;
    showPreviewsInListMode = true;
  }
  _exports.default = _default;
});

define("views/site-portal/navbar", ["exports", "views/site/navbar"], function (_exports, _navbar) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _navbar = _interopRequireDefault(_navbar);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _navbar.default {
    getLogoSrc() {
      const companyLogoId = this.getConfig().get('companyLogoId');
      if (!companyLogoId) {
        return this.getBasePath() + (this.getThemeManager().getParam('logo') || 'client/img/logo.svg');
      }
      return `${this.getBasePath()}?entryPoint=LogoImage&id=${companyLogoId}&t=${companyLogoId}`;
    }
    getTabList() {
      const tabList = [...(this.getConfig().get('tabList') || [])];
      if (this.getThemeManager().getParam('navbarIsVertical') || tabList.length) {
        tabList.unshift('Home');
      }
      return tabList;
    }
  }
  _exports.default = _default;
});

define("views/site-portal/master", ["exports", "views/site/master"], function (_exports, _master) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _master = _interopRequireDefault(_master);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _master.default {
    views = {
      header: {
        id: 'header',
        view: 'views/site-portal/header'
      },
      main: {
        id: 'main',
        view: false
      },
      footer: {
        fullSelector: 'body > footer',
        view: 'views/site/footer'
      }
    };
    afterRender() {
      super.afterRender();
      this.element.querySelector('#main').classList.add('main-portal');

      //this.$el.find('#main').addClass('main-portal');
    }
  }
  _exports.default = _default;
});

define("views/site-portal/header", ["exports", "views/site/header"], function (_exports, _header) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _header = _interopRequireDefault(_header);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _header.default {
    navbarView = 'views/site-portal/navbar';
    customViewPath = ['clientDefs', 'App', 'portalNavbarView'];
  }
  _exports.default = _default;
});

define("views/site/footer", ["exports", "view"], function (_exports, _view) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class FooterSiteView extends _view.default {
    template = 'site/footer';
  }
  var _default = _exports.default = FooterSiteView;
});

define("views/site/navbar/quick-create", ["exports", "view", "helpers/record-modal"], function (_exports, _view, _recordModal) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  _recordModal = _interopRequireDefault(_recordModal);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class QuickCreateNavbarView extends _view.default {
    // language=Handlebars
    templateContent = `
        <a
            id="nav-quick-create-dropdown"
            class="dropdown-toggle"
            data-toggle="dropdown"
            role="button"
            tabindex="0"
            title="{{translate 'Create'}}"
        ><i class="fas fa-plus icon"></i></a>
        <ul class="dropdown-menu" role="menu" aria-labelledby="nav-quick-create-dropdown">
            <li class="dropdown-header">{{translate 'Create'}}</li>
            {{#each list}}
                <li><a
                    href="#{{name}}/create"
                    data-name="{{name}}"
                    data-action="quickCreate"
                >
                    {{~#if iconClass~}}
                        <span
                            class="item-icon {{iconClass}}"
                            style="{{#if color}}color: {{color}};{{/if}}"
                        ></span>
                    {{~/if~}}
                    <span class="item-text">{{translate name category='scopeNames'}}</span>
                    {{~null~}}
                </a></li>
            {{/each}}
        </ul>
    `;
    data() {
      return {
        list: this.list.map(it => {
          return {
            name: it,
            iconClass: this.getMetadata().get(`clientDefs.${it}.iconClass`),
            color: this.getMetadata().get(`clientDefs.${it}.color`)
          };
        })
      };
    }
    setup() {
      this.addActionHandler('quickCreate', (e, element) => {
        e.preventDefault();
        this.processCreate(element.dataset.name);
      });
      const scopes = this.getMetadata().get('scopes') || {};

      /** @type {string[]} */
      const list = this.getConfig().get('quickCreateList') || [];
      this.list = list.filter(scope => {
        if (!scopes[scope]) {
          return false;
        }
        if ((scopes[scope] || {}).disabled) {
          return;
        }
        if ((scopes[scope] || {}).acl) {
          return this.getAcl().check(scope, 'create');
        }
        return true;
      });
    }
    isAvailable() {
      return this.list.length > 0;
    }

    /**
     * @private
     * @param {string} scope
     */
    async processCreate(scope) {
      Espo.Ui.notifyWait();
      const type = this.getMetadata().get(`clientDefs.${scope}.quickCreateModalType`);
      if (type) {
        const viewName = this.getMetadata().get(`clientDefs.${scope}.modalViews.${type}`);
        if (viewName) {
          const view = await this.createView('modal', viewName, {
            scope: scope
          });
          await view.render();
          Espo.Ui.notify();
          return;
        }
      }
      const helper = new _recordModal.default();
      await helper.showCreate(this, {
        entityType: scope
      });
    }
  }
  var _default = _exports.default = QuickCreateNavbarView;
});

define("views/site/navbar/last-viewed", ["exports", "views/site/navbar/item", "view", "views/record/list", "helpers/site/window-panel-helper"], function (_exports, _item, _view, _list, _windowPanelHelper) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _item = _interopRequireDefault(_item);
  _view = _interopRequireDefault(_view);
  _list = _interopRequireDefault(_list);
  _windowPanelHelper = _interopRequireDefault(_windowPanelHelper);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  // noinspection JSUnusedGlobalSymbols
  class LastViewedSiteNavbarItemView extends _item.default {
    // language=Handlebars
    templateContent = `
        <a
            role="button"
            tabindex="0"
            data-action="showLastViewed"
            title="{{translate 'LastViewed' category='scopeNamesPlural'}}"
        ><span class="fas fa-clock-rotate-left fa-sm icon"></span></a>
        <div class="last-viewed-panel-container"></div>
    `;

    /**
     * @private
     * @type {HTMLDivElement|null}
     */
    panelElement = null;
    isAvailable() {
      return !this.getConfig().get('actionHistoryDisabled');
    }
    setup() {
      this.addActionHandler('showLastViewed', () => this.showPanel());
      this.onMouseUpBind = this.onMouseUp.bind(this);
      this.onClickBind = this.onClick.bind(this);
    }

    /**
     * @private
     */
    async showPanel() {
      const container = this.element.querySelector('.last-viewed-panel-container');
      if (!(container instanceof HTMLDivElement)) {
        this.panelElement = null;
        throw Error("No last-viewed-panel-container container.");
      }
      const panel = document.createElement('div');
      panel.id = 'last-viewed-panel';
      this.panelElement = panel;
      container.append(panel);
      const view = new PanelView({
        onClose: () => this.closePanel()
      });
      await this.assignView('panel', view, '#last-viewed-panel');
      await view.render();
      new _windowPanelHelper.default(view);
      document.addEventListener('mouseup', this.onMouseUpBind);
      document.addEventListener('click', this.onClickBind);
      this.element.classList.add('open');
      await view.processFetch();
    }

    /**
     * @private
     */
    closePanel() {
      var _this$panelElement;
      if (this.hasView('panel')) {
        this.getView('panel').remove();
      }
      this.element.classList.remove('open');
      (_this$panelElement = this.panelElement) === null || _this$panelElement === void 0 || (_this$panelElement = _this$panelElement.parentElement) === null || _this$panelElement === void 0 || _this$panelElement.removeChild(this.panelElement);
      document.removeEventListener('mouseup', this.onMouseUpBind);
      document.removeEventListener('click', this.onClickBind);
    }

    /**
     * @param {MouseEvent} e
     * @private
     */
    onMouseUp(e) {
      if (e.button !== 0) {
        return;
      }
      const target = e.target;
      if (!(target instanceof HTMLElement)) {
        return;
      }
      if (this.panelElement === target || this.panelElement.contains(target) || target.classList.contains('modal') || target.closest('.dialog.modal')) {
        return;
      }
      return this.closePanel();
    }

    /**
     * @param {MouseEvent} e
     * @private
     */
    onClick(e) {
      const target = e.target;
      if (!(target instanceof HTMLAnchorElement)) {
        return;
      }
      if (target.dataset.action === 'showMore' || target.dataset.action === 'showLastViewed') {
        return;
      }
      setTimeout(() => this.closePanel(), 100);
    }
  }
  _exports.default = LastViewedSiteNavbarItemView;
  class PanelView extends _view.default {
    // language=Handlebars
    templateContent = `
        <div class="panel panel-default">
            <div class="panel-heading panel-heading-no-title">
            <div class="link-group">
                <a
                    role="button"
                    tabindex="0"
                    class="close-link"
                    data-action="closePanel"
                ><span class="fas fa-times"></span></a>
            </div>
            <a
                href="#LastViewed"
                class="text-solid"
            >{{translate 'LastViewed' category='scopeNamesPlural'}}</a>
            </div>
            <div class="panel-body">
                <div class="list-container">
                    <span class="text-soft fas fa-spinner fa-spin"></span>
                </div>
            </div>
        </div>
    `;

    /**
     *
     * @param {{
     *     onClose: function(),
     * }} options
     */
    constructor(options) {
      super(options);
      this.options = options;
    }
    setup() {
      this.addActionHandler('closePanel', () => this.options.onClose());
      this.once('remove', () => {});
    }
    onRemove() {
      var _this$collection;
      (_this$collection = this.collection) === null || _this$collection === void 0 || _this$collection.abortLastFetch();
    }
    async processFetch() {
      const collection = await this.getCollectionFactory().create('ActionHistoryRecord');
      collection.maxSize = this.getConfig().get('globalSearchMaxSize') ?? 10;
      collection.url = 'LastViewed';
      this.collection = collection;
      await collection.fetch();
      const view = new _list.default({
        collection: collection,
        fullSelector: this.containerSelector + ' .list-container',
        selectable: false,
        checkboxes: false,
        massActionsDisabled: true,
        rowActionsView: false,
        checkAllResultDisabled: true,
        buttonsDisabled: true,
        headerDisabled: true,
        layoutName: 'listForLastViewed',
        layoutAclDisabled: true
      });
      await this.assignView('list', view, '.list-container');
      await view.render();
    }
  }
});

define("views/record/panel-actions", ["exports", "view"], function (_exports, _view) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class PanelActionsView extends _view.default {
    template = 'record/panel-actions';
    data() {
      return {
        defs: this.options.defs,
        buttonList: this.getButtonList(),
        actionList: this.getActionList(),
        entityType: this.options.entityType,
        scope: this.options.scope
      };
    }
    setup() {
      this.buttonList = this.options.defs.buttonList || [];
      this.actionList = this.options.defs.actionList || [];
      this.defs = this.options.defs;
    }
    getButtonList() {
      const list = [];
      this.buttonList.forEach(item => {
        if (item.hidden) {
          return;
        }
        list.push(item);
      });
      return list;
    }
    getActionList() {
      return this.actionList.filter(item => !item.hidden).map(item => {
        item = Espo.Utils.clone(item);
        if (item.action) {
          item.data = Espo.Utils.clone(item.data || {});
          item.data.panel = this.options.defs.name;
        }
        return item;
      });
    }
  }
  var _default = _exports.default = PanelActionsView;
});

define("views/record/merge", ["exports", "view", "jquery"], function (_exports, _view, _jquery) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  _jquery = _interopRequireDefault(_jquery);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class MergeRecordView extends _view.default {
    template = 'record/merge';
    scope = '';
    events = {
      /** @this MergeRecordView */
      'change input[type="radio"][name="check-all"]': function (e) {
        e.stopPropagation();
        const id = e.currentTarget.value;
        (0, _jquery.default)('input[data-id="' + id + '"]').prop('checked', true);
      },
      /** @this MergeRecordView */
      'click button[data-action="cancel"]': function () {
        this.getRouter().navigate('#' + this.scope, {
          trigger: true
        });
      },
      /** @this MergeRecordView */
      'click button[data-action="merge"]': function () {
        const id = (0, _jquery.default)('input[type="radio"][name="check-all"]:checked').val();
        let model;
        this.models.forEach(m => {
          if (m.id === id) {
            model = m;
          }
        });
        const attributes = {};
        (0, _jquery.default)('input.field-radio:checked').each((i, el) => {
          const field = el.name;
          const id = (0, _jquery.default)(el).attr('data-id');
          if (model.id === id) {
            return;
          }
          const fieldType = model.getFieldParam(field, 'type');
          const fields = this.getFieldManager().getActualAttributeList(fieldType, field);
          let modelFrom;
          this.models.forEach(itemModel => {
            if (itemModel.id === id) {
              modelFrom = itemModel;
            }
          });
          fields.forEach(field => {
            attributes[field] = modelFrom.get(field);
          });
        });
        Espo.Ui.notifyWait();
        const sourceIdList = this.models.filter(m => m.id !== model.id).map(m => m.id);
        Espo.Ajax.postRequest('Action', {
          entityType: this.scope,
          action: 'merge',
          id: model.id,
          data: {
            sourceIdList: sourceIdList,
            attributes: attributes
          }
        }).then(() => {
          Espo.Ui.success(this.translate('Merged'), {
            suppress: true
          });
          this.getRouter().navigate('#' + this.scope + '/view/' + model.id, {
            trigger: true
          });
          if (this.collection) {
            this.collection.fetch();
          }
        });
      }
    };
    data() {
      const rows = [];
      this.fields.forEach(field => {
        const o = {
          name: field,
          scope: this.scope
        };
        o.columns = [];
        this.models.forEach(model => {
          o.columns.push({
            id: model.id,
            fieldVariable: model.id + '-' + field,
            isReadOnly: this.readOnlyFields[field] || false
          });
        });
        rows.push(o);
      });
      return {
        rows: rows,
        modelList: this.models,
        scope: this.scope,
        hasCreatedAt: this.hasCreatedAt,
        width: Math.round((80 - this.models.length * 5) / this.models.length * 10) / 10,
        dataList: this.getDataList()
      };
    }
    afterRender() {
      (0, _jquery.default)('input[data-id="' + this.models[0].id + '"]').prop('checked', true);
    }
    setup() {
      this.scope = this.options.models[0].name;
      this.models = this.options.models;
      const fieldManager = this.getFieldManager();
      let differentFieldList = [];
      const fieldsDefs = this.models[0].defs.fields;
      this.readOnlyFields = {};
      for (const field in fieldsDefs) {
        const type = fieldsDefs[field].type;
        if (type === 'linkMultiple') {
          continue;
        }
        if (fieldsDefs[field].disabled || fieldsDefs[field].utility || fieldsDefs[field].mergeDisabled) {
          continue;
        }
        if (field === 'createdAt' || field === 'modifiedAt') {
          continue;
        }
        if (fieldManager.isMergeable(type)) {
          const actualAttributeList = fieldManager.getActualAttributeList(type, field);
          let differs = false;
          actualAttributeList.forEach(field => {
            const values = [];
            this.models.forEach(model => {
              values.push(model.get(field));
            });
            const firstValue = values[0];
            values.forEach(value => {
              if (!_.isEqual(firstValue, value)) {
                differs = true;
              }
            });
          });
          if (differs) {
            differentFieldList.push(field);
            if (this.models[0].isFieldReadOnly(field)) {
              this.readOnlyFields[field] = true;
            }
          }
        }
      }
      differentFieldList.sort((v1, v2) => {
        return this.translate(v1, 'fields', this.scope).localeCompare(this.translate(v2, 'fields', this.scope));
      });
      differentFieldList = differentFieldList.sort((v1, v2) => {
        if (!this.readOnlyFields[v1] && this.readOnlyFields[v2]) {
          return -1;
        }
        return 1;
      });
      this.fields = differentFieldList;
      this.fields.forEach(field => {
        const type = this.models[0].getFieldParam(field, 'type');
        this.models.forEach(model => {
          const viewName = model.getFieldParam(field, 'view') || this.getFieldManager().getViewName(type);
          this.createView(model.id + '-' + field, viewName, {
            model: model,
            fullSelector: '.merge [data-id="' + model.id + '"] .field[data-name="' + field + '"]',
            defs: {
              name: field
            },
            mode: 'detail',
            readOnly: true
          });
        });
      });
      this.hasCreatedAt = this.getMetadata().get(['entityDefs', this.scope, 'fields', 'createdAt']);
      if (this.hasCreatedAt) {
        this.models.forEach(model => {
          this.createView(model.id + '-' + 'createdAt', 'views/fields/datetime', {
            model: model,
            fullSelector: '.merge [data-id="' + model.id + '"] .field[data-name="createdAt"]',
            defs: {
              name: 'createdAt'
            },
            mode: 'detail',
            readOnly: true
          });
        });
      }
    }
    getDataList() {
      const dataList = [];
      this.models.forEach(model => {
        const o = {};
        o.id = model.id;
        o.name = model.get('name');
        o.createdAtViewName = model.id + '-' + 'createdAt';
        dataList.push(o);
      });
      return dataList;
    }
  }
  var _default = _exports.default = MergeRecordView;
});

define("views/record/list-tree", ["exports", "views/record/list", "helpers/record-modal", "helpers/list/misc/list-tree-draggable"], function (_exports, _list, _recordModal, _listTreeDraggable) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _list = _interopRequireDefault(_list);
  _recordModal = _interopRequireDefault(_recordModal);
  _listTreeDraggable = _interopRequireDefault(_listTreeDraggable);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/record/list-tree */

  class ListTreeRecordView extends _list.default {
    template = 'record/list-tree';
    showMore = false;
    showCount = false;
    checkboxes = false;
    rowActionsView = false;
    header = false;
    listContainerEl = ' > .list > ul';
    checkAllResultDisabled = true;
    showRoot = false;
    massActionList = ['remove'];
    selectable = false;
    createDisabled = false;
    selectedData = null;
    level = 0;
    itemViewName = 'views/record/list-tree-item';

    /**
     * @protected
     * @type {boolean}
     */
    readOnly;
    expandToggleInactive = false;

    /**
     * @private
     * @type {ListTreeRecordView}
     */
    rootView;

    /**
     * @type {string|null}
     */
    movedId = null;

    /**
     * @private
     * @type {boolean}
     */
    moveSupported;

    /**
     * @private
     * @type {ListTreeDraggableHelper}
     */
    draggableHelper;

    // noinspection JSCheckFunctionSignatures
    data() {
      const data = super.data();
      data.createDisabled = this.createDisabled;
      data.showRoot = this.showRoot;
      if (data.showRoot) {
        data.rootName = this.rootName || this.translate('Top Level');
      }
      if (this.level === 0 && this.selectable && (this.selectedData || {}).id === null) {
        data.rootIsSelected = true;
      }
      if (this.level === 0) {
        data.isExpanded = this.isExpanded;
      }
      data.noData = data.createDisabled && !data.rowDataList.length && !data.showRoot;
      data.expandToggleInactive = this.expandToggleInactive;
      data.hasExpandToggle = !this.getUser().isPortal();
      data.isEditable = this.level === 0 && !this.readOnly;
      return data;
    }
    setup() {
      if ('selectable' in this.options) {
        this.selectable = this.options.selectable;
      }
      this.readOnly = this.options.readOnly;
      this.createDisabled = this.readOnly || this.options.createDisabled || this.createDisabled;
      this.isExpanded = this.options.isExpanded;
      if ('showRoot' in this.options) {
        this.showRoot = this.options.showRoot;
        if ('rootName' in this.options) {
          this.rootName = this.options.rootName;
        }
      }
      if ('level' in this.options) {
        this.level = this.options.level;
      }
      this.rootView = this.options.rootView || this;
      if (this.level === 0) {
        this.selectedData = {
          id: null,
          path: [],
          names: {}
        };
      }
      if ('selectedData' in this.options) {
        this.selectedData = this.options.selectedData;
      }
      this.entityType = this.collection.entityType;
      this.moveSupported = !!this.getMetadata().get(`entityDefs.${this.entityType}.fields.order`);
      super.setup();
      if (this.selectable) {
        this.on('select', o => {
          if (o.id) {
            this.$el.find('a.link[data-id="' + o.id + '"]').addClass('text-bold');
            if (this.level === 0) {
              this.$el.find('a.link').removeClass('text-bold');
              this.$el.find('a.link[data-id="' + o.id + '"]').addClass('text-bold');
              this.setSelected(o.id);
              o.selectedData = this.selectedData;
            }
          }
          if (this.level > 0) {
            this.getParentView().trigger('select', o);
          }
        });
      }
      if (this.level === 0) {
        this.once('after:render', () => {
          const collection = /** @type {import('collections/tree').default} */this.collection;
          if (collection.openPath) {
            /**
             * @param {ListTreeRecordView} view
             * @param {string[]} path
             */
            const open = async (view, path) => {
              path = [...path];
              const id = path.shift();
              const itemView = view.getItemViews().find(view => view.model.id === id);
              if (!itemView) {
                return;
              }
              await itemView.unfold();
              if (!path.length) {
                return;
              }
              await open(itemView.getChildrenView(), path);
            };
            open(this, collection.openPath);
            collection.openPath = null;
          }
        });
      }
      this.listenTo(this.collection, 'model-sync', (/** import('model').default */m, /** Record */o) => {
        if (o.action === 'destroy') {
          const index = this.rowList.findIndex(it => it === m.id);
          if (index > -1) {
            this.rowList.splice(index, 1);
          }
        }
      });
    }
    onRemove() {
      super.onRemove();
      if (this.draggableHelper) {
        this.draggableHelper.destroy();
      }
    }
    afterRender() {
      super.afterRender();
      if (this.level === 0 && !this.readOnly && this.moveSupported) {
        this.initDraggableRoot();
      }
    }

    /**
     * @param {string|null} id
     */
    setSelected(id) {
      if (id === null) {
        this.selectedData.id = null;
      } else {
        this.selectedData.id = id;
      }
      this.rowList.forEach(key => {
        const view = /** @type module:views/record/list-tree-item */this.getView(key);
        if (view.model.id === id) {
          view.setIsSelected();
        } else {
          view.isSelected = false;
        }
        if (view.hasView('children')) {
          view.getChildrenView().setSelected(id);
        }
      });
    }

    /**
     * @return {import('views/record/list-tree-item').default[]}
     */
    getItemViews() {
      return this.rowList.map(key => this.getView(key));
    }
    buildRows(callback) {
      this.checkedList = [];
      this.rowList = [];
      if (this.collection.length > 0) {
        this.wait(true);
        const modelList = this.collection.models;
        const count = modelList.length;
        let built = 0;
        modelList.forEach(model => {
          const key = model.id;
          this.rowList.push(key);
          this.createView(key, this.itemViewName, {
            model: model,
            collection: this.collection,
            selector: this.getRowSelector(model.id),
            createDisabled: this.createDisabled,
            readOnly: this.readOnly,
            level: this.level,
            isSelected: model.id === this.selectedData.id,
            selectedData: this.selectedData,
            selectable: this.selectable,
            setViewBeforeCallback: this.options.skipBuildRows && !this.isRendered(),
            rootView: this.rootView,
            moveSupported: this.moveSupported
          }, () => {
            built++;
            if (built === count) {
              if (typeof callback === 'function') {
                callback();
              }
              this.wait(false);
            }
          });
        });
        return;
      }
      if (typeof callback === 'function') {
        callback();
      }
    }
    getRowSelector(id) {
      return 'li[data-id="' + id + '"]';
    }
    getCellSelector(model, item) {
      return `${this.getSelector() + this.getRowSelector(model.id)} span.cell[data-name="${item.name}"]`;
    }
    getCreateAttributes() {
      return {};
    }

    // noinspection JSUnusedGlobalSymbols
    actionCreate(data, e) {
      e.stopPropagation();
      const attributes = this.getCreateAttributes();
      let maxOrder = 0;
      this.collection.models.forEach(m => {
        if (m.get('order') > maxOrder) {
          maxOrder = m.get('order');
        }
      });
      attributes.order = maxOrder + 1;
      attributes.parentId = null;
      attributes.parentName = null;
      if (this.model) {
        attributes.parentId = this.model.id;
        attributes.parentName = this.model.attributes.name;
      }
      const helper = new _recordModal.default();
      helper.showCreate(this, {
        entityType: this.entityType,
        attributes: attributes,
        afterSave: model => {
          const collection = /** @type {import('collections/tree').default} collection */
          this.collection;
          model.set('childCollection', collection.createSeed());
          if (model.attributes.parentId !== attributes.parentId) {
            let v = this;
            while (1) {
              if (v.level) {
                v = v.getParentView().getParentView();
              } else {
                break;
              }
            }
            v.collection.fetch();
            return;
          }
          this.collection.fetch();
        }
      });
    }

    // noinspection JSUnusedGlobalSymbols
    actionSelectRoot() {
      this.trigger('select', {
        id: null
      });
      if (this.selectable) {
        this.$el.find('a.link').removeClass('text-bold');
        this.$el.find('a.link[data-action="selectRoot"]').addClass('text-bold');
        this.setSelected(null);
      }
    }

    /**
     * @private
     */
    initDraggableRoot() {
      if (!this.draggableHelper) {
        this.draggableHelper = new _listTreeDraggable.default(this);
      }
      this.draggableHelper.init();
    }
  }
  var _default = _exports.default = ListTreeRecordView;
});

define("views/record/list-tree-item", ["exports", "view"], function (_exports, _view) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/record/list-tree-item */

  class ListTreeRecordItemView extends _view.default {
    template = 'record/list-tree-item';
    isEnd = false;
    level = 0;
    listViewName = 'views/record/list-tree';

    /**
     * @private
     * @type {import('views/record/list-tree').default}
     */
    rootView;

    /**
     * @type {boolean}
     */
    isUnfolded = false;
    data() {
      return {
        name: this.model.attributes.name,
        isUnfolded: this.isUnfolded,
        showFold: this.isUnfolded && !this.isEnd,
        showUnfold: !this.isUnfolded && !this.isEnd,
        isEnd: this.isEnd,
        isSelected: this.isSelected,
        readOnly: this.readOnly,
        isMovable: this.options.moveSupported && !this.options.readOnly
      };
    }

    /**
     * @param {{
     *     moveSupported: boolean,
     *     readOnly: boolean,
     *     isSelected?: boolean,
     *     level?: number,
     *     selectedData?: {path: string, name: Record},
     *     rootView: import('views/record/list-tree').default,
     *     selectable?: boolean,
     *     createDisabled?: boolean,
     * }} options
     */
    constructor(options) {
      super(options);
      this.options = options;
    }
    setIsSelected() {
      this.isSelected = true;
      this.selectedData.id = this.model.id;
      const path = this.selectedData.path;
      const names = this.selectedData.names;
      path.length = 0;
      let view = this;
      while (1) {
        path.unshift(view.model.id);
        names[view.model.id] = view.model.attributes.name;
        if (view.getParentListView().level) {
          view = view.getParentView().getParentView();
        } else {
          break;
        }
      }
    }
    setup() {
      this.addActionHandler('unfold', e => {
        this.unfold();
        e.stopPropagation();
      });
      this.addActionHandler('fold', e => {
        this.fold();
        e.stopPropagation();
      });
      this.addActionHandler('remove', e => {
        this.actionRemove();
        e.stopPropagation();
      });
      if ('level' in this.options) {
        this.level = this.options.level;
      }
      if ('isSelected' in this.options) {
        this.isSelected = this.options.isSelected;
      }
      if ('selectedData' in this.options) {
        this.selectedData = this.options.selectedData;
      }
      this.readOnly = this.options.readOnly;
      if ('createDisabled' in this.options) {
        this.createDisabled = this.options.createDisabled;
      }
      if (this.readOnly) {
        this.createDisabled = true;
      }
      this.rootView = this.options.rootView;
      this.scope = this.model.entityType;
      this.isUnfolded = false;
      const childCollection = this.model.get('childCollection');
      if (childCollection && childCollection.length === 0 || this.model.isEnd) {
        if (this.createDisabled) {
          this.isEnd = true;
        }
      } else if (childCollection) {
        childCollection.models.forEach(model => {
          if (~this.selectedData.path.indexOf(model.id)) {
            this.isUnfolded = true;
          }
        });
        if (this.isUnfolded) {
          this.createChildren();
        }
      }
      this.on('select', o => {
        this.getParentListView().trigger('select', o);
      });
    }

    /**
     * @return {module:views/record/list-tree}
     */
    getParentListView() {
      return /** @type module:views/record/list-tree */this.getParentView();
    }

    /**
     * @private
     */
    createChildren() {
      const childCollection = this.model.get('childCollection');
      let callback = null;
      if (this.isRendered()) {
        callback = view => {
          this.listenToOnce(view, 'after:render', () => {
            this.trigger('children-created');
          });
          view.render();
        };
      }
      this.createView('children', this.listViewName, {
        collection: childCollection,
        selector: '> .children',
        createDisabled: this.options.createDisabled,
        readOnly: this.options.readOnly,
        level: this.level + 1,
        selectedData: this.selectedData,
        model: this.model,
        selectable: this.options.selectable,
        rootView: this.rootView
      }, callback);
    }

    /**
     * @private
     */
    checkLastChildren() {
      Espo.Ajax.getRequest(`${this.collection.entityType}/action/lastChildrenIdList`, {
        parentId: this.model.id
      }).then(idList => {
        const childrenView = this.getChildrenView();
        if (!childrenView) {
          return;
        }
        idList.forEach(id => {
          const model = this.model.get('childCollection').get(id);
          if (model) {
            model.isEnd = true;
          }

          /** @type {ListTreeRecordItemView|null} */
          const itemView = childrenView.getView(id);
          if (!itemView) {
            return;
          }
          itemView.isEnd = true;
          itemView.afterIsEnd();
        });

        // @todo Refactor.
        this.model.lastAreChecked = true;
      });
    }

    /**
     * Unfold.
     */
    async unfold() {
      if (this.createDisabled) {
        this.once('children-created', () => {
          if (!this.model.lastAreChecked) {
            this.checkLastChildren();
          }
        });
      }
      const childCollection = this.model.get('childCollection');
      if (childCollection != null) {
        this.createChildren();
        this.isUnfolded = true;
        this.afterUnfold();
        this.trigger('after:unfold');
        return;
      }
      const collection = await this.getCollectionFactory().create(this.scope);
      collection.url = this.collection.url;
      collection.parentId = this.model.id;
      Espo.Ui.notifyWait();
      this.listenToOnce(collection, 'sync', () => {
        Espo.Ui.notify(false);
        this.model.set('childCollection', collection);
        this.createChildren();
        this.isUnfolded = true;
        if (collection.length || !this.createDisabled) {
          this.afterUnfold();
          this.trigger('after:unfold');
        } else {
          this.isEnd = true;
          this.afterIsEnd();
        }
      });
      await collection.fetch();
    }
    fold() {
      this.clearView('children');
      this.isUnfolded = false;
      this.afterFold();
    }
    afterRender() {
      if (this.isUnfolded) {
        this.afterUnfold();
      } else {
        this.afterFold();
      }
      if (this.isEnd) {
        this.afterIsEnd();
      }
      if (!this.readOnly) {
        const $remove = this.$el.find('> .cell [data-action="remove"]');
        this.$el.find('> .cell').on('mouseenter', () => {
          if (this.rootView.movedId) {
            return;
          }
          $remove.removeClass('hidden');
        });
        this.$el.find('> .cell').on('mouseleave', () => {
          $remove.addClass('hidden');
        });
      }
    }

    /**
     * @private
     */
    afterFold() {
      this.$el.find('a[data-action="fold"][data-id="' + this.model.id + '"]').addClass('hidden');
      this.$el.find('a[data-action="unfold"][data-id="' + this.model.id + '"]').removeClass('hidden');
      this.$el.find(' > .children').addClass('hidden');
    }

    /**
     * @private
     */
    afterUnfold() {
      this.$el.find('a[data-action="unfold"][data-id="' + this.model.id + '"]').addClass('hidden');
      this.$el.find('a[data-action="fold"][data-id="' + this.model.id + '"]').removeClass('hidden');
      this.$el.find(' > .children').removeClass('hidden');
    }
    afterIsEnd() {
      this.$el.find('a[data-action="unfold"][data-id="' + this.model.id + '"]').addClass('hidden');
      this.$el.find('a[data-action="fold"][data-id="' + this.model.id + '"]').addClass('hidden');
      this.$el.find('span[data-name="white-space"][data-id="' + this.model.id + '"]').removeClass('hidden');
      this.$el.find(' > .children').addClass('hidden');
    }

    /*getCurrentPath() {
        let pointer = this;
        const path = [];
          while (true) {
            path.unshift(pointer.model.id);
              if (pointer.getParentView() === this.rootView) {
                break;
            }
              pointer = pointer.getParentView().getParentView();
        }
          return path;
    }*/

    /**
     * @private
     */
    async actionRemove() {
      await this.confirm({
        message: this.translate('removeRecordConfirmation', 'messages', this.scope),
        confirmText: this.translate('Remove')
      });
      await this.model.destroy({
        wait: true
      });
      this.remove();
    }

    /**
     * @return {module:views/record/list-tree}
     */
    getChildrenView() {
      return /** @type module:views/record/list-tree */this.getView('children');
    }
  }
  var _default = _exports.default = ListTreeRecordItemView;
});

define("views/record/list-pagination", ["exports", "view"], function (_exports, _view) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class RecordListPagination extends _view.default {
    template = 'record/list-pagination';
    isStandaloneComponent = true;
    data() {
      const total = this.collection.total;
      const offset = this.collection.offset;
      const length = this.collection.length;
      const next = this.collection.hasNextPage();
      const last = next && total >= 0;
      const from = offset + 1;
      const to = offset + length;
      const currentPageNumber = this.getCurrentPageNumber();
      const lastPageNumber = this.getLastPageNumber();
      const noTotal = !this.displayTotalCount || total < 0;
      return {
        hasGoToPage: lastPageNumber > 1 || total < 0,
        currentPageNumber: currentPageNumber,
        lastPageNumber: lastPageNumber,
        hasLastPageNumber: lastPageNumber > 1,
        total: this.getHelper().numberUtil.formatInt(total),
        from: this.getHelper().numberUtil.formatInt(from),
        to: this.getHelper().numberUtil.formatInt(to),
        previous: this.collection.hasPreviousPage(),
        next: next,
        last: last,
        noTotal: noTotal,
        noData: to === 0
      };
    }
    setup() {
      this.recordView = /** @type {import('views/record/list').default} */this.options.recordView;
      this.listenTo(this.collection, 'update', () => {
        if (!this.element) {
          // A hack. Prevents warnings in console.
          return;
        }
        this.reRender();
      });
      this.addHandler('change', 'input.page-input', (e, /** HTMLInputElement */input) => {
        if (input.value === '') {
          input.value = this.getCurrentPageNumber();
          return;
        }
        const result = this.goToNumber(parseInt(input.value));
        if (!result) {
          input.value = this.getCurrentPageNumber();
        }
      });
      this.addHandler('focus', 'input.page-input', (e, /** HTMLInputElement */input) => {
        input.select();
      });
      this.addHandler('input', 'input.page-input', (e, /** HTMLInputElement */input) => {
        input.value = input.value.replace(/[^0-9.]/g, '');
      });
      this.addHandler('click', '.page-input-group > .input-group-addon', e => {
        e.preventDefault();
        e.stopImmediatePropagation();
      });
      this.displayTotalCount = this.options.displayTotalCount;
    }

    /**
     * @return {number|null}
     */
    getCurrentPageNumber() {
      return Math.floor(this.collection.offset / this.collection.maxSize) + 1;
    }

    /**
     * @return {number|null}
     */
    getLastPageNumber() {
      return this.collection.total >= 0 ? Math.floor(this.collection.total / this.collection.maxSize) + 1 : null;
    }

    /**
     * @param {Number} number
     * @return {Promise|null}
     */
    goToNumber(number) {
      const offset = (number - 1) * this.collection.maxSize;
      if (this.collection.total >= 0 && offset > this.collection.total) {
        Espo.Ui.warning(this.translate('pageNumberIsOutOfBound', 'messages'));
        return null;
      }
      Espo.Ui.notifyWait();
      return this.collection.setOffset(offset).then(() => {
        Espo.Ui.notify(false);
        this.recordView.trigger('after:paginate');
      });
    }
  }
  var _default = _exports.default = RecordListPagination;
});

define("views/record/list-nested-categories", ["exports", "view", "helpers/record-modal"], function (_exports, _view, _recordModal) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  _recordModal = _interopRequireDefault(_recordModal);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/record/list-nested-categories */

  class ListNestedCategoriesRecordView extends _view.default {
    template = 'record/list-nested-categories';
    isLoading = false;
    events = {
      'click .action': function (e) {
        Espo.Utils.handleAction(this, e.originalEvent, e.currentTarget);
      }
    };

    /**
     * @type {import('collections/tree').default}
     */
    collection;
    constructor(options) {
      super(options);
      this.collection = options.collection;
    }

    /**
     * @type {import('collection').default}
     */
    itemCollection;

    /**
     * @type {boolean}
     */
    hasNavigationPanel;

    /**
     * @type {boolean}
     */
    isExpanded;

    /**
     * @protected
     * @type {string}
     */
    subjectEntityType;

    /**
     * @protected
     * @type {string}
     */
    categoryEntityType;

    /**
     * @private
     */
    showCreate;
    data() {
      const data = {};
      if (!this.isLoading) {
        data.list = this.getDataList();
      }
      data.scope = this.collection.entityType;
      data.isExpanded = this.isExpanded;
      data.isLoading = this.isLoading;
      data.currentId = this.collection.currentCategoryId;
      data.currentName = this.collection.currentCategoryName;
      data.categoryData = this.collection.categoryData;
      data.showFolders = !this.isExpanded;
      data.hasExpandedToggler = this.options.hasExpandedToggler;
      data.showEditLink = this.options.showEditLink;
      data.showCreate = this.showCreate;
      data.hasNavigationPanel = this.hasNavigationPanel;
      data.createCategoryLabel = this.translate(`Create ${this.categoryEntityType}`, 'labels', this.categoryEntityType);
      const categoryData = this.collection.categoryData || {};
      if (this.showCreate) {
        data.createLink = `#${this.categoryEntityType}/create`;
        let createReturnUrl = `#${this.subjectEntityType}`;
        if (categoryData.id) {
          createReturnUrl += `/list/categoryId=${categoryData.id}`;
        }
        data.createLink += `?returnUrl=${encodeURIComponent(createReturnUrl)}`;
        if (categoryData.id) {
          data.createLink += `&parentId=${categoryData.id}&parentName=${categoryData.name}`;
        }
      }
      data.upperLink = categoryData.upperId ? '#' + this.subjectEntityType + '/list/categoryId=' + categoryData.upperId : '#' + this.subjectEntityType;
      if (this.options.primaryFilter) {
        const part = 'primaryFilter=' + this.getHelper().escapeString(this.options.primaryFilter);
        if (categoryData.upperId) {
          data.upperLink += '&' + part;
        } else {
          data.upperLink += '/list/' + part;
        }
      }
      data.isExpandedResult = data.isExpanded || this.itemCollection.data.textFilter || this.itemCollection.where && this.itemCollection.where.find(it => it.type === 'textFilter');
      return data;
    }

    /**
     * @private
     * @return {{
     *     id: string,
     *     name: string,
     *     recordCount: number,
     *     isEmpty: boolean,
     *     link: string,
     * }[]}
     */
    getDataList() {
      const list = [];
      this.collection.forEach(model => {
        let url = `#${this.subjectEntityType}/list/categoryId=${model.id}`;
        if (this.options.primaryFilter) {
          url += '&primaryFilter=' + this.getHelper().escapeString(this.options.primaryFilter);
        }
        const o = {
          id: model.id,
          name: model.get('name'),
          recordCount: model.get('recordCount'),
          isEmpty: model.get('isEmpty'),
          link: url
        };
        list.push(o);
      });
      return list;
    }
    setup() {
      this.isExpanded = this.options.isExpanded;
      this.subjectEntityType = this.options.subjectEntityType;
      this.hasNavigationPanel = this.options.hasNavigationPanel;
      this.itemCollection = this.options.itemCollection;
      this.categoryEntityType = this.collection.entityType;
      this.showCreate = this.getAcl().check(this.categoryEntityType, 'create');
      this.listenTo(this.collection, 'sync', () => this.reRender());
      this.listenTo(this.itemCollection, 'sync', () => this.reRender());
      this.addActionHandler('createCategory', event => this.handleCreateCategory(event));
    }

    // noinspection JSUnusedGlobalSymbols
    actionShowMore() {
      this.$el.find('.category-item.show-more').addClass('hidden');
      this.collection.fetch({
        remove: false,
        more: true
      });
    }

    /**
     * @param {MouseEvent} event
     * @private
     */
    async handleCreateCategory(event) {
      event.preventDefault();
      const categoryData = this.collection.categoryData || {};
      const view = await new _recordModal.default().showCreate(this, {
        entityType: this.categoryEntityType,
        attributes: {
          parentId: categoryData.id ?? null,
          parentName: categoryData.name ?? null
        },
        rootUrl: this.getRouter().getCurrentUrl(),
        afterSave: () => {
          this.collection.fetch();
        }
      });
      await view.render();
    }
  }

  // noinspection JSUnusedGlobalSymbols
  var _default = _exports.default = ListNestedCategoriesRecordView;
});

define("views/record/kanban", ["exports", "views/record/list", "helpers/record-modal", "views/record/kanban/pipeline-dropdown", "helpers/misc/pipelines", "underscore"], function (_exports, _list, _recordModal, _pipelineDropdown, _pipelines, _underscore) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _list = _interopRequireDefault(_list);
  _recordModal = _interopRequireDefault(_recordModal);
  _pipelineDropdown = _interopRequireDefault(_pipelineDropdown);
  _pipelines = _interopRequireDefault(_pipelines);
  _underscore = _interopRequireDefault(_underscore);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/record/kanban */

  /**
   * A kanban record view.
   */
  class KanbanRecordView extends _list.default {
    template = 'record/kanban';
    itemViewName = 'views/record/kanban-item';
    rowActionsView = 'views/record/row-actions/default-kanban';
    type = 'kanban';
    name = 'kanban';
    showCount = true;
    headerDisabled = false;
    layoutName = 'kanban';
    portalLayoutDisabled = false;
    minColumnWidthPx = 220;
    showMore = true;
    quickDetailDisabled = false;
    quickEditDisabled = false;
    _internalLayout = null;
    buttonsDisabled = false;
    backDragStarted = true;
    paginationDisabled = true;
    columnResize = false;

    /**
     * @private
     * @type {{
     *     list: Record[],
     *     total: number,
     *     name: string,
     *     label?: string,
     *     style?: string|null,
     * }[]}
     */
    groupRawDataList;

    /**
     * @private
     * @type {import('collection').default[]}
     */
    subCollectionList;

    /**
     * A button list.
     *
     * @protected
     * @inheritDoc
     */
    buttonList = [];

    /**
     * @private
     * @type {import('collection').default}
     */
    seedCollection;

    /**
     * @private
     * @type {Record.<string, string>}
     */
    styleMap;

    /**
     * @private
     * @type {boolean}
     */
    usePipeline = false;

    /**
     * @private
     * @type {string|null}
     */
    currentPipelineId = null;

    /**
     * @private
     * @type {{
     *     id: string,
     *     name: string,
     *     stages: {id: string, name: string, style: string|null}[],
     *     color: number|null,
     * }[]}
     */
    pipelines;

    /**
     * Layout item definitions.
     *
     * @typedef module:views/record/kanban~layoutItemDefs
     * @type {Object}
     * @property {string} name A name (usually a field name).
     * @property {string} [view] An overridden field view name.
     * @property {boolean} [link] To use `listLink` mode (link to the detail view).
     * @property {'left'|'right'} [align] An alignment.
     * @property {boolean} [isLarge] Large.
     * @property {boolean} [isMuted] Muted.
     * @property {boolean} [hidden] Hidden by default.
     */

    /**
     * Kanban view options.
     *
     * @typedef {Record} module:views/record/kanban~options
     * @property {import('collection').default} collection A collection.
     * @property {module:views/record/kanban~layoutItemDefs[]} [listLayout] A layout.
     * @property {boolean} [keepCurrentRootUrl] Keep a current root URL.
     * @property {string|'kanban'} [type] A type.
     * @property {boolean} [rowActionsDisabled] Disable row actions.
     * @property {boolean} [buttonsDisabled] Disable buttons.
     * @property {Record} [rowActionsOptions] Row-actions options.
     * @property {string[]} [additionalRowActionList] Additional row-action list.
     * @property {import('helpers/list/settings').default} [settingsHelper] A settings helper.
     * @property {string} [layoutName] A layout name.
     * @property {boolean} [skipBuildRows] Do not build rows on initialization. Use when the collection will be fetched
     *    afterward.
     * @property {boolean} [rowActionsDisabled] Disable row actions.
     * @property {boolean} [displayTotalCount] Display total count.
     * @property {boolean} [showCount] To show a record count.
     * @property {boolean} [topBarDisabled] Disable the top bar.
     * @property {function(string, string[]): Promise} [onGroupOrder] On group order function.
     * @property {function(string): Promise<Record>} [getCreateAttributes] Get create attributes function.
     * @property {function(import('model').default): Promise} [groupChangeSaveHandler] Handles record saving after drop.
     * @property {function(string)} [createActionHandler] A create handler.
     * @property {string} [statusField] A status field.
     * @property {boolean} [canChangeGroup] Can change group.
     * @property {boolean} [canCreate] Can create.
     * @property {boolean} [canReOrder] Can re-order.
     * @property {boolean} [moveOverRowAction] Enable a move-over row action.
     */

    /**
     * @param {module:views/record/kanban~options} options Options.
     */
    constructor(options) {
      super(options);

      /** @private */
      this.onGroupOrder = options.onGroupOrder;
      /** @private */
      this.getCreateAttributes = options.getCreateAttributes;
      /** @private */
      this.createActionHandler = options.createActionHandler;
      /** @private */
      this.groupChangeSaveHandler = options.groupChangeSaveHandler;
    }

    // @todo Move to `setupEventHandlers`.
    events = {
      /** @this KanbanRecordView */
      'click a.link': function (e) {
        if (e.ctrlKey || e.metaKey || e.shiftKey) {
          return;
        }
        e.stopPropagation();
        if (!this.scope || this.selectable) {
          return;
        }
        e.preventDefault();
        const id = $(e.currentTarget).data('id');
        const model = this.collection.get(id);
        const scope = this.getModelScope(id);
        const options = {
          id: id,
          model: model
        };
        if (this.options.keepCurrentRootUrl) {
          options.rootUrl = this.getRouter().getCurrentUrl();
        }
        this.getRouter().navigate(`#${scope}/view/${id}`, {
          trigger: false
        });
        this.getRouter().dispatch(scope, 'view', options);
      },
      /** @this KanbanRecordView */
      'click [data-action="groupShowMore"]': function (e) {
        const $target = $(e.currentTarget);
        const group = $target.data('name');
        this.groupShowMore(group);
      },
      /** @this KanbanRecordView */
      'click .action': function (e) {
        Espo.Utils.handleAction(this, e.originalEvent, e.currentTarget, {
          actionItems: [...this.buttonList],
          className: 'list-action-item'
        });
      },
      /** @this KanbanRecordView */
      'mouseenter th.group-header': function (e) {
        if (!this.isCreatable) {
          return;
        }
        const group = $(e.currentTarget).attr('data-name');
        this.showPlus(group);
      },
      /** @this KanbanRecordView */
      'mouseleave th.group-header': function (e) {
        const group = $(e.currentTarget).attr('data-name');
        this.hidePlus(group);
      },
      /** @this KanbanRecordView */
      'click [data-action="createInGroup"]': function (e) {
        const group = $(e.currentTarget).attr('data-group');
        this.actionCreateInGroup(group);
      },
      /** @this KanbanRecordView */
      'mousedown .kanban-columns td': function (e) {
        if ($(e.originalEvent.target).closest('.item').length) {
          return;
        }
        this.initBackDrag(e.originalEvent);
      },
      /** @this KanbanRecordView */
      'auxclick a.link': function (e) {
        const isCombination = e.button === 1 && (e.ctrlKey || e.metaKey);
        if (!isCombination) {
          return;
        }
        const $target = $(e.currentTarget);
        const id = $target.attr('data-id');
        if (!id) {
          return;
        }
        if (this.quickDetailDisabled) {
          return;
        }
        const $quickView = $target.parent().closest(`[data-id="${id}"]`).find(`ul.list-row-dropdown-menu[data-id="${id}"] a[data-action="quickView"]`);
        if (!$quickView.length) {
          return;
        }
        e.preventDefault();
        e.stopPropagation();
        this.actionQuickView({
          id: id
        });
      }
    };

    // noinspection JSCheckFunctionSignatures
    data() {
      const topBar = !this.options.topBarDisabled && (this.displayTotalCount || this.buttonList.length && !this.buttonsDisabled || !!this._listSettingsHelper || this.usePipeline);

      // noinspection JSValidateTypes
      return {
        scope: this.scope,
        header: this.header,
        topBar: topBar,
        showCount: this.showCount && this.collection.total > 0,
        buttonList: this.buttonList,
        displayTotalCount: this.displayTotalCount && this.collection.total >= 0 && !this._renderEmpty,
        totalCount: this.collection.total,
        groupDataList: this.groupDataList,
        minTableWidthPx: this.minColumnWidthPx * this.groupDataList.length,
        isEmptyList: this.collection.models.length === 0,
        totalCountFormatted: this.getNumberUtil().formatInt(this.collection.total),
        noDataDisabled: this._renderEmpty,
        usePipeline: this.usePipeline
      };
    }
    init() {
      /** @type {import('views/record/detail').ColumnDefs[]|null} */
      this.listLayout = this.options.listLayout || this.listLayout;
      this.type = this.options.type || this.type;
      this.layoutName = this.options.layoutName || this.layoutName || this.type;
      this.rowActionsView = _underscore.default.isUndefined(this.options.rowActionsView) ? this.rowActionsView : this.options.rowActionsView;
      if (this.massActionsDisabled && !this.selectable) {
        this.checkboxes = false;
      }
      this.rowActionsDisabled = this.options.rowActionsDisabled || this.rowActionsDisabled;
      if ('buttonsDisabled' in this.options) {
        this.buttonsDisabled = this.options.buttonsDisabled;
      }
    }

    /** @inheritDoc */
    getModelScope(id) {
      return this.scope;
    }
    setup() {
      if (typeof this.collection === 'undefined') {
        throw new Error('Collection has not been injected into Record.List view.');
      }
      this.setupEventHandlers();
      this.collection.onSync({
        owner: this,
        callback: o => {
          this.subCollectionList = undefined;
          // noinspection JSUnresolvedReference
          this.groupRawDataList = o.response.groups;
        }
      });
      this.layoutLoadCallbackList = [];
      this.entityType = this.collection.entityType || null;
      this.scope = this.options.scope || this.entityType;
      this.buttonList = Espo.Utils.clone(this.buttonList);
      if ('showCount' in this.options) {
        this.showCount = this.options.showCount;
      }
      this.displayTotalCount = this.showCount && this.getConfig().get('displayListViewRecordCount');
      this.minColumnWidthPx = this.getConfig().get('kanbanMinColumnWidth') || this.minColumnWidthPx;
      if ('displayTotalCount' in this.options) {
        this.displayTotalCount = this.options.displayTotalCount;
      }
      if (this.getUser().isPortal() && !this.portalLayoutDisabled && this.getMetadata().get(['clientDefs', this.scope, 'additionalLayouts', this.layoutName + 'Portal'])) {
        this.layoutName += 'Portal';
      }
      if ('canReOrder' in this.options) {
        this.orderDisabled = !this.options.canReOrder;
      } else {
        this.orderDisabled = this.getMetadata().get(['scopes', this.scope, 'kanbanOrderDisabled']);
        if (this.getUser().isPortal()) {
          this.orderDisabled = true;
        }
      }
      if (!this.options.statusField && this.getMetadata().get(`scopes.${this.scope}.pipelines`)) {
        this.usePipeline = true;
      }
      this.setupStatusField();
      if (this.usePipeline) {
        this.setupPipeline();
      }
      this.seedCollection = this.collection.clone();
      this.seedCollection.reset();
      this.seedCollection.url = this.scope;
      this.seedCollection.maxSize = this.collection.maxSize;
      this.seedCollection.entityType = this.collection.entityType;
      this.seedCollection.orderBy = this.collection.defaultOrderBy;
      this.seedCollection.order = this.collection.defaultOrder;
      this.setupRowActionDefs();
      this.setupSettings();
      this.collection.onSync({
        owner: this,
        callback: () => {
          this._renderEmpty = false;
          this.buildRowsAndRender();
        }
      });
      this.listenTo(this.collection, `change:${this.statusField}`, (m, v, o) => {
        this.onChangeGroup(m, v, o);
      });
      this.buildRows();
      this.on('remove', () => {
        $(window).off('resize.kanban-a-' + this.cid);
        $(window).off('scroll.kanban-' + this.cid);
        $(window).off('resize.kanban-' + this.cid);
      });
      if ('canChangeGroup' in this.options) {
        this.statusFieldIsEditable = this.options.canChangeGroup;
      } else {
        this.statusFieldIsEditable = this.getAcl().checkScope(this.entityType, 'edit') && this.getAcl().checkField(this.entityType, this.statusField, 'edit') && !this.getMetadata().get(`clientDefs.${this.scope}.editDisabled`) && !this.getMetadata().get(`entityDefs.${this.entityType}.fields.${this.statusField}.readOnly`);
      }
      if ('canCreate' in this.options) {
        this.isCreatable = this.options.canCreate;
      } else {
        this.isCreatable = this.statusFieldIsEditable && this.getAcl().check(this.entityType, 'create') && !this.getMetadata().get(`clientDefs.${this.scope}.createDisabled`);
      }

      /** @private */
      this.moveOverRowAction = true;
      if ('moveOverRowAction' in this.options) {
        this.moveOverRowAction = this.options.moveOverRowAction;
      }
      this._renderEmpty = this.options.skipBuildRows;
      this.wait(this.getHelper().processSetupHandlers(this, 'record/kanban'));

      /**
       * @private
       * @type {boolean}
       */
      this.hasStars = this.getMetadata().get(`scopes.${this.entityType}.stars`) || false;
    }

    /**
     * @protected
     */
    setupEventHandlers() {}

    /**
     * @private
     */
    setupPipeline() {
      this.pipelines = new _pipelines.default().get(this.entityType);
      this.currentPipelineId = this.getStorage().get('state', this.buildPipelineIdStorageKey());
      if (!this.currentPipelineId) {
        var _this$pipelines$;
        this.currentPipelineId = ((_this$pipelines$ = this.pipelines[0]) === null || _this$pipelines$ === void 0 ? void 0 : _this$pipelines$.id) ?? null;
      }
      if (this.currentPipelineId && !this.pipelines.find(it => it.id === this.currentPipelineId)) {
        this.currentPipelineId = null;
      }
      this.setPipelineWhere();
      this.setupPipelineDropdown();
    }

    /**
     * @private
     */
    setPipelineWhere() {
      if (!this.currentPipelineId) {
        this.collection.whereFunction = null;
        return;
      }
      this.collection.whereFunction = () => {
        return [{
          type: 'equals',
          attribute: 'pipelineId',
          value: this.currentPipelineId
        }];
      };
    }

    /**
     * @private
     */
    setupPipelineDropdown() {
      const state = {
        pipelineId: this.currentPipelineId,
        pipelines: this.pipelines
      };
      const view = new _pipelineDropdown.default({
        state: state,
        onChange: async id => {
          this.currentPipelineId = id;
          state.pipelineId = id;
          this.setPipelineWhere();
          this.getStorage().set('state', this.buildPipelineIdStorageKey(), id);
          await view.reRender();
          Espo.Ui.notifyWait();
          await this.collection.fetch({
            maxSize: this.collection.maxSize
          });
          Espo.Ui.notify();
        }
      });
      this.assignView('pipelineDropdown', view);
    }

    /**
     * @private
     */
    setupStatusField() {
      this.statusField = this.options.statusField || this.getMetadata().get(['scopes', this.scope, 'statusField']);
      if (this.usePipeline) {
        this.statusField = 'pipelineStageId';
      }
      if (!this.statusField) {
        throw new Error(`No status field for entity type '${this.scope}'.`);
      }

      // @todo Use options-provider.
      this.styleMap = /** @type {Record.<string, string>} */
      this.getMetadata().get(`entityDefs.${this.scope}.fields.${this.statusField}.style`) ?? {};
      const optionsReference = this.getMetadata().get(`entityDefs.${this.scope}.fields.${this.statusField}.optionsReference`);
      if (optionsReference) {
        const [entityType, field] = optionsReference.split('.');
        this.styleMap = /** @type {Record.<string, string>} */
        this.getMetadata().get(`entityDefs.${entityType}.fields.${field}.style`) ?? {};
      }
    }
    afterRender() {
      const $window = $(window);
      this.$listKanban = this.$el.find('.list-kanban');
      this.$content = $('#content');
      this.$groupColumnList = this.$listKanban.find('.group-column-list');
      this.$container = this.$el.find('.list-kanban-container');
      $window.off('resize.kanban-a-' + this.cid);
      $window.on('resize.kanban-a-' + this.cid, () => this.adjustMinHeight());
      this.$container.on('scroll', () => this.syncHeadScroll());
      this.adjustMinHeight();
      if (this.statusFieldIsEditable) {
        this.initSortable();
      }
      this.initStickableHeader();
      this.$showMore = this.$el.find('.group-column .show-more');
      this.plusElementMap = {};
      this.groupDataList.forEach(item => {
        const value = CSS.escape(item.name);
        this.plusElementMap[item.name] = this.$el.find(`.kanban-head .create-button[data-group="${value}"]`);
      });
    }

    /**
     * @private
     */
    initStickableHeader() {
      const $container = this.$headContainer = this.$el.find('.kanban-head-container');
      const topBarHeight = (this.getThemeManager().getParam('navbarHeight') || 30) * this.getThemeManager().getFontSizeFactor();
      const screenWidthXs = this.getThemeManager().getParam('screenWidthXs');
      const $middle = this.$el.find('.kanban-columns-container');
      const $window = $(window);
      const $block = $('<div>').addClass('kanban-head-placeholder').html('&nbsp;').hide().insertAfter($container);
      $window.off('scroll.kanban-' + this.cid);
      $window.on('scroll.kanban-' + this.cid, () => {
        controlSticking();
      });
      $window.off('resize.kanban-' + this.cid);
      $window.on('resize.kanban-' + this.cid, () => controlSticking());
      const controlSticking = () => {
        const width = $middle.width();
        if ($(window.document).width() < screenWidthXs) {
          $container.removeClass('sticked');
          $container.css('width', '');
          $block.hide();
          $container.show();
          $container.get(0).scrollLeft = 0;
          $container.children().css('width', '');
          return;
        }
        const stickTop = this.$listKanban.offset().top - topBarHeight;
        const edge = $middle.offset().top + $middle.outerHeight(true);
        const scrollTop = $window.scrollTop();
        if (scrollTop < edge) {
          if (scrollTop > stickTop) {
            const containerWidth = this.$container.width() - 3;
            $container.children().css('width', width);
            $container.css('width', containerWidth + 'px');
            if (!$container.hasClass('sticked')) {
              $container.addClass('sticked');
              $block.show();
            }
          } else {
            $container.css('width', '');
            if ($container.hasClass('sticked')) {
              $container.removeClass('sticked');
              $block.hide();
            }
          }
          $container.show();
          this.syncHeadScroll();
          return;
        }
        $container.css('width', width + 'px');
        $container.hide();
        $block.show();
        $container.get(0).scrollLeft = 0;
        $container.children().css('width', '');
      };
    }

    /**
     * @private
     */
    initSortable() {
      const $list = this.$groupColumnList;
      $list.find('> .item').on('touchstart', e => {
        e.originalEvent.stopPropagation();
      });
      const orderDisabled = this.orderDisabled;
      const $groupColumnList = this.$el.find('.group-column-list');
      $list.sortable({
        distance: 10,
        connectWith: '.group-column-list',
        cancel: '.btn-group *',
        containment: this.getSelector(),
        scroll: false,
        over: function () {
          $(this).addClass('drop-hover');
        },
        out: function () {
          $(this).removeClass('drop-hover');
        },
        sort: e => {
          if (!this.blockScrollControl) {
            this.controlHorizontalScroll(e.originalEvent);
          }
        },
        start: (e, ui) => {
          $groupColumnList.addClass('drop-active');
          $list.sortable('refreshPositions');
          $(ui.item).find('.btn-group.open > .dropdown-toggle').parent().removeClass('open');
          this.draggedGroupFrom = $(ui.item).closest('.group-column-list').data('name');
          this.$showMore.addClass('hidden');
          this.sortIsStarted = true;
          this.sortWasCentered = false;
          this.$draggable = ui.item;
        },
        stop: (e, ui) => {
          this.blockScrollControl = false;
          this.sortIsStarted = false;
          this.$draggable = null;
          const $item = $(ui.item);
          this.$el.find('.group-column-list').removeClass('drop-active');
          const group = $item.closest('.group-column-list').data('name');
          const id = $item.data('id');
          const draggedGroupFrom = this.draggedGroupFrom;
          this.draggedGroupFrom = null;
          this.$showMore.removeClass('hidden');
          if (group !== draggedGroupFrom) {
            const model = this.collection.get(id);
            if (!model) {
              $list.sortable('cancel');
              return;
            }
            const attributes = {};
            attributes[this.statusField] = group;
            this.handleAttributesOnGroupChange(model, attributes, group);
            $list.sortable('disable');
            const processSave = async () => {
              if (this.groupChangeSaveHandler) {
                model.set(attributes, {
                  isDrop: true
                });
                return this.groupChangeSaveHandler(model);
              }
              return model.save(attributes, {
                patch: true,
                isDrop: true
              });
            };
            processSave().then(() => {
              Espo.Ui.success(this.translate('Saved'));
              $list.sortable('destroy');
              this.initSortable();
              this.moveModelBetweenGroupCollections(model, draggedGroupFrom, group);
              if (!orderDisabled) {
                this.reOrderGroup(group);
                this.storeGroupOrder(group);
              }
              this.rebuildGroupDataList();
            }).catch(() => {
              $list.sortable('cancel');
              $list.sortable('enable');
            });
            return;
          }
          if (orderDisabled) {
            $list.sortable('cancel');
            $list.sortable('enable');
            return;
          }
          this.reOrderGroup(group);
          this.storeGroupOrder(group);
          this.rebuildGroupDataList();
        }
      });
    }

    /**
     * @param {string} group
     * @param {string} [id] Prepend. To be used after save.
     * @return {Promise}
     */
    storeGroupOrder(group, id) {
      const ids = this.getGroupOrderFromDom(group);
      if (id) {
        ids.unshift(id);
      }
      if (this.onGroupOrder) {
        return this.onGroupOrder(group, ids);
      }
      return Espo.Ajax.putRequest('Kanban/order', {
        entityType: this.entityType,
        group: group,
        ids: ids
      });
    }

    /**
     * @private
     * @param {string} group
     * @return {string[]}
     */
    getGroupOrderFromDom(group) {
      const ids = [];
      const $group = this.$el.find('.group-column-list[data-name="' + group + '"]');
      $group.children().each((i, el) => {
        ids.push($(el).data('id'));
      });
      return ids;
    }

    /**
     * @param {string} group
     */
    reOrderGroup(group) {
      const groupCollection = this.getGroupCollection(group);
      const ids = this.getGroupOrderFromDom(group);
      const modelMap = {};
      groupCollection.models.forEach(m => {
        modelMap[m.id] = m;
      });
      while (groupCollection.models.length) {
        groupCollection.pop({
          silent: true
        });
      }
      ids.forEach(id => {
        const model = modelMap[id];
        if (!model) {
          return;
        }
        groupCollection.add(model, {
          silent: true
        });
      });
    }

    /**
     * @private
     */
    rebuildGroupDataList() {
      this.groupDataList.forEach(item => {
        item.dataList = [];
        for (const model of item.collection.models) {
          item.dataList.push({
            key: model.id,
            id: model.id
          });
        }
      });
    }

    /**
     * @private
     * @param {import('model').default} model
     * @param {string} groupFrom
     * @param {string} groupTo
     */
    moveModelBetweenGroupCollections(model, groupFrom, groupTo) {
      let collection = this.getGroupCollection(groupFrom);
      if (!collection) {
        return;
      }
      collection.remove(model.id, {
        silent: true
      });
      collection = this.getGroupCollection(groupTo);
      if (!collection) {
        return;
      }
      collection.add(model, {
        silent: true
      });
    }
    handleAttributesOnGroupChange(model, attributes, group) {}
    adjustMinHeight() {
      if (this.collection.models.length === 0 || !this.$container) {
        return;
      }
      let height = this.getHelper().calculateContentContainerHeight(this.$el.find('.kanban-columns-container'));
      const containerEl = this.$container.get(0);
      if (containerEl && containerEl.scrollWidth > containerEl.clientWidth) {
        height -= 18;
      }
      if (height < 100) {
        height = 100;
      }
      this.$listKanban.find('td.group-column').css({
        minHeight: height + 'px'
      });
    }
    getListLayout(callback) {
      if (this.listLayout) {
        callback.call(this, this.listLayout);
        return;
      }
      this._loadListLayout(listLayout => {
        this.listLayout = listLayout;
        callback.call(this, listLayout);
      });
    }
    async getSelectAttributeList(callback) {
      const attributeList = await super.getSelectAttributeList();
      if (!attributeList) {
        return null;
      }
      if (!attributeList.includes(this.statusField)) {
        attributeList.push(this.statusField);
      }
      if (callback) {
        // For bc.
        callback(attributeList);
      }
      return attributeList;
    }
    buildRows(callback) {
      let groupList = this.groupRawDataList;
      if (this.subCollectionList && groupList) {
        this.subCollectionList.forEach((collection, i) => {
          const group = groupList[i];
          if (!group) {
            console.warn("No group.", collection);
            return;
          }
          group.list = collection.models.map(model => model.getClonedAttributes());
          group.total = collection.total;
        });
      }
      if (!groupList) {
        groupList = [];
      }
      this.collection.reset();

      /** @type {import('collection').default[]} */
      this.subCollectionList = [];
      this.wait(true);

      /**
       * @type {{
       *     name: string,
       *     label: string,
       *     style: string,
       *     hasShowMore: boolean,
       *     collection: import('collection').default,
       *     dataList: Record[],
       * }[]}
       */
      this.groupDataList = [];
      let count = 0;
      let loadedCount = 0;
      this.getListLayout(listLayout => {
        this.listLayout = listLayout;
        groupList.forEach(item => {
          const collection = this.seedCollection.clone();
          this.listenTo(collection, 'destroy', (model, attributes, o) => {
            if (o.fromList) {
              return;
            }
            this.removeRecordFromList(model.id);
          });
          collection.total = item.total;
          collection.url = this.collection.url;
          collection.where = this.collection.where;
          collection.entityType = this.seedCollection.entityType;
          collection.maxSize = this.seedCollection.maxSize;
          collection.orderBy = this.seedCollection.orderBy;
          collection.order = this.seedCollection.order;
          collection.whereAdditional = [{
            field: this.statusField,
            type: 'equals',
            value: item.name
          }];
          collection.data.groupName = item.name;
          collection.add(item.list);
          this.subCollectionList.push(collection);
          this.collection.add(collection.models);
          const itemDataList = [];
          collection.models.forEach(model => {
            count++;
            itemDataList.push({
              key: model.id,
              id: model.id
            });
          });
          const style = item.style || this.styleMap[item.name];
          const label = item.label || this.getLanguage().translateOption(item.name, this.statusField, this.scope);
          const o = {
            name: item.name,
            label: label,
            dataList: itemDataList,
            collection: collection,
            hasShowMore: collection.total > collection.length || collection.total === -1,
            style: style
          };
          this.groupDataList.push(o);
        });
        if (count === 0) {
          this.wait(false);
          if (callback) {
            callback();
          }
          return;
        }
        this.groupDataList.forEach(groupItem => {
          groupItem.dataList.forEach((item, j) => {
            const model = groupItem.collection.get(item.id);
            this.buildRow(j, model, () => {
              loadedCount++;
              if (loadedCount === count) {
                this.wait(false);
                if (callback) {
                  callback();
                }
              }
            });
          });
        });
      });
    }
    buildRow(i, model, callback) {
      const key = model.id;
      const hiddenMap = this._listSettingsHelper ? this._listSettingsHelper.getHiddenColumnMap() : {};
      const itemLayout = this.listLayout.filter(item => {
        const name = item.name;
        if (!name) {
          return true;
        }
        if (hiddenMap[name]) {
          return false;
        }
        if (item.hidden && !(name in hiddenMap)) {
          return false;
        }
        return true;
      });
      this.createView(key, this.itemViewName, {
        model: model,
        selector: `.item[data-id="${model.id}"]`,
        itemLayout: itemLayout,
        rowActionsDisabled: this.rowActionsDisabled,
        rowActionsView: this.rowActionsView,
        rowActionHandlers: this._rowActionHandlers || {},
        setViewBeforeCallback: this.options.skipBuildRows && !this.isRendered(),
        statusFieldIsEditable: this.statusFieldIsEditable,
        moveOverRowAction: this.moveOverRowAction,
        additionalRowActionList: this._additionalRowActionList,
        scope: this.scope,
        hasStars: this.hasStars
      }, callback);
    }

    /**
     * @param {string} id
     */
    removeRecordFromList(id) {
      this.collection.remove(id);
      if (this.collection.total > 0) {
        this.collection.total--;
      }
      this.collection.trigger('update-total');
      this.totalCount = this.collection.total;
      this.$el.find('.total-count-span').text(this.totalCount.toString());
      this.clearView(id);
      this.$el.find('.item[data-id="' + id + '"]').remove();
      this.subCollectionList.forEach(collection => {
        if (collection.get(id)) {
          collection.remove(id);
        }
      });
      for (const groupItem of this.groupDataList) {
        for (let j = 0; j < groupItem.dataList.length; j++) {
          const item = groupItem.dataList[j];
          if (item.id !== id) {
            continue;
          }
          groupItem.dataList.splice(j, 1);
          if (groupItem.collection.total > 0) {
            groupItem.collection.total--;
          }
          groupItem.hasShowMore = groupItem.collection.total > groupItem.collection.length || groupItem.collection.total === -1;
          break;
        }
      }
    }

    /**
     * @protected
     * @param {import('model').default} model A model.
     * @param {string} value A group.
     * @param {Record} o Options.
     */
    onChangeGroup(model, value, o) {
      if (o.action === 'fetch') {
        return;
      }
      const id = model.id;
      const group = model.get(this.statusField);
      this.subCollectionList.forEach(collection => {
        if (collection.get(id)) {
          collection.remove(id);
          if (collection.total > 0) {
            collection.total--;
          }
        }
      });
      let dataItem;
      for (const groupItem of this.groupDataList) {
        for (let j = 0; j < groupItem.dataList.length; j++) {
          const item = groupItem.dataList[j];
          if (item.id === id) {
            dataItem = item;
            groupItem.dataList.splice(j, 1);
            break;
          }
        }
      }
      if (!group) {
        return;
      }
      if (o.isDrop) {
        return;
      }
      for (const groupItem of this.groupDataList) {
        if (groupItem.name !== group) {
          continue;
        }
        groupItem.collection.unshift(model);
        groupItem.collection.total++;
        if (dataItem) {
          groupItem.dataList.unshift(dataItem);
          groupItem.hasShowMore = groupItem.collection.total > groupItem.collection.length || groupItem.collection.total === -1;
        }
      }
      const $item = this.$el.find('.item[data-id="' + id + '"]');
      const $column = this.$el.find('.group-column[data-name="' + group + '"] .group-column-list');
      if ($column.length) {
        $column.prepend($item);
      } else {
        $item.remove();
      }
      if (!this.orderDisabled) {
        this.storeGroupOrder(group);
      }
    }
    groupShowMore(group) {
      let groupItem;
      for (const i in this.groupDataList) {
        groupItem = this.groupDataList[i];
        if (groupItem.name === group) {
          break;
        }
        groupItem = null;
      }
      if (!groupItem) {
        return;
      }
      const collection = groupItem.collection;
      const $list = this.$el.find('.group-column-list[data-name="' + group + '"]');
      const $showMore = this.$el.find('.group-column[data-name="' + group + '"] .show-more');
      collection.data.select = this.collection.data.select;
      this.showMoreRecords({}, collection, $list, $showMore, () => {
        this.noRebuild = false;
        collection.models.forEach(model => {
          if (this.collection.get(model.id)) {
            return;
          }
          this.collection.add(model);
          groupItem.dataList.push({
            key: model.id,
            id: model.id
          });
        });
      });
    }

    /**
     * @protected
     * @param {string}id
     * @return {HTMLElement | null}
     */
    getDomRowItem(id) {
      return this.element.querySelector(`.item[data-id="${id}"]`);
    }
    getRowContainerHtml(id) {
      return $('<div>').attr('data-id', id).addClass('item').get(0).outerHTML;
    }

    // noinspection JSUnusedGlobalSymbols
    actionMoveOver(data) {
      const model = this.collection.get(data.id);
      this.createView('moveOverDialog', 'views/modals/kanban-move-over', {
        model: model,
        statusField: this.statusField,
        pipelineId: this.currentPipelineId
      }, view => {
        view.render();
      });
    }

    /**
     *
     * @param {string} group
     * @return {module:collection}
     */
    getGroupCollection(group) {
      let collection = null;
      this.subCollectionList.forEach(itemCollection => {
        if (itemCollection.data.groupName === group) {
          collection = itemCollection;
        }
      });
      return collection;
    }

    /**
     * @param {string} group
     */
    showPlus(group) {
      const $el = this.plusElementMap[group];
      if (!$el) {
        return;
      }
      $el.removeClass('hidden');
    }

    /**
     * @param {string} group
     */
    hidePlus(group) {
      const $el = this.plusElementMap[group];
      if (!$el) {
        return;
      }
      $el.addClass('hidden');
    }

    /**
     * @param {string} group
     */
    async actionCreateInGroup(group) {
      if (this.createActionHandler) {
        this.createActionHandler(group);
        return;
      }
      const getCreateAttributes = () => {
        if (this.getCreateAttributes) {
          return this.getCreateAttributes(group);
        }
        const attributes = {
          [this.statusField]: group
        };
        if (this.usePipeline) {
          attributes.pipelineId = this.currentPipelineId;
        }
        return Promise.resolve(attributes);
      };
      const attributes = await getCreateAttributes();
      const helper = new _recordModal.default();
      await helper.showCreate(this, {
        attributes: attributes,
        entityType: this.scope,
        afterSave: async model => {
          if (this.orderDisabled) {
            await this.collection.fetch({
              maxSize: this.collection.maxSize
            });
            return;
          }
          await this.storeGroupOrder(group, model.id);
          await this.collection.fetch({
            maxSize: this.collection.maxSize
          });
        },
        beforeRender: view => {
          view.getRecordView().setFieldReadOnly(this.statusField, true);
        }
      });
    }

    /**
     * @private
     * @param {MouseEvent} e
     */
    initBackDrag(e) {
      this.backDragStarted = true;
      const containerEl = this.$container.get(0);
      containerEl.style.cursor = 'grabbing';
      containerEl.style.userSelect = 'none';
      const $document = $(document);
      const startLeft = containerEl.scrollLeft;
      const startX = e.clientX;
      $document.on(`mousemove.${this.cid}`, e => {
        // noinspection JSUnresolvedReference
        const dx = e.originalEvent.clientX - startX;
        containerEl.scrollLeft = startLeft - dx;
        this.syncHeadScroll();
      });
      $document.one('mouseup.' + this.cid, () => {
        this.stopBackDrag();
      });
    }
    stopBackDrag() {
      this.$container.get(0).style.cursor = 'default';
      this.$container.get(0).style.userSelect = 'none';
      $(document).off('mousemove.' + this.cid);
    }
    syncHeadScroll() {
      if (!this.$headContainer.hasClass('sticked')) {
        return;
      }
      this.$headContainer.get(0).scrollLeft = this.$container.get(0).scrollLeft;
    }
    controlHorizontalScroll(e) {
      if (!this.sortIsStarted) {
        return;
      }
      if (!this.$draggable) {
        return;
      }
      const draggableRect = this.$draggable.get(0).getBoundingClientRect();
      const itemLeft = draggableRect.left;
      const itemRight = draggableRect.right;
      const containerEl = this.$container.get(0);
      const rect = containerEl.getBoundingClientRect();
      const marginSens = 70;
      let step = 2;
      const interval = 5;
      const marginSensStepRatio = 4;
      const stepRatio = 3;
      const isRight = rect.right - marginSens < itemRight && containerEl.scrollLeft + containerEl.offsetWidth < containerEl.scrollWidth;
      const isLeft = rect.left + marginSens > itemLeft && containerEl.scrollLeft > 0;
      this.$groupColumnList.sortable('refreshPositions');
      if (isRight && this.sortWasCentered) {
        const margin = rect.right - itemRight;
        if (margin < marginSens / marginSensStepRatio) {
          step *= stepRatio;
        }
        const stepActual = Math.min(step, containerEl.offsetWidth - containerEl.scrollLeft);
        containerEl.scrollLeft = containerEl.scrollLeft + stepActual;
        this.syncHeadScroll();
        if (containerEl.scrollLeft + containerEl.offsetWidth === containerEl.scrollWidth) {
          this.blockScrollControl = false;
          return;
        }
        this.blockScrollControl = true;
        setTimeout(() => this.controlHorizontalScroll(e), interval);
        return;
      }
      if (isLeft && this.sortWasCentered) {
        const margin = -(rect.left - itemLeft);
        if (margin < marginSens / marginSensStepRatio) {
          step *= stepRatio;
        }
        const stepActual = Math.min(step, containerEl.scrollLeft);
        containerEl.scrollLeft = containerEl.scrollLeft - stepActual;
        this.syncHeadScroll();
        if (containerEl.scrollLeft === 0) {
          this.blockScrollControl = false;
          return;
        }
        this.blockScrollControl = true;
        setTimeout(() => this.controlHorizontalScroll(e), interval);
        return;
      }
      if (this.blockScrollControl && !isLeft && !isRight) {
        this.blockScrollControl = false;
      }
      if (!isLeft && !isRight) {
        this.sortWasCentered = true;
      }
    }

    /** @inheritDoc */
    async afterSettingsChange(options) {
      this._internalLayout = null;
      if (options.action === 'toggleColumn' || options.action === 'resetToDefault') {
        const selectAttributes = await this.getSelectAttributeList();
        if (selectAttributes) {
          this.collection.data.select = selectAttributes.join(',');
        }
      }
      Espo.Ui.notifyWait();
      await this.collection.fetch({
        maxSize: this.collection.maxSize
      });
      Espo.Ui.notify(false);
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * Set can create.
     *
     * @param {boolean} canCreate
     * @sinc 8.4.0
     */
    setCanCreate(canCreate) {
      this.isCreatable = canCreate;
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * Set can re-order.
     *
     * @param {boolean} canReOrder
     * @sinc 8.4.0
     */
    setCanReOrder(canReOrder) {
      this.orderDisabled = !canReOrder;
    }

    /**
     * @private
     * @return {string}
     */
    buildPipelineIdStorageKey() {
      return 'kanban-pipelineId-' + this.scope;
    }
  }
  var _default = _exports.default = KanbanRecordView;
});

define("views/record/kanban-item", ["exports", "view"], function (_exports, _view) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class KanbanRecordItem extends _view.default {
    template = 'record/kanban-item';
    data() {
      return {
        layoutDataList: this.layoutDataList,
        rowActionsDisabled: this.rowActionsDisabled,
        isStarred: this.hasStars && this.model.attributes.isStarred
      };
    }
    setup() {
      this.itemLayout = this.options.itemLayout;
      this.rowActionsView = this.options.rowActionsView;
      this.rowActionsDisabled = this.options.rowActionsDisabled;
      this.hasStars = this.options.hasStars;
      this.layoutDataList = [];
      this.itemLayout.forEach((item, i) => {
        const name = item.name;
        const key = name + 'Field';
        const o = {
          name: name,
          isAlignRight: item.align === 'right',
          isLarge: item.isLarge,
          isMuted: item.isMuted,
          isFirst: i === 0,
          key: key
        };
        this.layoutDataList.push(o);
        let viewName = item.view || this.model.getFieldParam(name, 'view');
        if (!viewName) {
          const type = this.model.getFieldType(name) || 'base';
          viewName = this.getFieldManager().getViewName(type);
        }
        let mode = 'list';
        if (item.link) {
          mode = 'listLink';
        }
        this.createView(key, viewName, {
          model: this.model,
          name: name,
          mode: mode,
          readOnly: true,
          selector: '.field[data-name="' + name + '"]'
        });
      });
      if (!this.rowActionsDisabled) {
        const acl = {
          edit: this.getAcl().checkModel(this.model, 'edit'),
          delete: this.getAcl().checkModel(this.model, 'delete')
        };
        this.createView('itemMenu', this.rowActionsView, {
          selector: '.item-menu-container',
          model: this.model,
          acl: acl,
          moveOverRowAction: this.options.moveOverRowAction,
          statusFieldIsEditable: this.options.statusFieldIsEditable,
          rowActionHandlers: this.options.rowActionHandlers || {},
          additionalActionList: this.options.additionalRowActionList,
          scope: this.options.scope
        });
      }
    }
  }
  var _default = _exports.default = KanbanRecordItem;
});

define("views/record/edit-small", ["exports", "views/record/edit"], function (_exports, _edit) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _edit = _interopRequireDefault(_edit);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * For bc.
   *
   * @deprecated As of v9.0.0. Extend from EditRecordView instead.
   */
  class EditSmallRecordView extends _edit.default {}
  var _default = _exports.default = EditSmallRecordView;
});

define("views/record/edit-side", ["exports", "views/record/detail-side"], function (_exports, _detailSide) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _detailSide = _interopRequireDefault(_detailSide);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/record/edit-side */

  class EditSideRecordView extends _detailSide.default {
    /** @inheritDoc */
    mode = 'edit';

    /** @inheritDoc */
    defaultPanelDefs = {
      name: 'default',
      label: false,
      view: 'views/record/panels/side',
      isForm: true,
      options: {
        fieldList: [{
          name: ':assignedUser'
        }, {
          name: 'teams',
          view: 'views/fields/teams'
        }]
      }
    };
  }
  var _default = _exports.default = EditSideRecordView;
});

define("views/record/edit-bottom", ["exports", "views/record/detail-bottom"], function (_exports, _detailBottom) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _detailBottom = _interopRequireDefault(_detailBottom);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EditBottomRecordView extends _detailBottom.default {
    mode = 'edit';
    streamPanel = false;
    relationshipPanels = false;
  }
  var _default = _exports.default = EditBottomRecordView;
});

define("views/record/detail-small", ["exports", "views/record/detail"], function (_exports, _detail) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _detail = _interopRequireDefault(_detail);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * For bc.
   *
   * @deprecated As of v9.0.0. Extend from DetailRecordView instead.
   */
  class DetailSmallRecordView extends _detail.default {}
  var _default = _exports.default = DetailSmallRecordView;
});

define("views/record/detail-middle", ["exports", "view"], function (_exports, _view) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/record/detail-middle */

  /**
   * A detail-middle record view.
   */
  class DetailMiddleRecordView extends _view.default {
    init() {
      this.recordHelper = this.options.recordHelper;
      this.scope = this.model.entityType;
    }
    data() {
      return {
        hiddenPanels: this.recordHelper.getHiddenPanels(),
        hiddenFields: this.recordHelper.getHiddenFields()
      };
    }

    /**
     * Show a panel.
     *
     * @param {string} name
     */
    showPanel(name) {
      if (this.recordHelper.getPanelStateParam(name, 'hiddenLocked')) {
        return;
      }
      this.showPanelInternal(name);
      this.recordHelper.setPanelStateParam(name, 'hidden', false);
    }

    /**
     * @param {string} name
     */
    showPanelInternal(name) {
      if (this.isRendered()) {
        this.$el.find('.panel[data-name="' + name + '"]').removeClass('hidden');
      }
      const wasShown = !this.recordHelper.getPanelStateParam(name, 'hidden');
      if (!wasShown && this.options.panelFieldListMap && this.options.panelFieldListMap[name]) {
        this.options.panelFieldListMap[name].forEach(field => {
          const view = this.getFieldView(field);
          if (!view) {
            return;
          }
          view.reRender();
        });
      }
    }

    /**
     * Hide a panel.
     *
     * @param {string} name
     */
    hidePanel(name) {
      this.hidePanelInternal(name);
      this.recordHelper.setPanelStateParam(name, 'hidden', true);
    }

    /**
     * @public
     * @param {string} name A name.
     */
    hidePanelInternal(name) {
      if (this.isRendered()) {
        this.$el.find('.panel[data-name="' + name + '"]').addClass('hidden');
      }
    }

    /**
     * Hide a field.
     *
     * @param {string} name A name.
     */
    hideField(name) {
      this.recordHelper.setFieldStateParam(name, 'hidden', true);
      const processHtml = () => {
        const fieldView = this.getFieldView(name);
        if (fieldView) {
          const $field = fieldView.$el;
          const $cell = $field.closest('.cell[data-name="' + name + '"]');
          const $label = $cell.find('label.control-label[data-name="' + name + '"]');
          $field.addClass('hidden');
          $label.addClass('hidden');
          $cell.addClass('hidden-cell');
        } else {
          this.$el.find('.cell[data-name="' + name + '"]').addClass('hidden-cell');
          this.$el.find('.field[data-name="' + name + '"]').addClass('hidden');
          this.$el.find('label.control-label[data-name="' + name + '"]').addClass('hidden');
        }
      };
      if (this.isRendered()) {
        processHtml();
      } else {
        this.once('after:render', () => {
          processHtml();
        });
      }
      const view = this.getFieldView(name);
      if (view) {
        view.setDisabled();
      }
    }

    /**
     * Show a field.
     *
     * @param {string} name A name.
     */
    showField(name) {
      if (this.recordHelper.getFieldStateParam(name, 'hiddenLocked')) {
        return;
      }
      this.recordHelper.setFieldStateParam(name, 'hidden', false);
      const processHtml = () => {
        const fieldView = this.getFieldView(name);
        if (fieldView) {
          const $field = fieldView.$el;
          const $cell = $field.closest('.cell[data-name="' + name + '"]');
          const $label = $cell.find('label.control-label[data-name="' + name + '"]');
          $field.removeClass('hidden');
          $label.removeClass('hidden');
          $cell.removeClass('hidden-cell');
        } else {
          this.$el.find('.cell[data-name="' + name + '"]').removeClass('hidden-cell');
          this.$el.find('.field[data-name="' + name + '"]').removeClass('hidden');
          this.$el.find('label.control-label[data-name="' + name + '"]').removeClass('hidden');
        }
      };
      if (this.isRendered()) {
        processHtml();
      } else {
        this.once('after:render', () => {
          processHtml();
        });
      }
      const view = this.getFieldView(name);
      if (view) {
        if (!view.disabledLocked) {
          view.setNotDisabled();
        }
      }
    }

    /**
     * Get field views.
     *
     * @return {Object.<string, module:views/fields/base>}
     */
    getFieldViews() {
      const fieldViews = {};
      for (const viewKey in this.nestedViews) {
        // noinspection JSUnresolvedReference
        const name = this.nestedViews[viewKey].name;
        fieldViews[name] = this.nestedViews[viewKey];
      }
      return fieldViews;
    }

    /**
     * Get a field view.
     *
     * @param {string} name A field name.
     * @return {module:views/fields/base}
     */
    getFieldView(name) {
      return (this.getFieldViews() || {})[name];
    }

    /**
     * For backward compatibility.
     *
     * @todo Remove.
     */
    getView(name) {
      let view = super.getView(name);
      if (!view) {
        view = this.getFieldView(name);
      }
      return view;
    }
  }

  // noinspection JSUnusedGlobalSymbols
  var _default = _exports.default = DetailMiddleRecordView;
});

define("views/record/deleted-detail", ["exports", "views/record/detail"], function (_exports, _detail) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _detail = _interopRequireDefault(_detail);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class DeletedDetailRecordView extends _detail.default {
    bottomView = null;
    sideView = 'views/record/deleted-detail-side';
    setupBeforeFinal() {
      super.setupBeforeFinal();
      this.buttonList = [];
      this.dropdownItemList = [];
      this.addDropdownItem({
        name: 'restoreDeleted',
        label: 'Restore'
      });
    }

    // noinspection JSUnusedGlobalSymbols
    actionRestoreDeleted() {
      Espo.Ui.notifyWait();
      Espo.Ajax.postRequest(this.model.entityType + '/action/restoreDeleted', {
        id: this.model.id
      }).then(() => {
        Espo.Ui.notify(false);
        this.model.set('deleted', false);
        this.model.trigger('after:restore-deleted');
      });
    }
  }
  var _default = _exports.default = DeletedDetailRecordView;
});

define("views/record/deleted-detail-side", ["exports", "views/record/detail-side"], function (_exports, _detailSide) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _detailSide = _interopRequireDefault(_detailSide);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class DeletedDetailSideRecordView extends _detailSide.default {
    additionalPanelsDisabled = true;
  }

  // noinspection JSUnusedGlobalSymbols
  var _default = _exports.default = DeletedDetailSideRecordView;
});

define("views/record/row-actions/view-only", ["exports", "views/record/row-actions/default"], function (_exports, _default2) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _default2 = _interopRequireDefault(_default2);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ViewOnlyRowActionsView extends _default2.default {
    getActionList() {
      return [{
        action: 'quickView',
        label: 'View',
        data: {
          id: this.model.id
        },
        link: '#' + this.model.entityType + '/view/' + this.model.id,
        groupIndex: 0,
        iconClass: _default2.default.ICON_CLASS_VIEW
      }];
    }
  }
  var _default = _exports.default = ViewOnlyRowActionsView;
});

define("views/record/row-actions/view-and-remove", ["exports", "views/record/row-actions/default"], function (_exports, _default2) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _default2 = _interopRequireDefault(_default2);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ViewAndRemoveRowActionsView extends _default2.default {
    getActionList() {
      /** @type {import('views/record/list').RowAction[]} */
      const actionList = [{
        action: 'quickView',
        label: 'View',
        data: {
          id: this.model.id
        },
        link: '#' + this.model.entityType + '/view/' + this.model.id,
        groupIndex: 0,
        iconClass: 'fas fa-expand'
      }];
      if (this.options.acl.delete) {
        actionList.push({
          action: 'quickRemove',
          label: 'Remove',
          data: {
            id: this.model.id
          },
          groupIndex: 0,
          iconClass: 'fas fa-times'
        });
      }
      return actionList;
    }
  }
  var _default = _exports.default = ViewAndRemoveRowActionsView;
});

define("views/record/row-actions/view-and-edit", ["exports", "views/record/row-actions/default"], function (_exports, _default2) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _default2 = _interopRequireDefault(_default2);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ViewAndEditRowActionsView extends _default2.default {
    getActionList() {
      let list = [{
        action: 'quickView',
        label: 'View',
        data: {
          id: this.model.id
        },
        link: '#' + this.model.entityType + '/view/' + this.model.id,
        groupIndex: 0,
        iconClass: _default2.default.ICON_CLASS_VIEW
      }];
      if (this.options.acl.edit) {
        list = list.concat([{
          action: 'quickEdit',
          label: 'Edit',
          data: {
            id: this.model.id
          },
          link: '#' + this.model.entityType + '/edit/' + this.model.id,
          groupIndex: 0,
          iconClass: _default2.default.ICON_CLASS_EDIT
        }]);
      }
      this.getAdditionalActionList().forEach(item => list.push(item));
      return list;
    }
  }
  var _default = _exports.default = ViewAndEditRowActionsView;
});

define("views/record/row-actions/remove-only", ["exports", "views/record/row-actions/default"], function (_exports, _default2) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _default2 = _interopRequireDefault(_default2);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class RemoveOnlyRowActionsView extends _default2.default {
    getActionList() {
      if (this.options.acl.delete) {
        return [{
          action: 'quickRemove',
          label: 'Remove',
          data: {
            id: this.model.id
          },
          groupIndex: 0,
          iconClass: _default2.default.ICON_CLASS_REMOVE
        }];
      }
      return [];
    }
  }
  var _default = _exports.default = RemoveOnlyRowActionsView;
});

define("views/record/row-actions/relationship-view-only", ["exports", "views/record/row-actions/relationship"], function (_exports, _relationship) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _relationship = _interopRequireDefault(_relationship);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class RelationshipViewOnlyActionsView extends _relationship.default {
    getActionList() {
      return [{
        action: 'viewRelated',
        label: 'View',
        data: {
          id: this.model.id
        },
        link: '#' + this.model.entityType + '/view/' + this.model.id,
        groupIndex: 0,
        iconClass: _relationship.default.ICON_CLASS_VIEW
      }];
    }
  }
  var _default = _exports.default = RelationshipViewOnlyActionsView;
});

define("views/record/row-actions/relationship-view-and-unlink", ["exports", "views/record/row-actions/relationship"], function (_exports, _relationship) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _relationship = _interopRequireDefault(_relationship);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class RelationshipViewAndUnlinkActionsView extends _relationship.default {
    getActionList() {
      const list = [{
        action: 'quickView',
        label: 'View',
        data: {
          id: this.model.id
        },
        link: '#' + this.model.entityType + '/view/' + this.model.id,
        groupIndex: 0,
        iconClass: _relationship.default.ICON_CLASS_VIEW
      }];
      if (this.options.acl.edit && !this.options.unlinkDisabled) {
        list.push({
          action: 'unlinkRelated',
          label: 'Unlink',
          data: {
            id: this.model.id
          },
          groupIndex: 1
        });
      }
      return list;
    }
  }
  var _default = _exports.default = RelationshipViewAndUnlinkActionsView;
});

define("views/record/row-actions/relationship-view-and-edit", ["exports", "views/record/row-actions/relationship"], function (_exports, _relationship) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _relationship = _interopRequireDefault(_relationship);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class RelationshipViewAndEditActionsView extends _relationship.default {
    getActionList() {
      const list = [{
        action: 'quickView',
        label: 'View',
        data: {
          id: this.model.id
        },
        link: '#' + this.model.entityType + '/view/' + this.model.id,
        groupIndex: 0,
        iconClass: _relationship.default.ICON_CLASS_VIEW
      }];
      if (this.options.acl.edit) {
        list.push({
          action: 'quickEdit',
          label: 'Edit',
          data: {
            id: this.model.id
          },
          link: '#' + this.model.entityType + '/edit/' + this.model.id,
          groupIndex: 0,
          iconClass: _relationship.default.ICON_CLASS_EDIT
        });
      }
      return list;
    }
  }
  var _default = _exports.default = RelationshipViewAndEditActionsView;
});

define("views/record/row-actions/relationship-unlink-only", ["exports", "views/record/row-actions/relationship"], function (_exports, _relationship) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _relationship = _interopRequireDefault(_relationship);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class RelationshipUnlinkOnlyActionsView extends _relationship.default {
    getActionList() {
      if (this.options.acl.edit && !this.options.unlinkDisabled) {
        return [{
          action: 'unlinkRelated',
          label: 'Unlink',
          data: {
            id: this.model.id
          },
          groupIndex: 1
        }];
      }
      return [];
    }
  }

  // noinspection JSUnusedGlobalSymbols
  var _default = _exports.default = RelationshipUnlinkOnlyActionsView;
});

define("views/record/row-actions/relationship-remove-only", ["exports", "views/record/row-actions/relationship"], function (_exports, _relationship) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _relationship = _interopRequireDefault(_relationship);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class RelationshipRemoveOnlyActionsView extends _relationship.default {
    getActionList() {
      if (this.options.acl.delete) {
        return [{
          action: 'removeRelated',
          label: 'Remove',
          data: {
            id: this.model.id
          },
          groupIndex: 0,
          iconClass: _relationship.default.ICON_CLASS_REMOVE
        }];
      }
      return [];
    }
  }

  // noinspection JSUnusedGlobalSymbols
  var _default = _exports.default = RelationshipRemoveOnlyActionsView;
});

define("views/record/row-actions/relationship-no-unlink", ["exports", "views/record/row-actions/relationship"], function (_exports, _relationship) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _relationship = _interopRequireDefault(_relationship);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class RelationshipNoUnlinkActionsView extends _relationship.default {
    getActionList() {
      let list = [{
        action: 'quickView',
        label: 'View',
        data: {
          id: this.model.id
        },
        link: '#' + this.model.entityType + '/view/' + this.model.id,
        groupIndex: 0,
        iconClass: _relationship.default.ICON_CLASS_VIEW
      }];
      if (this.options.acl.edit) {
        list = list.concat([{
          action: 'quickEdit',
          label: 'Edit',
          data: {
            id: this.model.id
          },
          link: '#' + this.model.entityType + '/edit/' + this.model.id,
          groupIndex: 0,
          iconClass: _relationship.default.ICON_CLASS_EDIT
        }]);
      }
      if (this.options.acl.delete) {
        list.push({
          action: 'removeRelated',
          label: 'Remove',
          data: {
            id: this.model.id
          },
          groupIndex: 0,
          iconClass: _relationship.default.ICON_CLASS_REMOVE
        });
      }
      return list;
    }
  }

  // noinspection JSUnusedGlobalSymbols
  var _default = _exports.default = RelationshipNoUnlinkActionsView;
});

define("views/record/row-actions/relationship-no-remove", ["exports", "views/record/row-actions/relationship"], function (_exports, _relationship) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _relationship = _interopRequireDefault(_relationship);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  // noinspection JSUnusedGlobalSymbols
  class UserRelationshipNoRemoveRowActionsView extends _relationship.default {
    getActionList() {
      const list = [];
      list.push({
        action: 'quickView',
        label: 'View',
        data: {
          id: this.model.id
        },
        link: `#${this.model.entityType}/view/${this.model.id}`,
        groupIndex: 0,
        iconClass: _relationship.default.ICON_CLASS_VIEW
      });
      if (this.options.acl.edit) {
        list.push({
          action: 'quickEdit',
          label: 'Edit',
          data: {
            id: this.model.id
          },
          link: `#${this.model.entityType}/edit/${this.model.id}`,
          groupIndex: 0,
          iconClass: _relationship.default.ICON_CLASS_EDIT
        });
        if (!this.options.unlinkDisabled) {
          list.push({
            action: 'unlinkRelated',
            label: 'Unlink',
            data: {
              id: this.model.id
            },
            groupIndex: 1
          });
        }
      }
      return list;
    }
  }
  _exports.default = UserRelationshipNoRemoveRowActionsView;
});

define("views/record/row-actions/relationship-edit-and-remove", ["exports", "views/record/row-actions/relationship"], function (_exports, _relationship) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _relationship = _interopRequireDefault(_relationship);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class RelationshipEditAndRemoveActionsView extends _relationship.default {
    getActionList() {
      const list = [];
      if (this.options.acl.edit) {
        list.push({
          action: 'quickEdit',
          label: 'Edit',
          data: {
            id: this.model.id
          },
          groupIndex: 0,
          iconClass: RelationshipEditAndRemoveActionsView.ICON_CLASS_EDIT
        });
      }
      if (this.options.acl.delete) {
        list.push({
          action: 'quickRemove',
          label: 'Remove',
          data: {
            id: this.model.id
          },
          groupIndex: 0,
          iconClass: _relationship.default.ICON_CLASS_REMOVE
        });
      }
      return list;
    }
  }
  var _default = _exports.default = RelationshipEditAndRemoveActionsView;
});

define("views/record/row-actions/empty", ["exports", "views/record/row-actions/default"], function (_exports, _default2) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _default2 = _interopRequireDefault(_default2);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EmptyRowActionsView extends _default2.default {
    getActionList() {
      return [];
    }
  }
  var _default = _exports.default = EmptyRowActionsView;
});

define("views/record/row-actions/edit-and-remove", ["exports", "views/record/row-actions/default"], function (_exports, _default2) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _default2 = _interopRequireDefault(_default2);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EditAndRemoveRowActionsView extends _default2.default {
    getActionList() {
      let list = [];
      if (this.options.acl.edit) {
        list.push({
          action: 'quickEdit',
          label: 'Edit',
          data: {
            id: this.model.id
          },
          link: '#' + this.model.entityType + '/edit/' + this.model.id,
          groupIndex: 0,
          iconClass: _default2.default.ICON_CLASS_EDIT
        });
      }
      if (this.options.acl.delete) {
        list.push({
          action: 'quickRemove',
          label: 'Remove',
          data: {
            id: this.model.id
          },
          groupIndex: 0,
          iconClass: _default2.default.ICON_CLASS_REMOVE
        });
      }
      return list;
    }
  }
  var _default = _exports.default = EditAndRemoveRowActionsView;
});

define("views/record/row-actions/default-kanban", ["exports", "views/record/row-actions/default"], function (_exports, _default2) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _default2 = _interopRequireDefault(_default2);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class DefaultKanbanRowActionsView extends _default2.default {
    getActionList() {
      const list = [{
        action: 'quickView',
        label: 'View',
        data: {
          id: this.model.id
        },
        link: '#' + this.model.entityType + '/view/' + this.model.id,
        groupIndex: 0,
        iconClass: _default2.default.ICON_CLASS_VIEW
      }];
      if (this.options.moveOverRowAction && this.options.statusFieldIsEditable) {
        list.push({
          action: 'moveOver',
          label: 'Move Over',
          data: {
            id: this.model.id
          },
          groupIndex: 1
        });
      }
      if (this.options.acl.edit) {
        list.push({
          action: 'quickEdit',
          label: 'Edit',
          data: {
            id: this.model.id
          },
          link: '#' + this.model.entityType + '/edit/' + this.model.id,
          groupIndex: 0,
          iconClass: _default2.default.ICON_CLASS_EDIT
        });
      }
      this.getAdditionalActionList().forEach(item => list.push(item));
      if (this.options.acl.delete) {
        list.push({
          action: 'quickRemove',
          label: 'Remove',
          data: {
            id: this.model.id
          },
          groupIndex: 0,
          iconClass: _default2.default.ICON_CLASS_REMOVE
        });
      }
      return list;
    }
  }
  var _default = _exports.default = DefaultKanbanRowActionsView;
});

define("views/preferences/edit", ["exports", "views/edit"], function (_exports, _edit) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _edit = _interopRequireDefault(_edit);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _edit.default {
    userName = '';
    setup() {
      super.setup();
      this.userName = this.model.get('name');
    }
    getHeader() {
      return this.buildHeaderHtml([$('<span>').text(this.translate('Preferences')), $('<span>').text(this.userName)]);
    }
    updatePageTitle() {
      let title = this.getLanguage().translate(this.scope, 'scopeNames');
      if (this.model.id !== this.getUser().id && this.userName) {
        title += ' · ' + this.userName;
      }
      this.setPageTitle(title);
    }
  }
  _exports.default = _default;
});

define("views/preferences/record/edit", ["exports", "views/record/edit"], function (_exports, _edit) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _edit = _interopRequireDefault(_edit);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class PreferencesEditRecordView extends _edit.default {
    sideView = null;
    saveAndContinueEditingAction = false;
    buttonList = [{
      name: 'save',
      label: 'Save',
      style: 'primary'
    }, {
      name: 'cancel',
      label: 'Cancel'
    }];
    setup() {
      this.dynamicLogicDefs = Espo.Utils.cloneDeep(this.getMetadata().get(`logicDefs.Preferences`));
      super.setup();
      const model = /** @type {import('models/preferences').default} */this.model;
      this.addDropdownItem({
        name: 'reset',
        text: this.getLanguage().translate('Reset to Default', 'labels', 'Admin'),
        style: 'danger',
        onClick: () => this.actionReset()
      });
      const forbiddenEditFieldList = this.getAcl().getScopeForbiddenFieldList('Preferences', 'edit');
      if (!forbiddenEditFieldList.includes('dashboardLayout') && !model.isPortal()) {
        this.addDropdownItem({
          name: 'resetDashboard',
          text: this.getLanguage().translate('Reset Dashboard to Default', 'labels', 'Preferences'),
          onClick: () => this.actionResetDashboard()
        });
      }
      if (model.isPortal()) {
        this.layoutName = 'detailPortal';
      }
      if (this.model.id === this.getUser().id) {
        const preferencesModel = this.getPreferences();
        this.on('save', (a, attributeList) => {
          const data = this.model.getClonedAttributes();
          delete data['smtpPassword'];
          preferencesModel.set(data);
          preferencesModel.trigger('update', attributeList);
        });
      }
      if (!this.getUser().isAdmin() || model.isPortal()) {
        this.hidePanel('dashboard');
        this.hideField('dashboardLayout');
      }
      this.controlFollowCreatedEntityListVisibility();
      this.listenTo(this.model, 'change:followCreatedEntities', this.controlFollowCreatedEntityListVisibility);
      this.controlColorsField();
      this.listenTo(this.model, 'change:scopeColorsDisabled', () => this.controlColorsField());
      let hideNotificationPanel = true;
      if (!this.getConfig().get('assignmentEmailNotifications') || model.isPortal()) {
        this.hideField('receiveAssignmentEmailNotifications', true);
        this.hideField('assignmentEmailNotificationsIgnoreEntityTypeList', true);
      } else {
        hideNotificationPanel = false;
      }
      if ((this.getConfig().get('assignmentEmailNotificationsEntityList') || []).length === 0) {
        this.hideField('assignmentEmailNotificationsIgnoreEntityTypeList', true);
      }
      if ((this.getConfig().get('assignmentNotificationsEntityList') || []).length === 0 || model.isPortal()) {
        this.hideField('assignmentNotificationsIgnoreEntityTypeList');
      } else {
        hideNotificationPanel = false;
      }
      if (this.getConfig().get('emailForceUseExternalClient')) {
        this.hideField('emailUseExternalClient');
      }
      if (!this.getConfig().get('mentionEmailNotifications') || model.isPortal()) {
        this.hideField('receiveMentionEmailNotifications');
      } else {
        hideNotificationPanel = false;
      }
      if (!this.getConfig().get('streamEmailNotifications') && !model.isPortal()) {
        this.hideField('receiveStreamEmailNotifications');
      } else if (!this.getConfig().get('portalStreamEmailNotifications') && model.isPortal()) {
        this.hideField('receiveStreamEmailNotifications');
      } else {
        hideNotificationPanel = false;
      }
      if (hideNotificationPanel) {
        this.hidePanel('notifications');
      }
      if (this.getConfig().get('userThemesDisabled')) {
        this.hideField('theme');
      }
      this.on('save', /** Record */initialAttributes => {
        if (this.model.get('language') !== initialAttributes.language || this.model.get('theme') !== initialAttributes.theme || (this.model.get('themeParams') || {}).navbar !== (initialAttributes.themeParams || {}).navbar || this.model.get('pageContentWidth') !== initialAttributes.pageContentWidth) {
          this.setConfirmLeaveOut(false);
          window.location.reload();
        }
      });
    }
    controlFollowCreatedEntityListVisibility() {
      if (!this.model.get('followCreatedEntities')) {
        this.showField('followCreatedEntityTypeList');
      } else {
        this.hideField('followCreatedEntityTypeList');
      }
    }
    controlColorsField() {
      if (this.model.get('scopeColorsDisabled')) {
        this.hideField('tabColorsDisabled');
      } else {
        this.showField('tabColorsDisabled');
      }
    }
    actionReset() {
      this.confirm(this.translate('resetPreferencesConfirmation', 'messages'), () => {
        Espo.Ajax.deleteRequest(`Preferences/${this.model.id}`).then(data => {
          Espo.Ui.success(this.translate('resetPreferencesDone', 'messages'));
          this.model.set(data);
          for (const attribute in data) {
            this.setInitialAttributeValue(attribute, data[attribute]);
          }
          this.getPreferences().set(this.model.getClonedAttributes());
          this.getPreferences().trigger('update');
          this.setIsNotChanged();
        });
      });
    }
    actionResetDashboard() {
      this.confirm(this.translate('confirmation', 'messages'), () => {
        Espo.Ajax.postRequest('Preferences/action/resetDashboard', {
          id: this.model.id
        }).then(data => {
          const isChanged = this.isChanged;
          Espo.Ui.success(this.translate('Done'));
          this.model.set(data);
          for (const attribute in data) {
            this.setInitialAttributeValue(attribute, data[attribute]);
          }
          this.getPreferences().set(this.model.getClonedAttributes());
          this.getPreferences().trigger('update');
          if (!isChanged) {
            this.setIsNotChanged();
          }
        });
      });
    }
    exit(after) {
      if (after === 'cancel') {
        let url = `#User/view/${this.model.id}`;
        if (!this.getAcl().checkModel(this.getUser())) {
          url = '#';
        }
        this.getRouter().navigate(url, {
          trigger: true
        });
      }
    }
    handleShortcutKeyCtrlS(e) {
      this.handleShortcutKeyCtrlEnter(e);
    }
  }
  var _default = _exports.default = PreferencesEditRecordView;
});

define("views/preferences/fields/week-start", ["exports", "views/fields/enum-int"], function (_exports, _enumInt) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _enumInt = _interopRequireDefault(_enumInt);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _enumInt.default {
    setupOptions() {
      this.params.options = Espo.Utils.clone(this.params.options);
      this.params.options.unshift(-1);
      this.translatedOptions = {};
      const dayList = this.getLanguage().get('Global', 'lists', 'dayNames') || [];
      dayList.forEach((item, i) => this.translatedOptions[i] = item);
      const defaultWeekStart = this.getConfig().get('weekStart');
      this.translatedOptions[-1] = `${this.translate('Default')} · ${dayList[defaultWeekStart]}`;
    }
  }
  _exports.default = _default;
});

define("views/preferences/fields/time-zone", ["exports", "views/fields/enum"], function (_exports, _enum) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _enum = _interopRequireDefault(_enum);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _enum.default {
    setupOptions() {
      this.params.options = Espo.Utils.clone(this.getHelper().getAppParam('timeZoneList')) || [];
      this.translatedOptions = this.params.options.reduce((o, it) => {
        o[it] = it.replace('/', ' / ');
        return o;
      }, {});

      /** @type {string} */
      const systemValue = this.getConfig().get('timeZone') ?? '';
      const systemLabel = systemValue.replace('/', ' / ');
      this.params.options.unshift('');
      this.translatedOptions[''] = `${this.translate('Default')} · ${systemLabel}`;
    }
  }
  _exports.default = _default;
});

define("views/preferences/fields/time-format", ["exports", "views/fields/enum"], function (_exports, _enum) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _enum = _interopRequireDefault(_enum);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _enum.default {
    setupOptions() {
      this.params.options = Espo.Utils.clone(this.getMetadata().get(['app', 'dateTime', 'timeFormatList']) || []);
      this.params.options.unshift('');
      this.translatedOptions = this.translatedOptions || {};
      this.translatedOptions[''] = `${this.translate('Default')} · ${this.getConfig().get('timeFormat')}`;
    }
  }
  _exports.default = _default;
});

define("views/preferences/fields/theme", ["exports", "views/settings/fields/theme"], function (_exports, _theme) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _theme = _interopRequireDefault(_theme);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _theme.default {
    setupOptions() {
      this.params.options = Object.keys(this.getMetadata().get('themes') || {}).sort((v1, v2) => {
        if (v2 === 'EspoRtl') {
          return -1;
        }
        return this.translate(v1, 'themes').localeCompare(this.translate(v2, 'themes'));
      });
      this.params.options.unshift('');
    }
    setupTranslation() {
      super.setupTranslation();
      this.translatedOptions = this.translatedOptions || {};
      const defaultTheme = this.getConfig().get('theme');
      const defaultTranslated = this.translatedOptions[defaultTheme] || defaultTheme;
      this.translatedOptions[''] = `${this.translate('Default')} · ${defaultTranslated}`;
    }
    afterRenderDetail() {
      const navbar = this.getNavbarValue() || this.getDefaultNavbar();
      if (navbar) {
        this.$el.append(' ').append($('<span>').addClass('text-muted chevron-right')).append(' ').append($('<span>').text(this.translate(navbar, 'themeNavbars')));
      }
    }
  }
  _exports.default = _default;
});

define("views/preferences/fields/tab-list", ["exports", "views/settings/fields/tab-list"], function (_exports, _tabList) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _tabList = _interopRequireDefault(_tabList);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _tabList.default {
    setup() {
      super.setup();
      this.params.options = this.params.options.filter(scope => {
        if (scope === '_delimiter_' || scope === 'Home') {
          return true;
        }
        const defs = this.getMetadata().get(['scopes', scope]);
        if (!defs) {
          return;
        }
        if (defs.disabled) {
          return;
        }
        if (defs.acl) {
          return this.getAcl().check(scope);
        }
        if (defs.tabAclPermission) {
          const level = this.getAcl().getPermissionLevel(defs.tabAclPermission);
          return level && level !== 'no';
        }
        return true;
      });
    }
  }
  _exports.default = _default;
});

define("views/preferences/fields/signature", ["exports", "views/fields/wysiwyg"], function (_exports, _wysiwyg) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _wysiwyg = _interopRequireDefault(_wysiwyg);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _wysiwyg.default {
    fetchEmptyValueAsNull = true;
    setupToolbar() {
      super.setupToolbar();
      const codeviewName = this.getConfig().get('wysiwygCodeEditorDisabled') ? 'codeview' : 'aceCodeview';
      this.toolbar = [["style", ["bold", "italic", "underline", "clear"]], ["color", ["color"]], ["height", ["height"]], ['table', ['espoLink']], ["misc", [codeviewName, "fullscreen"]]];
    }
  }
  _exports.default = _default;
});

define("views/preferences/fields/language", ["exports", "views/fields/enum"], function (_exports, _enum) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _enum = _interopRequireDefault(_enum);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _enum.default {
    setupOptions() {
      this.params.options = Espo.Utils.clone(this.getMetadata().get(['app', 'language', 'list']) || []).sort((v1, v2) => {
        return this.getLanguage().translateOption(v1, 'language').localeCompare(this.getLanguage().translateOption(v2, 'language'));
      });
      this.params.options.unshift('');
      this.translatedOptions = Espo.Utils.clone(this.getLanguage().translate('language', 'options') || {});
      const defaultTranslated = this.translatedOptions[this.getConfig().get('language')] || this.getConfig().get('language');
      this.translatedOptions[''] = `${this.translate('Default')} · ${defaultTranslated}`;
    }
  }
  _exports.default = _default;
});

define("views/preferences/fields/default-currency", ["exports", "views/fields/enum"], function (_exports, _enum) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _enum = _interopRequireDefault(_enum);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _enum.default {
    setupOptions() {
      this.params.options = Espo.Utils.clone(this.getConfig().get('currencyList') || []);
      this.params.options.unshift('');
      this.translatedOptions = this.translatedOptions || {};
      this.translatedOptions[''] = `${this.translate('Default')} · ${this.getConfig().get('defaultCurrency')}`;
    }
  }
  _exports.default = _default;
});

define("views/preferences/fields/date-format", ["exports", "views/fields/enum"], function (_exports, _enum) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _enum = _interopRequireDefault(_enum);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _enum.default {
    setupOptions() {
      this.params.options = Espo.Utils.clone(this.getMetadata().get(['app', 'dateTime', 'dateFormatList']) || []);
      this.params.options.unshift('');
      this.translatedOptions = this.translatedOptions || {};
      this.translatedOptions[''] = `${this.translate('Default')} · ${this.getConfig().get('dateFormat')}`;
    }
  }
  _exports.default = _default;
});

define("views/preferences/fields/dashboard-tab-list", ["exports", "views/fields/array"], function (_exports, _array) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _array = _interopRequireDefault(_array);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  // noinspection JSUnusedGlobalSymbols
  class _default extends _array.default {
    maxItemLength = 36;
    setup() {
      super.setup();
      this.translatedOptions = {};
      const list = this.model.get(this.name) || [];
      list.forEach(value => {
        this.translatedOptions[value] = value;
      });
      this.validations.push('uniqueLabel');
    }
    getItemHtml(value) {
      value = value.toString();
      const translatedValue = this.translatedOptions[value] || value;
      return $('<div>').addClass('list-group-item link-with-role form-inline').attr('data-value', value).append((() => {
        const span = document.createElement('span');
        span.className = 'drag-handle pull-left';
        span.append((() => {
          const span = document.createElement('span');
          span.className = 'fas fa-grip fa-sm';
          return span;
        })());
        return span;
      })()).append($('<div>').addClass('pull-left').css('width', 'calc(100% - var(--36px))').css('display', 'inline-block').append($('<input>').attr('maxLength', this.maxItemLength).attr('data-name', 'translatedValue').attr('data-value', value).addClass('role form-control input-sm').attr('value', translatedValue).css('width', 'calc(100% - var(--4px))'))).append($('<div>').css('width', 'var(--18px)').css('display', 'inline-block').css('vertical-align', 'top').append($('<a>').attr('role', 'button').attr('tabindex', '0').addClass('pull-right').attr('data-value', value).attr('data-action', 'removeValue').append($('<span>').addClass('fas fa-times')))).get(0).outerHTML;
    }

    /**
     * @private
     * @return {boolean}
     */
    validateUniqueLabel() {
      const keyList = this.model.get(this.name) || [];
      const labels = this.model.get('translatedOptions') || {};
      const metLabelList = [];
      for (const key of keyList) {
        const label = labels[key];
        if (!label) {
          return true;
        }
        if (metLabelList.indexOf(label) !== -1) {
          return true;
        }
        metLabelList.push(label);
      }
      return false;
    }
    fetch() {
      const data = super.fetch();
      data.translatedOptions = {};
      (data[this.name] || []).forEach(value => {
        const valueInternal = CSS.escape(value);
        data.translatedOptions[value] = this.$el.find(`input[data-name="translatedValue"][data-value="${valueInternal}"]`).val() || value;
      });
      return data;
    }
  }
  _exports.default = _default;
});

define("views/preferences/fields/calendar-slot-duration", ["exports", "views/fields/enum-int"], function (_exports, _enumInt) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _enumInt = _interopRequireDefault(_enumInt);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  // noinspection JSUnusedGlobalSymbols
  class _default extends _enumInt.default {
    setupOptions() {
      super.setupOptions();
      this.translatedOptions = {};
      this.translatedOptions[''] = this.translate('Default');
    }
  }
  _exports.default = _default;
});

define("views/preferences/fields/calendar-scroll-hour", ["exports", "views/fields/enum-int", "moment"], function (_exports, _enumInt, _moment) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _enumInt = _interopRequireDefault(_enumInt);
  _moment = _interopRequireDefault(_moment);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class PreferencesCalendarScrollHourView extends _enumInt.default {
    setupOptions() {
      super.setupOptions();
      this.translatedOptions = {};
      this.translatedOptions[''] = this.translate('Default');
      const timeFormat = this.getDateTime().getTimeFormat();
      const today = this.getDateTime().getToday();
      this.params.options.forEach(item => {
        if (item === '') {
          return;
        }
        const itemString = today + ' ' + item.toString().padStart(2, '0') + ':00';
        this.translatedOptions[item] = _moment.default.utc(itemString).format(timeFormat);
      });
    }
  }

  // noinspection JSUnusedGlobalSymbols
  var _default = _exports.default = PreferencesCalendarScrollHourView;
});

define("views/preferences/fields/auto-follow-entity-type-list", ["exports", "views/fields/multi-enum"], function (_exports, _multiEnum) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _multiEnum = _interopRequireDefault(_multiEnum);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  // noinspection JSUnusedGlobalSymbols
  class _default extends _multiEnum.default {
    setup() {
      this.params.options = Object.keys(this.getMetadata().get('scopes')).filter(scope => {
        if (this.getMetadata().get(`scopes.${scope}.disabled`)) {
          return;
        }
        return this.getMetadata().get(`scopes.${scope}.entity`) && this.getMetadata().get(`scopes.${scope}.stream`);
      }).sort((v1, v2) => {
        return this.translate(v1, 'scopeNamesPlural').localeCompare(this.translate(v2, 'scopeNamesPlural'));
      });
      super.setup();
    }
  }
  _exports.default = _default;
});

define("views/preferences/fields/assignment-notifications-ignore-entity-type-list", ["exports", "views/fields/checklist"], function (_exports, _checklist) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _checklist = _interopRequireDefault(_checklist);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  // noinspection JSUnusedGlobalSymbols
  class _default extends _checklist.default {
    isInversed = true;
    setupOptions() {
      this.params.options = Espo.Utils.clone(this.getConfig().get('assignmentNotificationsEntityList')) || [];
    }
  }
  _exports.default = _default;
});

define("views/preferences/fields/assignment-email-notifications-ignore-entity-type-list", ["exports", "views/fields/checklist"], function (_exports, _checklist) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _checklist = _interopRequireDefault(_checklist);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  // noinspection JSUnusedGlobalSymbols
  class _default extends _checklist.default {
    isInversed = true;
    setupOptions() {
      this.params.options = Espo.Utils.clone(this.getConfig().get('assignmentEmailNotificationsEntityList')) || [];
    }
  }
  _exports.default = _default;
});

define("views/portal-user/list", ["exports", "views/list"], function (_exports, _list) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _list = _interopRequireDefault(_list);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class PortalUserListView extends _list.default {
    defaultOrderBy = 'createdAt';
    defaultOrder = 'desc';
    async actionCreate(data) {
      /**
       * @type {
       *     module:views/modals/select-records~Options &
       *     {onSkip: function()}
       * }
       */
      const options = {
        entityType: 'Contact',
        primaryFilterName: 'notPortalUsers',
        createButton: false,
        mandatorySelectAttributeList: ['salutationName', 'firstName', 'lastName', 'accountName', 'accountId', 'emailAddress', 'emailAddressData', 'phoneNumber', 'phoneNumberData'],
        onSelect: models => {
          const model = models[0];
          const attributes = {};
          attributes.contactId = model.id;
          attributes.contactName = model.attributes.name;
          if (model.attributes.accountId) {
            const names = {};
            names[model.attributes.accountId] = model.attributes.accountName;
            attributes.accountsIds = [model.attributes.accountId];
            attributes.accountsNames = names;
          }
          attributes.firstName = model.get('firstName');
          attributes.lastName = model.get('lastName');
          attributes.salutationName = model.get('salutationName');
          attributes.emailAddress = model.get('emailAddress');
          attributes.emailAddressData = model.get('emailAddressData');
          attributes.phoneNumber = model.get('phoneNumber');
          attributes.phoneNumberData = model.get('phoneNumberData');
          attributes.userName = attributes.emailAddress;
          if (attributes.userName) {
            attributes.userName = attributes.userName.toLowerCase();
          }
          attributes.type = 'portal';
          const url = `#${this.scope}/create`;
          this.getRouter().dispatch(this.scope, 'create', {
            attributes: attributes
          });
          this.getRouter().navigate(url, {
            trigger: false
          });
        },
        onSkip: () => {
          const attributes = {
            type: 'portal'
          };
          const url = `#${this.scope}/create`;
          this.getRouter().dispatch(this.scope, 'create', {
            attributes: attributes
          });
          this.getRouter().navigate(url, {
            trigger: false
          });
        }
      };

      // As the file is supposed to bundled separately, resort to async module loading.
      /** @type {typeof import('modules/crm/views/contact/modals/select-for-portal-user').default} */
      const SelectForPortalUserModalView = await Espo.loader.requirePromise('modules/crm/views/contact/modals/select-for-portal-user');
      const view = new SelectForPortalUserModalView(options);
      await this.assignView('modal', view);
      await view.render();
    }
  }
  var _default = _exports.default = PortalUserListView;
});

define("views/pipeline-stage/fields/mapped-status", ["exports", "views/fields/enum"], function (_exports, _enum) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _enum = _interopRequireDefault(_enum);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  // noinspection JSUnusedGlobalSymbols
  class PipelineStageMappedStatusFieldView extends _enum.default {
    setupOptions() {
      const entityType = this.model.attributes.entityType;
      const field = this.model.attributes.field;
      if (!entityType || !field) {
        return;
      }
      let sourceEntityType = entityType;
      let sourceField = field;
      const params = this.getMetadata().get(`entityDefs.${entityType}.fields.${field}`) ?? {};
      let optionsPath = params.optionsPath;
      const optionsReference = params.optionsReference;
      /** @var string[] */
      let options = params.options ?? [];
      const style = params.style;
      if (!optionsPath && optionsReference) {
        const [refEntityType, refField] = optionsReference.split('.');
        optionsPath = `entityDefs.${refEntityType}.fields.${refField}.options`;
        sourceEntityType = refEntityType;
        sourceField = refField;
      }
      if (optionsPath) {
        options = this.getMetadata().get(optionsPath);
      }
      options = options.filter(it => it);
      this.params.options = Espo.Utils.clone(options);
      this.styleMap = style ?? {};
      const pairs = this.params.options.map(item => [item, this.getLanguage().translateOption(item, sourceField, sourceEntityType)]);
      this.translatedOptions = Object.fromEntries(pairs);
    }
  }
  _exports.default = PipelineStageMappedStatusFieldView;
});

define("views/pipeline/detail", ["exports", "views/detail"], function (_exports, _detail) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _detail = _interopRequireDefault(_detail);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _detail.default {
    setup() {
      this.rootUrl = '#Admin/pipelines';
      super.setup();
    }
  }
  _exports.default = _default;
});

define("views/pipeline/record/panels/stages", ["exports", "views/record/panels/relationship"], function (_exports, _relationship) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _relationship = _interopRequireDefault(_relationship);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  // noinspection JSUnusedGlobalSymbols
  class _default extends _relationship.default {
    setup() {
      this.recordsPerPage = this.getConfig().get('recordsPerPage');
      super.setup();
    }
  }
  _exports.default = _default;
});

define("views/pipeline/fields/field", ["exports", "views/fields/enum"], function (_exports, _enum) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _enum = _interopRequireDefault(_enum);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _enum.default {
    getAttributeList() {
      return [...super.getAttributeList(), 'entityType'];
    }
    setup() {
      super.setup();
      this.model.onChange({
        owner: this,
        attributes: ['entityType'],
        callback: () => this.setupTranslation()
      });
    }
    setupTranslation() {
      const entityType = this.model.attributes.entityType;
      if (!entityType) {
        this.setTranslatedOptions({});
        return;
      }
      const field = this.getMetadata().get(`scopes.${entityType}.statusField`);
      if (!field) {
        this.setTranslatedOptions({});
        return;
      }
      this.setTranslatedOptions({
        [field]: this.translate(field, 'fields', entityType)
      });
    }
  }
  _exports.default = _default;
});

define("views/pipeline/fields/entity-type", ["exports", "views/fields/entity-type"], function (_exports, _entityType) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _entityType = _interopRequireDefault(_entityType);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _entityType.default {
    setup() {
      super.setup();
      if (this.model.attributes.entityType && !this.isListMode() && !this.isSearchMode()) {
        this.setReadOnly(true);
      }
    }
  }
  _exports.default = _default;
});

define("views/o-auth-provider/fields/authorization-params", ["exports", "views/fields/base"], function (_exports, _base) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * @type {{
   *     edit: import('ace-builds').edit,
   *     require: import('ace-builds').require,
   * }}
   */
  let ace;
  class OAuthProviderAuthorizationParamsFieldView extends _base.default {
    // language=Handlebars
    detailTemplateContent = `
        {{#if isNotEmpty}}
            <div id="{{containerId}}">{{value}}</div>
        {{else}}
            {{#if isSet}}
                <span class="none-value">{{translate 'None'}}</span>
            {{else}}
                <span class="loading-value"></span>
            {{/if}}
        {{/if}}
    `;

    // language=Handlebars
    editTemplateContent = `
        <div id="{{containerId}}">{{value}}</div>
    `;
    height = 46;
    maxLineDetailCount = 80;
    maxLineEditCount = 200;
    data() {
      const data = super.data();
      const value = this.model.attributes[this.name];
      data.containerId = this.containerId;
      data.isNotEmpty = value != null;
      data.isSet = value !== undefined;
      try {
        data.value = value ? JSON.stringify(value, null, '  ') : null;
      } catch (e) {
        data.value = null;
      }
      return data;
    }
    setup() {
      super.setup();
      this.height = this.options.height || this.params.height || this.height;
      this.maxLineDetailCount = this.options.maxLineDetailCount || this.params.maxLineDetailCount || this.maxLineDetailCount;
      this.maxLineEditCount = this.options.maxLineEditCount || this.params.maxLineEditCount || this.maxLineEditCount;
      this.containerId = 'editor-' + Math.floor(Math.random() * 10000 + 1).toString();
      if (this.mode === this.MODE_EDIT || this.mode === this.MODE_DETAIL) {
        this.wait(this.requireAce());
      }
      this.on('remove', () => {
        if (this.editor) {
          this.editor.destroy();
        }
      });
      this.validations.push(() => this.validateJson());
    }
    requireAce() {
      return Espo.loader.requirePromise('lib!ace').then(lib => {
        ace = lib;
        const list = [Espo.loader.requirePromise('lib!ace-ext-language_tools'), Espo.loader.requirePromise('lib!ace-mode-json')];
        if (this.getThemeManager().getParam('isDark')) {
          list.push(Espo.loader.requirePromise('lib!ace-theme-tomorrow_night'));
        }
        return Promise.all(list);
      });
    }
    afterRender() {
      super.afterRender();
      this.$editor = this.$el.find('#' + this.containerId);
      if (this.$editor.length && (this.mode === this.MODE_EDIT || this.mode === this.MODE_DETAIL || this.mode === this.MODE_LIST)) {
        this.$editor.css('fontSize', 'var(--font-size-base)');
        if (this.mode === this.MODE_EDIT) {
          this.$editor.css('minHeight', this.height + 'px');
        }
        const editor = this.editor = ace.edit(this.containerId);
        editor.setOptions({
          fontFamily: 'var(--font-family-monospace)'
        });
        editor.setFontSize('var(--font-size-base)');
        editor.container.style.lineHeight = 'var(--line-height-computed)';
        editor.renderer.updateFontSize();
        editor.setOptions({
          maxLines: this.mode === this.MODE_EDIT ? this.maxLineEditCount : this.maxLineDetailCount,
          enableLiveAutocompletion: true
        });
        if (this.getThemeManager().getParam('isDark')) {
          editor.setOptions({
            theme: 'ace/theme/tomorrow_night'
          });
        }
        if (this.isEditMode()) {
          editor.getSession().on('change', () => {
            this.trigger('change', {
              ui: true
            });
          });
          editor.getSession().setUseWrapMode(true);
        }
        if (this.isReadMode()) {
          editor.setReadOnly(true);
          editor.renderer.$cursorLayer.element.style.display = 'none';
          editor.renderer.setShowGutter(false);
        }
        editor.setShowPrintMargin(false);
        editor.getSession().setUseWorker(false);
        editor.commands.removeCommand('find');
        editor.setHighlightActiveLine(false);
        const Mode = ace.require('ace/mode/json').Mode;
        editor.session.setMode(new Mode());
      }
    }

    /**
     * @private
     * @return {boolean}
     */
    validateJson() {
      const raw = this.editor.getValue();
      if (!raw) {
        return false;
      }
      try {
        JSON.parse(raw);
      } catch (e) {
        const message = this.translate('Not valid');
        this.showValidationMessage(message, '.ace_editor');
        return true;
      }
      return false;
    }
    fetch() {
      let value = null;
      const raw = this.editor.getValue();
      if (!raw) {
        return {
          [this.name]: null
        };
      }
      try {
        value = JSON.parse(raw);
      } catch (e) {}
      return {
        [this.name]: value
      };
    }
  }
  _exports.default = OAuthProviderAuthorizationParamsFieldView;
});

define("views/o-auth-account/records/panels/connection", ["exports", "views/record/panels/side"], function (_exports, _side) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _side = _interopRequireDefault(_side);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class OAuthAccountConnectionPanelView extends _side.default {
    // language=Handlebars
    templateContent = `
        {{#if hasDisconnect}}
            <div class="margin-bottom">
                <span
                    class="label label-success label-md"
                >{{translate 'Connected' scope='ExternalAccount'}}</span>
            </div>
            <button
                class="btn btn-default"
                data-action="disconnect"
            >{{translate 'Disconnect' scope='ExternalAccount'}}</button>
        {{/if}}

        {{#if hasConnect}}
            <div class="margin-bottom">
                <span
                    class="label label-default label-md"
                >{{translate 'Disconnected' scope='ExternalAccount'}}</span>
            </div>
            <button
                class="btn btn-default"
                data-action="connect"
            >{{translate 'Connect' scope='ExternalAccount'}}</button>
        {{/if}}
    `;

    /**
     * @private
     * @type {boolean}
     */
    inProcess = false;
    data() {
      const isSet = this.model.attributes.hasAccessToken !== undefined;
      const hasDisconnect = !this.inProcess && isSet && this.model.attributes.hasAccessToken;
      const hasConnect = !this.inProcess && isSet && !this.model.attributes.hasAccessToken && this.model.attributes.providerIsActive;

      // noinspection JSValidateTypes
      return {
        hasDisconnect,
        hasConnect
      };
    }
    setup() {
      super.setup();
      this.listenTo(this.model, 'sync', () => this.reRender());
      this.addActionHandler('connect', () => this.actionConnect());
      this.addActionHandler('disconnect', () => this.actionDisconnect());
    }

    /**
     * @private
     */
    async actionDisconnect() {
      this.inProcess = true;
      await this.reRender();
      Espo.Ui.notifyWait();
      await Espo.Ajax.deleteRequest(`OAuth/${this.model.id}/connection`);
      await this.model.fetch();
      Espo.Ui.notify();
      this.inProcess = false;
      await this.reRender();
    }

    /**
     * @private
     */
    async actionConnect() {
      const data = this.model.attributes.data || {};
      const endpoint = data.endpoint;
      const redirectUri = data.redirectUri;
      const clientId = data.clientId;
      const scope = data.scope;
      const prompt = data.prompt;
      const params = data.params;
      const proxy = window.open('about:blank', 'ConnectWithOAuth', 'location=0,status=0,width=800,height=800');
      const info = await this.processWithData({
        endpoint,
        redirectUri,
        clientId,
        scope,
        prompt,
        params
      }, proxy);
      this.inProcess = true;
      await this.reRender();
      Espo.Ui.notifyWait();
      try {
        await Espo.Ajax.postRequest(`OAuth/${this.model.id}/connection`, {
          code: info.code
        });
      } catch (e) {
        this.inProcess = false;
        await this.reRender();
        return;
      }
      await this.model.fetch();
      Espo.Ui.notify();
      this.inProcess = false;
      await this.reRender();
    }

    /**
     * @private
     * @param {{
     *     endpoint: string,
     *     clientId: string,
     *     redirectUri: string,
     *     scope: string|null,
     *     prompt: string,
     *     params: Record|null,
     * }} data
     * @param {WindowProxy} proxy
     * @return {Promise<{code: string}>}
     */
    processWithData(data, proxy) {
      const state = undefined;
      const params = {
        client_id: data.clientId,
        redirect_uri: data.redirectUri,
        response_type: 'code',
        prompt: data.prompt
      };
      if (data.scope) {
        params.scope = data.scope;
      }
      if (data.params) {
        for (const name in data.params) {
          params[name] = data.params[name];
        }
      }
      const partList = Object.entries(params).map(_ref => {
        let [key, value] = _ref;
        return key + '=' + encodeURIComponent(value);
      });
      const url = data.endpoint + '?' + partList.join('&');
      return this.processWindow(url, state, proxy);
    }

    /**
     * @private
     * @param {string} url
     * @param {string} state
     * @param {WindowProxy} proxy
     * @return {Promise<{code: string}>}
     */
    processWindow(url, state, proxy) {
      proxy.location.href = url;
      return new Promise((resolve, reject) => {
        const fail = () => {
          window.clearInterval(interval);
          if (!proxy.closed) {
            proxy.close();
          }
          reject();
        };
        const interval = window.setInterval(() => {
          if (proxy.closed) {
            fail();
            return;
          }
          let url;
          try {
            url = proxy.location.href;
          } catch (e) {
            return;
          }
          if (!url) {
            return;
          }
          const parsedData = this.parseWindowUrl(url);
          if (!parsedData) {
            fail();
            Espo.Ui.error('Could not parse URL', true);
            return;
          }
          if ((parsedData.error || parsedData.code) && state && parsedData.state !== state) {
            fail();
            Espo.Ui.error('State mismatch', true);
            return;
          }
          if (parsedData.error) {
            fail();
            Espo.Ui.error(parsedData.errorDescription || this.translate('Error'), true);
            return;
          }
          if (parsedData.code) {
            window.clearInterval(interval);
            proxy.close();
            resolve({
              code: parsedData.code
            });
          }
        }, 300);
      });
    }

    /**
     * @private
     * @param {string} url
     * @return {?{
     *     code: ?string,
     *     state: ?string,
     *     error: ?string,
     *     errorDescription: ?string,
     * }}
     */
    parseWindowUrl(url) {
      try {
        const params = new URL(url).searchParams;
        return {
          code: params.get('code'),
          state: params.get('state'),
          error: params.get('error'),
          errorDescription: params.get('errorDescription')
        };
      } catch (e) {
        return null;
      }
    }
  }
  _exports.default = OAuthAccountConnectionPanelView;
});

define("views/notification/list", ["exports", "view", "ajax", "ui"], function (_exports, _view, _ajax, _ui) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  _ajax = _interopRequireDefault(_ajax);
  _ui = _interopRequireDefault(_ui);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class NotificationListView extends _view.default {
    template = 'notification/list';

    /**
     * @private
     * @type {boolean}
     */
    groupingEnabled;
    setup() {
      this.addActionHandler('refresh', () => this.actionRefresh());
      this.addActionHandler('markAllNotificationsRead', () => this.actionMarkAllRead());
      this.groupingEnabled = this.getPreferences().get('notificationGrouping') === true;
      const promise = this.getCollectionFactory().create('Notification').then(collection => {
        this.collection = collection;
        this.collection.maxSize = this.getConfig().get('recordsPerPage') || 20;
      });
      this.wait(promise);
    }
    actionRefresh() {
      _ui.default.notifyWait();
      const $btn = this.$el.find('[data-action="refresh"]');
      $btn.addClass('disabled').attr('disabled', 'disabled');
      this.animateRefreshButton();
      this.getRecordView().showNewRecords().then(() => {
        _ui.default.notify(false);
      }).finally(() => $btn.removeClass('disabled').removeAttr('disabled'));
    }
    animateRefreshButton() {
      const iconEl = this.element.querySelector('button[data-action="refresh"] span');
      if (iconEl) {
        iconEl.classList.add('animation-spin-fast');
        setTimeout(() => iconEl.classList.remove('animation-spin-fast'), 500);
      }
    }
    afterRender() {
      const viewName = this.getMetadata().get(['clientDefs', 'Notification', 'recordViews', 'list']) || 'views/notification/record/list';
      const options = {
        selector: '.notification-list',
        collection: this.collection,
        showCount: false,
        rowActionsView: 'views/record/row-actions/remove-only',
        listLayout: {
          rows: [[{
            name: 'data',
            view: 'views/notification/fields/container',
            options: {
              containerSelector: this.getSelector(),
              groupingEnabled: this.groupingEnabled
            }
          }]]
        }
      };
      this.collection.fetch().then(() => this.createView('list', viewName, options)).then(view => view.render()).then(view => {
        view.$el.find('> .list > .list-group');
      });
    }
    actionMarkAllRead() {
      this.collection.trigger('all-read');
      _ui.default.notifyWait();
      const $link = this.$el.find('[data-action="markAllNotificationsRead"]');
      $link.attr('disabled', 'disabled').addClass('disabled');
      _ajax.default.postRequest('Notification/action/markAllRead').then(() => {
        this.trigger('all-read');
        _ui.default.notify(false);
        this.$el.find('.badge-circle-warning').remove();
      }).finally(() => $link.removeAttr('disabled').removeClass('disabled'));
      this.collection.models.forEach(model => {
        model.set('read', true, {
          sync: true
        });
      });
    }

    /**
     * @return {module:views/notification/record/list}
     */
    getRecordView() {
      return this.getView('list');
    }
  }
  var _default = _exports.default = NotificationListView;
});

define("views/notification/badge", ["exports", "view", "di", "web-socket-manager", "helpers/site/window-panel-helper", "helpers/site/modal-bar-provider"], function (_exports, _view, _di, _webSocketManager, _windowPanelHelper, _modalBarProvider) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  _webSocketManager = _interopRequireDefault(_webSocketManager);
  _windowPanelHelper = _interopRequireDefault(_windowPanelHelper);
  _modalBarProvider = _interopRequireDefault(_modalBarProvider);
  var _staticBlock;
  let _init_webSocketManager, _init_extra_webSocketManager, _init_modalBarProvider, _init_extra_modalBarProvider;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  class NotificationBadgeView extends _view.default {
    constructor() {
      super(...arguments);
      _init_extra_modalBarProvider(this);
    }
    template = 'notification/badge';

    /**
     * @private
     * @type {number}
     */
    notificationsCheckInterval = 10;

    /**
     * @private
     * @type {number}
     */
    groupedCheckInterval = 15;

    /**
     * @private
     * @type {number}
     */
    waitInterval = 2;

    /** @private */
    useWebSocket = false;

    /**
     * @private
     * @type {number|null}
     */
    timeout = null;

    /**
     * @private
     * @type {number|null}
     */
    groupedTimeout = null;

    /**
     * @private
     * @type {Object.<string, {
     *     portalDisabled?: boolean,
     *     grouped?: boolean,
     *     disabled?: boolean,
     *     interval?: Number,
     *     url?: string,
     *     useWebSocket?: boolean,
     *     view?: string,
     *     webSocketCategory?: string,
     * }>}
     */
    popupNotificationsData;

    /**
     * @private
     * @type {string}
     */
    soundPath = 'client/sounds/cloud.ogg';

    /**
     * @private
     * @type {WebSocketManager}
     */
    webSocketManager = _init_webSocketManager(this);

    /**
     * @private
     * @type {ModalBarProvider}
     */
    modalBarProvider = (_init_extra_webSocketManager(this), _init_modalBarProvider(this));
    setup() {
      this.addActionHandler('showNotifications', () => this.showNotifications());
      this.soundPath = this.getBasePath() + (this.getConfig().get('notificationSound') || this.soundPath);
      this.useWebSocket = this.webSocketManager.isEnabled();
      const clearTimeouts = () => {
        if (this.timeout) {
          clearTimeout(this.timeout);
        }
        if (this.groupedTimeout) {
          clearTimeout(this.groupedTimeout);
        }
        for (const name in this.popupTimeouts) {
          clearTimeout(this.popupTimeouts[name]);
        }
      };
      this.once('remove', () => clearTimeouts());
      this.listenToOnce(this.getHelper().router, 'logout', () => clearTimeouts());
      this.notificationsCheckInterval = this.getConfig().get('notificationsCheckInterval') || this.notificationsCheckInterval;
      this.groupedCheckInterval = this.getConfig().get('popupNotificationsCheckInterval') || this.groupedCheckInterval;
      this.lastId = 0;
      this.shownNotificationIds = [];
      this.closedNotificationIds = [];
      this.popupTimeouts = {};
      delete localStorage['messageBlockPlayNotificationSound'];
      delete localStorage['messageClosePopupNotificationId'];
      delete localStorage['messageNotificationRead'];
      delete localStorage['messageCollapsePopupNotificationId'];
      delete localStorage['messageExpandPopupNotificationId'];
      const onWindowStorageBind = this.onWindowStorage.bind(this);
      window.addEventListener('storage', onWindowStorageBind, false);
      this.on('remove', () => window.removeEventListener('storage', onWindowStorageBind));
    }
    afterRender() {
      this.$badge = this.$el.find('.notifications-button');
      this.$number = this.$el.find('.number-badge');
      this.runCheckUpdates(true);
      this.$popupContainer = $('#popup-notifications-container');
      if (!$(this.$popupContainer).length) {
        this.$popupContainer = $('<div>').attr('id', 'popup-notifications-container').addClass('hidden').appendTo('body');
      }
      const popupNotificationsData = this.popupNotificationsData = this.getMetadata().get('app.popupNotifications') || {};
      for (const name in popupNotificationsData) {
        this.checkPopupNotifications(name);
      }
      if (this.hasGroupedPopupNotifications()) {
        this.checkGroupedPopupNotifications();
      }
    }

    /**
     * @private
     * @param {StorageEvent} e
     */
    onWindowStorage(e) {
      if (e.key === 'messageClosePopupNotificationId') {
        const id = localStorage.getItem(e.key);
        this.closePopupNotification(id);
        delete localStorage[e.key];
      }
      if (e.key === 'messageCollapsePopupNotificationId') {
        const id = localStorage.getItem(e.key);
        this.collapsePopupNotification(id, true);
        delete localStorage[e.key];
      }
      if (e.key === 'messageExpandPopupNotificationId') {
        const id = localStorage.getItem(e.key);
        this.expandPopupNotification(id, true);
        delete localStorage[e.key];
      }
      if (e.key === 'messageNotificationRead') {
        if (!this.isBroadcastingNotificationRead && localStorage.getItem('messageNotificationRead')) {
          this.checkUpdates();
        }
      }
    }

    /**
     * @private
     * @param {string} id
     */
    closePopupNotification(id) {
      var _this$modalBarProvide;
      if (!id) {
        return;
      }
      const key = `popup-${id}`;
      const view = this.getPopupNotificationView(id);
      if (!view) {
        return;
      }
      (_this$modalBarProvide = this.modalBarProvider) === null || _this$modalBarProvide === void 0 || _this$modalBarProvide.get().removeModalView(view);
      this.markPopupRemoved(id);
      this.clearView(key);
    }
    playSound() {
      if (!this.getPreferences().get('notificationSound')) {
        return;
      }
      const audio = new Audio(this.soundPath);
      audio.volume = 0.3;
      audio.play();
    }

    /**
     * @private
     * @param {number} count
     */
    showNotRead(count) {
      this.$badge.attr('title', this.translate('New notifications') + ': ' + count);
      this.$number.removeClass('hidden').html(count.toString());
      this.getHelper().pageTitle.setNotificationNumber(count);
    }

    /**
     * @private
     */
    hideNotRead() {
      this.$badge.attr('title', this.translate('Notifications'));
      this.$number.addClass('hidden').html('');
      this.getHelper().pageTitle.setNotificationNumber(0);
    }

    /**
     * @private
     */
    checkBypass() {
      const last = this.getRouter().getLast() || {};
      const pageAction = (last.options || {}).page || null;
      if (last.controller === 'Admin' && last.action === 'page' && ['upgrade', 'extensions'].includes(pageAction)) {
        return true;
      }
      return false;
    }

    /**
     * @private
     * @param {boolean} [isFirstCheck]
     */
    async checkUpdates(isFirstCheck) {
      if (this.checkBypass()) {
        return;
      }

      /** @type {number} */
      const count = await Espo.Ajax.getRequest('Notification/action/notReadCount');
      if (!isFirstCheck && count > this.unreadCount) {
        const blockSound = localStorage.getItem('messageBlockPlayNotificationSound');
        if (!blockSound) {
          this.playSound();
          localStorage.setItem('messageBlockPlayNotificationSound', 'true');
          setTimeout(() => {
            delete localStorage['messageBlockPlayNotificationSound'];
          }, this.notificationsCheckInterval * 1000);
        }
      }
      this.unreadCount = count;
      if (count) {
        this.showNotRead(count);
        return;
      }
      this.hideNotRead();
    }
    runCheckUpdates(isFirstCheck) {
      this.checkUpdates(isFirstCheck);
      if (this.useWebSocket) {
        this.initWebSocketCheckUpdates();
        return;
      }
      this.timeout = setTimeout(() => this.runCheckUpdates(), this.notificationsCheckInterval * 1000);
    }

    /**
     * @private
     */
    initWebSocketCheckUpdates() {
      let isBlocked = false;
      let hasBeenBlocked = false;
      const onWebSocketNewNotification = () => {
        if (isBlocked) {
          hasBeenBlocked = true;
          return;
        }
        this.checkUpdates();
        isBlocked = true;
        setTimeout(() => {
          const reRun = hasBeenBlocked;
          isBlocked = false;
          hasBeenBlocked = false;
          if (reRun) {
            onWebSocketNewNotification();
          }
        }, this.waitInterval * 1000);
      };
      this.webSocketManager.subscribe('newNotification', () => onWebSocketNewNotification());
      this.webSocketManager.subscribeToReconnect(onWebSocketNewNotification);
      this.once('remove', () => this.webSocketManager.unsubscribe('newNotification'));
      this.once('remove', () => this.webSocketManager.unsubscribeFromReconnect(onWebSocketNewNotification));
    }

    /**
     * @private
     * @return {boolean}
     */
    hasGroupedPopupNotifications() {
      for (const name in this.popupNotificationsData) {
        const data = this.popupNotificationsData[name] || {};
        if (!data.grouped) {
          continue;
        }
        if (data.portalDisabled && this.getUser().isPortal()) {
          continue;
        }
        return true;
      }
      return false;
    }

    /**
     * @private
     */
    checkGroupedPopupNotifications() {
      if (!this.checkBypass()) {
        Espo.Ajax.getRequest('PopupNotification/action/grouped').then(result => {
          for (const type in result) {
            const list = result[type];
            list.forEach(item => this.showPopupNotification(type, item));
          }
        });
      }
      if (this.useWebSocket) {
        return;
      }
      this.groupedTimeout = setTimeout(() => this.checkGroupedPopupNotifications(), this.groupedCheckInterval * 1000);
    }
    checkPopupNotifications(name, isNotFirstCheck) {
      const data = this.popupNotificationsData[name] || {};
      const url = data.url;
      const interval = data.interval;
      const disabled = data.disabled || false;
      if (disabled) {
        return;
      }
      if (data.portalDisabled && this.getUser().isPortal()) {
        return;
      }
      const useWebSocket = this.useWebSocket && data.useWebSocket;
      if (useWebSocket) {
        const category = 'popupNotifications.' + (data.webSocketCategory || name);
        this.webSocketManager.subscribe(category, (c, response) => {
          if (!response.list) {
            return;
          }
          response.list.forEach(item => {
            this.showPopupNotification(name, item);
          });
        });
      }
      if (data.grouped) {
        return;
      }
      if (!url) {
        return;
      }
      if (!interval) {
        return;
      }
      new Promise(resolve => {
        if (this.checkBypass()) {
          resolve();
          return;
        }
        Espo.Ajax.getRequest(url).then(list => list.forEach(item => this.showPopupNotification(name, item, isNotFirstCheck))).finally(() => resolve());
      }).then(() => {
        if (useWebSocket) {
          return;
        }
        this.popupTimeouts[name] = setTimeout(() => this.checkPopupNotifications(name, true), interval * 1000);
      });
    }

    /**
     * @private
     * @param {string} name
     * @param {Record} data
     * @param {boolean} isNotFirstCheck
     */
    async showPopupNotification(name, data) {
      let isNotFirstCheck = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
      const viewName = this.popupNotificationsData[name].view;
      if (!viewName) {
        return;
      }
      let id;
      const notificationId = data.id || null;
      if (notificationId) {
        id = name + '_' + notificationId;
        if (this.shownNotificationIds.includes(id)) {
          const notificationView = this.getPopupNotificationView(id);
          if (notificationView) {
            notificationView.trigger('update-data', data.data);
          }
          return;
        }
        if (this.closedNotificationIds.includes(notificationId)) {
          return;
        }
      } else {
        id = this.lastId++;
      }
      this.shownNotificationIds.push(id);

      /** @type {import('views/popup-notification').default} */
      let view;
      view = /** @type {import('views/popup-notification').default} */
      await this.createView(`popup-${id}`, viewName, {
        notificationData: data.data ?? {},
        notificationId: data.id,
        id: id,
        isFirstCheck: !isNotFirstCheck,
        onCollapse: () => {
          this.collapsePopupNotification(id);
        },
        onExpand: () => {
          this.expandPopupNotification(id);
        }
      });
      this.$popupContainer.removeClass('hidden');
      this.listenTo(view, 'remove', () => {
        this.markPopupRemoved(id);
        localStorage.setItem('messageClosePopupNotificationId', id);
      });
      if (data.id && this.getStorage().get('state', this.getCollapsedStorageKey(id))) {
        this.collapsePopupNotification(id, true);
        return;
      }
      await view.render();
    }

    /**
     * @private
     * @param {string} id
     * @param {boolean} silent
     */
    collapsePopupNotification(id) {
      let silent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
      const view = this.getPopupNotificationView(id);
      if (!view) {
        return;
      }
      if (!silent || !view.isCollapsed) {
        var _this$modalBarProvide2;
        (_this$modalBarProvide2 = this.modalBarProvider.get()) === null || _this$modalBarProvide2 === void 0 || _this$modalBarProvide2.addModalView(view, {
          title: view.getTitle() ?? this.translate('Notification')
        });
      }
      if (silent) {
        view.makeCollapsed();
        return;
      }
      localStorage.setItem('messageCollapsePopupNotificationId', id);
      this.getStorage().set('state', this.getCollapsedStorageKey(id), true);
    }

    /**
     * @private
     * @param {string} id
     * @param {boolean} silent
     */
    expandPopupNotification(id) {
      let silent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
      const view = this.getPopupNotificationView(id);
      if (!view) {
        return;
      }
      if (!silent || view.isCollapsed) {
        var _this$modalBarProvide3;
        (_this$modalBarProvide3 = this.modalBarProvider.get()) === null || _this$modalBarProvide3 === void 0 || _this$modalBarProvide3.removeModalView(view);
      }
      if (silent) {
        view.makeExpanded();
        return;
      }
      localStorage.setItem('messageExpandPopupNotificationId', id);
      this.getStorage().clear('state', this.getCollapsedStorageKey(id));
    }

    /**
     * @private
     * @param {string} id
     * @return {string}
     */
    getCollapsedStorageKey(id) {
      return `popupNotificationCollapsed-${id}`;
    }

    /**
     * @private
     * @param {string} id
     * @return {import('views/popup-notification').default}
     */
    getPopupNotificationView(id) {
      return this.getView(`popup-${id}`);
    }

    /**
     * @private
     * @param {string} id
     */
    markPopupRemoved(id) {
      const index = this.shownNotificationIds.indexOf(id);
      if (index > -1) {
        this.shownNotificationIds.splice(index, 1);
      }
      if (this.shownNotificationIds.length === 0) {
        this.$popupContainer.addClass('hidden');
      }
      this.closedNotificationIds.push(id);
    }
    broadcastNotificationsRead() {
      if (!this.useWebSocket) {
        return;
      }
      this.isBroadcastingNotificationRead = true;
      localStorage.setItem('messageNotificationRead', 'true');
      setTimeout(() => {
        this.isBroadcastingNotificationRead = false;
        delete localStorage['messageNotificationRead'];
      }, 500);
    }
    showNotifications() {
      this.closeNotifications();
      const $container = $('<div>').attr('id', 'notifications-panel');
      $container.appendTo(this.$el.find('.notifications-panel-container'));
      this.createView('panel', 'views/notification/panel', {
        fullSelector: '#notifications-panel'
      }).then(async view => {
        await view.render();
        new _windowPanelHelper.default(view);
        this.$el.closest('.navbar-body').removeClass('in');
        this.listenTo(view, 'all-read', () => {
          this.hideNotRead();
          this.$el.find('.badge-circle-warning').remove();
          this.broadcastNotificationsRead();
        });
        this.listenTo(view, 'collection-fetched', () => {
          this.checkUpdates();
          this.broadcastNotificationsRead();
        });
        this.listenToOnce(view, 'close', () => {
          this.closeNotifications();
        });
      });
      const $document = $(document);
      $document.on('mouseup.notification', e => {
        if (!$container.is(e.target) && $container.has(e.target).length === 0 && !$(e.target).closest('div.modal-dialog').length && !e.target.classList.contains('modal')) {
          this.closeNotifications();
        }
      });
      if (window.innerWidth < this.getThemeManager().getParam('screenWidthXs')) {
        this.listenToOnce(this.getRouter(), 'route', () => {
          this.closeNotifications();
        });
      }
    }
    closeNotifications() {
      const $container = $('#notifications-panel');
      $container.remove();
      const $document = $(document);
      if (this.hasView('panel')) {
        this.getView('panel').remove();
      }
      $document.off('mouseup.notification');
    }
    static #_ = _staticBlock = () => [_init_webSocketManager, _init_extra_webSocketManager, _init_modalBarProvider, _init_extra_modalBarProvider] = _applyDecs(this, [], [[(0, _di.inject)(_webSocketManager.default), 0, "webSocketManager"], [(0, _di.inject)(_modalBarProvider.default), 0, "modalBarProvider"]], 0, void 0, _view.default).e;
  }
  _staticBlock();
  var _default = _exports.default = NotificationBadgeView;
});

define("views/notification/items/user-reaction", ["exports", "views/notification/items/base", "helpers/misc/reactions"], function (_exports, _base, _reactions) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  _reactions = _interopRequireDefault(_reactions);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  // noinspection JSUnusedGlobalSymbols
  class UserReactionNotificationItemView extends _base.default {
    // language=Handlebars
    templateContent = `
        <div class="stream-head-container">
            <div class="pull-left">
                {{{avatar}}}
            </div>
            <div class="stream-head-text-container">
                <span
                    class="{{reactionIconClass}} text-muted action icon"
                    style="cursor: pointer;"
                    title="{{translate 'View'}}"
                    data-action="quickView"
                    data-id="{{noteId}}"
                    data-scope="Note"
                ></span><span class="text-muted message">{{{message}}}</span>
            </div>
        </div>

        <div class="stream-date-container">
            <span class="text-muted small">{{{createdAt}}}</span>
        </div>
    `;
    messageName = 'userPostReaction';

    /**
     * @private
     * @type {string|null}
     */
    reactionIconClass;

    /**
     * @private
     * @type {string}
     */
    noteId;
    data() {
      return {
        ...super.data(),
        reactionIconClass: this.reactionIconClass,
        noteId: this.noteId
      };
    }
    setup() {
      const data = /** @type {Object.<string, *>} */this.model.attributes.data || {};
      const relatedParentId = this.model.attributes.relatedParentId;
      const relatedParentType = this.model.attributes.relatedParentType;
      this.userId = this.model.attributes.createdById || data.userId;
      this.noteId = this.model.attributes.relatedId;
      const userName = data.userName || this.model.attributes.createdByName;
      this.messageData['type'] = this.translate(data.type, 'reactions');
      const reactionsHelper = new _reactions.default();
      this.reactionIconClass = reactionsHelper.getIconClass(data.type);
      const userElement = document.createElement('a');
      userElement.href = `#User/view/${this.model.attributes.createdById}`;
      userElement.dataset.id = this.model.attributes.createdById;
      userElement.dataset.scope = 'User';
      userElement.textContent = userName;
      this.messageData['user'] = userElement;
      if (relatedParentId && relatedParentType) {
        this.messageData['entityType'] = this.translateEntityType(relatedParentType);
        this.messageData['entity'] = 'field:relatedParent';
        this.messageName = 'userPostInParentReaction';
      }
      let postLabel = this.getLanguage().translateOption('Post', 'type', 'Note');
      if (!this.toUpperCaseFirstLetter()) {
        postLabel = Espo.Utils.lowerCaseFirst(postLabel);
      }
      const postElement = document.createElement('a');
      postElement.href = `#Note/view/${this.noteId}`;
      postElement.dataset.id = this.noteId;
      postElement.dataset.scope = 'Note';
      postElement.textContent = postLabel;
      this.messageData['post'] = postElement;
      this.createMessage();
    }
  }
  _exports.default = UserReactionNotificationItemView;
});

define("views/notification/items/system", ["exports", "views/notification/items/base"], function (_exports, _base) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class SystemNotificationItemView extends _base.default {
    template = 'notification/items/system';
    data() {
      return {
        ...super.data(),
        message: this.model.get('message')
      };
    }
    setup() {
      const data = this.model.get('data') || {};
      this.userId = data.userId;
    }
  }
  var _default = _exports.default = SystemNotificationItemView;
});

define("views/notification/items/message", ["exports", "views/notification/items/base", "dompurify", "helpers/misc/mailto", "ui"], function (_exports, _base, _dompurify, _mailto, _ui) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  _dompurify = _interopRequireDefault(_dompurify);
  _mailto = _interopRequireDefault(_mailto);
  _ui = _interopRequireDefault(_ui);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class MessageNotificationItemView extends _base.default {
    template = 'notification/items/message';
    data() {
      return {
        ...super.data(),
        style: this.style
      };
    }
    setup() {
      const data = /** @type {Object.<string, *>} */this.model.get('data') || {};
      const messageRaw = this.model.get('message') || data.message || '';
      const message = this.getHelper().transformMarkdownText(messageRaw);
      this.messageTemplate = _dompurify.default.sanitize(message, {}).toString();
      this.userId = data.userId;
      this.style = data.style || 'text-muted';
      this.messageData['entityType'] = this.translateEntityType(data.entityType);
      this.messageData['user'] = $('<a>').attr('href', '#User/view/' + data.userId).attr('data-id', data.userId).attr('data-scope', 'User').text(data.userName);
      this.messageData['entity'] = $('<a>').attr('href', '#' + data.entityType + '/view/' + data.entityId).attr('data-id', data.entityId).attr('data-scope', data.entityType).text(data.entityName);
      this.createMessage();
      this.addActionHandler('mailTo', (_, target) => this.mailTo(target.dataset.emailAddress));
    }

    /**
     * @private
     * @param {string} emailAddress
     * @return {Promise<void>}
     */
    async mailTo(emailAddress) {
      const attributes = {
        status: 'Draft',
        to: emailAddress
      };
      const helper = new _mailto.default();
      if (helper.toUse()) {
        document.location.href = helper.composeLink(attributes);
        return;
      }
      _ui.default.notifyWait();
      const view = await this.createView('dialog', 'views/modals/compose-email', {
        attributes: attributes
      });
      await view.render();
      _ui.default.notify();
    }
  }
  var _default = _exports.default = MessageNotificationItemView;
});

define("views/notification/items/group-note", ["exports", "views/notification/items/base", "ajax", "views/notification/fields/container"], function (_exports, _base, _ajax, _container) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  _ajax = _interopRequireDefault(_ajax);
  _container = _interopRequireDefault(_container);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  // noinspection JSUnusedGlobalSymbols
  class GroupNoteNotificationItemView extends _base.default {
    // language=Handlebars
    templateContent = `
        <div class="stream-head-container">
            {{#if iconClass}}
                <div class="pull-left stream-head-left-icon-container">
                    <span
                        class=" {{iconClass}} text-muted action icon"
                        style="
                            cursor: pointer;
                            {{#if color}} color: {{color}}; {{/if}}
                        "
                        title="{{translate 'View'}}"
                        data-action="quickView"
                        data-id="{{relatedParentId}}"
                        data-scope="{{relatedParentType}}"
                    ></span>
                </div>
            {{/if}}
            <div class="stream-head-text-container">
                <span class="text-muted message">{{{message}}}</span>
            </div>
        </div>
        {{~#if isFeatured~}}
            <div class="stream-post-container">
                <span class="label label-default">{{translate 'Assigned'}}</span>
            </div>
        {{~/if~}}
        <div class="stream-date-container">
            <span class="text-muted small">{{{createdAt}}}</span>
        </div>
    `;
    data() {
      const relatedParentType = this.model.attributes.relatedParentType;
      const iconClass = this.getMetadata().get(`clientDefs.${relatedParentType}.iconClass`);
      const color = this.getMetadata().get(`clientDefs.${relatedParentType}.color`);
      return {
        ...super.data(),
        relatedParentId: this.model.attributes.relatedParentId,
        relatedParentType: this.model.attributes.relatedParentType,
        isFeatured: this.model.attributes.isFeatured,
        iconClass,
        color
      };
    }
    setup() {
      const relatedParentType = this.model.attributes.relatedParentType;
      if (relatedParentType) {
        this.messageData['entityType'] = this.translateEntityType(relatedParentType);
      }
      this.messageData['entity'] = 'field:relatedParent';
      const newCount = this.model.attributes.groupedUnreadCount ?? 0;
      this.messageData['number'] = newCount.toString();
      this.messageName = newCount > 1 ? 'groupUpdatesMultiple' : 'groupUpdatesOne';
      if (newCount === 0) {
        this.messageName = 'groupUpdates';
      }
      this.createMessage();
      this.addHandler('click', '> .stream-head-container > .stream-head-text-container [data-key="entity"] a', () => {
        this.markGroupRead();
      });
    }

    /**
     * @private
     */
    async markGroupRead() {
      if (this.model.attributes.read) {
        return;
      }
      await _ajax.default.postRequest(`Notification/group/${this.model.id}/markRead`);
      this.model.set('read', true, {
        sync: true
      });
      this.triggerUpdateRead();
    }

    /**
     * @private
     */
    triggerUpdateRead() {
      const parentView = this.getParentView();
      if (!(parentView instanceof _container.default)) {
        return;
      }
      parentView.triggerUpdateRead();
    }
  }
  _exports.default = GroupNoteNotificationItemView;
});

define("views/notification/items/group-email-received", ["exports", "views/notification/items/base"], function (_exports, _base) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  // noinspection JSUnusedGlobalSymbols
  class GroupNoteNotificationItemView extends _base.default {
    // language=Handlebars
    templateContent = `
        <div class="stream-head-container">
            <div class="pull-left stream-head-left-icon-container">
                <span
                    class="far fa-envelope text-soft icon"
                >
            </div>
            <div class="stream-head-text-container">
                <span class="text-muted message">{{{message}}}</span>
            </div>
        </div>

        <div class="stream-date-container">
            <span class="text-muted small">{{{createdAt}}}</span>
        </div>
    `;
    data() {
      return {
        ...super.data()
      };
    }
    setup() {
      const newCount = this.model.attributes.groupedUnreadCount ?? 0;
      this.messageData['number'] = newCount.toString();
      this.messageName = 'groupEmailsReceivedNew';
      if (newCount === 0) {
        this.messageName = 'groupEmailsReceived';
      }
      this.createMessage();
    }
  }
  _exports.default = GroupNoteNotificationItemView;
});

define("views/notification/items/entity-removed", ["exports", "views/notification/items/base"], function (_exports, _base) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EntityRemovedNotificationItemView extends _base.default {
    messageName = 'entityRemoved';
    template = 'notification/items/entity-removed';
    setup() {
      const data = /** @type {Object.<string, *>} */this.model.get('data') || {};
      this.userId = data.userId;
      this.messageData['entityType'] = this.translateEntityType(data.entityType);
      this.messageData['user'] = $('<a>').attr('href', '#User/view/' + data.userId).attr('data-id', data.userId).attr('data-scope', 'User').text(data.userName);
      this.messageData['entity'] = $('<a>').attr('href', '#' + data.entityType + '/view/' + data.entityId).attr('data-id', data.entityId).attr('data-scope', data.entityType).text(data.entityName);
      this.createMessage();
    }
  }
  var _default = _exports.default = EntityRemovedNotificationItemView;
});

define("views/notification/items/email-received", ["exports", "views/notification/items/base"], function (_exports, _base) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EmailReceivedNotificationItemView extends _base.default {
    messageName = 'emailReceived';
    template = 'notification/items/email-received';
    data() {
      return {
        ...super.data(),
        emailId: this.emailId,
        emailName: this.emailName
      };
    }
    setup() {
      const data = /** @type {Record} */this.model.get('data') || {};
      this.userId = data.userId;
      this.messageData['entityType'] = this.translateEntityType(data.entityType);
      if (data.personEntityId) {
        this.messageData['from'] = $('<a>').attr('href', '#' + data.personEntityType + '/view/' + data.personEntityId).attr('data-id', data.personEntityId).attr('data-scope', data.personEntityType).text(data.personEntityName);
      } else {
        const text = data.fromString || this.translate('empty address');
        this.messageData['from'] = $('<span>').text(text);
      }
      this.emailId = data.emailId;
      this.emailName = data.emailName;
      this.createMessage();
    }
  }
  var _default = _exports.default = EmailReceivedNotificationItemView;
});

define("views/notification/items/email-inbox", ["exports", "views/notification/items/base"], function (_exports, _base) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EmailInboxNotificationItemView extends _base.default {
    messageName = 'emailInbox';

    // language=Handlebars
    templateContent = `
        <div class="stream-head-container">
            <div class="pull-left">{{{avatar}}}</div>
            <div class="stream-head-text-container">
                <span
                    class="fas fa-envelope text-muted action icon"
                    style="cursor: pointer;"
                    title="{{translate 'View'}}"
                    data-action="quickView"
                    data-id="{{model.attributes.relatedId}}"
                    data-scope="Email"
                ></span><span class="text-muted message">{{{message}}}</span>
            </div>
        </div>
        <div class="stream-date-container">
            <span class="text-muted small">{{{createdAt}}}</span>
        </div>
    `;
    setup() {
      /** @type {{userId: string, userName: string, emailName: string}} */
      const data = this.model.attributes.data || {};
      this.userId = data.userId;
      this.messageData['entityType'] = this.translateEntityType('Email');
      const entity = document.createElement('a');
      entity.href = `#Email/view/${this.model.attributes.relatedId}`;
      entity.dataset.id = this.model.attributes.relatedId;
      entity.dataset.scope = 'Email';
      entity.innerText = data.emailName;
      const user = document.createElement('a');
      user.href = `#User/view/${data.userId}`;
      user.dataset.id = data.userId;
      user.dataset.scope = 'User';
      user.innerText = data.userName;
      this.messageData['entity'] = entity;
      this.messageData['user'] = user;
      this.createMessage();
    }
  }
  var _default = _exports.default = EmailInboxNotificationItemView;
});

define("views/notification/items/collaborating", ["exports", "views/notification/items/base"], function (_exports, _base) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  // noinspection JSUnusedGlobalSymbols
  class CollaboratingNotificationItemView extends _base.default {
    // language=Handlebars
    templateContent = `
        <div class="stream-head-container">
            <div class="pull-left">
                {{{avatar}}}
            </div>
            <div class="stream-head-text-container text-muted">
                {{#if iconHtml}}{{{iconHtml}}}{{/if}}<span class="message"">{{{message}}}</span>
            </div>
        </div>

        <div class="stream-date-container">
            <span class="text-muted small">{{{createdAt}}}</span>
        </div>
    `;
    messageName = 'addedToCollaborators';
    data() {
      const iconHtml = this.model.attributes.relatedType && this.model.attributes.relatedId ? this.getIconHtml(this.model.attributes.relatedType, this.model.attributes.relatedId) : null;
      return {
        ...super.data(),
        iconHtml: iconHtml
      };
    }
    setup() {
      this.userId = this.model.attributes.createdById;
      this.messageData['user'] = (() => {
        const element = document.createElement('a');
        element.href = `#User/view/${this.model.attributes.createdById}`;
        element.dataset.id = this.model.attributes.createdById;
        element.dataset.scope = 'User';
        element.textContent = this.model.attributes.createdByName;
        return element;
      })();
      this.messageData['entityType'] = this.translateEntityType(this.model.attributes.relatedType);
      this.messageData['entity'] = 'field:related';
      this.createMessage();
    }
  }
  _exports.default = CollaboratingNotificationItemView;
});

define("views/notification/items/assign", ["exports", "views/notification/items/base"], function (_exports, _base) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class AssignNotificationItemView extends _base.default {
    messageName = 'assign';
    template = 'notification/items/assign';
    setup() {
      const data = this.model.get('data') || {};
      this.userId = data.userId;
      this.messageData['entityType'] = this.translateEntityType(data.entityType);
      this.messageData['entity'] = 'field:related';
      this.messageData['user'] = $('<a>').attr('href', '#User/view/' + data.userId).attr('data-id', data.userId).attr('data-scope', 'User').text(data.userName);
      this.createMessage();
    }
  }
  var _default = _exports.default = AssignNotificationItemView;
});

define("views/note/detail", ["exports", "views/main", "helpers/util/debounce", "di", "web-socket-manager"], function (_exports, _main, _debounce, _di, _webSocketManager) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _main = _interopRequireDefault(_main);
  _debounce = _interopRequireDefault(_debounce);
  _webSocketManager = _interopRequireDefault(_webSocketManager);
  var _staticBlock;
  let _init_webSocketManager, _init_extra_webSocketManager;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  class NoteDetailView extends _main.default {
    constructor() {
      super(...arguments);
      _init_extra_webSocketManager(this);
    }
    templateContent = `
        <div class="header page-header">{{{header}}}</div>
        <div class="record list-container list-container-panel block-center">{{{record}}}</div>
    `;

    /**
     * @private
     */
    isDeleted = false;

    /**
     * @private
     * @type {DebounceHelper}
     */
    webSocketDebounceHelper;

    /**
     * @private
     * @type {WebSocketManager}
     */
    webSocketManager = _init_webSocketManager(this);
    setup() {
      this.scope = this.model.entityType;
      this.setupHeader();
      this.setupRecord();
      this.setupWebSocket();
      this.listenToOnce(this.model, 'remove', () => {
        this.clearView('record');
        this.isDeleted = true;
        this.getHeaderView().reRender();
      });
      this.addActionHandler('fullRefresh', () => this.actionFullRefresh());
    }

    /**
     * @private
     */
    setupHeader() {
      this.createView('header', 'views/header', {
        selector: '> .header',
        scope: this.scope,
        fontSizeFlexible: true
      });
    }

    /**
     * @private
     */
    setupRecord() {
      this.wait((async () => {
        this.collection = await this.getCollectionFactory().create(this.scope);
        this.collection.add(this.model);
        const view = await this.createView('record', 'views/stream/record/list', {
          selector: '> .record',
          collection: this.collection,
          isUserStream: true
        });
        if (this.webSocketDebounceHelper) {
          this.listenTo(view, 'before:save', () => this.webSocketDebounceHelper.block());
        }
      })());
    }
    getHeader() {
      const parentType = this.model.attributes.parentType;
      const parentId = this.model.attributes.parentId;
      const typeText = document.createElement('span');
      typeText.textContent = this.getLanguage().translateOption(this.model.attributes.type, 'type', 'Note');
      if (this.model.attributes.deleted || this.isDeleted) {
        typeText.style.textDecoration = 'line-through';
      }
      typeText.title = this.translate('clickToRefresh', 'messages');
      typeText.dataset.action = 'fullRefresh';
      typeText.style.cursor = 'pointer';
      if (parentType && parentId) {
        return this.buildHeaderHtml([(() => {
          const a = document.createElement('a');
          a.href = `#${parentType}`;
          a.textContent = this.translate(parentType, 'scopeNamesPlural');
          return a;
        })(), (() => {
          const a = document.createElement('a');
          a.href = `#${parentType}/view/${parentId}`;
          a.textContent = this.model.attributes.parentName || parentId;
          return a;
        })(), (() => {
          const span = document.createElement('span');
          span.textContent = this.translate('Stream', 'scopeNames');
          return span;
        })(), typeText]);
      }
      return this.buildHeaderHtml([(() => {
        const span = document.createElement('span');
        span.textContent = this.translate('Stream', 'scopeNames');
        return span;
      })(), typeText]);
    }

    /**
     * @private
     */
    async actionFullRefresh() {
      Espo.Ui.notifyWait();
      await this.model.fetch();
      Espo.Ui.notify();
    }
    onRemove() {
      super.onRemove();
      if (this.webSocketManager.isEnabled()) {
        this.webSocketManager.unsubscribe(`recordUpdate.Note.${this.model.id}`);
      }
    }
    setupWebSocket() {
      if (!this.webSocketManager.isEnabled()) {
        return;
      }
      this.webSocketDebounceHelper = new _debounce.default({
        handler: () => this.handleRecordUpdate()
      });
      const topic = `recordUpdate.Note.${this.model.id}`;
      this.webSocketManager.subscribe(topic, () => this.webSocketDebounceHelper.process());
    }

    /**
     * @private
     */
    async handleRecordUpdate() {
      await this.model.fetch({
        highlight: true
      });
    }
    static #_ = _staticBlock = () => [_init_webSocketManager, _init_extra_webSocketManager] = _applyDecs(this, [], [[(0, _di.inject)(_webSocketManager.default), 0, "webSocketManager"]], 0, void 0, _main.default).e;
  }
  _exports.default = NoteDetailView;
  _staticBlock();
});

define("views/note/record/edit", ["exports", "views/record/edit"], function (_exports, _edit) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _edit = _interopRequireDefault(_edit);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _edit.default {
    sideView = null;
    isWide = true;
    setup() {
      super.setup();
      this.controlRequiredFields();
      this.listenTo(this.model, 'change:attachmentsIds', () => {
        this.controlRequiredFields();
      });
    }
    controlRequiredFields() {
      if (!(this.model.get('attachmentsIds') || []).length) {
        this.setFieldRequired('post');
      } else {
        this.setFieldNotRequired('post');
      }
    }
  }
  _exports.default = _default;
});

define("views/note/modals/edit", ["exports", "views/modals/edit"], function (_exports, _edit) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _edit = _interopRequireDefault(_edit);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _edit.default {
    fullFormDisabled = true;
    setup() {
      super.setup();
      this.once('ready', () => {
        const recordView = this.getView('edit') || this.getView('record');
        if (!recordView) {
          return;
        }
        const fieldView = recordView.getFieldView('post');
        if (!fieldView) {
          return;
        }
        this.listenTo(fieldView, 'add-files', files => {
          /** @type {import('views/fields/attachment-multiple').default} */
          const attachmentsView = recordView.getFieldView('attachments');
          if (attachmentsView) {
            attachmentsView.uploadFiles(files);
          }
        });
      });
    }
  }
  _exports.default = _default;
});

define("views/note/fields/users", ["exports", "views/fields/link-multiple"], function (_exports, _linkMultiple) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _linkMultiple = _interopRequireDefault(_linkMultiple);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _linkMultiple.default {
    init() {
      this.messagePermission = this.getAcl().getPermissionLevel('message');
      this.portalPermission = this.getAcl().getPermissionLevel('portal');
      if (this.messagePermission === 'no' && this.portalPermission === 'no') {
        this.readOnly = true;
      }
      super.init();
    }
    getSelectBoolFilterList() {
      if (this.messagePermission === 'team') {
        return ['onlyMyTeam'];
      }
      if (this.portalPermission === 'yes') {
        return null;
      }
    }
    getSelectPrimaryFilterName() {
      if (this.portalPermission === 'yes' && this.messagePermission === 'no') {
        return 'activePortal';
      }
      return 'active';
    }
    getSelectFilterList() {
      if (this.portalPermission === 'yes') {
        if (this.messagePermission === 'no') {
          return ['activePortal'];
        }
        return ['active', 'activePortal'];
      }
      return null;
    }

    /**
     * @inheritDoc
     */
    prepareEditItemElement(id, name) {
      const itemElement = super.prepareEditItemElement(id, name);
      const avatarHtml = this.getHelper().getAvatarHtml(id, 'small', 18, 'avatar-link');
      if (avatarHtml) {
        const img = new DOMParser().parseFromString(avatarHtml, 'text/html').body.childNodes[0];
        const textElement = itemElement.querySelector('.text');
        textElement === null || textElement === void 0 || textElement.prepend(img);
      }
      return itemElement;
    }
  }
  _exports.default = _default;
});

define("views/note/fields/type", ["exports", "views/fields/enum"], function (_exports, _enum) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _enum = _interopRequireDefault(_enum);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _enum.default {
    searchTypeList = ['anyOf', 'noneOf'];
  }
  _exports.default = _default;
});

define("views/note/fields/related", ["exports", "views/fields/link-parent"], function (_exports, _linkParent) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _linkParent = _interopRequireDefault(_linkParent);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _linkParent.default {
    setup() {
      this.foreignScopeList = Object.keys(this.getMetadata().get('scopes')).filter(scope => {
        const defs = /** @type {Record} */this.getMetadata().get(`scopes.${scope}`) || {};
        if (!defs.entity || !defs.object) {
          return false;
        }
        return this.getAcl().checkScope(scope, 'stream');
      });
      super.setup();
    }
  }
  _exports.default = _default;
});

define("views/note/fields/parent", ["exports", "views/fields/link-parent"], function (_exports, _linkParent) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _linkParent = _interopRequireDefault(_linkParent);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _linkParent.default {
    setup() {
      this.foreignScopeList = Object.keys(this.getMetadata().get('scopes')).filter(scope => {
        const defs = /** @type {Record} */this.getMetadata().get(`scopes.${scope}`) || {};
        if (!defs.stream || !defs.entity || !defs.object) {
          return false;
        }
        return this.getAcl().checkScope(scope, 'stream');
      });
      super.setup();
    }
  }
  _exports.default = _default;
});

define("views/modals/view-map", ["exports", "views/modal"], function (_exports, _modal) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ViewMapModalView extends _modal.default {
    templateContent = `<div class="map-container no-side-margin">{{{map}}}</div>`;
    backdrop = true;
    setup() {
      const field = this.options.field;
      const url = '#AddressMap/view/' + this.model.entityType + '/' + this.model.id + '/' + field;
      const fieldLabel = this.translate(field, 'fields', this.model.entityType);
      this.headerElement = $('<a>').attr('href', '#' + url).text(fieldLabel).get(0);
      const viewName = this.model.getFieldParam(field + 'Map', 'view') || this.getFieldManager().getViewName('map');
      this.createView('map', viewName, {
        model: this.model,
        name: field + 'Map',
        selector: '.map-container',
        height: 'auto'
      });
    }
  }
  var _default = _exports.default = ViewMapModalView;
});

define("views/modals/select-records-with-categories", ["exports", "views/modals/select-records"], function (_exports, _selectRecords) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _selectRecords = _interopRequireDefault(_selectRecords);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class SelectRecordsWithCategoriesModalView extends _selectRecords.default {
    template = 'modals/select-records-with-categories';

    /**
     * @private
     * @type {string}
     */
    categoryField = 'category';

    /**
     * @private
     * @type {string}
     */
    categoryFilterType = 'inCategory';

    /**
     * @private
     * @type {string}
     */
    categoryScope;

    /**
     * @private
     * @type {boolean}
     */
    isExpanded = true;

    /**
     * @protected
     * @type {boolean}
     */
    isCategoryMultiple;
    data() {
      return {
        ...super.data(),
        categoriesDisabled: this.categoriesDisabled
      };
    }
    setup() {
      // noinspection JSUnresolvedReference
      this.scope = this.entityType = this.options.scope || this.scope || this.options.entityType;
      this.categoryScope = this.categoryScope || this.scope + 'Category';
      this.categoryField = this.getMetadata().get(`scopes.${this.categoryScope}.categoryField`) || this.categoryField;
      this.isCategoryMultiple = this.getMetadata().get(`entityDefs.${this.scope}.fields.${this.categoryField}.type`) === 'linkMultiple';
      this.categoriesDisabled = this.categoriesDisabled || this.getMetadata().get(['scopes', this.categoryScope, 'disabled']) || !this.getAcl().checkScope(this.categoryScope);
      super.setup();
      this.addActionHandler('toggleExpandedFromNavigation', () => this.actionToggleExpandedFromNavigation());
    }
    setupList() {
      if (!this.categoriesDisabled) {
        this.setupCategories();
      }
      super.setupList();
    }
    setupCategories() {
      this.getCollectionFactory().create(this.categoryScope, collection => {
        this.treeCollection = collection;
        collection.url = collection.entityType + '/action/listTree';
        collection.data.onlyNotEmpty = true;
        collection.fetch().then(() => this.createCategoriesView());
      });
    }

    /**
     * @protected
     * @return {import('views/record/list-tree').default}
     */
    getCategoriesView() {
      return this.getView('categories');
    }
    createCategoriesView() {
      this.createView('categories', 'views/record/list-tree', {
        collection: this.treeCollection,
        selector: '.categories-container',
        selectable: true,
        readOnly: true,
        showRoot: true,
        buttonsDisabled: true,
        checkboxes: false,
        isExpanded: this.isExpanded
      }, view => {
        if (this.isRendered()) {
          view.render();
        } else {
          this.listenToOnce(this, 'after:render', () => view.render());
        }
        this.listenTo(view, 'select', model => {
          this.currentCategoryId = null;
          this.currentCategoryName = '';
          if (model && model.id) {
            this.currentCategoryId = model.id;
            this.currentCategoryName = model.get('name');
          }
          this.applyCategoryToCollection();
          Espo.Ui.notifyWait();
          this.collection.fetch().then(() => Espo.Ui.notify(false));
        });
      });
    }

    /**
     * @private
     */
    async actionToggleExpandedFromNavigation() {
      this.isExpanded = !this.isExpanded;

      /** @type {HTMLAnchorElement} */
      const a = this.element.querySelector('a[data-role="expandButtonContainer"]');
      if (a) {
        a.classList.add('disabled');
      }
      this.applyCategoryToCollection();
      this.getCategoriesView().isExpanded = this.isExpanded;
      Espo.Ui.notifyWait();
      await this.collection.fetch();
      this.getCategoriesView().reRender().then(() => {});
      Espo.Ui.notify();
    }

    /**
     * @private
     * @todo Move to helper. Together with list view.
     */
    applyCategoryToCollection() {
      this.collection.whereFunction = () => {
        let filter;
        const isExpanded = this.isExpanded;
        if (!isExpanded && !this.hasTextFilter()) {
          if (this.isCategoryMultiple) {
            if (this.currentCategoryId) {
              filter = {
                attribute: this.categoryField,
                type: 'linkedWith',
                value: [this.currentCategoryId]
              };
            } else {
              filter = {
                attribute: this.categoryField,
                type: 'isNotLinked'
              };
            }
          } else {
            if (this.currentCategoryId) {
              filter = {
                attribute: this.categoryField + 'Id',
                type: 'equals',
                value: this.currentCategoryId
              };
            } else {
              filter = {
                attribute: this.categoryField + 'Id',
                type: 'isNull'
              };
            }
          }
        } else {
          if (this.currentCategoryId) {
            filter = {
              attribute: this.categoryField,
              type: this.categoryFilterType,
              value: this.currentCategoryId
            };
          }
        }
        if (filter) {
          return [filter];
        }
      };
    }

    /**
     * @private
     * @return {boolean}
     */
    hasTextFilter() {
      return !!this.collection.data.textFilter || this.collection.where && this.collection.where.find(it => it.type === 'textFilter');
    }
  }

  // noinspection JSUnusedGlobalSymbols
  var _default = _exports.default = SelectRecordsWithCategoriesModalView;
});

define("views/modals/select-category-tree-records", ["exports", "views/modals/select-records", "search-manager"], function (_exports, _selectRecords, _searchManager) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _selectRecords = _interopRequireDefault(_selectRecords);
  _searchManager = _interopRequireDefault(_searchManager);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class SelectCategoryTreeRecordsModalView extends _selectRecords.default {
    setup() {
      this.filters = this.options.filters || {};
      this.boolFilterList = this.options.boolFilterList || {};
      this.primaryFilterName = this.options.primaryFilterName || null;
      if ('multiple' in this.options) {
        this.multiple = this.options.multiple;
      }
      this.createButton = false;
      this.massRelateEnabled = this.options.massRelateEnabled;
      this.buttonList = [{
        name: 'cancel',
        label: 'Cancel'
      }];
      if (this.multiple) {
        this.buttonList.unshift({
          name: 'select',
          style: 'danger',
          label: 'Select',
          onClick: dialog => {
            const listView = this.getRecordView();
            if (listView.allResultIsChecked) {
              const data = {
                massRelate: true,
                where: listView.getWhereForAllResult(),
                searchParams: this.collection.data
              };
              this.trigger('select', data);
              if (this.options.onMassSelect) {
                this.options.onMassSelect(data);
              }
            } else {
              const list = listView.getSelected();
              if (list.length) {
                this.trigger('select', list);
                if (this.options.onSelect) {
                  this.options.onSelect(list);
                }
              }
            }
            dialog.close();
          }
        });
      }

      // noinspection JSUnresolvedReference
      this.scope = this.entityType = this.options.entityType || this.options.scope;
      this.$header = $('<span>');
      this.$header.append($('<span>').text(this.translate('Select') + ' · ' + this.getLanguage().translate(this.entityType, 'scopeNamesPlural')));
      this.$header.prepend(this.getHelper().getScopeColorIconHtml(this.entityType));
      this.waitForView('list');
      this.getCollectionFactory().create(this.entityType, collection => {
        collection.maxSize = this.getConfig().get('recordsPerPageSelect') || 5;
        this.collection = collection;
        const searchManager = new _searchManager.default(collection);
        searchManager.emptyOnReset = true;
        if (this.filters) {
          searchManager.setAdvanced(this.filters);
        }
        if (this.boolFilterList) {
          searchManager.setBool(this.boolFilterList);
        }
        if (this.primaryFilterName) {
          searchManager.setPrimary(this.primaryFilterName);
        }
        collection.where = searchManager.getWhere();
        collection.url = collection.entityType + '/action/listTree';
        const viewName = this.getMetadata().get(`clientDefs.${this.entityType}.recordViews.listSelectCategoryTree`) || 'views/record/list-tree';
        this.listenToOnce(collection, 'sync', () => {
          this.createView('list', viewName, {
            collection: collection,
            fullSelector: this.containerSelector + ' .list-container',
            readOnly: true,
            selectable: true,
            checkboxes: this.multiple,
            massActionsDisabled: true,
            searchManager: searchManager,
            checkAllResultDisabled: true,
            buttonsDisabled: true
          }, listView => {
            listView.once('select', models => {
              if (!Array.isArray(models)) {
                models = [models];
              }
              this.trigger('select', models);
              if (this.options.onSelect) {
                this.options.onSelect(models);
              }
              this.close();
            });
          });
        });
        collection.fetch();
      });
    }
  }

  // noinspection JSUnusedGlobalSymbols
  var _default = _exports.default = SelectCategoryTreeRecordsModalView;
});

define("views/modals/resolve-save-conflict", ["exports", "views/modal", "ui/select"], function (_exports, _modal, _select) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  _select = _interopRequireDefault(_select);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ResolveSaveConflictModalView extends _modal.default {
    // language=Handlebars
    templateContent = `
        <div class="margin-bottom-3x">
            <p>{{translate 'resolveSaveConflict' category='messages'}}</p>
        </div>

        <div class="panel panel-default no-side-margin">
            <table class="table" style="table-layout: fixed;">
                <thead>
                <tr>
                    <th style="width: 25%">{{translate 'Field'}}</th>
                    <th style="width: 25%">{{translate 'Resolution'}}</th>
                    <th>{{translate 'Value'}}</th>
                </tr>
                </thead>
                <tbody>
                {{#each dataList}}
                    <tr>
                        <td class="cell cell-nowrap">
                    <span>
                        {{translate field category='fields' scope=../entityType}}
                    </span>
                        </td>
                        <td class="cell">
                            <select class="form-control" data-name="resolution" data-field="{{field}}">
                                {{options ../resolutionList resolution field='saveConflictResolution'}}
                            </select>
                        </td>
                        <td class="cell">
                            <div data-name="field" data-field="{{field}}">
                                {{{var viewKey ../this}}}
                            </div>
                        </td>
                    </tr>
                {{/each}}
                </tbody>
            </table>
        </div>
    `;
    backdrop = true;
    resolutionList = ['current', 'actual', 'original'];
    defaultResolution = 'current';

    /**
     * @private
     * @type {string[]}
     */
    fieldList;
    data() {
      const dataList = [];
      this.fieldList.forEach(item => {
        const o = {
          field: item,
          viewKey: item + 'Field',
          resolution: this.defaultResolution
        };
        dataList.push(o);
      });
      return {
        dataList: dataList,
        entityType: this.entityType,
        resolutionList: this.resolutionList
      };
    }
    setup() {
      this.headerText = this.translate('Resolve Conflict');
      this.buttonList = [{
        name: 'apply',
        label: 'Apply',
        style: 'danger'
      }, {
        name: 'cancel',
        label: 'Cancel'
      }];
      this.entityType = this.model.entityType;
      this.originalModel = this.model;
      this.originalAttributes = Espo.Utils.cloneDeep(this.options.originalAttributes);
      this.currentAttributes = Espo.Utils.cloneDeep(this.options.currentAttributes);
      this.actualAttributes = Espo.Utils.cloneDeep(this.options.actualAttributes);
      const attributeList = this.options.attributeList;
      const fieldList = [];
      this.getFieldManager().getEntityTypeFieldList(this.entityType).forEach(field => {
        const fieldAttributeList = this.getFieldManager().getEntityTypeFieldAttributeList(this.entityType, field);
        const intersect = attributeList.filter(value => fieldAttributeList.includes(value));
        if (intersect.length) {
          fieldList.push(field);
        }
      });
      this.fieldList = fieldList;
      this.wait(this.getModelFactory().create(this.entityType).then(model => {
        this.model = model;
        this.fieldList.forEach(field => {
          this.setResolution(field, this.defaultResolution);
        });
        this.fieldList.forEach(field => {
          this.createField(field);
        });
      }));
    }
    setResolution(field, resolution) {
      const attributeList = this.getFieldManager().getEntityTypeFieldAttributeList(this.entityType, field);
      const values = {};
      let source = this.currentAttributes;
      if (resolution === 'actual') {
        source = this.actualAttributes;
      } else if (resolution === 'original') {
        source = this.originalAttributes;
      }
      for (const attribute of attributeList) {
        values[attribute] = source[attribute] || null;
      }
      this.model.set(values);
    }
    createField(field) {
      const type = this.model.getFieldType(field);
      const viewName = this.model.getFieldParam(field, 'view') || this.getFieldManager().getViewName(type);
      this.createView(field + 'Field', viewName, {
        readOnly: true,
        model: this.model,
        name: field,
        selector: `[data-name="field"][data-field="${field}"]`,
        mode: 'list'
      });
    }
    afterRender() {
      this.$el.find('[data-name="resolution"]').on('change', e => {
        const $el = $(e.currentTarget);
        const field = $el.attr('data-field');
        const resolution = $el.val();
        this.setResolution(field, resolution);
      });
      this.fieldList.forEach(field => {
        const selectElement = this.element.querySelector(`select[data-field="${field}"]`);
        _select.default.init(selectElement);
      });
    }

    // noinspection JSUnusedGlobalSymbols
    actionApply() {
      const attributes = this.model.attributes;
      this.originalModel.set(attributes);
      this.trigger('resolve');
      this.close();
    }
  }
  var _default = _exports.default = ResolveSaveConflictModalView;
});

define("views/modals/password-change-request", ["exports", "views/modal"], function (_exports, _modal) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class PasswordChangeRequestModalView extends _modal.default {
    template = 'modals/password-change-request';
    cssName = 'password-change-request';
    className = 'dialog dialog-centered';
    noFullHeight = true;
    footerAtTheTop = false;
    setup() {
      this.buttonList = [{
        name: 'submit',
        label: 'Submit',
        style: 'danger',
        className: 'btn-s-wide'
      }, {
        name: 'cancel',
        label: 'Close',
        pullLeft: true,
        className: 'btn-s-wide'
      }];
      this.headerText = this.translate('Password Change Request', 'labels', 'User');
      this.once('close remove', () => {
        if (this.$userName) {
          this.$userName.popover('destroy');
        }
        if (this.$emailAddress) {
          this.$emailAddress.popover('destroy');
        }
      });
    }
    afterRender() {
      this.$userName = this.$el.find('input[name="username"]');
      this.$emailAddress = this.$el.find('input[name="emailAddress"]');
    }

    // noinspection JSUnusedGlobalSymbols
    actionSubmit() {
      const $userName = this.$userName;
      const $emailAddress = this.$emailAddress;
      const userName = $userName.val();
      const emailAddress = $emailAddress.val();
      let isValid = true;
      if (userName === '') {
        isValid = false;
        const message = this.getLanguage().translate('userCantBeEmpty', 'messages', 'User');
        this.isPopoverUserNameDestroyed = false;
        $userName.popover({
          container: 'body',
          placement: 'bottom',
          content: message,
          trigger: 'manual'
        }).popover('show');
        const $cellUserName = $userName.closest('.form-group');
        $cellUserName.addClass('has-error');
        $userName.one('mousedown click', () => {
          $cellUserName.removeClass('has-error');
          if (this.isPopoverUserNameDestroyed) {
            return;
          }
          $userName.popover('destroy');
          this.isPopoverUserNameDestroyed = true;
        });
      }
      if (emailAddress === '') {
        isValid = false;
        const message = this.getLanguage().translate('emailAddressCantBeEmpty', 'messages', 'User');
        this.isPopoverEmailAddressDestroyed = false;
        $emailAddress.popover({
          container: 'body',
          placement: 'bottom',
          content: message,
          trigger: 'manual'
        }).popover('show');
        const $cellEmailAddress = $emailAddress.closest('.form-group');
        $cellEmailAddress.addClass('has-error');
        $emailAddress.one('mousedown click', () => {
          $cellEmailAddress.removeClass('has-error');
          if (this.isPopoverEmailAddressDestroyed) {
            return;
          }
          $emailAddress.popover('destroy');
          this.isPopoverEmailAddressDestroyed = true;
        });
      }
      if (!isValid) {
        return;
      }
      const $submit = this.$el.find('button[data-name="submit"]');
      $submit.addClass('disabled');
      Espo.Ui.notify(this.translate('pleaseWait', 'messages'));
      Espo.Ajax.postRequest('User/passwordChangeRequest', {
        userName: userName,
        emailAddress: emailAddress,
        url: this.options.url
      }).then(() => {
        Espo.Ui.notify(false);
        let msg = this.translate('uniqueLinkHasBeenSent', 'messages', 'User');
        msg += ' ' + this.translate('passwordRecoverySentIfMatched', 'messages', 'User');
        this.$el.find('.cell-userName').addClass('hidden');
        this.$el.find('.cell-emailAddress').addClass('hidden');
        $submit.addClass('hidden');
        this.$el.find('.msg-box').removeClass('hidden');
        this.$el.find('.msg-box').html('<span class="text-success">' + msg + '</span>');
      }).catch(xhr => {
        if (xhr.status === 404) {
          Espo.Ui.error(this.translate('userNameEmailAddressNotFound', 'messages', 'User'));
          xhr.errorIsHandled = true;
        }
        if (xhr.status === 403 && xhr.getResponseHeader('X-Status-Reason') === 'Already-Sent') {
          Espo.Ui.error(this.translate('forbidden', 'messages', 'User'), true);
          xhr.errorIsHandled = true;
        }
        $submit.removeClass('disabled');
      });
    }
  }
  var _default = _exports.default = PasswordChangeRequestModalView;
});

define("views/modals/mass-action", ["exports", "views/modal", "model"], function (_exports, _modal, _model) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  _model = _interopRequireDefault(_model);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class MassActionModalView extends _modal.default {
    template = 'modals/mass-action';
    className = 'dialog dialog-record';
    checkInterval = 4000;
    data() {
      return {
        infoText: this.translate('infoText', 'messages', 'MassAction')
      };
    }
    setup() {
      this.action = this.options.action;
      this.id = this.options.id;
      this.status = 'Pending';
      this.headerText = this.translate('Mass Action', 'scopeNames') + ' · ' + this.translate(this.action, 'massActions', this.options.scope);
      this.model = new _model.default();
      this.model.name = 'MassAction';
      this.model.setDefs({
        fields: {
          'status': {
            type: 'enum',
            readOnly: true,
            options: ['Pending', 'Running', 'Success', 'Failed'],
            style: {
              'Success': 'success',
              'Failed': 'danger'
            }
          },
          'processedCount': {
            type: 'int',
            readOnly: true
          }
        }
      });
      this.model.set({
        status: this.status,
        processedCount: null
      });
      this.createView('record', 'views/record/edit-for-modal', {
        scope: 'None',
        model: this.model,
        selector: '.record',
        detailLayout: [{
          rows: [[{
            name: 'status',
            labelText: this.translate('status', 'fields', 'MassAction')
          }, {
            name: 'processedCount',
            labelText: this.translate('processedCount', 'fields', 'MassAction')
          }]]
        }]
      });
      this.on('close', () => {
        const status = this.model.get('status');
        if (status !== 'Pending' && status !== 'Running') {
          return;
        }
        Espo.Ajax.postRequest(`MassAction/${this.id}/subscribe`);
      });
      this.checkStatus();
    }
    checkStatus() {
      Espo.Ajax.getRequest(`MassAction/${this.id}/status`).then(response => {
        const status = response.status;
        this.model.set('status', status);
        if (status === 'Pending' || status === 'Running') {
          setTimeout(() => this.checkStatus(), this.checkInterval);
          return;
        }
        this.model.set({
          processedCount: response.processedCount
        });
        if (status === 'Success') {
          this.trigger('success', {
            count: response.processedCount
          });
        }
        if (this.$el) {
          this.$el.find('.info-text').addClass('hidden');
        }
      });
    }
  }
  var _default = _exports.default = MassActionModalView;
});

define("views/modals/last-viewed", ["exports", "views/modal"], function (_exports, _modal) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class LastViewedModalView extends _modal.default {
    scope = 'ActionHistoryRecord';
    className = 'dialog dialog-record';
    template = 'modals/last-viewed';
    backdrop = true;
    setup() {
      this.events['click .list .cell > a'] = () => {
        this.close();
      };
      this.$header = $('<a>').attr('href', '#LastViewed').attr('data-action', 'listView').addClass('action').text(this.getLanguage().translate('LastViewed', 'scopeNamesPlural'));
      this.waitForView('list');
      this.getCollectionFactory().create(this.scope, collection => {
        collection.maxSize = this.getConfig().get('recordsPerPage');
        collection.url = 'LastViewed';
        this.collection = collection;
        this.loadList();
        collection.fetch();
      });
    }

    // noinspection JSUnusedGlobalSymbols
    actionListView() {
      this.getRouter().navigate('#LastViewed', {
        trigger: true
      });
      this.close();
    }
    loadList() {
      const viewName = 'views/record/list';
      this.listenToOnce(this.collection, 'sync', () => {
        this.createView('list', viewName, {
          collection: this.collection,
          fullSelector: this.containerSelector + ' .list-container',
          selectable: false,
          checkboxes: false,
          massActionsDisabled: true,
          rowActionsView: false,
          checkAllResultDisabled: true,
          buttonsDisabled: true,
          headerDisabled: true,
          layoutName: 'listForLastViewed',
          layoutAclDisabled: true
        });
      });
    }
  }

  // noinspection JSUnusedGlobalSymbols
  var _default = _exports.default = LastViewedModalView;
});

define("views/modals/kanban-move-over", ["exports", "views/modal", "helpers/field/options-provider", "helpers/misc/pipelines"], function (_exports, _modal, _optionsProvider, _pipelines) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  _optionsProvider = _interopRequireDefault(_optionsProvider);
  _pipelines = _interopRequireDefault(_pipelines);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class KanbanMoveOverModalView extends _modal.default {
    template = 'modals/kanban-move-over';

    /** @inheritDoc */
    backdrop = true;
    data() {
      return {
        optionDataList: this.optionDataList
      };
    }
    events = {
      /** @this KanbanMoveOverModalView */
      'click [data-action="move"]': function (e) {
        const value = $(e.currentTarget).data('value');
        this.moveTo(value);
      }
    };
    setup() {
      this.scope = this.model.entityType;
      const iconHtml = this.getHelper().getScopeColorIconHtml(this.scope);
      this.statusField = this.options.statusField;
      this.$header = $('<span>');
      this.$header.append($('<span>').text(this.getLanguage().translate(this.scope, 'scopeNames')));
      if (this.model.get('name')) {
        this.$header.append(' <span class="chevron-right"></span> ');
        this.$header.append($('<span>').text(this.model.get('name')));
      }
      this.$header.prepend(iconHtml);
      this.buttonList = [{
        name: 'cancel',
        label: 'Cancel'
      }];
      this.setupGroupDataList();
    }

    /**
     * @private
     */
    setupGroupDataList() {
      if (this.options.pipelineId) {
        const pipeline = new _pipelines.default().get(this.scope).find(it => it.id === this.options.pipelineId);
        const stages = pipeline === null || pipeline === void 0 ? void 0 : pipeline.stages;
        this.optionDataList = stages.map(it => {
          return {
            value: it.id,
            label: it.name
          };
        });
        return;
      }
      const options = new _optionsProvider.default().get(this.scope, this.statusField).filter(it => it.name);
      this.optionDataList = options.map(it => {
        return {
          value: it.name,
          label: it.label
        };
      });
    }

    /**
     * @private
     * @param {string} status
     */
    moveTo(status) {
      const previousStatus = this.model.attributes[this.statusField];
      this.model.save({
        [this.statusField]: status
      }, {
        patch: true,
        isMoveTo: true
      }).then(() => {
        Espo.Ui.success(this.translate('Done'));
      }).catch(() => {
        this.model.setMultiple({
          [this.statusField]: previousStatus
        }, {
          isMoveTo: true
        });
      });
      this.close();
    }
  }

  // noinspection JSUnusedGlobalSymbols
  var _default = _exports.default = KanbanMoveOverModalView;
});

define("views/modals/image-preview", ["exports", "views/modal"], function (_exports, _modal) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  let Exif;
  class ImagePreviewModalView extends _modal.default {
    template = 'modals/image-preview';
    cssName = 'image-preview';
    size = '';
    backdrop = true;
    isMaximizable = true;
    transformClassList = ['transform-flip', 'transform-rotate-180', 'transform-flip-and-rotate-180', 'transform-flip-and-rotate-270', 'transform-rotate-90', 'transform-flip-and-rotate-90', 'transform-rotate-270'];

    /**
     * @protected
     * @type {HTMLElement}
     */
    imageContainerElement;

    /**
     * @protected
     * @type {HTMLImageElement}
     */
    imageElement;

    /**
     * @private
     * @type {string}
     */
    imageId;

    /**
     * @private
     * @type {string|null}
     */
    imageName;

    /**
     * @type {{id: string, name?: string|null}[]}
     */
    imageList;
    events = {
      /** @this ImagePreviewModalView */
      'keydown': function (e) {
        if (e.code === 'ArrowLeft') {
          this.switchToPrevious(true);
          return;
        }
        if (e.code === 'ArrowRight') {
          this.switchToNext(true);
        }
      }
    };
    data() {
      return {
        name: this.imageName,
        url: this.getImageUrl(),
        originalUrl: this.getOriginalImageUrl(),
        showOriginalLink: this.size
      };
    }
    setup() {
      this.buttonList = [];
      this.headerHtml = '&nbsp;';
      this.imageId = this.options.id;
      this.imageName = this.options.name;
      this.imageList = this.options.imageList || [];
      this.navigationEnabled = this.imageList.length > 1;
      this.wait(Espo.loader.requirePromise('lib!exif-js').then(Lib => Exif = Lib));

      /** @private */
      this.onImageLoadBind = this.onImageLoad.bind(this);
      /** @private */
      this.onImageClickBind = this.onImageClick.bind(this);
      /** @private */
      this.onWindowResizeBind = this.onWindowResize.bind(this);
    }
    onRemove() {
      window.removeEventListener('resize', this.onWindowResizeBind);
      if (this.imageElement) {
        this.imageElement.removeEventListener('load', this.onImageLoadBind);
        this.imageElement.removeEventListener('click', this.onImageClickBind);
      }
    }

    /**
     * @private
     * @return {string}
     */
    getImageUrl() {
      let url = `${this.getBasePath()}?entryPoint=image&id=${this.imageId}`;
      if (this.size) {
        url += `&size=${this.size}`;
      }
      if (this.getUser().get('portalId')) {
        url += `&portalId=${this.getUser().get('portalId')}`;
      }
      return url;
    }
    getOriginalImageUrl() {
      let url = `${this.getBasePath()}?entryPoint=image&id=${this.imageId}`;
      if (this.getUser().get('portalId')) {
        url += `&portalId=${this.getUser().get('portalId')}`;
      }
      return url;
    }

    /**
     * @private
     */
    onImageLoad() {
      const image = this.imageElement;
      Exif.getData(image, () => {
        // noinspection JSDeprecatedSymbols
        if (window.getComputedStyle(image).imageOrientation === 'from-image') {
          return;
        }
        const orientation = Exif.getTag(image, 'Orientation');
        switch (orientation) {
          case 2:
            image.classList.add('transform-flip');
            break;
          case 3:
            image.classList.add('transform-rotate-180');
            break;
          case 4:
            image.classList.add('transform-rotate-180');
            image.classList.add('transform-flip');
            break;
          case 5:
            image.classList.add('transform-rotate-270');
            image.classList.add('transform-flip');
            break;
          case 6:
            image.classList.add('transform-rotate-90');
            break;
          case 7:
            image.classList.add('transform-rotate-90');
            image.classList.add('transform-flip');
            break;
          case 8:
            image.classList.add('transform-rotate-270');
            break;
        }
      });

      /*if (image.naturalWidth > image.clientWidth) {}*/
    }
    afterRender() {
      if (this.isMultiple()) {
        /** @type {HTMLDivElement|null} */
        const titleElement = this.dialog.getElement().querySelector('.modal-header .modal-title');
        if (titleElement) {
          titleElement.classList.add('text-muted');
          titleElement.style.userSelect = 'none';
        }
        this.dialog.setHeaderText((this.getImageIndex() + 1).toString());
      }
      this.imageContainerElement = this.element.querySelector('.image-container');
      this.imageElement = this.imageContainerElement.querySelector('img');
      this.imageElement.addEventListener('load', this.onImageLoadBind);
      if (this.navigationEnabled) {
        this.imageElement.style.cursor = 'pointer';
      }
      this.imageElement.addEventListener('click', this.onImageClickBind);
      window.removeEventListener('resize', this.onWindowResizeBind);
      window.addEventListener('resize', this.onWindowResizeBind);
      setTimeout(() => this.onWindowResize(), 100);
    }

    /**
     * @private
     */
    onWindowResize() {
      if (!this.imageContainerElement) {
        return;
      }
      const width = this.imageContainerElement.clientWidth;
      this.imageElement.style.maxWidth = width + 'px';
    }

    /**
     * @private
     */
    onImageClick() {
      this.switchToNext();
    }

    /**
     * @private
     * @return {boolean}
     */
    isMultiple() {
      return this.imageList.length > 1;
    }

    /**
     * @private
     * @param {boolean} [noLoop]
     */
    switchToPrevious(noLoop) {
      if (!this.isMultiple()) {
        return;
      }
      let index = this.getImageIndex();
      if (noLoop && index === 0) {
        return;
      }
      if (this.imageElement) {
        this.transformClassList.forEach(item => {
          this.imageElement.classList.remove(item);
        });
      }
      index--;
      if (index < 0) {
        index = this.imageList.length - 1;
      }
      this.imageId = this.imageList[index].id;
      this.imageName = this.imageList[index].name;
      this.reRender();
    }

    /**
     * @private
     * @param {boolean} [noLoop]
     */
    switchToNext(noLoop) {
      if (!this.isMultiple()) {
        return;
      }
      let index = this.getImageIndex();
      if (noLoop && index === this.imageList.length - 1) {
        return;
      }
      if (this.imageElement) {
        this.transformClassList.forEach(item => {
          this.imageElement.classList.remove(item);
        });
      }
      index++;
      if (index > this.imageList.length - 1) {
        index = 0;
      }
      this.imageId = this.imageList[index].id;
      this.imageName = this.imageList[index].name;
      this.reRender();
    }

    /**
     * @private
     * @return {number}
     */
    getImageIndex() {
      let index = -1;
      this.imageList.forEach((item, i) => {
        if (item.id === this.imageId) {
          index = i;
        }
      });
      return index;
    }
    onMaximize() {
      const width = this.imageContainerElement.clientWidth;
      this.imageElement.style.maxWidth = width + 'px';
    }
    onMinimize() {
      const width = this.imageContainerElement.clientWidth;
      this.imageElement.style.maxWidth = width + 'px';
    }
  }
  var _default = _exports.default = ImagePreviewModalView;
});

define("views/modals/image-crop", ["exports", "views/modal"], function (_exports, _modal) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ImageCropModalView extends _modal.default {
    template = 'modals/image-crop';
    cssName = 'image-crop';
    events = {
      /** @this ImageCropModalView */
      'click [data-action="zoomIn"]': function () {
        this.$img.cropper('zoom', 0.1);
      },
      /** @this ImageCropModalView */
      'click [data-action="zoomOut"]': function () {
        this.$img.cropper('zoom', -0.1);
      }
    };
    setup() {
      this.buttonList = [{
        name: 'crop',
        label: 'Submit',
        style: 'primary'
      }, {
        name: 'cancel',
        label: 'Cancel'
      }];
      this.wait(Espo.loader.requirePromise('lib!cropper'));
      this.on('remove', () => {
        if (this.$img.length) {
          this.$img.cropper('destroy');
          this.$img.parent().empty();
        }
      });
    }
    afterRender() {
      // noinspection RequiredAttributes,HtmlRequiredAltAttribute
      let $img = this.$img = $(`<img>`).attr('src', this.options.contents).addClass('hidden');
      this.$el.find('.image-container').append($img);
      setTimeout(() => {
        $img.cropper({
          aspectRatio: 1,
          movable: true,
          resizable: true,
          rotatable: false
        });
      }, 50);
    }

    // noinspection JSUnusedGlobalSymbols
    actionCrop() {
      let dataUrl = this.$img.cropper('getDataURL', 'image/jpeg');
      this.trigger('crop', dataUrl);
      this.close();
    }
  }
  var _default = _exports.default = ImageCropModalView;
});

define("views/modals/followers-list", ["exports", "views/modals/related-list", "helpers/record/select-related"], function (_exports, _relatedList, _selectRelated) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _relatedList = _interopRequireDefault(_relatedList);
  _selectRelated = _interopRequireDefault(_selectRelated);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class FollowersListModalView extends _relatedList.default {
    massActionRemoveDisabled = true;
    massActionMassUpdateDisabled = true;
    mandatorySelectAttributeList = ['type'];
    setup() {
      if (!this.getUser().isAdmin() && this.getAcl().getPermissionLevel('followerManagementPermission') === 'no' && this.getAcl().getPermissionLevel('portalPermission') === 'no') {
        this.unlinkDisabled = true;
      }
      super.setup();
    }
    actionSelectRelated() {
      let filter = 'active';
      if (!this.getUser().isAdmin() && this.getAcl().getPermissionLevel('followerManagementPermission') === 'no' && this.getAcl().getPermissionLevel('portalPermission') === 'yes') {
        filter = 'activePortal';
      }
      const helper = new _selectRelated.default(this);
      helper.process(this.model, this.link, {
        primaryFilterName: filter,
        massSelect: false,
        foreignEntityType: 'User',
        viewKey: 'selectFollowers'
      });
    }
  }
  var _default = _exports.default = FollowersListModalView;
});

define("views/modals/edit-dashboard", ["exports", "views/modal", "model"], function (_exports, _modal, _model) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  _model = _interopRequireDefault(_model);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EditDashboardModalView extends _modal.default {
    template = 'modals/edit-dashboard';
    className = 'dialog dialog-record';
    cssName = 'edit-dashboard';
    data() {
      return {
        hasLocked: this.hasLocked
      };
    }
    events = {
      /** @this EditDashboardModalView */
      'click button.add': function (e) {
        const name = $(e.currentTarget).data('name');
        this.getParentDashboardView().addDashlet(name);
        this.close();
      }
    };
    shortcutKeys = {
      'Control+Enter': 'save'
    };

    /**
     * @return {module:views/dashboard}
     */
    getParentDashboardView() {
      return /** @type module:views/dashboard */this.getParentView();
    }
    setup() {
      this.buttonList = [{
        name: 'save',
        label: this.options.fromDashboard ? 'Save' : 'Apply',
        style: 'primary',
        title: 'Ctrl+Enter'
      }, {
        name: 'cancel',
        label: 'Cancel',
        title: 'Esc'
      }];
      const dashboardLayout = this.options.dashboardLayout || [];
      const dashboardTabList = [];
      dashboardLayout.forEach(item => {
        if (item.name) {
          dashboardTabList.push(item.name);
        }
      });
      const model = this.model = new _model.default({}, {
        entityType: 'Preferences'
      });
      model.set('dashboardTabList', dashboardTabList);
      this.hasLocked = 'dashboardLocked' in this.options;
      if (this.hasLocked) {
        model.set('dashboardLocked', this.options.dashboardLocked || false);
      }
      this.createView('dashboardTabList', 'views/preferences/fields/dashboard-tab-list', {
        selector: '.field[data-name="dashboardTabList"]',
        defs: {
          name: 'dashboardTabList',
          params: {
            required: true,
            noEmptyString: true
          }
        },
        mode: 'edit',
        model: model
      });
      if (this.hasLocked) {
        this.createView('dashboardLocked', 'views/fields/bool', {
          selector: '.field[data-name="dashboardLocked"]',
          mode: 'edit',
          model: model,
          defs: {
            name: 'dashboardLocked'
          }
        });
      }
      this.headerText = this.translate('Edit Dashboard');
      this.dashboardLayout = this.options.dashboardLayout;
    }

    /**
     * @param {string} field
     * @return {module:views/fields/base}
     */
    getFieldView(field) {
      return this.getView(field);
    }
    actionSave() {
      const dashboardTabListView = this.getFieldView('dashboardTabList');
      dashboardTabListView.fetchToModel();
      if (this.hasLocked) {
        const dashboardLockedView = this.getFieldView('dashboardLocked');
        dashboardLockedView.fetchToModel();
      }
      if (dashboardTabListView.validate()) {
        return;
      }
      const attributes = {};
      attributes.dashboardTabList = this.model.get('dashboardTabList');
      if (this.hasLocked) {
        attributes.dashboardLocked = this.model.get('dashboardLocked');
      }
      const names = this.model.get('translatedOptions');
      const renameMap = {};
      for (const name in names) {
        if (name !== names[name]) {
          renameMap[name] = names[name];
        }
      }
      attributes.renameMap = renameMap;
      this.trigger('after:save', attributes);
      this.dialog.close();
    }
  }
  var _default = _exports.default = EditDashboardModalView;
});

define("views/modals/duplicate", ["exports", "views/modal"], function (_exports, _modal) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class DuplicateModalView extends _modal.default {
    template = 'modals/duplicate';
    cssName = 'duplicate-modal';
    data() {
      return {
        scope: this.scope,
        duplicates: this.duplicates
      };
    }
    setup() {
      let saveLabel = 'Save';
      if (this.model && this.model.isNew()) {
        saveLabel = 'Create';
      }
      this.buttonList = [{
        name: 'save',
        label: saveLabel,
        style: 'danger',
        onClick: dialog => {
          this.trigger('save');
          dialog.close();
        }
      }, {
        name: 'cancel',
        label: 'Cancel'
      }];
      this.scope = this.options.scope;
      this.duplicates = this.options.duplicates;
      if (this.scope) {
        this.setupRecord();
      }
    }
    setupRecord() {
      let promise = new Promise(resolve => {
        this.getHelper().layoutManager.get(this.scope, 'listSmall', layout => {
          layout = Espo.Utils.cloneDeep(layout);
          layout.forEach(item => item.notSortable = true);
          this.getCollectionFactory().create(this.scope).then(collection => {
            collection.add(this.duplicates);
            this.createView('record', 'views/record/list', {
              selector: '.list-container',
              collection: collection,
              listLayout: layout,
              buttonsDisabled: true,
              massActionsDisabled: true,
              rowActionsDisabled: true
            });
            resolve();
          });
        });
      });
      this.wait(promise);
    }
  }
  var _default = _exports.default = DuplicateModalView;
});

define("views/modals/convert-currency", ["exports", "views/modals/mass-convert-currency"], function (_exports, _massConvertCurrency) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _massConvertCurrency = _interopRequireDefault(_massConvertCurrency);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ConvertCurrencyModalView extends _massConvertCurrency.default {
    setup() {
      super.setup();
      this.headerText = this.translate('convertCurrency', 'massActions');
    }
    actionConvert() {
      this.disableButton('convert');
      this.getFieldView('currency').fetchToModel();
      this.getFieldView('currencyRates').fetchToModel();
      const currency = this.model.get('currency');
      const currencyRates = this.model.get('currencyRates');
      Espo.Ajax.postRequest('Action', {
        entityType: this.options.entityType,
        action: 'convertCurrency',
        id: this.options.model.id,
        data: {
          targetCurrency: currency,
          rates: currencyRates,
          fieldList: this.options.fieldList || null
        }
      }).then(attributes => {
        this.trigger('after:update', attributes);
        this.close();
      }).catch(() => {
        this.enableButton('convert');
      });
    }
  }
  var _default = _exports.default = ConvertCurrencyModalView;
});

define("views/modals/compose-email", ["exports", "views/modals/edit", "helpers/misc/mailto", "views/email/modals/schedule-send", "helpers/action-item-setup"], function (_exports, _edit, _mailto, _scheduleSend, _actionItemSetup) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _edit = _interopRequireDefault(_edit);
  _mailto = _interopRequireDefault(_mailto);
  _scheduleSend = _interopRequireDefault(_scheduleSend);
  _actionItemSetup = _interopRequireDefault(_actionItemSetup);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ComposeEmailModalView extends _edit.default {
    scope = 'Email';
    layoutName = 'composeSmall';
    saveDisabled = true;
    fullFormDisabled = true;
    isCollapsible = true;
    wasModified = false;
    shortcutKeys = {
      /** @this ComposeEmailModalView */
      'Control+Enter': function (e) {
        if (this.buttonList.findIndex(item => item.name === 'send' && !item.hidden && !item.disabled) === -1) {
          return;
        }
        e.stopPropagation();
        e.preventDefault();
        this.actionSend();
      },
      /** @this ComposeEmailModalView */
      'Control+KeyS': function (e) {
        if (this.buttonList.findIndex(item => item.name === 'saveDraft' && !item.hidden && !item.disabled) === -1) {
          return;
        }
        e.preventDefault();
        e.stopPropagation();
        this.actionSaveDraft();
      },
      /** @this ComposeEmailModalView */
      'Escape': function (e) {
        e.stopPropagation();
        e.preventDefault();
        const focusedFieldView = this.getRecordView().getFocusedFieldView();
        if (focusedFieldView) {
          this.model.set(focusedFieldView.fetch());
        }
        if (this.getRecordView().hasChanged()) {
          this.confirm(this.translate('confirmLeaveOutMessage', 'messages')).then(() => this.actionClose());
          return;
        }
        this.actionClose();
      }
    };
    setup() {
      super.setup();
      this.buttonList.unshift({
        name: 'saveDraft',
        text: this.translate('Save Draft', 'labels', 'Email'),
        title: 'Ctrl+S',
        onClick: () => this.actionSaveDraft()
      });
      this.buttonList.unshift({
        name: 'send',
        text: this.translate('Send', 'labels', 'Email'),
        style: 'primary',
        title: 'Ctrl+Enter',
        onClick: () => this.actionSend()
      });
      this.dropdownItemList.push({
        name: 'scheduleSend',
        text: this.translate('Schedule Send', 'labels', 'Email'),
        onClick: () => this.actionScheduleSend(),
        iconClass: 'far fa-clock'
      });
      this.$header = $('<a>').attr('role', 'button').attr('tabindex', '0').attr('data-action', 'fullFormDraft').text(this.getLanguage().translate('Compose Email'));
      this.events['click a[data-action="fullFormDraft"]'] = () => this.actionFullFormDraft();
      this.once('remove', () => {
        this.dialogIsHidden = false;
      });
      const helper = new _mailto.default();
      if (helper.toUse()) {
        this.once('after:render', () => this.actionClose());
        this.getRouter().confirmLeaveOut = false;
        const attributes = this.options.attributes || {};
        this.once('after:render', () => document.location.href = helper.composeLink(attributes));
      }
    }
    async setupLate() {
      this.listenTo(this.model, 'change', (m, o) => {
        if (o.ui) {
          this.wasModified = true;
        }
      });
    }
    createRecordView(model, callback) {
      const viewName = this.getMetadata().get('clientDefs.' + model.entityType + '.recordViews.compose') || 'views/email/record/compose';
      const options = {
        model: model,
        fullSelector: this.containerSelector + ' .edit-container',
        type: 'editSmall',
        layoutName: this.layoutName || 'detailSmall',
        buttonsDisabled: true,
        selectTemplateDisabled: this.options.selectTemplateDisabled,
        removeAttachmentsOnSelectTemplate: this.options.removeAttachmentsOnSelectTemplate,
        signatureDisabled: this.options.signatureDisabled,
        appendSignature: this.options.appendSignature,
        focusForCreate: this.options.focusForCreate,
        exit: () => {}
      };
      this.createView('edit', viewName, options, callback);
    }
    actionSend() {
      const dialog = this.dialog;
      const editView = /** @type {module:views/email/record/compose} */this.getRecordView();
      const model = editView.model;
      const afterSend = () => {
        this.dialogIsHidden = false;
        this.trigger('after:save', model);
        this.trigger('after:send', model);
        dialog.close();
        this.stopListening(editView, 'before:save', beforeSave);
        this.stopListening(editView, 'error:save', errorSave);
        this.remove();
      };
      const beforeSave = () => {
        this.dialogIsHidden = true;
        dialog.hideWithBackdrop();
        editView.setConfirmLeaveOut(false);
        if (!this.forceRemoveIsInitiated) {
          this.initiateForceRemove();
        }
      };
      const errorSave = () => {
        this.dialogIsHidden = false;
        if (this.isRendered()) {
          dialog.show();
        }
        this.stopListening(editView, 'before:save', beforeSave);
        this.stopListening(editView, 'error:save', errorSave);
      };
      this.listenToOnce(editView, 'after:send', afterSend);
      this.disableButton('send');
      this.disableButton('saveDraft');
      this.listenToOnce(editView, 'cancel:save', () => {
        this.enableButton('send');
        this.enableButton('saveDraft');
        this.stopListening(editView, 'after:send', afterSend);
        this.stopListening(editView, 'before:save', beforeSave);
        this.stopListening(editView, 'error:save', errorSave);
      });
      this.listenToOnce(editView, 'before:save', beforeSave);
      this.listenToOnce(editView, 'error:save', errorSave);
      editView.send();
    }

    /**
     * @param {import('views/record/base').SaveOptions} [options] Options.
     * @return {Promise}
     */
    actionSaveDraft(options) {
      const editView = /** @type {module:views/email/record/compose} */this.getRecordView();
      const model = editView.model;
      this.disableButton('send');
      this.disableButton('saveDraft');
      const afterSave = () => {
        this.enableButton('send');
        this.enableButton('saveDraft');
        Espo.Ui.success(this.translate('savedAsDraft', 'messages', 'Email'));
        this.trigger('after:save', model);
        this.$el.find('button[data-name="cancel"]').html(this.translate('Close'));
      };
      editView.once('after:save', () => afterSave());
      editView.once('cancel:save', () => {
        this.enableButton('send');
        this.enableButton('saveDraft');
        editView.off('after:save', afterSave);
      });
      return editView.saveDraft(options);
    }
    initiateForceRemove() {
      this.forceRemoveIsInitiated = true;
      const parentView = this.getParentView();
      if (!parentView) {
        return true;
      }
      parentView.once('remove', () => {
        if (!this.dialogIsHidden) {
          return;
        }
        this.remove();
      });
    }
    actionFullFormDraft() {
      this.actionSaveDraft({
        skipNotModifiedWarning: true
      }).then(() => {
        this.getRecordView().setConfirmLeaveOut(false);
        this.getRouter().navigate('#Email/edit/' + this.model.id, {
          trigger: true
        });
        this.close();
      }).catch(reason => {
        if (reason === 'notModified') {
          Espo.Ui.notify(false);
          this.getRouter().navigate('#Email/edit/' + this.model.id, {
            trigger: true
          });
        }
      });
    }
    beforeCollapse() {
      if (this.wasModified) {
        this.actionSaveDraft({
          skipNotModifiedWarning: true
        }).then(() => {
          this.getRecordView().setConfirmLeaveOut(false);
          this.getRouter().removeWindowLeaveOutObject(this);
        });
      }
      return super.beforeCollapse();
    }

    /**
     * @private
     */
    async actionScheduleSend() {
      // Prevents skipping required validation of the 'To' field.
      this.model.set('status', 'Sending');
      if (this.getRecordView().validate()) {
        Espo.Ui.error(this.translate('Not valid'));
        this.model.set('status', 'Draft');
        return;
      }
      this.model.set('status', 'Draft');
      const view = new _scheduleSend.default({
        model: this.model,
        onSave: () => {
          this.trigger('after:save', this.model);
          this.close();
        }
      });
      await this.assignView('dialog', view);
      await view.render();
    }

    /**
     * @protected
     */
    setupActionItems() {
      const actionItemSetup = new _actionItemSetup.default();
      actionItemSetup.setup({
        view: this,
        type: 'recordControls.compose.dropdown',
        waitFunc: promise => this.wait(promise),
        addFunc: item => this.addDropdownItem(item),
        showFunc: name => this.showActionItem(name),
        hideFunc: name => this.hideActionItem(name)
      });
      actionItemSetup.setup({
        view: this,
        type: 'recordControls.composeSide.buttons',
        waitFunc: promise => this.wait(promise),
        addFunc: item => {
          this.addButton({
            ...item,
            position: 'right'
          });
        },
        showFunc: name => this.showActionItem(name),
        hideFunc: name => this.hideActionItem(name),
        enableFunc: name => this.enableButton(name),
        disableFunc: name => this.disableButton(name)
      });
    }
  }
  var _default = _exports.default = ComposeEmailModalView;
});

define("views/modals/change-password", ["exports", "views/modal"], function (_exports, _modal) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ChangePasswordModalView extends _modal.default {
    template = 'modals/change-password';
    cssName = 'change-password';
    className = 'dialog dialog-record';
    setup() {
      this.buttonList = [{
        name: 'change',
        label: 'Change',
        style: 'danger'
      }, {
        name: 'cancel',
        label: 'Cancel'
      }];
      this.headerText = this.translate('Change Password', 'labels', 'User');
      const promise = this.getModelFactory().create('User', user => {
        this.model = user;
        this.createView('currentPassword', 'views/fields/password', {
          model: user,
          mode: 'edit',
          selector: '.field[data-name="currentPassword"]',
          defs: {
            name: 'currentPassword',
            params: {
              required: true
            }
          }
        });
        this.createView('password', 'views/user/fields/password', {
          model: user,
          mode: 'edit',
          selector: '.field[data-name="password"]',
          defs: {
            name: 'password',
            params: {
              required: true
            }
          }
        });
        this.createView('passwordConfirm', 'views/fields/password', {
          model: user,
          mode: 'edit',
          selector: '.field[data-name="passwordConfirm"]',
          defs: {
            name: 'passwordConfirm',
            params: {
              required: true
            }
          }
        });
      });
      this.wait(promise);
    }

    /**
     * @param {string} field
     * @return {module:views/fields/base}
     */
    getFieldView(field) {
      return this.getView(field);
    }

    // noinspection JSUnusedGlobalSymbols
    actionChange() {
      this.getFieldView('currentPassword').fetchToModel();
      this.getFieldView('password').fetchToModel();
      this.getFieldView('passwordConfirm').fetchToModel();
      const notValid = this.getFieldView('currentPassword').validate() || this.getFieldView('password').validate() || this.getFieldView('passwordConfirm').validate();
      if (notValid) {
        return;
      }
      this.$el.find('button[data-name="change"]').addClass('disabled');
      Espo.Ajax.putRequest('UserSecurity/password', {
        currentPassword: this.model.get('currentPassword'),
        password: this.model.get('password')
      }).then(() => {
        Espo.Ui.success(this.translate('passwordChanged', 'messages', 'User'));
        this.trigger('changed');
        this.close();
      }).catch(() => {
        this.$el.find('button[data-name="change"]').removeClass('disabled');
      });
    }
  }
  var _default = _exports.default = ChangePasswordModalView;
});

define("views/modals/auth2fa-required", ["exports", "views/modal"], function (_exports, _modal) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class Auth2faRequiredModalView extends _modal.default {
    noCloseButton = true;
    escapeDisabled = true;
    events = {
      'click [data-action="proceed"]': 'actionProceed',
      'click [data-action="logout"]': 'actionLogout'
    };

    // language=Handlebars
    templateContent = `
        <div class="complex-text">{{complexText viewObject.messageText}}</div>
        <div class="button-container btn-group" style="margin-top: 30px">
        <button class="btn btn-primary" data-action="proceed">{{translate 'Proceed'}}</button>
        <button class="btn btn-default" data-action="logout">{{translate 'Log Out'}}</button></div>
    `;
    setup() {
      this.buttonList = [];
      this.headerText = this.translate('auth2FARequiredHeader', 'messages', 'User');
      // noinspection JSUnusedGlobalSymbols
      this.messageText = this.translate('auth2FARequired', 'messages', 'User');
    }
    actionProceed() {
      this.createView('dialog', 'views/user/modals/security', {
        userModel: this.getUser()
      }, view => {
        view.render();
        this.listenToOnce(view, 'done', () => {
          this.clearView('dialog');
          this.close();
        });
      });
    }
    actionLogout() {
      this.getRouter().logout();
    }
  }
  var _default = _exports.default = Auth2faRequiredModalView;
});

define("views/modals/array-field-add", ["exports", "views/modal"], function (_exports, _modal) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ArrayFieldAddModalView extends _modal.default {
    template = 'modals/array-field-add';
    cssName = 'add-modal';
    backdrop = true;
    data() {
      return {
        optionDataList: this.getOptionDataList()
      };
    }
    events = {
      /** @this ArrayFieldAddModalView */
      'click .add': function (e) {
        const value = $(e.currentTarget).attr('data-value');
        this.trigger('add', value);
      },
      /** @this ArrayFieldAddModalView */
      'click input[type="checkbox"]': function (e) {
        const value = $(e.currentTarget).attr('data-value');
        if (e.target.checked) {
          this.checkedList.push(value);
        } else {
          const index = this.checkedList.indexOf(value);
          if (index !== -1) {
            this.checkedList.splice(index, 1);
          }
        }
        this.checkedList.length ? this.enableButton('select') : this.disableButton('select');
      },
      /** @this ArrayFieldAddModalView */
      'keyup input[data-name="quick-search"]': function (e) {
        this.processQuickSearch(e.currentTarget.value);
      }
    };
    setup() {
      this.headerText = this.translate('Add Item');
      this.checkedList = [];

      /** @type {Object.<string, string>} */
      this.translations = Espo.Utils.clone(this.options.translatedOptions || {});

      /** @type {string[]} */
      this.optionList = this.options.options || [];
      this.optionList.forEach(item => {
        if (item in this.translations) {
          return;
        }
        this.translations[item] = item;
      });
      this.buttonList = [{
        name: 'select',
        style: 'danger',
        label: 'Select',
        disabled: true,
        onClick: () => {
          this.trigger('add-mass', this.checkedList);
        }
      }, {
        name: 'cancel',
        label: 'Cancel'
      }];
    }
    afterRender() {
      this.$noData = this.$el.find('.no-data');
      setTimeout(() => {
        this.$el.find('input[data-name="quick-search"]').focus();
      }, 100);
    }

    /**
     * @protected
     * @return {{value: string, label: string}[]}
     */
    getOptionDataList() {
      return this.optionList.map(value => ({
        value: value,
        label: value in this.translations ? this.translations[value] : value
      }));
    }
    processQuickSearch(text) {
      text = text.trim();
      const $noData = this.$noData;
      $noData.addClass('hidden');
      if (!text) {
        this.$el.find('ul .list-group-item').removeClass('hidden');
        return;
      }
      const matchedList = [];
      const lowerCaseText = text.toLowerCase();
      this.optionList.forEach(item => {
        const label = this.translations[item].toLowerCase();
        for (const word of label.split(' ')) {
          const matched = word.indexOf(lowerCaseText) === 0;
          if (matched) {
            matchedList.push(item);
            return;
          }
        }
      });
      if (matchedList.length === 0) {
        this.$el.find('ul .list-group-item').addClass('hidden');
        $noData.removeClass('hidden');
        return;
      }
      this.optionList.forEach(item => {
        const $row = this.$el.find(`ul .list-group-item[data-name="${item}"]`);
        if (!~matchedList.indexOf(item)) {
          $row.addClass('hidden');
          return;
        }
        $row.removeClass('hidden');
      });
    }
  }
  var _default = _exports.default = ArrayFieldAddModalView;
});

define("views/modals/add-dashlet", ["exports", "views/modal"], function (_exports, _modal) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class AddDashletModalView extends _modal.default {
    template = 'modals/add-dashlet';
    cssName = 'add-dashlet';
    backdrop = true;
    events = {
      /** @this AddDashletModalView */
      'click .add': function (e) {
        const name = $(e.currentTarget).data('name');
        this.trigger('add', name);
        this.close();
      },
      /** @this AddDashletModalView */
      'keyup input[data-name="quick-search"]': function (e) {
        this.processQuickSearch(e.currentTarget.value);
      }
    };
    data() {
      return {
        dashletList: this.dashletList
      };
    }
    setup() {
      this.headerText = this.translate('Add Dashlet');
      const dashletList = Object.keys(this.getMetadata().get('dashlets') || {}).sort((v1, v2) => {
        return this.translate(v1, 'dashlets').localeCompare(this.translate(v2, 'dashlets'));
      });
      this.translations = {};
      this.dashletList = dashletList.filter(item => {
        const aclScope = this.getMetadata().get(['dashlets', item, 'aclScope']) || null;
        const accessDataList = this.getMetadata().get(['dashlets', item, 'accessDataList']) || null;
        if (this.options.parentType === 'Settings') {
          return true;
        }
        if (this.options.parentType === 'Portal') {
          if (accessDataList && accessDataList.find(item => item.inPortalDisabled)) {
            return false;
          }
          return true;
        }
        if (aclScope) {
          if (!this.getAcl().check(aclScope)) {
            return false;
          }
        }
        if (accessDataList) {
          if (!Espo.Utils.checkAccessDataList(accessDataList, this.getAcl(), this.getUser())) {
            return false;
          }
        }
        this.translations[item] = this.translate(item, 'dashlets');
        return true;
      });
      this.dashletList.forEach(item => {
        this.translations[item] = this.translate(item, 'dashlets');
      });
    }
    afterRender() {
      this.$noData = this.$el.find('.no-data');
      setTimeout(() => {
        this.$el.find('input[data-name="quick-search"]').focus();
      }, 100);
    }
    processQuickSearch(text) {
      text = text.trim();
      const $noData = this.$noData;
      $noData.addClass('hidden');
      if (!text) {
        this.$el.find('ul .list-group-item').removeClass('hidden');
        return;
      }
      const matchedList = [];
      const lowerCaseText = text.toLowerCase();
      this.dashletList.forEach(item => {
        if (!(item in this.translations)) {
          return;
        }
        const label = this.translations[item].toLowerCase();
        for (const word of label.split(' ')) {
          const matched = word.indexOf(lowerCaseText) === 0;
          if (matched) {
            matchedList.push(item);
            return;
          }
        }
      });
      if (matchedList.length === 0) {
        this.$el.find('ul .list-group-item').addClass('hidden');
        $noData.removeClass('hidden');
        return;
      }
      this.dashletList.forEach(item => {
        const $row = this.$el.find(`ul .list-group-item[data-name="${item}"]`);
        if (!~matchedList.indexOf(item)) {
          $row.addClass('hidden');
          return;
        }
        $row.removeClass('hidden');
      });
    }
  }
  var _default = _exports.default = AddDashletModalView;
});

define("views/modals/action-history", ["exports", "views/modal", "search-manager"], function (_exports, _modal, _searchManager) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  _searchManager = _interopRequireDefault(_searchManager);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ActionHistoryModalView extends _modal.default {
    template = 'modals/action-history';
    scope = 'ActionHistoryRecord';
    className = 'dialog dialog-record';
    backdrop = true;
    setup() {
      super.setup();
      this.buttonList = [{
        name: 'cancel',
        label: 'Close'
      }];
      this.scope = this.entityType = this.options.scope || this.scope;
      this.$header = $('<a>').attr('href', '#ActionHistoryRecord').addClass('action').attr('data-action', 'listView').text(this.getLanguage().translate(this.scope, 'scopeNamesPlural'));
      this.waitForView('list');
      this.getCollectionFactory().create(this.scope, collection => {
        collection.maxSize = this.getConfig().get('recordsPerPage') || 20;
        this.collection = collection;
        this.setupSearch();
        this.setupList();
        collection.fetch();
      });
    }

    // noinspection JSUnusedGlobalSymbols
    actionListView() {
      this.getRouter().navigate('#ActionHistoryRecord', {
        trigger: true
      });
      this.close();
    }
    setupSearch() {
      this.searchManager = new _searchManager.default(this.collection);
      this.collection.data.boolFilterList = ['onlyMy'];
      this.collection.where = this.searchManager.getWhere();
      this.createView('search', 'views/record/search', {
        collection: this.collection,
        fullSelector: this.containerSelector + ' .search-container',
        searchManager: this.searchManager,
        disableSavePreset: true,
        textFilterDisabled: true
      });
    }
    setupList() {
      const viewName = this.getMetadata().get(`clientDefs.${this.scope}.recordViews.list`) || 'views/record/list';
      this.listenToOnce(this.collection, 'sync', () => {
        this.createView('list', viewName, {
          collection: this.collection,
          fullSelector: this.containerSelector + ' .list-container',
          selectable: false,
          checkboxes: false,
          massActionsDisabled: true,
          rowActionsView: 'views/record/row-actions/view-only',
          type: 'listSmall',
          searchManager: this.searchManager,
          checkAllResultDisabled: true,
          buttonsDisabled: true
        });
      });
    }
  }
  var _default = _exports.default = ActionHistoryModalView;
});

define("views/lead-capture/opt-in-confirmation-success", ["exports", "view", "model"], function (_exports, _view, _model) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  _model = _interopRequireDefault(_model);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class OptInConfirmationSuccessView extends _view.default {
    template = 'lead-capture/opt-in-confirmation-success';
    setup() {
      const model = new _model.default();
      this.resultData = this.options.resultData;
      if (this.resultData.message) {
        model.set('message', this.resultData.message);
        this.createView('messageField', 'views/fields/text', {
          selector: '.field[data-name="message"]',
          mode: 'detail',
          inlineEditDisabled: true,
          model: model,
          name: 'message'
        });
      }
    }
    data() {
      return {
        resultData: this.options.resultData,
        defaultMessage: this.getLanguage().translate('optInIsConfirmed', 'messages', 'LeadCapture')
      };
    }
  }
  var _default = _exports.default = OptInConfirmationSuccessView;
});

define("views/lead-capture/opt-in-confirmation-expired", ["exports", "view"], function (_exports, _view) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class OptInConfirmationExpiredView extends _view.default {
    template = 'lead-capture/opt-in-confirmation-expired';
    setup() {
      this.resultData = this.options.resultData;
    }
    data() {
      return {
        defaultMessage: this.getLanguage().translate('optInConfirmationExpired', 'messages', 'LeadCapture')
      };
    }
  }
  var _default = _exports.default = OptInConfirmationExpiredView;
});

define("views/lead-capture/record/list", ["exports", "views/record/list"], function (_exports, _list) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _list = _interopRequireDefault(_list);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _list.default {
    massActionList = ['remove', 'massUpdate', 'export'];
  }
  _exports.default = _default;
});

define("views/lead-capture/record/detail", ["exports", "views/record/detail"], function (_exports, _detail) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _detail = _interopRequireDefault(_detail);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _detail.default {
    setupActionItems() {
      super.setupActionItems();
      this.addDropdownItem({
        label: 'Generate New API Key',
        name: 'generateNewApiKey',
        onClick: () => this.actionGenerateNewApiKey()
      });
      this.addDropdownItem({
        label: 'Generate New Form ID',
        name: 'generateNewFormId',
        onClick: () => this.actionGenerateNewFormId()
      });
    }
    actionGenerateNewApiKey() {
      this.confirm(this.translate('confirmation', 'messages'), () => {
        Espo.Ajax.postRequest('LeadCapture/action/generateNewApiKey', {
          id: this.model.id
        }).then(data => {
          this.model.set(data);
          Espo.Ui.success(this.translate('Done'));
        });
      });
    }
    async actionGenerateNewFormId() {
      await this.confirm(this.translate('confirmation', 'messages'));
      const data = await Espo.Ajax.postRequest('LeadCapture/action/generateNewFormId', {
        id: this.model.id
      });
      this.model.set(data);
      Espo.Ui.success(this.translate('Done'));
    }
  }
  _exports.default = _default;
});

define("views/lead-capture/record/panels/request", ["exports", "views/record/panels/side"], function (_exports, _side) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _side = _interopRequireDefault(_side);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _side.default {
    fieldList = ['exampleRequestUrl', 'exampleRequestMethod', 'exampleRequestHeaders', 'exampleRequestPayload'];
  }
  _exports.default = _default;
});

define("views/lead-capture/record/panels/form", ["exports", "views/record/panels/side"], function (_exports, _side) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _side = _interopRequireDefault(_side);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _side.default {
    fieldList = ['formUrl'];
  }
  _exports.default = _default;
});

define("views/lead-capture/fields/smtp-account", ["exports", "views/fields/enum"], function (_exports, _enum) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _enum = _interopRequireDefault(_enum);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _enum.default {
    /**
     * @private
     * @type {string}
     */
    dataUrl = 'LeadCapture/action/smtpAccountDataList';
    getAttributeList() {
      return [this.name, 'inboundEmailId'];
    }
    data() {
      const data = super.data();
      data.valueIsSet = this.model.has('inboundEmailId');
      data.isNotEmpty = this.model.has('inboundEmailId');
      data.value = this.getValueForDisplay();
      data.valueTranslated = data.value != null ? this.translatedOptions[data.value] : undefined;
      return data;
    }
    setupOptions() {
      super.setupOptions();
      this.params.options = [];
      this.translatedOptions = {};
      this.params.options.push('');
      if (!this.loadedOptionList) {
        if (this.model.get('inboundEmailId')) {
          const item = 'inboundEmail:' + this.model.get('inboundEmailId');
          this.params.options.push(item);
          this.translatedOptions[item] = (this.model.get('inboundEmailName') || this.model.get('inboundEmailId')) + ' (' + this.translate('group', 'labels', 'MassEmail') + ')';
        }
      } else {
        this.loadedOptionList.forEach(item => {
          this.params.options.push(item);
          this.translatedOptions[item] = (this.loadedOptionTranslations[item] || item) + ' (' + this.translate('group', 'labels', 'MassEmail') + ')';
        });
      }
      this.translatedOptions[''] = this.getConfig().get('outboundEmailFromAddress') + ' (' + this.translate('system', 'labels', 'MassEmail') + ')';
    }
    getValueForDisplay() {
      if (!this.model.has(this.name)) {
        if (this.model.has('inboundEmailId')) {
          if (this.model.get('inboundEmailId')) {
            return 'inboundEmail:' + this.model.get('inboundEmailId');
          } else {
            return '';
          }
        } else {
          return '';
        }
      }
      return this.model.get(this.name);
    }
    setup() {
      super.setup();
      if (this.getAcl().checkScope('MassEmail', 'create') || this.getAcl().checkScope('MassEmail', 'edit')) {
        Espo.Ajax.getRequest(this.dataUrl).then(dataList => {
          if (!dataList.length) {
            return;
          }
          this.loadedOptionList = [];
          this.loadedOptionTranslations = {};
          this.loadedOptionAddresses = {};
          this.loadedOptionFromNames = {};
          dataList.forEach(item => {
            this.loadedOptionList.push(item.key);
            this.loadedOptionTranslations[item.key] = item.emailAddress;
            this.loadedOptionAddresses[item.key] = item.emailAddress;
            this.loadedOptionFromNames[item.key] = item.fromName || '';
          });
          this.setupOptions();
          this.reRender();
        });
      }
    }
    fetch() {
      const data = {};
      const value = this.$element.val();
      data[this.name] = value;
      if (!value || value === '') {
        data.inboundEmailId = null;
        data.inboundEmailName = null;
      } else {
        const arr = value.split(':');
        if (arr.length > 1) {
          data.inboundEmailId = arr[1];
          data.inboundEmailName = this.translatedOptions[data.inboundEmailId] || data.inboundEmailId;
        }
      }
      return data;
    }
  }
  _exports.default = _default;
});

define("views/lead-capture/fields/phone-number-country", ["exports", "views/fields/enum", "intl-tel-input-globals"], function (_exports, _enum, _intlTelInputGlobals) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _enum = _interopRequireDefault(_enum);
  _intlTelInputGlobals = _interopRequireDefault(_intlTelInputGlobals);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  // noinspection NpmUsedModulesInstalled

  class LeadCapturePhoneNumberCountry extends _enum.default {
    setupOptions() {
      this.params.options = ['', ..._intlTelInputGlobals.default.getCountryData().map(item => item.iso2)];
      this.translatedOptions = _intlTelInputGlobals.default.getCountryData().reduce((map, item) => {
        map[item.iso2] = `${item.iso2.toUpperCase()} +${item.dialCode}`;
        return map;
      }, {});
    }
  }
  var _default = _exports.default = LeadCapturePhoneNumberCountry;
});

define("views/lead-capture/fields/form-theme", ["exports", "views/fields/enum"], function (_exports, _enum) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _enum = _interopRequireDefault(_enum);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class FormThemeFieldView extends _enum.default {
    setupOptions() {
      const list = Object.keys(this.getMetadata().get('themes') || {}).sort((v1, v2) => {
        if (v2 === 'EspoRtl') {
          return -1;
        }
        return this.translate(v1, 'theme').localeCompare(this.translate(v2, 'theme'));
      });
      this.params.options = ['', ...list];
    }
  }
  _exports.default = FormThemeFieldView;
});

define("views/lead-capture/fields/field-list", ["exports", "views/fields/array"], function (_exports, _array) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _array = _interopRequireDefault(_array);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _array.default {
    // language=Handlebars
    detailTemplateContent = `
        {{#unless isEmpty}}
            {{#each items}}
                <div
                    class="multi-enum-item-container"
                    style="{{#if strikeThrough}} text-decoration: line-through; {{/if}}"
                >{{label}}{{#if required}} *{{/if}}</div>
            {{/each}}
        {{else}}
            {{#if valueIsSet}}<span class="none-value">{{translate 'None'}}</span>
            {{else}}
                <span class="loading-value"></span>
            {{/if}}
        {{/unless}}
    `;

    /**
     * @private
     * @type {string[]}
     */
    webFormNotAllowedFields;
    data() {
      /** @type {string[]|null} */
      const items = this.model.get(this.name);
      if (!items) {
        return super.data();
      }
      const dataItems = items.map(it => {
        return {
          label: this.translatedOptions[it] || it,
          strikeThrough: this.model.attributes.formEnabled && this.webFormNotAllowedFields.includes(it),
          required: this.isFieldRequired(it)
        };
      });
      return {
        ...super.data(),
        items: dataItems
      };
    }
    getAttributeList() {
      return [...super.getAttributeList(), 'formEnabled', 'fieldParams'];
    }
    setup() {
      this.webFormNotAllowedFields = [];
      super.setup();
      this.listenTo(this.model, 'change:formEnabled', (m, v, o) => {
        if (!o.ui || !this.isDetailMode()) {
          return;
        }
        this.reRender();
      });
      this.addActionHandler('toggleRequired', (e, target) => this.toggleRequired(target.dataset.value));
    }
    setupOptions() {
      this.params.options = [];
      this.translatedOptions = {};

      /** @type {Record.<string, Record>} */
      const fields = this.getMetadata().get(['entityDefs', 'Lead', 'fields']) || {};

      /** @type {string[]} */
      const ignoreFieldList = this.getMetadata().get(`entityDefs.LeadCapture.fields.fieldList.ignoreFieldList`) || [];

      /** @type {string[]} */
      const webFormTypeList = this.getMetadata().get(`entityDefs.LeadCapture.fields.fieldList.webFormFieldTypeList`) || [];
      for (const field in fields) {
        const defs = fields[field];
        if (defs.disabled || defs.utility || defs.readOnly) {
          continue;
        }
        if (ignoreFieldList.includes(field)) {
          continue;
        }
        if (!webFormTypeList.includes(defs.type)) {
          this.webFormNotAllowedFields.push(field);
        }
        this.params.options.push(field);
        this.translatedOptions[field] = this.translate(field, 'fields', 'Lead');
      }
    }
    getItemHtml(value) {
      const html = super.getItemHtml(value);
      const div = document.createElement('div');
      div.innerHTML = html;

      /** @type {HTMLElement} */
      const item = div.querySelector('.list-group-item');
      const group = document.createElement('div');
      group.classList.add('btn-group', 'pull-right', 'item-button');
      const button = document.createElement('button');
      button.classList.add('btn', 'btn-link', 'btn-sm', 'dropdown-toggle');
      button.innerHTML = `<span class="caret"></span>`;
      button.dataset.toggle = 'dropdown';
      button.type = 'button';
      const ul = document.createElement('ul');
      ul.classList.add('dropdown-menu', 'pull-right');
      const li = document.createElement('li');
      const a = document.createElement('a');
      a.dataset.value = value;
      a.dataset.action = 'toggleRequired';
      a.role = 'button';
      a.tabIndex = 0;
      if (this.isFieldRequired(value)) {
        a.innerHTML += `<span class="check-icon fas fa-check pull-right"></span>`;
      }
      const textDiv = document.createElement('div');
      textDiv.textContent = this.translate('required', 'fields', 'Admin');
      a.append(textDiv);
      li.append(a);
      ul.append(li);
      group.append(button, ul);
      item.append(group);
      if (this.isFieldRequired(value)) {
        const text = div.querySelector('.text');
        if (text) {
          text.innerHTML += ' *';
        }
      }
      return div.innerHTML;
    }

    /**
     * @param {string} field
     * @return {boolean}
     */
    isFieldRequired(field) {
      const params = this.model.attributes.fieldParams || {};
      const fieldParams = params[field] || {};
      return !!fieldParams.required;
    }

    /**
     * @private
     * @param {string} field
     */
    toggleRequired(field) {
      const params = Espo.Utils.cloneDeep(this.model.attributes.fieldParams || {});
      if (!params[field]) {
        params[field] = {};
      }
      if (!('required' in params[field])) {
        params[field].required = false;
      }
      params[field].required = !params[field].required;
      const newParams = {};

      /** @type {string[]} */
      const fieldList = this.model.attributes.fieldList || [];
      fieldList.forEach(it => newParams[it] = params[it]);
      this.model.set('fieldParams', newParams, {
        ui: true
      });
      this.reRender();
    }
    addValue(value) {
      /** @type {string[]} */
      const items = this.model.get(this.name);
      let isAdded = false;
      if (items && !items.includes(value)) {
        isAdded = true;
      }
      super.addValue(value);
      if (isAdded && this.getMetadata().get(`entityDefs.Lead.fields.${value}.required`) && !this.isFieldRequired(value)) {
        this.toggleRequired(value);
      }
    }
  }
  _exports.default = _default;
});

define("views/last-viewed/list", ["exports", "views/list"], function (_exports, _list) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _list = _interopRequireDefault(_list);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _list.default {
    searchPanel = false;
    createButton = false;
    setup() {
      super.setup();
      this.collection.url = 'LastViewed';
    }
  }
  _exports.default = _default;
});

define("views/last-viewed/record/list", ["exports", "views/record/list"], function (_exports, _list) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _list = _interopRequireDefault(_list);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _list.default {
    layoutName = 'listForLastViewed';
    rowActionsDisabled = true;
    massActionsDisabled = true;
    headerDisabled = true;
  }
  _exports.default = _default;
});

define("views/last-viewed/fields/target", ["exports", "views/fields/link-parent"], function (_exports, _linkParent) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _linkParent = _interopRequireDefault(_linkParent);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class LastViewedTargetFieldView extends _linkParent.default {
    data() {
      return {
        ...super.data(),
        linkClass: 'text-record'
      };
    }
  }
  _exports.default = LastViewedTargetFieldView;
});

define("views/last-viewed/fields/target-type", ["exports", "views/fields/base"], function (_exports, _base) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class LastViewedTargetTypeFieldView extends _base.default {
    // language=Handlebars
    templateContent = `
        <span class="text-soft small">{{value}}</span>
    `;
    data() {
      const value = this.model.attributes[this.name];
      return {
        value: this.translate(value, 'scopeNames')
      };
    }
  }
  _exports.default = LastViewedTargetTypeFieldView;
});

define("views/last-viewed/fields/created-at", ["exports", "views/fields/datetime-short"], function (_exports, _datetimeShort) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _datetimeShort = _interopRequireDefault(_datetimeShort);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class LastViewedCreatedAtFieldView extends _datetimeShort.default {
    data() {
      return {
        ...super.data(),
        style: 'soft'
      };
    }
    setup() {
      super.setup();
      this.params.hasSeconds = false;
    }
    afterRender() {
      super.afterRender();
      if (this.isListMode()) {
        var _this$element$querySe;
        (_this$element$querySe = this.element.querySelector(':scope > span')) === null || _this$element$querySe === void 0 || _this$element$querySe.classList.add('small');
      }
    }
  }
  _exports.default = LastViewedCreatedAtFieldView;
});

define("views/global-search/status-field", ["exports", "views/fields/base"], function (_exports, _base) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _base.default {
    // language=Handlebars
    listTemplateContent = `
        {{~#if stringValue}}
            <span class="label label-sm label-state label-{{style}}">{{stringValue}}</span>
        {{/if~}}
    `;
    data() {
      /** @type {string} */
      const entityType = this.model.attributes._scope;
      const field = this.getMetadata().get(`scopes.${entityType}.statusField`);
      if (!field) {
        return {};
      }
      const value = this.model.attributes[field];
      if (!value) {
        return {};
      }
      const stringValue = this.getLanguage().translateOption(value, field, entityType);
      const style = this.getMetadata().get(`entityDefs.${entityType}.fields.${field}.style.${value}`) ?? 'default';
      return {
        stringValue,
        style
      };
    }
  }
  _exports.default = _default;
});

define("views/global-search/scope-badge", ["exports", "view"], function (_exports, _view) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class GlobalSearchScopeBadgeView extends _view.default {
    template = 'global-search/scope-badge';
    data() {
      return {
        label: this.translate(this.model.get('_scope'), 'scopeNames')
      };
    }
  }

  // noinspection JSUnusedGlobalSymbols
  var _default = _exports.default = GlobalSearchScopeBadgeView;
});

define("views/global-search/panel", ["exports", "view"], function (_exports, _view) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class GlobalSearchPanel extends _view.default {
    template = 'global-search/panel';
    setup() {
      this.addHandler('click', '[data-action="closePanel"]', () => this.close());
      this.maxSize = this.getConfig().get('globalSearchMaxSize') || 10;
    }
    afterRender() {
      this.collection.reset();
      this.collection.maxSize = this.maxSize;
      this.collection.fetch().then(() => this.createRecordView()).then(view => view.render());
    }

    /**
     * @return {Promise<module:views/record/list-expanded>}
     */
    createRecordView() {
      // noinspection JSValidateTypes
      return this.createView('list', 'views/record/list-expanded', {
        selector: '.list-container',
        collection: this.collection,
        listLayout: {
          rows: [[{
            name: 'name',
            view: 'views/global-search/name-field'
          }], [{
            name: 'status',
            view: 'views/global-search/status-field'
          }]],
          right: {
            name: 'read',
            view: 'views/global-search/scope-badge',
            width: '80px'
          }
        }
      });
    }
    close() {
      this.trigger('close');
    }
  }
  var _default = _exports.default = GlobalSearchPanel;
});

define("views/global-search/name-field", ["exports", "views/fields/base", "helpers/record-modal"], function (_exports, _base, _recordModal) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  _recordModal = _interopRequireDefault(_recordModal);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class GlobalSearchNameFieldView extends _base.default {
    listTemplate = 'global-search/name-field';
    data() {
      const scope = this.model.attributes._scope;
      return {
        scope: scope,
        name: this.model.attributes.name || this.translate('None'),
        id: this.model.id,
        iconHtml: this.getHelper().getScopeColorIconHtml(scope)
      };
    }
    setup() {
      this.addHandler('auxclick', 'a[href]:not([role="button"])', (/** MouseEvent */e) => {
        if (!this.isReadMode()) {
          return;
        }
        const isCombination = e.button === 1 && (e.ctrlKey || e.metaKey);
        if (!isCombination) {
          return;
        }
        e.preventDefault();
        e.stopPropagation();
        this.quickView();
      });
    }
    quickView() {
      const helper = new _recordModal.default();
      helper.showDetail(this, {
        id: this.model.id,
        entityType: this.model.attributes._scope
      });
    }
  }
  var _default = _exports.default = GlobalSearchNameFieldView;
});

define("views/global-search/global-search", ["exports", "ui/autocomplete", "helpers/site/tabs", "views/site/navbar/item", "helpers/site/window-panel-helper"], function (_exports, _autocomplete, _tabs, _item, _windowPanelHelper) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _autocomplete = _interopRequireDefault(_autocomplete);
  _tabs = _interopRequireDefault(_tabs);
  _item = _interopRequireDefault(_item);
  _windowPanelHelper = _interopRequireDefault(_windowPanelHelper);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/global-search/global-search */

  class GlobalSearchView extends _item.default {
    template = 'global-search/global-search';

    /**
     * @private
     * @type {HTMLElement}
     */
    containerElement;

    /**
     * @private
     * @type {HTMLInputElement}
     */
    inputElement;

    /**
     * @private
     * @type {boolean}
     */
    tabQuickSearch;

    /**
     * @private
     * @type {boolean}
     */
    hasGlobalSearch;

    /**
     * @private
     * @type {TabsHelper}
     */
    tabsHelper;

    /**
     * @private
     * @type {Autocomplete}
     */
    autocomplete;

    /**
     * @private
     * @type {module:views/global-search/global-search~tabData[]}
     */
    tabDataList;
    data() {
      return {
        hasSearchButton: this.hasGlobalSearch
      };
    }
    setup() {
      this.addHandler('keydown', 'input.global-search-input', 'onKeydown');
      this.addHandler('focus', 'input.global-search-input', 'onFocus');
      this.addHandler('click', '[data-action="search"]', () => this.runSearch());
      const promise = this.getCollectionFactory().create('GlobalSearch', collection => {
        this.collection = collection;
        this.collection.url = 'GlobalSearch';
      });
      this.wait(promise);
      this.closeNavbarOnShow = /iPad|iPhone|iPod/.test(navigator.userAgent);
      this.onMouseUpBind = this.onMouseUp.bind(this);
      this.onClickBind = this.onClick.bind(this);
      this.tabQuickSearch = this.getConfig().get('tabQuickSearch') || false;
      this.hasGlobalSearch = (this.getConfig().get('globalSearchEntityList') || []).length > 0;
      this.tabsHelper = new _tabs.default(this.getConfig(), this.getPreferences(), this.getUser(), this.getAcl(), this.getMetadata(), this.getLanguage());
      this.tabDataList = this.getTabDataList();
    }

    /**
     * @param {MouseEvent} e
     * @private
     */
    onFocus(e) {
      const inputElement = /** @type {HTMLInputElement} */e.target;
      inputElement.select();
    }

    /**
     * @param {KeyboardEvent} e
     * @private
     */
    onKeydown(e) {
      if (!this.hasGlobalSearch) {
        return;
      }
      const key = Espo.Utils.getKeyFromKeyEvent(e);
      if (e.key === 'Enter' || key === 'Enter' || key === 'Control+Enter') {
        this.runSearch();
        return;
      }
      if (key === 'Escape') {
        this.closePanel();
      }
    }
    afterRender() {
      this.$input = this.$el.find('input.global-search-input');
      this.inputElement = this.$input.get(0);
      if (this.tabQuickSearch) {
        this.autocomplete = new _autocomplete.default(this.inputElement, {
          minChars: 1,
          lookupFunction: async query => {
            const lower = query.toLowerCase();
            return this.tabDataList.filter(it => {
              if (it.words.find(word => word.startsWith(lower))) {
                return true;
              }
              if (it.lowerLabel.toLowerCase().startsWith(lower)) {
                return true;
              }
              return false;
            }).sort((a, b) => {
              if (a.lowerLabel.startsWith(lower) && !b.lowerLabel.startsWith(lower)) {
                return -1;
              }
              if (!a.lowerLabel.startsWith(lower) && b.lowerLabel.startsWith(lower)) {
                return 1;
              }
              const lengthDiff = a.lowerLabel.length - b.lowerLabel.length;
              if (lengthDiff !== 0) {
                return lengthDiff;
              }
              return a.lowerLabel.localeCompare(b.lowerLabel);
            }).map(it => ({
              value: it.label,
              url: it.url
            }));
          },
          formatResult: /** {value: string, url: string} */item => {
            const a = document.createElement('a');
            a.text = item.value;
            a.href = item.url;
            a.classList.add('text-default');
            return a.outerHTML;
          },
          onSelect: /** {value: string, url: string} */item => {
            window.location.href = item.url;
            this.inputElement.value = '';
          }
        });
        this.once('render remove', () => {
          this.autocomplete.dispose();
          this.autocomplete = undefined;
        });
      }
    }

    /**
     * @private
     */
    runSearch() {
      const text = this.$input.val().trim();
      if (text !== '' && text.length >= 2) {
        this.search(text);
      }
    }

    /**
     * @private
     * @param {string} text
     */
    search(text) {
      this.collection.url = this.collection.urlRoot = 'GlobalSearch?q=' + encodeURIComponent(text);
      this.showPanel();
    }

    /**
     * @param {MouseEvent} e
     * @private
     */
    onMouseUp(e) {
      if (e.button !== 0) {
        return;
      }
      const target = e.target;
      if (!(target instanceof HTMLElement)) {
        return;
      }
      if (this.containerElement === target || this.containerElement.contains(target) || target.classList.contains('modal') || target.closest('.dialog.modal')) {
        return;
      }
      return this.closePanel();
    }

    /**
     * @param {MouseEvent} e
     * @private
     */
    onClick(e) {
      const target = e.target;
      if (!(target instanceof HTMLAnchorElement)) {
        return;
      }
      if (target.dataset.action === 'showMore' || target.classList.contains('global-search-button')) {
        return;
      }
      setTimeout(() => this.closePanel(), 100);
    }

    /**
     * @private
     */
    showPanel() {
      this.closePanel();
      if (this.autocomplete) {
        this.autocomplete.hide();
      }
      if (this.closeNavbarOnShow) {
        this.$el.closest('.navbar-body').removeClass('in');
      }
      const $container = this.$container = $('<div>').attr('id', 'global-search-panel');
      this.containerElement = this.$container.get(0);
      $container.appendTo(this.$el.find('.global-search-panel-container'));
      this.createView('panel', 'views/global-search/panel', {
        fullSelector: '#global-search-panel',
        collection: this.collection
      }).then(async view => {
        await view.render();
        new _windowPanelHelper.default(view);
        this.listenToOnce(view, 'close', this.closePanel);
      });
      document.addEventListener('mouseup', this.onMouseUpBind);
      document.addEventListener('click', this.onClickBind);
    }

    /**
     * @private
     */
    closePanel() {
      const $container = $('#global-search-panel');
      $container.remove();
      if (this.hasView('panel')) {
        this.getView('panel').remove();
      }
      document.removeEventListener('mouseup', this.onMouseUpBind);
      document.removeEventListener('click', this.onClickBind);
    }

    /**
     * @typedef {Object} module:views/global-search/global-search~tabData
     * @property {string} url
     * @property {string} label
     * @property {string} lowerLabel
     * @property {string[]} words
     */

    /**
     * @private
     * @return {module:views/global-search/global-search~tabData[]}
     */
    getTabDataList() {
      /** @type {module:views/global-search/global-search~tabData[]}*/
      let list = [];

      /**
       * @param {string|TabsHelper~item} item
       * @return {module:views/global-search/global-search~tabData}
       */
      const toData = item => {
        const label = this.tabsHelper.getTranslatedTabLabel(item);
        const url = this.tabsHelper.isTabScope(item) ? `#${item}` : item.url;
        return {
          url: url,
          label: label,
          words: label.split(' ').map(it => it.toLowerCase()),
          lowerLabel: label.toLowerCase()
        };
      };

      /**
       * @param {string|TabsHelper~item} item
       * @return {boolean}
       */
      const checkTab = item => {
        return (this.tabsHelper.isTabScope(item) || this.tabsHelper.isTabUrl(item)) && this.tabsHelper.checkTabAccess(item);
      };
      for (const item of this.tabsHelper.getTabList()) {
        if (checkTab(item)) {
          list.push(toData(item));
          continue;
        }
        if (this.tabsHelper.isTabGroup(item) && item.itemList) {
          for (const subItem of item.itemList) {
            if (checkTab(subItem)) {
              list.push(toData(subItem));
            }
          }
        }
      }
      if (this.getUser().isAdmin()) {
        /** @type {
         *     Record<string, {
         *         order?: number,
         *         itemList: {
         *             url: string,
         *             tabQuickSearch: boolean,
         *             label: string,
         *         }[]
         *     }>
         * } panels */
        const panels = this.getMetadata().get(`app.adminPanel`) || {};
        Object.entries(panels).map(it => it[1]).sort((a, b) => a.order - b.order).filter(it => it.itemList) // For bc.
        .forEach(it => {
          it.itemList.filter(it => it.tabQuickSearch && it.label).filter(it => !list.find(subIt => subIt.url === it.url)).forEach(it => {
            const label = this.translate(it.label, 'labels', 'Admin');
            list.push({
              label: this.translate(it.label, 'labels', 'Admin'),
              url: it.url,
              lowerLabel: label.toLowerCase(),
              words: label.split(' ').map(it => it.toLowerCase())
            });
          });
        });
      }
      list = list.filter((it, i) => {
        return list.findIndex(subIt => subIt.url === it.url) === i && list.findIndex(subIt => subIt.lowerLabel === it.lowerLabel) === i;
      });

      /** @type {Record<string, {tab: boolean}>} */
      const scopes = this.getMetadata().get('scopes') || {};
      Object.entries(scopes).filter(_ref => {
        let [scope, it] = _ref;
        return it.tab && checkTab(scope);
      }).forEach(_ref2 => {
        let [scope] = _ref2;
        const data = toData(scope);
        if (list.find(it => it.lowerLabel === data.lowerLabel)) {
          return;
        }
        list.push(data);
      });
      return list.filter((item, index) => list.findIndex(it => it.lowerLabel === item.lowerLabel) === index);
    }
    isAvailable() {
      if (this.tabQuickSearch && !this.getUser().isPortal()) {
        return true;
      }
      let isAvailable = false;

      /** @type {string[]} */
      const entityTypeList = this.getConfig().get('globalSearchEntityList') || [];
      for (const it of entityTypeList) {
        if (this.getAcl().checkScope(it)) {
          isAvailable = true;
          break;
        }
      }
      return isAvailable;
    }
  }
  var _default = _exports.default = GlobalSearchView;
});

define("views/global/fields/is-locked", ["exports", "views/fields/bool"], function (_exports, _bool) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _bool = _interopRequireDefault(_bool);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class IsLockedFieldView extends _bool.default {
    //language=Handlebars
    detailTemplateContent = `
        {{~#if valueIsSet~}}
            {{~#if value~}}
                <span class="fas fa-lock text-soft"></span>
            {{~else~}}
                <input
                    class="form-checkbox"
                    type="checkbox" {{#if value}} checked {{/if}}
                    disabled
                >
            {{~/if~}}
        {{~else~}}
            <span class="loading-value"></span>
        {{~/if~}}
    `;
  }
  _exports.default = IsLockedFieldView;
});

define("views/fields/varchar-column", ["exports", "views/fields/varchar"], function (_exports, _varchar) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _varchar = _interopRequireDefault(_varchar);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class VarcharColumnFieldView extends _varchar.default {
    searchTypeList = ['startsWith', 'contains', 'equals', 'endsWith', 'like', 'isEmpty', 'isNotEmpty'];
    fetchSearch() {
      const type = this.fetchSearchType() || 'startsWith';
      if (~['isEmpty', 'isNotEmpty'].indexOf(type)) {
        if (type === 'isEmpty') {
          return {
            typeFront: type,
            where: {
              type: 'or',
              value: [{
                type: 'columnIsNull',
                field: this.name
              }, {
                type: 'columnEquals',
                field: this.name,
                value: ''
              }]
            }
          };
        }
        return {
          typeFront: type,
          where: {
            type: 'and',
            value: [{
              type: 'columnNotEquals',
              field: this.name,
              value: ''
            }, {
              type: 'columnIsNotNull',
              field: this.name,
              value: null
            }]
          }
        };
      }
      let value = this.$element.val().toString().trim();
      value = value.trim();
      if (value) {
        return {
          value: value,
          type: 'column'.Espo.Utils.upperCaseFirst(type),
          data: {
            type: type,
            value: value
          }
        };
      }
      return null;
    }
  }
  var _default = _exports.default = VarcharColumnFieldView;
});

define("views/fields/users", ["exports", "views/fields/link-multiple"], function (_exports, _linkMultiple) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _linkMultiple = _interopRequireDefault(_linkMultiple);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class UsersFieldView extends _linkMultiple.default {
    init() {
      this.assignmentPermission = this.getAcl().getPermissionLevel('assignmentPermission');
      if (this.assignmentPermission === 'no') {
        this.readOnly = true;
      }
      super.init();
    }
    getSelectBoolFilterList() {
      if (this.assignmentPermission === 'team' || this.assignmentPermission === 'no') {
        return ['onlyMyTeam'];
      }
    }
    getSelectPrimaryFilterName() {
      return 'active';
    }
  }
  var _default = _exports.default = UsersFieldView;
});

define("views/fields/teams", ["exports", "views/fields/link-multiple"], function (_exports, _linkMultiple) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _linkMultiple = _interopRequireDefault(_linkMultiple);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class TeamsFieldView extends _linkMultiple.default {
    init() {
      this.assignmentPermission = this.getAcl().getPermissionLevel('assignmentPermission');
      super.init();
    }
    getSelectBoolFilterList() {
      if (this.assignmentPermission === 'team' || this.assignmentPermission === 'no') {
        return ['onlyMy'];
      }
    }

    /** @inheritDoc */
    getOnEmptyAutocomplete() {
      if (this.autocompleteOnEmpty) {
        return undefined;
      }
      if (this.assignmentPermission === 'no') {
        return undefined;
      }

      /** @type {Record} */
      const names = this.getUser().get('teamsNames') || {};
      const list = this.getUser().getTeamIdList().filter(id => !this.ids.includes(id)).map(id => ({
        id: id,
        name: names[id] || id
      }));
      return Promise.resolve(list);
    }
  }
  var _default = _exports.default = TeamsFieldView;
});

define("views/fields/range-currency", ["exports", "views/fields/range-float", "views/fields/currency", "ui/select"], function (_exports, _rangeFloat, _currency, _select) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _rangeFloat = _interopRequireDefault(_rangeFloat);
  _currency = _interopRequireDefault(_currency);
  _select = _interopRequireDefault(_select);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class RangeCurrencyFieldView extends _rangeFloat.default {
    type = 'rangeCurrency';
    editTemplate = 'fields/range-currency/edit';
    data() {
      return {
        currencyField: this.currencyField,
        currencyValue: this.model.get(this.fromCurrencyField) || this.getPreferences().get('defaultCurrency') || this.getConfig().get('defaultCurrency'),
        currencyList: this.currencyList,
        ...super.data()
      };
    }
    setup() {
      super.setup();
      const ucName = Espo.Utils.upperCaseFirst(this.name);
      this.fromCurrencyField = 'from' + ucName + 'Currency';
      this.toCurrencyField = 'to' + ucName + 'Currency';
      this.currencyField = this.name + 'Currency';
      this.currencyList = this.getConfig().get('currencyList') || ['USD'];
      this.decimalPlaces = this.getConfig().get('currencyDecimalPlaces');
    }
    setupAutoNumericOptions() {
      this.autoNumericOptions = {
        digitGroupSeparator: this.thousandSeparator || '',
        decimalCharacter: this.decimalMark,
        modifyValueOnWheel: false,
        selectOnFocus: false,
        decimalPlaces: this.decimalPlaces,
        allowDecimalPadding: true,
        showWarnings: false,
        formulaMode: true
      };
      if (this.decimalPlaces === null) {
        this.autoNumericOptions.decimalPlaces = this.decimalPlacesRawValue;
        this.autoNumericOptions.decimalPlacesRawValue = this.decimalPlacesRawValue;
        this.autoNumericOptions.allowDecimalPadding = false;
      }
    }
    afterRender() {
      super.afterRender();
      if (this.mode === this.MODE_EDIT) {
        this.$currency = this.$el.find('[data-name="' + this.currencyField + '"]');
        _select.default.init(this.$currency);
      }
    }
    formatNumber(value) {
      return _currency.default.prototype.formatNumberDetail.call(this, value);
    }
    getValueForDisplay() {
      let fromValue = this.model.get(this.fromField);
      let toValue = this.model.get(this.toField);
      fromValue = isNaN(fromValue) ? null : fromValue;
      toValue = isNaN(toValue) ? null : toValue;
      const currencyValue = this.model.get(this.fromCurrencyField) || this.model.get(this.toCurrencyField);
      const symbol = this.getMetadata().get(['app', 'currency', 'symbolMap', currencyValue]) || currencyValue;
      if (fromValue !== null && toValue !== null) {
        return this.formatNumber(fromValue) + ' &#8211 ' + this.formatNumber(toValue) + ' ' + symbol + '';
      }
      if (fromValue) {
        return '&#62;&#61; ' + this.formatNumber(fromValue) + ' ' + symbol + '';
      }
      if (toValue) {
        return '&#60;&#61; ' + this.formatNumber(toValue) + ' ' + symbol + '';
      }
      return this.translate('None');
    }
    fetch() {
      const data = super.fetch();
      const currencyValue = this.$currency.val();
      if (data[this.fromField] !== null) {
        data[this.fromCurrencyField] = currencyValue;
      } else {
        data[this.fromCurrencyField] = null;
      }
      if (data[this.toField] !== null) {
        data[this.toCurrencyField] = currencyValue;
      } else {
        data[this.toCurrencyField] = null;
      }
      return data;
    }
  }

  // noinspection JSUnusedGlobalSymbols
  var _default = _exports.default = RangeCurrencyFieldView;
});

define("views/fields/number", ["exports", "views/fields/varchar"], function (_exports, _varchar) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _varchar = _interopRequireDefault(_varchar);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class NumberFieldView extends _varchar.default {
    type = 'number';
    validations = [];
    inlineEditDisabled = true;
    readOnly = true;
    data() {
      return {
        ...super.data(),
        textClass: 'numeric-text'
      };
    }

    /** @inheritDoc */
    fetch() {
      return {};
    }
  }
  var _default = _exports.default = NumberFieldView;
});

define("views/fields/map", ["exports", "views/fields/base"], function (_exports, _base) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class MapFieldView extends _base.default {
    type = 'map';
    detailTemplate = 'fields/map/detail';
    listTemplate = 'fields/map/detail';

    /** @type {string} */
    addressField;
    /** @type {string} */
    provider;
    height = 300;
    DEFAULT_PROVIDER = 'Google';

    // noinspection JSCheckFunctionSignatures
    data() {
      const data = super.data();
      data.hasAddress = this.hasAddress();

      // noinspection JSValidateTypes
      return data;
    }
    setup() {
      this.addressField = this.name.slice(0, this.name.length - 3);
      this.provider = this.provider || this.getConfig().get('mapProvider') || this.DEFAULT_PROVIDER;
      this.height = this.options.height || this.params.height || this.height;
      const addressAttributeList = Object.keys(this.getMetadata().get('fields.address.fields') || {}).map(a => this.addressField + Espo.Utils.upperCaseFirst(a));
      this.listenTo(this.model, 'sync', model => {
        let isChanged = false;
        addressAttributeList.forEach(attribute => {
          if (model.hasChanged(attribute)) {
            isChanged = true;
          }
        });
        if (isChanged && this.isRendered()) {
          this.reRender();
        }
      });
      this.listenTo(this.model, 'after:save', () => {
        if (this.isRendered()) {
          this.reRender();
        }
      });
    }
    hasAddress() {
      return !!this.model.get(this.addressField + 'City') || !!this.model.get(this.addressField + 'PostalCode');
    }
    onRemove() {
      $(window).off('resize.' + this.cid);
    }
    afterRender() {
      this.addressData = {
        city: this.model.get(this.addressField + 'City'),
        street: this.model.get(this.addressField + 'Street'),
        postalCode: this.model.get(this.addressField + 'PostalCode'),
        country: this.model.get(this.addressField + 'Country'),
        state: this.model.get(this.addressField + 'State')
      };
      this.$map = this.$el.find('.map');
      if (this.hasAddress()) {
        this.renderMap();
      }
    }
    renderMap() {
      this.processSetHeight(true);
      if (this.height === 'auto') {
        $(window).off('resize.' + this.cid);
        $(window).on('resize.' + this.cid, this.processSetHeight.bind(this));
      }
      const rendererId = this.getMetadata().get(['app', 'mapProviders', this.provider, 'renderer']);
      if (rendererId) {
        Espo.loader.require(rendererId, Renderer => {
          new Renderer(this).render(this.addressData);
        });
        return;
      }
      const methodName = 'afterRender' + this.provider.replace(/\s+/g, '');
      if (typeof this[methodName] === 'function') {
        this[methodName]();
      }
    }
    processSetHeight(init) {
      let height = this.height;
      if (this.height === 'auto') {
        height = this.$el.parent().height();
        if (init && height <= 0) {
          setTimeout(() => this.processSetHeight(true), 50);
          return;
        }
      }
      this.$map.css('height', height + 'px');
    }
  }
  var _default = _exports.default = MapFieldView;
});

define("views/fields/link-one", ["exports", "views/fields/link"], function (_exports, _link) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _link = _interopRequireDefault(_link);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class LinkOneFieldView extends _link.default {
    searchTypeList = ['is', 'isEmpty', 'isNotEmpty', 'isOneOf'];
    fetchSearch() {
      const type = this.$el.find('select.search-type').val();
      const value = this.$el.find('[data-name="' + this.idName + '"]').val();
      if (['isOneOf'].includes(type) && !this.searchData.oneOfIdList.length) {
        return {
          type: 'isNotNull',
          attribute: 'id',
          data: {
            type: type
          }
        };
      }
      if (type === 'isOneOf') {
        if (!value) {
          return false;
        }
        return {
          type: 'linkedWith',
          field: this.name,
          value: this.searchData.oneOfIdList,
          data: {
            type: type,
            oneOfIdList: this.searchData.oneOfIdList,
            oneOfNameHash: this.searchData.oneOfNameHash
          }
        };
      }
      if (type === 'is' || !type) {
        if (!value) {
          return false;
        }
        return {
          type: 'linkedWith',
          field: this.name,
          value: value,
          data: {
            type: type,
            nameValue: this.$el.find('[data-name="' + this.nameName + '"]').val()
          }
        };
      }
      if (type === 'isEmpty') {
        return {
          type: 'isNotLinked',
          data: {
            type: type
          }
        };
      }
      if (type === 'isNotEmpty') {
        return {
          type: 'isLinked',
          data: {
            type: type
          }
        };
      }
    }
  }
  var _default = _exports.default = LinkOneFieldView;
});

define("views/fields/link-multiple-with-status", ["exports", "views/fields/link-multiple"], function (_exports, _linkMultiple) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _linkMultiple = _interopRequireDefault(_linkMultiple);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class LinkMultipleWithStatusFieldView extends _linkMultiple.default {
    /**
     * @protected
     * @type {string[]}
     */
    canceledStatusList;
    setup() {
      super.setup();
      this.columnsName = this.name + 'Columns';
      this.columns = Espo.Utils.cloneDeep(this.model.get(this.columnsName) || {});
      this.listenTo(this.model, 'change:' + this.columnsName, () => {
        this.columns = Espo.Utils.cloneDeep(this.model.get(this.columnsName) || {});
      });
      this.statusField = this.getMetadata().get(['entityDefs', this.model.entityType, 'fields', this.name, 'columns', 'status']);
      this.styleMap = this.getMetadata().get(['entityDefs', this.foreignScope, 'fields', this.statusField, 'style']) || {};
      this.canceledStatusList = [];
    }
    getAttributeList() {
      const list = super.getAttributeList();
      list.push(this.name + 'Columns');
      return list;
    }
    getDetailLinkHtml(id, name) {
      const status = (this.columns[id] || {}).status;
      if (!status) {
        return super.getDetailLinkHtml(id, name);
      }
      const style = this.styleMap[status];
      const targetStyleList = ['success', 'info', 'danger', 'warning'];
      if (!style || !~targetStyleList.indexOf(style)) {
        return super.getDetailLinkHtml(id, name);
      }
      let iconStyle = '';
      if (style === 'success') {
        iconStyle = 'fas fa-check text-success small';
      } else if (this.canceledStatusList.includes(status)) {
        iconStyle = `fas fa-times text-${style} small`;
      }
      return `<span class="${iconStyle}" style="display: inline-block; min-width: 12px"></span> ` + super.getDetailLinkHtml(id, name);
    }
  }

  // noinspection JSUnusedGlobalSymbols
  var _default = _exports.default = LinkMultipleWithStatusFieldView;
});

define("views/fields/link-multiple-with-columns-with-primary", ["exports", "views/fields/link-multiple-with-columns", "views/fields/link-multiple-with-primary"], function (_exports, _linkMultipleWithColumns, _linkMultipleWithPrimary) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _linkMultipleWithColumns = _interopRequireDefault(_linkMultipleWithColumns);
  _linkMultipleWithPrimary = _interopRequireDefault(_linkMultipleWithPrimary);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * A link-multiple field with columns and a primary.
   */
  class LinkMultipleWithColumnsWithPrimaryFieldView extends _linkMultipleWithColumns.default {
    /**
     * @protected
     * @type {string}
     */
    primaryLink;
    getAttributeList() {
      const list = super.getAttributeList();
      list.push(this.primaryIdAttribute);
      list.push(this.primaryNameAttribute);
      return list;
    }
    setup() {
      this.primaryLink = this.primaryLink || this.model.getFieldParam(this.name, 'primaryLink');
      this.primaryIdAttribute = this.primaryLink + 'Id';
      this.primaryNameAttribute = this.primaryLink + 'Name';
      super.setup();
      this.events['click [data-action="switchPrimary"]'] = e => {
        const $target = $(e.currentTarget);
        const id = $target.data('id');
        this.switchPrimary(id);
      };
      this.primaryId = this.model.get(this.primaryIdAttribute);
      this.primaryName = this.model.get(this.primaryNameAttribute);
      this.listenTo(this.model, 'change:' + this.primaryIdAttribute, () => {
        this.primaryId = this.model.get(this.primaryIdAttribute);
        this.primaryName = this.model.get(this.primaryNameAttribute);
      });
    }
    setPrimaryId(id) {
      this.primaryId = id;
      this.primaryName = id ? this.nameHash[id] : null;
    }
    switchPrimary(id) {
      const $switch = this.$el.find(`[data-id="${id}"][data-action="switchPrimary"]`);
      if (!$switch.hasClass('active')) {
        this.$el.find('button[data-action="switchPrimary"]').removeClass('active').children().addClass('text-muted');
        $switch.addClass('active').children().removeClass('text-muted');
        this.setPrimaryId(id);
        this.trigger('change');
      }
    }
    renderLinks() {
      if (this.primaryId) {
        this.addLinkHtml(this.primaryId, this.primaryName);
      }
      this.ids.forEach(id => {
        if (id !== this.primaryId) {
          this.addLinkHtml(id, this.nameHash[id]);
        }
      });
    }
    getValueForDisplay() {
      if (this.isDetailMode() || this.isListMode()) {
        const itemList = [];
        if (this.primaryId) {
          itemList.push(this.getDetailLinkHtml(this.primaryId, this.primaryName));
        }
        if (!this.ids.length) {
          return;
        }
        this.ids.forEach(id => {
          if (id !== this.primaryId) {
            itemList.push(this.getDetailLinkHtml(id));
          }
        });
        return itemList.map(item => $('<div>').append(item).addClass('link-multiple-item').get(0).outerHTML).join('');
      }
    }
    deleteLink(id) {
      if (id === this.primaryId) {
        this.setPrimaryId(null);
      }
      super.deleteLink(id);
    }
    deleteLinkHtml(id) {
      super.deleteLinkHtml(id);
      this.managePrimaryButton();
    }
    addLinkHtml(id, name) {
      name = name || id;
      if (this.isSearchMode()) {
        return super.addLinkHtml(id, name);
      }
      if (this.skipRoles) {
        return _linkMultipleWithPrimary.default.prototype.addLinkHtml.call(this, id, name);
      }
      const $el = super.addLinkHtml(id, name);
      const isPrimary = id === this.primaryId;
      const $star = $('<span>').addClass('fas fa-star fa-sm').addClass(!isPrimary ? 'text-muted' : '');
      const $button = $('<button>').attr('type', 'button').addClass('btn btn-link btn-sm pull-right hidden').attr('title', this.translate('Primary')).attr('data-action', 'switchPrimary').attr('data-id', id).append($star);
      $button.insertAfter($el.children().first().children().first());
      this.managePrimaryButton();
      return $el;
    }
    managePrimaryButton() {
      const $primary = this.$el.find('button[data-action="switchPrimary"]');
      if ($primary.length > 1) {
        $primary.removeClass('hidden');
      } else {
        $primary.addClass('hidden');
      }
      if ($primary.filter('.active').length === 0) {
        const $first = $primary.first();
        if ($first.length) {
          $first.addClass('active').children().removeClass('text-muted');
          const id = $first.data('id');
          this.setPrimaryId(id);
          if (id !== this.primaryId) {
            this.trigger('change');
          }
        }
      }
    }
    fetch() {
      const data = super.fetch();
      data[this.primaryIdAttribute] = this.primaryId;
      data[this.primaryNameAttribute] = this.primaryName;
      return data;
    }
  }

  // noinspection JSUnusedGlobalSymbols
  var _default = _exports.default = LinkMultipleWithColumnsWithPrimaryFieldView;
});

define("views/fields/link-multiple-category-tree", ["exports", "views/fields/link-multiple"], function (_exports, _linkMultiple) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _linkMultiple = _interopRequireDefault(_linkMultiple);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class LinkMultipleCategoryTreeFieldView extends _linkMultiple.default {
    selectRecordsView = 'views/modals/select-category-tree-records';
    autocompleteDisabled = false;
    getUrl(id) {
      return '#' + this.entityType + '/list/categoryId=' + id;
    }
  }

  // noinspection JSUnusedGlobalSymbols
  var _default = _exports.default = LinkMultipleCategoryTreeFieldView;
});

define("views/fields/link-category-tree", ["exports", "views/fields/link"], function (_exports, _link) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _link = _interopRequireDefault(_link);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class LinkCategoryTreeFieldView extends _link.default {
    selectRecordsView = 'views/modals/select-category-tree-records';
    autocompleteDisabled = false;
    getUrl() {
      if (this.getMetadata().get(`scopes.${this.entityType}.type`) === 'CategoryTree') {
        // Can be used for the 'parent' field of the category entity type.
        return super.getUrl();
      }
      const id = this.model.get(this.idName);
      if (!id) {
        return null;
      }
      return '#' + this.entityType + '/list/categoryId=' + id;
    }
  }

  // noinspection JSUnusedGlobalSymbols
  var _default = _exports.default = LinkCategoryTreeFieldView;
});

define("views/fields/json-object", ["exports", "views/fields/base"], function (_exports, _base) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class JsonObjectFieldView extends _base.default {
    type = 'jsonObject';
    listTemplate = 'fields/json-object/detail';
    detailTemplate = 'fields/json-object/detail';
    data() {
      const data = super.data();
      data.valueIsSet = this.model.has(this.name);
      data.isNotEmpty = !!this.model.get(this.name);
      return data;
    }
    getValueForDisplay() {
      const value = this.model.get(this.name);
      if (!value) {
        return null;
      }
      return JSON.stringify(value, null, 2).replace(/(\r\n|\n|\r)/gm, '<br>').replace(/\s/g, '&nbsp;');
    }
  }
  var _default = _exports.default = JsonObjectFieldView;
});

define("views/fields/id", ["exports", "views/fields/varchar"], function (_exports, _varchar) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _varchar = _interopRequireDefault(_varchar);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class IdFieldView extends _varchar.default {
    searchTypeList = ['equals', 'notEquals', 'isEmpty'];
  }
  var _default = _exports.default = IdFieldView;
});

define("views/fields/formula", ["exports", "views/fields/text"], function (_exports, _text) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _text = _interopRequireDefault(_text);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * @type {{
   *     edit: import('ace-builds').edit,
   *     require: import('ace-builds').require,
   * }}
   */
  let ace;
  class FormulaFieldView extends _text.default {
    detailTemplate = 'fields/formula/detail';
    editTemplate = 'fields/formula/edit';
    height = 308;
    maxLineDetailCount = 80;
    maxLineEditCount = 200;
    insertDisabled = false;
    checkSyntaxDisabled = false;
    smallFont = false;
    events = {
      /** @this FormulaFieldView */
      'click [data-action="addAttribute"]': function () {
        this.addAttribute();
      },
      /** @this FormulaFieldView */
      'click [data-action="addFunction"]': function () {
        this.addFunction();
      },
      /** @this FormulaFieldView */
      'click [data-action="checkSyntax"]': function () {
        this.checkSyntax();
      }
    };
    setup() {
      super.setup();
      this.height = this.options.height || this.params.height || this.height;
      this.smallFont = this.options.smallFont || this.params.smallFont || this.smallFont;
      this.maxLineDetailCount = this.options.maxLineDetailCount || this.params.maxLineDetailCount || this.maxLineDetailCount;
      this.maxLineEditCount = this.options.maxLineEditCount || this.params.maxLineEditCount || this.maxLineEditCount;
      this.targetEntityType = this.options.targetEntityType || this.params.targetEntityType || this.targetEntityType;
      this.insertDisabled = this.insertDisabled || this.options.insertDisabled;
      this.checkSyntaxDisabled = this.checkSyntaxDisabled || this.options.checkSyntaxDisabled;
      this.containerId = 'editor-' + Math.floor(Math.random() * 10000 + 1).toString();
      if (this.mode === this.MODE_EDIT || this.mode === this.MODE_DETAIL) {
        this.wait(this.requireAce());
      }
      this.on('remove', () => {
        if (this.editor) {
          this.editor.destroy();
        }
      });
    }
    requireAce() {
      return Espo.loader.requirePromise('lib!ace').then(lib => {
        ace = /** window.ace */lib;
        const list = [Espo.loader.requirePromise('lib!ace-mode-javascript'), Espo.loader.requirePromise('lib!ace-ext-language_tools')];
        if (this.getThemeManager().getParam('isDark')) {
          list.push(Espo.loader.requirePromise('lib!ace-theme-tomorrow_night'));
        }
        return Promise.all(list);
      });
    }
    data() {
      const data = super.data();
      data.containerId = this.containerId;
      data.targetEntityType = this.targetEntityType;
      data.hasSide = !this.insertDisabled || !this.checkSyntaxDisabled;
      data.hasInsert = !this.insertDisabled;
      data.hasCheckSyntax = !this.checkSyntaxDisabled;
      return data;
    }
    afterRender() {
      super.afterRender();
      this.$editor = this.$el.find('#' + this.containerId);
      if (this.$editor.length && (this.mode === this.MODE_EDIT || this.mode === this.MODE_DETAIL || this.mode === this.MODE_LIST)) {
        const fontSize = this.smallFont ? 'var(--font-size-small)' : 'var(--font-size-base)';
        const lineHeight = this.smallFont ? 'var(--line-height-small)' : 'var(--line-height-computed)';
        this.$editor.css('fontSize', fontSize);
        if (this.mode === this.MODE_EDIT) {
          const height = (this.height * this.getThemeManager().getFontSizeFactor()).toString();
          this.$editor.css('minHeight', `${height}px`);
        }
        const editor = this.editor = ace.edit(this.containerId);
        editor.setOptions({
          fontFamily: 'var(--font-family-monospace)'
        });
        editor.setFontSize(fontSize);
        editor.container.style.lineHeight = lineHeight;
        editor.renderer.updateFontSize();
        editor.setOptions({
          maxLines: this.mode === this.MODE_EDIT ? this.maxLineEditCount : this.maxLineDetailCount
        });
        if (this.getThemeManager().getParam('isDark')) {
          editor.setOptions({
            theme: 'ace/theme/tomorrow_night'
          });
        }
        if (this.isEditMode()) {
          // noinspection JSCheckFunctionSignatures
          editor.getSession().on('change', () => {
            this.trigger('change', {
              ui: true
            });
          });
          editor.getSession().setUseWrapMode(true);
        }
        if (this.isReadMode()) {
          editor.setReadOnly(true);
          // noinspection JSUnresolvedReference
          editor.renderer.$cursorLayer.element.style.display = "none";
          editor.renderer.setShowGutter(false);
        }
        editor.setShowPrintMargin(false);
        editor.getSession().setUseWorker(false);
        editor.commands.removeCommand('find');
        editor.setHighlightActiveLine(false);
        const JavaScriptMode = ace.require('ace/mode/javascript').Mode;
        editor.session.setMode(new JavaScriptMode());
        if (!this.insertDisabled && !this.isReadMode()) {
          this.initAutocomplete();
        }
      }
    }
    fetch() {
      const data = {};
      let value = this.editor.getValue();
      if (value === '') {
        value = null;
      }
      data[this.name] = value;
      return data;
    }
    addAttribute() {
      this.createView('dialog', 'views/admin/formula/modals/add-attribute', {
        scope: this.targetEntityType
      }, view => {
        view.render();
        this.listenToOnce(view, 'add', attribute => {
          this.editor.insert(attribute);
          this.clearView('dialog');
        });
      });
    }
    addFunction() {
      this.createView('dialog', 'views/admin/formula/modals/add-function', {
        scope: this.targetEntityType,
        functionDataList: this.getFunctionDataList()
      }, view => {
        view.render();
        this.listenToOnce(view, 'add', string => {
          this.editor.insert(string);
          this.clearView('dialog');
        });
      });
    }

    /**
     * @private
     * @return {{
     *     name: string,
     *     insertText?: string,
     *     returnType?: string,
     * }[]}
     */
    getFunctionDataList() {
      let list = [...this.getMetadata().get(['app', 'formula', 'functionList'], [])].filter(item => item.insertText);
      if (this.options.additionalFunctionDataList) {
        list = list.concat(this.options.additionalFunctionDataList);
      }
      const allowedFunctionList = /** @type string[] */this.options.allowedFunctionList;
      if (allowedFunctionList) {
        list = list.filter(/** {name: string} */item => {
          for (const func of allowedFunctionList) {
            if (func.endsWith('\\') && item.name.startsWith(func)) {
              return true;
            }
            if (item.name === func) {
              return true;
            }
          }
          return false;
        });
      }
      if (!this.targetEntityType) {
        list = list.filter(item => {
          if (item.name.indexOf('entity\\') === 0) {
            return false;
          }
          return true;
        });
      }
      return list;
    }
    initAutocomplete() {
      const functionItemList = this.getFunctionDataList().filter(item => item.insertText);
      const attributeList = this.getFormulaAttributeList();
      ace.require('ace/ext/language_tools');
      this.editor.setOptions({
        enableBasicAutocompletion: true,
        enableLiveAutocompletion: true
      });

      // noinspection JSUnusedGlobalSymbols
      const completer = {
        identifierRegexps: [/[\\a-zA-Z0-9{}\[\].$'"]/],
        getCompletions: function (editor, session, pos, prefix, callback) {
          const matchedFunctionItemList = functionItemList.filter(originalItem => {
            const text = originalItem.name.toString().toLowerCase();
            if (text.indexOf(prefix) === 0) {
              return true;
            }
            const parts = text.split('\\');
            if (parts[parts.length - 1].indexOf(prefix) === 0) {
              return true;
            }
            if (parts.length > 2 && parts[parts.length - 2].indexOf(prefix) === 0) {
              return true;
            }
            return false;
          });
          let itemList = matchedFunctionItemList.map(item => {
            return {
              caption: item.name + '()',
              value: item.insertText,
              meta: item.returnType || null,
              completer: {
                insertMatch: (editor, data) => {
                  editor.completer.insertMatch({
                    value: data.value
                  });
                  const index = data.value.indexOf('(');
                  if (!~index) {
                    return;
                  }
                  if (~data.value.indexOf('()')) {
                    return;
                  }
                  const pos = editor.selection.getCursor();

                  // noinspection JSCheckFunctionSignatures
                  editor.gotoLine(pos.row + 1, pos.column - data.value.length + index + 1);
                }
              }
            };
          });
          const matchedAttributeList = attributeList.filter(item => {
            if (item.indexOf(prefix) === 0) {
              return true;
            }
            return false;
          });
          const itemAttributeList = matchedAttributeList.map(item => {
            return {
              name: item,
              value: item,
              meta: 'attribute'
            };
          });

          // noinspection JSCheckFunctionSignatures
          itemList = itemList.concat(itemAttributeList);
          callback(null, itemList);
        }
      };
      this.editor.completers = [completer];
    }
    getFormulaAttributeList() {
      if (!this.targetEntityType) {
        return [];
      }
      const attributeList = this.getFieldManager().getEntityTypeAttributeList(this.targetEntityType).concat(['id']).sort();
      const links = this.getMetadata().get(['entityDefs', this.targetEntityType, 'links']) || {};
      const linkList = [];
      Object.keys(links).forEach(link => {
        const type = links[link].type;
        if (!type) {
          return;
        }
        if (~['belongsToParent', 'hasOne', 'belongsTo'].indexOf(type)) {
          linkList.push(link);
        }
      });
      linkList.sort();
      linkList.forEach(link => {
        const scope = links[link].entity;
        if (!scope) {
          return;
        }
        if (links[link].disabled) {
          return;
        }
        const linkAttributeList = this.getFieldManager().getEntityTypeAttributeList(scope).sort();
        linkAttributeList.forEach(item => {
          attributeList.push(link + '.' + item);
        });
      });
      return attributeList;
    }
    checkSyntax() {
      const expression = this.editor.getValue();
      if (!expression) {
        Espo.Ui.success(this.translate('checkSyntaxSuccess', 'messages', 'Formula'));
        return;
      }
      Espo.Ajax.postRequest('Formula/action/checkSyntax', {
        expression: expression
      }).then(/** Record */response => {
        if (response.isSuccess) {
          Espo.Ui.success(this.translate('checkSyntaxSuccess', 'messages', 'Formula'));
          return;
        }
        let message = this.translate('checkSyntaxError', 'messages', 'Formula');
        if (response.message) {
          message += ' ' + response.message;
        }
        Espo.Ui.error(message);
      });
    }
  }
  var _default = _exports.default = FormulaFieldView;
});

define("views/fields/foreign", ["exports", "views/fields/base"], function (_exports, _base) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ForeignFieldView extends _base.default {
    type = 'foreign';
  }
  var _default = _exports.default = ForeignFieldView;
});

define("views/fields/foreign-varchar", ["exports", "views/fields/varchar", "helpers/misc/foreign-field"], function (_exports, _varchar, _foreignField) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _varchar = _interopRequireDefault(_varchar);
  _foreignField = _interopRequireDefault(_foreignField);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ForeignVarcharFieldView extends _varchar.default {
    type = 'foreign';
    setup() {
      const helper = new _foreignField.default(this);
      const foreignParams = helper.getForeignParams();
      for (const param in foreignParams) {
        this.params[param] = foreignParams[param];
      }
      super.setup();
    }
  }
  var _default = _exports.default = ForeignVarcharFieldView;
});

define("views/fields/foreign-url", ["exports", "views/fields/url", "helpers/misc/foreign-field"], function (_exports, _url, _foreignField) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _url = _interopRequireDefault(_url);
  _foreignField = _interopRequireDefault(_foreignField);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ForeignUrlFieldView extends _url.default {
    type = 'foreign';
    readOnly = true;
    setup() {
      const helper = new _foreignField.default(this);
      const foreignParams = helper.getForeignParams();
      for (const param in foreignParams) {
        this.params[param] = foreignParams[param];
      }
      super.setup();
    }
  }
  var _default = _exports.default = ForeignUrlFieldView;
});

define("views/fields/foreign-url-multiple", ["exports", "views/fields/url-multiple", "helpers/misc/foreign-field"], function (_exports, _urlMultiple, _foreignField) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _urlMultiple = _interopRequireDefault(_urlMultiple);
  _foreignField = _interopRequireDefault(_foreignField);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ForeignUrlMultipleFieldView extends _urlMultiple.default {
    type = 'foreign';
    readOnly = true;
    setup() {
      const helper = new _foreignField.default(this);
      const foreignParams = helper.getForeignParams();
      for (const param in foreignParams) {
        this.params[param] = foreignParams[param];
      }
      super.setup();
    }
  }
  var _default = _exports.default = ForeignUrlMultipleFieldView;
});

define("views/fields/foreign-text", ["exports", "views/fields/text", "helpers/misc/foreign-field"], function (_exports, _text, _foreignField) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _text = _interopRequireDefault(_text);
  _foreignField = _interopRequireDefault(_foreignField);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ForeignTextFieldView extends _text.default {
    type = 'foreign';
    setup() {
      const helper = new _foreignField.default(this);
      const foreignParams = helper.getForeignParams();
      for (const param in foreignParams) {
        this.params[param] = foreignParams[param];
      }
      super.setup();
    }
  }
  var _default = _exports.default = ForeignTextFieldView;
});

define("views/fields/foreign-phone", ["exports", "views/fields/phone"], function (_exports, _phone) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _phone = _interopRequireDefault(_phone);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ForeignPhoneFieldView extends _phone.default {
    type = 'foreign';
    readOnly = true;
    setup() {
      super.setup();

      // Numeric search does not work for foreign.
      this.isNumeric = false;
    }
  }
  var _default = _exports.default = ForeignPhoneFieldView;
});

define("views/fields/foreign-multi-enum", ["exports", "views/fields/multi-enum", "views/fields/foreign-array", "helpers/misc/foreign-field"], function (_exports, _multiEnum, _foreignArray, _foreignField) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _multiEnum = _interopRequireDefault(_multiEnum);
  _foreignArray = _interopRequireDefault(_foreignArray);
  _foreignField = _interopRequireDefault(_foreignField);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ForeignMultiEnumFieldView extends _multiEnum.default {
    type = 'foreign';

    /**
     * @private
     * @type {string}
     */
    foreignEntityType;
    setup() {
      const helper = new _foreignField.default(this);
      const foreignParams = helper.getForeignParams();
      for (const param in foreignParams) {
        this.params[param] = foreignParams[param];
      }
      this.foreignEntityType = helper.getEntityType();
      super.setup();
    }
    setupOptions() {
      _foreignArray.default.prototype.setupOptions.call(this);
    }
  }
  var _default = _exports.default = ForeignMultiEnumFieldView;
});

define("views/fields/foreign-int", ["exports", "views/fields/int", "helpers/misc/foreign-field"], function (_exports, _int, _foreignField) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _int = _interopRequireDefault(_int);
  _foreignField = _interopRequireDefault(_foreignField);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ForeignIntFieldView extends _int.default {
    type = 'foreign';
    setup() {
      const helper = new _foreignField.default(this);
      const foreignParams = helper.getForeignParams();
      for (const param in foreignParams) {
        this.params[param] = foreignParams[param];
      }
      this.disableFormatting = foreignParams.disableFormatting;
      super.setup();
    }
  }
  var _default = _exports.default = ForeignIntFieldView;
});

define("views/fields/foreign-float", ["exports", "views/fields/float", "helpers/misc/foreign-field"], function (_exports, _float, _foreignField) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _float = _interopRequireDefault(_float);
  _foreignField = _interopRequireDefault(_foreignField);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ForeignFloatFieldView extends _float.default {
    type = 'foreign';
    setup() {
      const helper = new _foreignField.default(this);
      const foreignParams = helper.getForeignParams();
      for (const param in foreignParams) {
        this.params[param] = foreignParams[param];
      }
      super.setup();
    }
  }
  var _default = _exports.default = ForeignFloatFieldView;
});

define("views/fields/foreign-email", ["exports", "views/fields/email"], function (_exports, _email) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _email = _interopRequireDefault(_email);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ForeignEmailFieldView extends _email.default {
    type = 'foreign';
    readOnly = true;
  }
  var _default = _exports.default = ForeignEmailFieldView;
});

define("views/fields/foreign-datetime", ["exports", "views/fields/datetime", "helpers/misc/foreign-field"], function (_exports, _datetime, _foreignField) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _datetime = _interopRequireDefault(_datetime);
  _foreignField = _interopRequireDefault(_foreignField);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ForeignDatetimeFieldView extends _datetime.default {
    type = 'foreign';
    setup() {
      const helper = new _foreignField.default(this);
      const foreignParams = helper.getForeignParams();
      for (const param in foreignParams) {
        this.params[param] = foreignParams[param];
      }
      super.setup();
    }
  }
  var _default = _exports.default = ForeignDatetimeFieldView;
});

define("views/fields/foreign-date", ["exports", "views/fields/date", "helpers/misc/foreign-field"], function (_exports, _date, _foreignField) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _date = _interopRequireDefault(_date);
  _foreignField = _interopRequireDefault(_foreignField);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ForeignDateFieldView extends _date.default {
    type = 'foreign';
    setup() {
      const helper = new _foreignField.default(this);
      const foreignParams = helper.getForeignParams();
      for (const param in foreignParams) {
        this.params[param] = foreignParams[param];
      }
      super.setup();
    }
  }
  var _default = _exports.default = ForeignDateFieldView;
});

define("views/fields/foreign-currency-converted", ["exports", "views/fields/currency-converted"], function (_exports, _currencyConverted) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _currencyConverted = _interopRequireDefault(_currencyConverted);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ForeignCurrencyConvertedFieldView extends _currencyConverted.default {
    type = 'foreign';
  }
  var _default = _exports.default = ForeignCurrencyConvertedFieldView;
});

define("views/fields/foreign-checklist", ["exports", "views/fields/checklist", "helpers/misc/foreign-field", "views/fields/foreign-array"], function (_exports, _checklist, _foreignField, _foreignArray) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _checklist = _interopRequireDefault(_checklist);
  _foreignField = _interopRequireDefault(_foreignField);
  _foreignArray = _interopRequireDefault(_foreignArray);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ForeignChecklistFieldView extends _checklist.default {
    type = 'foreign';

    /**
     * @private
     * @type {string}
     */
    foreignEntityType;
    setup() {
      const helper = new _foreignField.default(this);
      const foreignParams = helper.getForeignParams();
      for (const param in foreignParams) {
        this.params[param] = foreignParams[param];
      }
      this.foreignEntityType = helper.getEntityType();
      super.setup();
    }
    setupOptions() {
      _foreignArray.default.prototype.setupOptions.call(this);
    }
  }
  var _default = _exports.default = ForeignChecklistFieldView;
});

define("views/fields/foreign-bool", ["exports", "views/fields/bool", "helpers/misc/foreign-field"], function (_exports, _bool, _foreignField) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _bool = _interopRequireDefault(_bool);
  _foreignField = _interopRequireDefault(_foreignField);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ForeignBoolFieldView extends _bool.default {
    type = 'foreign';
    setup() {
      const helper = new _foreignField.default(this);
      const foreignParams = helper.getForeignParams();
      for (const param in foreignParams) {
        this.params[param] = foreignParams[param];
      }
      super.setup();
    }
  }
  var _default = _exports.default = ForeignBoolFieldView;
});

define("views/fields/followers", ["exports", "views/fields/link-multiple"], function (_exports, _linkMultiple) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _linkMultiple = _interopRequireDefault(_linkMultiple);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class FollowersFieldView extends _linkMultiple.default {
    foreignScope = 'User';
    portionSize = 6;
    linkClass = 'text-default';
    setup() {
      super.setup();
      this.addActionHandler('showMoreFollowers', (e, target) => {
        this.showMoreFollowers();
        $(target).remove();
      });
      this.portionSize = this.getConfig().get('recordFollowersLoadLimit') || this.portionSize;
      this.limit = this.portionSize;
      this.listenTo(this.model, 'change:isFollowed', () => {
        const idList = this.model.get(this.idsName) || [];
        if (this.model.get('isFollowed')) {
          if (!idList.includes(this.getUser().id)) {
            idList.unshift(this.getUser().id);
            const nameMap = this.model.get(this.nameHashName) || {};
            nameMap[this.getUser().id] = this.getUser().get('name');
            this.model.trigger('change:' + this.idsName);
            this.reRender();
          }
          return;
        }
        const index = idList.indexOf(this.getUser().id);
        if (~index) {
          idList.splice(index, 1);
          this.model.trigger('change:' + this.idsName);
          this.reRender();
        }
      });
    }

    /*reloadFollowers() {
        this.getCollectionFactory().create('User', collection => {
            collection.url = this.model.entityType + '/' + this.model.id + '/followers';
            collection.offset = 0;
            collection.maxSize = this.limit;
              this.listenToOnce(collection, 'sync', () => {
                let idList = [];
                let nameMap = {};
                  collection.forEach(user => {
                    idList.push(user.id);
                    nameMap[user.id] = user.get('name');
                });
                  this.model.set(this.idsName, idList);
                this.model.set(this.nameHashName, nameMap);
                  this.reRender();
            });
              collection.fetch();
        });
    }*/

    showMoreFollowers() {
      this.getCollectionFactory().create('User', collection => {
        collection.url = this.model.entityType + '/' + this.model.id + '/followers';
        collection.offset = this.ids.length || 0;
        collection.maxSize = this.portionSize;
        collection.data.select = ['id', 'name'].join(',');
        collection.orderBy = null;
        collection.order = null;
        this.listenToOnce(collection, 'sync', () => {
          const idList = this.model.get(this.idsName) || [];
          const nameMap = this.model.get(this.nameHashName) || {};
          collection.forEach(user => {
            idList.push(user.id);
            nameMap[user.id] = user.get('name');
          });
          this.limit += this.portionSize;
          this.model.trigger('change:' + this.idsName);
          this.reRender();
        });
        collection.fetch();
      });
    }
    getValueForDisplay() {
      if (this.mode === this.MODE_DETAIL || this.mode === this.MODE_LIST) {
        const list = [];
        this.ids.forEach(id => {
          list.push(this.getDetailLinkHtml(id));
        });
        let str = null;
        if (list.length) {
          str = '' + list.join(', ') + '';
        }
        if (list.length >= this.limit) {
          str += ', <a role="button" data-action="showMoreFollowers">...</a>';
        }
        return str;
      }
    }
  }
  var _default = _exports.default = FollowersFieldView;
});

define("views/fields/enum-styled", ["exports", "views/fields/enum"], function (_exports, _enum) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _enum = _interopRequireDefault(_enum);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EnumStyledFieldView extends _enum.default {}

  // noinspection JSUnusedGlobalSymbols
  var _default = _exports.default = EnumStyledFieldView;
});

define("views/fields/enum-float", ["exports", "views/fields/enum-int"], function (_exports, _enumInt) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _enumInt = _interopRequireDefault(_enumInt);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EnumFloatFieldView extends _enumInt.default {
    type = 'enumFloat';
    fetch() {
      const raw = this.$element.val();
      if (raw === '') {
        return {
          [this.name]: null
        };
      }
      const value = parseFloat(raw);
      const data = {};
      data[this.name] = value;
      return data;
    }
    parseItemForSearch(item) {
      return parseFloat(item);
    }
  }
  var _default = _exports.default = EnumFloatFieldView;
});

define("views/fields/enum-column", ["exports", "views/fields/enum"], function (_exports, _enum) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _enum = _interopRequireDefault(_enum);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EnumColumnFieldView extends _enum.default {
    searchTypeList = ['anyOf', 'noneOf'];
    fetchSearch() {
      const type = this.fetchSearchType();
      let list = this.$element.val().split(':,:');
      if (list.length === 1 && list[0] === '') {
        list = [];
      }
      list.forEach((item, i) => {
        list[i] = this.parseItemForSearch(item);
      });
      if (type === 'anyOf') {
        if (list.length === 0) {
          return {
            data: {
              type: 'anyOf',
              valueList: list
            }
          };
        }
        return {
          type: 'columnIn',
          value: list,
          data: {
            type: 'anyOf',
            valueList: list
          }
        };
      } else if (type === 'noneOf') {
        if (list.length === 0) {
          return {
            data: {
              type: 'noneOf',
              valueList: list
            }
          };
        }
        return {
          type: 'or',
          value: [{
            type: 'columnIsNull',
            attribute: this.name
          }, {
            type: 'columnNotIn',
            value: list,
            attribute: this.name
          }],
          data: {
            type: 'noneOf',
            valueList: list
          }
        };
      }
      return null;
    }
  }
  var _default = _exports.default = EnumColumnFieldView;
});

define("views/fields/entity-type-list", ["exports", "views/fields/multi-enum"], function (_exports, _multiEnum) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _multiEnum = _interopRequireDefault(_multiEnum);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EntityTypeListFieldView extends _multiEnum.default {
    checkAvailability(entityType) {
      const defs = this.scopesMetadataDefs[entityType] || {};
      if (defs.entity && defs.object) {
        return true;
      }
    }
    setupOptions() {
      const scopes = this.scopesMetadataDefs = this.getMetadata().get('scopes');
      this.params.options = Object.keys(scopes).filter(scope => {
        if (this.checkAvailability(scope)) {
          return true;
        }
      }).sort((v1, v2) => {
        return this.translate(v1, 'scopeNames').localeCompare(this.translate(v2, 'scopeNames'));
      });
    }
    setup() {
      if (!this.params.translation) {
        this.params.translation = 'Global.scopeNames';
      }
      this.setupOptions();
      super.setup();
    }
  }
  var _default = _exports.default = EntityTypeListFieldView;
});

define("views/fields/email-address", ["exports", "views/fields/varchar"], function (_exports, _varchar) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _varchar = _interopRequireDefault(_varchar);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EmailAddressFieldView extends _varchar.default {
    editTemplate = 'fields/email-address/edit';
    validations = ['required', 'emailAddress'];
    emailAddressRe = new RegExp(/^[-!#$%&'*+/=?^_`{|}~A-Za-z0-9]+(?:\.[-!#$%&'*+/=?^_`{|}~A-Za-z0-9]+)*/.source + /@([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])?\.)+[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9]/.source);

    // noinspection JSUnusedGlobalSymbols
    validateEmailAddress() {
      const value = this.model.get(this.name);
      if (!value) {
        return false;
      }
      if (value !== '' && !this.emailAddressRe.test(value)) {
        const msg = this.translate('fieldShouldBeEmail', 'messages').replace('{field}', this.getLabelText());
        this.showValidationMessage(msg);
        return true;
      }
      return false;
    }
  }
  var _default = _exports.default = EmailAddressFieldView;
});

define("views/fields/duration", ["exports", "views/fields/enum", "ui/select", "moment"], function (_exports, _enum, _select, _moment) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _enum = _interopRequireDefault(_enum);
  _select = _interopRequireDefault(_select);
  _moment = _interopRequireDefault(_moment);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class DurationFieldView extends _enum.default {
    type = 'duration';
    listTemplate = 'fields/base/detail';
    detailTemplate = 'fields/varchar/detail';
    editTemplate = 'fields/duration/edit';

    /**
     * @private
     * @type {boolean}
     */
    _justFocused = false;
    data() {
      const valueIsSet = this.model.has(this.startField) && this.model.has(this.endField);
      return {
        valueIsSet: valueIsSet,
        durationOptions: this.durationOptions,
        ...super.data()
      };
    }

    /**
     * @private
     */
    calculateSeconds() {
      this.seconds = 0;
      const start = this.model.get(this.startField);
      let end = this.model.get(this.endField);
      if (this.isEditMode() || this.isDetailMode()) {
        if (this.model.isNew()) {
          this.seconds = this.model.getFieldParam(this.name, 'default') || 0;
        }
      }
      if (this.model.attributes.isAllDay && this.hasAllDay) {
        const startDate = this.model.attributes[this.startDateField];
        const endDate = this.model.attributes[this.endDateField];
        if (startDate && endDate) {
          this.seconds = (0, _moment.default)(endDate).add(1, 'days').unix() - (0, _moment.default)(startDate).unix();
          return;
        }
      }
      if (start && end) {
        this.seconds = (0, _moment.default)(this.model.get(this.endField)).unix() - (0, _moment.default)(this.model.get(this.startField)).unix();
        return;
      }
      if (start) {
        end = this._getDateEnd();
        this.model.set(this.endField, end, {
          silent: true
        });
      }
    }
    init() {
      super.init();
      this.listenTo(this, 'render', () => {
        this.calculateSeconds();
        this.durationOptions = '';
        this.getOptions().forEach(duration => {
          const option = document.createElement('option');
          option.value = duration.toString();
          option.text = this.stringifyDuration(duration);
          if (duration === this.seconds) {
            option.setAttribute('selected', 'selected');
          }
          this.durationOptions += option.outerHTML;
        });
        this.stringValue = this.stringifyDuration(this.seconds);
      });
    }

    /**
     * @return {Number[]}
     */
    getOptions() {
      const options = Espo.Utils.clone(this.model.getFieldParam(this.name, 'options') ?? []);
      if (!this.model.attributes.isAllDay && options.indexOf(this.seconds) === -1) {
        options.push(this.seconds);
      }
      options.sort((a, b) => a - b);
      return options;
    }
    setup() {
      this.startField = this.model.getFieldParam(this.name, 'start');
      this.endField = this.model.getFieldParam(this.name, 'end');
      this.startDateField = this.startField + 'Date';
      this.endDateField = this.endField + 'Date';
      this.hasAllDay = this.model.getFieldType(this.startField) === 'datetimeOptional';
      if (!this.startField || !this.endField) {
        throw new Error(`Bad definition for field '${this.name}'.`);
      }
      this.calculateSeconds();
      this.blockDateEndChangeListener = false;
      this.listenTo(this.model, `change:${this.endField}`, (m, v, o) => {
        if (this.blockDateEndChangeListener) {
          return;
        }
        const start = this.model.get(this.startField);
        const end = this.model.get(this.endField);
        if (!end || !start) {
          return;
        }
        this.seconds = _moment.default.utc(end).unix() - _moment.default.utc(start).unix();
        if (o.updatedByDuration) {
          return;
        }
        this.updateDuration();
      });
      this.listenTo(this.model, `change:${this.startField}`, (m, v, o) => {
        if (o.ui) {
          const isAllDay = this.model.attributes[this.startDateField];
          if (isAllDay && this.hasAllDay) {
            const remainder = this.seconds % (3600 * 24);
            if (remainder !== 0) {
              this.seconds = this.seconds - remainder + 3600 * 24;
            }
          }
          this.blockDateEndChangeListener = true;
          setTimeout(() => this.blockDateEndChangeListener = false, 100);
          this.updateDateEnd(this.startField);
          setTimeout(() => this.updateDuration(), 110);
          return;
        }
        if (!this.isEditMode() && o.xhr) {
          return;
        }
        this.updateDateEnd();
      });
    }
    getValueForDisplay() {
      return this.stringValue;
    }

    /**
     * @private
     * @param {number} secondsTotal
     * @return {string}
     */
    stringifyDuration(secondsTotal) {
      if (!secondsTotal) {
        return '0';
      }
      if (secondsTotal < 60) {
        return '0';
      }
      let d = secondsTotal;
      const days = Math.floor(d / 86400);
      d = d % 86400;
      const hours = Math.floor(d / 3600);
      d = d % 3600;
      const minutes = Math.floor(d / 60);
      const parts = [];
      if (days) {
        parts.push(days + '' + this.getLanguage().translate('d', 'durationUnits'));
      }
      if (hours) {
        parts.push(hours + '' + this.getLanguage().translate('h', 'durationUnits'));
      }
      if (minutes) {
        parts.push(minutes + '' + this.getLanguage().translate('m', 'durationUnits'));
      }
      return parts.join(' ');
    }
    focusOnInlineEdit() {
      _select.default.focus(this.$duration);
    }
    afterRender() {
      const parentView = this.getParentView();
      if (parentView && 'getView' in parentView) {
        this.endFieldView = parentView.getView(this.endField);
      }
      if (this.isEditMode()) {
        this.$duration = this.$el.find('.main-element');
        this.$duration.on('change', () => {
          this.seconds = parseInt(this.$duration.val());
          this.updateDateEnd();
        });
        const start = this.model.get(this.startField);
        const end = this.model.get(this.endField);
        const seconds = this.$duration.val();
        if (!end && start && seconds) {
          if (this.endFieldView) {
            if (this.endFieldView.isRendered()) {
              this.updateDateEnd();
            } else {
              this.endFieldView.once('after:render', () => {
                this.updateDateEnd();
              });
            }
          }
        }
        _select.default.init(this.$duration, {
          sortBy: '$score',
          sortDirection: 'desc',
          /**
           * @param {string} search
           * @param {{value: string}} item
           * @return {number}
           */
          score: (search, item) => {
            const num = parseInt(item.value);
            const searchNum = parseInt(search);
            if (isNaN(searchNum)) {
              return 0;
            }
            const numOpposite = Number.MAX_SAFE_INTEGER - num;
            if (searchNum === 0 && num === 0) {
              return numOpposite;
            }
            if (searchNum * 60 === num) {
              return numOpposite;
            }
            if (searchNum * 60 * 60 === num) {
              return numOpposite;
            }
            if (searchNum * 60 * 60 * 24 === num) {
              return numOpposite;
            }
            return 0;
          },
          load: (item, callback) => {
            const num = parseInt(item);
            if (isNaN(num) || num <= 0) {
              return;
            }
            if (num > 59) {
              return;
            }
            const list = [];
            const mSeconds = num * 60;
            list.push({
              value: mSeconds.toString(),
              text: this.stringifyDuration(mSeconds)
            });
            if (num <= 9) {
              const hSeconds = num * 3600;
              list.push({
                value: hSeconds.toString(),
                text: this.stringifyDuration(hSeconds)
              });
            }
            callback(list);
          },
          onFocus: () => {
            this._justFocused = true;
            setTimeout(() => this._justFocused = false, 150);
          }
        });
      }
    }

    /**
     * @private
     * @return {string}
     */
    _getDateEndDate() {
      const seconds = this.seconds;
      const start = this.model.attributes[this.startDateField];
      if (!start) {
        return undefined;
      }
      if (!seconds) {
        return start;
      }
      const endUnix = _moment.default.utc(start).unix() + seconds;
      return _moment.default.unix(endUnix).utc().add(-1, 'day').format(this.getDateTime().internalDateFormat);
    }

    /**
     * @private
     * @return {string}
     */
    _getDateEnd() {
      const seconds = this.seconds;
      const start = this.model.get(this.startField);
      if (!start) {
        return undefined;
      }
      let endUnix;
      let end;
      if (seconds) {
        endUnix = _moment.default.utc(start).unix() + seconds;
        end = _moment.default.unix(endUnix).utc().format(this.getDateTime().internalDateTimeFormat);
      } else {
        end = start;
      }
      return end;
    }

    /**
     * @private
     * @param {string} [fromField]
     */
    updateDateEnd(fromField) {
      if (this.model.attributes.isAllDay && this.hasAllDay) {
        const end = this._getDateEndDate();
        setTimeout(() => {
          this.model.set(this.endDateField, end, {
            updatedByDuration: true,
            fromField: fromField
          });
        }, 1);
        return;
      }
      const end = this._getDateEnd();

      // Smaller timeouts produce a js error in timepicker.
      setTimeout(() => {
        this.model.set(this.endField, end, {
          updatedByDuration: true,
          fromField: fromField
        });
        if (this.hasAllDay) {
          this.model.set(this.endDateField, null, {
            fromField: fromField
          });
        }
      }, 100);
    }

    /**
     * @private
     */
    updateDuration() {
      const seconds = this.seconds;
      if (this.isEditMode() && this.$duration && this.$duration.length && !this._justFocused) {
        const options = this.getOptions().map(value => {
          return {
            value: value.toString(),
            text: this.stringifyDuration(value)
          };
        });
        _select.default.setValue(this.$duration, '');
        _select.default.setOptions(this.$duration, options);
        _select.default.setValue(this.$duration, seconds.toString());
        return;
      }
      this.reRender();
    }
    fetch() {
      // noinspection JSValidateTypes
      return {};
    }
  }
  var _default = _exports.default = DurationFieldView;
});

define("views/fields/datetime-optional", ["exports", "views/fields/datetime", "moment"], function (_exports, _datetime, _moment) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _datetime = _interopRequireDefault(_datetime);
  _moment = _interopRequireDefault(_moment);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/fields/datetime-optional */

  /**
   * A date-time or date.
   */
  class DatetimeOptionalFieldView extends _datetime.default {
    type = 'datetimeOptional';
    emptyTimeInInlineEditDisabled = false;
    noneOptionIsHidden = false;
    validateAfterAllowSameDay = false;
    isEnd = false;
    setup() {
      super.setup();
      this.noneOption = this.translate('None');
      this.nameDate = this.name + 'Date';
    }
    isDate() {
      const dateValue = this.model.get(this.nameDate);
      if (dateValue && dateValue !== '') {
        return true;
      }
      return false;
    }
    data() {
      const data = super.data();
      if (this.isDate()) {
        const dateValue = this.model.get(this.nameDate);
        data.date = this.getDateTime().toDisplayDate(dateValue);
        data.time = this.noneOption;
      }
      return data;
    }
    getDateStringValue() {
      if (this.isDate()) {
        const dateValue = this.model.get(this.nameDate);
        return this.stringifyDateValue(dateValue);
      }
      return super.getDateStringValue();
    }
    setDefaultTime() {
      var _this$$time;
      (_this$$time = this.$time) === null || _this$$time === void 0 || _this$$time.val(this.noneOption);
    }
    initTimepicker() {
      const $time = this.$time;
      const modalBodyElement = this.element.closest('.modal-body');
      const o = {
        step: this.params.minuteStep || 30,
        scrollDefaultNow: true,
        timeFormat: this.timeFormatMap[this.getDateTime().timeFormat],
        noneOption: [{
          label: this.noneOption,
          value: this.noneOption
        }],
        appendTo: modalBodyElement ? $(modalBodyElement) : 'body'
      };
      if (this.emptyTimeInInlineEditDisabled && this.isInlineEditMode() || this.noneOptionIsHidden) {
        delete o.noneOption;
      }

      // @ts-ignore
      $time === null || $time === void 0 || $time.timepicker(o);
      $time === null || $time === void 0 || $time.parent().find('button.time-picker-btn').on('click', () => {
        // @ts-ignore
        $time.timepicker('show');
      });
    }
    fetch() {
      var _this$$date, _this$$time2;
      const data = {};
      const date = (_this$$date = this.$date) === null || _this$$date === void 0 ? void 0 : _this$$date.val();
      const time = (_this$$time2 = this.$time) === null || _this$$time2 === void 0 ? void 0 : _this$$time2.val();
      let value = null;
      if (time !== this.noneOption && time !== '') {
        if (date !== '' && time !== '') {
          value = this.parse(date + ' ' + time);
        }
        data[this.name] = value;
        data[this.nameDate] = null;
        return data;
      }
      if (date !== '') {
        data[this.nameDate] = this.getDateTime().fromDisplayDate(date);
        let dateTimeValue = data[this.nameDate] + ' 00:00:00';
        dateTimeValue = _moment.default
        // @ts-ignore
        .tz(dateTimeValue, this.getConfig().get('timeZone') || 'UTC').add(this.isEnd ? 1 : 0, 'days').utc().format(this.getDateTime().internalDateTimeFullFormat);
        data[this.name] = dateTimeValue;
        return data;
      }
      data[this.nameDate] = null;
      data[this.name] = null;
      return data;
    }
    validateAfter() {
      const field = this.params.after;
      if (!field) {
        return false;
      }
      const fieldDate = field + 'Date';
      const value = this.model.get(this.name) || this.model.get(this.nameDate);
      const otherValue = this.model.get(field) || this.model.get(fieldDate);
      if (!(value && otherValue)) {
        return false;
      }
      const isNotValid = this.validateAfterAllowSameDay && this.model.get(this.nameDate) ? (0, _moment.default)(value).unix() < (0, _moment.default)(otherValue).unix() : (0, _moment.default)(value).unix() <= (0, _moment.default)(otherValue).unix();
      if (isNotValid) {
        const otherFieldLabelText = this.options.otherFieldLabelText || this.translate(field, 'fields', this.entityType);
        const msg = this.translate('fieldShouldAfter', 'messages').replace('{field}', this.getLabelText()).replace('{otherField}', otherFieldLabelText);
        this.showValidationMessage(msg);
        return true;
      }
      return false;
    }
    validateBefore() {
      const field = this.params.before;
      if (!field) {
        return false;
      }
      const fieldDate = field + 'Date';
      const value = this.model.get(this.name) || this.model.get(this.nameDate);
      const otherValue = this.model.get(field) || this.model.get(fieldDate);
      if (!(value && otherValue)) {
        return;
      }
      if ((0, _moment.default)(value).unix() >= (0, _moment.default)(otherValue).unix()) {
        const msg = this.translate('fieldShouldBefore', 'messages').replace('{field}', this.getLabelText()).replace('{otherField}', this.translate(field, 'fields', this.entityType));
        this.showValidationMessage(msg);
        return true;
      }
    }
    validateRequired() {
      if (!this.isRequired()) {
        return false;
      }
      if (this.model.get(this.name) === null && this.model.get(this.nameDate) === null) {
        const msg = this.translate('fieldIsRequired', 'messages').replace('{field}', this.getLabelText());
        this.showValidationMessage(msg);
        return true;
      }
      return false;
    }
    getStartDateForDatePicker() {
      if (!this.isEditMode() || !this.params.after) {
        return undefined;
      }
      const date = this.model.attributes[this.params.after + 'Date'];
      if (date) {
        return this.getDateTime().toDisplayDate(date);
      }
      return super.getStartDateForDatePicker();
    }
  }

  // noinspection JSUnusedGlobalSymbols
  var _default = _exports.default = DatetimeOptionalFieldView;
});

define("views/fields/currency-list", ["exports", "views/fields/enum"], function (_exports, _enum) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _enum = _interopRequireDefault(_enum);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class CurrencyListFieldView extends _enum.default {
    setupOptions() {
      this.params.options = [];
      (this.getConfig().get('currencyList') || []).forEach(item => {
        this.params.options.push(item);
      });
    }
  }
  var _default = _exports.default = CurrencyListFieldView;
});

define("views/fields/complex-expression", ["exports", "views/fields/text"], function (_exports, _text) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _text = _interopRequireDefault(_text);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * @type {{
   *     edit: import('ace-builds').edit,
   *     require: import('ace-builds').require,
   * }}
   */
  let ace;
  class ComplexExpressionFieldView extends _text.default {
    detailTemplate = 'fields/formula/detail';
    editTemplate = 'fields/formula/edit';
    height = 46;
    maxLineDetailCount = 80;
    maxLineEditCount = 200;
    smallFont = false;
    events = {
      /** @this ComplexExpressionFieldView */
      'click [data-action="addAttribute"]': function () {
        this.addAttribute();
      },
      /** @this ComplexExpressionFieldView */
      'click [data-action="addFunction"]': function () {
        this.addFunction();
      }
    };
    setup() {
      super.setup();
      this.height = this.options.height || this.params.height || this.height;
      this.smallFont = this.options.smallFont || this.params.smallFont || this.smallFont;
      this.maxLineDetailCount = this.options.maxLineDetailCount || this.params.maxLineDetailCount || this.maxLineDetailCount;
      this.maxLineEditCount = this.options.maxLineEditCount || this.params.maxLineEditCount || this.maxLineEditCount;
      this.targetEntityType = this.options.targetEntityType || this.params.targetEntityType || this.targetEntityType;
      this.containerId = 'editor-' + Math.floor(Math.random() * 10000 + 1).toString();
      if (this.mode === this.MODE_EDIT || this.mode === this.MODE_DETAIL) {
        this.wait(this.requireAce());
      }
      this.on('remove', () => {
        if (this.editor) {
          this.editor.destroy();
        }
      });
    }
    requireAce() {
      return Espo.loader.requirePromise('lib!ace').then(lib => {
        ace = lib;
        const list = [Espo.loader.requirePromise('lib!ace-ext-language_tools')];
        if (this.getThemeManager().getParam('isDark')) {
          list.push(Espo.loader.requirePromise('lib!ace-theme-tomorrow_night'));
        }
        return Promise.all(list);
      });
    }
    data() {
      const data = super.data();
      data.containerId = this.containerId;
      data.targetEntityType = this.targetEntityType;
      data.hasInsert = true;
      return data;
    }
    afterRender() {
      super.afterRender();
      this.$editor = this.$el.find('#' + this.containerId);
      if (this.$editor.length && (this.mode === this.MODE_EDIT || this.mode === this.MODE_DETAIL || this.mode === this.MODE_LIST)) {
        const fontSize = this.smallFont ? 'var(--font-size-small)' : 'var(--font-size-base)';
        const lineHeight = this.smallFont ? 'var(--line-height-small)' : 'var(--line-height-computed)';
        this.$editor.css('fontSize', fontSize);
        if (this.mode === this.MODE_EDIT) {
          this.$editor.css('minHeight', this.height + 'px');
        }
        const editor = this.editor = ace.edit(this.containerId);
        editor.setOptions({
          fontFamily: 'var(--font-family-monospace)'
        });
        editor.setFontSize(fontSize);
        editor.container.style.lineHeight = lineHeight;
        editor.renderer.updateFontSize();
        editor.setOptions({
          maxLines: this.mode === this.MODE_EDIT ? this.maxLineEditCount : this.maxLineDetailCount
        });
        if (this.getThemeManager().getParam('isDark')) {
          editor.setOptions({
            theme: 'ace/theme/tomorrow_night'
          });
        }
        if (this.isEditMode()) {
          // noinspection JSCheckFunctionSignatures
          editor.getSession().on('change', () => {
            this.trigger('change', {
              ui: true
            });
          });
          editor.getSession().setUseWrapMode(true);
        }
        if (this.isReadMode()) {
          editor.setReadOnly(true);
          // noinspection JSUnresolvedReference
          editor.renderer.$cursorLayer.element.style.display = 'none';
          editor.renderer.setShowGutter(false);
        }
        editor.setShowPrintMargin(false);
        editor.getSession().setUseWorker(false);
        editor.commands.removeCommand('find');
        editor.setHighlightActiveLine(false);

        //let JavaScriptMode = ace.require('ace/mode/javascript').Mode;
        //editor.session.setMode(new JavaScriptMode());

        if (!this.isReadMode()) {
          this.initAutocomplete();
        }
      }
    }
    fetch() {
      const data = {};
      data[this.name] = this.editor.getValue();
      return data;
    }
    getFunctionDataList() {
      return this.getMetadata().get(['app', 'complexExpression', 'functionList']) || [];
    }
    initAutocomplete() {
      const functionItemList = this.getFunctionDataList().filter(item => item.insertText);
      const attributeList = this.getFormulaAttributeList();
      ace.require('ace/ext/language_tools');
      this.editor.setOptions({
        enableBasicAutocompletion: true,
        enableLiveAutocompletion: true
      });

      // noinspection JSUnusedGlobalSymbols
      const completer = {
        identifierRegexps: [/[\\a-zA-Z0-9{}\[\].$'"]/],
        getCompletions: function (editor, session, pos, prefix, callback) {
          const matchedFunctionItemList = functionItemList.filter(originalItem => {
            const text = originalItem.name.toLowerCase();
            if (text.indexOf(prefix.toLowerCase()) === 0) {
              return true;
            }
            return false;
          });
          let itemList = matchedFunctionItemList.map(item => {
            return {
              caption: item.name + '()',
              value: item.insertText,
              meta: item.returnType || null
            };
          });
          const matchedAttributeList = attributeList.filter(item => {
            if (item.indexOf(prefix) === 0) {
              return true;
            }
            return false;
          });
          const itemAttributeList = matchedAttributeList.map(item => {
            return {
              name: item,
              value: item,
              meta: 'attribute'
            };
          });
          itemList = itemList.concat(itemAttributeList);
          callback(null, itemList);
        }
      };
      this.editor.completers = [completer];
    }
    getFormulaAttributeList() {
      if (!this.targetEntityType) {
        return [];
      }
      const attributeList = this.getFieldManager().getEntityTypeAttributeList(this.targetEntityType, {
        ignoreTypeList: ['map', 'linkMultiple', 'attachmentMultiple'],
        onlyAvailable: true
      }).sort();
      attributeList.unshift('id');

      // @todo Skip not storable attributes.

      const links = this.getMetadata().get(['entityDefs', this.targetEntityType, 'links']) || {};
      const linkList = [];
      Object.keys(links).forEach(link => {
        const type = links[link].type;
        if (!type) {
          return;
        }
        if (['hasMany', 'hasOne', 'belongsTo'].includes(type)) {
          linkList.push(link);
        }
      });
      linkList.sort();
      linkList.forEach(link => {
        /** @type {Record} */
        const defs = links[link];
        const scope = defs.entity;
        if (!scope) {
          return;
        }
        if (defs.disabled || defs.utility) {
          return;
        }
        attributeList.push(`${link}.id`);
        const linkAttributeList = this.getFieldManager().getEntityTypeAttributeList(scope, {
          ignoreTypeList: ['map', 'linkMultiple', 'attachmentMultiple'],
          onlyAvailable: true
        }).sort();
        linkAttributeList.forEach(item => attributeList.push(link + '.' + item));
      });
      return attributeList;
    }
    addAttribute() {
      this.createView('dialog', 'views/admin/formula/modals/add-attribute', {
        scope: this.targetEntityType,
        attributeList: this.getFormulaAttributeList()
      }, view => {
        view.render();
        this.listenToOnce(view, 'add', attribute => {
          this.editor.insert(attribute);
          this.clearView('dialog');
        });
      });
    }
    addFunction() {
      this.createView('dialog', 'views/admin/complex-expression/modals/add-function', {
        scope: this.targetEntityType,
        functionDataList: this.getFunctionDataList()
      }, view => {
        view.render();
        this.listenToOnce(view, 'add', string => {
          this.editor.insert(string);
          this.clearView('dialog');
        });
      });
    }
  }
  var _default = _exports.default = ComplexExpressionFieldView;
});

define("views/fields/complex-created", ["exports", "views/fields/base"], function (_exports, _base) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ComplexCreatedFieldView extends _base.default {
    // language=Handlebars
    detailTemplateContent = `
        {{~#if hasAt~}}
            <span data-name="{{baseName}}At" class="field">{{{atField}}}</span>
        {{~/if~}}
        {{~#if hasBoth~}}
            <span style="user-select: none"> <span class="text-muted middle-dot"></span> </span>
        {{~/if~}}
        {{~#if hasBy~}}
            <span data-name="{{baseName}}By" class="field">{{{byField}}}</span>
        {{~/if~}}
    `;
    baseName = 'created';
    getAttributeList() {
      return [this.fieldAt, this.fieldBy];
    }
    init() {
      this.baseName = this.options.baseName || this.baseName;
      this.fieldAt = this.baseName + 'At';
      this.fieldBy = this.baseName + 'By';
      super.init();
    }
    setup() {
      super.setup();
      this.createField('at');
      this.createField('by');
    }

    // noinspection JSCheckFunctionSignatures
    data() {
      const hasBy = this.model.has(this.fieldBy + 'Id');
      const hasAt = this.model.has(this.fieldAt);
      return {
        baseName: this.baseName,
        hasBy: hasBy,
        hasAt: hasAt,
        hasBoth: hasAt && hasBy,
        ...super.data()
      };
    }
    createField(part) {
      const field = this.baseName + Espo.Utils.upperCaseFirst(part);
      const type = this.model.getFieldType(field) || 'base';
      const viewName = this.model.getFieldParam(field, 'view') || this.getFieldManager().getViewName(type);
      this.createView(part + 'Field', viewName, {
        name: field,
        model: this.model,
        mode: this.MODE_DETAIL,
        readOnly: true,
        readOnlyLocked: true,
        selector: '[data-name="' + field + '"]',
        isInComplexField: true
      });
    }
    fetch() {
      return {};
    }
  }

  // noinspection JSUnusedGlobalSymbols
  var _default = _exports.default = ComplexCreatedFieldView;
});

define("views/fields/color", ["exports", "views/fields/base"], function (_exports, _base) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * @since 10.0.0
   */
  class ColorFieldView extends _base.default {
    // language=Handlebars
    listTemplateContent = `
        {{#if isNotNull}}
            <span class="fas fa-square" style="color: {{color}}"></span>
        {{/if}}
    `;

    // language=Handlebars
    detailTemplateContent = `
        {{#if isNotNull}}
            <span class="fas fa-square" style="color: {{color}}"></span>
        {{else}}
            {{#if valueIsSet}}
                <span class="none-value">{{translate 'None'}}</span>
            {{else}}
                <span class="loading-value"></span>
            {{/if}}
        {{/if}}
    `;

    // language=Handlebars
    editTemplateContent = `
        <div class="btn-group">
            <button class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                <span class="fas fa-square" style="color: {{color}}"></span>
            </button>
            <ul class="dropdown-menu">
                <li>
                    <ul
                        style="
                            display: grid;
                            grid-template-columns: 52px 52px 52px;
                            padding-left: 0;
                        "
                    >
                        {{#each colors}}
                            <li style="list-style: none;">
                                <a
                                    style="
                                        width: 100%;
                                        display: inline-block;
                                        text-align: center;
                                        padding: 2px;
                                    "
                                    class="dropdown-item"
                                    role="button"
                                    tabindex="0"
                                    data-action="selectColor{{#if selected}} active{{/if}}"
                                    data-value="{{value}}"
                                ><span class="fas fa-square" style="color: {{color}}"></span></a>
                            </li>
                        {{/each}}
                    </ul>
                </li>
                <li class="divider"></li>
                <li>
                    <a
                        class="dropdown-item"
                        role="button"
                        tabindex="0"
                        data-action="selectColor{{#if isNull}} active{{/if}}"
                        data-value=""
                        style="text-align: center;"
                    >{{translate 'None'}}</a>
                </li>
            </ul>
        </div>
    `;

    // noinspection JSCheckFunctionSignatures
    data() {
      const value = this.model.attributes[this.name];
      if (this.isEditMode()) {
        const colors = [];
        let color = 'transparent';
        for (let i = 0; i < 9; i++) {
          colors.push({
            color: this.colors[i],
            selected: i === value,
            value: i
          });
          if (i === value) {
            color = this.colors[i];
          }
        }
        return {
          colors: colors,
          color: color,
          isNull: value === null
        };
      }
      if (this.isReadMode()) {
        return {
          valueIsSet: value !== undefined,
          isNotNull: value !== null,
          color: value != null ? this.colors[value] : 'transparent'
        };
      }
      return super.data();
    }
    setup() {
      /** @type {string[]} */
      this.colors = this.getHelper().themeManager.getParam('chartColorList') || [];
      this.addActionHandler('selectColor', (e, element) => {
        const value = element.dataset.value !== '' ? parseInt(element.dataset.value) : null;
        this.model.set(this.name, value, {
          ui: true
        });
        this.reRender();
      });
    }
  }
  var _default = _exports.default = ColorFieldView;
});

define("views/fields/collaborators", ["exports", "views/fields/link-multiple"], function (_exports, _linkMultiple) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _linkMultiple = _interopRequireDefault(_linkMultiple);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class CollaboratorsFieldView extends _linkMultiple.default {
    init() {
      this.assignmentPermission = this.getAcl().getPermissionLevel('assignmentPermission');
      if (this.assignmentPermission === 'no') {
        this.readOnly = true;
      }
      super.init();
    }
    getSelectBoolFilterList() {
      if (this.assignmentPermission === 'team') {
        return ['onlyMyTeam'];
      }
    }
    getSelectPrimaryFilterName() {
      return 'active';
    }
    getDetailLinkHtml(id, name) {
      const html = super.getDetailLinkHtml(id);
      const avatarHtml = this.isDetailMode() ? this.getHelper().getAvatarHtml(id, 'small', 18, 'avatar-link') : '';
      if (!avatarHtml) {
        return html;
      }
      return `${avatarHtml}${html}`;
    }

    /** @inheritDoc */
    getOnEmptyAutocomplete() {
      if (this.params.autocompleteOnEmpty) {
        return undefined;
      }
      if (this.ids && this.ids.includes(this.getUser().id)) {
        return Promise.resolve([]);
      }
      return Promise.resolve([{
        id: this.getUser().id,
        name: this.getUser().attributes.name
      }]);
    }

    /**
     * @inheritDoc
     */
    prepareEditItemElement(id, name) {
      const itemElement = super.prepareEditItemElement(id, name);
      const avatarHtml = this.getHelper().getAvatarHtml(id, 'small', 18, 'avatar-link');
      if (avatarHtml) {
        const img = new DOMParser().parseFromString(avatarHtml, 'text/html').body.childNodes[0];
        const textElement = itemElement.querySelector('.text');
        textElement === null || textElement === void 0 || textElement.prepend(img);
      }
      return itemElement;
    }
  }
  _exports.default = CollaboratorsFieldView;
});

define("views/fields/barcode", ["exports", "views/fields/varchar"], function (_exports, _varchar) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _varchar = _interopRequireDefault(_varchar);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  let JsBarcode;
  let QRCode;
  class BarcodeFieldView extends _varchar.default {
    type = 'barcode';
    listTemplate = 'fields/barcode/detail';
    detailTemplate = 'fields/barcode/detail';
    setup() {
      this.validations.push('valid');
      let maxLength = 255;

      // noinspection SpellCheckingInspection
      switch (this.params.codeType) {
        case 'EAN2':
          maxLength = 2;
          break;
        case 'EAN5':
          maxLength = 5;
          break;
        case 'EAN8':
          maxLength = 8;
          break;
        case 'EAN13':
          maxLength = 13;
          break;
        case 'UPC':
          maxLength = 12;
          break;
        case 'UPCE':
          maxLength = 11;
          break;
        case 'ITF14':
          maxLength = 14;
          break;
        case 'pharmacode':
          maxLength = 6;
          break;
      }
      this.params.maxLength = maxLength;

      // noinspection SpellCheckingInspection
      if (this.params.codeType !== 'QRcode') {
        this.isSvg = true;
        this.wait(Espo.loader.requirePromise('lib!jsbarcode').then(lib => JsBarcode = lib));
      } else {
        this.wait(Espo.loader.requirePromise('lib!qrcodejs').then(lib => QRCode = lib));
      }
      super.setup();
      $(window).on('resize.' + this.cid, () => {
        if (!this.isRendered()) {
          return;
        }
        this.controlWidth();
      });
      this.listenTo(this.recordHelper, 'panel-show', () => this.controlWidth());
    }
    data() {
      const data = super.data();
      data.isSvg = this.isSvg;

      // noinspection JSValidateTypes
      return data;
    }
    onRemove() {
      $(window).off('resize.' + this.cid);
    }
    afterRender() {
      super.afterRender();
      if (this.isListMode() || this.isDetailMode()) {
        const value = this.model.get(this.name);
        if (value) {
          // noinspection SpellCheckingInspection
          if (this.params.codeType === 'QRcode') {
            this.initQrcode(value);
          } else {
            const $barcode = $(this.getSelector() + ' .barcode');
            if ($barcode.length) {
              this.initBarcode(value);
            } else {
              // SVG may be not available yet (in webkit).
              setTimeout(() => {
                this.initBarcode(value);
                this.controlWidth();
              }, 100);
            }
          }
        }
        this.controlWidth();
      }
    }
    initQrcode(value) {
      let size = 128;
      if (value.length > 192) {
        size *= 2;
      }
      if (this.isListMode()) {
        size = 64;
      }
      const containerWidth = this.$el.width();
      if (containerWidth < size && containerWidth) {
        size = containerWidth;
      }
      const $barcode = this.$el.find('.barcode');
      const init = level => {
        const options = {
          text: value,
          width: size,
          height: size,
          colorDark: '#000000',
          colorLight: '#ffffff',
          correctLevel: level || QRCode.CorrectLevel.H
        };
        new QRCode($barcode.get(0), options);
      };
      try {
        init();
      } catch (e) {
        try {
          $barcode.empty();
          init(QRCode.CorrectLevel.L);
        } catch (e) {
          console.error(this.name + ': ' + e.message);
        }
      }
    }
    initBarcode(value) {
      const factor = this.getThemeManager().getFontSizeFactor();
      try {
        JsBarcode(this.getSelector() + ' .barcode', value, {
          format: this.params.codeType,
          height: 50 * factor,
          fontSize: 14 * factor,
          margin: 0,
          lastChar: this.params.lastChar
        });
      } catch (e) {
        console.error(this.name, e);
      }
    }
    controlWidth() {
      this.$el.find('.barcode').css('max-width', this.$el.width() + 'px');
    }

    // noinspection JSUnusedGlobalSymbols
    validateValid() {
      if (this.params.codeType === 'QRcode') {
        return;
      }
      const value = this.model.get(this.name);
      if (!value) {
        return;
      }
      let isValid;
      try {
        JsBarcode({}, value, {
          format: this.params.codeType,
          lastChar: this.params.lastChar,
          valid: valid => isValid = valid
        });
      } catch (e) {
        return true;
      }
      if (isValid) {
        return;
      }
      const msg = this.translate('barcodeInvalid', 'messages').replace('{field}', this.getLabelText()).replace('{type}', this.params.codeType);
      this.showValidationMessage(msg);
      return true;
    }
  }
  var _default = _exports.default = BarcodeFieldView;
});

define("views/fields/autoincrement", ["exports", "views/fields/int"], function (_exports, _int) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _int = _interopRequireDefault(_int);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class AutoincrementFieldView extends _int.default {
    type = 'autoincrement';
    validations = [];
    inlineEditDisabled = true;
    readOnly = true;
    disableFormatting = true;
    parse(value) {
      value = value !== '' ? value : null;
      if (value !== null) {
        value = value.indexOf('.') !== -1 || value.indexOf(',') !== -1 ? NaN : parseInt(value);
      }
      return value;
    }
    fetch() {
      return {};
    }
  }
  var _default = _exports.default = AutoincrementFieldView;
});

define("views/fields/assigned-users", ["exports", "views/fields/link-multiple"], function (_exports, _linkMultiple) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _linkMultiple = _interopRequireDefault(_linkMultiple);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class AssignedUsersFieldView extends _linkMultiple.default {
    init() {
      this.assignmentPermission = this.getAcl().getPermissionLevel('assignmentPermission');
      if (this.assignmentPermission === 'no') {
        this.readOnly = true;
      }
      super.init();
    }
    getSelectBoolFilterList() {
      if (this.assignmentPermission === 'team') {
        return ['onlyMyTeam'];
      }
    }
    getSelectPrimaryFilterName() {
      return 'active';
    }
    getDetailLinkHtml(id, name) {
      const html = super.getDetailLinkHtml(id);
      const avatarHtml = this.isDetailMode() || this.isListMode() ? this.getHelper().getAvatarHtml(id, 'small', 18, 'avatar-link') : '';
      if (!avatarHtml) {
        return html;
      }
      return avatarHtml + html;
    }

    /** @inheritDoc */
    getOnEmptyAutocomplete() {
      if (this.params.autocompleteOnEmpty) {
        return undefined;
      }
      if (this.ids && this.ids.includes(this.getUser().id)) {
        return Promise.resolve([]);
      }
      return Promise.resolve([{
        id: this.getUser().id,
        name: this.getUser().get('name')
      }]);
    }

    /**
     * @inheritDoc
     */
    prepareEditItemElement(id, name) {
      const itemElement = super.prepareEditItemElement(id, name);
      const avatarHtml = this.getHelper().getAvatarHtml(id, 'small', 18, 'avatar-link');
      if (avatarHtml) {
        const img = new DOMParser().parseFromString(avatarHtml, 'text/html').body.childNodes[0];
        const textElement = itemElement.querySelector('.text');
        textElement === null || textElement === void 0 || textElement.prepend(img);
      }
      return itemElement;
    }
  }
  var _default = _exports.default = AssignedUsersFieldView;
});

define("views/fields/assigned-user", ["exports", "views/fields/user-with-avatar"], function (_exports, _userWithAvatar) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _userWithAvatar = _interopRequireDefault(_userWithAvatar);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class AssignedUserFieldView extends _userWithAvatar.default {
    init() {
      this.assignmentPermission = this.getAcl().getPermissionLevel('assignmentPermission');
      if (this.assignmentPermission === 'no') {
        this.setReadOnly(true);
      }
      super.init();
    }
    getSelectBoolFilterList() {
      if (this.assignmentPermission === 'team') {
        return ['onlyMyTeam'];
      }
    }
    getSelectPrimaryFilterName() {
      return 'active';
    }

    /** @inheritDoc */
    getOnEmptyAutocomplete() {
      if (this.params.autocompleteOnEmpty) {
        return undefined;
      }
      return Promise.resolve([{
        id: this.getUser().id,
        name: this.getUser().get('name')
      }]);
    }
  }
  var _default = _exports.default = AssignedUserFieldView;
});

define("views/fields/array-int", ["exports", "views/fields/array"], function (_exports, _array) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _array = _interopRequireDefault(_array);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ArrayIntFieldView extends _array.default {
    type = 'arrayInt';
    fetchFromDom() {
      let selected = [];
      this.$el.find('.list-group .list-group-item').each((i, el) => {
        let value = $(el).data('value');
        if (typeof value === 'string' || value instanceof String) {
          value = parseInt($(el).data('value'));
        }
        selected.push(value);
      });
      this.selected = selected;
    }
    addValue(value) {
      value = parseInt(value);
      if (isNaN(value)) {
        return;
      }
      super.addValue(value);
    }
    removeValue(value) {
      value = parseInt(value);
      if (isNaN(value)) {
        return;
      }
      const valueInternal = CSS.escape(value.toString());
      this.$list.children('[data-value="' + valueInternal + '"]').remove();
      const index = this.selected.indexOf(value);
      this.selected.splice(index, 1);
      this.trigger('change');
    }
  }
  var _default = _exports.default = ArrayIntFieldView;
});

define("views/fields/address-state", ["exports", "views/fields/varchar"], function (_exports, _varchar) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _varchar = _interopRequireDefault(_varchar);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class AddressStateFieldView extends _varchar.default {
    setupOptions() {
      let stateList = this.getConfig().get('addressStateList') || [];
      if (stateList.length) {
        this.params.options = Espo.Utils.clone(stateList);
      }
    }
  }
  var _default = _exports.default = AddressStateFieldView;
});

define("views/fields/address-country", ["exports", "views/fields/varchar"], function (_exports, _varchar) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _varchar = _interopRequireDefault(_varchar);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class AddressCountryFieldView extends _varchar.default {
    setupOptions() {
      const countryList = this.getCountryList();
      if (countryList.length) {
        this.params.options = Espo.Utils.clone(countryList);
      }
    }

    /**
     * @private
     * @return {string[]}
     */
    getCountryList() {
      const list = (this.getHelper().getAppParam('addressCountryData') || {}).list || [];
      if (list.length) {
        return list;
      }
      return [];
    }
    getAutocompleteLookupFunction() {
      // noinspection JSUnresolvedReference
      const list = (this.getHelper().getAppParam('addressCountryData') || {}).preferredList || [];
      if (!list.length) {
        return undefined;
      }
      const fullList = this.params.options || [];
      return query => {
        if (query.length === 0) {
          const result = list.map(item => ({
            value: item
          }));
          return Promise.resolve(result);
        }
        const queryLowerCase = query.toLowerCase();
        const result = fullList.filter(item => {
          if (item.toLowerCase().indexOf(queryLowerCase) === 0) {
            return item.length !== queryLowerCase.length;
          }
        }).map(item => ({
          value: item
        }));
        return Promise.resolve(result);
      };
    }
  }
  var _default = _exports.default = AddressCountryFieldView;
});

define("views/fields/address-city", ["exports", "views/fields/varchar"], function (_exports, _varchar) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _varchar = _interopRequireDefault(_varchar);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class AddressCityFieldView extends _varchar.default {
    setupOptions() {
      let cityList = this.getConfig().get('addressCityList') || [];
      if (cityList.length) {
        this.params.options = Espo.Utils.clone(cityList);
      }
    }
  }
  var _default = _exports.default = AddressCityFieldView;
});

define("views/fields/extra/pipeline", ["exports", "views/fields/link", "di", "views/fields/enum", "model", "helpers/misc/pipelines", "theme-manager"], function (_exports, _link, _di, _enum, _model, _pipelines, _themeManager) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _link = _interopRequireDefault(_link);
  _enum = _interopRequireDefault(_enum);
  _model = _interopRequireDefault(_model);
  _pipelines = _interopRequireDefault(_pipelines);
  _themeManager = _interopRequireDefault(_themeManager);
  var _staticBlock;
  let _init_themeManager, _init_extra_themeManager;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  class PipelineFieldView extends _link.default {
    constructor() {
      super(...arguments);
      _init_extra_themeManager(this);
    }
    // language=Handlebars
    listTemplateContent = `
        {{~#if stringValue~}}
            <span
                class="color-icon fas fa-square text-soft"
                style=" {{#if color}} color: {{color}}; {{/if}} "
            ></span><span style="user-select: none">&nbsp;</span>
            {{~#if 1}}{{/if~}}
            <span
                class=""
                title="{{stringValue}}"
            >{{stringValue}}</span>
        {{/if}}
    `;

    // language=Handlebars
    detailTemplateContent = `
        {{~#if stringValue~}}
            <span
                class="color-icon fas fa-square text-soft"
                style=" {{#if color}} color: {{color}}; {{/if}} "
            ></span><span style="user-select: none">&nbsp;</span>
            {{~#if 1}}{{/if~}}
            <span
                class=""
            >{{stringValue}}</span>
        {{else}}
            {{#if valueIsSet}}
                <span class="none-value">{{translate 'None'}}</span>
            {{else}}
                <span class="loading-value"></span>
            {{/if}}
        {{/if}}
    `;

    // language=Handlebars
    editTemplateContent = `
        <div data-sub-field="pipeline">{{{pipelineField}}}</div>
    `;

    /**
     * @private
     * @type {Model}
     */
    subModel;

    /**
     * @private
     * @type {EnumFieldView}
     */
    enumView;

    /**
     * @private
     * @type {{id: string, name: string, color: number|null}[]}
     */
    pipelines;

    /**
     * @private
     * @type {Record<string, string>}
     */
    translatedOptions;

    /**
     * @private
     * @type {Record<string, number|null>}
     */
    colorMap;

    /**
     * @private
     * @type {ThemeManager}
     */
    themeManager = _init_themeManager(this);
    data() {
      const data = super.data();
      data.stringValue = data.nameValue;
      if (this.model.attributes[this.idName]) {
        data.color = this.colorMap[this.model.attributes[this.idName]] ?? null;
      }

      // noinspection JSValidateTypes
      return data;
    }
    setup() {
      super.setup();
      this.setupPipelines();
      const translatedOptions = {};
      for (const it of this.pipelines) {
        translatedOptions[it.id] = it.name;
      }
      this.translatedOptions = translatedOptions;
      this.setupSub();
    }

    /**
     * @private
     */
    setupPipelines() {
      this.pipelines = new _pipelines.default().get(this.entityType);

      /** @type {string[]} */
      const colors = this.themeManager.getParam('chartColorList') || [];
      this.colorMap = this.pipelines.reduce((o, it) => {
        let color = null;
        if (it.color != null) {
          color = colors[it.color] ?? null;
        }
        o[it.id] = color;
        return o;
      }, {});
    }

    /**
     * @private
     */
    setupSub() {
      this.subModel = new _model.default();
      const syncModels = () => {
        this.subModel.setMultiple({
          pipeline: this.model.attributes[this.idName]
        });
      };
      syncModels();
      this.listenTo(this.model, `change:${this.idName}`, (m, v, o) => {
        if (!o.ui || o.fromView && o.fromView !== this) {
          syncModels();
        }
      });
      this.listenTo(this.subModel, 'change', (m, o) => o.ui ? this.trigger('change') : null);
    }
    onEditModeSet() {
      const options = this.pipelines.map(it => it.id);
      const currentId = this.model.attributes[this.idName];
      if (!currentId) {
        options.unshift('');
      }
      if (currentId && !options.includes(currentId)) {
        options.push(currentId);
      }
      const translatedOptions = {
        ...this.translatedOptions
      };
      if (currentId && !translatedOptions[currentId]) {
        translatedOptions[currentId] = this.model.attributes[this.idName] ?? currentId;
      }
      this.enumView = new _enum.default({
        name: 'pipeline',
        model: this.subModel,
        mode: 'edit',
        params: {
          options,
          translatedOptions
        },
        optionItemHandler: it => {
          return {
            color: this.colorMap[it.value]
          };
        }
      });
      return this.assignView('pipelineField', this.enumView, '[data-sub-field="pipeline"]');
    }
    fetch() {
      const id = this.subModel.attributes.pipeline;

      // noinspection JSValidateTypes
      return {
        [this.idName]: id,
        [this.nameName]: id ? this.translatedOptions[id] ?? id : null
      };
    }
    static #_ = _staticBlock = () => [_init_themeManager, _init_extra_themeManager] = _applyDecs(this, [], [[(0, _di.inject)(_themeManager.default), 0, "themeManager"]], 0, void 0, _link.default).e;
  }
  _exports.default = PipelineFieldView;
  _staticBlock();
});

define("views/fields/extra/pipeline-stage", ["exports", "views/fields/link", "model", "views/fields/enum", "helpers/misc/pipelines"], function (_exports, _link, _model, _enum, _pipelines) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _link = _interopRequireDefault(_link);
  _model = _interopRequireDefault(_model);
  _enum = _interopRequireDefault(_enum);
  _pipelines = _interopRequireDefault(_pipelines);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class PipelineFieldView extends _link.default {
    // language=Handlebars
    listTemplateContent = `
        {{#if stringValue}}
            <span
                class="label label-md label-state label-{{style}}"
                title="{{stringValue}}"
            >{{stringValue}}</span>
        {{/if}}
    `;

    // language=Handlebars
    detailTemplateContent = `
        {{#if stringValue}}
            <span
                class="label label-md label-state label-{{style}}"
            >{{stringValue}}</span>
        {{else}}
            {{#if valueIsSet}}
                <span class="none-value">{{translate 'None'}}</span>
            {{else}}
                <span class="loading-value"></span>
            {{/if}}
        {{/if}}
    `;

    // language=Handlebars
    editTemplateContent = `
        <div data-sub-field="stage">{{{stageField}}}</div>
    `;

    /**
     * @private
     * @type {{id: string, stages: {id: string, name: string, style: string|null}[]}[]}
     */
    pipelines;
    data() {
      const data = super.data();
      data.stringValue = data.nameValue;
      const pipeline = this.getPipeline();
      data.style = 'default';
      if (pipeline && this.model.attributes[this.idName]) {
        const stage = pipeline.stages.find(it => it.id === this.model.attributes[this.idName]);
        data.style = (stage === null || stage === void 0 ? void 0 : stage.style) ?? 'default';
      }

      // noinspection JSValidateTypes
      return data;
    }
    setup() {
      super.setup();
      this.pipelines = new _pipelines.default().get(this.entityType);
      this.setupSub();
    }

    /**
     * @private
     */
    setupSub() {
      this.subModel = new _model.default();
      const syncModels = () => {
        this.subModel.setMultiple({
          stage: this.model.attributes[this.idName]
        });
      };
      syncModels();
      this.listenTo(this.model, `change:${this.idName}`, (m, v, o) => {
        if (!o.ui || o.fromView && o.fromView !== this) {
          syncModels();
        }
      });
      this.listenTo(this.subModel, 'change', (m, o) => o.ui ? this.trigger('change') : null);
      this.listenTo(this.model, 'change:pipelineId pipeline-changed', async () => {
        await this.onEditModeSet();
        await this.reRender();
      });
    }

    /**
     * @private
     * @return {{id: string, stages: {id: string, name: string, style: string|null}[]}|null}
     */
    getPipeline() {
      const pipelineId = this.model.attributes.pipelineId;
      if (!pipelineId) {
        return null;
      }
      return this.pipelines.find(it => it.id === pipelineId) ?? null;
    }
    onEditModeSet() {
      const pipeline = this.getPipeline();
      const options = pipeline ? pipeline.stages.map(it => it.id) : [];
      const currentId = this.model.attributes[this.idName];
      if (!currentId || !pipeline) {
        options.unshift('');
      }
      if (currentId && !options.includes(currentId)) {
        options.push(currentId);
      }
      const translatedOptions = {};
      const style = {};
      if (pipeline) {
        pipeline.stages.forEach(it => {
          translatedOptions[it.id] = it.name;
          style[it.id] = it.style;
        });
      }
      if (currentId && !translatedOptions[currentId]) {
        translatedOptions[currentId] = this.model.attributes[this.idName] ?? currentId;
      }
      this.enumView = new _enum.default({
        name: 'stage',
        model: this.subModel,
        mode: 'edit',
        params: {
          options,
          translatedOptions,
          style
        }
      });
      return this.assignView('stageField', this.enumView, '[data-sub-field="stage"]');
    }
    fetch() {
      const id = this.subModel.attributes.stage;
      let name = null;
      const pipeline = this.getPipeline();
      if (id && pipeline) {
        var _pipeline$stages$find;
        name = ((_pipeline$stages$find = pipeline.stages.find(it => it.id === id)) === null || _pipeline$stages$find === void 0 ? void 0 : _pipeline$stages$find.name) ?? null;
      }

      // noinspection JSValidateTypes
      return {
        [this.idName]: id,
        [this.nameName]: name ?? id
      };
    }
  }
  _exports.default = PipelineFieldView;
});

define("views/export/record/record", ["exports", "views/record/edit-for-modal"], function (_exports, _editForModal) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _editForModal = _interopRequireDefault(_editForModal);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ExportRecordView extends _editForModal.default {
    formatList = null;

    /**
     * @type {Object.<string, string[]>},
     */
    customParams = null;
    setupBeforeFinal() {
      this.formatList = this.options.formatList;
      this.scope = this.options.scope;
      const fieldsData = this.getExportFieldsData();
      this.setupExportFieldDefs(fieldsData);
      this.setupExportLayout(fieldsData);
      this.setupExportDynamicLogic();
      this.controlFormatField();
      this.listenTo(this.model, 'change:format', () => this.controlFormatField());
      this.controlAllFields();
      this.listenTo(this.model, 'change:exportAllFields', () => this.controlAllFields());
      super.setupBeforeFinal();
    }
    setupExportFieldDefs(fieldsData) {
      const fieldDefs = {
        format: {
          type: 'enum',
          options: this.formatList
        },
        fieldList: {
          type: 'multiEnum',
          options: fieldsData.list,
          required: true
        },
        exportAllFields: {
          type: 'bool'
        }
      };
      this.customParams = {};
      this.formatList.forEach(format => {
        const fields = this.getFormatParamsDefs(format).fields || {};
        this.customParams[format] = [];
        for (const name in fields) {
          const newName = this.modifyParamName(format, name);
          this.customParams[format].push(name);
          fieldDefs[newName] = Espo.Utils.cloneDeep(fields[name]);
        }
      });
      this.model.setDefs({
        fields: fieldDefs
      });
    }
    setupExportLayout(fieldsData) {
      this.detailLayout = [];
      const mainPanel = {
        rows: [[{
          name: 'format'
        }, false], [{
          name: 'exportAllFields'
        }, false], [{
          name: 'fieldList',
          options: {
            translatedOptions: fieldsData.translations
          }
        }]]
      };
      this.detailLayout.push(mainPanel);
      this.formatList.forEach(format => {
        const rows = this.getFormatParamsDefs(format).layout || [];
        rows.forEach(row => {
          row.forEach(item => {
            item.name = this.modifyParamName(format, item.name);
          });
        });
        this.detailLayout.push({
          name: format,
          rows: rows
        });
      });
    }
    setupExportDynamicLogic() {
      this.dynamicLogicDefs = {
        fields: {}
      };
      this.formatList.forEach(format => {
        const defs = this.getFormatParamsDefs(format).dynamicLogic || {};
        this.customParams[format].forEach(param => {
          const logic = defs[param] || {};
          if (!logic.visible) {
            logic.visible = {};
          }
          if (!logic.visible.conditionGroup) {
            logic.visible.conditionGroup = [];
          }
          logic.visible.conditionGroup.push({
            type: 'equals',
            attribute: 'format',
            value: format
          });
          const newName = this.modifyParamName(format, param);
          this.dynamicLogicDefs.fields[newName] = logic;
        });
      });
    }

    /**
     * @param {string} format
     * @return {string[]}
     */
    getFormatParamList(format) {
      return Object.keys(this.getFormatParamsDefs(format).fields || {});
    }

    /**
     * @private
     * @return {Object.<string, *>}
     */
    getFormatParamsDefs(format) {
      const defs = this.getMetadata().get(['app', 'export', 'formatDefs', format]) || {};
      return Espo.Utils.cloneDeep(defs.params || {});
    }

    /**
     * @param {string} format
     * @param {string} name
     * @return {string}
     */
    modifyParamName(format, name) {
      return format + Espo.Utils.upperCaseFirst(name);
    }

    /**
     * @return {{
     *   translations: Object.<string, string>,
     *   list: string[]
     * }}
     */
    getExportFieldsData() {
      let fieldList = this.getFieldManager().getEntityTypeFieldList(this.scope);
      const forbiddenFieldList = this.getAcl().getScopeForbiddenFieldList(this.scope);
      fieldList = fieldList.filter(item => {
        return !~forbiddenFieldList.indexOf(item);
      });
      fieldList = fieldList.filter(item => {
        /** @type {Record} */
        const defs = this.getMetadata().get(['entityDefs', this.scope, 'fields', item]) || {};
        if (defs.disabled || defs.exportDisabled || defs.type === 'map' || defs.utility) {
          return false;
        }
        return true;
      });
      this.getLanguage().sortFieldList(this.scope, fieldList);
      fieldList.unshift('id');
      const fieldListTranslations = {};
      fieldList.forEach(item => {
        fieldListTranslations[item] = this.getLanguage().translate(item, 'fields', this.scope);
      });
      const setFieldList = this.model.get('fieldList') || [];
      setFieldList.forEach(item => {
        if (~fieldList.indexOf(item)) {
          return;
        }
        if (!~item.indexOf('_')) {
          return;
        }
        const arr = item.split('_');
        fieldList.push(item);
        const foreignScope = this.getMetadata().get(['entityDefs', this.scope, 'links', arr[0], 'entity']);
        if (!foreignScope) {
          return;
        }
        fieldListTranslations[item] = this.getLanguage().translate(arr[0], 'links', this.scope) + '.' + this.getLanguage().translate(arr[1], 'fields', foreignScope);
      });
      return {
        list: fieldList,
        translations: fieldListTranslations
      };
    }
    controlAllFields() {
      if (!this.model.get('exportAllFields')) {
        this.showField('fieldList');
        return;
      }
      this.hideField('fieldList');
    }
    controlFormatField() {
      const format = this.model.get('format');
      this.formatList.filter(item => item !== format).forEach(format => {
        this.hidePanel(format);
      });
      this.formatList.filter(item => item === format).forEach(format => {
        this.customParams[format].length ? this.showPanel(format) : this.hidePanel(format);
      });
    }
  }
  var _default = _exports.default = ExportRecordView;
});

define("views/export/modals/idle", ["exports", "views/modal", "model"], function (_exports, _modal, _model) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  _model = _interopRequireDefault(_model);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ExportIdleModalView extends _modal.default {
    template = 'export/modals/idle';
    className = 'dialog dialog-record';
    checkInterval = 4000;
    data() {
      return {
        infoText: this.translate('infoText', 'messages', 'Export')
      };
    }
    setup() {
      this.addActionHandler('download', () => this.actionDownload());
      this.action = this.options.action;
      this.id = this.options.id;
      this.status = 'Pending';
      this.headerText = this.translate('Export');
      this.model = new _model.default();
      this.model.name = 'Export';
      this.model.setDefs({
        fields: {
          'status': {
            type: 'enum',
            readOnly: true,
            options: ['Pending', 'Running', 'Success', 'Failed'],
            style: {
              'Success': 'success',
              'Failed': 'danger'
            }
          },
          'attachmentId': {
            type: 'varchar'
          }
        }
      });
      this.model.set({
        status: this.status,
        processedCount: null
      });
      this.createView('record', 'views/record/edit-for-modal', {
        scope: 'None',
        model: this.model,
        selector: '.record',
        detailLayout: [{
          rows: [[{
            name: 'status',
            labelText: this.translate('status', 'fields', 'Export')
          }]]
        }]
      });
      this.on('close', () => {
        const status = this.model.get('status');
        if (status !== 'Pending' && status !== 'Running') {
          return;
        }
        Espo.Ajax.postRequest(`Export/${this.id}/subscribe`);
      });
      this.checkStatus();
    }

    /**
     * @private
     */
    checkStatus() {
      Espo.Ajax.getRequest(`Export/${this.id}/status`).then(response => {
        const status = response.status;
        this.model.set('status', status);
        if (status === 'Pending' || status === 'Running') {
          setTimeout(() => this.checkStatus(), this.checkInterval);
          return;
        }
        this.model.set({
          attachmentId: response.attachmentId
        });
        if (status === 'Success') {
          this.trigger('success', {
            attachmentId: response.attachmentId
          });
          this.showDownload();
        }
        if (this.$el) {
          this.$el.find('.info-text').addClass('hidden');
        }
      });
    }

    /**
     * @private
     */
    showDownload() {
      this.$el.find('.download-container').removeClass('hidden');
      const $download = this.$el.find('[data-action="download"]');
      $download.removeClass('hidden');
    }

    /**
     * @private
     */
    actionDownload() {
      this.trigger('download', this.model.get('attachmentId'));
      this.close();
    }
  }
  var _default = _exports.default = ExportIdleModalView;
});

define("views/export/modals/export", ["exports", "views/modal", "model"], function (_exports, _modal, _model) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  _model = _interopRequireDefault(_model);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ExportModalView extends _modal.default {
    cssName = 'export-modal';
    className = 'dialog dialog-record';
    template = 'export/modals/export';
    shortcutKeys = {
      'Control+Enter': 'export'
    };
    setup() {
      this.buttonList = [{
        name: 'export',
        label: 'Export',
        style: 'danger',
        title: 'Ctrl+Enter'
      }, {
        name: 'cancel',
        label: 'Cancel'
      }];
      this.model = new _model.default();
      this.model.name = 'Export';
      this.scope = this.options.scope;
      if (this.options.fieldList) {
        const fieldList = this.options.fieldList.filter(field => {
          /** @type {Record} */
          const defs = this.getMetadata().get(`entityDefs.${this.scope}.fields.${field}`) || {};
          return !defs.exportDisabled && !defs.utility;
        });
        this.model.set('fieldList', fieldList);
        this.model.set('exportAllFields', false);
      } else {
        this.model.set('exportAllFields', true);
      }
      const formatList = this.getMetadata().get(['scopes', this.scope, 'exportFormatList']) || this.getMetadata().get('app.export.formatList');
      this.model.set('format', formatList[0]);
      this.createView('record', 'views/export/record/record', {
        scope: this.scope,
        model: this.model,
        selector: '.record',
        formatList: formatList
      });
    }

    /**
     * @return {import('views/record/edit').default}
     */
    getRecordView() {
      return this.getView('record');
    }

    // noinspection JSUnusedGlobalSymbols
    actionExport() {
      const recordView = this.getRecordView();
      const data = recordView.fetch();
      this.model.set(data);
      if (recordView.validate()) {
        return;
      }
      const returnData = {
        exportAllFields: data.exportAllFields,
        format: data.format
      };
      if (!data.exportAllFields) {
        const attributeList = [];
        data.fieldList.forEach(item => {
          if (item === 'id') {
            attributeList.push('id');
            return;
          }
          const type = this.getMetadata().get(['entityDefs', this.scope, 'fields', item, 'type']);
          if (type) {
            this.getFieldManager().getAttributeList(type, item).forEach(attribute => {
              attributeList.push(attribute);
            });
          }
          if (~item.indexOf('_')) {
            attributeList.push(item);
          }
        });
        returnData.attributeList = attributeList;
        returnData.fieldList = data.fieldList;
      }
      returnData.params = {};
      recordView.getFormatParamList(data.format).forEach(param => {
        const name = recordView.modifyParamName(data.format, param);
        const fieldView = recordView.getFieldView(name);
        if (!fieldView || fieldView.disabled) {
          return;
        }
        this.getFieldManager().getActualAttributeList(fieldView.type, param).forEach(subParam => {
          const name = recordView.modifyParamName(data.format, subParam);
          returnData.params[subParam] = data[name];
        });
      });
      this.trigger('proceed', returnData);
      this.close();
    }
  }
  var _default = _exports.default = ExportModalView;
});

define("views/event/fields/name-for-history", ["exports", "views/fields/varchar"], function (_exports, _varchar) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _varchar = _interopRequireDefault(_varchar);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _varchar.default {
    listLinkTemplate = 'event/fields/name-for-history/list-link';
    data() {
      const data = super.data();
      const status = this.model.get('status');
      const canceledStatusList = this.getMetadata().get(['scopes', this.model.entityType, 'canceledStatusList']) || [];
      data.strikethrough = canceledStatusList.includes(status);
      return data;
    }
  }
  _exports.default = _default;
});

define("views/email-template/list", ["exports", "views/list-with-categories"], function (_exports, _listWithCategories) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _listWithCategories = _interopRequireDefault(_listWithCategories);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _listWithCategories.default {
    quickCreate = false;
  }
  _exports.default = _default;
});

define("views/email-template/record/edit", ["exports", "views/record/edit", "views/email-template/record/detail"], function (_exports, _edit, _detail) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _edit = _interopRequireDefault(_edit);
  _detail = _interopRequireDefault(_detail);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _edit.default {
    saveAndContinueEditingAction = true;
    setup() {
      super.setup();
      _detail.default.prototype.listenToInsertField.call(this);
    }
  }
  _exports.default = _default;
});

define("views/email-template/record/edit-quick", ["exports", "views/record/edit", "views/email-template/record/detail"], function (_exports, _edit, _detail) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _edit = _interopRequireDefault(_edit);
  _detail = _interopRequireDefault(_detail);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _edit.default {
    setup() {
      super.setup();
      _detail.default.prototype.listenToInsertField.call(this);
    }
  }
  _exports.default = _default;
});

define("views/email-template/record/panels/information", ["exports", "views/record/panels/side"], function (_exports, _side) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _side = _interopRequireDefault(_side);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _side.default {
    templateContent = `{{{infoText}}}`;
    data() {
      const list2 = this.getMetadata().get(['clientDefs', 'EmailTemplate', 'placeholderList']) || [];
      const defs = this.getMetadata().get('app.emailTemplate.placeholders') || {};
      const list1 = Object.keys(defs).sort((a, b) => {
        const o1 = defs[a].order || 0;
        const o2 = defs[b].order || 0;
        return o1 - o2;
      });
      const placeholderList = [...list1, ...list2];
      if (!placeholderList.length) {
        return {
          infoText: ''
        };
      }
      const $header = $('<h4>').text(this.translate('Available placeholders', 'labels', 'EmailTemplate') + ':');
      const $liList = placeholderList.map(item => {
        return $('<li>').append($('<code>').text('{' + item + '}'), ' &#8211; ', $('<span>').text(this.translate(item, 'placeholderTexts', 'EmailTemplate')));
      });
      const $ul = $('<ul>').append($liList);
      const $text = $('<span>').addClass('complex-text').append($header, $ul);
      return {
        infoText: $text[0].outerHTML
      };
    }
  }
  _exports.default = _default;
});

define("views/email-template/fields/insert-field", ["exports", "views/fields/base", "ui/select"], function (_exports, _base, _select) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  _select = _interopRequireDefault(_select);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _base.default {
    inlineEditDisabled = true;
    detailTemplate = 'email-template/fields/insert-field/detail';
    editTemplate = 'email-template/fields/insert-field/edit';
    data() {
      return {};
    }
    setup() {
      this.addActionHandler('insert', () => {
        const entityType = this.$entityType.val();
        const field = this.$field.val();
        if (!field) {
          return;
        }
        this.insert(entityType, field);
      });
      if (this.mode !== this.MODE_LIST) {
        const defs = this.getMetadata().get('scopes');
        const entityList = Object.keys(defs).filter(scope => {
          if (scope === 'Email') {
            return;
          }
          if (!this.getAcl().checkScope(scope)) {
            return;
          }
          return defs[scope].entity && defs[scope].object;
        });
        this.translatedOptions = {};
        const entityPlaceholders = {};
        entityList.forEach(scope => {
          this.translatedOptions[scope] = {};
          entityPlaceholders[scope] = this.getScopeAttributeList(scope);
          entityPlaceholders[scope].forEach(item => {
            this.translatedOptions[scope][item] = this.translatePlaceholder(scope, item);
          });

          /** @type {Record<string, Record>} */
          const links = this.getMetadata().get(`entityDefs.${scope}.links`) || {};
          const linkList = Object.keys(links).sort((v1, v2) => {
            return this.translate(v1, 'links', scope).localeCompare(this.translate(v2, 'links', scope));
          });
          linkList.forEach(link => {
            const type = links[link].type;
            if (type !== 'belongsTo') {
              return;
            }
            const foreignScope = links[link].entity;
            if (!foreignScope) {
              return;
            }
            if (links[link].disabled || links[link].utility) {
              return;
            }
            if (this.getMetadata().get(['entityAcl', scope, 'links', link, 'onlyAdmin']) || this.getMetadata().get(['entityAcl', scope, 'links', link, 'forbidden']) || this.getMetadata().get(['entityAcl', scope, 'links', link, 'internal'])) {
              return;
            }
            const attributeList = this.getScopeAttributeList(foreignScope, true);
            attributeList.forEach(item => {
              entityPlaceholders[scope].push(`${link}.${item}`);
              this.translatedOptions[scope][`${link}.${item}`] = this.translatePlaceholder(scope, `${link}.${item}`);
            });
          });
        });
        entityPlaceholders['Person'] = ['name', 'firstName', 'lastName', 'salutationName', 'emailAddress', 'assignedUserName'];
        this.translatedOptions['Person'] = {};
        this.entityList = entityList;
        this.entityFields = entityPlaceholders;
      }
    }

    /**
     * @private
     * @param {string} scope
     * @param {boolean} [isForeign]
     * @return {string[]}
     */
    getScopeAttributeList(scope) {
      let isForeign = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
      let fieldList = this.getFieldManager().getEntityTypeFieldList(scope);
      let list = [];
      fieldList = fieldList.sort((v1, v2) => {
        return this.translate(v1, 'fields', scope).localeCompare(this.translate(v2, 'fields', scope));
      });
      fieldList.forEach(field => {
        const fieldType = this.getMetadata().get(['entityDefs', scope, 'fields', field, 'type']);

        /** @type {Record} */
        const aclDefs = this.getMetadata().get(['entityAcl', scope, 'fields', field]) || {};
        /** @type {Record} */
        const fieldDefs = this.getMetadata().get(['entityDefs', scope, 'fields', field]) || {};
        if (aclDefs.onlyAdmin || aclDefs.forbidden || aclDefs.internal || fieldDefs.disabled || fieldDefs.utility || fieldDefs.directAccessDisabled && (isForeign || !fieldDefs.loaderClassName) || fieldDefs.templatePlaceholderDisabled) {
          return false;
        }
        if (fieldType === 'map') {
          return;
        }
        if (fieldType === 'linkMultiple') {
          return;
        }
        if (fieldType === 'attachmentMultiple') {
          return;
        }
        if (this.getMetadata().get(['entityAcl', scope, 'fields', field, 'onlyAdmin']) || this.getMetadata().get(['entityAcl', scope, 'fields', field, 'forbidden']) || this.getMetadata().get(['entityAcl', scope, 'fields', field, 'internal'])) {
          return;
        }
        const fieldAttributeList = this.getFieldManager().getAttributeList(fieldType, field);
        fieldAttributeList.forEach(attribute => {
          if (list.includes(attribute)) {
            return;
          }
          list.push(attribute);
        });
      });
      const forbiddenList = this.getAcl().getScopeForbiddenAttributeList(scope);
      list = list.filter(item => {
        if (~forbiddenList.indexOf(item)) {
          return;
        }
        return true;
      });
      list.push('id');
      if (this.getMetadata().get('entityDefs.' + scope + '.fields.name.type') === 'personName') {
        list.unshift('name');
      }
      return list;
    }

    /**
     * @private
     * @param {string} entityType
     * @param {string} item
     * @return {string}
     */
    translatePlaceholder(entityType, item) {
      let field = item;
      let scope = entityType;
      let isForeign = false;
      let link;
      if (item.includes('.')) {
        isForeign = true;
        field = item.split('.')[1];
        link = item.split('.')[0];
        scope = this.getMetadata().get(`entityDefs.${entityType}.links.${link}.entity`);
      }
      let label = this.translate(field, 'fields', scope);
      if (field.indexOf('Id') === field.length - 2) {
        const baseField = field.substr(0, field.length - 2);
        if (this.getMetadata().get(['entityDefs', scope, 'fields', baseField])) {
          label = this.translate(baseField, 'fields', scope) + ' (' + this.translate('id', 'fields') + ')';
        }
      } else if (field.indexOf('Name') === field.length - 4) {
        const baseField = field.substr(0, field.length - 4);
        if (this.getMetadata().get(['entityDefs', scope, 'fields', baseField])) {
          label = this.translate(baseField, 'fields', scope) + ' (' + this.translate('name', 'fields') + ')';
        }
      } else if (field.indexOf('Type') === field.length - 4) {
        const baseField = field.substr(0, field.length - 4);
        if (this.getMetadata().get(['entityDefs', scope, 'fields', baseField])) {
          label = this.translate(baseField, 'fields', scope) + ' (' + this.translate('type', 'fields') + ')';
        }
      }
      if (field.indexOf('Ids') === field.length - 3) {
        const baseField = field.substr(0, field.length - 3);
        if (this.getMetadata().get(['entityDefs', scope, 'fields', baseField])) {
          label = this.translate(baseField, 'fields', scope) + ' (' + this.translate('ids', 'fields') + ')';
        }
      } else if (field.indexOf('Names') === field.length - 5) {
        const baseField = field.substr(0, field.length - 5);
        if (this.getMetadata().get(['entityDefs', scope, 'fields', baseField])) {
          label = this.translate(baseField, 'fields', scope) + ' (' + this.translate('names', 'fields') + ')';
        }
      } else if (field.indexOf('Types') === field.length - 5) {
        const baseField = field.substr(0, field.length - 5);
        if (this.getMetadata().get(['entityDefs', scope, 'fields', baseField])) {
          label = this.translate(baseField, 'fields', scope) + ' (' + this.translate('types', 'fields') + ')';
        }
      }
      if (isForeign) {
        label = this.translate(link, 'links', entityType) + ' . ' + label;
      }
      return label;
    }
    afterRender() {
      super.afterRender();
      if (this.mode === this.MODE_EDIT) {
        const entityTranslation = {};
        this.entityList.forEach(scope => {
          entityTranslation[scope] = this.translate(scope, 'scopeNames');
        });
        this.entityList.sort((a, b) => {
          return a.localeCompare(b);
        });
        const $entityType = this.$entityType = this.$el.find('[data-name="entityType"]');
        this.$field = this.$el.find('[data-name="field"]');
        $entityType.on('change', () => {
          this.changeEntityType();
        });
        $entityType.append($('<option>').val('Person').text(this.translate('Person')));
        this.entityList.forEach(scope => {
          $entityType.append($('<option>').val(scope).text(entityTranslation[scope]));
        });
        _select.default.init(this.$field);
        this.changeEntityType();
        _select.default.init(this.$entityType);
      }
    }

    /**
     * @private
     */
    changeEntityType() {
      const entityType = this.$entityType.val();
      const fieldList = this.entityFields[entityType];
      _select.default.setValue(this.$field, '');
      _select.default.setOptions(this.$field, fieldList.map(field => {
        return {
          value: field,
          label: this.translateItem(entityType, field)
        };
      }));
    }

    /**
     * @private
     * @param {string} entityType
     * @param {string} item
     * @return {string}
     */
    translateItem(entityType, item) {
      if (this.translatedOptions[entityType][item]) {
        return this.translatedOptions[entityType][item];
      }
      return this.translate(item, 'fields');
    }

    /**
     * @private
     * @param {string} entityType
     * @param {string} field
     */
    insert(entityType, field) {
      this.model.trigger('insert-field', {
        entityType: entityType,
        field: field
      });
    }
  }
  _exports.default = _default;
});

define("views/email-template/fields/body", ["exports", "views/fields/wysiwyg"], function (_exports, _wysiwyg) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _wysiwyg = _interopRequireDefault(_wysiwyg);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EmailTemplateBodyFieldView extends _wysiwyg.default {
    // To allow the iterate attribute.
    htmlPurificationForEditDisabled = true;
    hasBodyPlainField = true;
  }
  var _default = _exports.default = EmailTemplateBodyFieldView;
});

define("views/email-folder/list", ["exports", "views/list"], function (_exports, _list) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _list = _interopRequireDefault(_list);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _list.default {
    quickCreate = true;
    setup() {
      super.setup();
      this.collection.data = {
        boolFilterList: ['onlyMy']
      };
    }
  }
  _exports.default = _default;
});

define("views/email-folder/list-side", ["exports", "view"], function (_exports, _view) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _view = _interopRequireDefault(_view);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _view.default {
    template = 'email-folder/list-side';
    FOLDER_ALL = 'all';
    FOLDER_INBOX = 'inbox';
    FOLDER_DRAFTS = 'drafts';
    data() {
      const data = {};
      data.selectedFolderId = this.selectedFolderId;
      data.showEditLink = this.options.showEditLink;
      data.scope = this.scope;
      return data;
    }
    actionSelectFolder(id) {
      this.$el.find('li.selected').removeClass('selected');
      this.selectFolder(id);
      this.$el.find(`li[data-id="${id}"]`).addClass('selected');
    }
    setup() {
      this.addActionHandler('selectFolder', (e, target) => {
        e.preventDefault();
        this.actionSelectFolder(target.dataset.id);
      });
      this.scope = 'EmailFolder';
      this.selectedFolderId = this.options.selectedFolderId || this.FOLDER_ALL;
      this.emailCollection = this.options.emailCollection;
      this.loadNotReadCounts();
      this.listenTo(this.emailCollection, 'sync', this.loadNotReadCounts);
      this.listenTo(this.emailCollection, 'folders-update', this.loadNotReadCounts);
      this.listenTo(this.emailCollection, 'all-marked-read', () => {
        this.countsData = this.countsData || {};
        for (const id in this.countsData) {
          if (id === this.FOLDER_DRAFTS) {
            continue;
          }
          this.countsData[id] = 0;
        }
        this.renderCounts();
      });
      this.listenTo(this.emailCollection, 'draft-sent', () => {
        this.decreaseNotReadCount(this.FOLDER_DRAFTS);
        this.renderCounts();
      });
      this.listenTo(this.emailCollection, 'change:isRead', model => {
        if (this.countsIsBeingLoaded) {
          return;
        }
        this.manageCountsDataAfterModelChanged(model);
      });
      this.listenTo(this.emailCollection, 'model-removing', id => {
        const model = this.emailCollection.get(id);
        if (!model) {
          return;
        }
        if (this.countsIsBeingLoaded) {
          return;
        }
        this.manageModelRemoving(model);
      });
      this.listenTo(this.emailCollection, 'moving-to-trash', (id, model) => {
        model = this.emailCollection.get(id) || model;
        if (!model) {
          return;
        }
        if (this.countsIsBeingLoaded) {
          return;
        }
        this.manageModelRemoving(model);
      });
      this.listenTo(this.emailCollection, 'retrieving-from-trash', (id, model) => {
        model = this.emailCollection.get(id) || model;
        if (!model) {
          return;
        }
        if (this.countsIsBeingLoaded) {
          return;
        }
        this.manageModelRetrieving(model);
      });
    }
    manageModelRemoving(model) {
      if (model.get('status') === 'Draft') {
        this.decreaseNotReadCount(this.FOLDER_DRAFTS);
        this.renderCounts();
        return;
      }
      if (!model.get('isUsers')) {
        return;
      }
      if (model.get('isRead')) {
        return;
      }
      let folderId = model.get('groupFolderId') ? 'group:' + model.get('groupFolderId') : model.get('folderId') || this.FOLDER_INBOX;
      this.decreaseNotReadCount(folderId);
      this.renderCounts();
    }
    manageModelRetrieving(model) {
      if (!model.get('isUsers')) {
        return;
      }
      if (model.get('isRead')) {
        return;
      }
      const folderId = model.get('groupFolderId') ? 'group:' + model.get('groupFolderId') : model.get('folderId') || this.FOLDER_INBOX;
      this.increaseNotReadCount(folderId);
      this.renderCounts();
    }
    manageCountsDataAfterModelChanged(model) {
      if (!model.get('isUsers')) {
        return;
      }
      const folderId = model.get('groupFolderId') ? 'group:' + model.get('groupFolderId') : model.get('folderId') || this.FOLDER_INBOX;
      !model.get('isRead') ? this.increaseNotReadCount(folderId) : this.decreaseNotReadCount(folderId);
      this.renderCounts();
    }
    increaseNotReadCount(folderId) {
      this.countsData = this.countsData || {};
      this.countsData[folderId] = this.countsData[folderId] || 0;
      this.countsData[folderId]++;
    }
    decreaseNotReadCount(folderId) {
      this.countsData = this.countsData || {};
      this.countsData[folderId] = this.countsData[folderId] || 0;
      if (this.countsData[folderId]) {
        this.countsData[folderId]--;
      }
    }
    selectFolder(id) {
      this.emailCollection.reset();
      this.emailCollection.abortLastFetch();
      this.selectedFolderId = id;
      this.trigger('select', id);
    }
    afterRender() {
      if (this.countsData) {
        this.renderCounts();
      }
    }
    loadNotReadCounts() {
      if (this.countsIsBeingLoaded) {
        return;
      }
      this.countsIsBeingLoaded = true;
      Espo.Ajax.getRequest('Email/inbox/notReadCounts').then(data => {
        this.countsData = data;
        if (this.isRendered()) {
          this.renderCounts();
          this.countsIsBeingLoaded = false;
          return;
        }
        this.once('after:render', () => {
          this.renderCounts();
          this.countsIsBeingLoaded = false;
        });
      });
    }
    renderCounts() {
      const data = this.countsData;
      for (const id in data) {
        let value = '';
        if (data[id]) {
          value = data[id].toString();
        }
        this.$el.find(`li a.count[data-id="${id}"]`).text(value);
      }
    }
  }
  _exports.default = _default;
});

define("views/email-folder/record/list", ["exports", "views/record/list"], function (_exports, _list) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _list = _interopRequireDefault(_list);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _list.default {
    massUpdateDisabled = true;
    mergeDisabled = true;
    exportDisabled = true;
    removeDisabled = true;
    rowActionsView = 'views/email-folder/record/row-actions/default';

    // noinspection JSUnusedGlobalSymbols
    actionMoveUp(data) {
      const model = this.collection.get(data.id);
      if (!model) {
        return;
      }
      const index = this.collection.indexOf(model);
      if (index === 0) {
        return;
      }
      Espo.Ajax.postRequest('EmailFolder/action/moveUp', {
        id: model.id
      }).then(() => {
        this.collection.fetch();
      });
    }

    // noinspection JSUnusedGlobalSymbols
    actionMoveDown(data) {
      const model = this.collection.get(data.id);
      if (!model) {
        return;
      }
      const index = this.collection.indexOf(model);
      if (index === this.collection.length - 1 && this.collection.length === this.collection.total) {
        return;
      }
      Espo.Ajax.postRequest('EmailFolder/action/moveDown', {
        id: model.id
      }).then(() => {
        this.collection.fetch();
      });
    }
  }
  _exports.default = _default;
});

define("views/email-folder/record/edit-small", ["exports", "views/record/edit"], function (_exports, _edit) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _edit = _interopRequireDefault(_edit);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _edit.default {
    afterSave() {
      this.getBaseController().clearScopeStoredMainView('Email');
      super.afterSave();
    }
  }
  _exports.default = _default;
});

define("views/email-folder/record/row-actions/default", ["exports", "views/record/row-actions/default"], function (_exports, _default2) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _default2 = _interopRequireDefault(_default2);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _default2.default {
    getActionList() {
      const list = super.getActionList();
      if (this.options.acl.edit) {
        list.unshift({
          action: 'moveDown',
          label: 'Move Down',
          data: {
            id: this.model.id
          },
          iconClass: 'fas fa-arrow-down'
        });
        list.unshift({
          action: 'moveUp',
          label: 'Move Up',
          data: {
            id: this.model.id
          },
          iconClass: 'fas fa-arrow-up'
        });
      }
      return list;
    }
  }
  _exports.default = _default;
});

define("views/email-folder/modals/select-folder", ["exports", "views/modal"], function (_exports, _modal) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _modal.default {
    template = 'email-folder/modals/select-folder';
    cssName = 'select-folder';
    backdrop = true;

    /** @const */
    FOLDER_ALL = 'all';
    /** @const */
    FOLDER_INBOX = 'inbox';
    /** @const */
    FOLDER_IMPORTANT = 'important';
    /** @const */
    FOLDER_SENT = 'sent';
    /** @const */
    FOLDER_DRAFTS = 'drafts';
    /** @const */
    FOLDER_TRASH = 'trash';
    /** @const */
    FOLDER_ARCHIVE = 'archive';
    data() {
      return {
        folderDataList: this.folderDataList
      };
    }

    /**
     * @private
     * @type {string|undefined}
     */
    currentFolderId;
    setup() {
      this.addActionHandler('selectFolder', (e, target) => {
        const id = target.dataset.id;
        const name = target.dataset.name;
        this.trigger('select', id, name);
        this.close();
      });
      this.headerText = this.options.headerText || '';
      this.isGroup = this.options.isGroup || false;
      this.noArchive = this.options.noArchive || false;
      this.currentFolderId = this.options.currentFolderId;
      if (this.headerText === '') {
        this.buttonList.push({
          name: 'cancel',
          label: 'Cancel'
        });
      }
      Espo.Ui.notifyWait();
      this.wait(Espo.Ajax.getRequest('EmailFolder/action/listAll').then(/** {list: {id: string, name: string}[]} */data => {
        Espo.Ui.notify(false);
        const builtInFolders = [this.FOLDER_INBOX, this.FOLDER_IMPORTANT, this.FOLDER_SENT, this.FOLDER_DRAFTS, this.FOLDER_TRASH, this.FOLDER_ARCHIVE];
        const iconMap = {
          [this.FOLDER_ALL]: 'far fa-hdd',
          [this.FOLDER_TRASH]: 'far fa-trash-alt',
          [this.FOLDER_SENT]: 'far fa-paper-plane',
          [this.FOLDER_INBOX]: 'fas fa-inbox',
          [this.FOLDER_ARCHIVE]: 'far fa-caret-square-down'
        };
        this.folderDataList = data.list.filter(item => {
          if (this.isGroup && !item.id.startsWith('group:')) {
            return false;
          }
          return !builtInFolders.includes(item.id);
        }).map(item => {
          const isGroup = item.id.startsWith('group:');
          return {
            disabled: item.id === this.currentFolderId,
            id: item.id,
            name: item.name,
            isGroup: isGroup,
            iconClass: isGroup ? 'far fa-circle' : 'far fa-folder'
          };
        });
        this.folderDataList.unshift({
          id: 'inbox',
          name: this.isGroup ? this.translate('all', 'presetFilters', 'Email') : this.translate('inbox', 'presetFilters', 'Email'),
          iconClass: this.isGroup ? iconMap[this.FOLDER_ALL] : iconMap[this.FOLDER_INBOX]
        });
        if (!this.noArchive) {
          this.folderDataList.push({
            id: this.FOLDER_ARCHIVE,
            name: this.translate('archive', 'presetFilters', 'Email'),
            iconClass: iconMap[this.FOLDER_ARCHIVE],
            disabled: this.currentFolderId === this.FOLDER_ARCHIVE
          });
        }
      }));
    }
  }
  _exports.default = _default;
});

define("views/email-filter/record/list", ["exports", "views/record/list"], function (_exports, _list) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _list = _interopRequireDefault(_list);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _list.default {
    massActionList = ['remove', 'export'];
  }
  _exports.default = _default;
});

define("views/email-filter/modals/edit", ["exports", "views/modals/edit"], function (_exports, _edit) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _edit = _interopRequireDefault(_edit);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" wo
   * rd.
   ************************************************************************/

  class _default extends _edit.default {
    fullFormDisabled = true;
  }
  _exports.default = _default;
});

define("views/email-filter/fields/parent", ["exports", "views/fields/link-parent"], function (_exports, _linkParent) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _linkParent = _interopRequireDefault(_linkParent);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _linkParent.default {
    getSelectPrimaryFilterName() {
      const map = {
        'User': 'active'
      };
      if (!this.foreignScope) {
        return;
      }
      return map[this.foreignScope];
    }
  }
  _exports.default = _default;
});

define("views/email-filter/fields/email-folder", ["exports", "views/fields/link"], function (_exports, _link) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _link = _interopRequireDefault(_link);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _link.default {
    createDisabled = true;
    autocompleteDisabled = true;
    getSelectFilters() {
      if (this.getUser().isAdmin() && this.model.get('parentType') === 'User' && this.model.get('parentId')) {
        return {
          assignedUser: {
            type: 'equals',
            attribute: 'assignedUserId',
            value: this.model.get('parentId'),
            data: {
              nameValue: this.model.get('parentName')
            }
          }
        };
      }
    }
  }
  _exports.default = _default;
});

define("views/email/list", ["exports", "views/list", "utils"], function (_exports, _list, _utils) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _list = _interopRequireDefault(_list);
  _utils = _interopRequireDefault(_utils);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EmailListView extends _list.default {
    createButton = false;
    template = 'email/list';
    folderId = null;
    folderScope = 'EmailFolder';
    selectedFolderId = null;
    defaultFolderId = 'inbox';
    keepCurrentRootUrl = true;
    stickableTop = null;

    /** @const */
    FOLDER_ALL = 'all';
    /** @const */
    FOLDER_INBOX = 'inbox';
    /** @const */
    FOLDER_IMPORTANT = 'important';
    /** @const */
    FOLDER_SENT = 'sent';
    /** @const */
    FOLDER_DRAFTS = 'drafts';
    /** @const */
    FOLDER_TRASH = 'trash';
    /** @const */
    FOLDER_ARCHIVE = 'archive';
    noDropFolderIdList = ['sent', 'drafts'];

    /**
     * @inheritDoc
     */
    async createListRecordView(fetch) {
      const view = await super.createListRecordView(fetch);
      this.listenTo(view, 'after:render', () => this.initDraggable(null));
      this.listenTo(view, 'after:show-more', fromIndex_1 => this.initDraggable(fromIndex_1));
      return view;
    }

    /**
     * @private
     */
    initDroppable() {
      // noinspection JSUnresolvedReference
      this.$el.find('.folders-container .folder-list > .droppable').droppable({
        accept: '.list-row',
        tolerance: 'pointer',
        over: e => {
          if (!this.isDroppable(e)) {
            return;
          }
          const $target = $(e.target);
          $target.removeClass('success');
          $target.addClass('active');
          $target.find('a').css('pointer-events', 'none');
        },
        out: e => {
          if (!this.isDroppable(e)) {
            return;
          }
          const $target = $(e.target);
          $target.removeClass('active');
          $target.find('a').css('pointer-events', '');
        },
        drop: (e, ui) => {
          if (!this.isDroppable(e)) {
            return;
          }
          const $target = $(e.target);
          const $helper = $(ui.helper);
          $target.find('a').css('pointer-events', '');
          const folderId = $target.attr('data-id');
          let id = $helper.attr('data-id');
          id = id === '' ? true : id;
          this.onDrop(folderId, id);
          $target.removeClass('active');
          $target.addClass('success');
          setTimeout(() => {
            $target.removeClass('success');
          }, 1000);
        }
      });
    }

    /**
     * @private
     * @param {?Number} fromIndex
     */
    initDraggable(fromIndex) {
      fromIndex = fromIndex || 0;
      const isTouchDevice = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
      if (isTouchDevice) {
        return;
      }
      const $container = this.$el.find('.list-container > .list');
      const recordView = this.getEmailRecordView();
      this.collection.models.slice(fromIndex).forEach(m => {
        const $row = $container.find(`.list-row[data-id="${m.id}"]`).first();

        // noinspection JSUnresolvedReference,JSUnusedGlobalSymbols
        $row.draggable({
          cancel: 'input,textarea,button,select,option,.dropdown-menu',
          helper: () => {
            let text = this.translate('Moving to Folder', 'labels', 'Email');
            if (recordView.isIdChecked(m.id) && !recordView.isAllResultChecked() && recordView.getCheckedIds().length > 1) {
              text += ' · ' + recordView.getCheckedIds().length;
            }
            let draggedId = m.id;
            if (recordView.isIdChecked(m.id) && !recordView.isAllResultChecked()) {
              draggedId = '';
            }
            return $('<div>').attr('data-id', draggedId).css('cursor', 'grabbing').addClass('draggable-helper').text(text);
          },
          distance: 8,
          containment: this.$el,
          appendTo: 'body',
          cursor: 'grabbing',
          cursorAt: {
            top: 0,
            left: 0
          },
          drag: () => {
            if (recordView.isAllResultChecked()) {
              return false;
            }
          },
          start: e => {
            if (recordView.isAllResultChecked()) {
              return;
            }
            const $target = $(e.target);
            $target.closest('tr').addClass('active');
          },
          stop: () => {
            if (!recordView.isIdChecked(m.id)) {
              $container.find(`.list-row[data-id="${m.id}"]`).first().removeClass('active');
            }
          }
        });
      });
    }
    isDroppable(e) {
      const $target = $(e.target);
      const folderId = $target.attr('data-id');
      if (this.selectedFolderId === this.FOLDER_DRAFTS) {
        return false;
      }
      if (this.selectedFolderId === this.FOLDER_SENT && folderId === this.FOLDER_INBOX) {
        return false;
      }
      if (this.selectedFolderId === this.FOLDER_ALL) {
        if (folderId.indexOf('group:') === 0) {
          return true;
        }
        return false;
      }
      if (folderId === this.FOLDER_ALL) {
        if (this.selectedFolderId.indexOf('group:') === 0) {
          return true;
        }
        return false;
      }
      if (this.selectedFolderId === this.FOLDER_DRAFTS) {
        if (folderId.indexOf('group:') === 0) {
          return true;
        }
        if (folderId === this.FOLDER_TRASH || folderId === this.FOLDER_ARCHIVE) {
          return false;
        }
        return true;
      }
      if (this.selectedFolderId.indexOf('group:') === 0) {
        if ([this.FOLDER_ALL, this.FOLDER_ARCHIVE, this.FOLDER_TRASH].includes(folderId) || folderId.startsWith('group:')) {
          return true;
        }
        return false;
      }
      return true;
    }
    setup() {
      super.setup();
      this.addMenuItem('dropdown', false);
      if (this.getAcl().checkScope('EmailAccountScope')) {
        this.addMenuItem('dropdown', {
          name: 'reply',
          label: 'Email Accounts',
          link: '#EmailAccount/list/userId=' + this.getUser().id + '&userName=' + encodeURIComponent(this.getUser().get('name'))
        });
      }
      if (!this.getAcl().checkScope('Import')) {
        this.hideHeaderActionItem('archiveEmail');
      }
      if (this.getUser().isAdmin()) {
        this.addMenuItem('dropdown', {
          link: '#InboundEmail',
          label: 'Inbound Emails'
        });
      }
      this.foldersDisabled = this.foldersDisabled || this.getConfig().get('emailFoldersDisabled') || this.getMetadata().get(['scopes', this.folderScope, 'disabled']) || !this.getAcl().checkScope(this.folderScope);
      const params = this.options.params || {};
      this.selectedFolderId = params.folder || this.defaultFolderId;
      if (this.foldersDisabled) {
        this.selectedFolderId = null;
      }
      this.applyFolder();
      this.initEmailShortcuts();
      this.on('remove', () => {
        $(window).off('resize.email-folders');
        $(window).off('scroll.email-folders');
      });
    }
    data() {
      const data = {};
      data.foldersDisabled = this.foldersDisabled;
      return data;
    }

    /** @inheritDoc */
    createSearchView() {
      const promise = super.createSearchView();
      promise.then(view => {
        this.listenTo(view, 'update-ui', () => {
          this.stickableTop = null;
          setTimeout(() => {
            $(window).trigger('scroll');

            // If search fields are not yet rendered, the value may be wrong.
            this.stickableTop = null;
          }, 100);
        });
      });
      return promise;
    }
    initEmailShortcuts() {
      this.shortcutKeys['Control+Delete'] = e => {
        if (_utils.default.isKeyEventInTextInput(e)) {
          return;
        }
        if (!this.hasSelectedRecords()) {
          return;
        }
        e.preventDefault();
        e.stopPropagation();
        this.getEmailRecordView().massActionMoveToTrash();
      };
      this.shortcutKeys['Control+Backspace'] = e => {
        if (_utils.default.isKeyEventInTextInput(e)) {
          return;
        }
        if (!this.hasSelectedRecords()) {
          return;
        }
        e.preventDefault();
        e.stopPropagation();
        this.getEmailRecordView().massActionMoveToArchive();
      };
      this.shortcutKeys['Control+KeyI'] = e => {
        if (!this.hasSelectedRecords()) {
          return;
        }
        e.preventDefault();
        e.stopPropagation();
        this.getEmailRecordView().toggleMassMarkAsImportant();
      };
      this.shortcutKeys['Control+KeyM'] = e => {
        if (!this.hasSelectedRecords()) {
          return;
        }
        e.preventDefault();
        e.stopPropagation();
        this.getEmailRecordView().massActionMoveToFolder();
      };
      this.shortcutKeys['Control+KeyQ'] = e => {
        e.preventDefault();
        e.stopPropagation();
        if (this.hasSelectedRecords()) {
          this.getEmailRecordView().massActionMarkAsRead();
          return;
        }
        this.getEmailRecordView().actionMarkAllAsRead();
      };
    }

    /**
     * @private
     * @return {boolean}
     */
    hasSelectedRecords() {
      const recordView = this.getEmailRecordView();
      return recordView.getCheckedIds().length > 0 && !recordView.isAllResultChecked();
    }

    /** @inheritDoc */
    setupReuse(params) {
      super.setupReuse(params);
      this.applyRoutingParams(params);
      this.initDroppable();
      this.initStickableFolders();
      const recordView = /** @type {import('views/email/record/list').default} */this.getRecordView();
      recordView.removeQueuedRecord();
    }

    /**
     * @param {Object.<string,*>} [data]
     */
    actionComposeEmail(data) {
      data = data || {};
      Espo.Ui.notifyWait();
      const viewName = this.getMetadata().get('clientDefs.Email.modalViews.compose') || 'views/modals/compose-email';
      const options = {
        attributes: {
          status: 'Draft'
        },
        focusForCreate: data.focusForCreate
      };
      this.createView('quickCreate', viewName, options, view => {
        view.render();
        view.notify(false);
        this.listenToOnce(view, 'after:save', () => {
          this.collection.fetch();
        });
      });
    }
    afterRender() {
      super.afterRender();
      if (!this.foldersDisabled && !this.hasView('folders')) {
        this.loadFolders();
      }
    }

    /**
     * @private
     * @param {function(import('collection').default)} callback
     */
    getFolderCollection(callback) {
      this.getCollectionFactory().create(this.folderScope, collection => {
        collection.url = 'EmailFolder/action/listAll';
        collection.maxSize = 200;
        this.listenToOnce(collection, 'sync', () => {
          callback.call(this, collection);
        });
        collection.fetch();
      });
    }
    loadFolders() {
      let xhr = null;
      const auxFolderList = [this.FOLDER_TRASH, this.FOLDER_DRAFTS, this.FOLDER_ALL, this.FOLDER_INBOX, this.FOLDER_IMPORTANT, this.FOLDER_SENT, this.FOLDER_ARCHIVE];
      const iconMap = {
        [this.FOLDER_TRASH]: 'far fa-trash-alt',
        [this.FOLDER_SENT]: 'far fa-paper-plane',
        [this.FOLDER_INBOX]: 'fas fa-inbox',
        [this.FOLDER_ARCHIVE]: 'far fa-caret-square-down',
        [this.FOLDER_DRAFTS]: 'far fa-file',
        [this.FOLDER_IMPORTANT]: 'far fa-star'
      };
      this.getFolderCollection(collection => {
        collection.forEach((model, i) => {
          if (this.noDropFolderIdList.indexOf(model.id) === -1) {
            model.droppable = true;
          }
          if (model.id === this.FOLDER_INBOX) {
            model.groupStart = true;
          } else if (model.id === this.FOLDER_ARCHIVE || model.id === this.FOLDER_TRASH && !collection.models.find(m => m.id === this.FOLDER_ARCHIVE)) {
            model.groupStart = true;
          } else if (model.id.indexOf('group:') === 0 && collection.models.findIndex(m => m.id.indexOf('group:') === 0) === i) {
            model.groupStart = true;
          }
          model.iconClass = iconMap[model.id];
          if (model.id.indexOf('group:') === 0) {
            model.title = this.translate('groupFolder', 'fields', 'Email');
            model.iconClass = 'far fa-circle';
          } else if (auxFolderList.indexOf(model.id) === -1) {
            model.title = this.translate('folder', 'fields', 'Email');
            model.iconClass = 'far fa-folder';
          }
        });
        this.createView('folders', 'views/email-folder/list-side', {
          collection: collection,
          emailCollection: this.collection,
          selector: '.folders-container',
          showEditLink: this.getAcl().check(this.folderScope, 'edit'),
          selectedFolderId: this.selectedFolderId
        }, view => {
          view.render().then(() => this.initDroppable()).then(() => this.initStickableFolders());
          this.listenTo(view, 'select', id => {
            this.selectedFolderId = id;
            this.applyFolder();
            if (xhr && xhr.readyState < 4) {
              xhr.abort();
            }
            Espo.Ui.notifyWait();
            this.collection.offset = 0;
            xhr = this.collection.fetch().then(() => Espo.Ui.notify(false));
            if (id !== this.defaultFolderId) {
              this.getRouter().navigate(`#Email/list/folder=${id}`);
            } else {
              this.getRouter().navigate('#Email');
            }
            this.updateLastUrl();
          });
        });
      });
    }
    applyFolder() {
      this.rootData.selectedFolderId = this.selectedFolderId;
      this.collection.trigger('select-folder');
      if (!this.selectedFolderId) {
        this.collection.whereFunction = null;
        return;
      }
      this.collection.whereFunction = () => {
        return [{
          type: 'inFolder',
          attribute: 'folderId',
          value: this.selectedFolderId
        }];
      };
    }

    /**
     * @protected
     * @return {import('views/email-folder/list-side').default}
     */
    getFoldersView() {
      // noinspection JSValidateTypes
      return this.getView('folders');
    }
    applyRoutingParams(params) {
      let id;
      if ('folder' in params) {
        id = params.folder || 'inbox';
      } else {
        return;
      }
      if (!params.isReturnThroughLink && id !== this.selectedFolderId) {
        const foldersView = this.getFoldersView();
        if (foldersView) {
          foldersView.actionSelectFolder(id);
          foldersView.reRender();
          $(window).scrollTop(0);
        }
      }
    }
    onDrop(folderId, id) {
      const recordView = this.getEmailRecordView();
      if (folderId === this.FOLDER_IMPORTANT) {
        setTimeout(() => {
          id === true ? recordView.massActionMarkAsImportant() : recordView.actionMarkAsImportant({
            id: id
          });
        }, 10);
        return;
      }
      if (this.selectedFolderId === this.FOLDER_TRASH) {
        if (folderId === this.FOLDER_TRASH) {
          return;
        }
        id === true ? recordView.massRetrieveFromTrashMoveToFolder(folderId) : recordView.actionRetrieveFromTrashMoveToFolder({
          id: id,
          folderId: folderId
        });
        return;
      }
      if (folderId === this.FOLDER_TRASH) {
        id === true ? recordView.massActionMoveToTrash() : recordView.actionMoveToTrash({
          id: id
        });
        return;
      }
      if (this.selectedFolderId.indexOf('group:') === 0 && folderId === this.FOLDER_ALL) {
        folderId = this.FOLDER_INBOX;
      }
      id === true ? recordView.massMoveToFolder(folderId) : recordView.actionMoveToFolder({
        id: id,
        folderId: folderId
      });
    }

    /**
     * @protected
     * @return {module:views/email/record/list}
     */
    getEmailRecordView() {
      return /** @type {module:views/email/record/list} */this.getRecordView();
    }

    /**
     * @private
     */
    initStickableFolders() {
      const $window = $(window);
      const $list = this.$el.find('.list-container');
      const $container = this.$el.find('.folders-container');
      const $left = this.$el.find('.left-container').first();
      const screenWidthXs = this.getThemeManager().getParam('screenWidthXs');
      const isSmallScreen = $(window.document).width() < screenWidthXs;
      const factor = this.getThemeManager().getFontSizeFactor();
      const offset = this.getThemeManager().getParam('navbarHeight') * factor + (this.getThemeManager().getParam('buttonsContainerHeight') || 47) * factor;
      const bottomSpaceHeight = parseInt(window.getComputedStyle($('#content').get(0)).paddingBottom, 10);
      const getOffsetTop = (/** JQuery */$element) => {
        let element = $element.get(0);
        let value = 0;
        while (element) {
          value += !isNaN(element.offsetTop) ? element.offsetTop : 0;
          element = element.offsetParent;
        }
        if (isSmallScreen) {
          return value;
        }
        return value - offset;
      };
      this.stickableTop = getOffsetTop($list);
      const control = () => {
        let start = this.stickableTop;
        if (start === null) {
          start = this.stickableTop = getOffsetTop($list);
        }
        const scrollTop = $window.scrollTop();
        if (scrollTop <= start || isSmallScreen) {
          $container.removeClass('sticked').width('').scrollTop(0);
          $container.css({
            maxHeight: ''
          });
          return;
        }
        if (scrollTop > start) {
          const scroll = $window.scrollTop() - start;
          $container.addClass('sticked').width($left.outerWidth(true)).scrollTop(scroll);
          const topStickPosition = parseInt(window.getComputedStyle($container.get(0)).top);
          const maxHeight = $window.height() - topStickPosition - bottomSpaceHeight;
          $container.css({
            maxHeight: maxHeight
          });
        }
      };
      $window.on('resize.email-folders', () => control());
      $window.on('scroll.email-folders', () => control());
    }

    /**
     * @protected
     * @param {KeyboardEvent} e
     */
    handleShortcutKeyCtrlSpace(e) {
      if (_utils.default.isKeyEventInTextInput(e)) {
        return;
      }
      if (!this.getAcl().checkScope(this.scope, 'create')) {
        return;
      }
      e.preventDefault();
      e.stopPropagation();
      this.actionComposeEmail({
        focusForCreate: true
      });
    }
  }
  var _default = _exports.default = EmailListView;
});

define("views/email/detail", ["exports", "views/detail", "email-helper", "helpers/record-modal", "views/attachment/modals/select-one", "utils", "ui"], function (_exports, _detail, _emailHelper, _recordModal, _selectOne, _utils, _ui) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _detail = _interopRequireDefault(_detail);
  _emailHelper = _interopRequireDefault(_emailHelper);
  _recordModal = _interopRequireDefault(_recordModal);
  _selectOne = _interopRequireDefault(_selectOne);
  _utils = _interopRequireDefault(_utils);
  _ui = _interopRequireDefault(_ui);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EmailDetailView extends _detail.default {
    setup() {
      super.setup();
      const status = this.model.get('status');
      if (status === 'Draft') {
        this.menu = {
          'buttons': [],
          'dropdown': [],
          'actions': []
        };
      } else {
        this.addMenuItem('buttons', {
          name: 'reply',
          label: 'Reply',
          action: this.getPreferences().get('emailReplyToAllByDefault') ? 'replyToAll' : 'reply',
          style: 'danger',
          className: 'btn-s-wide'
        }, true);
        this.addMenuItem('dropdown', false);
        if (status === 'Archived') {
          if (!this.model.get('parentId')) {
            this.addMenuItem('dropdown', {
              label: 'Create Lead',
              action: 'createLead',
              acl: 'create',
              aclScope: 'Lead',
              iconClass: 'fas fa-plus'
            });
            this.addMenuItem('dropdown', {
              label: 'Create Contact',
              action: 'createContact',
              acl: 'create',
              aclScope: 'Contact',
              iconClass: 'fas fa-plus'
            });
          }
        }
        this.addMenuItem('dropdown', {
          label: 'Create Task',
          action: 'createTask',
          acl: 'create',
          aclScope: 'Task',
          iconClass: 'fas fa-plus'
        });
        if (this.model.get('parentType') !== 'Case' || !this.model.get('parentId')) {
          this.addMenuItem('dropdown', {
            label: 'Create Case',
            action: 'createCase',
            acl: 'create',
            aclScope: 'Case',
            iconClass: 'fas fa-plus'
          });
        }
        if (this.getAcl().checkScope('Document', 'create')) {
          if (this.model.get('attachmentsIds') === undefined || this.model.getLinkMultipleIdList('attachments').length) {
            this.addMenuItem('dropdown', {
              text: this.translate('Create Document', 'labels', 'Document'),
              action: 'createDocument',
              acl: 'create',
              aclScope: 'Document',
              hidden: this.model.get('attachmentsIds') === undefined,
              iconClass: 'fas fa-plus'
            });
            if (this.model.get('attachmentsIds') === undefined) {
              this.listenToOnce(this.model, 'sync', () => {
                if (this.model.getLinkMultipleIdList('attachments').length) {
                  this.showHeaderActionItem('createDocument');
                }
              });
            }
          }
        }
      }
      this.listenTo(this.model, 'change:isImportant change:inTrash change:inArchive change:groupStatusFolder', () => {
        if (!this.isRendered()) {
          return;
        }
        const headerView = this.getHeaderView();
        if (headerView) {
          headerView.reRender();
        }
      });
      this.shortcutKeys['Control+Backspace'] = e => {
        if (_utils.default.isKeyEventInTextInput(e)) {
          return;
        }
        const recordView = /** @type {module:views/email/record/detail} */this.getRecordView();
        if (!this.model.get('isUsers') || this.model.get('inArchive')) {
          return;
        }
        e.preventDefault();
        e.stopPropagation();
        recordView.actionMoveToArchive();
      };
      this.shortcutKeys['Control+Delete'] = e => {
        if (_utils.default.isKeyEventInTextInput(e)) {
          return;
        }
        const recordView = /** @type {module:views/email/record/detail} */this.getRecordView();
        if (!this.model.get('isUsers') || this.model.get('inTrash')) {
          return;
        }
        e.preventDefault();
        e.stopPropagation();
        recordView.actionMoveToTrash();
      };
      this.shortcutKeys['Control+KeyI'] = e => {
        if (_utils.default.isKeyEventInTextInput(e)) {
          return;
        }
        const recordView = /** @type {module:views/email/record/detail} */this.getRecordView();
        if (!this.model.get('isUsers')) {
          return;
        }
        e.preventDefault();
        e.stopPropagation();
        this.model.get('isImportant') ? recordView.actionMarkAsNotImportant() : recordView.actionMarkAsImportant();
      };
      this.shortcutKeys['Control+KeyM'] = e => {
        if (_utils.default.isKeyEventInTextInput(e)) {
          return;
        }
        const recordView = /** @type {module:views/email/record/detail} */this.getRecordView();
        if (!this.model.get('isUsers')) {
          return;
        }
        e.preventDefault();
        e.stopPropagation();
        recordView.actionMoveToFolder();
      };
    }

    // noinspection JSUnusedGlobalSymbols
    async actionCreateLead() {
      const attributes = {};
      const emailHelper = new _emailHelper.default();
      const fromString = this.model.get('fromString') || this.model.get('fromName');
      if (fromString) {
        const fromName = emailHelper.parseNameFromStringAddress(fromString);
        if (fromName) {
          const firstName = fromName.split(' ').slice(0, -1).join(' ');
          const lastName = fromName.split(' ').slice(-1).join(' ');
          attributes.firstName = firstName;
          attributes.lastName = lastName;
        }
      }
      if (this.model.get('replyToString')) {
        const str = this.model.get('replyToString');
        const p = str.split(';')[0];
        attributes.emailAddress = emailHelper.parseAddressFromStringAddress(p);
        const fromName = emailHelper.parseNameFromStringAddress(p);
        if (fromName) {
          const firstName = fromName.split(' ').slice(0, -1).join(' ');
          const lastName = fromName.split(' ').slice(-1).join(' ');
          attributes.firstName = firstName;
          attributes.lastName = lastName;
        }
      }
      if (!attributes.emailAddress) {
        attributes.emailAddress = this.model.get('from');
      }
      attributes.originalEmailId = this.model.id;
      const helper = new _recordModal.default();
      const modalView = await helper.showCreate(this, {
        entityType: 'Lead',
        attributes: attributes,
        afterSave: () => {
          this.model.fetch();
          this.removeMenuItem('createContact');
          this.removeMenuItem('createLead');
        }
      });
      this.listenTo(modalView, 'before:save', () => {
        if (this.getRecordView().blockUpdateWebSocket) {
          this.getRecordView().blockUpdateWebSocket(true);
        }
      });
    }

    // noinspection JSUnusedGlobalSymbols
    async actionCreateCase() {
      const attributes = {};
      const parentId = this.model.get('parentId');
      const parentType = this.model.get('parentType');
      const parentName = this.model.get('parentName');
      const accountId = this.model.get('accountId');
      const accountName = this.model.get('accountName');
      if (parentId) {
        if (parentType === 'Account') {
          attributes.accountId = parentId;
          attributes.accountName = parentName;
        } else if (parentType === 'Contact') {
          attributes.contactId = parentId;
          attributes.contactName = parentName;
          attributes.contactsIds = [parentId];
          attributes.contactsNames = {};
          attributes.contactsNames[parentId] = parentName;
          if (accountId) {
            attributes.accountId = accountId;
            attributes.accountName = accountName || accountId;
          }
        } else if (parentType === 'Lead') {
          attributes.leadId = parentId;
          attributes.leadName = parentName;
        }
      }
      attributes.originalEmailId = this.model.id;
      attributes.name = this.model.get('name');
      attributes.description = this.model.get('bodyPlain') || '';
      const attachmentIds = this.model.get('attachmentsIds') || [];
      Espo.Ui.notifyWait();
      if (attachmentIds.length) {
        /** @type {Record} data */
        const data = await Espo.Ajax.postRequest(`Email/${this.model.id}/attachments/copy`, {
          parentType: 'Case',
          field: 'attachments'
        });
        attributes.attachmentsIds = data.ids;
        attributes.attachmentsNames = data.names;
      }
      const helper = new _recordModal.default();
      const modalView = await helper.showCreate(this, {
        entityType: 'Case',
        attributes: attributes,
        afterSave: () => {
          this.model.fetch();
          this.removeMenuItem('createCase');
        }
      });
      this.listenTo(modalView, 'before:save', () => this.getRecordView().blockUpdateWebSocket(true));
    }

    // noinspection JSUnusedGlobalSymbols
    actionCreateTask() {
      const attributes = {};
      attributes.parentId = this.model.get('parentId');
      attributes.parentName = this.model.get('parentName');
      attributes.parentType = this.model.get('parentType');
      attributes.originalEmailId = this.model.id;
      const subject = this.model.attributes.name;
      attributes.description = `[${this.translate('Email', 'scopeNames')}: ${subject}](#Email/view/${this.model.id})\n`;
      const fullFormUrl = `#Task/create?emailId=${attributes.originalEmailId}`;
      const helper = new _recordModal.default();
      helper.showCreate(this, {
        entityType: 'Task',
        attributes: attributes,
        fullFormUrl: fullFormUrl,
        afterSave: () => {
          this.model.fetch();
        },
        beforeRender: view => {
          const nameFieldView = view.getRecordView().getFieldView('name');
          const nameOptionList = [];
          if (nameFieldView && nameFieldView.params.options) {
            nameOptionList.push(...nameFieldView.params.options);
          }
          nameOptionList.push(this.translate('replyToEmail', 'nameOptions', 'Task'));
          view.getRecordView().setFieldOptionList('name', nameOptionList);
        }
      });
    }

    // noinspection JSUnusedGlobalSymbols
    async actionCreateContact() {
      const attributes = {};
      const emailHelper = new _emailHelper.default();
      const fromString = this.model.get('fromString') || this.model.get('fromName');
      if (fromString) {
        const fromName = emailHelper.parseNameFromStringAddress(fromString);
        if (fromName) {
          const firstName = fromName.split(' ').slice(0, -1).join(' ');
          const lastName = fromName.split(' ').slice(-1).join(' ');
          attributes.firstName = firstName;
          attributes.lastName = lastName;
        }
      }
      if (this.model.get('replyToString')) {
        const str = this.model.get('replyToString');
        const p = str.split(';')[0];
        attributes.emailAddress = emailHelper.parseAddressFromStringAddress(p);
        const fromName = emailHelper.parseNameFromStringAddress(p);
        if (fromName) {
          const firstName = fromName.split(' ').slice(0, -1).join(' ');
          const lastName = fromName.split(' ').slice(-1).join(' ');
          attributes.firstName = firstName;
          attributes.lastName = lastName;
        }
      }
      if (!attributes.emailAddress) {
        attributes.emailAddress = this.model.get('from');
      }
      attributes.originalEmailId = this.model.id;
      const helper = new _recordModal.default();
      const modalView = await helper.showCreate(this, {
        entityType: 'Contact',
        attributes: attributes,
        afterSave: () => {
          this.model.fetch();
          this.removeMenuItem('createContact');
          this.removeMenuItem('createLead');
        }
      });
      this.listenTo(modalView, 'before:save', () => {
        this.getRecordView().blockUpdateWebSocket(true);
      });
    }

    /**
     * @private
     * @param {boolean} cc
     */
    async actionInternalReply() {
      let cc = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
      const emailHelper = new _emailHelper.default();
      const attributes = emailHelper.getReplyAttributes(this.model, cc);
      _ui.default.notifyWait();
      const viewName = this.getMetadata().get('clientDefs.Email.modalViews.compose') || 'views/modals/compose-email';
      const view = await this.createView('quickCreate', viewName, {
        attributes: attributes,
        focusForCreate: true
      });
      this.listenTo(view, 'after:save', () => {
        this.model.fetch();
      });
      await view.render();
      _ui.default.notify();
    }

    // noinspection JSUnusedGlobalSymbols
    actionReply() {
      this.actionInternalReply();
    }

    // noinspection JSUnusedGlobalSymbols
    actionReplyToAll() {
      this.actionInternalReply(true);
    }

    // noinspection JSUnusedGlobalSymbols
    actionForward() {
      const emailHelper = new _emailHelper.default();
      Espo.Ui.notifyWait();
      Espo.Ajax.postRequest('Email/action/getDuplicateAttributes', {
        id: this.model.id
      }).then(duplicateAttributes => {
        const model = this.model.clone();
        model.set('body', duplicateAttributes.body);
        const attributes = emailHelper.getForwardAttributes(model);
        attributes.attachmentsIds = duplicateAttributes.attachmentsIds;
        attributes.attachmentsNames = duplicateAttributes.attachmentsNames;
        Espo.Ui.notifyWait();
        const viewName = this.getMetadata().get('clientDefs.Email.modalViews.compose') || 'views/modals/compose-email';
        this.createView('quickCreate', viewName, {
          attributes: attributes
        }, view => {
          view.render();
          view.notify(false);
        });
      });
    }
    getHeader() {
      const name = this.model.attributes.name;
      const isImportant = this.model.attributes.isImportant;
      const inTrash = this.model.attributes.groupFolderId ? this.model.attributes.groupStatusFolder === 'Trash' : this.model.attributes.inTrash;
      const inArchive = this.model.attributes.groupFolderId ? this.model.attributes.groupStatusFolder === 'Archive' : this.model.attributes.inArchive;
      const scopeLabel = this.getLanguage().translate(this.scope, 'scopeNamesPlural');
      let root = document.createElement('span');
      root.text = scopeLabel;
      root.style.userSelect = 'none';
      if (!this.rootLinkDisabled) {
        const a = document.createElement('a');
        a.href = this.rootUrl;
        a.classList.add('action');
        a.dataset.action = 'navigateToRoot';
        a.text = scopeLabel;
        root = document.createElement('span');
        root.style.userSelect = 'none';
        root.append(a);
      }
      const iconHtml = this.getHeaderIconHtml();
      if (iconHtml) {
        root.insertAdjacentHTML('afterbegin', iconHtml);
      }
      let styleClass = null;
      if (isImportant) {
        styleClass = 'text-warning';
      } else if (inTrash) {
        styleClass = 'text-muted';
      } else if (inArchive) {
        styleClass = 'text-info';
      }
      const title = document.createElement('span');
      title.classList.add('font-size-flexible', 'title');
      title.textContent = name;
      if (styleClass) {
        title.classList.add(styleClass);
      }
      if (this.getRecordMode() === 'detail') {
        title.title = this.translate('clickToRefresh', 'messages');
        title.dataset.action = 'fullRefresh';
        title.style.cursor = 'pointer';
      }
      return this.buildHeaderHtml([root, title]);
    }
    actionNavigateToRoot(data, event) {
      event.stopPropagation();
      this.getRouter().checkConfirmLeaveOut(() => {
        const rootUrl = this.options.rootUrl || this.options.params.rootUrl || '#' + this.scope;
        const options = {
          isReturn: true,
          isReturnThroughLink: true
        };
        this.getRouter().navigate(rootUrl, {
          trigger: false
        });
        this.getRouter().dispatch(this.scope, null, options);
      });
    }

    // noinspection JSUnusedGlobalSymbols
    actionCreateDocument() {
      const attachmentIdList = this.model.getLinkMultipleIdList('attachments');
      if (!attachmentIdList.length) {
        return;
      }
      const names = this.model.get('attachmentsNames') || {};
      const types = this.model.get('attachmentsTypes') || {};
      const proceed = async id => {
        const attributes = {};
        if (this.model.get('accountId')) {
          attributes.accountsIds = [this.model.get('accountId')];
          attributes.accountsNames = {};
          attributes.accountsNames[this.model.get('accountId')] = this.model.get('accountName');
        }
        Espo.Ui.notifyWait();
        const attachment = await Espo.Ajax.postRequest(`Attachment/copy/${id}`, {
          relatedType: 'Document',
          field: 'file'
        });
        attributes.fileId = attachment.id;
        attributes.fileName = attachment.name;
        attributes.name = attachment.name;
        const helper = new _recordModal.default();
        await helper.showCreate(this, {
          entityType: 'Document',
          attributes: attributes
        });
      };
      if (attachmentIdList.length === 1) {
        proceed(attachmentIdList[0]);
        return;
      }
      const dataList = [];
      attachmentIdList.forEach(id => {
        dataList.push({
          id: id,
          name: names[id] || id,
          type: types[id]
        });
      });
      const modalView = new _selectOne.default({
        dataList: dataList,
        fieldLabel: this.translate('attachments', 'fields', 'Email'),
        onSelect: id => proceed(id)
      });
      this.assignView('selectModal', modalView);
      modalView.render();
    }
  }
  var _default = _exports.default = EmailDetailView;
});

define("views/email/record/list-related", ["exports", "views/record/list"], function (_exports, _list) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _list = _interopRequireDefault(_list);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _list.default {
    massActionList = ['remove', 'massUpdate'];
  }
  _exports.default = _default;
});

define("views/email/record/list-expanded", ["exports", "views/record/list-expanded", "views/email/record/list"], function (_exports, _listExpanded, _list) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _listExpanded = _interopRequireDefault(_listExpanded);
  _list = _interopRequireDefault(_list);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _listExpanded.default {
    // noinspection JSUnusedGlobalSymbols
    actionMarkAsImportant(data) {
      _list.default.prototype.actionMarkAsImportant.call(this, data);
    }

    // noinspection JSUnusedGlobalSymbols
    actionMarkAsNotImportant(data) {
      _list.default.prototype.actionMarkAsNotImportant.call(this, data);
    }

    // noinspection JSUnusedGlobalSymbols
    actionMoveToTrash(data) {
      _list.default.prototype.actionMoveToTrash.call(this, data);
    }
  }
  _exports.default = _default;
});

define("views/email/record/edit-quick", ["exports", "views/email/record/edit"], function (_exports, _edit) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _edit = _interopRequireDefault(_edit);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _edit.default {
    isWide = true;
    sideView = false;
  }
  _exports.default = _default;
});

define("views/email/record/detail-side", ["exports", "views/record/detail-side"], function (_exports, _detailSide) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _detailSide = _interopRequireDefault(_detailSide);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _detailSide.default {}
  _exports.default = _default;
});

define("views/email/record/detail-quick", ["exports", "views/email/record/detail"], function (_exports, _detail) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _detail = _interopRequireDefault(_detail);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _detail.default {
    isWide = true;
    sideView = false;
  }
  _exports.default = _default;
});

define("views/email/record/compose", ["exports", "views/record/edit", "views/email/record/detail"], function (_exports, _edit, _detail) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _edit = _interopRequireDefault(_edit);
  _detail = _interopRequireDefault(_detail);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module views/email/record/compose */

  class EmailComposeRecordView extends _edit.default {
    isWide = true;
    sideView = false;

    /**
     * @private
     * @type {string|null}
     */
    initialBody;

    /**
     * @private
     * @type {boolean|null}
     */
    initialIsHtml;
    setupBeforeFinal() {
      super.setupBeforeFinal();
      this.initialBody = this.model.attributes.body;
      this.initialIsHtml = this.model.attributes.isHtml;
      if (!this.model.attributes.isHtml && this.getPreferences().get('emailReplyForceHtml')) {
        this.initialBody = (this.initialBody || '').replace(/\n/g, '<br>') || null;
        this.initialIsHtml = true;
      }
      let body = this.initialBody;
      if (!this.options.signatureDisabled && this.hasSignature()) {
        let addSignatureMethod = 'prependSignature';
        if (this.options.appendSignature) {
          addSignatureMethod = 'appendSignature';
        }
        body = this[addSignatureMethod](body || '', this.initialIsHtml) || null;
      }
      this.model.set('body', body, {
        silent: true
      });
      this.model.set('isHtml', this.initialIsHtml, {
        silent: true
      });
    }
    setup() {
      super.setup();
      this.isBodyChanged = false;
      this.listenTo(this.model, 'change:body', () => {
        this.isBodyChanged = true;
      });
      if (!this.options.removeAttachmentsOnSelectTemplate) {
        this.initialAttachmentsIds = this.model.get('attachmentsIds') || [];
        this.initialAttachmentsNames = this.model.get('attachmentsNames') || {};
      }
      this.initInsertTemplate();
      if (this.options.selectTemplateDisabled) {
        this.hideField('selectTemplate');
      }
    }
    initInsertTemplate() {
      this.listenTo(this.model, 'insert-template', data => {
        const body = this.model.get('body') || '';
        let bodyPlain = body.replace(/<br\s*\/?>/mg, '');
        bodyPlain = bodyPlain.replace(/<\/p\s*\/?>/mg, '');
        bodyPlain = bodyPlain.replace(/ /g, '');
        bodyPlain = bodyPlain.replace(/\n/g, '');
        const $div = $('<div>').html(bodyPlain);
        bodyPlain = $div.text();
        if (bodyPlain !== '' && this.isBodyChanged) {
          this.confirm({
            message: this.translate('confirmInsertTemplate', 'messages', 'Email'),
            confirmText: this.translate('Yes')
          }).then(() => this.insertTemplate(data));
          return;
        }
        this.insertTemplate(data);
      });
    }

    /**
     * @param {{
     *     body: string | null,
     *     isHtml: boolean,
     *     subject?: string | null,
     *     attachmentsIds?: string[],
     *     attachmentsNames?: Record<string, string>,
     * }} data
     */
    insertTemplate(data) {
      var _data$attachmentsIds, _this$model$attribute;
      let body = data.body;
      if (this.hasSignature()) {
        body = this.appendSignature(body || '', data.isHtml);
      }
      if (this.initialBody && !this.isBodyChanged) {
        let initialBody = this.initialBody;
        if (data.isHtml !== this.initialIsHtml) {
          if (data.isHtml) {
            initialBody = this.plainToHtml(initialBody);
          } else {
            initialBody = this.htmlToPlain(initialBody);
          }
        }
        body += initialBody;
      }

      // @todo Revise.
      this.model.set('body', '');
      const attributes = {
        isHtml: data.isHtml,
        body: body
      };
      if (data.subject) {
        attributes.name = data.subject;
      }
      if (!this.options.removeAttachmentsOnSelectTemplate) {
        this.initialAttachmentsIds.forEach(id => {
          if (data.attachmentsIds) {
            data.attachmentsIds.push(id);
          }
          if (data.attachmentsNames) {
            data.attachmentsNames[id] = this.initialAttachmentsNames[id] || id;
          }
        });
      }

      // Prevents highlight.
      const skipAttachments = !((_data$attachmentsIds = data.attachmentsIds) !== null && _data$attachmentsIds !== void 0 && _data$attachmentsIds.length) && !((_this$model$attribute = this.model.attributes.attachmentsIds) !== null && _this$model$attribute !== void 0 && _this$model$attribute.length);
      if (!skipAttachments) {
        attributes.attachmentsIds = data.attachmentsIds;
        attributes.attachmentsNames = data.attachmentsNames;
      }
      this.model.setMultiple(attributes, {
        highlight: true
      });
      this.isBodyChanged = false;
    }
    prependSignature(body, isHtml) {
      if (isHtml) {
        let signature = this.getSignature();
        if (body) {
          signature += '';
        }
        return '<p><br></p>' + signature + body;
      }
      let signature = this.getPlainTextSignature();
      if (body) {
        signature += '\n';
      }
      return '\n\n' + signature + body;
    }
    appendSignature(body, isHtml) {
      if (isHtml) {
        const signature = this.getSignature();
        return body + '' + signature;
      }
      const signature = this.getPlainTextSignature();
      return body + '\n\n' + signature;
    }
    hasSignature() {
      return !!this.getPreferences().get('signature');
    }
    getSignature() {
      return this.getPreferences().get('signature') || '';
    }
    getPlainTextSignature() {
      let value = this.getSignature().replace(/<br\s*\/?>/mg, '\n');
      value = $('<div>').html(value).text();
      return value;
    }
    afterSave() {
      super.afterSave();
      if (this.isSending && this.model.get('status') === 'Sent') {
        Espo.Ui.success(this.translate('emailSent', 'messages', 'Email'));
      }
    }
    send() {
      _detail.default.prototype.send.call(this);
    }

    /**
     * @param {module:views/record/base~saveOptions} [options] Options.
     * @return {Promise}
     */
    saveDraft(options) {
      const model = this.model;
      model.set('status', 'Draft');
      const subjectView = this.getFieldView('subject');
      if (subjectView) {
        subjectView.fetchToModel();
        if (!model.get('name')) {
          model.set('name', this.translate('No Subject', 'labels', 'Email'));
        }
      }
      return this.save(options);
    }
    htmlToPlain(text) {
      text = text || '';
      let value = text.replace(/<br\s*\/?>/mg, '\n');
      value = value.replace(/<\/p\s*\/?>/mg, '\n\n');
      const $div = $('<div>').html(value);
      $div.find('style').remove();
      $div.find('link[ref="stylesheet"]').remove();
      value = $div.text();
      return value;
    }
    plainToHtml(html) {
      html = html || '';
      return html.replace(/\n/g, '<br>');
    }

    // noinspection JSUnusedGlobalSymbols
    errorHandlerSendingFail(data) {
      _detail.default.prototype.errorHandlerSendingFail.call(this, data);
    }
    focusForCreate() {
      if (!this.model.get('to')) {
        this.$el.find('.field[data-name="to"] input').focus();
        return;
      }
      if (!this.model.get('subject')) {
        this.$el.find('.field[data-name="subject"] input').focus();
        return;
      }
      if (this.model.get('isHtml')) {
        const $div = this.$el.find('.field[data-name="body"] .note-editable');
        if (!$div.length) {
          return;
        }
        $div.focus();
        return;
      }
      this.$el.find('.field[data-name="body"] textarea').prop('selectionEnd', 0).focus();
    }
  }
  var _default = _exports.default = EmailComposeRecordView;
});

define("views/email/record/row-actions/default", ["exports", "views/record/row-actions/default"], function (_exports, _default2) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _default2 = _interopRequireDefault(_default2);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EmailDefaultRowActionView extends _default2.default {
    setup() {
      super.setup();
      this.listenTo(this.model, 'change:isImportant change:inTrash change:groupStatusFolder', () => {
        setTimeout(() => this.reRender(), 10);
      });
    }
    getActionList() {
      /** @type {import('views/record/list').RowAction[]} */
      let list = [{
        action: 'quickView',
        label: 'View',
        data: {
          id: this.model.id
        },
        groupIndex: 0,
        iconClass: _default2.default.ICON_CLASS_VIEW
      }];
      if (this.model.get('createdById') === this.getUser().id && this.model.get('status') === 'Draft' && !this.model.attributes.inTrash) {
        list.push({
          action: 'send',
          label: 'Send',
          data: {
            id: this.model.id
          },
          iconClass: 'far fa-paper-plane'
        });
      }
      if (this.options.acl.edit) {
        list = list.concat([{
          action: 'quickEdit',
          label: 'Edit',
          data: {
            id: this.model.id
          },
          groupIndex: 0,
          iconClass: _default2.default.ICON_CLASS_EDIT
        }]);
      }
      if (this.model.get('isUsers')) {
        if (!this.model.get('isImportant')) {
          if (!this.model.get('inTrash')) {
            list.push({
              action: 'markAsImportant',
              label: 'Mark as Important',
              data: {
                id: this.model.id
              },
              groupIndex: 1,
              iconClass: 'far fa-star'
            });
          }
        } else {
          list.push({
            action: 'markAsNotImportant',
            label: 'Unmark Importance',
            data: {
              id: this.model.id
            },
            groupIndex: 1
          });
        }
      }
      if (this.model.attributes.isUsers && !this.model.attributes.isRead) {
        list.push({
          action: 'markAsRead',
          label: 'Mark Read',
          data: {
            id: this.model.id
          },
          groupIndex: 1
        });
      }
      if (this.model.attributes.isUsers && this.model.attributes.status !== 'Draft' || this.model.attributes.groupFolderId) {
        const inTrash = this.model.attributes.groupFolderId ? this.model.attributes.groupStatusFolder === 'Trash' : this.model.attributes.inTrash;
        const inArchive = this.model.attributes.groupFolderId ? this.model.attributes.groupStatusFolder === 'Archive' : this.model.attributes.inArchive;
        if (!inTrash) {
          list.push({
            action: 'moveToTrash',
            label: 'Move to Trash',
            data: {
              id: this.model.id
            },
            groupIndex: 2,
            iconClass: 'far fa-trash-alt'
          });
        } else {
          list.push({
            action: 'retrieveFromTrash',
            label: 'Retrieve from Trash',
            data: {
              id: this.model.id
            },
            groupIndex: 2
          });
        }
        if (!inArchive) {
          list.push({
            action: 'moveToArchive',
            text: this.getLanguage().translatePath('Email.actions.moveToArchive'),
            data: {
              id: this.model.id
            },
            groupIndex: 2,
            iconClass: 'far fa-caret-square-down'
          });
        }
        list.push({
          action: 'moveToFolder',
          label: 'Move to Folder',
          data: {
            id: this.model.id
          },
          groupIndex: 2,
          iconClass: 'far fa-folder'
        });
      } else if (!this.model.attributes.isUsers && !this.model.attributes.groupFolderId && this.model.attributes.status === 'Archived') {
        list.push({
          action: 'moveToFolder',
          label: 'Move to Folder',
          data: {
            id: this.model.id
          },
          groupIndex: 2,
          iconClass: 'far fa-folder'
        });
      }
      if (this.options.acl.delete) {
        list.push({
          action: 'quickRemove',
          label: 'Remove',
          data: {
            id: this.model.id
          },
          groupIndex: 0,
          iconClass: _default2.default.ICON_CLASS_REMOVE
        });
      }
      return list;
    }
  }
  var _default = _exports.default = EmailDefaultRowActionView;
});

define("views/email/record/row-actions/dashlet", ["exports", "views/record/row-actions/default"], function (_exports, _default2) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _default2 = _interopRequireDefault(_default2);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _default2.default {
    setup() {
      super.setup();
      this.listenTo(this.model, 'change:isImportant', () => {
        setTimeout(() => this.reRender(), 10);
      });
    }
    getActionList() {
      let list = [{
        action: 'quickView',
        label: 'View',
        data: {
          id: this.model.id
        },
        groupIndex: 0,
        iconClass: _default2.default.ICON_CLASS_VIEW
      }];
      if (this.options.acl.edit) {
        list = list.concat([{
          action: 'quickEdit',
          label: 'Edit',
          data: {
            id: this.model.id
          },
          groupIndex: 0,
          iconClass: _default2.default.ICON_CLASS_EDIT
        }]);
      }
      if (this.model.get('isUsers') && this.model.get('status') !== 'Draft') {
        if (!this.model.get('inTrash')) {
          list.push({
            action: 'moveToTrash',
            label: 'Move to Trash',
            data: {
              id: this.model.id
            },
            groupIndex: 1,
            iconClass: 'far fa-trash-alt'
          });
        } else {
          list.push({
            action: 'retrieveFromTrash',
            label: 'Retrieve from Trash',
            data: {
              id: this.model.id
            },
            groupIndex: 1
          });
        }
      }
      if (this.getAcl().checkModel(this.model, 'delete')) {
        list.push({
          action: 'quickRemove',
          label: 'Remove',
          data: {
            id: this.model.id
          },
          groupIndex: 0,
          iconClass: _default2.default.ICON_CLASS_REMOVE
        });
      }
      if (this.model.get('isUsers')) {
        if (!this.model.get('isImportant')) {
          list.push({
            action: 'markAsImportant',
            label: 'Mark as Important',
            data: {
              id: this.model.id
            },
            groupIndex: 1,
            iconClass: 'far fa-star'
          });
        } else {
          list.push({
            action: 'markAsNotImportant',
            label: 'Unmark Importance',
            data: {
              id: this.model.id
            },
            groupIndex: 1
          });
        }
      }
      return list;
    }
  }
  _exports.default = _default;
});

define("views/email/record/panels/event", ["exports", "views/record/panels/side"], function (_exports, _side) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _side = _interopRequireDefault(_side);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _side.default {
    setupFields() {
      super.setupFields();
      this.fieldList.push({
        name: 'icsEventDateStart',
        readOnly: true,
        labelText: this.translate('dateStart', 'fields', 'Meeting')
      });
      this.fieldList.push({
        name: 'createdEvent',
        readOnly: true
      });
      this.fieldList.push({
        name: 'createEvent',
        readOnly: true,
        noLabel: true
      });
      this.controlEventField();
      this.listenTo(this.model, 'change:icsEventData', this.controlEventField, this);
      this.listenTo(this.model, 'change:createdEventId', this.controlEventField, this);
    }

    /**
     * @private
     */
    controlEventField() {
      if (!this.model.get('icsEventData')) {
        this.recordViewObject.hideField('createEvent');
        this.recordViewObject.showField('createdEvent');
        return;
      }
      const eventData = this.model.get('icsEventData');
      if (eventData.createdEvent) {
        this.recordViewObject.hideField('createEvent');
        this.recordViewObject.showField('createdEvent');
        return;
      }
      if (!this.model.get('createdEventId')) {
        this.recordViewObject.hideField('createdEvent');
        this.recordViewObject.showField('createEvent');
        return;
      }
      this.recordViewObject.hideField('createEvent');
      this.recordViewObject.showField('createdEvent');
    }
  }
  _exports.default = _default;
});

define("views/email/record/panels/default-side", ["exports", "views/record/panels/default-side"], function (_exports, _defaultSide) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _defaultSide = _interopRequireDefault(_defaultSide);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _defaultSide.default {
    setupFields() {
      super.setupFields();
      this.fieldList.push({
        name: 'isAutoReply'
      });
      this.fieldList.push({
        name: 'hasAttachment',
        view: 'views/email/fields/has-attachment',
        noLabel: true
      });
      this.controlHasAttachmentField();
      this.listenTo(this.model, 'change:hasAttachment', () => this.controlHasAttachmentField());
      this.controlIsAutoReply();
      this.listenTo(this.model, 'change:isAutoReply', () => this.controlIsAutoReply());
    }

    /**
     * @private
     */
    controlHasAttachmentField() {
      if (this.model.attributes.hasAttachment) {
        this.recordViewObject.showField('hasAttachment');
        return;
      }
      this.recordViewObject.hideField('hasAttachment');
    }

    /**
     * @private
     */
    controlIsAutoReply() {
      if (this.model.attributes.isAutoReply) {
        this.recordViewObject.showField('isAutoReply');
        return;
      }
      this.recordViewObject.hideField('isAutoReply');
    }
  }
  _exports.default = _default;
});

define("views/email/modals/insert-field", ["exports", "views/modal", "helpers/misc/field-language"], function (_exports, _modal, _fieldLanguage) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  _fieldLanguage = _interopRequireDefault(_fieldLanguage);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _modal.default {
    backdrop = true;

    // language=Handlebars
    templateContent = `
        {{#each viewObject.dataList}}
            <div class="margin-bottom">
            <h5>{{label}}: {{translate entityType category='scopeNames'}}</h5>
            </div>
            <ul class="list-group no-side-margin">
                {{#each dataList}}
                    <li class="list-group-item clearfix">
                        <a role="button"
                            data-action="insert" class="text-bold" data-name="{{name}}" data-type="{{../type}}">
                            {{label}}
                        </a>

                        <div class="pull-right"
                            style="width: 50%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;">
                            {{valuePreview}}
                        </div>
                    </li>
                {{/each}}
            </ul>
        {{/each}}

        {{#unless viewObject.dataList.length}}
            {{translate 'No Data'}}
        {{/unless}}
    `;
    setup() {
      super.setup();
      this.headerText = this.translate('Insert Field', 'labels', 'Email');
      this.fieldLanguage = new _fieldLanguage.default(this.getMetadata(), this.getLanguage());
      this.wait(Espo.Ajax.getRequest('Email/insertFieldData', {
        parentId: this.options.parentId,
        parentType: this.options.parentType,
        to: this.options.to
      }).then(fetchedData => {
        this.fetchedData = fetchedData;
        this.prepareData();
      }));
      this.addActionHandler('insert', (e, target) => {
        const name = target.dataset.name;
        const type = target.dataset.type;
        this.insert(type, name);
      });
    }
    prepareData() {
      this.dataList = [];
      const fetchedData = this.fetchedData;
      const typeList = ['parent', 'to'];
      typeList.forEach(type => {
        if (!fetchedData[type]) {
          return;
        }
        const entityType = fetchedData[type].entityType;
        const id = fetchedData[type].id;
        for (const it of this.dataList) {
          if (it.id === id && it.entityType === entityType) {
            return;
          }
        }
        const dataList = this.prepareDisplayValueList(fetchedData[type].entityType, fetchedData[type].values);
        if (!dataList.length) {
          return;
        }
        this.dataList.push({
          type: type,
          entityType: entityType,
          id: id,
          name: fetchedData[type].name,
          dataList: dataList,
          label: this.translate(type, 'fields', 'Email')
        });
      });
    }
    prepareDisplayValueList(scope, values) {
      const list = [];
      let attributeList = Object.keys(values);
      const labels = {};
      attributeList.forEach(item => {
        labels[item] = this.fieldLanguage.translateAttribute(scope, item);
      });
      attributeList = attributeList.sort((v1, v2) => {
        return labels[v1].localeCompare(labels[v2]);
      });
      const ignoreAttributeList = ['id', 'modifiedAt', 'modifiedByName'];
      const fm = this.getFieldManager();
      fm.getEntityTypeFieldList(scope).forEach(field => {
        const type = this.getMetadata().get(['entityDefs', scope, 'fields', field, 'type']);
        if (['link', 'linkOne', 'image', 'filed', 'linkParent'].includes(type)) {
          ignoreAttributeList.push(field + 'Id');
        }
        if (type === 'linkParent') {
          ignoreAttributeList.push(field + 'Type');
        }
      });
      attributeList.forEach(item => {
        if (~ignoreAttributeList.indexOf(item)) {
          return;
        }
        let value = values[item];
        if (value === null || value === '') {
          return;
        }
        if (typeof value == 'boolean') {
          return;
        }
        if (Array.isArray(value)) {
          for (const v in value) {
            if (typeof v !== 'string') {
              return;
            }
          }
          value = value.split(', ');
        }
        value = this.getHelper().sanitizeHtml(value);
        const valuePreview = value.replace(/<br( \/)?>/gm, ' ');

        // noinspection RegExpUnnecessaryNonCapturingGroup
        value = value.replace(/(?:\r\n|\r|\n)/g, '');
        value = value.replace(/<br( \/)?>/gm, '\n');
        list.push({
          name: item,
          label: labels[item],
          value: value,
          valuePreview: valuePreview
        });
      });
      return list;
    }

    /**
     * @private
     * @param {string} type
     * @param {string} name
     */
    insert(type, name) {
      for (const g of this.dataList) {
        if (g.type !== type) {
          continue;
        }
        for (const i of g.dataList) {
          if (i.name !== name) {
            continue;
          }
          this.trigger('insert', i.value);
          break;
        }
        break;
      }
      this.close();
    }
  }
  _exports.default = _default;
});

define("views/email/modals/detail", ["exports", "views/modals/detail", "email-helper", "multi-collection", "ui"], function (_exports, _detail, _emailHelper, _multiCollection, _ui) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _detail = _interopRequireDefault(_detail);
  _emailHelper = _interopRequireDefault(_emailHelper);
  _multiCollection = _interopRequireDefault(_multiCollection);
  _ui = _interopRequireDefault(_ui);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EmailDetailModalView extends _detail.default {
    setup() {
      super.setup();
      this.addButton({
        name: 'reply',
        label: 'Reply',
        hidden: this.model && this.model.get('status') === 'Draft',
        style: 'danger',
        position: 'right'
      }, true);
      if (this.model) {
        this.listenToOnce(this.model, 'sync', () => {
          setTimeout(() => {
            this.model.set('isRead', true);
          }, 50);
        });
      }
    }
    controlRecordButtonsVisibility() {
      super.controlRecordButtonsVisibility();
      if (this.model.get('status') === 'Draft' || !this.getAcl().check('Email', 'create')) {
        this.hideActionItem('reply');
        return;
      }
      this.showActionItem('reply');
    }

    // noinspection JSUnusedGlobalSymbols
    async actionReply() {
      const replyByDefault = this.getPreferences().get('emailReplyToAllByDefault');
      const emailHelper = new _emailHelper.default();
      const attributes = emailHelper.getReplyAttributes(this.model, replyByDefault);
      _ui.default.notifyWait();
      const viewName = this.getMetadata().get('clientDefs.Email.modalViews.compose') || 'views/modals/compose-email';
      const view = await this.createView('quickCreate', viewName, {
        attributes: attributes,
        focusForCreate: true
      });
      this.listenTo(view, 'after:save', () => {
        this.model.fetch();
      });
      await view.render();
      _ui.default.notify();
      this.listenToOnce(view, 'after:send', () => {
        var _this$sourceModel;
        if (!(((_this$sourceModel = this.sourceModel) === null || _this$sourceModel === void 0 ? void 0 : _this$sourceModel.collection) instanceof _multiCollection.default)) {
          return;
        }

        // Fetch history.
        this.sourceModel.collection.fetch();
      });
    }
  }
  _exports.default = EmailDetailModalView;
});

define("views/email/modals/body-plain", ["exports", "views/modal"], function (_exports, _modal) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _modal.default {
    backdrop = true;
    templateContent = `
        <div class="panel no-side-margin">
            <div class="panel-body">
                <div class="field" data-name="body-plain">{{{bodyPlain}}}</div>
            </div>

        </div>
    `;
    setup() {
      super.setup();
      this.buttonList.push({
        'name': 'cancel',
        'label': 'Close'
      });
      this.headerText = this.model.get('name');
      this.createView('bodyPlain', 'views/fields/text', {
        selector: '.field[data-name="bodyPlain"]',
        model: this.model,
        defs: {
          name: 'bodyPlain',
          params: {
            readOnly: true,
            inlineEditDisabled: true,
            displayRawText: true
          }
        }
      });
    }
  }
  _exports.default = _default;
});

define("views/email/modals/attachments", ["exports", "views/modal"], function (_exports, _modal) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _modal.default {
    backdrop = true;
    templateContent = `<div class="record no-side-margin">{{{record}}}</div>`;
    setup() {
      super.setup();
      this.headerText = this.translate('attachments', 'fields', 'Email');
      this.createView('record', 'views/record/detail', {
        model: this.model,
        selector: '.record',
        readOnly: true,
        sideView: null,
        buttonsDisabled: true,
        detailLayout: [{
          rows: [[{
            name: 'attachments',
            noLabel: true
          }, false]]
        }]
      });
      if (!this.model.has('attachmentsIds')) {
        this.wait(this.model.fetch());
      }
    }
  }
  _exports.default = _default;
});

define("views/email/fields/subject", ["exports", "views/fields/varchar"], function (_exports, _varchar) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _varchar = _interopRequireDefault(_varchar);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EmailSubjectFieldView extends _varchar.default {
    listLinkTemplate = 'email/fields/subject/list-link';
    data() {
      const data = super.data();
      data.isRead = this.model.get('sentById') === this.getUser().id || this.model.get('isRead');
      data.isImportant = this.model.has('isImportant') && this.model.get('isImportant');
      data.hasAttachment = this.model.has('hasAttachment') && this.model.get('hasAttachment');
      data.isReplied = this.model.has('isReplied') && this.model.get('isReplied');
      data.isAutoReply = this.model.has('isAutoReply') && this.model.attributes.isAutoReply;
      data.hasIcon = data.hasAttachment || data.isAutoReply;
      if (data.hasIcon) {
        data.iconCount = 1;
        if (data.hasAttachment && data.isAutoReply) {
          data.iconCount = 2;
        }
      }
      data.inTrash = this.model.attributes.groupFolderId ? this.model.attributes.groupStatusFolder === 'Trash' : this.model.attributes.inTrash;
      data.inArchive = this.model.attributes.groupFolderId ? this.model.attributes.groupStatusFolder === 'Archive' : this.model.attributes.inArchive;
      data.style = null;
      if (data.isImportant) {
        data.style = 'warning';
      } else if (data.inTrash) {
        data.style = 'muted';
      } else if (data.inArchive) {
        data.style = 'info';
      }
      if (!data.isRead && !this.model.has('isRead')) {
        data.isRead = true;
      }
      if (!data.isNotEmpty) {
        if (this.model.get('name') !== null && this.model.get('name') !== '' && this.model.has('name')) {
          data.isNotEmpty = true;
        }
      }
      return data;
    }
    getValueForDisplay() {
      return this.model.get('name');
    }
    getAttributeList() {
      return ['name', 'subject', 'isRead', 'isImportant', 'hasAttachment', 'inTrash', 'groupStatusFolder', 'isAutoReply'];
    }
    setup() {
      super.setup();
      this.events['click [data-action="showAttachments"]'] = e => {
        e.stopPropagation();
        this.showAttachments();
      };
      this.listenTo(this.model, 'change:isRead change:isImportant change:groupStatusFolder', () => {
        if (this.mode === this.MODE_LIST || this.mode === this.MODE_LIST_LINK) {
          this.reRender();
        }
      });
    }
    fetch() {
      const data = super.fetch();
      data.name = data.subject;
      return data;
    }
    showAttachments() {
      Espo.Ui.notifyWait();
      this.createView('dialog', 'views/email/modals/attachments', {
        model: this.model
      }).then(view => {
        view.render();
        Espo.Ui.notify(false);
      });
    }
  }
  var _default = _exports.default = EmailSubjectFieldView;
});

define("views/email/fields/select-template", ["exports", "views/fields/link"], function (_exports, _link) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _link = _interopRequireDefault(_link);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _link.default {
    editTemplate = 'email/fields/select-template/edit';
    foreignScope = 'EmailTemplate';
    setup() {
      super.setup();
      this.on('change', () => {
        const id = this.model.get(this.idName);
        if (id) {
          this.loadTemplate(id);
        }
      });
    }
    getSelectPrimaryFilterName() {
      return 'actual';
    }
    loadTemplate(id) {
      let to = this.model.get('to') || '';
      let emailAddress = null;
      to = to.trim();
      if (to) {
        emailAddress = to.split(';')[0].trim();
      }
      Espo.Ajax.postRequest(`EmailTemplate/${id}/prepare`, {
        emailAddress: emailAddress,
        parentType: this.model.get('parentType'),
        parentId: this.model.get('parentId'),
        relatedType: this.model.get('relatedType'),
        relatedId: this.model.get('relatedId')
      }).then(data => {
        this.model.trigger('insert-template', data);
        this.emptyField();
      }).catch(() => {
        this.emptyField();
      });
    }

    /**
     * @private
     */
    emptyField() {
      this.model.set(this.idName, null);
      this.model.set(this.nameName, null);
    }
  }
  _exports.default = _default;
});

define("views/email/fields/replies", ["exports", "views/fields/link-multiple"], function (_exports, _linkMultiple) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _linkMultiple = _interopRequireDefault(_linkMultiple);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _linkMultiple.default {
    getAttributeList() {
      const attributeList = super.getAttributeList();
      attributeList.push(this.name + 'Columns');
      return attributeList;
    }
    getDetailLinkHtml(id) {
      const html = super.getDetailLinkHtml(id);
      const columns = this.model.get(this.name + 'Columns') || {};
      const status = (columns[id] || {})['status'];
      return $('<div>').append($('<span>').addClass('fas fa-arrow-right fa-sm link-multiple-item-icon').addClass(status === 'Draft' ? 'text-warning' : 'text-success')).append(html).html();
    }
  }
  _exports.default = _default;
});

define("views/email/fields/replied", ["exports", "views/fields/link"], function (_exports, _link) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _link = _interopRequireDefault(_link);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _link.default {
    afterRender() {
      super.afterRender();
      if (this.mode === this.MODE_DETAIL) {
        const $a = this.$el.find('a');
        if ($a.get(0)) {
          $('<span class="fas fa-arrow-left fa-sm link-field-icon text-soft"></span>').insertBefore($a);
        }
      }
    }
  }
  _exports.default = _default;
});

define("views/email/fields/person-string-data-for-expanded", ["exports", "views/email/fields/person-string-data"], function (_exports, _personStringData) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _personStringData = _interopRequireDefault(_personStringData);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  // noinspection JSUnusedGlobalSymbols
  class _default extends _personStringData.default {
    listTemplate = 'email/fields/person-string-data/list-for-expanded';
  }
  _exports.default = _default;
});

define("views/email/fields/icon", ["exports", "views/fields/base"], function (_exports, _base) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _base.default {
    listTemplate = 'email/fields/icon/detail';
    detailTemplate = 'email/fields/icon/detail';
  }
  _exports.default = _default;
});

define("views/email/fields/has-attachment", ["exports", "views/fields/base"], function (_exports, _base) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _base.default {
    listTemplate = 'email/fields/has-attachment/detail';
    detailTemplate = 'email/fields/has-attachment/detail';
    data() {
      const data = super.data();
      data.isSmall = this.mode === this.MODE_LIST;
      return data;
    }
    setup() {
      super.setup();
      this.addActionHandler('show', e => {
        e.stopPropagation();
        this.show();
      });
    }

    /**
     * @private
     */
    show() {
      Espo.Ui.notifyWait();
      this.createView('dialog', 'views/email/modals/attachments', {
        model: this.model
      }).then(view => {
        view.render();
        Espo.Ui.notify(false);
      });
    }
  }
  _exports.default = _default;
});

define("views/email/fields/from-email-address", ["exports", "views/fields/link"], function (_exports, _link) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _link = _interopRequireDefault(_link);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _link.default {
    listTemplate = 'email/fields/from-email-address/detail';
    detailTemplate = 'email/fields/from-email-address/detail';
  }
  _exports.default = _default;
});

define("views/email/fields/folder-string", ["exports", "views/fields/base"], function (_exports, _base) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EmailFolderStringFieldView extends _base.default {
    // language=Handlebars
    detailTemplateContent = `
        {{#if valueIsSet}}
            {{#if value}}
                {{#if isList}}
                    {{#each value}}
                        <div class="multi-enum-item-container">{{this}}</div>
                    {{/each}}
                {{else}}
                    {{value}}
                {{/if}}

            {{else}}
                <span class="none-value">{{translate 'None'}}</span>
            {{/if}}
        {{else}}
            <span class="loading-value"></span>
        {{/if}}
    `;

    // noinspection JSCheckFunctionSignatures
    data() {
      if (!this.model.has('folderId')) {
        return {
          valueIsSet: false
        };
      }
      const value = this.getFolderString();
      return {
        valueIsSet: true,
        value: this.getFolderString(),
        isList: Array.isArray(value)
      };
    }
    getAttributeList() {
      return ['isUsers', 'folderId', 'folderName', 'groupFolderId', 'groupFolderName', 'inArchive', 'inTrash', 'isUsersSent', 'groupStatusFolder'];
    }

    /**
     * @return {string|string[]}
     */
    getFolderString() {
      if (this.model.attributes.groupFolderName) {
        let string = this.translate('group', 'strings', 'Email') + ' · ' + this.model.attributes.groupFolderName;
        if (this.model.attributes.groupStatusFolder === 'Archive') {
          string += ' · ' + this.translate('archive', 'presetFilters', 'Email');
        } else if (this.model.attributes.groupStatusFolder === 'Trash') {
          string += ' · ' + this.translate('trash', 'presetFilters', 'Email');
        }
        if (this.model.attributes.isUsersSent) {
          return [string, this.translate('sent', 'presetFilters', 'Email')];
        }
        return string;
      }
      let string;
      if (this.model.attributes.inTrash) {
        string = this.translate('trash', 'presetFilters', 'Email');
      }
      if (this.model.attributes.inArchive) {
        string = this.translate('archive', 'presetFilters', 'Email');
      }
      if (this.model.attributes.folderName && this.model.attributes.folderId) {
        string = this.model.attributes.folderName;
      }
      if (string && this.model.attributes.isUsersSent) {
        return [string, this.translate('sent', 'presetFilters', 'Email')];
      }
      if (this.model.attributes.isUsersSent) {
        return this.translate('sent', 'presetFilters', 'Email');
      }
      if (this.model.attributes.createdById === this.getUser().id && this.model.attributes.status === 'Draft') {
        return this.translate('drafts', 'presetFilters', 'Email');
      }
      if (string) {
        return string;
      }
      if (this.model.attributes.isUsers) {
        return this.translate('inbox', 'presetFilters', 'Email');
      }
      return undefined;
    }
  }
  var _default = _exports.default = EmailFolderStringFieldView;
});

define("views/email/fields/email-address-varchar", ["exports", "views/fields/base", "views/email/fields/from-address-varchar", "views/email/fields/email-address", "ui/autocomplete"], function (_exports, _base, _fromAddressVarchar, _emailAddress, _autocomplete) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  _fromAddressVarchar = _interopRequireDefault(_fromAddressVarchar);
  _emailAddress = _interopRequireDefault(_emailAddress);
  _autocomplete = _interopRequireDefault(_autocomplete);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EmailAddressVarcharFieldView extends _base.default {
    detailTemplate = 'email/fields/email-address-varchar/detail';
    editTemplate = 'email/fields/email-address-varchar/edit';
    emailAddressRegExp = new RegExp(/^[-!#$%&'*+/=?^_`{|}~A-Za-z0-9]+(?:\.[-!#$%&'*+/=?^_`{|}~A-Za-z0-9]+)*/.source + /@([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])?\.)+[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9]/.source);

    // noinspection JSCheckFunctionSignatures
    data() {
      const data = super.data();
      data.valueIsSet = this.model.has(this.name);
      data.maxLength = 254;
      data.hasSelectAddress = this.hasSelectAddress;

      // noinspection JSValidateTypes
      return data;
    }
    events = {
      /** @this EmailAddressVarcharFieldView */
      'click a[data-action="clearAddress"]': function (e) {
        const address = $(e.currentTarget).data('address').toString();
        this.deleteAddress(address);
      },
      /** @this EmailAddressVarcharFieldView */
      'keyup input': function (e) {
        if (!this.isEditMode()) {
          return;
        }
        const key = Espo.Utils.getKeyFromKeyEvent(e);
        if (key === 'Comma' || key === 'Semicolon' || key === 'Enter') {
          const $input = $(e.currentTarget);
          const address = this.obtainEmailAddressFromString($input.val());
          if (address) {
            this.addAddress(address, '');
            $input.val('');
          }
        }
      },
      /** @this EmailAddressVarcharFieldView */
      'change input': function (e) {
        if (!this.isEditMode()) {
          return;
        }
        const $input = $(e.currentTarget);
        const address = this.obtainEmailAddressFromString($input.val());
        if (address) {
          this.addAddress(address, '');
          $input.val('');
        }
      },
      /** @this EmailAddressVarcharFieldView */
      'click [data-action="createContact"]': function (e) {
        const address = $(e.currentTarget).data('address');
        _fromAddressVarchar.default.prototype.createPerson.call(this, 'Contact', address);
      },
      /** @this EmailAddressVarcharFieldView */
      'click [data-action="createLead"]': function (e) {
        const address = $(e.currentTarget).data('address');
        _fromAddressVarchar.default.prototype.createPerson.call(this, 'Lead', address);
      },
      /** @this EmailAddressVarcharFieldView */
      'click [data-action="addToContact"]': function (e) {
        const address = $(e.currentTarget).data('address');
        _fromAddressVarchar.default.prototype.addToPerson.call(this, 'Contact', address);
      },
      /** @this EmailAddressVarcharFieldView */
      'click [data-action="addToLead"]': function (e) {
        const address = $(e.currentTarget).data('address');
        _fromAddressVarchar.default.prototype.addToPerson.call(this, 'Lead', address);
      },
      /** @this EmailAddressVarcharFieldView */
      'auxclick a[href][data-scope][data-id]': function (e) {
        const isCombination = e.button === 1 && (e.ctrlKey || e.metaKey);
        if (!isCombination) {
          return;
        }
        const $target = $(e.currentTarget);
        const id = $target.attr('data-id');
        const scope = $target.attr('data-scope');
        e.preventDefault();
        e.stopPropagation();
        _fromAddressVarchar.default.prototype.quickView.call(this, {
          id: id,
          scope: scope
        });
      }
    };

    /**
     *
     * @param {string} input
     * @return {string}
     */
    obtainEmailAddressFromString(input) {
      input = input.replace(',', '').replace(';', '').trim();
      const address = input.split(' ').find(it => it.includes('@'));
      if (!address) {
        return undefined;
      }
      if (!this.checkEmailAddressInString(address)) {
        return undefined;
      }
      return address;
    }
    getAutocompleteMaxCount() {
      if (this.autocompleteMaxCount) {
        return this.autocompleteMaxCount;
      }
      return this.getConfig().get('recordsPerPage');
    }
    getAttributeList() {
      const list = super.getAttributeList();
      list.push('nameHash');
      list.push('typeHash');
      list.push('idHash');
      list.push('accountId');
      list.push(this.name + 'EmailAddressesNames');
      list.push(this.name + 'EmailAddressesIds');
      return list;
    }
    setup() {
      this.setupSelectAddress();
      this.on('render', () => this.initAddressList());
    }

    /**
     * @private
     */
    setupSelectAddress() {
      const list = /** @type {string[]} */this.getConfig().get('emailAddressSelectEntityTypeList') || [];
      this.selectAddressEntityTypeList = list.filter(it => this.getAcl().checkScope(it));
      this.hasSelectAddress = this.selectAddressEntityTypeList.length !== 0;
      this.addActionHandler('selectAddress', () => {
        const entityType = this.selectAddressEntityTypeList[0];
        this.processSelectEntityType(entityType);
      });
    }

    /**
     * @param {string} entityType
     */
    async processSelectEntityType(entityType) {
      const viewName = this.getMetadata().get(['clientDefs', entityType, 'modalViews', 'select']) || 'views/modals/select-records';
      const headerText = this.translate('Select') + ' · ' + this.translate(this.name, 'fields', 'Email');
      const filters = {
        emailAddress: {
          type: 'isNotNull',
          data: {
            type: 'isNotEmpty'
          }
        },
        emailAddressIsInvalid: {
          type: 'isFalse',
          data: {
            type: 'isFalse'
          }
        }
      };
      if (entityType === 'Contact' && (this.model.attributes.parentId && this.model.attributes.parentType === 'Account' || this.model.attributes.accountId)) {
        const accountId = this.model.attributes.accountId || this.model.attributes.parentId;
        const accountName = this.model.attributes.accountId ? this.model.attributes.accountName : this.model.attributes.parentName;
        filters.accounts = {
          field: 'accounts',
          type: 'linkedWith',
          value: [accountId],
          data: {
            nameHash: {
              [accountId]: accountName
            }
          }
        };
      }

      /** @type {module:views/modals/select-records~Options} */
      const options = {
        entityType: entityType,
        multiple: true,
        createButton: false,
        mandatorySelectAttributeList: ['emailAddress'],
        headerText: headerText,
        filters: filters,
        onSelect: models => {
          models.filter(model => model.attributes.emailAddress).forEach(model => {
            const address = model.attributes.emailAddress;
            if (this.addressList.includes(address)) {
              return;
            }
            this.addressList.push(address);
            this.nameHash[address] = model.attributes.name;
            this.idHash[address] = model.id;
            this.typeHash[address] = model.entityType;
            this.addAddressHtml(address, model.attributes.name);
          });
          this.trigger('change');
        }
      };
      const view = /** @type {import('views/modals/select-records').default} */
      await this.createView('modal', viewName, options);
      this.selectAddressEntityTypeList.forEach(itemEntityType => {
        view.addButton({
          name: 'selectEntityType' + itemEntityType,
          style: 'text',
          position: 'right',
          label: this.translate(itemEntityType, 'scopeNamesPlural'),
          className: itemEntityType === entityType ? 'active btn-xs-wide' : 'btn-xs-wide',
          disabled: itemEntityType === entityType,
          onClick: () => {
            this.clearView('modal');
            this.processSelectEntityType(itemEntityType);
          }
        }, false, true);
      });
      await view.render();
    }
    initAddressList() {
      this.nameHash = {};
      this.addressList = (this.model.get(this.name) || '').split(';').filter(item => {
        return item !== '';
      }).map(item => {
        return item.trim();
      });
      this.idHash = this.idHash || {};
      this.typeHash = this.typeHash || {};
      this.nameHash = this.nameHash || {};
      _.extend(this.typeHash, this.model.get('typeHash') || {});
      _.extend(this.nameHash, this.model.get('nameHash') || {});
      _.extend(this.idHash, this.model.get('idHash') || {});
      this.nameHash = _.clone(this.nameHash);
      this.typeHash = _.clone(this.typeHash);
      this.idHash = _.clone(this.idHash);
    }
    afterRender() {
      super.afterRender();
      if (this.isEditMode()) {
        this.$input = this.$element = this.$el.find('input');
        this.addressList.forEach(item => {
          this.addAddressHtml(item, this.nameHash[item] || '');
        });

        /** @type {module:ajax.AjaxPromise & Promise<any>} */
        let lastAjaxPromise;
        const autocomplete = new _autocomplete.default(this.$input.get(0), {
          name: this.name,
          autoSelectFirst: true,
          triggerSelectOnValidInput: false,
          focusOnSelect: true,
          minChars: 1,
          forceHide: true,
          onSelect: item => {
            this.addAddress(item.emailAddress, item.entityName, item.entityType, item.entityId);
            this.$input.val('');
          },
          formatResult: item => {
            return this.getHelper().escapeString(item.name) + ' &#60;' + this.getHelper().escapeString(item.id) + '&#62;';
          },
          lookupFunction: query => {
            if (lastAjaxPromise && lastAjaxPromise.getReadyState() < 4) {
              lastAjaxPromise.abort();
            }
            lastAjaxPromise = Espo.Ajax.getRequest('EmailAddress/search', {
              q: query,
              maxSize: this.getAutocompleteMaxCount(),
              onlyActual: true
            });
            return lastAjaxPromise.then(/** Record[] */response => {
              return response.map(item => {
                return {
                  id: item.emailAddress,
                  name: item.entityName,
                  emailAddress: item.emailAddress,
                  entityId: item.entityId,
                  entityName: item.entityName,
                  entityType: item.entityType,
                  data: item.emailAddress,
                  value: item.emailAddress
                };
              });
            });
          }
        });
        this.once('render remove', () => autocomplete.dispose());
      }
      if (this.mode === 'search' && this.getAcl().check('Email', 'create')) {
        _emailAddress.default.prototype.initSearchAutocomplete.call(this);
      }
      if (this.mode === 'search') {
        this.$input.on('input', () => {
          this.trigger('change');
        });
      }
    }
    checkEmailAddressInString(string) {
      const arr = string.match(this.emailAddressRegExp);
      if (!arr || !arr.length) {
        return;
      }
      return true;
    }

    /**
     *
     * @param {string} address
     * @param {string} name
     * @param {string} [type]
     * @param {string} [id]
     */
    addAddress(address, name, type, id) {
      if (name === '') {
        const nameHash = this.model.attributes.nameHash ?? {};
        if (address in nameHash) {
          name = nameHash[address];
        }
      }
      if (type === undefined) {
        const typeHash = this.model.attributes.typeHash ?? {};
        if (address in typeHash) {
          type = typeHash[address];
        }
      }
      if (id === undefined) {
        const idHash = this.model.attributes.idHash ?? {};
        if (address in idHash) {
          id = idHash[address];
        }
      }
      if (this.justAddedAddress) {
        this.deleteAddress(this.justAddedAddress);
      }
      this.justAddedAddress = address;
      setTimeout(() => {
        this.justAddedAddress = null;
      }, 100);
      address = address.trim();
      if (!type) {
        const arr = address.match(this.emailAddressRegExp);
        if (!arr || !arr.length) {
          return;
        }
        address = arr[0];
      }
      if (!~this.addressList.indexOf(address)) {
        this.addressList.push(address);
        this.nameHash[address] = name;
        if (type) {
          this.typeHash[address] = type;
        }
        if (id) {
          this.idHash[address] = id;
        }
        this.addAddressHtml(address, name);
        this.trigger('change');
      }
    }

    /**
     * @private
     * @param {string} address
     * @param {string} name
     */
    addAddressHtml(address, name) {
      const $container = this.$el.find('.link-container');
      const entityType = this.typeHash[address];
      const id = this.idHash[address];
      let avatarHtml = '';
      const $text = $('<span>');
      if (name) {
        if (entityType === 'User' && id) {
          avatarHtml = this.getHelper().getAvatarHtml(id, 'small', 18, 'avatar-link');
        } else {
          avatarHtml = this.getHelper().getScopeColorIconHtml(entityType);
        }
        $text.append($('<span>').text(name), '<span class="no-select"> </span>', $('<span>').addClass('text-muted middle-dot'), '<span class="no-select"> </span>');
      }
      $text.append($('<span>').text(address));
      const $div = $('<div>').attr('data-address', address).addClass('list-group-item').append(avatarHtml, $('<a>').attr('data-address', address).attr('role', 'button').attr('tabindex', '0').attr('data-action', 'clearAddress').addClass('pull-right').append($('<span>').addClass('fas fa-times')), $text);
      $container.append($div);
    }
    deleteAddress(address) {
      this.deleteAddressHtml(address);
      const index = this.addressList.indexOf(address);
      if (index > -1) {
        this.addressList.splice(index, 1);
      }
      delete this.nameHash[address];
      this.trigger('change');
    }
    deleteAddressHtml(address) {
      this.$el.find('.list-group-item[data-address="' + address + '"]').remove();
    }
    fetch() {
      const data = {};
      data[this.name] = this.addressList.join(';');
      return data;
    }
    fetchSearch() {
      const value = this.$element.val().trim();
      if (value) {
        return {
          type: 'equals',
          value: value
        };
      }
      return null;
    }
    getValueForDisplay() {
      if (this.isDetailMode()) {
        const names = [];
        this.addressList.forEach(address => {
          names.push(this.getDetailAddressHtml(address));
        });
        return names.join('');
      }
    }
    getDetailAddressHtml(address) {
      if (!address) {
        return '';
      }
      const name = this.nameHash[address] || null;
      const entityType = this.typeHash[address] || null;
      const id = this.idHash[address] || null;
      if (id) {
        let avatarHtml = '';
        if (entityType === 'User') {
          avatarHtml = this.getHelper().getAvatarHtml(id, 'small', 18, 'avatar-link');
        } else {
          avatarHtml = this.getHelper().getScopeColorIconHtml(entityType);
        }
        const className = this.mode === this.MODE_LIST ? 'text-default' : 'text-record';
        return $('<div class="email-address-detail-item">').append(avatarHtml, $('<a>').attr('href', `#${entityType}/view/${id}`).attr('data-scope', entityType).attr('data-id', id).addClass(className).text(name), ' <span class="text-muted middle-dot"></span> ', $('<span>').text(address)).get(0).outerHTML;
      }
      const $div = $('<div>');
      if (name) {
        $div.append($('<span>').addClass('email-address-line').text(name).append(' <span class="text-muted middle-dot"></span> ').append($('<span>').text(address)));
      } else {
        $div.append($('<span>').addClass('email-address-line').text(address));
      }
      if (this.getAcl().check('Contact', 'create') || this.getAcl().check('Lead', 'create')) {
        $div.prepend(_fromAddressVarchar.default.prototype.getCreateHtml.call(this, address));
      }
      return $div.get(0).outerHTML;
    }
    validateRequired() {
      if (this.model.get('status') === 'Draft') {
        return false;
      }
      return super.validateRequired();
    }
  }
  var _default = _exports.default = EmailAddressVarcharFieldView;
});

define("views/email/fields/date-sent", ["exports", "views/fields/datetime-short"], function (_exports, _datetimeShort) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _datetimeShort = _interopRequireDefault(_datetimeShort);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _datetimeShort.default {
    shortInDetailMode = false;
  }
  _exports.default = _default;
});

define("views/email/fields/created-event", ["exports", "views/fields/link-parent"], function (_exports, _linkParent) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _linkParent = _interopRequireDefault(_linkParent);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _linkParent.default {
    data() {
      const data = super.data();

      /** @type {Record} */
      const icsEventData = this.model.get('icsEventData') || {};
      if (this.isReadMode() && !data.idValue && icsEventData.createdEvent) {
        data.idValue = icsEventData.createdEvent.id;
        data.typeValue = icsEventData.createdEvent.entityType;
        data.nameValue = icsEventData.createdEvent.name;
      }
      return data;
    }
    getAttributeList() {
      const list = super.getAttributeList();
      list.push('icsEventData');
      return list;
    }
  }
  _exports.default = _default;
});

define("views/email/fields/create-event", ["exports", "views/fields/base", "helpers/record-modal"], function (_exports, _base, _recordModal) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  _recordModal = _interopRequireDefault(_recordModal);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _base.default {
    detailTemplate = 'email/fields/create-event/detail';
    eventEntityType = 'Meeting';
    getAttributeList() {
      return ['icsEventData', 'createdEventId'];
    }
    setup() {
      super.setup();
      this.addActionHandler('createEvent', () => this.createEvent());
    }
    createEvent() {
      const eventData = this.model.get('icsEventData') || {};
      const attributes = Espo.Utils.cloneDeep(eventData.valueMap || {});
      attributes.parentId = this.model.get('parentId');
      attributes.parentType = this.model.get('parentType');
      attributes.parentName = this.model.get('parentName');
      this.addFromAddressToAttributes(attributes);
      const helper = new _recordModal.default();
      helper.showCreate(this, {
        entityType: this.eventEntityType,
        attributes: attributes,
        afterSave: async () => {
          await this.model.fetch();
          Espo.Ui.success(this.translate('Done'));
        }
      });
    }

    /**
     * @private
     * @param {Record} attributes
     */
    addFromAddressToAttributes(attributes) {
      const fromAddress = this.model.get('from');
      const idHash = this.model.get('idHash') || {};
      const typeHash = this.model.get('typeHash') || {};
      const nameHash = this.model.get('nameHash') || {};
      let fromId = null;
      let fromType = null;
      let fromName = null;
      if (!fromAddress) {
        return;
      }
      fromId = idHash[fromAddress] || null;
      fromType = typeHash[fromAddress] || null;
      fromName = nameHash[fromAddress] || null;
      const attendeeLink = this.getAttendeeLink(fromType);
      if (!attendeeLink) {
        return;
      }
      attributes[attendeeLink + 'Ids'] = attributes[attendeeLink + 'Ids'] || [];
      attributes[attendeeLink + 'Names'] = attributes[attendeeLink + 'Names'] || {};
      if (~attributes[attendeeLink + 'Ids'].indexOf(fromId)) {
        return;
      }
      attributes[attendeeLink + 'Ids'].push(fromId);
      attributes[attendeeLink + 'Names'][fromId] = fromName;
    }

    /**
     * @private
     * @param {string} entityType
     * @return {null|string}
     */
    getAttendeeLink(entityType) {
      if (entityType === 'User') {
        return 'users';
      }
      if (entityType === 'Contact') {
        return 'contacts';
      }
      if (entityType === 'Lead') {
        return 'leads';
      }
      return null;
    }
  }
  _exports.default = _default;
});

define("views/email/fields/compose-from-address", ["exports", "views/fields/base", "ui/select"], function (_exports, _base, _select) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  _select = _interopRequireDefault(_select);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _base.default {
    detailTemplate = 'email/fields/email-address-varchar/detail';
    editTemplate = 'email/fields/compose-from-address/edit';
    data() {
      let noSmtpMessage = this.translate('noSmtpSetup', 'messages', 'Email');
      const linkHtml = $('<a>').attr('href', '#EmailAccount').text(this.translate('EmailAccount', 'scopeNamesPlural')).get(0).outerHTML;
      noSmtpMessage = noSmtpMessage.replace('{link}', linkHtml);
      return {
        list: this.list,
        noSmtpMessage: noSmtpMessage,
        ...super.data()
      };
    }
    setup() {
      super.setup();
      this.nameHash = {
        ...(this.model.get('nameHash') || {})
      };
      this.typeHash = this.model.get('typeHash') || {};
      this.idHash = this.model.get('idHash') || {};
      this.list = this.getUser().get('emailAddressList') || [];
    }
    afterRenderEdit() {
      if (this.$element.length) {
        _select.default.init(this.$element);
      }
    }
    getValueForDisplay() {
      if (this.isDetailMode()) {
        const address = this.model.get(this.name);
        return this.getDetailAddressHtml(address);
      }
      return super.getValueForDisplay();
    }
    getDetailAddressHtml(address) {
      if (!address) {
        return '';
      }
      const name = this.nameHash[address] || null;
      const entityType = this.typeHash[address] || null;
      const id = this.idHash[address] || null;
      if (id && name) {
        return $('<div>').append($('<a>').attr('href', `#${entityType}/view/${id}`).attr('data-scope', entityType).attr('data-id', id).text(name), ' ', $('<span>').addClass('text-muted chevron-right'), ' ', $('<span>').text(address)).get(0).outerHTML;
      }
      const $div = $('<div>');
      if (name) {
        $div.append($('<span>').addClass('email-address-line').text(name).append(' ', $('<span>').addClass('text-muted chevron-right'), ' ', $('<span>').text(address)));
        return $div.get(0).outerHTML;
      }
      $div.append($('<span>').addClass('email-address-line').text(address));
      return $div.get(0).outerHTML;
    }
  }
  _exports.default = _default;
});

define("views/dashlets/stream", ["exports", "views/dashlets/abstract/base"], function (_exports, _base) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class StreamDashletView extends _base.default {
    name = 'Stream';
    templateContent = '<div class="list-container">{{{list}}}</div>';
    actionRefresh() {
      this.refreshInternal();
    }
    autoRefresh() {
      this.refreshInternal({
        skipNotify: true
      });
    }
    /**
     * @private
     * @param {{skipNotify?: boolean}} [options]
     * @return {Promise<void>}
     */
    async refreshInternal() {
      let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      if (!this.getRecordView()) {
        return;
      }
      if (!options.skipNotify) {
        Espo.Ui.notifyWait();
      }
      await this.getRecordView().showNewRecords();
      if (!options.skipNotify) {
        Espo.Ui.notify();
      }
    }
    afterRender() {
      this.getCollectionFactory().create('Note', collection => {
        this.collection = collection;
        collection.url = 'Stream';
        collection.maxSize = this.getOption('displayRecords');
        if (this.getOption('skipOwn')) {
          collection.data.skipOwn = true;
        }
        collection.fetch().then(() => {
          this.createView('list', 'views/stream/record/list', {
            selector: '> .list-container',
            collection: collection,
            isUserStream: true,
            noEdit: false
          }, view => {
            view.render();
          });
        });
      });
    }

    /**
     * @return {module:views/stream/record/list}
     */
    getRecordView() {
      return this.getView('list');
    }
    setupActionList() {
      this.actionList.unshift({
        name: 'viewList',
        text: this.translate('View'),
        iconClass: 'fas fa-align-justify',
        url: '#Stream'
      });
      if (!this.getUser().isPortal()) {
        this.actionList.unshift({
          name: 'create',
          text: this.translate('Create Post', 'labels'),
          iconClass: 'fas fa-plus'
        });
      }
    }

    // noinspection JSUnusedGlobalSymbols
    actionCreate() {
      this.createView('dialog', 'views/stream/modals/create-post', {}, view => {
        view.render();
        this.listenToOnce(view, 'after:save', () => {
          view.close();
          this.actionRefresh();
        });
      });
    }

    // noinspection JSUnusedGlobalSymbols
    actionViewList() {
      this.getRouter().navigate('#Stream', {
        trigger: true
      });
    }
  }
  var _default = _exports.default = StreamDashletView;
});

define("views/dashlets/records", ["exports", "views/dashlets/abstract/record-list"], function (_exports, _recordList) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _recordList = _interopRequireDefault(_recordList);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class RecordsDashletView extends _recordList.default {
    name = 'Records';
    rowActionsView = 'views/record/row-actions/view-and-edit';
    listView = 'views/email/record/list-expanded';
    init() {
      super.init();
      this.scope = this.getOption('entityType');
    }
    getSearchData() {
      const data = {
        primary: /** @type string */this.getOption('primaryFilter')
      };
      if (data.primary === 'all') {
        delete data.primary;
      }
      const bool = {};
      (this.getOption('boolFilterList') || []).forEach(item => {
        bool[item] = true;
      });
      data.bool = bool;
      return data;
    }
    setupActionList() {
      const scope = this.getOption('entityType');
      if (scope && this.getAcl().checkScope(scope, 'create')) {
        this.actionList.unshift({
          name: 'create',
          text: this.translate('Create ' + scope, 'labels', scope),
          iconClass: 'fas fa-plus',
          url: `#${scope}/create`
        });
      }
    }
  }
  var _default = _exports.default = RecordsDashletView;
});

define("views/dashlets/memo", ["exports", "views/dashlets/abstract/base"], function (_exports, _base) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class MemoDashletView extends _base.default {
    name = 'Memo';
    templateContent = `
        {{#if text}}
        <div class="complex-text complex-text-memo">{{complexText text}}</div>
        {{/if}}
    `;
    data() {
      return {
        text: this.getOption('text')
      };
    }
    afterAdding() {
      this.getContainerView().actionOptions();
    }
  }
  var _default = _exports.default = MemoDashletView;
});

define("views/dashlets/iframe", ["exports", "views/dashlets/abstract/base"], function (_exports, _base) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class IframeDashletView extends _base.default {
    name = 'Iframe';

    /**
     * @private
     * @type {boolean}
     */
    sandboxDisabled = false;

    // language=Handlebars
    templateContent = `
        <iframe
            style="margin: 0; border: 0;"
            {{#unless viewObject.sandboxDisabled}}
                sandbox="allow-scripts"
            {{/unless}}
        ></iframe>
    `;
    setup() {
      const url = this.getOption('url');

      /** @type {string[]} */
      const excludeDomains = this.getConfig().get('iframeSandboxExcludeDomainList') || [];
      if (url) {
        for (const domain of excludeDomains) {
          try {
            const urlObject = new URL(url);
            if (urlObject.hostname === domain) {
              this.sandboxDisabled = true;
              break;
            }
          } catch (e) {
            console.warn(`Invalid URL ${url}.`);
          }
        }
      }
    }
    afterRender() {
      const $iframe = this.$el.find('iframe');
      const url = this.getOption('url');
      if (url) {
        $iframe.attr('src', url);
      }
      this.$el.addClass('no-padding');
      this.$el.css('overflow', 'hidden');
      const height = this.$el.height();
      $iframe.css('height', height);
      $iframe.css('width', '100%');
    }
    afterAdding() {
      this.getContainerView().actionOptions();
    }
  }
  var _default = _exports.default = IframeDashletView;
});

define("views/dashlets/emails", ["exports", "views/dashlets/abstract/record-list"], function (_exports, _recordList) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _recordList = _interopRequireDefault(_recordList);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EmailsDashletView extends _recordList.default {
    name = 'Emails';
    scope = 'Emails';
    rowActionsView = 'views/email/record/row-actions/dashlet';
    listView = 'views/email/record/list-expanded';
    setupActionList() {
      if (this.getAcl().checkScope(this.scope, 'create')) {
        this.actionList.unshift({
          name: 'compose',
          text: this.translate('Compose Email', 'labels', this.scope),
          iconClass: 'fas fa-plus'
        });
      }
    }

    // noinspection JSUnusedGlobalSymbols
    actionCompose() {
      const attributes = this.getCreateAttributes() || {};
      Espo.Ui.notifyWait();
      const viewName = this.getMetadata().get('clientDefs.' + this.scope + '.modalViews.compose') || 'views/modals/compose-email';
      this.createView('modal', viewName, {
        scope: this.scope,
        attributes: attributes
      }, view => {
        view.render();
        Espo.Ui.notify(false);
        this.listenToOnce(view, 'after:save', () => {
          this.actionRefresh();
        });
      });
    }

    /**
     * @return {module:search-manager~data}
     */
    getSearchData() {
      return {
        'advanced': [{
          'attribute': 'folderId',
          'type': 'inFolder',
          'value': this.getOption('folder') || 'inbox'
        }]
      };
    }
  }
  var _default = _exports.default = EmailsDashletView;
});

define("views/dashlets/options/record-list", ["exports", "views/dashlets/options/base"], function (_exports, _base) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class RecordListDashletOptionsModalView extends _base.default {
    /**
     * @protected
     * @type {boolean}
     */
    hasCollaborators;
    setup() {
      const entityType = this.getMetadata().get(`dashlets.${this.name}.entityType`);
      this.hasCollaborators = entityType && !!this.getMetadata().get(`scopes.${entityType}.collaborators`);
      super.setup();
      if (!this.hasCollaborators) {
        this.getRecordView().hideField('includeShared');
      }
    }
  }
  _exports.default = RecordListDashletOptionsModalView;
});

define("views/dashlets/fields/records/sort-direction", ["exports", "views/fields/enum"], function (_exports, _enum) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _enum = _interopRequireDefault(_enum);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  // noinspection JSUnusedGlobalSymbols
  class _default extends _enum.default {
    setup() {
      super.setup();
      this.listenTo(this.model, 'change:entityType', () => {
        this.setupOptions();
        this.reRender();
      });
    }
  }
  _exports.default = _default;
});

define("views/dashlets/fields/records/sort-by", ["exports", "views/fields/enum"], function (_exports, _enum) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _enum = _interopRequireDefault(_enum);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _enum.default {
    setup() {
      super.setup();
      this.listenTo(this.model, 'change:entityType', () => {
        this.setupOptions();
        this.reRender();
      });
    }
    setupOptions() {
      const entityType = this.model.attributes.entityType ?? this.getMetadata().get(['dashlets', this.dataObject.dashletName, 'entityType']);
      const scope = entityType;
      if (!entityType) {
        this.params.options = [];
        return;
      }

      /** @type {Record<string, Record>} */
      const fieldDefs = this.getMetadata().get(`entityDefs.${scope}.fields`) || {};
      const orderableFieldList = Object.keys(fieldDefs).filter(item => {
        if (fieldDefs[item].orderDisabled || fieldDefs[item].utility) {
          return false;
        }
        return true;
      }).sort((v1, v2) => {
        return this.translate(v1, 'fields', scope).localeCompare(this.translate(v2, 'fields', scope));
      });
      const translatedOptions = {};
      orderableFieldList.forEach(item => {
        translatedOptions[item] = this.translate(item, 'fields', scope);
      });
      this.params.options = orderableFieldList;
      this.translatedOptions = translatedOptions;
    }
  }
  _exports.default = _default;
});

define("views/dashlets/fields/records/primary-filter", ["exports", "views/fields/enum"], function (_exports, _enum) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _enum = _interopRequireDefault(_enum);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _enum.default {
    setup() {
      super.setup();
      this.listenTo(this.model, 'change:entityType', () => {
        this.setupOptions();
        this.reRender();
      });
    }
    setupOptions() {
      const entityType = this.model.get('entityType');
      if (!entityType) {
        this.params.options = [];
        return;
      }
      const filterList = this.getMetadata().get(['clientDefs', entityType, 'filterList']) || [];
      this.params.options = [];
      filterList.forEach(item => {
        if (typeof item === 'object' && item.name) {
          if (item.accessDataList && !Espo.Utils.checkAccessDataList(item.accessDataList, this.getAcl(), this.getUser(), null, true)) {
            return false;
          }
          this.params.options.push(item.name);
          return;
        }
        this.params.options.push(item);
      });
      this.params.options.unshift('all');
      if (this.getMetadata().get(`scopes.${entityType}.stars`)) {
        this.params.options.push('starred');
      }
      this.translatedOptions = {};
      this.params.options.forEach(item => {
        this.translatedOptions[item] = this.translate(item, 'presetFilters', entityType);
      });
    }
  }
  _exports.default = _default;
});

define("views/dashlets/fields/records/expanded-layout", ["exports", "views/fields/base", "ui/multi-select", "views/dashlets/fields/records/expanded-layout/modals/edit-item"], function (_exports, _base, _multiSelect, _editItem) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  _multiSelect = _interopRequireDefault(_multiSelect);
  _editItem = _interopRequireDefault(_editItem);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ExpandedLayoutDashletFieldView extends _base.default {
    // language=Handlebars
    editTemplateContent = `
        <div class="layout-container">
            {{#each rowDataList}}
                <div data-role="layoutRow">
                    <div
                        style="display: inline-block; width: calc(100% - var(--40px));"
                    >
                        <input
                            type="text"
                            value="{{value}}"
                            data-index="{{index}}"
                        >
                    </div>
                    {{#if hasEdit}}
                        <div class="btn-group pull-right">
                            <button
                                class="btn btn-text dropdown-toggle"
                                data-toggle="dropdown"
                            ><span class="caret"></span></button>
                            <ul class="dropdown-menu pull-right">
                                <li class="dropdown-header">{{translate 'Edit'}}</li>
                                {{#each itemList}}
                                    <li>
                                        <a
                                            role="button"
                                            tabindex="0"
                                            data-action="editItem"
                                            data-name="{{name}}"
                                        >{{label}}</a>
                                    </li>
                                {{/each}}
                            </ul>
                        </div>
                    {{/if}}
                </div>
            {{/each}}
        </div>
    `;
    delimiter = ':,:';

    /**
     * @private
     * @type {string}
     */
    targetEntityType;
    data() {
      const rowList = this.getRowList();
      const dataList = [...rowList, []].map((it, i) => ({
        index: i,
        value: it.map(subIt => subIt.name).join(this.delimiter),
        hasEdit: i < rowList.length,
        itemList: it.map(subIt => ({
          name: subIt.name,
          label: this.translate(subIt.name, 'fields', this.targetEntityType)
        }))
      }));
      return {
        rowDataList: dataList
      };
    }
    setup() {
      this.addHandler('change', 'div[data-role="layoutRow"] input', () => {
        setTimeout(() => {
          this.trigger('change');
          this.reRender();
        }, 1);
      });
      this.addActionHandler('editItem', (event, target) => this.editItem(target.dataset.name));
      this.targetEntityType = this.model.attributes.entityType ?? this.getMetadata().get(['dashlets', this.dataObject.dashletName, 'entityType']);
      this.listenTo(this.model, 'change:entityType', () => {
        if (this.model.attributes.entityType) {
          this.targetEntityType = this.model.attributes.entityType;
        }
      });
    }

    /**
     * @private
     * @return {Array.<{name: string, link?: boolean, soft?: boolean, small?: boolean}>[]}
     */
    getRowList() {
      return Espo.Utils.cloneDeep((this.model.get(this.name) || {}).rows || []);
    }
    afterRenderEdit() {
      const rowList = Espo.Utils.cloneDeep(this.getRowList());
      rowList.push([]);
      const fieldDataList = this.getFieldDataList();
      rowList.forEach((row, i) => {
        const usedOtherList = [];
        const usedList = [];
        rowList.forEach((it, j) => {
          usedList.push(...it.map(it => it.name));
          if (j === i) {
            return;
          }
          usedOtherList.push(...it.map(it => it.name));
        });
        const preparedList = fieldDataList.filter(it => !usedOtherList.includes(it.value)).map(it => {
          if (!usedList.includes(it.value)) {
            return it;
          }
          const itemData = this.getItemData(it.value) || {};
          if (itemData.soft) {
            it.style = 'soft';
          }
          if (itemData.small) {
            it.small = true;
          }
          return it;
        });
        const inputElement = this.element.querySelector(`input[data-index="${i.toString()}"]`);

        /** @type {module:ui/multi-select~Options} */
        const multiSelectOptions = {
          items: preparedList,
          delimiter: this.delimiter,
          matchAnyWord: this.matchAnyWord,
          draggable: true
        };
        _multiSelect.default.init(inputElement, multiSelectOptions);
      });
    }

    /**
     * @private
     * @return {{value: string, text: string}[]}
     */
    getFieldDataList() {
      const scope = this.model.get('entityType') || this.getMetadata().get(['dashlets', this.dataObject.dashletName, 'entityType']);
      if (!scope) {
        return [];
      }
      const fields = this.getMetadata().get(['entityDefs', scope, 'fields']) || {};
      const forbiddenFieldList = this.getAcl().getScopeForbiddenFieldList(scope);
      const fieldList = Object.keys(fields).sort((v1, v2) => {
        return this.translate(v1, 'fields', scope).localeCompare(this.translate(v2, 'fields', scope));
      }).filter(item => {
        const defs = /** @type {Record} */fields[item];
        if (defs.disabled || defs.listLayoutDisabled || defs.utility) {
          return false;
        }
        const layoutAvailabilityList = defs.layoutAvailabilityList;
        if (layoutAvailabilityList && !layoutAvailabilityList.includes('list')) {
          return false;
        }
        const layoutIgnoreList = defs.layoutIgnoreList || [];
        if (layoutIgnoreList.includes('list')) {
          return false;
        }
        if (forbiddenFieldList.indexOf(item) !== -1) {
          return false;
        }
        return true;
      });
      const dataList = [];
      fieldList.forEach(item => {
        dataList.push({
          value: item,
          text: this.translate(item, 'fields', scope)
        });
      });
      return dataList;
    }

    /**
     * @private
     * @param {string} name
     */
    async editItem(name) {
      const inputData = this.getItemData(name);
      const view = new _editItem.default({
        label: this.translate(name, 'fields', this.targetEntityType),
        data: inputData,
        onApply: data => this.applyItem(name, data)
      });
      await this.assignView('modal', view);
      await view.render();
    }

    /**
     * @private
     * @param {string} name
     * @return {{
     *     soft: boolean,
     *     small: boolean,
     * }}
     */
    getItemData(name) {
      /**
       * @type {{
       *     soft: boolean,
       *     small: boolean,
       * }}
       */
      let inputData;
      for (const row of this.getRowList()) {
        for (const item of row) {
          if (item.name === name) {
            inputData = {
              soft: item.soft || false,
              small: item.small || false
            };
          }
        }
      }
      return inputData;
    }
    fetch() {
      const value = {
        rows: []
      };

      /** @type {Record.<string, Record>} */
      const params = {};
      for (const row of this.getRowList()) {
        for (const item of row) {
          params[item.name] = item;
        }
      }
      this.element.querySelectorAll('input').forEach(/** HTMLInputElement*/inputElement => {
        const row = [];
        let list = inputElement.value.split(this.delimiter);
        if (list.length === 1 && list[0] === '') {
          list = [];
        }
        if (list.length === 0) {
          return;
        }
        list.forEach(name => {
          const item = {
            name: name
          };
          if (name === 'name') {
            item.link = true;
          }
          if (params[name]) {
            item.soft = params[name].soft || false;
            item.small = params[name].small || false;
          }
          row.push(item);
        });
        value.rows.push(row);
      });
      return {
        [this.name]: value
      };
    }

    /**
     * @private
     * @param {string} name
     * @param {{soft: boolean, small: boolean}} data
     */
    applyItem(name, data) {
      const rowList = this.getRowList();
      for (const row of rowList) {
        for (const item of row) {
          if (item.name === name) {
            item.soft = data.soft;
            item.small = data.small;
          }
        }
      }
      this.model.set(this.name, {
        rows: rowList
      }, {
        ui: true
      });
      this.reRender();
    }
  }
  var _default = _exports.default = ExpandedLayoutDashletFieldView;
});

define("views/dashlets/fields/records/entity-type", ["exports", "views/fields/enum"], function (_exports, _enum) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _enum = _interopRequireDefault(_enum);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _enum.default {
    setup() {
      super.setup();
      this.on('change', () => {
        const o = {
          primaryFilter: null,
          boolFilterList: [],
          title: this.translate('Records', 'dashlets'),
          sortBy: null,
          sortDirection: 'asc'
        };
        o.expandedLayout = {
          rows: []
        };
        const entityType = this.model.get('entityType');
        if (entityType) {
          o.title = this.translate(entityType, 'scopeNamesPlural');
          o.sortBy = this.getMetadata().get(['entityDefs', entityType, 'collection', 'orderBy']);
          const order = this.getMetadata().get(['entityDefs', entityType, 'collection', 'order']);
          if (order) {
            o.sortDirection = order;
          } else {
            o.sortDirection = 'asc';
          }
          o.expandedLayout = {
            rows: [[{
              name: "name",
              link: true,
              scope: entityType
            }]]
          };
        }
        this.model.set(o);
      });
    }
    setupOptions() {
      this.params.options = Object.keys(this.getMetadata().get('scopes')).filter(scope => {
        if (this.getMetadata().get(`scopes.${scope}.disabled`)) {
          return;
        }
        if (!this.getAcl().checkScope(scope, 'read')) {
          return;
        }
        if (!this.getMetadata().get(['scopes', scope, 'entity'])) {
          return;
        }
        if (!this.getMetadata().get(['scopes', scope, 'object'])) {
          return;
        }
        return true;
      }).sort((v1, v2) => {
        return this.translate(v1, 'scopeNames').localeCompare(this.translate(v2, 'scopeNames'));
      });
      this.params.options.unshift('');
    }
  }
  _exports.default = _default;
});

define("views/dashlets/fields/records/bool-filter-list", ["exports", "views/fields/multi-enum"], function (_exports, _multiEnum) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _multiEnum = _interopRequireDefault(_multiEnum);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _multiEnum.default {
    setup() {
      super.setup();
      this.listenTo(this.model, 'change:entityType', () => {
        this.setupOptions();
        this.reRender();
      });
    }
    setupOptions() {
      const entityType = this.model.get('entityType');
      if (!entityType) {
        this.params.options = [];
        return;
      }
      const filterList = this.getMetadata().get(['clientDefs', entityType, 'boolFilterList']) || [];
      this.params.options = [];
      filterList.forEach(item => {
        if (typeof item === 'object' && item.name) {
          if (item.accessDataList && !Espo.Utils.checkAccessDataList(item.accessDataList, this.getAcl(), this.getUser(), null, true)) {
            return false;
          }
          this.params.options.push(item.name);
          return;
        }
        this.params.options.push(item);
      });
      if (this.getMetadata().get(['scopes', entityType, 'stream']) && this.getAcl().checkScope(entityType, 'stream')) {
        this.params.options.push('followed');
      }
      if (this.getMetadata().get(`scopes.${entityType}.collaborators`)) {
        this.params.options.push('shared');
      }
      this.translatedOptions = {};
      this.params.options.forEach(item => {
        this.translatedOptions[item] = this.translate(item, 'boolFilters', entityType);
      });
    }
  }
  _exports.default = _default;
});

define("views/dashlets/fields/emails/folder", ["exports", "views/fields/enum"], function (_exports, _enum) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _enum = _interopRequireDefault(_enum);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EmailFolderDashletFieldView extends _enum.default {
    /** @type {{id: string, name: string}[]} */
    folderDataList;
    setup() {
      super.setup();
      let userId = this.dataObject.userId ?? this.getUser().id;
      this.wait(Espo.Ajax.getRequest('EmailFolder/action/listAll', {
        userId: userId
      }).then(data => this.folderDataList = data.list).then(() => this.setupOptions()));
      this.setupOptions();
    }
    setupOptions() {
      if (!this.folderDataList) {
        return;
      }
      this.params.options = this.folderDataList.map(item => item.id).filter(item => item !== 'inbox' && item !== 'trash');
      this.params.options.unshift('');
      this.translatedOptions = {
        '': this.translate('inbox', 'presetFilters', 'Email')
      };
      this.folderDataList.forEach(item => {
        this.translatedOptions[item.id] = item.name;
      });
    }
  }
  var _default = _exports.default = EmailFolderDashletFieldView;
});

define("views/dashboard-template/detail", ["exports", "views/detail"], function (_exports, _detail) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _detail = _interopRequireDefault(_detail);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _detail.default {
    // noinspection JSUnusedGlobalSymbols
    actionDeployToUsers() {
      this.createView('dialog', 'views/dashboard-template/modals/deploy-to-users', {
        model: this.model
      }, view => {
        view.render();
      });
    }

    // noinspection JSUnusedGlobalSymbols
    actionDeployToTeam() {
      this.createView('dialog', 'views/dashboard-template/modals/deploy-to-team', {
        model: this.model
      }, view => {
        view.render();
      });
    }
  }
  _exports.default = _default;
});

define("views/dashboard-template/record/list", ["exports", "views/record/list"], function (_exports, _list) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _list = _interopRequireDefault(_list);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _list.default {
    massActionList = ['remove', 'export'];
  }
  _exports.default = _default;
});

define("views/dashboard-template/modals/deploy-to-users", ["exports", "views/modal", "model"], function (_exports, _modal, _model) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  _model = _interopRequireDefault(_model);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _modal.default {
    className = 'dialog dialog-record';
    templateContent = `<div class="record">{{{record}}}</div>`;
    setup() {
      this.buttonList = [{
        name: 'deploy',
        text: this.translate('Deploy for Users', 'labels', 'DashboardTemplate'),
        style: 'danger',
        onClick: () => this.actionDeploy()
      }, {
        name: 'cancel',
        label: 'Cancel'
      }];
      this.headerText = this.model.get('name');
      this.formModel = new _model.default();
      this.formModel.name = 'None';
      this.formModel.setDefs({
        fields: {
          'users': {
            type: 'linkMultiple',
            view: 'views/fields/users',
            entity: 'User',
            required: true
          },
          'append': {
            type: 'bool'
          }
        }
      });
      this.createView('record', 'views/record/edit-for-modal', {
        scope: 'None',
        model: this.formModel,
        selector: '.record',
        detailLayout: [{
          rows: [[{
            name: 'users',
            labelText: this.translate('users', 'links')
          }, {
            name: 'append',
            labelText: this.translate('append', 'fields', 'DashboardTemplate')
          }]]
        }]
      });
    }

    /**
     * @private
     * @return {import('views/record/edit').default}
     */
    getRecordView() {
      return this.getView('record');
    }

    /**
     * @private
     */
    actionDeploy() {
      if (this.getRecordView().processFetch()) {
        Espo.Ajax.postRequest('DashboardTemplate/action/deployToUsers', {
          id: this.model.id,
          userIdList: this.formModel.get('usersIds'),
          append: this.formModel.get('append')
        }).then(() => {
          Espo.Ui.success(this.translate('Done'));
          this.close();
        });
      }
    }
  }
  _exports.default = _default;
});

define("views/dashboard-template/modals/deploy-to-team", ["exports", "views/modal", "model"], function (_exports, _modal, _model) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _modal = _interopRequireDefault(_modal);
  _model = _interopRequireDefault(_model);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _modal.default {
    className = 'dialog dialog-record';
    templateContent = `<div class="record">{{{record}}}</div>`;
    setup() {
      this.buttonList = [{
        name: 'deploy',
        text: this.translate('Deploy for Team', 'labels', 'DashboardTemplate'),
        style: 'danger',
        onClick: () => this.actionDeploy()
      }, {
        name: 'cancel',
        label: 'Cancel'
      }];
      this.headerText = this.model.get('name');
      this.formModel = new _model.default();
      this.formModel.name = 'None';
      this.formModel.setDefs({
        fields: {
          'team': {
            type: 'link',
            entity: 'Team',
            required: true
          },
          'append': {
            type: 'bool'
          }
        }
      });
      this.createView('record', 'views/record/edit-for-modal', {
        scope: 'None',
        model: this.formModel,
        selector: '.record',
        detailLayout: [{
          rows: [[{
            name: 'team',
            labelText: this.translate('team', 'links')
          }, {
            name: 'append',
            labelText: this.translate('append', 'fields', 'DashboardTemplate')
          }]]
        }]
      });
    }

    /**
     * @private
     * @return {import('views/record/edit').default}
     */
    getRecordView() {
      return this.getView('record');
    }

    /**
     * @private
     */
    actionDeploy() {
      if (this.getRecordView().processFetch()) {
        Espo.Ajax.postRequest('DashboardTemplate/action/deployToTeam', {
          id: this.model.id,
          teamId: this.formModel.get('teamId'),
          append: this.formModel.get('append')
        }).then(() => {
          Espo.Ui.success(this.translate('Done'));
          this.close();
        });
      }
    }
  }
  _exports.default = _default;
});

define("views/currency-record-rate/fields/rate", ["exports", "views/fields/decimal"], function (_exports, _decimal) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _decimal = _interopRequireDefault(_decimal);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class CurrencyRecordRateRateFieldView extends _decimal.default {
    // language=Handlebars
    listTemplateContent = `
        {{#if isNotEmpty~}}
            <span class="text-soft">{{targetCode}} = </span>
            <span class="numeric-text">{{value}}</span>
            <span class="text-soft">{{baseCode}}</span>
        {{~/if~}}
    `;

    // language=Handlebars
    detailTemplateContent = `
        {{~#if isNotEmpty~}}
            <span class="text-soft">{{targetCode}} = </span>
            <span class="numeric-text">{{value}}</span>
            <span class="text-soft">{{baseCode}}</span>
        {{~else~}}
            {{~#if valueIsSet~}}
                <span class="none-value">{{translate 'None'}}</span>
            {{~else~}}<span class="loading-value"></span>
            {{~/if}}
        {{~/if~}}
    `;

    // language=Handlebars
    editTemplateContent = `
            <div class="input-group">
            <span class="input-group-addon radius-left" style="width: 24%">1 {{targetCode}} = </span>
            <span class="input-group-item">
                <input
                    type="text"
                    class="main-element form-control numeric-text"
                    data-name="{{name}}"
                    value="{{value}}"
                    autocomplete="espo-{{name}}"
                    pattern="[\\-]?[0-9]*"
                    style="text-align: end;"
                >
            </span>
            <span class="input-group-addon radius-right" style="width: 21%">{{baseCode}}</span>
        </div>
    `;
    getAttributeList() {
      return [...super.getAttributeList(), 'baseCode', 'recordName'];
    }
    data() {
      let baseCode = this.model.attributes.baseCode;
      let targetCode = this.model.attributes.recordName;
      if (this.model.entityType === 'CurrencyRecord') {
        baseCode = this.getConfig().get('baseCurrency');
        targetCode = this.model.attributes.code;
      }
      return {
        ...super.data(),
        baseCode,
        targetCode
      };
    }
  }
  _exports.default = CurrencyRecordRateRateFieldView;
});

define("views/currency-record/list", ["exports", "views/list"], function (_exports, _list) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _list = _interopRequireDefault(_list);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _list.default {
    keepCurrentRootUrl = true;
  }
  _exports.default = _default;
});

define("views/currency-record/record/panels/rates", ["exports", "views/record/panels/relationship"], function (_exports, _relationship) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _relationship = _interopRequireDefault(_relationship);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class RatesPanelView extends _relationship.default {
    setup() {
      if (this.model.attributes.code === this.getConfig().get('baseCurrency')) {
        this.defs.createDisabled = true;
      }
      super.setup();
    }
  }
  _exports.default = RatesPanelView;
});

define("views/currency/fields/currency-rates", ["exports", "views/fields/base"], function (_exports, _base) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _base = _interopRequireDefault(_base);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2025 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _base.default {
    editTemplateContent = `
        {{#each rateValues}}
            <div class="input-group">
                <span class="input-group-addon radius-left" style="width: 25%">1 {{@key}} = </span>
                <span class="input-group-item">
                    <input
                        class="form-control"
                        type="text"
                        data-currency="{{@key}}"
                        value="{{./this}}"
                        style="text-align: right;"
                    >
                </span>
                <span class="input-group-addon radius-right" style="width: 22%">{{../baseCurrency}}</span>
            </div>
        {{/each}}
    `;
    data() {
      const baseCurrency = this.model.get('baseCurrency');
      const currencyRates = this.model.get('currencyRates') || {};
      const rateValues = {};
      (this.model.get('currencyList') || []).forEach(currency => {
        if (currency !== baseCurrency) {
          rateValues[currency] = currencyRates[currency];
          if (!rateValues[currency]) {
            if (currencyRates[baseCurrency]) {
              rateValues[currency] = Math.round(1 / currencyRates[baseCurrency] * 1000) / 1000;
            }
            if (!rateValues[currency]) {
              rateValues[currency] = 1.00;
            }
          }
        }
      });
      return {
        rateValues: rateValues,
        baseCurrency: baseCurrency
      };
    }
    fetch() {
      const data = {};
      const currencyRates = {};
      const baseCurrency = this.model.get('baseCurrency');
      const currencyList = this.model.get('currencyList') || [];
      currencyList.forEach(currency => {
        if (currency !== baseCurrency) {
          const value = this.$el.find(`input[data-currency="${currency}"]`).val() || '1';
          currencyRates[currency] = parseFloat(value);
        }
      });
      delete currencyRates[baseCurrency];
      for (const c in currencyRates) {
        if (!~currencyList.indexOf(c)) {
          delete currencyRates[c];
        }
      }
      data[this.name] = currencyRates;
      return data;
    }
  }
  _exports.default = _default;
});

define("views/attachment/record/list", ["exports", "views/record/list"], function (_exports, _list) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _list = _interopRequireDefault(_list);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _list.default {
    rowActionsView = 'views/record/row-actions/view-and-remove';
    massActionList = ['remove'];
  }
  _exports.default = _default;
});

define("views/attachment/record/detail", ["exports", "views/record/detail"], function (_exports, _detail) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _detail = _interopRequireDefault(_detail);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _detail.default {
    readOnly = true;
  }
  _exports.default = _default;
});

define("views/attachment/modals/detail", ["exports", "views/modals/detail"], function (_exports, _detail) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _detail = _interopRequireDefault(_detail);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _detail.default {
    editDisabled = true;
  }
  _exports.default = _default;
});

define("views/attachment/fields/parent", ["exports", "views/fields/link-parent"], function (_exports, _linkParent) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _linkParent = _interopRequireDefault(_linkParent);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _linkParent.default {
    ignoreScopeList = ['Preferences', 'ExternalAccount', 'Notification', 'Note', 'ArrayValue', 'Attachment'];
    displayEntityType = true;
    setup() {
      super.setup();
      this.foreignScopeList = this.getMetadata().getScopeEntityList().filter(item => {
        if (!this.getUser().isAdmin() && !this.getAcl().checkScopeHasAcl(item)) {
          return false;
        }
        if (this.ignoreScopeList.includes(item)) {
          return false;
        }
        if (!this.getAcl().checkScope(item)) {
          return false;
        }
        return true;
      });
      this.getLanguage().sortEntityList(this.foreignScopeList);
      this.foreignScope = this.model.get(this.typeName) || this.foreignScopeList[0];
    }
  }
  _exports.default = _default;
});

define("views/attachment/fields/name", ["exports", "views/fields/varchar"], function (_exports, _varchar) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _varchar = _interopRequireDefault(_varchar);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _varchar.default {
    detailTemplate = 'attachment/fields/name/detail';
    data() {
      const data = super.data();
      let url = this.getBasePath() + '?entryPoint=download&id=' + this.model.id;
      if (this.getUser().get('portalId')) {
        url += '&portalId=' + this.getUser().get('portalId');
      }
      data.url = url;
      return data;
    }
  }
  _exports.default = _default;
});

define("views/attachment/fields/name-for-stream", ["exports", "model", "views/fields/file", "views/fields/base"], function (_exports, _model, _file, _base) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _model = _interopRequireDefault(_model);
  _file = _interopRequireDefault(_file);
  _base = _interopRequireDefault(_base);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _base.default {
    // language=Handlebars
    listTemplateContent = `
        <span>{{{subField}}}</span>
    `;
    prepare() {
      const model = new _model.default({
        fileId: this.model.id,
        fileName: this.model.attributes.name,
        fileType: this.model.attributes.type
      });
      const view = new _file.default({
        name: 'file',
        model: model,
        params: {
          showPreview: true,
          listPreviewSize: 'small'
        },
        mode: 'list'
      });
      return this.assignView('subField', view);
    }
  }
  _exports.default = _default;
});

define("views/address-map/view", ["exports", "views/main"], function (_exports, _main) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _main = _interopRequireDefault(_main);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class AddressMapView extends _main.default {
    templateContent = `
        <div class="header page-header">{{{header}}}</div>
        <div class="map-container">{{{map}}}</div>
    `;
    setup() {
      this.scope = this.model.entityType;
      this.createView('header', 'views/header', {
        model: this.model,
        fullSelector: '#main > .header',
        scope: this.model.entityType,
        fontSizeFlexible: true
      });
    }
    afterRender() {
      const field = this.options.field;
      const viewName = this.model.getFieldParam(field + 'Map', 'view') || this.getFieldManager().getViewName('map');
      this.createView('map', viewName, {
        model: this.model,
        name: field + 'Map',
        selector: '.map-container',
        height: this.getHelper().calculateContentContainerHeight(this.$el.find('.map-container'))
      }, view => {
        view.render();
      });
    }
    getHeader() {
      let name = this.model.get('name');
      if (!name) {
        name = this.model.id;
      }
      const recordUrl = `#${this.model.entityType}/view/${this.model.id}`;
      const scopeLabel = this.getLanguage().translate(this.model.entityType, 'scopeNamesPlural');
      const fieldLabel = this.translate(this.options.field, 'fields', this.model.entityType);
      const rootUrl = this.options.rootUrl || this.options.params.rootUrl || '#' + this.model.entityType;
      const $name = $('<a>').attr('href', recordUrl).append($('<span>').addClass('font-size-flexible title').text(name));
      if (this.model.get('deleted')) {
        $name.css('text-decoration', 'line-through');
      }
      const $root = $('<span>').append($('<a>').attr('href', rootUrl).addClass('action').attr('data-action', 'navigateToRoot').text(scopeLabel));
      const headerIconHtml = this.getHeaderIconHtml();
      if (headerIconHtml) {
        $root.prepend(headerIconHtml);
      }
      const $field = $('<span>').text(fieldLabel);
      return this.buildHeaderHtml([$root, $name, $field]);
    }
  }
  var _default = _exports.default = AddressMapView;
});

define("views/action-history-record/record/list", ["exports", "views/record/list"], function (_exports, _list) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _list = _interopRequireDefault(_list);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _list.default {
    rowActionsView = 'views/record/row-actions/view-and-remove';
    massActionList = ['remove', 'export'];
  }
  _exports.default = _default;
});

define("views/action-history-record/modals/detail", ["exports", "views/modals/detail"], function (_exports, _detail) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _detail = _interopRequireDefault(_detail);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _detail.default {
    fullFormDisabled = true;
    editDisabled = true;
    sideDisabled = true;
  }
  _exports.default = _default;
});

define("views/action-history-record/fields/target", ["exports", "views/fields/link-parent"], function (_exports, _linkParent) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _linkParent = _interopRequireDefault(_linkParent);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ActionHistoryRecordTargetFieldView extends _linkParent.default {
    displayScopeColorInListMode = true;
    ignoreScopeList = ['Preferences', 'ExternalAccount', 'Notification', 'Note', 'ArrayValue'];
    setup() {
      super.setup();
      this.foreignScopeList = this.getMetadata().getScopeEntityList().filter(item => {
        if (!this.getUser().isAdmin() && !this.getAcl().checkScopeHasAcl(item)) {
          return false;
        }
        if (this.ignoreScopeList.includes(item)) {
          return false;
        }
        if (!this.getAcl().checkScope(item)) {
          return false;
        }
        return true;
      });
      this.getLanguage().sortEntityList(this.foreignScopeList);
      this.foreignScope = this.model.get(this.typeName) || this.foreignScopeList[0];
    }
  }
  var _default = _exports.default = ActionHistoryRecordTargetFieldView;
});

define("views/action-history-record/fields/target-type", ["exports", "views/fields/enum"], function (_exports, _enum) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _enum = _interopRequireDefault(_enum);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _enum.default {
    setupOptions() {
      super.setupOptions();
      this.params.options = this.getMetadata().getScopeEntityList();
    }
  }
  _exports.default = _default;
});

define("models/notification", ["exports", "model"], function (_exports, _model) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _model = _interopRequireDefault(_model);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class Notification extends _model.default {
    /**
     * @inheritDoc
     */
    constructor(attributes, options) {
      super(attributes, options);
      if (!options.url && this.attributes.groupType) {
        this.urlRoot = 'Notification/group';
      }
    }
    setMultiple(attributes, options) {
      attributes = {
        ...attributes
      };
      if (attributes.read !== undefined) {
        attributes.isNotRead = !attributes.read;
      }
      return super.setMultiple(attributes, options);
    }
  }
  _exports.default = Notification;
});

define("helpers/misc/list-select-attributes", ["exports"], function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module helpers/misc/stored-text-search */

  class _default {
    /**
     * @param {module:storage} storage
     * @param {string} scope
     * @param {Number} [maxCount]
     */
    constructor(scope, storage, maxCount) {
      this.scope = scope;
      this.storage = storage;
      this.key = 'textSearches';
      this.maxCount = maxCount || 100;
      /** @type {string[]|null} */
      this.list = null;
    }

    /**
     * Match.
     *
     * @param {string} text
     * @param {Number} [limit]
     * @return {string[]}
     */
    match(text, limit) {
      text = text.toLowerCase().trim();
      const list = this.get();
      const matchedList = [];
      for (const item of list) {
        if (item.toLowerCase().startsWith(text)) {
          matchedList.push(item);
        }
        if (limit !== undefined && matchedList.length === limit) {
          break;
        }
      }
      return matchedList;
    }

    /**
     * Get stored text filters.
     *
     * @private
     * @return {string[]}
     */
    get() {
      if (this.list === null) {
        this.list = this.getFromStorage();
      }
      return this.list;
    }

    /**
     * @private
     * @return {string[]}
     */
    getFromStorage() {
      /** @var {string[]} */
      return this.storage.get(this.key, this.scope) || [];
    }

    /**
     * Store a text filter.
     *
     * @param {string} text
     */
    store(text) {
      text = text.trim();
      let list = this.getFromStorage();
      const index = list.indexOf(text);
      if (index !== -1) {
        list.splice(index, 1);
      }
      list.unshift(text);
      if (list.length > this.maxCount) {
        list = list.slice(0, this.maxCount);
      }
      this.list = list;
      this.storage.set(this.key, this.scope, list);
    }

    /**
     * Remove a text filter.
     *
     * @param {string} text
     */
    remove(text) {
      text = text.trim();
      const list = this.getFromStorage();
      const index = list.indexOf(text);
      if (index === -1) {
        return;
      }
      list.splice(index, 1);
      this.list = list;
      this.storage.set(this.key, this.scope, list);
    }
  }
  _exports.default = _default;
});

define("helpers/misc/foreign-field-params", ["exports", "di", "metadata"], function (_exports, _di, _metadata) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _metadata = _interopRequireDefault(_metadata);
  var _staticBlock;
  let _init_metadata, _init_extra_metadata;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  /**
   * @since 9.1.1
   * @internal For future use.
   */
  class _Class {
    constructor() {
      _init_extra_metadata(this);
    }
    /**
     * @type {Metadata}
     * @private
     */
    metadata = _init_metadata(this);

    /**
     * Get foreign field params.
     *
     * @param {string} entityType
     * @param {string} field
     * @return {Record|null}
     */
    get(entityType, field) {
      /** @type {Record|null} */
      const params = this.metadata.get(`entityDefs.${entityType}.fields.${field}`);
      if (!params) {
        return null;
      }
      const foreignField = params.field;
      const link = params.link;
      const foreignEntityType = this.metadata.get(`entityDefs.${entityType}.links.${link}.entity`);
      if (!foreignEntityType) {
        return null;
      }
      return this.metadata.get(`entityDefs.${foreignEntityType}.links.${foreignField}`);
    }
    static #_ = _staticBlock = () => [_init_metadata, _init_extra_metadata] = _applyDecs(this, [], [[(0, _di.inject)(_metadata.default), 0, "metadata"]]).e;
  }
  _exports.default = _Class;
  _staticBlock();
});

define("helpers/misc/authentication-provider", ["exports"], function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /** @module module:helpers/misc/authentication-provider */

  class _default {
    /**
     * @param {module:views/record/detail} view A view.
     */
    constructor(view) {
      /**
       * @private
       * @type {module:views/record/detail}
       */
      this.view = view;
      this.metadata = view.getMetadata();

      /**
       * @private
       * @type {module:model}
       */
      this.model = view.model;

      /** @var {Object.<string, Object.<string, *>>} defs */
      const defs = view.getMetadata().get(['authenticationMethods']) || {};

      /**
       * @private
       * @type {string[]}
       */
      this.methodList = Object.keys(defs).filter(item => {
        /** @var {Object.<string, *>} */
        const data = defs[item].provider || {};
        return data.isAvailable;
      });

      /** @private */
      this.authFields = {};

      /** @private */
      this.dynamicLogicDefs = {
        fields: {},
        panels: {}
      };
    }

    /**
     * @param {function(): void} callback
     */
    setupPanelsVisibility(callback) {
      this.handlePanelsVisibility(callback);
      this.view.listenTo(this.model, 'change:method', () => this.handlePanelsVisibility(callback));
    }

    /**
     * @private
     * @param {string} method
     * @param {string} param
     * @return {*}
     */
    getFromMetadata(method, param) {
      return this.metadata.get(['authenticationMethods', method, 'provider', param]) || this.metadata.get(['authenticationMethods', method, 'settings', param]);
    }

    /**
     * @return {Object}
     */
    setupMethods() {
      this.methodList.forEach(method => this.setupMethod(method));
      return this.dynamicLogicDefs;
    }

    /**
     * @private
     */
    setupMethod(method) {
      /** @var {string[]} */
      let fieldList = this.getFromMetadata(method, 'fieldList') || [];
      fieldList = fieldList.filter(item => this.model.hasField(item));
      this.authFields[method] = fieldList;
      const mDynamicLogicFieldsDefs = (this.getFromMetadata(method, 'dynamicLogic') || {}).fields || {};
      for (const f in mDynamicLogicFieldsDefs) {
        if (!fieldList.includes(f)) {
          continue;
        }
        const defs = this.modifyDynamicLogic(mDynamicLogicFieldsDefs[f]);
        this.dynamicLogicDefs.fields[f] = Espo.Utils.cloneDeep(defs);
      }
    }

    /**
     * @private
     */
    modifyDynamicLogic(defs) {
      defs = Espo.Utils.clone(defs);
      if (Array.isArray(defs)) {
        return defs.map(item => this.modifyDynamicLogic(item));
      }
      if (typeof defs === 'object') {
        const o = {};
        for (const property in defs) {
          let value = defs[property];
          if (property === 'attribute' && value === 'authenticationMethod') {
            value = 'method';
          }
          o[property] = this.modifyDynamicLogic(value);
        }
        return o;
      }
      return defs;
    }
    modifyDetailLayout(layout) {
      this.methodList.forEach(method => {
        let mLayout = this.getFromMetadata(method, 'layout');
        if (!mLayout) {
          return;
        }
        mLayout = Espo.Utils.cloneDeep(mLayout);
        mLayout.name = method;
        this.prepareLayout(mLayout, method);
        layout.push(mLayout);
      });
    }
    prepareLayout(layout, method) {
      layout.rows.forEach(row => {
        row.filter(item => !item.noLabel && !item.labelText && item.name).forEach(item => {
          if (item === null) {
            return;
          }
          const labelText = this.view.translate(item.name, 'fields', 'Settings');
          item.options = item.options || {};
          if (labelText && labelText.toLowerCase().indexOf(method.toLowerCase() + ' ') === 0) {
            item.labelText = labelText.substring(method.length + 1);
          }
          item.options.tooltipText = this.view.translate(item.name, 'tooltips', 'Settings');
        });
      });
      layout.rows = layout.rows.map(row => {
        row = row.map(cell => {
          if (cell && cell.name && !this.model.hasField(cell.name)) {
            return false;
          }
          return cell;
        });
        return row;
      });
    }

    /**
     * @private
     * @param {function(): void} callback
     */
    handlePanelsVisibility(callback) {
      const authenticationMethod = this.model.get('method');
      this.methodList.forEach(method => {
        const fieldList = this.authFields[method] || [];
        if (method !== authenticationMethod) {
          this.view.hidePanel(method);
          fieldList.forEach(field => {
            this.view.hideField(field);
          });
          return;
        }
        this.view.showPanel(method);
        fieldList.forEach(field => this.view.showField(field));
        callback();
      });
    }
  }
  _exports.default = _default;
});

define("helpers/field/link-icon", ["exports"], function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * @since 9.3.1
   */
  class LinkFieldIconHelper {
    /**
     * @param {import('views/fields/link').default} view
     * @param {{
     *     iconClass: string,
     *     getIconClass: function(): string|null,
     *     getColor: function(): string,
     * }} options
     */
    constructor(view, options) {
      this.view = view;
      this.options = options;
      view.listenTo(view, 'after:render', () => {
        if (view.isEditMode()) {
          this.control();
        }
      });
      view.addHandler('keydown', `input[data-name="${view.nameName}"]`, (/** KeyboardEvent */e, target) => {
        if (e.code === 'Enter') {
          return;
        }
        target.classList.add('being-typed');
      });
      view.addHandler('change', `input[data-name="${view.nameName}"]`, (e, target) => {
        setTimeout(() => target.classList.remove('being-typed'), 200);
      });
      view.addHandler('blur', `input[data-name="${view.nameName}"]`, (e, target) => {
        target.classList.remove('being-typed');
      });
      view.on('change', () => {
        if (!view.isEditMode()) {
          return;
        }
        const span = view.element.querySelector('span.icon-in-input');
        if (span) {
          span.parentNode.removeChild(span);
        }
        setTimeout(() => this.control(), 0);
      });
    }

    /**
     * @private
     */
    control() {
      const view = this.view;
      const nameElement = view.element.querySelector(`input[data-name="${view.nameName}"]`);
      nameElement.classList.remove('being-typed');
      const icon = document.createElement('span');
      icon.className = 'icon-in-input ' + this.options.iconClass;
      icon.style.color = this.options.getColor();
      const iconClass = this.options.getIconClass();
      if (!iconClass) {
        return;
      }
      icon.className += ' ' + iconClass;
      const input = view.element.querySelector('.input-group > input');
      if (!input) {
        return;
      }
      input.after(icon);
    }
  }
  _exports.default = LinkFieldIconHelper;
});

define("handlers/working-time-range", ["exports", "bullbone"], function (_exports, _bullbone) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * @mixes Bull.Events
   */
  class WorkingTimeRangeHandler {
    constructor(view) {
      /** @type {module:views/record/edit} */
      this.view = view;
    }
    process() {
      this.listenTo(this.view.model, 'change:dateStart', (model, value, o) => {
        if (!o.ui || model.get('dateEnd')) {
          return;
        }
        setTimeout(() => model.set('dateEnd', value), 50);
      });
    }
  }
  Object.assign(WorkingTimeRangeHandler.prototype, _bullbone.Events);
  var _default = _exports.default = WorkingTimeRangeHandler;
});

define("handlers/select-field-relation", ["exports"], function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * @since 10.0.0
   */
  class SelectFieldRelationHandler {
    /**
     * @internal
     */

    /**
     * A parent model.
     */

    /**
     * @internal
     */
    constructor(viewHelper, model) {
      this.viewHelper = viewHelper;
      this.model = model;
    }

    /**
     * @inheritDoc
     */

    /**
     * @inheritDoc
     */
  }
  var _default = _exports.default = SelectFieldRelationHandler;
});

define("handlers/navbar-menu", ["exports", "action-handler"], function (_exports, _actionHandler) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _actionHandler = _interopRequireDefault(_actionHandler);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class NavbarMenuHandler extends _actionHandler.default {
    logout() {
      this.view.getRouter().logout();
    }

    // noinspection JSUnusedGlobalSymbols
    lastViewed() {
      Espo.Ui.notifyWait();
      this.view.createView('dialog', 'views/modals/last-viewed', {}, view => {
        view.render();
        Espo.Ui.notify(false);
      });
    }
  }
  var _default = _exports.default = NavbarMenuHandler;
});

define("handlers/import", ["exports", "action-handler"], function (_exports, _actionHandler) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _actionHandler = _interopRequireDefault(_actionHandler);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ImportHandler extends _actionHandler.default {
    // noinspection JSUnusedGlobalSymbols
    errorExport() {
      Espo.Ajax.postRequest(`Import/${this.view.model.id}/exportErrors`).then(data => {
        if (!data.attachmentId) {
          const message = this.view.translate('noErrors', 'messages', 'Import');
          Espo.Ui.warning(message);
          return;
        }
        window.location = this.view.getBasePath() + '?entryPoint=download&id=' + data.attachmentId;
      });
    }
  }
  var _default = _exports.default = ImportHandler;
});

define("handlers/email-filter", ["exports", "dynamic-handler"], function (_exports, _dynamicHandler) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _dynamicHandler = _interopRequireDefault(_dynamicHandler);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EmailFilterHandler extends _dynamicHandler.default {
    init() {
      if (this.model.isNew()) {
        if (!this.recordView.getUser().isAdmin()) {
          this.recordView.hideField('isGlobal');
        }
      }
      if (!this.model.isNew() && !this.recordView.getUser().isAdmin() && !this.model.get('isGlobal')) {
        this.recordView.hideField('isGlobal');
      }
      if (this.model.isNew() && !this.model.get('parentId')) {
        this.model.set('parentType', 'User');
        this.model.set('parentId', this.recordView.getUser().id);
        this.model.set('parentName', this.recordView.getUser().get('name'));
        if (!this.recordView.getUser().isAdmin()) {
          this.recordView.setFieldReadOnly('parent');
        }
      } else if (this.model.get('parentType') && !this.recordView.options.duplicateSourceId) {
        this.recordView.setFieldReadOnly('parent');
        this.recordView.setFieldReadOnly('isGlobal');
      }
      this.recordView.listenTo(this.model, 'change:isGlobal', (model, value, o) => {
        if (!o.ui) {
          return;
        }
        if (value) {
          this.model.set({
            action: 'Skip',
            parentName: null,
            parentType: null,
            parentId: null,
            emailFolderId: null,
            groupEmailFolderId: null,
            markAsRead: false
          });
        }
      });
      this.recordView.listenTo(this.model, 'change:parentType', (model, value, o) => {
        if (!o.ui) {
          return;
        }

        // Avoiding side effects.
        setTimeout(() => {
          if (value !== 'User') {
            this.model.set('markAsRead', false);
          }
          if (value === 'EmailAccount') {
            this.model.set('action', 'Skip');
            this.model.set('emailFolderId', null);
            this.model.set('groupEmailFolderId', null);
            this.model.set('markAsRead', false);
            return;
          }
          if (value !== 'InboundEmail') {
            if (this.model.get('action') === 'Move to Group Folder') {
              this.model.set('action', 'Skip');
            }
            this.model.set('groupEmailFolderId', null);
            return;
          }
          if (value !== 'User') {
            if (this.model.get('action') === 'Move to Folder') {
              this.model.set('action', 'Skip');
            }
            this.model.set('groupFolderId', null);
          }
        }, 40);
      });
    }
  }
  var _default = _exports.default = EmailFilterHandler;
});

define("handlers/user/select-contact", ["exports", "handlers/select-related"], function (_exports, _selectRelated) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _selectRelated = _interopRequireDefault(_selectRelated);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _selectRelated.default {
    /**
     * @param {import('model').default} model
     */
    async getFilters(model) {
      /** @type {string[]|null} */
      const accountIds = model.attributes.accountsIds;
      if (accountIds && accountIds.length) {
        return {
          advanced: {
            accounts: {
              field: 'accounts',
              type: 'linkedWith',
              value: accountIds,
              data: {
                nameHash: model.attributes.accountsNames || {}
              }
            }
          }
        };
      }
      return {};
    }
  }
  _exports.default = _default;
});

define("handlers/user/change-team-position-row-action", ["exports", "handlers/row-action", "views/user/modals/select-position"], function (_exports, _rowAction, _selectPosition) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _rowAction = _interopRequireDefault(_rowAction);
  _selectPosition = _interopRequireDefault(_selectPosition);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  // noinspection JSUnusedGlobalSymbols
  class ChangeUserTeamPositionRowActionHandler extends _rowAction.default {
    async process(model, action) {
      if (!model.collection || !model.collection.parentModel) {
        console.error(`Team model cannot be obtained.`);
        return;
      }
      const team = model.collection.parentModel;

      /** @type {string[]} */
      const positionList = team.attributes.positionList || [];
      const position = model.attributes.teamRole;
      const view = new _selectPosition.default({
        position: position,
        positionList: positionList,
        name: model.attributes.name,
        onApply: position => {
          this.savePosition(team.id, model, position);
        }
      });
      await this.view.assignView('dialog', view);
      await view.render();
    }
    isAvailable(model, action) {
      if (!model.collection || !model.collection.parentModel) {
        return false;
      }
      if (!this.view.getAcl().checkModel(model, 'edit')) {
        return false;
      }
      if (!this.view.getUser().isAdmin()) {
        return false;
      }
      return true;
    }

    /**
     * @private
     * @param {string} teamId
     * @param {import('model').default} model
     * @param {string|null} position
     */
    async savePosition(teamId, model, position) {
      Espo.Ui.notifyWait();
      await Espo.Ajax.putRequest(`Team/${teamId}/userPosition`, {
        id: model.id,
        position: position
      });
      model.setMultiple({
        teamRole: position
      });
      Espo.Ui.success(this.view.translate('Saved'));
    }
  }
  _exports.default = ChangeUserTeamPositionRowActionHandler;
});

define("handlers/select-related/same-account", ["exports", "handlers/select-related"], function (_exports, _selectRelated) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _selectRelated = _interopRequireDefault(_selectRelated);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class SameAccountSelectRelatedHandler extends _selectRelated.default {
    /**
     * @param {module:model} model
     * @return {Promise<module:handlers/select-related~filters>}
     */
    getFilters(model) {
      const advanced = {};
      let accountId = null;
      let accountName = null;
      if (model.get('accountId')) {
        accountId = model.get('accountId');
        accountName = model.get('accountName');
      }
      if (!accountId && model.get('parentType') === 'Account' && model.get('parentId')) {
        accountId = model.get('parentId');
        accountName = model.get('parentName');
      }
      if (accountId) {
        advanced.account = {
          attribute: 'accountId',
          type: 'equals',
          value: accountId,
          data: {
            type: 'is',
            nameValue: accountName
          }
        };
      }
      return Promise.resolve({
        advanced: advanced
      });
    }
  }

  // noinspection JSUnusedGlobalSymbols
  var _default = _exports.default = SameAccountSelectRelatedHandler;
});

define("handlers/select-related/same-account-many", ["exports", "handlers/select-related"], function (_exports, _selectRelated) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _selectRelated = _interopRequireDefault(_selectRelated);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class SameAccountManySelectRelatedHandler extends _selectRelated.default {
    /**
     * @param {module:model} model
     * @return {Promise<module:handlers/select-related~filters>}
     */
    getFilters(model) {
      const advanced = {};
      let accountId = null;
      let accountName = null;
      if (model.get('accountId')) {
        accountId = model.get('accountId');
        accountName = model.get('accountName');
      }
      if (!accountId && model.get('parentType') === 'Account' && model.get('parentId')) {
        accountId = model.get('parentId');
        accountName = model.get('parentName');
      }
      if (accountId) {
        const nameHash = {};
        nameHash[accountId] = accountName;
        advanced.accounts = {
          field: 'accounts',
          type: 'linkedWith',
          value: [accountId],
          data: {
            nameHash: nameHash
          }
        };
      }
      return Promise.resolve({
        advanced: advanced
      });
    }
  }

  // noinspection JSUnusedGlobalSymbols
  var _default = _exports.default = SameAccountManySelectRelatedHandler;
});

define("handlers/record/view-user-access", ["exports", "views/modals/related-list"], function (_exports, _relatedList) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _relatedList = _interopRequireDefault(_relatedList);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default {
    toShow;
    constructor(/** import('views/record/detail').default */view) {
      this.view = view;
      this.metadata = /** @type {module:metadata} */view.getMetadata();
      this.entityType = this.view.entityType;
      this.model = this.view.model;
      const level = this.view.getAcl().getPermissionLevel('user');
      this.toShow = (level === 'all' || level === 'team') && (this.metadata.get(`scopes.${this.entityType}.object`) || this.metadata.get(`scopes.${this.entityType}.acl`));
      this.view.getAcl().checkScope('User');
    }
    isAvailable() {
      return this.toShow;
    }
    async show() {
      const actionList = this.getActionList();

      /** @type {Record[]} */
      const listLayout = [{
        name: 'name',
        link: true,
        view: 'views/user/fields/name'
      }];

      //const width = Math.round((100.0 - 40) / (actionList.length + 1));

      actionList.forEach(action => {
        listLayout.push({
          name: 'recordAccessLevel' + action,
          customLabel: this.view.translate(action, 'recordActions'),
          view: 'views/user/fields/record-access-level',
          notSortable: true,
          width: 16
        });
      });
      const view = new _relatedList.default({
        model: this.model,
        link: 'usersAccess',
        entityType: 'User',
        title: this.view.translate('View User Access'),
        url: `${this.entityType}/${this.model.id}/usersAccess`,
        createDisabled: true,
        selectDisabled: true,
        massActionsDisabled: true,
        maxSize: this.view.getConfig().get('recordsPerPageSmall'),
        rowActionsView: null,
        listLayout: listLayout,
        filter: 'active'
      });
      await this.view.assignView('dialog', view);
      await view.render();
    }

    /**
     * @private
     * @return {string[]}
     */
    getActionList() {
      /** @type {string[]} */
      let actionList = this.metadata.get(`scopes.${this.entityType}.aclActionList`);
      if (!actionList) {
        actionList = ['read', 'edit', 'delete'];
        if (this.metadata.get(`scopes.${this.entityType}.stream`)) {
          actionList.push('stream');
        }
      }
      return actionList.filter(it => it !== 'create');
    }
  }
  _exports.default = _default;
});

define("handlers/record/view-audit-log", ["exports", "views/stream/modals/view-audit-log"], function (_exports, _viewAuditLog) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _viewAuditLog = _interopRequireDefault(_viewAuditLog);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ViewAuditLogHandler {
    constructor(/** import('views/record/detail').default */view) {
      this.view = view;
      this.metadata = /** @type {module:metadata} */view.getMetadata();
      this.entityType = this.view.entityType;
      this.model = /** @type {module:model} */this.view.model;
      this.hasAudited = this.metadata.get(`scopes.${this.entityType}.statusField`) || this.model.getFieldList().find(field => this.model.getFieldParam(field, 'audited')) !== undefined;
      if (this.entityType === 'User' && !this.view.getUser().isAdmin()) {
        this.hasAudited = false;
      }
      if (this.view.getUser().isPortal()) {
        this.hasAudited = false;
      }
      if (this.view.getAcl().getPermissionLevel('audit') !== 'yes') {
        this.hasAudited = false;
      }
    }
    isAvailable() {
      return this.hasAudited;
    }
    show() {
      const view = new _viewAuditLog.default({
        model: this.model
      });
      this.view.assignView('dialog', view).then(() => {
        view.render();
      });
    }
  }

  // noinspection JSUnusedGlobalSymbols
  var _default = _exports.default = ViewAuditLogHandler;
});

define("handlers/record/pipeline-view-setup", ["exports", "di", "metadata", "app-params", "helpers/misc/pipelines"], function (_exports, _di, _metadata, _appParams, _pipelines) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _metadata = _interopRequireDefault(_metadata);
  _appParams = _interopRequireDefault(_appParams);
  _pipelines = _interopRequireDefault(_pipelines);
  var _staticBlock;
  let _init_metadata, _init_extra_metadata, _init_appParams, _init_extra_appParams;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  // noinspection JSUnusedGlobalSymbols
  class PipelineViewSetupHandler {
    /**
     * @private
     * @type {Metadata}
     */
    metadata = _init_metadata(this);

    /**
     * @private
     * @type {import('model').default}
     */
    model = void _init_extra_metadata(this);

    /**
     * @private
     * @type {import('views/record/detail').default}
     */
    view;

    /**
     * @private
     * @type {AppParams}
     */
    appParams = _init_appParams(this);

    /**
     * @private
     * @type {{id: string, stages: {id: string, name: string, style: string|null}[]}[]}
     */
    pipelines = void _init_extra_appParams(this);

    /**
     * @param {import('views/record/detail').default} view
     */
    constructor(view) {
      this.view = view;
      this.model = view.model;
    }
    process() {
      const entityType = this.model.entityType;
      if (this.metadata.get(`scopes.${entityType}.pipelines`) !== true) {
        return;
      }
      this.pipelines = new _pipelines.default().get(entityType);
      this.model.onChange({
        owner: this.view,
        attributes: ['pipelineId'],
        callback: o => {
          if (!o.ui) {
            return;
          }
          setTimeout(() => this.updateStage(), 1);
        }
      });
    }

    /**
     * @private
     */
    updateStage() {
      const pipelineId = this.model.attributes.pipelineId;
      if (!pipelineId) {
        this.setStageNull();
        return;
      }
      const pipeline = this.pipelines.find(it => it.id === pipelineId);
      if (!pipeline) {
        this.setStageNull();
        return;
      }
      const stage = pipeline.stages[0];
      if (!stage) {
        this.setStageNull();
        return;
      }
      this.model.setMultiple({
        pipelineStageId: stage.id,
        pipelineStageName: stage.name
      });
      this.model.trigger('pipeline-changed');
    }

    /**
     * @private
     */
    setStageNull() {
      this.model.setMultiple({
        pipelineStageId: null,
        pipelineStageName: null
      });
      this.model.trigger('pipeline-changed');
    }
    static #_ = _staticBlock = () => [_init_metadata, _init_extra_metadata, _init_appParams, _init_extra_appParams] = _applyDecs(this, [], [[(0, _di.inject)(_metadata.default), 0, "metadata"], [(0, _di.inject)(_appParams.default), 0, "appParams"]]).e;
  }
  _exports.default = PipelineViewSetupHandler;
  _staticBlock();
});

define("handlers/record/lock-view-setup", ["exports", "di", "metadata", "helpers/assignment"], function (_exports, _di, _metadata, _assignment) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _metadata = _interopRequireDefault(_metadata);
  _assignment = _interopRequireDefault(_assignment);
  var _staticBlock;
  let _init_metadata, _init_extra_metadata;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  // noinspection JSUnusedGlobalSymbols
  class LockViewSetup {
    /**
     * @private
     * @type {Metadata}
     */
    metadata = _init_metadata(this);

    /**
     * @private
     * @type {import('model').default}
     */
    model = void _init_extra_metadata(this);

    /**
     * @private
     * @type {import('views/record/detail').default}
     */
    view;
    ignoreFieldList = ['isLocked', 'modifiedAt', 'modifiedBy', 'streamUpdatedAt'];

    /**
     * @param {import('views/record/detail').default} view
     */
    constructor(view) {
      this.view = view;
      this.model = view.model;
    }
    process() {
      const entityType = this.model.entityType;
      if (this.metadata.get(`scopes.${entityType}.lockable`) !== true) {
        return;
      }
      let wasLocked = false;
      const lockedMap = {};
      const ignoreFieldList = this.getIgnoreFieldList();
      const fieldsDefs = /** @type {Record.<string, Record>} */
      this.metadata.get(`entityDefs.${entityType}.fields`) ?? {};
      const lockableFields = Object.keys(fieldsDefs).filter(field => {
        if (ignoreFieldList.includes(field)) {
          return false;
        }
        const defs = fieldsDefs[field];
        return !defs.notLockable && !defs.readOnly && !defs.readOnlyAfterCreate;
      });
      const controlLocked = () => {
        const isLocked = this.model.attributes.isLocked;
        if (!isLocked && !wasLocked) {
          return;
        }
        if (isLocked) {
          wasLocked = true;
        }
        lockableFields.forEach(field => {
          if (isLocked) {
            if (this.view.recordHelper && this.view.recordHelper.getFieldStateParam(field, 'readOnly')) {
              return;
            }
            lockedMap[field] = true;
            this.view.setFieldReadOnly(field);
            return;
          }
          if (!lockedMap[field]) {
            return;
          }
          delete lockedMap[field];
          this.view.setFieldNotReadOnly(field);
        });
      };
      controlLocked();
      this.view.listenTo(this.model, 'change:isLocked', () => controlLocked());
    }

    /**
     * @private
     * @return {string[]}
     */
    getIgnoreFieldList() {
      const entityType = this.model.entityType;
      const ignoreFieldList = [...this.ignoreFieldList];
      const helper = new _assignment.default();
      if (helper.hasCollaboratorsField(entityType)) {
        if (helper.hasAssignedUsersField(entityType)) {
          if (this.model.getFieldParam('assignedUsers', 'notLockable')) {
            ignoreFieldList.push('collaborators');
          }
        } else if (helper.hasAssignedUserField(entityType)) {
          if (this.model.getFieldParam('assignedUser', 'notLockable')) {
            ignoreFieldList.push('collaborators');
          }
        }
      }
      return ignoreFieldList;
    }
    static #_ = _staticBlock = () => [_init_metadata, _init_extra_metadata] = _applyDecs(this, [], [[(0, _di.inject)(_metadata.default), 0, "metadata"]]).e;
  }
  _exports.default = LockViewSetup;
  _staticBlock();
});

define("handlers/record/lock-mass-action", ["exports", "action-handler", "di", "acl-manager", "language", "helpers/mass-action", "metadata"], function (_exports, _actionHandler, _di, _aclManager, _language, _massAction, _metadata) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _actionHandler = _interopRequireDefault(_actionHandler);
  _aclManager = _interopRequireDefault(_aclManager);
  _language = _interopRequireDefault(_language);
  _massAction = _interopRequireDefault(_massAction);
  _metadata = _interopRequireDefault(_metadata);
  var _staticBlock;
  let _init_acl, _init_extra_acl, _init_language, _init_extra_language, _init_metadata, _init_extra_metadata;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  // noinspection JSUnusedGlobalSymbols
  class LockMassActionHandler extends _actionHandler.default {
    constructor() {
      super(...arguments);
      _init_extra_metadata(this);
    }
    /**
     * @type {AclManager}
     */
    acl = _init_acl(this);

    /**
     * @type {Language}
     */
    language = (_init_extra_acl(this), _init_language(this));

    /**
     * @type {Metadata}
     */
    metadata = (_init_extra_language(this), _init_metadata(this));

    // noinspection JSUnusedGlobalSymbols
    async actionLock() {
      const msg = this.language.translate('confirmMassLock', 'messages');
      await this.view.confirm(msg);
      await this.process('lock');
    }

    // noinspection JSUnusedGlobalSymbols
    async actionUnlock() {
      const msg = this.language.translate('confirmMassUnlock', 'messages');
      await this.view.confirm(msg);
      await this.process('unlock');
    }

    /**
     * @private
     * @param {string} action
     */
    async process(action) {
      const helper = new _massAction.default(this.view);
      const params = this.view.getMassActionSelectionPostData();
      const idle = !!params.searchParams && helper.checkIsIdle(this.view.collection.total);
      const onDone = count => {
        const labelKey = action === 'lock' ? 'massLockDone' : 'massUnlockDone';
        const msg = this.view.translate(labelKey, 'messages').replace('{count}', count.toString());
        Espo.Ui.success(msg);
      };
      Espo.Ui.notifyWait();
      const result = await Espo.Ajax.postRequest('MassAction', {
        entityType: this.view.entityType,
        action: action,
        params: params,
        idle: idle
      });
      if (result.id) {
        const view = await helper.process(result.id, action);
        this.view.listenToOnce(view, 'close:success', result => onDone(result.count));
        return;
      }
      onDone(result.count);
    }

    // noinspection JSUnusedGlobalSymbols
    initLock() {
      if (!this.view.collection || !this.isEnabled(this.view.collection.entityType) || this.acl.getPermissionLevel('massUpdate') !== 'yes' || this.acl.getPermissionLevel('lock') !== 'yes') {
        this.view.removeMassAction('lock');
      }
    }

    // noinspection JSUnusedGlobalSymbols
    initUnlock() {
      if (!this.view.collection || !this.isEnabled(this.view.collection.entityType) || this.acl.getPermissionLevel('massUpdate') !== 'yes' || this.acl.getPermissionLevel('lock') !== 'yes') {
        this.view.removeMassAction('unlock');
      }
    }

    /**
     * @private
     * @param {string} entityType
     * @return {boolean}
     */
    isEnabled(entityType) {
      return this.metadata.get(`scopes.${entityType}.lockable`) === true;
    }
    static #_ = _staticBlock = () => [_init_acl, _init_extra_acl, _init_language, _init_extra_language, _init_metadata, _init_extra_metadata] = _applyDecs(this, [], [[(0, _di.inject)(_aclManager.default), 0, "acl"], [(0, _di.inject)(_language.default), 0, "language"], [(0, _di.inject)(_metadata.default), 0, "metadata"]], 0, void 0, _actionHandler.default).e;
  }
  _exports.default = LockMassActionHandler;
  _staticBlock();
});

define("handlers/record/lock-action", ["exports", "action-handler", "di", "acl-manager", "metadata"], function (_exports, _actionHandler, _di, _aclManager, _metadata) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _actionHandler = _interopRequireDefault(_actionHandler);
  _aclManager = _interopRequireDefault(_aclManager);
  _metadata = _interopRequireDefault(_metadata);
  var _staticBlock;
  let _init_acl, _init_extra_acl, _init_metadata, _init_extra_metadata;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  // noinspection JSUnusedGlobalSymbols
  class LockActionHandler extends _actionHandler.default {
    constructor() {
      super(...arguments);
      _init_extra_metadata(this);
    }
    /**
     * @type {AclManager}
     */
    acl = _init_acl(this);

    /**
     * @type {Metadata}
     */
    metadata = (_init_extra_acl(this), _init_metadata(this));
    async actionLock() {
      const model = this.view.model;
      Espo.Ui.notifyWait();
      let attributes;
      try {
        attributes = await Espo.Ajax.postRequest('Action', {
          action: 'lock',
          entityType: model.entityType,
          id: model.id
        });
      } catch (e) {
        return;
      }
      model.setMultiple(attributes, {
        sync: true
      });
      model.trigger('sync', this.model, null, {});
      Espo.Ui.success(this.view.translate('locked', 'messages'));
    }
    async actionUnlock() {
      const model = this.view.model;
      Espo.Ui.notifyWait();
      let attributes;
      try {
        attributes = await Espo.Ajax.postRequest('Action', {
          action: 'unlock',
          entityType: model.entityType,
          id: model.id
        });
      } catch (e) {
        return;
      }
      model.setMultiple(attributes, {
        sync: true
      });
      model.trigger('sync', this.model, null, {});
      Espo.Ui.success(this.view.translate('unlocked', 'messages'));
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * @return {boolean}
     */
    canBeLocked() {
      const model = this.view.model;
      if (!this.isEnabled(model.entityType)) {
        return false;
      }
      if (this.acl.getPermissionLevel('lock') !== 'yes') {
        return false;
      }
      if (model.attributes.isLocked) {
        return false;
      }
      return true;
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * @return {boolean}
     */
    canBeUnlocked() {
      const model = this.view.model;
      if (!this.isEnabled(model.entityType)) {
        return false;
      }
      if (this.acl.getPermissionLevel('lock') !== 'yes') {
        return false;
      }
      if (!model.attributes.isLocked) {
        return false;
      }
      return true;
    }

    /**
     * @private
     * @param {string} entityType
     * @return {boolean}
     */
    isEnabled(entityType) {
      return this.metadata.get(`scopes.${entityType}.lockable`) === true;
    }
    static #_ = _staticBlock = () => [_init_acl, _init_extra_acl, _init_metadata, _init_extra_metadata] = _applyDecs(this, [], [[(0, _di.inject)(_aclManager.default), 0, "acl"], [(0, _di.inject)(_metadata.default), 0, "metadata"]], 0, void 0, _actionHandler.default).e;
  }
  _exports.default = LockActionHandler;
  _staticBlock();
});

define("handlers/pipeline-stage/move-row-action", ["exports", "handlers/row-action"], function (_exports, _rowAction) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _rowAction = _interopRequireDefault(_rowAction);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class PipelineStageMoveRowActionHandler extends _rowAction.default {
    isAvailable(model, action) {
      const collection = model.collection;
      if (!collection) {
        return false;
      }
      if (action === 'moveUp') {
        if (collection.indexOf(model) <= 0) {
          return false;
        }
        const index = collection.models.findIndex(m => m === model);
        const prevModel = this.collection.at(index - 1);
        if (!prevModel || prevModel.attributes.mappedStatus !== model.attributes.mappedStatus) {
          return false;
        }
      }
      if (action === 'moveDown') {
        if (collection.indexOf(model) >= collection.total - 1) {
          return false;
        }
        const index = collection.models.findIndex(m => m === model);
        const nextModel = this.collection.at(index + 1);
        if (!nextModel || nextModel.attributes.mappedStatus !== model.attributes.mappedStatus) {
          return false;
        }
      }
      return collection.orderBy === 'order' && collection.order === 'asc';
    }
    async process(model, action) {
      let type;
      if (action === 'moveUp') {
        type = 'up';
      } else if (action === 'moveDown') {
        type = 'down';
      } else {
        throw new Error();
      }
      Espo.Ui.notifyWait();
      await Espo.Ajax.postRequest(`${model.entityType}/${model.id}/move/${type}`, {
        whereGroup: this.collection.getWhere()
      });
      await this.collection.fetch();
      Espo.Ui.notify();
    }
  }
  _exports.default = PipelineStageMoveRowActionHandler;
});

define("handlers/pipeline/move-row-action", ["exports", "handlers/row-action"], function (_exports, _rowAction) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _rowAction = _interopRequireDefault(_rowAction);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class PipelineMoveRowActionHandler extends _rowAction.default {
    isAvailable(model, action) {
      const collection = model.collection;
      if (!collection) {
        return false;
      }
      if (action === 'moveToTop' || action === 'moveUp') {
        if (collection.indexOf(model) <= 0) {
          return false;
        }
      }
      if (action === 'moveToBottom' || action === 'moveDown') {
        if (collection.indexOf(model) >= collection.total - 1) {
          return false;
        }
      }
      return collection.orderBy === 'order' && collection.order === 'asc';
    }
    async process(model, action) {
      let type;
      if (action === 'moveToTop') {
        type = 'top';
      } else if (action === 'moveToBottom') {
        type = 'bottom';
      } else if (action === 'moveUp') {
        type = 'up';
      } else if (action === 'moveDown') {
        type = 'down';
      } else {
        throw new Error();
      }
      Espo.Ui.notifyWait();
      await Espo.Ajax.postRequest(`${model.entityType}/${model.id}/move/${type}`, {
        whereGroup: this.collection.getWhere()
      });
      await this.collection.fetch();
      Espo.Ui.notify();
    }
  }
  _exports.default = PipelineMoveRowActionHandler;
});

define("handlers/note/record-detail-setup", ["exports"], function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default {
    /**
     * @param {import('views/record/detail').default} view
     */
    constructor(view) {
      this.view = view;
    }
    process() {
      this.controlFields();
      this.view.listenTo(this.view.model, 'sync', () => this.controlFields());
    }
    controlFields() {
      const attachmentsIds = this.view.model.attributes.attachmentsIds;
      if (!attachmentsIds || !attachmentsIds.length) {
        this.view.hideField('attachments');
        return;
      }
      this.view.showField('attachments');
    }
  }
  _exports.default = _default;
});

define("handlers/map/google-maps-renderer", ["exports", "handlers/map/renderer"], function (_exports, _renderer) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _renderer = _interopRequireDefault(_renderer);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class GoogleMapsRenderer extends _renderer.default {
    /**
     * @param {module:handlers/map/renderer~addressData} addressData
     */
    render(addressData) {
      if ('google' in window && window.google.maps) {
        this.initMapGoogle(addressData);
        return;
      }

      // noinspection SpellCheckingInspection
      if (typeof window.mapapiloaded === 'function') {
        // noinspection SpellCheckingInspection
        const mapapiloaded = window.mapapiloaded;

        // noinspection SpellCheckingInspection
        window.mapapiloaded = () => {
          this.initMapGoogle(addressData);
          mapapiloaded();
        };
        return;
      }

      // noinspection SpellCheckingInspection
      window.mapapiloaded = () => this.initMapGoogle(addressData);
      let src = 'https://maps.googleapis.com/maps/api/js?callback=mapapiloaded&loading=async&v=weekly&libraries=marker';
      const apiKey = this.view.getConfig().get('googleMapsApiKey');
      if (apiKey) {
        src += '&key=' + apiKey;
      }
      const scriptElement = document.createElement('script');
      scriptElement.setAttribute('defer', 'defer');
      scriptElement.src = src;
      document.head.appendChild(scriptElement);
    }

    /**
     * @param {module:handlers/map/renderer~addressData} addressData
     */
    initMapGoogle(addressData) {
      // noinspection JSUnresolvedReference
      const geocoder = new google.maps.Geocoder();
      let map;
      const mapId = this.view.getConfig().get('googleMapsMapId') || 'DEMO_MAP_ID';
      try {
        // noinspection SpellCheckingInspection,JSUnresolvedReference
        map = new google.maps.Map(this.view.$el.find('.map').get(0), {
          zoom: 15,
          center: {
            lat: 0,
            lng: 0
          },
          scrollwheel: false,
          mapId: mapId
        });
      } catch (e) {
        console.error(e.message);
        return;
      }
      let address = '';
      if (addressData.street) {
        address += addressData.street;
      }
      if (addressData.city) {
        if (address !== '') {
          address += ', ';
        }
        address += addressData.city;
      }
      if (addressData.state) {
        if (address !== '') {
          address += ', ';
        }
        address += addressData.state;
      }
      if (addressData.postalCode) {
        if (addressData.state || addressData.city) {
          address += ' ';
        } else {
          if (address) {
            address += ', ';
          }
        }
        address += addressData.postalCode;
      }
      if (addressData.country) {
        if (address !== '') {
          address += ', ';
        }
        address += addressData.country;
      }

      // noinspection JSUnresolvedReference
      geocoder.geocode({
        'address': address
      }, (results, status) => {
        // noinspection JSUnresolvedReference
        if (status === google.maps.GeocoderStatus.OK) {
          // noinspection JSUnresolvedReference
          map.setCenter(results[0].geometry.location);

          // noinspection JSUnresolvedReference
          new google.maps.marker.AdvancedMarkerElement({
            map: map,
            position: results[0].geometry.location
          });
        }
      });
    }
  }

  // noinspection JSUnusedGlobalSymbols
  var _default = _exports.default = GoogleMapsRenderer;
});

define("handlers/login/oidc", ["exports", "handlers/login", "js-base64"], function (_exports, _login, _jsBase) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _login = _interopRequireDefault(_login);
  _jsBase = _interopRequireDefault(_jsBase);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class OidcLoginHandler extends _login.default {
    /** @inheritDoc */
    process() {
      const proxy = window.open('about:blank', 'ConnectWithOAuth', 'location=0,status=0,width=800,height=800');
      Espo.Ui.notifyWait();
      return new Promise((resolve, reject) => {
        Espo.Ajax.getRequest('Oidc/authorizationData').then(data => {
          Espo.Ui.notify(false);
          this.processWithData(data, proxy).then(info => {
            const code = info.code;
            const nonce = info.nonce;
            const authString = _jsBase.default.encode('**oidc:' + code);
            const headers = {
              'Espo-Authorization': authString,
              'Authorization': 'Basic ' + authString,
              'X-Oidc-Authorization-Nonce': nonce
            };
            resolve(headers);
          }).catch(() => {
            proxy.close();
            reject();
          });
        }).catch(() => {
          Espo.Ui.notify(false);
          proxy.close();
          reject();
        });
      });
    }

    /**
     * @private
     * @param {{
     *  endpoint: string,
     *  clientId: string,
     *  redirectUri: string,
     *  scopes: string[],
     *  claims: string|null,
     *  prompt: 'login'|'consent'|'select_account',
     *  maxAge: Number|null,
     *  codeChallenge: string|null,
     *  codeChallengeMethod: string|null
     * }} data
     * @param {WindowProxy} proxy
     * @return {Promise<{code: string, nonce: string}>}
     */
    processWithData(data, proxy) {
      const state = (Math.random() + 1).toString(36).substring(4);
      const nonce = (Math.random() + 1).toString(36).substring(4);
      const params = {
        client_id: data.clientId,
        redirect_uri: data.redirectUri,
        response_type: 'code',
        scope: data.scopes.join(' '),
        state: state,
        nonce: nonce,
        prompt: data.prompt
      };
      if (data.codeChallenge && data.codeChallengeMethod) {
        params.code_challenge = data.codeChallenge;
        params.code_challenge_method = data.codeChallengeMethod;
      }
      if (data.maxAge || data.maxAge === 0) {
        params.max_age = data.maxAge;
      }
      if (data.claims) {
        params.claims = data.claims;
      }
      const partList = Object.entries(params).map(_ref => {
        let [key, value] = _ref;
        return key + '=' + encodeURIComponent(value);
      });
      const url = data.endpoint + '?' + partList.join('&');
      return this.processWindow(url, state, nonce, proxy);
    }

    /**
     * @private
     * @param {string} url
     * @param {string} state
     * @param {string} nonce
     * @param {WindowProxy} proxy
     * @return {Promise<{code: string, nonce: string}>}
     */
    processWindow(url, state, nonce, proxy) {
      proxy.location.href = url;
      return new Promise((resolve, reject) => {
        const fail = () => {
          window.clearInterval(interval);
          if (!proxy.closed) {
            proxy.close();
          }
          reject();
        };
        const interval = window.setInterval(() => {
          if (proxy.closed) {
            fail();
            return;
          }
          let url;
          try {
            url = proxy.location.href;
          } catch (e) {
            return;
          }
          if (!url) {
            return;
          }
          const parsedData = this.parseWindowUrl(url);
          if (!parsedData) {
            fail();
            Espo.Ui.error('Could not parse URL', true);
            return;
          }
          if ((parsedData.error || parsedData.code) && parsedData.state !== state) {
            fail();
            Espo.Ui.error('State mismatch', true);
            return;
          }
          if (parsedData.error) {
            fail();
            const message = parsedData.errorDescription || this.loginView.translate('Error') + '\n' + parsedData.error;
            Espo.Ui.error(message, true);
            console.log(parsedData);
            return;
          }
          if (parsedData.code) {
            window.clearInterval(interval);
            proxy.close();
            resolve({
              code: parsedData.code,
              nonce: nonce
            });
          }
        }, 300);
      });
    }

    /**
     * @param {string} url
     * @return {?{
     *     code: ?string,
     *     state: ?string,
     *     error: ?string,
     *     errorDescription: ?string,
     * }}
     */
    parseWindowUrl(url) {
      try {
        const params = new URL(url).searchParams;
        return {
          code: params.get('code'),
          state: params.get('state'),
          error: params.get('error'),
          errorDescription: params.get('errorDescription')
        };
      } catch (e) {
        return null;
      }
    }
  }
  var _default = _exports.default = OidcLoginHandler;
});

define("handlers/lead-capture/record-detail-view-setup", ["exports", "di", "metadata"], function (_exports, _di, _metadata) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _metadata = _interopRequireDefault(_metadata);
  var _staticBlock;
  let _init_metadata, _init_extra_metadata;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  class LeadCaptureRecordDetailViewSetupHandler {
    /**
     * @private
     * @type {Metadata}
     */
    metadata = _init_metadata(this);

    /**
     * @param {import('views/record/detail').default} view
     */
    constructor(view) {
      _init_extra_metadata(this);
      this.view = view;
    }
    process() {
      if (!this.metadata.get(`scopes.Lead.pipelines`)) {
        this.view.hideField('pipeline', true);
      }
    }
    static #_ = _staticBlock = () => [_init_metadata, _init_extra_metadata] = _applyDecs(this, [], [[(0, _di.inject)(_metadata.default), 0, "metadata"]]).e;
  }
  _exports.default = LeadCaptureRecordDetailViewSetupHandler;
  _staticBlock();
});

define("handlers/lead-capture/pipeline-select-handler", ["exports", "handlers/select-related"], function (_exports, _selectRelated) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _selectRelated = _interopRequireDefault(_selectRelated);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  // noinspection JSUnusedGlobalSymbols
  class _default extends _selectRelated.default {
    async getFilters(model) {
      return {
        advanced: {
          entityType: {
            type: 'in',
            attribute: 'entityType',
            value: ['Lead']
          }
        }
      };
    }
  }
  _exports.default = _default;
});

define("handlers/email-account/reset-fetch-data-action", ["exports", "action-handler", "di", "language", "views/email-account/modals/reset-fetch-data"], function (_exports, _actionHandler, _di, _language, _resetFetchData) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _actionHandler = _interopRequireDefault(_actionHandler);
  _language = _interopRequireDefault(_language);
  _resetFetchData = _interopRequireDefault(_resetFetchData);
  var _staticBlock;
  let _init_language, _init_extra_language;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  class ResetFetchDataActionHandler extends _actionHandler.default {
    constructor() {
      super(...arguments);
      _init_extra_language(this);
    }
    /**
     * @private
     * @type {Language}
     */
    language = _init_language(this);
    async process() {
      const model = this.view.model;
      const view = new _resetFetchData.default({
        model: model
      });
      await this.view.assignView('dialog', view);
      await view.render();
    }
    static #_ = _staticBlock = () => [_init_language, _init_extra_language] = _applyDecs(this, [], [[(0, _di.inject)(_language.default), 0, "language"]], 0, void 0, _actionHandler.default).e;
  }
  _exports.default = ResetFetchDataActionHandler;
  _staticBlock();
});

define("handlers/email/select-user", ["exports", "handlers/select-related"], function (_exports, _selectRelated) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _selectRelated = _interopRequireDefault(_selectRelated);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _selectRelated.default {
    /**
     * @param {import('model').default} model
     * @return {Promise<module:handlers/select-related~filters>}
     */
    async getFilters(model) {
      const acl = this.viewHelper.acl;
      const permission = acl.getPermissionLevel('assignment');

      /** @type {string[]} */
      const boolFilterList = [];
      if (permission === 'team') {
        boolFilterList.push('onlyMyTeam');
      } else if (permission === 'own') {
        boolFilterList.push('onlyMe');
      }
      return {
        bool: boolFilterList
      };
    }
  }
  _exports.default = _default;
});

define("handlers/email/list-actions", ["exports", "action-handler", "views/email/modals/import-eml"], function (_exports, _actionHandler, _importEml) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _actionHandler = _interopRequireDefault(_actionHandler);
  _importEml = _interopRequireDefault(_importEml);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EmailListActionsHandler extends _actionHandler.default {
    // noinspection JSUnusedGlobalSymbols
    async importEml() {
      const view = new _importEml.default();
      await this.view.assignView('dialog', view);
      await view.render();
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * @return {boolean}
     */
    checkImportEml() {
      const acl = this.view.getAcl();
      return acl.checkScope('Email', 'create') && acl.checkScope('Import');
    }
  }
  var _default = _exports.default = EmailListActionsHandler;
});

define("handlers/currency-record-rate/default-preparator", ["exports", "handlers/model/defaults-preparator", "di", "models/settings"], function (_exports, _defaultsPreparator, _di, _settings) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _defaultsPreparator = _interopRequireDefault(_defaultsPreparator);
  _settings = _interopRequireDefault(_settings);
  var _staticBlock;
  let _init_config, _init_extra_config;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  // noinspection JSUnusedGlobalSymbols
  class _Class extends _defaultsPreparator.default {
    constructor() {
      super(...arguments);
      _init_extra_config(this);
    }
    /**
     * @private
     * @type {Settings}
     */
    config = _init_config(this);
    async prepare(model) {
      return {
        baseCode: this.config.get('baseCurrency')
      };
    }
    static #_ = _staticBlock = () => [_init_config, _init_extra_config] = _applyDecs(this, [], [[(0, _di.inject)(_settings.default), 0, "config"]], 0, void 0, _defaultsPreparator.default).e;
  }
  _exports.default = _Class;
  _staticBlock();
});

define("handlers/currency-record/record-detail", ["exports"], function (_exports) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class CurrencyRecordRecordDetailHandler {
    /**
     * @param {import('views/record/detail').default} view
     */
    constructor(view) {
      this.view = view;
    }
    process() {
      const model = this.view.model;
      this.view.listenTo(model, 'after:relate:rates after:unrelate:rates after:related-change:rates', () => {
        model.fetch();
      });
    }
  }
  _exports.default = CurrencyRecordRecordDetailHandler;
});

define("handlers/currency-record/menu-action-settings", ["exports", "action-handler"], function (_exports, _actionHandler) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _actionHandler = _interopRequireDefault(_actionHandler);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class CurrencyRecordMenuActionSettingsHandler extends _actionHandler.default {
    // noinspection JSUnusedGlobalSymbols
    isVisible() {
      var _this$view$options;
      /** @type {Record} */
      const params = ((_this$view$options = this.view.options) === null || _this$view$options === void 0 ? void 0 : _this$view$options.params) ?? {};
      return params.fromSettings ?? false;
    }
  }
  _exports.default = CurrencyRecordMenuActionSettingsHandler;
});

define("handlers/create-related/set-parent", ["exports", "handlers/create-related", "di", "model-factory"], function (_exports, _createRelated, _di, _modelFactory) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _createRelated = _interopRequireDefault(_createRelated);
  _modelFactory = _interopRequireDefault(_modelFactory);
  var _staticBlock;
  let _init_modelFactory, _init_extra_modelFactory;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  class SetParentHandler extends _createRelated.default {
    constructor() {
      super(...arguments);
      _init_extra_modelFactory(this);
    }
    /**
     * @private
     * @type {ModelFactory}
     */
    modelFactory = _init_modelFactory(this);
    async getAttributes(model, link) {
      const entityType = model.getLinkParam(link, 'entity');
      if (!entityType) {
        return {};
      }
      const seed = await this.modelFactory.create(entityType);

      /** @type {string[]} */
      const parentEntityTypeList = seed.getFieldParam('parent', 'entityList') ?? [];
      if (!parentEntityTypeList.includes(model.entityType)) {
        return {};
      }
      return {
        parentId: model.id,
        parentName: model.attributes.name,
        parentType: model.entityType
      };
    }
    static #_ = _staticBlock = () => [_init_modelFactory, _init_extra_modelFactory] = _applyDecs(this, [], [[(0, _di.inject)(_modelFactory.default), 0, "modelFactory"]], 0, void 0, _createRelated.default).e;
  }
  _exports.default = SetParentHandler;
  _staticBlock();
});

define("handlers/api-user/open-api-spec-action", ["exports", "action-handler", "di", "router"], function (_exports, _actionHandler, _di, _router) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _actionHandler = _interopRequireDefault(_actionHandler);
  _router = _interopRequireDefault(_router);
  var _staticBlock;
  let _init_router, _init_extra_router;
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  function _applyDecs(e, t, n, r, o, i) { var a, c, u, s, f, l, p, d = Symbol.metadata || Symbol.for("Symbol.metadata"), m = Object.defineProperty, h = Object.create, y = [h(null), h(null)], v = t.length; function g(t, n, r) { return function (o, i) { n && (i = o, o = e); for (var a = 0; a < t.length; a++) i = t[a].apply(o, r ? [i] : []); return r ? i : o; }; } function b(e, t, n, r) { if ("function" != typeof e && (r || void 0 !== e)) throw new TypeError(t + " must " + (n || "be") + " a function" + (r ? "" : " or undefined")); return e; } function applyDec(e, t, n, r, o, i, u, s, f, l, p) { function d(e) { if (!p(e)) throw new TypeError("Attempted to access private element on non-instance"); } var h = [].concat(t[0]), v = t[3], w = !u, D = 1 === o, S = 3 === o, j = 4 === o, E = 2 === o; function I(t, n, r) { return function (o, i) { return n && (i = o, o = e), r && r(o), P[t].call(o, i); }; } if (!w) { var P = {}, k = [], F = S ? "get" : j || D ? "set" : "value"; if (f ? (l || D ? P = { get: _setFunctionName(function () { return v(this); }, r, "get"), set: function (e) { t[4](this, e); } } : P[F] = v, l || _setFunctionName(P[F], r, E ? "" : F)) : l || (P = Object.getOwnPropertyDescriptor(e, r)), !l && !f) { if ((c = y[+s][r]) && 7 !== (c ^ o)) throw Error("Decorating two elements with the same name (" + P[F].name + ") is not supported yet"); y[+s][r] = o < 3 ? 1 : o; } } for (var N = e, O = h.length - 1; O >= 0; O -= n ? 2 : 1) { var T = b(h[O], "A decorator", "be", !0), z = n ? h[O - 1] : void 0, A = {}, H = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: r, metadata: a, addInitializer: function (e, t) { if (e.v) throw new TypeError("attempted to call addInitializer after decoration was finished"); b(t, "An initializer", "be", !0), i.push(t); }.bind(null, A) }; if (w) c = T.call(z, N, H), A.v = 1, b(c, "class decorators", "return") && (N = c);else if (H.static = s, H.private = f, c = H.access = { has: f ? p.bind() : function (e) { return r in e; } }, j || (c.get = f ? E ? function (e) { return d(e), P.value; } : I("get", 0, d) : function (e) { return e[r]; }), E || S || (c.set = f ? I("set", 0, d) : function (e, t) { e[r] = t; }), N = T.call(z, D ? { get: P.get, set: P.set } : P[F], H), A.v = 1, D) { if ("object" == typeof N && N) (c = b(N.get, "accessor.get")) && (P.get = c), (c = b(N.set, "accessor.set")) && (P.set = c), (c = b(N.init, "accessor.init")) && k.unshift(c);else if (void 0 !== N) throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined"); } else b(N, (l ? "field" : "method") + " decorators", "return") && (l ? k.unshift(N) : P[F] = N); } return o < 2 && u.push(g(k, s, 1), g(i, s, 0)), l || w || (f ? D ? u.splice(-1, 0, I("get", s), I("set", s)) : u.push(E ? P[F] : b.call.bind(P[F])) : m(e, r, P)), N; } function w(e) { return m(e, d, { configurable: !0, enumerable: !0, value: a }); } return void 0 !== i && (a = i[d]), a = h(null == a ? null : a), f = [], l = function (e) { e && f.push(g(e)); }, p = function (t, r) { for (var i = 0; i < n.length; i++) { var a = n[i], c = a[1], l = 7 & c; if ((8 & c) == t && !l == r) { var p = a[2], d = !!a[3], m = 16 & c; applyDec(t ? e : e.prototype, a, m, d ? "#" + p : _toPropertyKey(p), l, l < 2 ? [] : t ? s = s || [] : u = u || [], f, !!t, d, r, t && d ? function (t) { return _checkInRHS(t) === e; } : o); } } }, p(8, 0), p(0, 0), p(8, 1), p(0, 1), l(u), l(s), c = f, v || w(e), { e: c, get c() { var n = []; return v && [w(e = applyDec(e, [t], r, e.name, 5, n)), g(n, 1)]; } }; }
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
  function _setFunctionName(e, t, n) { "symbol" == typeof t && (t = (t = t.description) ? "[" + t + "]" : ""); try { Object.defineProperty(e, "name", { configurable: !0, value: n ? n + " " + t : t }); } catch (e) {} return e; }
  function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
  // noinspection JSUnusedGlobalSymbols
  class _Class extends _actionHandler.default {
    constructor() {
      super(...arguments);
      _init_extra_router(this);
    }
    /**
     * @type {Router}
     * @private
     */
    router = _init_router(this);
    process() {
      window.open('api/v1/OpenApi', '_blank');
    }
    static #_ = _staticBlock = () => [_init_router, _init_extra_router] = _applyDecs(this, [], [[(0, _di.inject)(_router.default), 0, "router"]], 0, void 0, _actionHandler.default).e;
  }
  _exports.default = _Class;
  _staticBlock();
});

define("handlers/admin/address-country/populate-defaults", ["exports", "action-handler"], function (_exports, _actionHandler) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _actionHandler = _interopRequireDefault(_actionHandler);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class PopulateDefaultsHandler extends _actionHandler.default {
    async populate() {
      const confirmMessage = this.view.translate('confirmPopulateDefaults', 'messages', 'AddressCountry');
      await this.view.confirm(confirmMessage);
      Espo.Ui.notifyWait();
      await Espo.Ajax.postRequest('AddressCountry/action/populateDefaults');
      await this.view.collection.fetch();
      Espo.Ui.success(this.view.translate('Done'));
    }
  }

  // noinspection JSUnusedGlobalSymbols
  var _default = _exports.default = PopulateDefaultsHandler;
});

define("controllers/user", ["exports", "controllers/record"], function (_exports, _record) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _record = _interopRequireDefault(_record);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class UserController extends _record.default {
    getCollection(usePreviouslyFetched) {
      return super.getCollection().then(collection => {
        collection.data.userType = 'internal';
        return collection;
      });
    }

    /**
     * @protected
     * @param {Object} options
     * @param {module:models/user} model
     * @param {string} view
     */
    createViewView(options, model, view) {
      if (model.get('deleted')) {
        view = 'views/deleted-detail';
        super.createViewView(options, model, view);
        return;
      }
      if (model.isPortal()) {
        this.getRouter().dispatch('PortalUser', 'view', {
          id: model.id,
          model: model
        });
        return;
      }
      if (model.isApi()) {
        this.getRouter().dispatch('ApiUser', 'view', {
          id: model.id,
          model: model
        });
        return;
      }
      super.createViewView(options, model, view);
    }
  }
  var _default = _exports.default = UserController;
});

define("controllers/team", ["exports", "controllers/record"], function (_exports, _record) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _record = _interopRequireDefault(_record);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class TeamController extends _record.default {
    checkAccess(action) {
      if (action === 'read') {
        return true;
      }
      if (this.getUser().isAdmin()) {
        return true;
      }
      return false;
    }
  }
  var _default = _exports.default = TeamController;
});

define("controllers/stream", ["exports", "controller"], function (_exports, _controller) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _controller = _interopRequireDefault(_controller);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class StreamController extends _controller.default {
    defaultAction = 'index';

    // noinspection JSUnusedGlobalSymbols
    actionIndex() {
      const key = 'index';
      const isReturn = this.getRouter().backProcessed;
      if (!isReturn) {
        this.clearStoredMainView(key);
      }
      this.main('views/stream', {
        displayTitle: true
      }, undefined, {
        key: key,
        useStored: isReturn
      });
    }

    // noinspection JSUnusedGlobalSymbols
    actionPosts() {
      const key = 'index';
      const isReturn = this.getRouter().backProcessed;
      if (!isReturn) {
        this.clearStoredMainView(key);
      }
      this.main('views/stream', {
        displayTitle: true,
        filter: 'posts'
      }, undefined, {
        key: key,
        useStored: isReturn
      });
    }

    // noinspection JSUnusedGlobalSymbols
    actionUpdates() {
      const key = 'index';
      const isReturn = this.getRouter().backProcessed;
      if (!isReturn) {
        this.clearStoredMainView(key);
      }
      this.main('views/stream', {
        displayTitle: true,
        filter: 'updates'
      }, undefined, {
        key: key,
        useStored: isReturn
      });
    }
  }
  var _default = _exports.default = StreamController;
});

define("controllers/record-tree", ["exports", "controllers/record", "collections/tree"], function (_exports, _record, _tree) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _record = _interopRequireDefault(_record);
  _tree = _interopRequireDefault(_tree);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class RecordTreeController extends _record.default {
    defaultAction = 'listTree';
    beforeView(options) {
      super.beforeView(options);
      options = options || {};
      if (options.model) {
        options.model.unset('childCollection');
        options.model.unset('childList');
      }
    }

    // noinspection JSUnusedGlobalSymbols
    beforeListTree() {
      this.handleCheckAccess('read');
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     *
     * @param {{
     *     currentId?: string,
     *     isReturn?: boolean,
     * }} options
     */
    async actionListTree(options) {
      const currentId = options.currentId;
      const collection = await this.getCollection();
      if (!(collection instanceof _tree.default)) {
        throw new Error("Wrong collection.");
      }
      collection.url = `${collection.entityType}/action/listTree`;
      collection.currentId = currentId ?? null;
      const isReturn = options.isReturn || this.getRouter().backProcessed;
      this.main(this.getViewName('listTree'), {
        scope: this.name,
        collection: collection
      }, undefined, {
        key: 'listTree',
        useStored: isReturn
      });
    }
    async create() {
      let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      if (options.parentId) {
        options.attributes ??= {};
        options.attributes.parentId = options.parentId;
        options.attributes.parentName = options.parentName;
        delete options.parentId;
        delete options.parentName;
      }
      return super.create(options);
    }
  }
  var _default = _exports.default = RecordTreeController;
});

define("controllers/preferences", ["exports", "controllers/record", "models/preferences"], function (_exports, _record, _preferences) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _record = _interopRequireDefault(_record);
  _preferences = _interopRequireDefault(_preferences);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class PreferencesController extends _record.default {
    defaultAction = 'own';
    getModel(callback, context) {
      const model = new _preferences.default({}, {
        defs: this.getMetadata().get('entityDefs.Preferences') || {}
      });
      model.setSettings(this.getConfig());
      if (callback) {
        callback.call(this, model);
      }
      return new Promise(resolve => {
        resolve(model);
      });
    }
    checkAccess(action) {
      return true;
    }

    // noinspection JSUnusedGlobalSymbols
    actionOwn() {
      this.actionEdit({
        id: this.getUser().id
      });
    }
    actionList(options) {}
  }
  var _default = _exports.default = PreferencesController;
});

define("controllers/portal-user", ["exports", "controllers/record"], function (_exports, _record) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _record = _interopRequireDefault(_record);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class PortalUserController extends _record.default {
    entityType = 'User';
    getCollection(usePreviouslyFetched) {
      return super.getCollection().then(collection => {
        collection.data.userType = 'portal';
        return collection;
      });
    }

    /**
     * @protected
     * @param {Object} options
     * @param {module:models/user} model
     * @param {string} view
     */
    createViewView(options, model, view) {
      if (!model.isPortal()) {
        if (model.isApi()) {
          this.getRouter().dispatch('ApiUser', 'view', {
            id: model.id,
            model: model
          });
          return;
        }
        this.getRouter().dispatch('User', 'view', {
          id: model.id,
          model: model
        });
        return;
      }
      super.createViewView(options, model, view);
    }
    actionCreate(options) {
      options = options || {};
      options.attributes = options.attributes || {};
      options.attributes.type = 'portal';
      super.actionCreate(options);
    }
    checkAccess(action) {
      if (this.getAcl().getPermissionLevel('portalPermission') === 'yes') {
        return true;
      }
      return false;
    }
  }
  var _default = _exports.default = PortalUserController;
});

define("controllers/password-change-request", ["exports", "controller"], function (_exports, _controller) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _controller = _interopRequireDefault(_controller);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class PasswordChangeRequestController extends _controller.default {
    // noinspection JSUnusedGlobalSymbols
    actionPasswordChange(options) {
      options = options || {};
      if (!options.id) {
        throw new Error();
      }
      this.entire('views/user/password-change-request', {
        requestId: options.id,
        strengthParams: options.strengthParams,
        notFound: options.notFound
      }, view => {
        view.render();
      });
    }
  }
  var _default = _exports.default = PasswordChangeRequestController;
});

define("controllers/notification", ["exports", "controller"], function (_exports, _controller) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _controller = _interopRequireDefault(_controller);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class NotificationController extends _controller.default {
    defaultAction = 'index';

    // noinspection JSUnusedGlobalSymbols
    actionIndex() {
      this.main('views/notification/list', {}, view => {
        view.render();
      });
    }
  }
  var _default = _exports.default = NotificationController;
});

define("controllers/note", ["exports", "controller"], function (_exports, _controller) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _controller = _interopRequireDefault(_controller);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class NoteController extends _controller.default {
    // noinspection JSUnusedGlobalSymbols
    /**
     * @param {Record} options
     */
    actionView(options) {
      const id = options.id;
      if (!id) {
        throw new Espo.Exceptions.NotFound();
      }
      const viewName = this.getMetadata().get(['clientDefs', this.name, 'views', 'detail']) || 'views/note/detail';
      let model;
      this.showLoadingNotification();
      this.modelFactory.create('Note').then(m => {
        model = m;
        model.id = id;
        return model.fetch({
          main: true
        });
      }).then(() => {
        this.hideLoadingNotification();
        this.main(viewName, {
          model: model
        });
      });
    }
  }
  var _default = _exports.default = NoteController;
});

define("controllers/login-as", ["exports", "controller"], function (_exports, _controller) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _controller = _interopRequireDefault(_controller);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class LoginAsController extends _controller.default {
    // noinspection JSUnusedGlobalSymbols
    /**
     * @param {Record} options
     */
    actionLogin(options) {
      const anotherUser = options.anotherUser;
      const username = options.username;
      if (!anotherUser) {
        throw new Error("No anotherUser.");
      }
      this.baseController.login({
        anotherUser: anotherUser,
        username: username
      });
      this.listenToOnce(this.baseController, 'login', () => {
        this.baseController.once('router-set', () => {
          const url = window.location.href.split('?')[0];
          window.location.replace(url);
        });
      });
    }
  }
  var _default = _exports.default = LoginAsController;
});

define("controllers/lead-capture-opt-in-confirmation", ["exports", "controller"], function (_exports, _controller) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _controller = _interopRequireDefault(_controller);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class LeadCaptureOptInConfirmationController extends _controller.default {
    // noinspection JSUnusedGlobalSymbols
    actionOptInConfirmationSuccess(data) {
      const viewName = this.getMetadata().get(['clientDefs', 'LeadCapture', 'optInConfirmationSuccessView']) || 'views/lead-capture/opt-in-confirmation-success';
      this.entire(viewName, {
        resultData: data
      }, view => {
        view.render();
      });
    }

    // noinspection JSUnusedGlobalSymbols
    actionOptInConfirmationExpired(data) {
      const viewName = this.getMetadata().get(['clientDefs', 'LeadCapture', 'optInConfirmationExpiredView']) || 'views/lead-capture/opt-in-confirmation-expired';
      this.entire(viewName, {
        resultData: data
      }, view => {
        view.render();
      });
    }
  }

  // noinspection JSUnusedGlobalSymbols
  var _default = _exports.default = LeadCaptureOptInConfirmationController;
});

define("controllers/lead-capture-form", ["exports", "controller", "views/lead-capture/form"], function (_exports, _controller, _form) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _controller = _interopRequireDefault(_controller);
  _form = _interopRequireDefault(_form);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  // noinspection JSUnusedGlobalSymbols
  class LeadCaptureFormController extends _controller.default {
    // noinspection JSUnusedGlobalSymbols
    actionShow(data) {
      this.prepareContainer();
      const view = new _form.default({
        formData: data
      });
      view.setSelector('body > .content');
      this.viewFactory.prepare(view, () => view.render());
    }

    /**
     * @private
     */
    prepareContainer() {
      // Prevents recaptcha removal.

      const existingContainer = document.body.querySelector('.container');
      existingContainer.remove();
      const container = document.createElement('div');
      container.classList.add('container', 'content');
      document.body.prepend(container);
    }
  }
  _exports.default = LeadCaptureFormController;
});

define("controllers/layout-set", ["exports", "controllers/record"], function (_exports, _record) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _record = _interopRequireDefault(_record);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class LayoutSetController extends _record.default {
    // noinspection JSUnusedGlobalSymbols
    /**
     * @param {Record} options
     */
    actionEditLayouts(options) {
      const id = options.id;
      if (!id) {
        throw new Error("ID not passed.");
      }
      this.main('views/layout-set/layouts', {
        layoutSetId: id,
        scope: options.scope,
        type: options.type
      });
    }
  }
  var _default = _exports.default = LayoutSetController;
});

define("controllers/last-viewed", ["exports", "controllers/record"], function (_exports, _record) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _record = _interopRequireDefault(_record);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class LastViewedController extends _record.default {
    entityType = 'ActionHistoryRecord';
    checkAccess(action) {
      return this.getAcl().check(this.entityType, action);
    }
  }

  // noinspection JSUnusedGlobalSymbols
  var _default = _exports.default = LastViewedController;
});

define("controllers/inbound-email", ["exports", "controllers/record"], function (_exports, _record) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _record = _interopRequireDefault(_record);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class InboundEmailController extends _record.default {
    checkAccess(action) {
      if (this.getUser().isAdmin()) {
        return true;
      }
      return false;
    }
  }
  var _default = _exports.default = InboundEmailController;
});

define("controllers/import", ["exports", "controllers/record"], function (_exports, _record) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _record = _interopRequireDefault(_record);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ImportController extends _record.default {
    defaultAction = 'index';
    storedData;
    checkAccessGlobal() {
      if (this.getAcl().checkScope('Import')) {
        return true;
      }
      return false;
    }
    checkAccess(action) {
      if (this.getAcl().checkScope('Import')) {
        return true;
      }
      return false;
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * @param {{
     *     step?: int|string,
     *     fromAdmin?: boolean,
     *     formData?: Object
     * }} o
     */
    actionIndex(o) {
      o = o || {};
      let step = null;
      if (o.step) {
        step = parseInt(step);
      }
      let formData = null;
      let fileContents = null;
      if (o.formData) {
        this.storedData = undefined;
      }
      if (this.storedData) {
        formData = this.storedData.formData;
        fileContents = this.storedData.fileContents;
      }
      if (!formData) {
        step = null;
      }
      formData = formData || o.formData;
      this.main('views/import/index', {
        step: step,
        formData: formData,
        fileContents: fileContents,
        fromAdmin: o.fromAdmin
      }, /** module:views/import/index */view => {
        this.listenTo(view, 'change', () => {
          this.storedData = {
            formData: view.formData,
            fileContents: view.fileContents
          };
        });
        this.listenTo(view, 'done', () => {
          this.storedData = undefined;
        });
        view.render();
      });
    }
  }
  var _default = _exports.default = ImportController;
});

define("controllers/home", ["exports", "controller"], function (_exports, _controller) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _controller = _interopRequireDefault(_controller);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class HomeController extends _controller.default {
    // noinspection JSUnusedGlobalSymbols
    actionIndex() {
      this.main('views/home', null);
    }
  }
  var _default = _exports.default = HomeController;
});

define("controllers/global-stream", ["exports", "controller", "views/global-stream"], function (_exports, _controller, _globalStream) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _controller = _interopRequireDefault(_controller);
  _globalStream = _interopRequireDefault(_globalStream);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class GlobalStreamController extends _controller.default {
    // noinspection JSUnusedGlobalSymbols
    actionIndex() {
      const key = 'index';
      const isReturn = this.getRouter().backProcessed;
      if (!isReturn) {
        this.clearStoredMainView(key);
      }
      const view = new _globalStream.default();
      this.main(view, undefined, undefined, {
        key: key,
        useStored: isReturn
      });
    }
  }
  var _default = _exports.default = GlobalStreamController;
});

define("controllers/external-account", ["exports", "controller"], function (_exports, _controller) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _controller = _interopRequireDefault(_controller);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ExternalAccountController extends _controller.default {
    defaultAction = 'list';
    actionList() {
      this.collectionFactory.create('ExternalAccount', collection => {
        collection.once('sync', () => {
          this.main('ExternalAccount.Index', {
            collection: collection
          });
        });
        collection.fetch();
      });
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * @param {{id: string}} options
     */
    actionEdit(options) {
      const id = options.id;
      this.collectionFactory.create('ExternalAccount', collection => {
        collection.once('sync', () => {
          this.main('ExternalAccount.Index', {
            collection: collection,
            id: id
          });
        });
        collection.fetch();
      });
    }
  }
  var _default = _exports.default = ExternalAccountController;
});

define("controllers/email", ["exports", "controllers/record"], function (_exports, _record) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _record = _interopRequireDefault(_record);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EmailController extends _record.default {
    prepareModelView(model, options) {
      super.prepareModelView(model, options);
      this.listenToOnce(model, 'after:send', () => {
        const key = 'list';
        const stored = this.getStoredMainView(key);
        if (stored) {
          this.clearStoredMainView(key);
        }
      });
    }
  }
  var _default = _exports.default = EmailController;
});

define("controllers/email-filter", ["exports", "controllers/record"], function (_exports, _record) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _record = _interopRequireDefault(_record);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EmailFilterController extends _record.default {
    actionCreate(options) {
      const attributes = {
        ...options.attributes
      };
      if (options.from) {
        attributes.from = options.from;
        attributes.name = options.from;
        options.attributes = attributes;
      }
      super.actionCreate(options);
    }
  }
  var _default = _exports.default = EmailFilterController;
});

define("controllers/dashboard", ["exports", "controller"], function (_exports, _controller) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _controller = _interopRequireDefault(_controller);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class DashboardController extends _controller.default {
    defaultAction = 'index';

    // noinspection JSUnusedGlobalSymbols
    actionIndex() {
      this.main('views/dashboard', {
        displayTitle: true
      }, view => {
        view.render();
      });
    }
  }
  var _default = _exports.default = DashboardController;
});

define("controllers/api-user", ["exports", "controllers/record"], function (_exports, _record) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _record = _interopRequireDefault(_record);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ApiUserController extends _record.default {
    entityType = 'User';
    getCollection(usePreviouslyFetched) {
      return super.getCollection().then(collection => {
        collection.data.userType = 'api';
        return collection;
      });
    }

    /**
     * @protected
     * @param {Object} options
     * @param {module:models/user} model
     * @param {string} view
     */
    createViewView(options, model, view) {
      if (!model.isApi()) {
        if (model.isPortal()) {
          this.getRouter().dispatch('PortalUser', 'view', {
            id: model.id,
            model: model
          });
          return;
        }
        this.getRouter().dispatch('User', 'view', {
          id: model.id,
          model: model
        });
        return;
      }
      super.createViewView(options, model, view);
    }
    actionCreate(options) {
      options = options || {};
      options.attributes = options.attributes || {};
      options.attributes.type = 'api';
      super.actionCreate(options);
    }
  }
  var _default = _exports.default = ApiUserController;
});

define("controllers/address-map", ["exports", "controller"], function (_exports, _controller) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _controller = _interopRequireDefault(_controller);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class AddressMapController extends _controller.default {
    defaultAction = 'index';

    // noinspection JSUnusedGlobalSymbols
    actionIndex() {
      this.error404();
    }

    // noinspection JSUnusedGlobalSymbols
    /**
     * @param {Object} o
     */
    actionView(o) {
      this.modelFactory.create(o.entityType).then(model => {
        model.id = o.id;
        model.fetch().then(() => {
          const viewName = this.getMetadata().get(['AddressMap', 'view']) || 'views/address-map/view';
          this.main(viewName, {
            model: model,
            field: o.field
          });
        });
      });
    }
  }
  var _default = _exports.default = AddressMapController;
});

define("controllers/about", ["exports", "controller"], function (_exports, _controller) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _controller = _interopRequireDefault(_controller);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class AboutController extends _controller.default {
    defaultAction = 'about';

    // noinspection JSUnusedGlobalSymbols
    actionAbout() {
      this.main('About', {}, view => {
        view.render();
      });
    }
  }
  var _default = _exports.default = AboutController;
});

define("collections/notification", ["exports", "collections/note"], function (_exports, _note) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _note = _interopRequireDefault(_note);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class NotificationCollection extends _note.default {
    paginationByNumber = true;
  }
  _exports.default = NotificationCollection;
});

define("acl-portal/preferences", ["exports", "acl-portal"], function (_exports, _aclPortal) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _aclPortal = _interopRequireDefault(_aclPortal);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class PreferencesAclPortal extends _aclPortal.default {
    checkIsOwner(model) {
      if (this.getUser().id === model.id) {
        return true;
      }
      return false;
    }
  }
  var _default = _exports.default = PreferencesAclPortal;
});

define("acl-portal/notification", ["exports", "acl-portal"], function (_exports, _aclPortal) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _aclPortal = _interopRequireDefault(_aclPortal);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class NotificationAclPortal extends _aclPortal.default {
    checkIsOwner(model) {
      if (this.getUser().id === model.get('userId')) {
        return true;
      }
      return false;
    }
  }
  var _default = _exports.default = NotificationAclPortal;
});

define("acl-portal/email", ["exports", "acl-portal"], function (_exports, _aclPortal) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _aclPortal = _interopRequireDefault(_aclPortal);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EmailAclPortal extends _aclPortal.default {
    // noinspection JSUnusedGlobalSymbols
    checkModelRead(model, data, precise) {
      const result = this.checkModel(model, data, 'read', precise);
      if (result) {
        return true;
      }
      if (data === false) {
        return false;
      }
      const d = data || {};
      if (d.read === 'no') {
        return false;
      }
      if (model.has('usersIds')) {
        if (~(model.get('usersIds') || []).indexOf(this.getUser().id)) {
          return true;
        }
      } else if (precise) {
        return null;
      }
      return result;
    }
  }
  var _default = _exports.default = EmailAclPortal;
});

define("acl/user", ["exports", "acl"], function (_exports, _acl) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _acl = _interopRequireDefault(_acl);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class UserAcl extends _acl.default {
    // noinspection JSUnusedGlobalSymbols
    checkModelRead(model, data, precise) {
      if (model.isPortal() && this.getPermissionLevel('portalPermission') === 'yes') {
        return true;
      }
      return this.checkModel(model, data, 'read', precise);
    }
    checkIsOwner(model) {
      return this.getUser().id === model.id;
    }
  }
  var _default = _exports.default = UserAcl;
});

define("acl/team", ["exports", "acl"], function (_exports, _acl) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _acl = _interopRequireDefault(_acl);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class TeamAcl extends _acl.default {
    checkInTeam(model) {
      const userTeamIdList = this.getUser().getTeamIdList();
      return userTeamIdList.indexOf(model.id) !== -1;
    }
  }
  var _default = _exports.default = TeamAcl;
});

define("acl/preferences", ["exports", "acl"], function (_exports, _acl) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _acl = _interopRequireDefault(_acl);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class PreferencesAcl extends _acl.default {
    checkIsOwner(model) {
      if (this.getUser().id === model.id) {
        return true;
      }
      return false;
    }
  }
  var _default = _exports.default = PreferencesAcl;
});

define("acl/notification", ["exports", "acl"], function (_exports, _acl) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _acl = _interopRequireDefault(_acl);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class NotificationAcl extends _acl.default {
    checkIsOwner(model) {
      if (this.getUser().id === model.get('userId')) {
        return true;
      }
      return false;
    }
  }
  var _default = _exports.default = NotificationAcl;
});

define("acl/import", ["exports", "acl"], function (_exports, _acl) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _acl = _interopRequireDefault(_acl);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class ImportAcl extends _acl.default {
    checkScope(data, action, precise, entityAccessData) {
      return !!data;
    }

    // noinspection JSUnusedGlobalSymbols,JSUnusedLocalSymbols
    checkModelRead(model, data, precise) {
      return true;
    }
    checkIsOwner(model) {
      if (this.getUser().id === model.get('createdById')) {
        return true;
      }
      return false;
    }
    checkModelDelete(model, data, precise) {
      return true;
    }
  }
  var _default = _exports.default = ImportAcl;
});

define("acl/foreign", ["exports", "acl"], function (_exports, _acl) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _acl = _interopRequireDefault(_acl);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  /**
   * To be used for entities for which access is determined by access to a foreign record.
   */
  class ForeignAcl extends _acl.default {
    checkIsOwner(model) {
      return true;
    }
    checkInTeam(model) {
      return true;
    }
  }
  var _default = _exports.default = ForeignAcl;
});

define("acl/email", ["exports", "acl"], function (_exports, _acl) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _acl = _interopRequireDefault(_acl);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class EmailAcl extends _acl.default {
    // noinspection JSUnusedGlobalSymbols
    checkModelRead(model, data, precise) {
      const result = this.checkModel(model, data, 'read', precise);
      if (result) {
        return true;
      }
      if (data === false) {
        return false;
      }
      const d = data || {};
      if (d.read === 'no') {
        return false;
      }
      if (model.has('usersIds')) {
        if (~(model.get('usersIds') || []).indexOf(this.getUser().id)) {
          return true;
        }
      } else if (precise) {
        return null;
      }
      return result;
    }
    checkIsOwner(model) {
      if (this.getUser().id === model.get('assignedUserId') || this.getUser().id === model.get('createdById')) {
        return true;
      }
      if (!model.has('assignedUsersIds')) {
        return null;
      }
      if (~(model.get('assignedUsersIds') || []).indexOf(this.getUser().id)) {
        return true;
      }
      return false;
    }

    // noinspection JSUnusedGlobalSymbols
    checkModelEdit(model, data, precise) {
      if (model.get('status') === 'Draft' && model.get('createdById') === this.getUser().id) {
        return true;
      }
      return this.checkModel(model, data, 'edit', precise);
    }
    checkModelDelete(model, data, precise) {
      const result = this.checkModel(model, data, 'delete', precise);
      if (result) {
        return true;
      }
      if (data === false) {
        return false;
      }
      const d = data || {};
      if (d.read === 'no') {
        return false;
      }
      if (model.get('createdById') === this.getUser().id) {
        if (model.get('status') !== 'Sent' && model.get('status') !== 'Archived') {
          return true;
        }
      }
      return result;
    }
  }
  var _default = _exports.default = EmailAcl;
});

define("acl/currency-record-rate", ["exports", "acl"], function (_exports, _acl) {
  "use strict";

  Object.defineProperty(_exports, "__esModule", {
    value: true
  });
  _exports.default = void 0;
  _acl = _interopRequireDefault(_acl);
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
  /************************************************************************
   * This file is part of EspoCRM.
   *
   * EspoCRM – Open Source CRM application.
   * Copyright (C) 2014-2026 EspoCRM, Inc.
   * Website: https://www.espocrm.com
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Affero General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Affero General Public License for more details.
   *
   * You should have received a copy of the GNU Affero General Public License
   * along with this program. If not, see <https://www.gnu.org/licenses/>.
   *
   * The interactive user interfaces in modified source and object code versions
   * of this program must display Appropriate Legal Notices, as required under
   * Section 5 of the GNU Affero General Public License version 3.
   *
   * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
   * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
   ************************************************************************/

  class _default extends _acl.default {
    checkScope(data, action, precise, entityAccessData) {
      if (action === 'create' || action === 'delete') {
        action = 'edit';
      }
      return super.checkScope(data, action, precise, entityAccessData);
    }
  }
  _exports.default = _default;
});

Espo.loader.mapBundleFile('admin', 'client/lib/espo-admin.js');
Espo.loader.mapBundleFile('extra', 'client/lib/espo-extra.js');
Espo.loader.mapBundleFile('crm', 'client/lib/espo-crm.js');
Espo.loader.mapBundleDependencies('chart', ["flotr2","espo-funnel-chart"]);
Espo.loader.mapBundleFile('chart', 'client/lib/espo-chart.js');
Espo.loader.mapBundleDependencies('calendar', ["fullcalendar"]);
Espo.loader.mapBundleFile('calendar', 'client/lib/espo-calendar.js');
Espo.loader.mapBundleDependencies('timeline', ["vis-data","vis-timeline"]);
Espo.loader.mapBundleFile('timeline', 'client/lib/espo-timeline.js');
Espo.loader.addBundleMapping({"views/admin/layouts/base":"admin","views/admin/layouts/rows":"admin","views/admin/layouts/side-panels-detail":"admin","views/admin/dynamic-logic/conditions-string/item-base":"admin","views/admin/link-manager/modals/edit-params":"admin","views/admin/layouts/grid":"admin","views/admin/layouts/default-page":"admin","views/admin/layouts/bottom-panels-detail":"admin","views/admin/layouts/modals/create":"admin","views/admin/field-manager/detail-fields/attributes":"admin","views/admin/dynamic-logic/conditions-string/item-operator-only-base":"admin","views/admin/dynamic-logic/conditions/field-types/base":"admin","views/settings/record/edit":"admin","views/settings/fields/quick-create-list":"admin","views/role/record/table":"admin","views/role/record/list":"admin","views/role/record/edit":"admin","views/role/record/detail":"admin","views/inbound-email/record/detail":"admin","views/admin/index":"admin","views/admin/pipelines/list-for-entity-type":"admin","views/admin/link-manager/index":"admin","views/admin/layouts/list":"admin","views/admin/layouts/index":"admin","views/admin/layouts/detail":"admin","views/admin/layouts/bottom-panels-edit":"admin","views/admin/integrations/edit":"admin","views/admin/field-manager/modals/view-details":"admin","views/admin/field-manager/fields/options":"admin","views/admin/entity-manager/record/edit-formula":"admin","views/admin/entity-manager/modals/export":"admin","views/admin/entity-manager/fields/primary-filters":"admin","views/admin/entity-manager/fields/acl-contact-link":"admin","views/admin/dynamic-logic/conditions-string/item-operator-only-date":"admin","views/admin/dynamic-logic/conditions-string/group-base":"admin","views/admin/dynamic-logic/conditions/group-base":"admin","views/admin/dynamic-logic/conditions/field-types/link-multiple":"admin","views/email-account/fields/test-send":"admin","views/email-account/fields/test-connection":"admin","views/email-account/fields/folders":"admin","views/email-account/fields/folder":"admin","views/templates/event/record/detail":"admin","views/settings/edit":"admin","views/settings/modals/tab-list-field-add":"admin","views/settings/modals/edit-tab-url":"admin","views/settings/modals/edit-tab-group":"admin","views/settings/modals/edit-tab-divider":"admin","views/settings/fields/time-zone":"admin","views/settings/fields/time-format":"admin","views/settings/fields/thousand-separator":"admin","views/settings/fields/tab-url":"admin","views/settings/fields/stream-email-with-content-entity-type-list":"admin","views/settings/fields/stream-email-notifications-entity-list":"admin","views/settings/fields/sms-provider":"admin","views/settings/fields/phone-number-preferred-country-list":"admin","views/settings/fields/pdf-engine":"admin","views/settings/fields/outbound-email-from-address":"admin","views/settings/fields/oidc-teams":"admin","views/settings/fields/oidc-redirect-uri":"admin","views/settings/fields/language":"admin","views/settings/fields/history-entity-list":"admin","views/settings/fields/group-tab-list":"admin","views/settings/fields/global-search-entity-list":"admin","views/settings/fields/fiscal-year-shift":"admin","views/settings/fields/email-address-lookup-entity-type-list":"admin","views/settings/fields/default-currency":"admin","views/settings/fields/date-format":"admin","views/settings/fields/dashboard-layout":"admin","views/settings/fields/currency-list":"admin","views/settings/fields/calendar-entity-list":"admin","views/settings/fields/busy-ranges-entity-list":"admin","views/settings/fields/baseline-role":"admin","views/settings/fields/available-reactions":"admin","views/settings/fields/authentication-method":"admin","views/settings/fields/auth-two-fa-method-list":"admin","views/settings/fields/assignment-notifications-entity-list":"admin","views/settings/fields/assignment-email-notifications-entity-list":"admin","views/settings/fields/address-preview":"admin","views/settings/fields/activities-entity-list":"admin","views/scheduled-job/list":"admin","views/scheduled-job/record/list":"admin","views/scheduled-job/record/detail":"admin","views/scheduled-job/record/panels/log":"admin","views/scheduled-job/fields/scheduling":"admin","views/scheduled-job/fields/job":"admin","views/role/list":"admin","views/role/record/detail-side":"admin","views/role/record/panels/side":"admin","views/role/modals/add-field":"admin","views/role/fields/permission":"admin","views/role/fields/info":"admin","views/portal-role/list":"admin","views/portal-role/record/table":"admin","views/portal-role/record/list":"admin","views/portal-role/record/edit":"admin","views/portal-role/record/detail":"admin","views/portal/record/list":"admin","views/portal/fields/tab-list":"admin","views/portal/fields/quick-create-list":"admin","views/portal/fields/custom-id":"admin","views/lead-capture-log-record/modals/detail":"admin","views/layout-set/layouts":"admin","views/layout-set/record/list":"admin","views/layout-set/fields/layout-list":"admin","views/layout-set/fields/edit":"admin","views/inbound-email/record/list":"admin","views/inbound-email/record/edit":"admin","views/inbound-email/fields/test-send":"admin","views/inbound-email/fields/test-connection":"admin","views/inbound-email/fields/target-user-position":"admin","views/inbound-email/fields/name":"admin","views/inbound-email/fields/folders":"admin","views/inbound-email/fields/folder":"admin","views/inbound-email/fields/email-address":"admin","views/extension/record/row-actions":"admin","views/extension/record/list":"admin","views/authentication-provider/record/edit":"admin","views/authentication-provider/record/detail":"admin","views/authentication-provider/fields/method":"admin","views/api-user/list":"admin","views/admin/user-interface":"admin","views/admin/sms":"admin","views/admin/settings":"admin","views/admin/outbound-emails":"admin","views/admin/notifications":"admin","views/admin/jobs-settings":"admin","views/admin/inbound-emails":"admin","views/admin/currency":"admin","views/admin/currency-main":"admin","views/admin/authentication":"admin","views/admin/upgrade/ready":"admin","views/admin/upgrade/index":"admin","views/admin/upgrade/done":"admin","views/admin/template-manager/index":"admin","views/admin/template-manager/edit":"admin","views/admin/template-manager/fields/body":"admin","views/admin/system-requirements/index":"admin","views/admin/pipelines/main":"admin","views/admin/panels/notifications":"admin","views/admin/link-manager/modals/edit":"admin","views/admin/link-manager/fields/foreign-link-entity-type-list":"admin","views/admin/layouts/side-panels-edit":"admin","views/admin/layouts/side-panels-edit-small":"admin","views/admin/layouts/side-panels-detail-small":"admin","views/admin/layouts/mass-update":"admin","views/admin/layouts/list-small":"admin","views/admin/layouts/kanban":"admin","views/admin/layouts/filters":"admin","views/admin/layouts/detail-small":"admin","views/admin/layouts/detail-convert":"admin","views/admin/layouts/default-side-panel":"admin","views/admin/layouts/bottom-panels-edit-small":"admin","views/admin/layouts/bottom-panels-detail-small":"admin","views/admin/layouts/record/edit-attributes":"admin","views/admin/layouts/modals/panel-attributes":"admin","views/admin/layouts/modals/edit-attributes":"admin","views/admin/layouts/fields/width-complex":"admin","views/admin/label-manager/index":"admin","views/admin/label-manager/edit":"admin","views/admin/label-manager/category":"admin","views/admin/job/list":"admin","views/admin/job/record/list":"admin","views/admin/job/record/detail-small":"admin","views/admin/job/modals/detail":"admin","views/admin/job/fields/name":"admin","views/admin/integrations/oauth2":"admin","views/admin/integrations/index":"admin","views/admin/integrations/google-maps":"admin","views/admin/formula-sandbox/index":"admin","views/admin/formula-sandbox/record/edit":"admin","views/admin/formula/modals/add-function":"admin","views/admin/formula/modals/add-attribute":"admin","views/admin/formula/fields/attribute":"admin","views/admin/field-manager/list":"admin","views/admin/field-manager/index":"admin","views/admin/field-manager/header":"admin","views/admin/field-manager/edit":"admin","views/admin/field-manager/modals/add-field":"admin","views/admin/field-manager/fields/source-list":"admin","views/admin/field-manager/fields/pattern":"admin","views/admin/field-manager/fields/options-with-style":"admin","views/admin/field-manager/fields/options-reference":"admin","views/admin/field-manager/fields/not-actual-options":"admin","views/admin/field-manager/fields/entity-list":"admin","views/admin/field-manager/fields/dynamic-logic-options":"admin","views/admin/field-manager/fields/dynamic-logic-conditions":"admin","views/admin/field-manager/fields/dynamic-logic-cascading":"admin","views/admin/field-manager/fields/currency-default":"admin","views/admin/field-manager/fields/text/attachment-field":"admin","views/admin/field-manager/fields/phone/default":"admin","views/admin/field-manager/fields/options/default":"admin","views/admin/field-manager/fields/options/default-multi":"admin","views/admin/field-manager/fields/link-multiple/default":"admin","views/admin/field-manager/fields/link/default":"admin","views/admin/field-manager/fields/int/max":"admin","views/admin/field-manager/fields/foreign/link":"admin","views/admin/field-manager/fields/foreign/field":"admin","views/admin/field-manager/fields/date/default":"admin","views/admin/field-manager/fields/date/after-before":"admin","views/admin/extensions/ready":"admin","views/admin/extensions/index":"admin","views/admin/extensions/done":"admin","views/admin/entity-manager/scope":"admin","views/admin/entity-manager/index":"admin","views/admin/entity-manager/formula":"admin","views/admin/entity-manager/edit":"admin","views/admin/entity-manager/record/edit":"admin","views/admin/entity-manager/modals/select-icon":"admin","views/admin/entity-manager/modals/select-formula":"admin","views/admin/entity-manager/fields/icon-class":"admin","views/admin/entity-manager/fields/duplicate-check-field-list":"admin","views/admin/entity-manager/fields/acl-account-link":"admin","views/admin/dynamic-logic/modals/edit":"admin","views/admin/dynamic-logic/modals/add-field":"admin","views/admin/dynamic-logic/fields/user-id":"admin","views/admin/dynamic-logic/fields/field":"admin","views/admin/dynamic-logic/conditions-string/item-value-varchar":"admin","views/admin/dynamic-logic/conditions-string/item-value-link":"admin","views/admin/dynamic-logic/conditions-string/item-value-enum":"admin","views/admin/dynamic-logic/conditions-string/item-multiple-values-base":"admin","views/admin/dynamic-logic/conditions-string/item-is-today":"admin","views/admin/dynamic-logic/conditions-string/item-in-past":"admin","views/admin/dynamic-logic/conditions-string/item-in-future":"admin","views/admin/dynamic-logic/conditions-string/group-not":"admin","views/admin/dynamic-logic/conditions/or":"admin","views/admin/dynamic-logic/conditions/not":"admin","views/admin/dynamic-logic/conditions/and":"admin","views/admin/dynamic-logic/conditions/field-types/multi-enum":"admin","views/admin/dynamic-logic/conditions/field-types/link":"admin","views/admin/dynamic-logic/conditions/field-types/link-parent":"admin","views/admin/dynamic-logic/conditions/field-types/enum":"admin","views/admin/dynamic-logic/conditions/field-types/date":"admin","views/admin/dynamic-logic/conditions/field-types/current-user":"admin","views/admin/dynamic-logic/conditions/field-types/current-user-teams":"admin","views/admin/complex-expression/modals/add-function":"admin","views/admin/authentication/fields/test-connection":"admin","views/admin/auth-token/list":"admin","views/admin/auth-token/record/list":"admin","views/admin/auth-token/record/detail":"admin","views/admin/auth-token/record/detail-small":"admin","views/admin/auth-token/record/row-actions/default":"admin","views/admin/auth-token/modals/detail":"admin","views/admin/auth-log-record/list":"admin","views/admin/auth-log-record/record/list":"admin","views/admin/auth-log-record/record/detail":"admin","views/admin/auth-log-record/record/detail-small":"admin","views/admin/auth-log-record/modals/detail":"admin","views/admin/auth-log-record/fields/authentication-method":"admin","views/admin/app-secret/fields/value":"admin","views/admin/app-log-record/record/list":"admin","controllers/role":"admin","controllers/portal-role":"admin","controllers/admin":"admin","views/import/record/panels/imported":"extra","views/email-account/record/detail":"extra","views/personal-data/record/record":"extra","views/personal-data/modals/personal-data":"extra","views/outbound-email/modals/test-send":"extra","views/import-error/fields/validation-failures":"extra","views/import-error/fields/line-number":"extra","views/import/step2":"extra","views/import/step1":"extra","views/import/list":"extra","views/import/index":"extra","views/import/detail":"extra","views/import/record/list":"extra","views/import/record/detail":"extra","views/import/record/row-actions/duplicates":"extra","views/import/record/panels/updated":"extra","views/import/record/panels/duplicates":"extra","views/group-email-folder/list":"extra","views/group-email-folder/record/list":"extra","views/group-email-folder/record/edit-small":"extra","views/group-email-folder/record/row-actions/default":"extra","views/external-account/oauth2":"extra","views/external-account/index":"extra","views/email-account/list":"extra","views/email-account/record/list":"extra","views/email-account/record/edit":"extra","views/email-account/modals/select-folder":"extra","views/email-account/fields/email-folder":"extra","views/email-account/fields/email-address":"extra","modules/crm/views/meeting/record/row-actions/default":"crm","modules/crm/views/meeting/fields/attendees":"crm","modules/crm/views/calendar/fields/teams":"crm","modules/crm/knowledge-base-helper":"crm","modules/crm/views/task/record/list":"crm","modules/crm/views/task/record/row-actions/default":"crm","modules/crm/views/record/panels/tasks":"crm","modules/crm/views/record/panels/activities":"crm","modules/crm/views/meeting/detail":"crm","modules/crm/views/meeting/record/list":"crm","modules/crm/views/meeting/record/row-actions/dashlet":"crm","modules/crm/views/mass-email/record/edit":"crm","modules/crm/views/mass-email/modals/send-test":"crm","modules/crm/views/dashlets/options/chart":"crm","modules/crm/views/contact/record/detail":"crm","modules/crm/views/call/record/list":"crm","modules/crm/views/call/fields/contacts":"crm","modules/crm/views/calendar/modals/edit-view":"crm","modules/crm/views/calendar/fields/users":"crm","modules/crm/acl/meeting":"crm","modules/crm/views/user/record/panels/tasks":"crm","modules/crm/views/task/list":"crm","modules/crm/views/task/detail":"crm","modules/crm/views/task/record/list-expanded":"crm","modules/crm/views/task/record/detail":"crm","modules/crm/views/task/record/row-actions/dashlet":"crm","modules/crm/views/task/fields/tasks":"crm","modules/crm/views/task/fields/priority-for-dashlet":"crm","modules/crm/views/task/fields/is-overdue":"crm","modules/crm/views/task/fields/date-end":"crm","modules/crm/views/target-list/record/detail":"crm","modules/crm/views/target-list/record/row-actions/opted-out":"crm","modules/crm/views/target-list/record/row-actions/default":"crm","modules/crm/views/target-list/record/panels/relationship":"crm","modules/crm/views/target-list/record/panels/opted-out":"crm","modules/crm/views/target-list/fields/target-status":"crm","modules/crm/views/target-list/fields/including-action-list":"crm","modules/crm/views/stream/notes/event-confirmation":"crm","modules/crm/views/record/list-activities-dashlet":"crm","modules/crm/views/record/row-actions/tasks":"crm","modules/crm/views/record/row-actions/relationship-target":"crm","modules/crm/views/record/row-actions/history":"crm","modules/crm/views/record/row-actions/activities":"crm","modules/crm/views/record/row-actions/activities-dashlet":"crm","modules/crm/views/record/panels/target-lists":"crm","modules/crm/views/record/panels/history":"crm","modules/crm/views/opportunity/detail":"crm","modules/crm/views/opportunity/record/list":"crm","modules/crm/views/opportunity/record/kanban":"crm","modules/crm/views/opportunity/record/edit":"crm","modules/crm/views/opportunity/record/edit-small":"crm","modules/crm/views/opportunity/record/panels/activities":"crm","modules/crm/views/opportunity/fields/stage":"crm","modules/crm/views/opportunity/fields/lead-source":"crm","modules/crm/views/opportunity/fields/last-stage":"crm","modules/crm/views/opportunity/fields/contacts":"crm","modules/crm/views/opportunity/fields/contact-role":"crm","modules/crm/views/opportunity/admin/field-manager/fields/probability-map":"crm","modules/crm/views/notification/items/event-attendee":"crm","modules/crm/views/meeting/popup-notification":"crm","modules/crm/views/meeting/record/list-expanded":"crm","modules/crm/views/meeting/record/edit-small":"crm","modules/crm/views/meeting/record/detail":"crm","modules/crm/views/meeting/record/panels/scheduler":"crm","modules/crm/views/meeting/record/panels/attendees":"crm","modules/crm/views/meeting/modals/send-invitations":"crm","modules/crm/views/meeting/modals/send-cancellation":"crm","modules/crm/views/meeting/modals/detail":"crm","modules/crm/views/meeting/modals/acceptance-status":"crm","modules/crm/views/meeting/fields/users":"crm","modules/crm/views/meeting/fields/reminders":"crm","modules/crm/views/meeting/fields/external-service":"crm","modules/crm/views/meeting/fields/date-start":"crm","modules/crm/views/meeting/fields/date-end":"crm","modules/crm/views/meeting/fields/contacts":"crm","modules/crm/views/meeting/fields/acceptance-status":"crm","modules/crm/views/mass-email/detail":"crm","modules/crm/views/mass-email/record/list-for-campaign":"crm","modules/crm/views/mass-email/record/edit-small":"crm","modules/crm/views/mass-email/record/detail":"crm","modules/crm/views/mass-email/record/detail-bottom":"crm","modules/crm/views/mass-email/record/row-actions/for-campaign":"crm","modules/crm/views/mass-email/fields/smtp-account":"crm","modules/crm/views/mass-email/fields/from-address":"crm","modules/crm/views/mass-email/fields/email-template":"crm","modules/crm/views/lead/detail":"crm","modules/crm/views/lead/convert":"crm","modules/crm/views/lead/record/detail":"crm","modules/crm/views/lead/record/detail-side":"crm","modules/crm/views/lead/record/panels/converted-to":"crm","modules/crm/views/lead/fields/industry":"crm","modules/crm/views/lead/fields/created-opportunity":"crm","modules/crm/views/lead/fields/created-contact":"crm","modules/crm/views/lead/fields/acceptance-status":"crm","modules/crm/views/knowledge-base-article/list":"crm","modules/crm/views/knowledge-base-article/record/list":"crm","modules/crm/views/knowledge-base-article/record/edit":"crm","modules/crm/views/knowledge-base-article/record/edit-quick":"crm","modules/crm/views/knowledge-base-article/record/detail":"crm","modules/crm/views/knowledge-base-article/record/detail-quick":"crm","modules/crm/views/knowledge-base-article/modals/select-records":"crm","modules/crm/views/knowledge-base-article/fields/status":"crm","modules/crm/views/knowledge-base-article/fields/language":"crm","modules/crm/views/fields/ico":"crm","modules/crm/views/event-confirmation/confirmation":"crm","modules/crm/views/email-queue-item/list":"crm","modules/crm/views/email-queue-item/record/list":"crm","modules/crm/views/document/list":"crm","modules/crm/views/document/modals/select-records":"crm","modules/crm/views/document/fields/name":"crm","modules/crm/views/document/fields/file":"crm","modules/crm/views/dashlets/tasks":"crm","modules/crm/views/dashlets/meetings":"crm","modules/crm/views/dashlets/calls":"crm","modules/crm/views/dashlets/calendar":"crm","modules/crm/views/dashlets/activities":"crm","modules/crm/views/dashlets/options/sales-pipeline":"crm","modules/crm/views/dashlets/options/calendar":"crm","modules/crm/views/dashlets/options/activities":"crm","modules/crm/views/dashlets/options/sales-pipeline/fields/team":"crm","modules/crm/views/contact/detail":"crm","modules/crm/views/contact/record/detail-small":"crm","modules/crm/views/contact/modals/select-for-portal-user":"crm","modules/crm/views/contact/fields/title":"crm","modules/crm/views/contact/fields/opportunity-role":"crm","modules/crm/views/contact/fields/name-for-account":"crm","modules/crm/views/contact/fields/accounts":"crm","modules/crm/views/contact/fields/account":"crm","modules/crm/views/contact/fields/account-role":"crm","modules/crm/views/case/record/detail":"crm","modules/crm/views/case/record/panels/activities":"crm","modules/crm/views/campaign-tracking-url/record/edit":"crm","modules/crm/views/campaign-tracking-url/record/edit-small":"crm","modules/crm/views/campaign-log-record/fields/data":"crm","modules/crm/views/campaign/unsubscribe":"crm","modules/crm/views/campaign/tracking-url":"crm","modules/crm/views/campaign/detail":"crm","modules/crm/views/campaign/record/detail":"crm","modules/crm/views/campaign/record/panels/campaign-stats":"crm","modules/crm/views/campaign/record/panels/campaign-log-records":"crm","modules/crm/views/campaign/modals/mail-merge-pdf":"crm","modules/crm/views/campaign/fields/template":"crm","modules/crm/views/campaign/fields/int-with-percentage":"crm","modules/crm/views/call/detail":"crm","modules/crm/views/call/record/list-expanded":"crm","modules/crm/views/call/record/edit-small":"crm","modules/crm/views/call/record/detail":"crm","modules/crm/views/call/record/row-actions/default":"crm","modules/crm/views/call/record/row-actions/dashlet":"crm","modules/crm/views/call/fields/leads":"crm","modules/crm/views/call/fields/date-start":"crm","modules/crm/views/calendar/mode-buttons":"crm","modules/crm/views/calendar/calendar-page":"crm","modules/crm/views/calendar/modals/shared-options":"crm","modules/crm/views/calendar/modals/edit":"crm","modules/crm/views/admin/entity-manager/fields/status-list":"crm","modules/crm/views/activities/list":"crm","modules/crm/views/account/detail":"crm","modules/crm/views/account/fields/shipping-address":"crm","modules/crm/view-setup-handlers/document/record-list-drag-n-drop":"crm","modules/crm/handlers/task/reminders-handler":"crm","modules/crm/handlers/task/menu":"crm","modules/crm/handlers/task/detail-actions":"crm","modules/crm/handlers/opportunity/defaults-preparator":"crm","modules/crm/handlers/opportunity/contacts-create":"crm","modules/crm/handlers/meeting/external-service":"crm","modules/crm/handlers/knowledge-base-article/send-in-email":"crm","modules/crm/handlers/knowledge-base-article/move":"crm","modules/crm/handlers/event/reminders-handler":"crm","modules/crm/handlers/case/detail-actions":"crm","modules/crm/handlers/campaign/mass-emails-create":"crm","modules/crm/controllers/unsubscribe":"crm","modules/crm/controllers/tracking-url":"crm","modules/crm/controllers/task":"crm","modules/crm/controllers/lead":"crm","modules/crm/controllers/event-confirmation":"crm","modules/crm/controllers/calendar":"crm","modules/crm/controllers/activities":"crm","modules/crm/acl-portal/document":"crm","modules/crm/acl-portal/contact":"crm","modules/crm/acl-portal/account":"crm","modules/crm/acl/mass-email":"crm","modules/crm/acl/campaign-tracking-url":"crm","modules/crm/acl/call":"crm","modules/crm/views/dashlets/abstract/chart":"chart","modules/crm/views/dashlets/sales-pipeline":"chart","modules/crm/views/dashlets/sales-by-month":"chart","modules/crm/views/dashlets/opportunities-by-stage":"chart","modules/crm/views/dashlets/opportunities-by-lead-source":"chart","modules/crm/views/calendar/calendar":"calendar","modules/crm/views/scheduler/scheduler":"timeline","modules/crm/views/calendar/timeline":"timeline"});

Espo.layoutTemplates = {"record":"<% var hasHiddenPanel = false; %>\r\n\r\n<% _.each(layout, function (panel, columnNumber) { %>\r\n    <% hasHiddenPanel = panel.hidden || hasHiddenPanel; %>\r\n    <div\r\n        class=\"panel panel-<%= panel.style %><%= panel.label ? ' headered' : '' %><%= panel.tabNumber ? ' tab-hidden' : '' %><% if (panel.name) { %>{{#if hiddenPanels.<%= panel.name %>}} hidden{{/if}}<% } %>\"\r\n        <% if (panel.name) print('data-name=\"'+panel.name+'\"') %>\r\n        <% if (panel.style) print('data-style=\"'+panel.style+'\"') %>\r\n        data-tab=\"<%= panel.tabNumber %>\"\r\n    >\r\n        <% if (panel.label) { %>\r\n        <div class=\"panel-heading\"><h4 class=\"panel-title\"><%= panel.label %></h4></div>\r\n        <% } %>\r\n        <div class=\"panel-body panel-body-form\">\r\n\r\n        <% if (panel.noteText) { %>\r\n        <div class=\"alert alert-<%= panel.noteStyle %>\"><%= panel.noteText %></div>\r\n        <% } %>\r\n\r\n        <% var rows = panel.rows || [] %>\r\n        <% var columns = panel.columns || [] %>\r\n\r\n        <% _.each(rows, function (row, rowNumber) { %>\r\n            <div class=\"row\">\r\n            <% var columnCount = row.length; %>\r\n            <% _.each(row, function (cell, cellNumber) { %>\r\n\r\n                <%\r\n                    var spanClassBase;\r\n                    if (columnCount === 1) {\r\n                        spanClassBase = 'col-sm-12';\r\n                    } else if (columnCount === 2) {\r\n                        spanClassBase = 'col-sm-6';\r\n                    } else if (columnCount === 3) {\r\n                        spanClassBase = 'col-sm-4';\r\n                    } else if (columnCount === 4) {\r\n                        spanClassBase = 'col-md-3 col-sm-6';\r\n                    } else {\r\n                        spanClass = 'col-sm-12';\r\n                    }\r\n                %>\r\n                <% if (cell != false) { %>\r\n                    <%\r\n                        var spanClass;\r\n                        if (columnCount === 1 || cell.fullWidth) {\r\n                            spanClass = 'col-sm-12';\r\n                        } else if (columnCount === 2) {\r\n                            if (cell.span === 2) {\r\n                                spanClass = 'col-sm-12';\r\n                            } else {\r\n                                spanClass = 'col-sm-6';\r\n                            }\r\n                        } else if (columnCount === 3) {\r\n                            if (cell.span === 2) {\r\n                                spanClass = 'col-sm-8';\r\n                            } else if (cell.span === 3) {\r\n                                spanClass = 'col-sm-12';\r\n                            } else {\r\n                                spanClass = 'col-sm-4';\r\n                            }\r\n                        } else if (columnCount === 4) {\r\n                            if (cell.span === 2) {\r\n                                spanClass = 'col-sm-6';\r\n                            } else if (cell.span === 3) {\r\n                                spanClass = 'col-sm-9';\r\n                            } else if (cell.span === 4) {\r\n                                spanClass = 'col-sm-12';\r\n                            } else {\r\n                                spanClass = 'col-md-3 col-sm-6';\r\n                            }\r\n                        } else {\r\n                            spanClass = 'col-sm-12';\r\n                        }\r\n                    %>\r\n                    <div\r\n                        class=\"cell <%= spanClass %> form-group<% if (cell.field) { %>{{#if hiddenFields.<%= cell.field %>}} hidden-cell{{/if}}<% } %>\"\r\n                        data-name=\"<%= cell.field %>\"\r\n                        tabindex=\"-1\"\r\n                    >\r\n                        <% if (!cell.noLabel) { %><label class=\"control-label<% if (cell.field) { %>{{#if hiddenFields.<%= cell.field %>}} hidden{{/if}}<% } %>\" data-name=\"<%= cell.field %>\"><span class=\"label-text\"><%\r\n                            if ('customLabel' in cell) {\r\n                                print (cell.customLabel);\r\n                            } else {\r\n                                var label = cell.label || cell.field;\r\n                                print (\"{{translate \\\"\"+label+\"\\\" scope=\\\"\"+model.name+\"\\\" category='fields'}}\");\r\n                            }\r\n                        %></span></label><% } %>\r\n                        <div class=\"field<% if (cell.field) { %>{{#if hiddenFields.<%= cell.field %>}} hidden{{/if}}<% } %>\" data-name=\"<%= cell.field %>\"><%\r\n                            if ('customCode' in cell) {\r\n                                print (cell.customCode);\r\n                            } else {\r\n                                print (\"{{{this.\"+cell.name+\"}}}\");\r\n                            }\r\n                        %></div>\r\n                    </div>\r\n                <% } else { %>\r\n                    <div class=\"<%= spanClassBase %>\"></div>\r\n                <% } %>\r\n            <% }); %>\r\n            </div>\r\n        <% }); %>\r\n\r\n        <%\r\n            var columnCount = columns.length;\r\n            if (columnCount) {\r\n                %>\r\n            <div class=\"row\">\r\n                <%\r\n            }\r\n        %>\r\n        <% _.each(columns, function (column, columnNumber) { %>\r\n            <%\r\n                var spanClass;\r\n                if (!columnCount) return;\r\n\r\n                if (columnCount === 1 || column.fullWidth) {\r\n                    spanClass = 'col-sm-12';\r\n                } else if (columnCount === 2) {\r\n                    if (column.span === 2) {\r\n                        spanClass = 'col-sm-12';\r\n                    } else {\r\n                        spanClass = 'col-sm-6';\r\n                    }\r\n                } else if (columnCount === 3) {\r\n                    if (column.span === 2) {\r\n                        spanClass = 'col-sm-8';\r\n                    } else if (column.span === 3) {\r\n                        spanClass = 'col-sm-12';\r\n                    } else {\r\n                        spanClass = 'col-sm-4';\r\n                    }\r\n                } else if (columnCount === 4) {\r\n                    if (column.span === 2) {\r\n                        spanClass = 'col-sm-6';\r\n                    } else if (column.span === 3) {\r\n                        spanClass = 'col-sm-9';\r\n                    } else if (column.span === 4) {\r\n                        spanClass = 'col-sm-12';\r\n                    } else {\r\n                        spanClass = 'col-md-3 col-sm-6';\r\n                    }\r\n                } else {\r\n                    spanClass = 'col-sm-12';\r\n                }\r\n            %>\r\n            <div class=\"column <%= spanClass %>\">\r\n                <% _.each(column, function (cell, cellNumber) { %>\r\n                    <div class=\"cell form-group<% if (cell.field) { %>{{#if hiddenFields.<%= cell.field %>}} hidden-cell{{/if}}<% } %>\" data-name=\"<%= cell.field %>\">\r\n                        <% if (!cell.noLabel) { %><label class=\"control-label<% if (cell.field) { %>{{#if hiddenFields.<%= cell.field %>}} hidden{{/if}}<% } %>\" data-name=\"<%= cell.field %>\"><span class=\"label-text\"><%\r\n                            if ('customLabel' in cell) {\r\n                                print (cell.customLabel);\r\n                            } else {\r\n                                print (\"{{translate \\\"\"+cell.field+\"\\\" scope=\\\"\"+model.name+\"\\\" category='fields'}}\");\r\n                            }\r\n                        %></span></label><% } %>\r\n                        <div class=\"field<% if (cell.field) { %>{{#if hiddenFields.<%= cell.field %>}} hidden{{/if}}<% } %>\" data-name=\"<%= cell.field %>\"><%\r\n                            if ('customCode' in cell) {\r\n                                print (cell.customCode);\r\n                            } else {\r\n                                print (\"{{{this.\"+cell.name+\"}}}\");\r\n                            }\r\n                        %></div>\r\n                    </div>\r\n                <% }); %>\r\n            </div>\r\n        <% }); %>\r\n        <%\r\n            if (columnCount) {\r\n                %>\r\n            </div>\r\n                <%\r\n            }\r\n        %>\r\n        </div>\r\n    </div>\r\n<% }); %>\r\n\r\n<%\r\nif (hasHiddenPanel) {\r\n%>\r\n<div class=\"panel panel-default panels-show-more-delimiter\" data-name=\"showMoreDelimiter\" data-tab=\"0\">\r\n    <a role=\"button\" tabindex=\"0\" data-action=\"showMoreDetailPanels\" title=\"{{translate 'Show more'}}\">\r\n        <span class=\"fas fa-ellipsis-h fa-lg\"></span>\r\n    </a>\r\n</div>\r\n<%\r\n}\r\n%>\r\n","list-row":"<% _.each(layout, function (defs, key) { %>\r\n    <%\r\n        let width = null;\r\n\r\n        if (defs.options && defs.options.defs && defs.options.defs.width !== undefined) {\r\n            width = (defs.options.defs.width + '%') || null;\r\n        }\r\n\r\n        if (defs.options && defs.options.defs && defs.options.defs.widthPx !== undefined) {\r\n            width = defs.options.defs.widthPx || null;\r\n        }\r\n\r\n        let align = false;\r\n\r\n        if (defs.options && defs.options.defs) {\r\n            align = defs.options.defs.align || false;\r\n        }\r\n    %>\r\n    <td\r\n        class=\"cell\"\r\n        data-name=\"<%= defs.columnName %>\"\r\n        <% if (width || align) { %>\r\n        style=\"<% if (width) print('width: ' + width); %>;<% if (align) print(' text-align: ' + align);%>\"\r\n        <% } %>\r\n    >\r\n    <%\r\n            var tag = 'tag' in defs ? defs.tag : false;\r\n            if (tag) {\r\n                print( '<' + tag);\r\n                if ('id' in defs) {\r\n                    print(' id=\"'+defs.id+'\"');\r\n                }\r\n                if ('class' in defs) {\r\n                    print(' class=\"'+defs.class+'\"');\r\n                };\r\n                print('>');\r\n            }\r\n        %>{{{this.<%= defs.name %>}}}<%\r\n            if (tag) {\r\n                print( '</' + tag + '>');\r\n            }\r\n    %>\r\n    </td>\r\n<% }); %>\r\n","list-row-expanded":"<% if (layout.right) { %>\r\n<div class=\"pull-right right cell\" data-name=\"buttons\">\r\n    {{{<%= layout.right.name %>}}}\r\n</div>\r\n<% } %>\r\n<% _.each(layout.rows, function (row, key) { %><div class=\"expanded-row\"><% _.each(row, function (defs, key) { %><span class=\"cell<%= defs.align ? ' pull-right' : '' %><%= defs.small ? ' small' : '' %><%= defs.soft ? ' text-soft' : '' %>\" data-name=\"<%= defs.field %>\"><%\r\n                var tag = 'tag' in defs ? defs.tag : false;\r\n                if (tag) {\r\n                    print( '<' + tag);\r\n                    if ('id' in defs) {\r\n                        print(' id=\"'+defs.id+'\"');\r\n                    }\r\n                    if ('class' in defs) {\r\n                        print(' class=\"'+defs.class+'\"');\r\n                    };\r\n                    print('>');\r\n                }\r\n            %>{{{this.<%= defs.name %>}}}<%\r\n                if (tag) {\r\n                    print( '</' + tag + '>');\r\n                }\r\n        %></span><% }); %></div>\r\n<% }); %>\r\n","default":"<% _.each(layout, function (defs, key) {\r\n        var tag = 'tag' in defs ? defs.tag : 'div';\r\n        print( '<' + tag);\r\n        if ('id' in defs) {\r\n            print(' id=\"'+defs.id+'\"');\r\n        }\r\n        if ('class' in defs) {\r\n            print(' class=\"'+defs.class+'\"');\r\n        }\r\n        print('>');\r\n    %>\r\n        {{{this.<%= defs.name %>}}}\r\n        <%= '</' + tag + '>' %>\r\n<% }); %>\r\n","columns-2":"<% _.each(layout, function (row, rowNumber) { %>\r\n    <div class=\"col-sm-6\">\r\n    <% _.each(row, function (defs, key) { %>\r\n        <%\r\n            var tag = 'tag' in defs ? defs.tag : 'div';\r\n            print( '<' + tag);\r\n            if ('id' in defs) {\r\n                print(' id=\"'+defs.id+'\"');\r\n            }\r\n            print(' class=\"');\r\n            if ('class' in defs) {\r\n                print(defs.class);\r\n            };\r\n            print('\"');\r\n            print('>');\r\n        %>\r\n            {{{this.<%= defs.name %>}}}\r\n            <%= '</' + tag + '>' %>\r\n    <% }); %>\r\n    </div>\r\n<% }); %>\r\n"};
