소재지 ₍₍◝(・'ω'・)◟⁾⁾ 🐟️?看XM(^_−)☆哈先看看刚看过卡卡国看过了回来冷藏柜好极过估计 PNG %k25u25%fgd5n!/*! espocrm 2023-11-08 */ define("view",["exports","bullbone"],function(e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;class i extends t.View{whenReady(){return this.isReady?Promise.resolve():new Promise(e=>{this.once("ready",()=>e())})}addActionHandler(e,t){this.events[`click [data-action="${e}"]`]=e=>{t.call(this,e.originalEvent,e.currentTarget)}}escapeString(e){return Handlebars.Utils.escapeExpression(e)}notify(e,t,i,s){e?(s=s||null,i=t?i||2e3:void 0,e=this.getLanguage().translate(e,"labels",s),Espo.Ui.notify(e,t,i)):Espo.Ui.notify(!1)}getHelper(){return this._helper}getUser(){return this._helper.user}getPreferences(){return this._helper.preferences}getConfig(){return this._helper.settings}getAcl(){return this._helper.acl}getModelFactory(){return this._helper.modelFactory}getCollectionFactory(){return this._helper.collectionFactory}getRouter(){return this._helper.router}getStorage(){return this._helper.storage}getSessionStorage(){return this._helper.sessionStorage}getLanguage(){return this._helper.language}getMetadata(){return this._helper.metadata}getCache(){return this._helper.cache}getDateTime(){return this._helper.dateTime}getNumberUtil(){return this._helper.numberUtil}getFieldManager(){return this._helper.fieldManager}getBaseController(){return this._helper.baseController}getThemeManager(){return this._helper.themeManager}updatePageTitle(){var e=this.getConfig().get("applicationName")||"EspoCRM";this.setPageTitle(e)}setPageTitle(e){this.getHelper().pageTitle.setTitle(e)}translate(e,t,i){return this.getLanguage().translate(e,t,i)}getBasePath(){return this._helper.basePath||""}ajaxRequest(e,t,i,s){return Espo.Ajax.request(e,t,i,s)}ajaxPostRequest(e,t,i){return Espo.Ajax.postRequest(e,t,i)}ajaxGetRequest(e,t,i){return Espo.Ajax.getRequest(e,t,i)}confirm(e,t,i){let s;"string"==typeof e||e instanceof String?(s=e,e={}):(e=e||{},s=e.message),s=s&&this.getHelper().transformMarkdownText(s,{linksInNewTab:!0}).toString();var a=e.confirmText||this.translate("Yes"),l=e.confirmStyle||null,o=e.cancelText||this.translate("Cancel");return Espo.Ui.confirm(s,{confirmText:a,cancelText:o,confirmStyle:l,backdrop:!("backdrop"in e)||e.backdrop,isHtml:!0},t,i)}}e.default=i}),define("ui/select",["exports","lib!selectize"],function(e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,t=(i=t)&&i.__esModule?i:{default:i};const d={init:function(e,t={}){const i=t.score,s=$(e),a=(t=d.applyDefaultOptions(t||{}),[]),l=(d.loadEspoSelectPlugin(),a.push("espo_select"),{}),o=s.children().toArray().map(e=>{var t=e.getAttributeNode("value").value;return e.classList&&(l[t]=e.classList.toString()),t});let r=null;e=s.closest(".modal-body");e.length&&(r=e);const n={sortField:[{field:t.sortBy,direction:t.sortDirection}],load:t.load,loadThrottle:1,plugins:a,highlight:!1,selectOnTab:t.selectOnTab,copyClassesToDropdown:!1,allowEmptyOption:o.includes(""),showEmptyOptionInDropdown:!0,$relativeParent:r,render:{item:function(e){return $("
").addClass("item").addClass(l[e.value]||"").text(e.text).get(0).outerHTML},option:function(e){const t=$("
").addClass("option").addClass(""===e.value?"selectize-dropdown-emptyoptionlabel":"").addClass(l[e.value]||"").val(e.value).text(e.text);return""===e.text&&t.html(" "),t.get(0).outerHTML}},onDelete:function(e){for(;e.length;)this.removeItem(e.pop(),!0);this.showInput(),this.positionDropdown(),this.refreshOptions(!0)}};t.matchAnyWord||(n.score=function(t){const i=this.getScoreFunction(t);return t=t.toLowerCase(),function(e){return 0===e.text.toLowerCase().indexOf(t)?i(e):0}}),t.matchAnyWord&&(n.score=function(i){const s=this.getScoreFunction(i);return i=i.toLowerCase(),function(e){const t=e.text.toLowerCase();return t.split(" ").find(e=>e.startsWith(i))||t.startsWith(i)?s(e):0}}),t.score&&(n.score=function(t){return function(e){return i(t,e)}}),s.selectize(n)},focus:function(e,t){e=$(e);if(t=t||{},e[0]&&e[0].selectize){const i=e[0].selectize;t.noTrigger&&(i.focusNoTrigger=!0),i.focus(),t.noTrigger&&setTimeout(()=>i.focusNoTrigger=!1,100)}},setOptions:function(e,t){const i=$(e),s=i.get(0).selectize;s.clearOptions(!0),s.load(e=>{e(t.map(e=>({value:e.value,text:e.text||e.label})))})},setValue:function(e,t){const i=e.get(0).selectize;i.setValue(t,!0)},destroy:function(e){e.length&&e[0].selectize&&e[0].selectize.destroy()},applyDefaultOptions:function(e){e=Espo.Utils.clone(e);var t={selectOnTab:!1,matchAnyWord:!1,sortBy:"$order",sortDirection:"asc"};for(const i in t)i in e||(e[i]=t[i]);return e},loadEspoSelectPlugin:function(){if(!("espo_select"in t.default.plugins)){const s=/Mac/.test(navigator.userAgent);t.default.define("espo_select",function(){const n=this;this.setup=function(){const e=n.setup;return function(){e.apply(this,arguments),n.selectedValue=n.items[0],n.$dropdown.on("mouseup","[data-selectable]",function(){return $(document).off("mouseup.select"),n.onOptionSelect.apply(n,arguments)}),n.$dropdown.on("mousedown","[data-selectable]",function(){$(document).one("mouseup.select",function(){n.focusOnControlSilently()})}),n.$control_input.css({width:"4px"})}}(),this.focusOnControlSilently=function(){n.preventReOpenOnFocus=!0,n.$control_input[0].focus(),n.preventReOpenOnFocus=!1},this.refreshOptions=function(){const e=n.refreshOptions;return function(){n.focusNoTrigger?e.apply(this,[!1]):e.apply(this,arguments)}}(),this.blur=function(){const e=n.blur;return function(){n.preventClose||e.apply(this,arguments)}}(),this.close=function(){const e=n.close;return function(){n.preventClose||e.apply(this,arguments)}}(),this.onOptionSelect=function(){const t=n.onOptionSelect;return function(e){if("mousedown"===e.type||"click"===e.type)return n.preventClose=!0,void setTimeout(()=>n.preventClose=!1,100);n.preventClose=!1,"mouseup"===e.type&&setTimeout(()=>n.focusOnControlSilently(),50),t.apply(this,arguments),n.selectedValue=$(e.currentTarget).attr("data-value")}}(),this.open=function(){const s=n.open;return function(){var e=!(n.isLocked||n.isOpen);if(s.apply(this,arguments),e){const t=n.$dropdown.children().first(),i=t.find(".selected");if(i.length){let e=i.get(0).offsetTop-t.get(0).clientHeight;e=0<=e?e:0,t.find(".selectize-dropdown-content").scrollTop(e)}}}}(),this.onMouseDown=function(){const t=n.onMouseDown;return function(e){if(n.isOpen||n.isInputHidden||!n.$control_input.val())return n.isOpen&&(n.closedByMouseDown=!0),t.apply(this,arguments)}}(),this.onFocus=function(){const t=n.onFocus;return function(e){if(!n.preventReOpenOnFocus){if(!n.closedByMouseDown)return n.closedByMouseDown=!1,t.apply(this,arguments);n.closedByMouseDown=!1}}}(),this.restoreSelectedValue=function(){this.preventRevertLoop||(this.preventRevertLoop=!0,setTimeout(()=>this.preventRevertLoop=!1,10),this.setValue(this.selectedValue,!0))},this.onBlur=function(){const e=n.onBlur;return function(){if(!n.preventClose)return n.restoreSelectedValue(),n.$control_input.css({width:"4px"}),e.apply(this,arguments)}}(),this.onKeyDown=function(){const i=n.onKeyDown;return function(e){var t;if(s?!e.metaKey:!e.ctrlKey)return"Escape"===e.code&&(!n.isOpen&&n.isInputHidden||e.stopPropagation(),n.isOpen&&n.close(),n.isInputHidden||n.hideInput(),n.addItem(this.selectedValue,!0)),(n.isFull()||n.isInputHidden)&&1===e.key.length&&(e.code.match(/Key[A-Z]/i)||e.key.match(/[0-9]/)||RegExp(/^\p{L}/,"u").test(e.key))&&(t=e.keyCode,e.keyCode=8,n.deleteSelection(e),e.keyCode=t,n.$control_input.width(15)),i.apply(this,arguments);n.items.length||(n.restoreSelectedValue(),n.focus())}}(),this.positionDropdown=function(){const r={top:"top",bottom:"bottom"};return function(){const e=n.$control,t="body"===this.settings.dropdownParent?e.offset():e.position();t.top+=e.outerHeight(!0);var i=n.$dropdown.prop("scrollHeight")+5,s=n.$control.get(0).getBoundingClientRect().top,a=n.$wrapper.height(),l=n.$control.get(0).getBoundingClientRect().bottom,o=this.settings.$relativeParent?this.settings.$relativeParent.get(0).getBoundingClientRect().top:0,s=s+i+a>window.innerHeight&&o<=l-i-a?r.top:r.bottom,o={width:e.outerWidth(),left:t.left};s===r.top?(Object.assign(o,{bottom:t.top,top:"unset",margin:"0 0 0 0"}),n.$dropdown.addClass("selectize-position-top")):(Object.assign(o,{top:t.top,bottom:"unset",margin:"0 0 0 0"}),n.$dropdown.removeClass("selectize-position-top")),n.$dropdown.css(o)}}()})}}};var i=d;e.default=i}),define("view-record-helper",["exports","bullbone"],function(e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;class i{constructor(e,t){this.defaultFieldStates=e||{},this.defaultPanelStates=t||{},this.fieldStateMap={},this.panelStateMap={},this.hiddenFields={},this.hiddenPanels={},this.fieldOptionListMap={}}getHiddenFields(){return this.hiddenFields}getHiddenPanels(){return this.hiddenPanels}setFieldStateParam(e,t,i){"hidden"===t&&(i?this.hiddenFields[e]=!0:delete this.hiddenFields[e]),this.fieldStateMap[e]=this.fieldStateMap[e]||{},this.fieldStateMap[e][t]=i,this.trigger("field-change")}getFieldStateParam(e,t){return e in this.fieldStateMap&&t in this.fieldStateMap[e]?this.fieldStateMap[e][t]:t in this.defaultFieldStates?this.defaultFieldStates[t]:null}setPanelStateParam(e,t,i){"hidden"===t&&(i?this.hiddenPanels[e]=!0:delete this.hiddenPanels[e]),this.panelStateMap[e]=this.panelStateMap[e]||{},this.panelStateMap[e][t]=i}getPanelStateParam(e,t){return e in this.panelStateMap&&t in this.panelStateMap[e]?this.panelStateMap[e][t]:t in this.defaultPanelStates?this.defaultPanelStates[t]:null}setFieldOptionList(e,t){this.fieldOptionListMap[e]=t}clearFieldOptionList(e){delete this.fieldOptionListMap[e]}getFieldOptionList(e){return this.fieldOptionListMap[e]||null}hasFieldOptionList(e){return e in this.fieldOptionListMap}}Object.assign(i.prototype,t.Events),e.default=i}),define("dynamic-logic",["exports"],function(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;e.default=class{constructor(e,t){this.defs=e||{},this.recordView=t,this.fieldTypeList=["visible","required","readOnly"],this.panelTypeList=["visible","styled"]}process(){let t=this.defs.fields||{};Object.keys(t).forEach(s=>{var e=t[s]||{};this.fieldTypeList.forEach(t=>{if(t in e&&e[t]){var i=e[t]||{};if(i.conditionGroup){i=this.checkConditionGroup(i.conditionGroup);let e;this[e=i?"makeField"+Espo.Utils.upperCaseFirst(t)+"True":"makeField"+Espo.Utils.upperCaseFirst(t)+"False"](s)}}})});var e=this.defs.panels||{};Object.keys(e).forEach(t=>{this.panelTypeList.forEach(e=>{this.processPanel(t,e)})});let a=this.defs.options||{};Object.keys(a).forEach(t=>{var i=a[t];if(a[t]){let e=!1;for(var s in i){s=i[s];if(this.checkConditionGroup(s.conditionGroup)){this.setOptionList(t,s.optionList||[]),e=!0;break}}e||this.resetOptionList(t)}})}processPanel(t,i){var s=(this.defs.panels||{})[t]||{};if(i in s){s=s[i]||{};if(s.conditionGroup){s=this.checkConditionGroup(s.conditionGroup);let e;this[e=s?"makePanel"+Espo.Utils.upperCaseFirst(i)+"True":"makePanel"+Espo.Utils.upperCaseFirst(i)+"False"](t)}}}checkConditionGroup(e,t){let i,s=!1;if("and"===(t=t||"and")){for(var a in i=e||[],s=!0,i)if(!this.checkCondition(i[a])){s=!1;break}}else if("or"===t){for(var l in i=e||[])if(this.checkCondition(i[l])){s=!0;break}}else"not"===t&&e&&(s=!this.checkCondition(e));return s}checkCondition(t){var e=(t=t||{}).type||"equals";if(["or","and","not"].includes(e))return this.checkConditionGroup(t.value,e);var i=t.attribute;let s=t.value;if(!i)return!1;t=this.recordView.model.get(i);if("equals"===e)return!!s&&t===s;if("notEquals"===e)return!!s&&t!==s;if("isEmpty"===e)return Array.isArray(t)?!t.length:null===t||""===t||void 0===t;if("isNotEmpty"===e)return Array.isArray(t)?!!t.length:null!==t&&""!==t&&void 0!==t;if("isTrue"===e)return!!t;if("isFalse"===e)return!t;if("contains"===e||"has"===e)return!!t&&!!~t.indexOf(s);if("notContains"===e||"notHas"===e)return!t||!~t.indexOf(s);if("startsWith"===e)return!!t&&0===t.indexOf(s);if("endsWith"===e)return!!t&&t.indexOf(s)===t.length-s.length;if("matches"===e){if(!t)return!1;i=/^\/(.*)\/([a-z]*)$/.exec(s);return!i||i.length<2?!1:new RegExp(i[1],i[2]).test(t)}if("greaterThan"===e)return t>s;if("lessThan"===e)return t=s;if("lessThanOrEquals"===e)return t<=s;if("in"===e)return!!~s.indexOf(t);if("notIn"===e)return!~s.indexOf(t);if("isToday"===e){let e=this.recordView.getDateTime();return t?(10{this.showRequiredSign()}))}setNotRequired(){this.params.required=!1,this.get$cell().removeClass("has-error"),this.isEditMode()&&(this.isRendered()?this.hideRequiredSign():this.once("after:render",()=>{this.hideRequiredSign()}))}setReadOnly(e){return this.readOnlyLocked?Promise.reject():(this.readOnly=!0,e&&(this.readOnlyLocked=!0),this.isEditMode()?this.isInlineEditMode()?this.inlineEditClose():this.setDetailMode().then(()=>this.reRender()):Promise.resolve())}setNotReadOnly(){this.readOnlyLocked||(this.readOnly=!1)}getLabelElement(){return this.$label&&this.$label.get(0)&&!document.contains(this.$label.get(0))&&(this.$label=void 0),this.$label&&this.$label.length||(this.$label=this.$el.parent().children("label")),this.$label}hide(){this.$el.addClass("hidden");let e=this.get$cell();e.children("label").addClass("hidden"),e.addClass("hidden-cell")}show(){this.$el.removeClass("hidden");let e=this.get$cell();e.children("label").removeClass("hidden"),e.removeClass("hidden-cell")}data(){let e={scope:this.model.entityType||this.model.name,name:this.name,defs:this.defs,params:this.params,value:this.getValueForDisplay()};return this.isSearchMode()&&(e.searchParams=this.searchParams,e.searchData=this.searchData,e.searchValues=this.getSearchValues(),e.searchType=this.getSearchType(),e.searchTypeList=this.getSearchTypeList()),e}getValueForDisplay(){return this.model.get(this.name)}isReadMode(){return this.mode===this.MODE_LIST||this.mode===this.MODE_DETAIL||this.mode===this.MODE_LIST_LINK}isListMode(){return this.mode===this.MODE_LIST||this.mode===this.MODE_LIST_LINK}isDetailMode(){return this.mode===this.MODE_DETAIL}isEditMode(){return this.mode===this.MODE_EDIT}isSearchMode(){return this.mode===this.MODE_SEARCH}setDetailMode(){return this.setMode(this.MODE_DETAIL)||Promise.resolve()}setEditMode(){return this.setMode(this.MODE_EDIT)||Promise.resolve()}setMode(e){var t=this.mode!==e&&this.mode,i=this.mode,s=(this.mode=e)+"Template",s=(s in this||(this[s]="fields/"+Espo.Utils.camelCaseToHyphen(this.type)+"/"+this.mode),this._hasTemplateContent||this.setTemplate(this[s]),e+"TemplateContent");return this._hasTemplateContent||s in this&&null!=this[s]&&this.setTemplateContent(this[s]),t?(i&&this.trigger("mode-changed"),this._onModeSet()):Promise.resolve()}prepare(){}_onModeSet(){return this.isListMode()?this.onListModeSet()||Promise.resolve():this.isDetailMode()?this.onDetailModeSet()||Promise.resolve():this.isEditMode()&&this.onEditModeSet()||Promise.resolve()}onDetailModeSet(){return this.prepare()}onEditModeSet(){return this.prepare()}onListModeSet(){return this.prepare()}init(){this.validations=Espo.Utils.clone(this.validations),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,this.dataObject=Espo.Utils.clone(this.options.dataObject||{}),this.labelText||(this.labelText=this.translate(this.name,"fields",this.entityType)),this.getFieldManager().getParamList(this.type).forEach(e=>{e=e.name;e in this.params||(this.params[e]=this.model.getFieldParam(this.name,e),void 0===this.params[e]&&(this.params[e]=null))});["inlineEditDisabled"].forEach(e=>{this.params[e]=this.model.getFieldParam(this.name,e)||null}),this.readOnly=this.readOnly||this.params.readOnly||this.model.getFieldParam(this.name,"readOnly")||this.model.getFieldParam(this.name,"clientReadOnly"),this.readOnlyLocked=this.options.readOnlyLocked||this.readOnly,this.inlineEditDisabled=this.options.inlineEditDisabled||this.params.inlineEditDisabled||this.inlineEditDisabled,this.readOnly=this.readOnlyLocked||this.options.readOnly||!1,this.tooltip=this.options.tooltip||this.params.tooltip||this.model.getFieldParam(this.name,"tooltip")||this.tooltip,this.options.readOnlyDisabled&&(this.readOnly=!1),this.disabledLocked=this.options.disabledLocked||!1,this.disabled=this.disabledLocked||this.options.disabled||this.disabled;let e=this.options.mode||this.mode||this.MODE_DETAIL;e===this.MODE_EDIT&&this.readOnly&&(e=this.MODE_DETAIL),this.mode=void 0,this.wait(this.setMode(e)),this.isSearchMode()&&(this.searchParams=_.clone(this.options.searchParams||{}),this.searchData={},this.setupSearch(),this.events["keydown."+this.cid]=e=>{"Control+Enter"===Espo.Utils.getKeyFromKeyEvent(e)&&this.trigger("search")}),this.on("highlight",()=>{let e=this.get$cell();e.addClass("highlighted"),e.addClass("transition"),setTimeout(()=>{e.removeClass("highlighted")},3e3),setTimeout(()=>{e.removeClass("transition")},5e3)}),this.on("invalid",()=>{let e=this.get$cell();e.addClass("has-error"),this.$el.one("click",()=>{e.removeClass("has-error")}),this.once("render",()=>{e.removeClass("has-error")})}),this.on("after:render",()=>{if(this.isEditMode())return this.hasRequiredMarker()?void this.showRequiredSign():void this.hideRequiredSign();var e;this.hasRequiredMarker()&&this.hideRequiredSign(),!this.isSearchMode()||(e=this.$el.find("select.search-type")).length&&i.default.init(e,{matchAnyWord:!0})}),(this.isDetailMode()||this.isEditMode())&&this.tooltip&&this.initTooltip(),this.isDetailMode()&&(this.inlineEditDisabled||this.listenToOnce(this,"after:render",()=>this.initInlineEdit())),this.isSearchMode()||(this.attributeList=this.getAttributeList(),this.listenTo(this.model,"change",(t,i)=>{if(!i.ui){let e=!1;for(var s of this.getAttributeList())if(t.hasChanged(s)){e=!0;break}if(e&&!(i.skipReRenderInEditMode&&this.isEditMode()||i.skipReRender)){let t=()=>{(this.isRendered()||this.isBeingRendered())&&(this.reRender(),i.highlight&&this.trigger("highlight"))};if(this.isReady){let e=this.prepare();e?e.then(()=>t()):t()}else this.once("ready",()=>{const e=this.prepare();e&&e.then(()=>t())})}}}),this.listenTo(this,"change",()=>{var e=this.fetch();this.model.set(e,{ui:!0})}))}setupFinal(){this.wait(this._onModeSet())}initTooltip(){let a;this.once("after:render",()=>{a=(0,l.default)("").attr("role","button").attr("tabindex","-1").addClass("text-muted field-info").append((0,l.default)("").addClass("fas fa-info-circle"));let e=this.getLabelElement(),t=(e.append(" "),this.getLabelElement().append(a),this.options.tooltipText||this.tooltipText);var i,s;t||"string"!=typeof this.tooltip||([i,s]=this.tooltip.includes(".")?this.tooltip.split("."):[this.entityType,this.tooltip],t=this.translate(s,"tooltips",i)),t=t||this.translate(this.name,"tooltips",this.entityType)||"",t=this.getHelper().transformMarkdownText(t,{linksInNewTab:!0}).toString(),Espo.Ui.popover(a,{placement:"bottom",content:t,preventDestroyOnRender:!0},this)})}showRequiredSign(){let e=this.getLabelElement(),t=e.find("span.required-sign");var i;e.length&&!t.length&&(i=e.find("span.label-text"),(0,l.default)(' *').insertAfter(i),t=e.find("span.required-sign")),t.show()}hideRequiredSign(){let e=this.getLabelElement(),t=e.find("span.required-sign");t.hide()}getSearchParamsData(){return this.searchParams.data||{}}getSearchValues(){return this.getSearchParamsData().values||{}}getSearchType(){return this.getSearchParamsData().type||this.searchParams.type}getSearchTypeList(){return this.searchTypeList}initInlineEdit(){let e=this.get$cell(),t=(0,l.default)("").attr("role","button").addClass("pull-right inline-edit-link hidden").append((0,l.default)("").addClass("fas fa-pencil-alt fa-sm"));0!==e.length?(e.prepend(t),t.on("click",()=>this.inlineEdit()),e.on("mouseenter",e=>{e.stopPropagation(),this.disabled||this.readOnly||this.isDetailMode()&&t.removeClass("hidden")}).on("mouseleave",e=>{e.stopPropagation(),this.isDetailMode()&&t.addClass("hidden")}),this.on("after:render",()=>{this.isDetailMode()||t.addClass("hidden")})):this.listenToOnce(this,"after:render",()=>this.initInlineEdit())}initElement(){this.$element=this.$el.find('[data-name="'+this.name+'"]'),this.$element.length||(this.$element=this.$el.find('[name="'+this.name+'"]')),this.$element.length||(this.$element=this.$el.find(".main-element")),this.isEditMode()&&this.$element.on("change",()=>{this.trigger("change")})}afterRender(){(this.isEditMode()||this.isSearchMode())&&this.initElement(),this.isReadMode()&&this.afterRenderRead(),this.isListMode()&&this.afterRenderList(),this.isDetailMode()&&this.afterRenderDetail(),this.isEditMode()&&this.afterRenderEdit(),this.isSearchMode()&&this.afterRenderSearch()}afterRenderRead(){}afterRenderList(){}afterRenderDetail(){}afterRenderEdit(){}afterRenderSearch(){}setup(){}setupSearch(){}getAttributeList(){return this.getFieldManager().getAttributeList(this.fieldType,this.name)}inlineEditSave(s){if(s=s||{},this.recordHelper)this.recordHelper.trigger("inline-edit-save",this.name,s);else{var a,l=this.fetch();let e=this.model,t=this.initialAttributes,i=(e.set(l,{silent:!0}),!1);for(a in l=e.attributes)_.isEqual(t[a],l[a])||((i=i||{})[a]=l[a]);if(i||this.inlineEditClose(),this.validateCallback?this.validateCallback():this.validate())return Espo.Ui.error(this.translate("Not valid")),void e.set(t,{silent:!0});Espo.Ui.notify(this.translate("saving","messages")),e.save(i,{patch:!0}).then(()=>{this.trigger("after:inline-save"),this.trigger("after:save"),e.trigger("after:save"),Espo.Ui.success(this.translate("Saved"))}).catch(()=>{Espo.Ui.error(this.translate("Error occurred")),e.set(t,{silent:!0}),this.reRender()}),s.bypassClose||this.inlineEditClose(!0)}}removeInlineEditLinks(){let e=this.get$cell();e.find(".inline-save-link").remove(),e.find(".inline-cancel-link").remove(),e.find(".inline-edit-link").addClass("hidden")}addInlineEditLinks(){let e=this.get$cell(),t=(0,l.default)("").attr("role","button").attr("tabindex","-1").addClass("pull-right inline-save-link").attr("title","Ctrl+Enter").text(this.translate("Update")),i=(0,l.default)("").attr("role","button").attr("tabindex","-1").addClass("pull-right inline-cancel-link").attr("title","Esc").text(this.translate("Cancel"));e.prepend(t),e.prepend(i),e.find(".inline-edit-link").addClass("hidden"),t.click(()=>{this.inlineEditSave()}),i.click(()=>{this.inlineEditClose()})}setIsInlineEditMode(e){this._isInlineEditMode=e}inlineEditClose(e){if(this.trigger("inline-edit-off",{noReset:e}),this.$el.off("keydown.inline-edit"),this._isInlineEditMode=!1,!this.isEditMode())return Promise.resolve();e||this.model.set(this.initialAttributes,{skipReRenderInEditMode:!0});var t=this.setDetailMode().then(()=>this.reRender(!0)).then(()=>this.removeInlineEditLinks());return this.trigger("after:inline-edit-off",{noReset:e}),t}inlineEdit(){this.trigger("edit",this),this.initialAttributes=this.model.getClonedAttributes(),this._isInlineEditMode=!0;var e=this.setEditMode().then(()=>this.reRender(!0)).then(()=>this.addInlineEditLinks()).then(()=>{this.$el.on("keydown.inline-edit",e=>{var t=Espo.Utils.getKeyFromKeyEvent(e);return"Control+Enter"===t?(e.stopPropagation(),this.inlineEditSave(),void setTimeout(()=>{this.get$cell().focus()},100)):"Escape"===t?(e.stopPropagation(),void this.inlineEditClose().then(()=>{this.get$cell().focus()})):void("Control+KeyS"===t&&(e.preventDefault(),e.stopPropagation(),this.inlineEditSave({bypassClose:!0})))}),setTimeout(()=>this.focusOnInlineEdit(),10)});return this.trigger("inline-edit-on"),e}focusOnInlineEdit(){let e=this.$element&&this.$element.length?this.$element:this.$el.find(".form-control").first();e&&e.first().focus()}suspendValidationMessage(e){this.validationMessageSuspended=!0,setTimeout(()=>this.validationMessageSuspended=!1,e||200)}showValidationMessage(t,i,s){if(!this.validationMessageSuspended){let e;if(i=i||this.validationElementSelector||".main-element",(e=(e=!(e="string"==typeof i||i instanceof String?this.$el.find(i):(0,l.default)(i)).length&&this.$element?this.$element:e).length?e:this.$el).length){i=e.get(0).getBoundingClientRect();if(this.lastValidationMessage=t,0===i.top&&0===i.bottom&&0===i.left)return}this._popoverMap=this._popoverMap||new WeakMap;i=e.get(0);if(i){if(this._popoverMap[i])try{this._popoverMap[i].detach()}catch(e){}const a=Espo.Ui.popover(e,{placement:"bottom",container:"body",content:this.getHelper().transformMarkdownText(t).toString(),trigger:"manual",noToggleInit:!0,noHideOnOutsideClick:!0},s||this);a.show(),this._popoverMap[i]=a,e.closest(".field").one("mousedown click",()=>a.destroy()),this.once("render remove",()=>a.destroy()),this._timeout&&clearTimeout(this._timeout),this._timeout=setTimeout(()=>a.destroy(),this.VALIDATION_POPOVER_TIMEOUT)}}}validate(){for(var e in this.lastValidationMessage=null,this.validations)if(this["validate"+Espo.Utils.upperCaseFirst(this.validations[e])].call(this))return this.trigger("invalid"),!0;return!1}getLabelText(){return this.labelText}validateRequired(){var e;if(this.isRequired()&&(""===this.model.get(this.name)||null===this.model.get(this.name)))return e=this.translate("fieldIsRequired","messages").replace("{field}",this.getLabelText()),this.showValidationMessage(e),!0}hasRequiredMarker(){return this.isRequired()}fetchToModel(){this.model.set(this.fetch(),{silent:!0})}fetch(){if(!this.$element.length)return{};let e={};return e[this.name]=this.$element.val().trim(),e}fetchSearch(){var e=this.$element.val().toString().trim();return e?{type:"equals",value:e}:null}fetchSearchType(){return this.$el.find("select.search-type").val()}}e.default=a}),define("helpers/model/defaults-populator",["exports"],function(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;e.default=class{constructor(e,t,i,s){this.user=e,this.preferences=t,this.acl=i,this.config=s}populate(e){e.populateDefaults();let t={};for(var i in this.user.isPortal()||this.prepare(e,t),this.user.isPortal()&&this.prepareForPortal(e,t),t)e.has(i)&&delete t[i];e.set(t,{silent:!0})}prepare(i,s){var a=i.hasField("assignedUsers")&&"User"===i.getLinkParam("assignedUsers","entity");if(i.hasField("assignedUser")||a){let e="assignedUser",t=(a&&(e="assignedUsers"),!0);this.preferences.get("doNotFillAssignedUserIfNotRequired")&&(t=!1,(i.getFieldParam(e,"required")||"no"===this.acl.getPermissionLevel("assignmentPermission")||"team"===this.acl.getPermissionLevel("assignmentPermission")&&!this.user.get("defaultTeamId")||this.acl.getScopeForbiddenFieldList(i.entityType,"edit").includes(e))&&(t=!0)),t&&(a?(s.assignedUsersIds=[this.user.id],s.assignedUsersNames={},s.assignedUsersNames[this.user.id]=this.user.get("name")):(s.assignedUserId=this.user.id,s.assignedUserName=this.user.get("name")))}a=this.user.get("defaultTeamId");a&&i.hasField("teams")&&!i.getFieldParam("teams","default")&&"entityTeam"===Espo.Utils.lowerCaseFirst(i.getLinkParam("teams","relationName")||"")&&(s.teamsIds=[a],s.teamsNames={},s.teamsNames[a]=this.user.get("defaultTeamName"))}prepareForPortal(e,t){if(e.hasField("account")&&["belongsTo","hasOne"].includes(e.getLinkType("account"))&&"Account"===e.getLinkParam("account","entity")&&this.user.get("accountId")&&(t.accountId=this.user.get("accountId"),t.accountName=this.user.get("accountName")),e.hasField("contact")&&["belongsTo","hasOne"].includes(e.getLinkType("contact"))&&"Contact"===e.getLinkParam("contact","entity")&&this.user.get("contactId")&&(t.contactId=this.user.get("contactId"),t.contactName=this.user.get("contactName")),e.hasField("parent")&&"belongsToParent"===e.getLinkType("parent")&&(this.config.get("b2cMode")?this.user.get("contactId")&&(e.getFieldParam("parent","entityList")||[]).includes("Contact")&&(t.contactId=this.user.get("contactId"),t.parentName=this.user.get("contactName"),t.parentType="Contact"):this.user.get("accountId")&&(e.getFieldParam("parent","entityList")||[]).includes("Account")&&(t.parentId=this.user.get("accountId"),t.parentName=this.user.get("accountName"),t.parentType="Account")),e.hasField("accounts")&&"hasMany"===e.getLinkType("accounts")&&"Account"===e.getLinkParam("accounts","entity")&&this.user.get("accountsIds")&&(t.accountsIds=this.user.get("accountsIds"),t.accountsNames=this.user.get("accountsNames")),e.hasField("contacts")&&"hasMany"===e.getLinkType("contacts")&&"Contact"===e.getLinkParam("contacts","entity")&&this.user.get("contactId")){t.contactsIds=[this.user.get("contactId")];let e={};e[this.user.get("contactId")]=this.user.get("contactName"),t.contactsNames=e}}}}),define("exceptions",["exports"],function(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,Espo.Exceptions=Espo.Exceptions||{},Espo.Exceptions.AccessDenied=function(e){this.message=e,Error.apply(this,arguments)},Espo.Exceptions.AccessDenied.prototype=new Error,Espo.Exceptions.AccessDenied.prototype.name="AccessDenied",Espo.Exceptions.NotFound=function(e){this.message=e,Error.apply(this,arguments)},Espo.Exceptions.NotFound.prototype=new Error,Espo.Exceptions.NotFound.prototype.name="NotFound";var t=Espo.Exceptions;e.default=t}),define("views/record/base",["exports","view","view-record-helper","dynamic-logic","underscore","jquery","helpers/model/defaults-populator"],function(e,t,i,s,u,a,l){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,t=o(t),i=o(i),s=o(s),u=o(u),a=o(a),l=o(l);class r extends t.default{type="edit";entityType=null;scope=null;isNew=!1;dependencyDefs={};dynamicLogicDefs={};fieldList=null;mode=null;lastSaveCancelReason=null;recordHelper=null;MODE_DETAIL="detail";MODE_EDIT="edit";TYPE_DETAIL="detail";TYPE_EDIT="edit";hideField(a,e){this.recordHelper.setFieldStateParam(a,"hidden",!0),e&&this.recordHelper.setFieldStateParam(a,"hiddenLocked",!0);let t=()=>{var s=this.getFieldView(a);if(s){let e=s.$el,t=e.closest('.cell[data-name="'+a+'"]'),i=t.find('label.control-label[data-name="'+a+'"]');e.addClass("hidden"),i.addClass("hidden"),t.addClass("hidden-cell")}else this.$el.find('.cell[data-name="'+a+'"]').addClass("hidden-cell"),this.$el.find('.field[data-name="'+a+'"]').addClass("hidden"),this.$el.find('label.control-label[data-name="'+a+'"]').addClass("hidden")},i=(this.isRendered()?t():this.once("after:render",()=>{t()}),this.getFieldView(a));i&&i.setDisabled(e)}showField(a){if(!this.recordHelper.getFieldStateParam(a,"hiddenLocked")){this.recordHelper.setFieldStateParam(a,"hidden",!1);let e=()=>{var s=this.getFieldView(a);if(s){let e=s.$el,t=e.closest('.cell[data-name="'+a+'"]'),i=t.find('label.control-label[data-name="'+a+'"]');return e.removeClass("hidden"),i.removeClass("hidden"),void t.removeClass("hidden-cell")}this.$el.find('.cell[data-name="'+a+'"]').removeClass("hidden-cell"),this.$el.find('.field[data-name="'+a+'"]').removeClass("hidden"),this.$el.find('label.control-label[data-name="'+a+'"]').removeClass("hidden")},t=(this.isRendered()?e():this.once("after:render",()=>{e()}),this.getFieldView(a));t&&(t.disabledLocked||t.setNotDisabled())}}setFieldReadOnly(t,i){var e=this.recordHelper.getFieldStateParam(t,"readOnly");this.recordHelper.setFieldStateParam(t,"readOnly",!0),i&&this.recordHelper.setFieldStateParam(t,"readOnlyLocked",!0);const s=this.getFieldView(t);s&&s.setReadOnly(i),e||this.trigger("set-field-read-only",t),s||this.isReady||this.once("ready",()=>{const e=this.getFieldView(t);e&&!e.readOnly&&this.recordHelper.getFieldStateParam(t,"readOnly")&&e.setReadOnly(i)})}setFieldNotReadOnly(t){var e=this.recordHelper.getFieldStateParam(t,"readOnly");this.recordHelper.setFieldStateParam(t,"readOnly",!1);const i=this.getFieldView(t);i&&i.readOnly&&(i.setNotReadOnly(),this.mode===this.MODE_EDIT&&!i.readOnlyLocked&&i.isDetailMode()&&i.setEditMode().then(()=>i.reRender())),e&&this.trigger("set-field-not-read-only",t),i||this.isReady||this.once("ready",()=>{const e=this.getFieldView(t);e&&e.readOnly&&!this.recordHelper.getFieldStateParam(t,"readOnly")&&e.setNotReadOnly()})}setFieldRequired(e){var t=this.recordHelper.getFieldStateParam(e,"required");this.recordHelper.setFieldStateParam(e,"required",!0);const i=this.getFieldView(e);i&&i.setRequired(),t||this.trigger("set-field-required",e)}setFieldNotRequired(e){var t=this.recordHelper.getFieldStateParam(e,"required");this.recordHelper.setFieldStateParam(e,"required",!1);const i=this.getFieldView(e);i&&i.setNotRequired(),t&&this.trigger("set-field-not-required",e)}setFieldOptionList(e,t){var i=this.recordHelper.hasFieldOptionList(e),s=this.recordHelper.getFieldOptionList(e);this.recordHelper.setFieldOptionList(e,t);let a=this.getFieldView(e);a&&"setOptionList"in a&&a.setOptionList(t),i&&(0,u.default)(s).isEqual(t)||this.trigger("set-field-option-list",e,t)}resetFieldOptionList(e){var t=this.recordHelper.hasFieldOptionList(e);this.recordHelper.clearFieldOptionList(e);let i=this.getFieldView(e);i&&"resetOptionList"in i&&i.resetOptionList(),t&&this.trigger("reset-field-option-list",e)}showPanel(e,t){this.recordHelper.setPanelStateParam(e,"hidden",!1),this.isRendered()&&this.$el.find('.panel[data-name="'+e+'"]').removeClass("hidden")}hidePanel(e,t,i){this.recordHelper.setPanelStateParam(e,"hidden",!0),this.isRendered()&&this.$el.find('.panel[data-name="'+e+'"]').addClass("hidden")}stylePanel(s){this.recordHelper.setPanelStateParam(s,"styled",!0);let e=()=>{let e=this.$el.find('.panel[data-name="'+s+'"]'),t=e.find("> .panel-heading .btn");var i=e.attr("data-style");i&&(e.removeClass("panel-default"),e.addClass("panel-"+i),t.removeClass("btn-default"),t.addClass("btn-"+i))};this.isRendered()?e():this.once("after:render",()=>{e()})}unstylePanel(s){this.recordHelper.setPanelStateParam(s,"styled",!1);let e=()=>{let e=this.$el.find('.panel[data-name="'+s+'"]'),t=e.find("> .panel-heading .btn");var i=e.attr("data-style");i&&(e.removeClass("panel-"+i),e.addClass("panel-default"),t.removeClass("btn-"+i),t.addClass("btn-default"))};this.isRendered()?e():this.once("after:render",()=>{e()})}setConfirmLeaveOut(e){this.getRouter()&&(this.getRouter().confirmLeaveOut=e)}getFieldViews(e){let i={};return this.fieldList.forEach(e=>{var t=this.getFieldView(e);t&&(i[e]=t)}),i}getFields(){return this.getFieldViews()}getFieldView(e){let t=this.getView(e+"Field")||null;return t=t||(this.getView(e)||null)}getField(e){return this.getFieldView(e)}getFieldList(){return Object.keys(this.getFieldViews())}getFieldViewList(){return this.getFieldList().map(e=>this.getFieldView(e)).filter(e=>null!==e)}data(){return{scope:this.scope,entityType:this.entityType,hiddenPanels:this.recordHelper.getHiddenPanels(),hiddenFields:this.recordHelper.getHiddenFields()}}handleDataBeforeRender(t){this.getFieldList().forEach(e=>{t[e]=t[e+"Field"]})}setup(){if(void 0===this.model)throw new Error("Model has not been injected into record view.");this.recordHelper=this.options.recordHelper||new i.default,this.dynamicLogicDefs=this.options.dynamicLogicDefs||this.dynamicLogicDefs,this.on("remove",()=>{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(1e4*Math.random()+1),this.id=Espo.Utils.toDom(this.entityType)+"-"+Espo.Utils.toDom(this.type)+"-"+this.numId,this.model.isNew()&&(this.isNew=!0),this.setupBeforeFinal()}setupBeforeFinal(){this.attributes=this.model.getClonedAttributes(),this.listenTo(this.model,"change",(e,t)=>{if(t.sync)for(var i in e.attributes)e.hasChanged(i)&&(this.attributes[i]=Espo.Utils.cloneDeep(e.get(i)));else this.mode===this.MODE_EDIT&&this.setIsChanged()}),this.options.attributes&&this.model.set(this.options.attributes),this.listenTo(this.model,"sync",()=>{this.attributes=this.model.getClonedAttributes()}),this.initDependency(),this.initDynamicLogic()}setInitialAttributeValue(e,t){this.attributes[e]=t}checkAttributeIsChanged(e){return!u.default.isEqual(this.attributes[e],this.model.get(e))}resetModelChanges(){for(var e in this.updatedAttributes&&(this.attributes=this.updatedAttributes,this.updatedAttributes=null),this.model.attributes)e in this.attributes||this.model.unset(e);this.model.set(this.attributes,{skipReRender:!0})}setModelAttributes(e,t){for(var i in this.model.attributes)i in e||this.model.unset(i);this.model.set(e,t||{})}initDynamicLogic(){this.dynamicLogicDefs=Espo.Utils.clone(this.dynamicLogicDefs||{}),this.dynamicLogicDefs.fields=Espo.Utils.clone(this.dynamicLogicDefs.fields),this.dynamicLogicDefs.panels=Espo.Utils.clone(this.dynamicLogicDefs.panels),this.dynamicLogic=new s.default(this.dynamicLogicDefs,this),this.listenTo(this.model,"change",()=>this.processDynamicLogic()),this.processDynamicLogic()}processDynamicLogic(){this.dynamicLogic.process()}initDependency(){Object.keys(this.dependencyDefs||{}).forEach(e=>{this.listenTo(this.model,"change:"+e,()=>{this._handleDependencyAttribute(e)})}),this._handleDependencyAttributes()}initDependancy(){this.initDependency()}setupFieldLevelSecurity(){let e=this.getAcl().getScopeForbiddenFieldList(this.entityType,"read"),t=(e.forEach(e=>{this.hideField(e,!0)}),this.getAcl().getScopeForbiddenFieldList(this.entityType,"edit"));t.forEach(e=>{this.setFieldReadOnly(e,!0)})}setIsChanged(){this.isChanged=!0}setIsNotChanged(){this.isChanged=!1}validate(){let t=[];return this.getFieldList().forEach(e=>{this.validateField(e)&&t.push(e)}),t.length&&this.onInvalid(t),!!t.length}onInvalid(e){}validateField(t){let i=this.getFieldView(t);if(!i)return!1;let e=!1;var s;return(e=i.isEditMode()&&!i.disabled&&!i.readOnly&&i.validate()||e)?(!i.$el||0===(s=i.$el.get(0).getBoundingClientRect()).top&&0===s.bottom&&0===s.left&&i.$el.closest(".panel.hidden").length&&setTimeout(()=>{var e=this.translate("Not valid")+": "+(i.lastValidationMessage||this.translate(t,"fields",this.entityType));Espo.Ui.error(e,!0)},10),!0):(this.dynamicLogic&&this.dynamicLogicDefs&&this.dynamicLogicDefs.fields&&this.dynamicLogicDefs.fields[t]&&this.dynamicLogicDefs.fields[t].invalid&&this.dynamicLogicDefs.fields[t].invalid.conditionGroup&&(s=this.dynamicLogicDefs.fields[t].invalid.conditionGroup,s=this.dynamicLogic.checkConditionGroup(s),e=s||e,s&&(s=this.translate("fieldInvalid","messages").replace("{field}",this.translate(t,"fields",this.entityType)),i.showValidationMessage(s),i.trigger("invalid"))),e)}afterSave(){this.isNew?Espo.Ui.success(this.translate("Created")):Espo.Ui.success(this.translate("Saved")),this.setIsNotChanged()}beforeBeforeSave(){}beforeSave(){Espo.Ui.notify(this.translate("saving","messages"))}afterSaveError(){}afterNotModified(){Espo.Ui.warning(this.translate("notModified","messages")),this.setIsNotChanged()}afterNotValid(){Espo.Ui.error(this.translate("Not valid"))}save(s){let e=(s=s||{}).headers||{},a=this.model;this.lastSaveCancelReason=null,this.beforeBeforeSave();var t=this.fetch();let l=this.attributes,o=this.model.getClonedAttributes();var i=u.default.extend(Espo.Utils.cloneDeep(o),t);let r={};if(a.isNew()&&(r=i),!a.isNew()){for(var n in i)u.default.isEqual(l[n],i[n])||(r[n]=i[n]);var d,h=this.forcePatchAttributeDependencyMap||{};for(d in h)if(!(d in r)&&d in t){let e=h[d];!!e.find(e=>e in r)&&(r[d]=i[d])}}if(0===Object.keys(r).length)return s.skipNotModifiedWarning||this.afterNotModified(),this.lastSaveCancelReason="notModified",this.trigger("cancel:save",{reason:"notModified"}),Promise.reject("notModified");if(a.set(r,{silent:!0}),this.validate())return a.attributes=o,this.afterNotValid(),this.lastSaveCancelReason="invalid",this.trigger("cancel:save",{reason:"invalid"}),Promise.reject("invalid");s.afterValidate&&s.afterValidate(),this.getMetadata().get(["entityDefs",this.entityType,"optimisticConcurrencyControl"])&&null!==this.model.get("versionNumber")&&(e["X-Version-Number"]=this.model.get("versionNumber")),this.model.isNew()&&this.options.duplicateSourceId&&(e["X-Duplicate-Source-Id"]=this.options.duplicateSourceId),this.beforeSave(),this.trigger("before:save"),a.trigger("before:save");let c=(e,t,i)=>{this.handleSaveError(e,s,i).then(e=>{e||t("error")}),this.afterSaveError(),this.setModelAttributes(o),this.lastSaveCancelReason="error",this.trigger("error:save"),this.trigger("cancel:save",{reason:"error"})};return new Promise((t,i)=>{a.save(r,{patch:!a.isNew(),headers:e}).then(()=>{this.trigger("save",l),this.afterSave(),this.isNew&&(this.isNew=!1),this.trigger("after:save"),a.trigger("after:save"),t()}).catch(e=>{c(e,i,t)})})}handleSaveError(t,s,a){let l=null;if(~[409,500].indexOf(t.status)){let e=t.getResponseHeader("X-Status-Reason");if(!e)return Promise.resolve(!1);try{l=JSON.parse(e)}catch(e){}if(!l&&(l={reason:e.toString()},t.responseText)){let e;try{e=JSON.parse(t.responseText)}catch(e){return console.error("Could not parse error response body."),Promise.resolve(!1)}l.data=e}}if(!l||!l.reason)return Promise.resolve(!1);let o=l.reason,r=this.getMetadata().get(["clientDefs",this.scope,"saveErrorHandlers",o])||this.getMetadata().get(["clientDefs","Global","saveErrorHandlers",o]);return new Promise(i=>{return r?(Espo.loader.require(r,e=>{let t=new e(this);t.process(l.data,s),i(!1)}),void(t.errorIsHandled=!0)):(e="errorHandler"+Espo.Utils.upperCaseFirst(o))in this?(t.errorIsHandled=!0,e=this[e](l.data,s,a),void i(e||!1)):void i(!1);var e})}fetch(){let t={};var i,s=this.getFieldViews();for(i in s){let e=s[i];e.isEditMode()&&(e.disabled||e.readOnly||!e.isFullyRendered()||(t={...t,...e.fetch()}))}return t}processFetch(){var e=this.fetch();return this.model.set(e),this.validate()?null:e}populateDefaults(){const e=new l.default(this.getUser(),this.getPreferences(),this.getAcl(),this.getConfig());e.populate(this.model)}errorHandlerDuplicate(e){}_handleDependencyAttributes(){Object.keys(this.dependencyDefs||{}).forEach(e=>{this._handleDependencyAttribute(e)})}_handleDependencyAttribute(e){let t=this.dependencyDefs[e];e=this.model.get(e);e in(t.map||{})?(t.map[e]||[]).forEach(e=>{this._doDependencyAction(e)}):"default"in t&&(t.default||[]).forEach(e=>{this._doDependencyAction(e)})}_doDependencyAction(i){var s=i.action;if("dependencyAction"+Espo.Utils.upperCaseFirst(s)in this&&"function"==typeof this.methodName)this.methodName(i);else{let e=i.fieldList||i.fields||[],t=i.panelList||i.panels||[];switch(s){case"hide":t.forEach(e=>{this.hidePanel(e)}),e.forEach(e=>{this.hideField(e)});break;case"show":t.forEach(e=>{this.showPanel(e)}),e.forEach(e=>{this.showField(e)});break;case"setRequired":e.forEach(e=>{this.setFieldRequired(e)});break;case"setNotRequired":e.forEach(e=>{this.setFieldNotRequired(e)});break;case"setReadOnly":e.forEach(e=>{this.setFieldReadOnly(e)});break;case"setNotReadOnly":e.forEach(e=>{this.setFieldNotReadOnly(e)})}}}createField(e,t,i,s,a,l){let o={model:this.model,mode:s||"edit",selector:'.field[data-name="'+e+'"]',defs:{name:e,params:i||{}}};if(a&&(o.readOnly=!0),(t=t||this.model.getFieldParam(e,"view"))||(s=this.model.getFieldType(e)||"base",t=this.getFieldManager().getViewName(s)),l)for(var r in l)o[r]=l[r];this.recordHelper.getFieldStateParam(e,"hidden")&&(o.disabled=!0),this.recordHelper.getFieldStateParam(e,"readOnly")&&(o.readOnly=!0),null!==this.recordHelper.getFieldStateParam(e,"required")&&(o.defs.params.required=this.recordHelper.getFieldStateParam(e,"required")),this.recordHelper.hasFieldOptionList(e)&&(o.customOptionList=this.recordHelper.getFieldOptionList(e)),this.createView(e+"Field",t,o),~this.fieldList.indexOf(e)||this.fieldList.push(e)}getFocusedFieldView(){let e=(0,a.default)(window.document.activeElement);if(!e.length)return null;let t=e.closest(".field");if(!t.length)return null;var i=t.attr("data-name");return i?this.getFieldView(i):null}exit(e){}}e.default=r}),define("views/fields/int",["exports","views/fields/base","autonumeric"],function(e,t,i){"use strict";function s(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,t=s(t),i=s(i);class a extends t.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"];autoNumericOptions=null;autoNumericInstance=null;setup(){super.setup(),this.setupMaxLength(),this.getPreferences().has("thousandSeparator")?this.thousandSeparator=this.getPreferences().get("thousandSeparator"):this.getConfig().has("thousandSeparator")&&(this.thousandSeparator=this.getConfig().get("thousandSeparator")),this.params.disableFormatting&&(this.disableFormatting=!0)}setupFinal(){super.setupFinal(),this.setupAutoNumericOptions()}setupAutoNumericOptions(){var e=(this.disableFormatting?null:this.thousandSeparator)||"";let t="."===e?",":".";this.autoNumericOptions={digitGroupSeparator:e,decimalCharacter:t,modifyValueOnWheel:!1,decimalPlaces:0,selectOnFocus:!1,formulaMode:!0}}afterRender(){if(super.afterRender(),this.mode===this.MODE_EDIT&&this.autoNumericOptions&&(this.autoNumericInstance=new i.default(this.$element.get(0),this.autoNumericOptions)),this.mode===this.MODE_SEARCH){let e=this.$el.find("select.search-type"),t=(this.handleSearchType(e.val()),this.$el.find("select.search-type").on("change",()=>{this.trigger("change")}),this.$element.on("input",()=>{this.trigger("change")}),this.$el.find("input.additional"));t.on("input",()=>{this.trigger("change")}),this.autoNumericOptions&&(new i.default(this.$element.get(0),this.autoNumericOptions),new i.default(t.get(0),this.autoNumericOptions))}}data(){let e=super.data();return null!==this.model.get(this.name)&&void 0!==this.model.get(this.name)&&(e.isNotEmpty=!0),e.valueIsSet=this.model.has(this.name),this.isSearchMode()&&(e.value=this.searchParams.value,"between"===this.getSearchType()&&(e.value=this.getSearchParamsData().value1||this.searchParams.value1,e.value2=this.getSearchParamsData().value2||this.searchParams.value2)),this.isEditMode()&&(e.value=this.model.get(this.name)),e}getValueForDisplay(){var e=isNaN(this.model.get(this.name))?null:this.model.get(this.name);return this.formatNumber(e)}formatNumber(e){return this.disableFormatting?e:this.formatNumberDetail(e)}formatNumberDetail(e){if(null===e)return"";let t=e.toString();return t=t.replace(/\B(?=(\d{3})+(?!\d))/g,this.thousandSeparator)}setupSearch(){this.events["change select.search-type"]=e=>{this.handleSearchType($(e.currentTarget).val())}}handleSearchType(e){var t=this.$el.find("input.additional"),i=this.$el.find('input[data-name="'+this.name+'"]');"between"===e?(t.removeClass("hidden"),i.removeClass("hidden")):~["isEmpty","isNotEmpty"].indexOf(e)?(t.addClass("hidden"),i.addClass("hidden")):(t.addClass("hidden"),i.removeClass("hidden"))}getMaxValue(){var e=this.model.getFieldParam(this.name,"max")||null;return e||0===e||(e=null),e="max"in this.params?this.params.max:e}getMinValue(){var e=this.model.getFieldParam(this.name,"min");return e||0===e||(e=null),e="min"in this.params?this.params.min:e}setupMaxLength(){var e=this.getMaxValue();"undefined"!=typeof max&&null!==max&&(e=this.formatNumber(e),this.params.maxLength=e.toString().length)}validateInt(){var e=this.model.get(this.name);if(isNaN(e))return e=this.translate("fieldShouldBeInt","messages").replace("{field}",this.getLabelText()),this.showValidationMessage(e),!0}validateRange(){var e=this.model.get(this.name);if(null===e)return!1;var t,i=this.getMinValue(),s=this.getMaxValue();if(null!==i&&null!==s){if(e{e.render().then(()=>Espo.Ui.notify(!1)),t.listenToOnce(e,"remove",()=>{t.clearView("modal")})})}}}),define("helpers/action-item-setup",["exports"],function(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;e.default=class{constructor(e,t,i,s){this.metadata=e,this.viewHelper=t,this.acl=i,this.language=s}setup(a,e,i,l,t,o,s){s=s||{};let r=[],n=a.scope||a.model.entityType;if(!n)throw new Error;let d=[...this.metadata.get(["clientDefs","Global",e+"ActionList"])||[],...this.metadata.get(["clientDefs",n,e+"ActionList"])||[]];if(d.forEach(s=>{"string"==typeof s&&(s={name:s});var e=(s=Espo.Utils.cloneDeep(s)).name;s.label||(s.html=this.language.translate(e,"actions",n)),s.data=s.data||{};let t=s.handler||s.data.handler;t&&!s.data.handler&&(s.data.handler=t),l(s),Espo.Utils.checkActionAvailability(this.viewHelper,s)&&(Espo.Utils.checkActionAccess(this.acl,a.model,s,!0)||(s.hidden=!0),r.push(s),t&&(s.initFunction||s.checkVisibilityFunction)&&i(new Promise(i=>{Espo.loader.require(t,e=>{let t=new e(a);s.initFunction&&t[s.initFunction].call(t),s.checkVisibilityFunction&&!t[s.checkVisibilityFunction].call(t)&&o(s.name),s.handlerInstance=t,i()})})))}),r.length){let e=()=>{r.forEach(e=>{if(e.handlerInstance&&e.checkVisibilityFunction&&!e.handlerInstance[e.checkVisibilityFunction].call(e.handlerInstance))return void o(e.name);(Espo.Utils.checkActionAccess(this.acl,a.model,e,!0)?t:o)(e.name)})};s.listenToViewModelSync?a.listenTo(a,"model-sync",()=>e()):a.listenTo(a.model,"sync",()=>e())}}}}),define("utils",["exports"],function(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;const i=/Mac/.test(navigator.userAgent),s=(Espo.Utils={handleAction:function(i,s,e,t){t=t||{};const a=$(e);var l=t.action||a.data("action");const o=a.data("name")||l;if(o&&t.actionItems&&(!t.className||e.classList.contains(t.className))){const r=t.actionItems.find(e=>e.name===o||e.action===o);if(r&&r.onClick)return r.onClick(),!0}if(!l)return!1;if(s.ctrlKey||s.metaKey||s.shiftKey){e=a.attr("href");if(e&&"javascript:"!==e)return!1}const r=a.data(),n="action"+Espo.Utils.upperCaseFirst(l);e=t.handler||r.handler;let d=!1;return e?(s.preventDefault(),s.stopPropagation(),d=!0,Espo.loader.require(e,e=>{let t=new e(i);t[n].call(t,r,s)})):"function"==typeof i[n]&&(i[n].call(i,r,s),s.preventDefault(),s.stopPropagation(),d=!0),!!d&&(this._processAfterActionDropdown(a),!0)},_processAfterActionDropdown:function(e){let i=e.closest(".dropdown-menu");if(i.length){let t=i.parent().find('[data-toggle="dropdown"]');if(t.length){let e=!1;t.attr("disabled")&&(e=!0,t.removeAttr("disabled").removeClass("disabled")),t.dropdown("toggle"),t.focus(),e&&t.attr("disabled","disabled").addClass("disabled")}}},checkActionAvailability:function(e,s){let a=e.config;if(s.configCheck){let e=s.configCheck,t=!1,i=("!"===e.substring(0,1)&&(t=!0,e=e.substring(1)),a.getByPath(e.split(".")));if(!(i=t?!i:i))return!1}return!0},checkActionAccess:function(e,t,i,s){let a=!0;return i.acl?a=i.aclScope?e.check(i.aclScope,i.acl):t?"string"==typeof t||t instanceof String?e.check(t,i.acl):e.checkModel(t,i.acl,s):e.check(i.scope,i.acl):i.aclScope&&(a=e.checkScope(i.aclScope)),a},checkAccessDataList:function(e,t,i,s,a){if(!e||!e.length)return!0;for(var l in e){var o=e[l];if(o.scope){if(o.action){if(!t.check(o.scope,o.action))return!1}else if(!t.checkScope(o.scope))return!1}else if(o.action&&s&&!t.check(s,o.action))return!1;if(o.teamIdList&&i&&(!a||!i.isAdmin())){var r=!1;if(i.getLinkMultipleIdList("teams").forEach(e=>{~o.teamIdList.indexOf(e)&&(r=!0)}),!r)return!1}if(o.portalIdList&&i&&(!a||!i.isAdmin())){var n=!1;if(i.getLinkMultipleIdList("portals").forEach(e=>{~o.portalIdList.indexOf(e)&&(n=!0)}),!n)return!1}if(o.isPortalOnly){if(i&&(!a||!i.isAdmin())&&!i.isPortal())return!1}else if(o.inPortalDisabled&&i&&(!a||!i.isAdmin())&&i.isPortal())return!1;if(o.isAdminOnly&&i&&!i.isAdmin())return!1}return!0},convert:function(e,t){if(null===e)return e;var i=e;switch(t){case"c-h":case"C-h":i=Espo.Utils.camelCaseToHyphen(e);break;case"h-c":i=Espo.Utils.hyphenToCamelCase(e);break;case"h-C":i=Espo.Utils.hyphenToUpperCamelCase(e)}return i},isObject:function(e){return null!==e&&"object"==typeof e},clone:function(e){return Espo.Utils.isObject(e)?_.isArray(e)?e.slice():_.extend({},e):e},cloneDeep:function(e){if(e=Espo.Utils.clone(e),Espo.Utils.isObject(e)||_.isArray(e))for(var t in e)e[t]=this.cloneDeep(e[t]);return e},composeClassName:function(e,t,i){return e?(e=this.camelCaseToHyphen(e),t=this.camelCaseToHyphen(t).split(".").join("/"),e+":"+(i=this.camelCaseToHyphen(i||""))+"/"+t):i+"/"+(t=this.camelCaseToHyphen(t).split(".").join("/"))},composeViewClassName:function(e){return e&&e[0]===e[0].toLowerCase()?e:-1!==e.indexOf(":")?(t=(i=e.split(":"))[0],i=i[1],(t=this.camelCaseToHyphen(t))+":views/"+(i=this.camelCaseToHyphen(i).split(".").join("/"))):"views/"+(e=this.camelCaseToHyphen(e).split(".").join("/"));var t,i},toDom:function(e){return Espo.Utils.convert(e,"c-h").split(".").join("-")},lowerCaseFirst:function(e){return null===e?e:e.charAt(0).toLowerCase()+e.slice(1)},upperCaseFirst:function(e){return null===e?e:e.charAt(0).toUpperCase()+e.slice(1)},hyphenToUpperCamelCase:function(e){return null===e?e:this.upperCaseFirst(e.replace(/-([a-z])/g,function(e){return e[1].toUpperCase()}))},hyphenToCamelCase:function(e){return null===e?e:e.replace(/-([a-z])/g,function(e){return e[1].toUpperCase()})},camelCaseToHyphen:function(e){return null===e?e:e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()},trimSlash:function(e){return"/"===e.slice(-1)?e.slice(0,-1):e},parseUrlOptionsParam:function(e){if(!e)return{};if(-1===e.indexOf("&")&&-1===e.indexOf("="))return{};let t={};return void 0!==e&&e.split("&").forEach(e=>{e=e.split("=");t[e[0]]=!0,1{s.textStatus=t,s.errorThrown=i,l&&l.call(s.context,e,t,i)};var o=e?JSON.stringify(e):null,o=s.bypassRequest?Promise.resolve():Espo.Ajax.request(a,i,o,s);return s.xhr=o.xhr,t.trigger("request",a,i,e,o,s),o}set(e,t,i){if(null==e)return this;let s;return"object"==typeof e?this.setMultiple(e,t):((s={})[e]=t,this.setMultiple(s,i))}setMultiple(e,t){this.idAttribute in e&&(this.id=e[this.idAttribute]),t=t||{};let i=[];var s=this._changing;this._changing=!0,s||(this._previousAttributes=d.default.clone(this.attributes),this.changed={});let a=this.attributes,l=this.changed;var o,r=this._previousAttributes;for(o in e){var n=e[o];d.default.isEqual(a[o],n)||i.push(o),d.default.isEqual(r[o],n)?delete l[o]:l[o]=n,t.unset?delete a[o]:a[o]=n}if(!t.silent){i.length&&(this._pending=t);for(let e=0;e{var t=this.prepareAttributes(e,i);this.set(t,i),s&&s.call(i.context,this,e,i),this.trigger("sync",this,e,i)},this.lastSyncPromise=this.sync("read",this,i),this.lastSyncPromise}save(e,i){i={...i},e&&!i.wait&&this.setMultiple(e,i);const s=i.success,a=this.attributes,t=(i.success=e=>{this.attributes=a;let t=this.prepareAttributes(e,i);(t=i.wait?{...a,...t}:t)&&this.setMultiple(t,i),s&&s.call(i.context,this,e,i),this.trigger("sync",this,e,i)},i.error);i.error=e=>{t&&t.call(i.context,this,e,i),this.trigger("error",this,e,i)},e&&i.wait&&(this.attributes={...a,...e});var l=this.isNew()?"create":i.patch?"patch":"update",e=("patch"==l&&(i.attributes=e),this.sync(l,this,i));return this.attributes=a,e}destroy(t){let i=(t=d.default.clone(t||{})).success;const s=()=>{this.stopListening(),this.trigger("destroy",this,this.collection,t)};if(t.success=e=>{t.wait&&s(),i&&i.call(t.context,this,e,t),this.isNew()||this.trigger("sync",this,e,t)},this.isNew())return d.default.defer(t.success),t.wait||s(),Promise.resolve();let a=t.error;t.error=e=>{a&&a.call(t.context,this,e,t),this.trigger("error",this,e,t)};var e=this.sync("delete",this,t);return t.wait||s(),e}composeSyncUrl(){if(this.url)return this.url;let e=this.urlRoot;if(!(e=!e&&this.collection?this.collection.urlRoot:e))throw new Error("No urlRoot.");if(this.isNew())return e;var t=this.get(this.idAttribute);return e.replace(/[^\/]$/,"$&/")+encodeURIComponent(t)}prepareAttributes(e,t){return e}clone(){return new this.constructor(Espo.Utils.cloneDeep(this.attributes),{entityType:this.entityType,urlRoot:this.urlRoot,url:this.url,defs:this.defs,dateTime:this.dateTime})}setDefs(e){this.defs=e||{},this.defs.fields||(this.defs.fields={})}getClonedAttributes(){return Espo.Utils.cloneDeep(this.attributes)}populateDefaults(){let e={};var t,i;for(t in this.defs.fields){var s=this.getFieldParam(t,"default");if(null!==s)try{s=this.parseDefaultValue(s),e[t]=s}catch(e){console.error(e)}var a=this.getFieldParam(t,"defaultAttributes");if(a)for(var l in a)e[l]=a[l]}for(i in e=Espo.Utils.cloneDeep(e))this.has(i)&&delete e[i];this.set(e,{silent:!0})}parseDefaultValue(e){var t;return"string"==typeof e&&0===e.indexOf("javascript:")&&(t=e.substring(11),e=new Function("with(this) { "+t+"}").call(this)),e}getLinkMultipleColumn(e,t,i){return((this.get(e+"Columns")||{})[i]||{})[t]}setRelate(e){let t=e=>{var i=e.link;let s=e.model;if(!i||!s)throw new Error("Bad related options");switch(this.defs.links[i].type){case"belongsToParent":this.set(i+"Id",s.id),this.set(i+"Type",s.entityType),this.set(i+"Name",s.get("name"));break;case"belongsTo":this.set(i+"Id",s.id),this.set(i+"Name",s.get("name"));break;case"hasMany":let e=[],t=(e.push(s.id),{});t[s.id]=s.get("name"),this.set(i+"Ids",e),this.set(i+"Names",t)}};"[object Array]"!==Object.prototype.toString.call(e)?t(e):e.forEach(e=>{t(e)})}getFieldType(e){return this.defs&&this.defs.fields&&e in this.defs.fields&&this.defs.fields[e].type||null}getFieldParam(e,t){return this.defs&&this.defs.fields&&e in this.defs.fields&&t in this.defs.fields[e]?this.defs.fields[e][t]:null}getLinkType(e){return this.defs&&this.defs.links&&e in this.defs.links&&this.defs.links[e].type||null}getLinkParam(e,t){return this.defs&&this.defs.links&&e in this.defs.links&&t in this.defs.links[e]?this.defs.links[e][t]:null}isFieldReadOnly(e){return this.getFieldParam(e,"readOnly")||!1}isRequired(e){return this.getFieldParam(e,"required")||!1}getLinkMultipleIdList(e){return this.get(e+"Ids")||[]}getTeamIdList(){return this.get("teamsIds")||[]}hasField(e){return"defs"in this&&"fields"in this.defs&&e in this.defs.fields}hasLink(e){return"defs"in this&&"links"in this.defs&&e in this.defs.links}isEditable(){return!0}isRemovable(){return!0}getEntityType(){return this.name}abortLastFetch(){this.lastSyncPromise&&this.lastSyncPromise.getReadyState()<4&&this.lastSyncPromise.abort()}toJSON(){return console.warn("model.toJSON is deprecated. Use 'getClonedAttributes' instead."),this.getClonedAttributes()}}Object.assign(s.prototype,t.Events),s.extend=t.View.extend,e.default=s}),define("controller",["exports","exceptions","bullbone","jquery"],function(e,a,t,l){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,a=i(a),l=i(l);class s{constructor(e,t){this.params=e||{},this.baseController=t.baseController,this.viewFactory=t.viewFactory,this.modelFactory=t.modelFactory,this.collectionFactory=t.collectionFactory,this._settings=t.settings||null,this._user=t.user||null,this._preferences=t.preferences||null,this._acl=t.acl||null,this._cache=t.cache||null,this._router=t.router||null,this._storage=t.storage||null,this._metadata=t.metadata||null,this._dateTime=t.dateTime||null,this._broadcastChannel=t.broadcastChannel||null,this.baseController||this.on("logout",()=>this.clearAllStoredMainViews()),this.set("masterRendered",!1)}defaultAction="index";name=null;params=null;viewFactory=null;modelFactory=null;masterView=null;setRouter(e){this._router=e,this.trigger("router-set",e)}getConfig(){return this._settings}getUser(){return this._user}getPreferences(){return this._preferences}getAcl(){return this._acl}getCache(){return this._cache}getRouter(){return this._router}getStorage(){return this._storage}getMetadata(){return this._metadata}getDateTime(){return this._dateTime}get(e){return e in this.params?this.params[e]:null}set(e,t){this.params[e]=t}unset(e){delete this.params[e]}has(e){return e in this.params}getStoredMainView(e){return this.get("storedMainView-"+e)}hasStoredMainView(e){return this.has("storedMainView-"+e)}clearStoredMainView(e){let t=this.getStoredMainView(e);t&&t.remove(!0),this.unset("storedMainView-"+e)}storeMainView(t,i){this.set("storedMainView-"+t,i),this.listenTo(i,"remove",e=>{(e=e||{}).ignoreCleaning||(this.stopListening(i,"remove"),this.clearStoredMainView(t))})}clearAllStoredMainViews(){for(var e in this.params)0===e.indexOf("storedMainView-")&&(e=e.slice(15),this.clearStoredMainView(e))}checkAccess(e){return!0}handleAccessGlobal(){if(!this.checkAccessGlobal())throw new a.default.AccessDenied("Denied access to '"+this.name+"'")}checkAccessGlobal(){return!0}handleCheckAccess(e){if(!this.checkAccess(e))throw e=e?"Denied access to action '"+this.name+"#"+e+"'":"Denied access to scope '"+this.name+"'",new a.default.AccessDenied(e)}doAction(e,t){this.handleAccessGlobal(),e=e||this.defaultAction;var i="action"+Espo.Utils.upperCaseFirst(e);if(!(i in this))throw new a.default.NotFound("Action '"+this.name+"#"+e+"' is not found");var s="before"+Espo.Utils.upperCaseFirst(e),e="after"+Espo.Utils.upperCaseFirst(e);s in this&&this[s].call(this,t||{}),this[i].call(this,t||{}),e in this&&this[e].call(this,t||{})}master(t){const e=this.get("entire");e&&(e.remove(),this.set("entire",null));var i=this.get("master");i?t.call(this,i):(i=this.masterView||"views/site/master",this.viewFactory.create(i,{fullSelector:"body"},e=>{this.set("master",e),this.get("masterRendered")?t.call(this,e):e.render().then(()=>{this.set("masterRendered",!0),t.call(this,e)})}))}_unchainMainView(e){if(e.currentViewKey&&this.hasStoredMainView(e.currentViewKey)){const t=e.getView("main");t&&(t.propagateEvent("remove",{ignoreCleaning:!0}),e.unchainView("main"))}}main(e,s,t,i={}){const a={isCanceled:!1,key:i.key,useStored:i.useStored,callback:t},l=i.useStored||!1,o=i.key,r=(this.listenToOnce(this.baseController,"action",()=>a.isCanceled=!0),e&&"object"==typeof e?e:void 0),n=r?void 0:e||"views/base";this.master(t=>{if(!a.isCanceled){if((s=s||{}).fullSelector="#main",l&&this.hasStoredMainView(o)){const r=this.getStoredMainView(o);let e=!0;r&&"isActualForReuse"in r&&"function"==typeof r.isActualForReuse&&(e=r.isActualForReuse());var i=r&&"lastUrl"in r?r.lastUrl:null;if(e&&(!i||i===this.getRouter().getCurrentUrl()))return this._processMain(r,t,a),void("setupReuse"in r&&"function"==typeof r.setupReuse&&r.setupReuse(s.params||{}));this.clearStoredMainView(o)}if(r)return this._unchainMainView(t),void t.assignView("main",r,"#main").then(()=>{a.isSet=!0,this._processMain(e,t,a)});this.viewFactory.create(n,s,e=>{this._processMain(e,t,a)})}})}_processMain(e,t,i){if(!i.isCanceled){const s=i.key,a=(s&&this.storeMainView(s,e),()=>{e.cancelRender(),i.isCanceled=!0});e.listenToOnce(this.baseController,"action",a),t.currentViewKey&&(this.set("storedScrollTop-"+t.currentViewKey,(0,l.default)(window).scrollTop()),this._unchainMainView(t)),t.currentViewKey=s,i.isSet||t.setView("main",e);t=()=>{setTimeout(()=>e.stopListening(this.baseController,"action",a),500),e.updatePageTitle(),i.useStored&&this.has("storedScrollTop-"+s)?(0,l.default)(window).scrollTop(this.get("storedScrollTop-"+s)):(0,l.default)(window).scrollTop(0)};if(i.callback)return this.listenToOnce(e,"after:render",t),void i.callback.call(this,e);e.render().then(t)}}showLoadingNotification(){let e=this.get("master");e&&e.showLoadingNotification()}hideLoadingNotification(){let e=this.get("master");e&&e.hideLoadingNotification()}entire(e,t,i){const s=this.get("master");if(s&&s.remove(),this.set("master",null),this.set("masterRendered",!1),"object"==typeof e)return e.setElement("body"),void this.viewFactory.prepare(e,()=>{i?i(e):e.render()});(t=t||{}).fullSelector="body",this.viewFactory.create(e,t,e=>{this.set("entire",e),i?i(e):e.render()})}}Object.assign(s.prototype,t.Events),s.extend=t.View.extend,e.default=s}),define("acl",["exports","bullbone"],function(e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;class i{constructor(e,t,i){this.user=e||null,this.scope=t,this.aclAllowDeleteCreated=(i=i||{}).aclAllowDeleteCreated,this.teamsFieldIsForbidden=i.teamsFieldIsForbidden,this.forbiddenFieldList=i.forbiddenFieldList}getUser(){return this.user}checkScope(e,t,i,s){var a=(s=s||{}).inTeam,s=s.isOwner;if(this.getUser().isAdmin())return!1!==e;if(!1===e)return!1;if(!0===e)return!0;if("string"==typeof e)return!0;if(null===e)return!1;if(null===(t=t||null))return!0;if(!(t in e))return!1;e=e[t];if("all"===e)return!0;if("yes"===e)return!0;if("no"===e)return!1;if(void 0===s)return!0;if(s&&("own"===e||"team"===e))return!0;let l=!1;if("team"===e)if(null===(l=a)){if(!i)return!0;l=null}else if(a)return!0;if(null===s){if(!i)return!0;l=null}return l}checkModel(e,t,i,s){if(this.getUser().isAdmin())return!0;e={isOwner:this.checkIsOwner(e),inTeam:this.checkInTeam(e)};return this.checkScope(t,i,s,e)}checkModelDelete(e,t,i){i=this.checkModel(e,t,"delete",i);if(i)return!0;if(!1===t)return!1;if("no"===(t||{}).read)return!1;if(e.has("createdById")&&e.get("createdById")===this.getUser().id&&this.aclAllowDeleteCreated){if(!e.has("assignedUserId"))return!0;if(!e.get("assignedUserId"))return!0;if(e.get("assignedUserId")===this.getUser().id)return!0}return i}checkIsOwner(e){let t=!1;if(e.hasField("assignedUser")){if(this.getUser().id===e.get("assignedUserId"))return!0;e.has("assignedUserId")||(t=null)}else if(e.hasField("createdBy")){if(this.getUser().id===e.get("createdById"))return!0;e.has("createdById")||(t=null)}if(e.hasField("assignedUsers")){if(!e.has("assignedUsersIds"))return null;if(~(e.get("assignedUsersIds")||[]).indexOf(this.getUser().id))return!0;t=!1}return t}checkInTeam(e){var t=this.getUser().getTeamIdList();if(!e.has("teamsIds"))return!!this.teamsFieldIsForbidden||null;let i=e.getTeamIdList(),s=!1;return t.forEach(e=>{~i.indexOf(e)&&(s=!0)}),s}}i.extend=t.View.extend,e.default=i}),define("views/main",["exports","view"],function(e,t){"use strict";var i;Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;class s extends(t=(i=t)&&i.__esModule?i:{default:i}).default{scope="";name="";menu={};$headerActionsContainer=null;shortcutKeys=null;events={"click .action":function(e){Espo.Utils.handleAction(this,e.originalEvent,e.currentTarget,{actionItems:[...this.menu.buttons,...this.menu.dropdown],className:"main-header-manu-action"})}};lastUrl;init(){var e;this.scope=this.options.scope||this.scope,this.menu={},this.options.params=this.options.params||{},this.name&&this.scope&&(e=this.name.charAt(0).toLowerCase()+this.name.slice(1),this.menu=this.getMetadata().get(["clientDefs",this.scope,"menu",e])||{}),this.headerActionItemTypeList=["buttons","dropdown","actions"],this.menu=Espo.Utils.cloneDeep(this.menu);let i={};this.name&&(i=Espo.Utils.cloneDeep(this.getMetadata().get(["clientDefs","Global","menu",this.name.charAt(0).toLowerCase()+this.name.slice(1)])||{})),this.headerActionItemTypeList.forEach(e=>{this.menu[e]=this.menu[e]||[],this.menu[e]=this.menu[e].concat(i[e]||[]);let t=this.menu[e];t.forEach(s=>{let a=this;s.initFunction&&s.data.handler&&this.wait(new Promise(i=>{Espo.loader.require(s.data.handler,e=>{let t=new e(a);t[s.initFunction].call(t),i()})}))})}),this.updateLastUrl(),this.on("after:render-internal",()=>{this.$headerActionsContainer=this.$el.find(".page-header .header-buttons")}),this.on("header-rendered",()=>{this.$headerActionsContainer=this.$el.find(".page-header .header-buttons"),this.adjustButtons()}),this.on("after:render",()=>this.adjustButtons()),this.shortcutKeys&&(this.shortcutKeys=Espo.Utils.cloneDeep(this.shortcutKeys))}setupFinal(){this.shortcutKeys&&(this.events["keydown.main"]=e=>{var t,i,s=Espo.Utils.getKeyFromKeyEvent(e);"function"!=typeof this.shortcutKeys[s]?(t=this.shortcutKeys[s])&&(e.preventDefault(),e.stopPropagation(),"function"!=typeof this[i="action"+Espo.Utils.upperCaseFirst(t)]?this[t]():this[i]()):this.shortcutKeys[s].call(this,e.originalEvent)})}updateLastUrl(){this.lastUrl=this.getRouter().getCurrentUrl()}getMenu(){if(this.menuDisabled||!this.menu)return{};let i={};return this.headerActionItemTypeList.forEach(t=>{(this.menu[t]||[]).forEach(e=>{!1!==e?(e=Espo.Utils.clone(e),i[t]=i[t]||[],Espo.Utils.checkActionAvailability(this.getHelper(),e)&&Espo.Utils.checkActionAccess(this.getAcl(),this.model||this.scope,e)&&(e.accessDataList&&!Espo.Utils.checkAccessDataList(e.accessDataList,this.getAcl(),this.getUser())||(e.name=e.name||e.action,e.action=e.action||null,e.labelTranslation&&(e.html=this.getHelper().escapeString(this.getLanguage().translatePath(e.labelTranslation))),i[t].push(e)))):i[t].push(!1)})}),i}getHeader(){return""}buildHeaderHtml(e){let i=e.map(e=>$("
").addClass("breadcrumb-item").append(e)),s=$("
").addClass("header-breadcrumbs");return i.forEach((e,t)=>{s.append(e),t!==i.length-1&&s.append($("
").addClass("breadcrumb-separator").append($("").addClass("chevron-right")))}),s.get(0).outerHTML}getHeaderIconHtml(){return this.getHelper().getScopeColorIconHtml(this.scope)}actionShowModal(e){e=e.view;e&&this.createView("modal",e,{model:this.model,collection:this.collection},e=>{e.render(),this.listenTo(e,"after:save",()=>{this.model&&this.model.fetch(),this.collection&&this.collection.fetch()})})}addMenuItem(e,t,i,s){if(t){t.name=t.name||t.action||Espo.Utils.generateId();let i=t.name,s=-1;this.menu[e].forEach((e,t)=>{(e=e||{}).name===i&&(s=t)}),~s&&this.menu[e].splice(s,1)}let a=i?"unshift":"push";this.menu[e][a](t),s||!this.isRendered()?!s&&this.isBeingRendered()&&this.once("after:render",()=>{this.getHeaderView().reRender()}):this.getHeaderView().reRender()}removeMenuItem(s,e){let a=-1,l=!1;this.headerActionItemTypeList.forEach(i=>{(this.menu[i]||[]).forEach((e,t)=>{(e=e||{}).name===s&&(a=t,l=i)})}),~a&&l&&this.menu[l].splice(a,1),e||!this.isRendered()?e||!this.isBeingRendered()?e&&this.isRendered()&&this.$headerActionsContainer.find('[data-name="'+s+'"]').remove():this.once("after:render",()=>{this.getHeaderView().reRender()}):this.getHeaderView().reRender()}disableMenuItem(e){this.$headerActionsContainer.find('[data-name="'+e+'"]').addClass("disabled").attr("disabled")}enableMenuItem(e){this.$headerActionsContainer.find('[data-name="'+e+'"]').removeClass("disabled").removeAttr("disabled")}actionNavigateToRoot(e,t){t.stopPropagation(),this.getRouter().checkConfirmLeaveOut(()=>{var e=this.options.rootUrl||this.options.params.rootUrl||"#"+this.scope;this.getRouter().navigate(e,{trigger:!1}),this.getRouter().dispatch(this.scope,null,{isReturn:!0})})}hideHeaderActionItem(t){this.headerActionItemTypeList.forEach(e=>{(this.menu[e]||[]).forEach(e=>{(e=e||{}).name===t&&(e.hidden=!0)})}),this.isRendered()&&(this.$headerActionsContainer.find('li > .action[data-name="'+t+'"]').parent().addClass("hidden"),this.$headerActionsContainer.find('a.action[data-name="'+t+'"]').addClass("hidden"),this.controlMenuDropdownVisibility(),this.adjustButtons())}showHeaderActionItem(t){this.headerActionItemTypeList.forEach(e=>{(this.menu[e]||[]).forEach(e=>{(e=e||{}).name===t&&(e.hidden=!1)})});let e=()=>{this.$headerActionsContainer.find('li > .action[data-name="'+t+'"]').parent().removeClass("hidden"),this.$headerActionsContainer.find('a.action[data-name="'+t+'"]').removeClass("hidden"),this.controlMenuDropdownVisibility(),this.adjustButtons()};this.isRendered()?e():this.isBeingRendered()&&this.whenRendered().then(()=>e())}hasMenuVisibleDropdownItems(){let t=!1;return(this.menu.dropdown||[]).forEach(e=>{e.hidden||(t=!0)}),t}controlMenuDropdownVisibility(){let e=this.$headerActionsContainer.find(".dropdown-group");if(this.hasMenuVisibleDropdownItems())return e.removeClass("hidden"),void e.find("> button").removeClass("hidden");e.addClass("hidden"),e.find("> button").addClass("hidden")}getHeaderView(){return this.getView("header")}adjustButtons(){let e=this.$headerActionsContainer.find(".btn"),t=(e.removeClass("radius-left").removeClass("radius-right"),e.filter(":not(.hidden)"));t.first().addClass("radius-left"),t.last().addClass("radius-right")}setupReuse(e){}}e.default=s}),define("views/base",["exports","view"],function(e,t){"use strict";var i;Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;class s extends(t=(i=t)&&i.__esModule?i:{default:i}).default{constructor(e){super(e)}}e.default=s}),define("views/record/detail",["exports","views/record/base","view-record-helper","helpers/action-item-setup"],function(e,t,i,s){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,t=a(t),i=a(i),s=a(s);class l extends t.default{constructor(e){super(e)}template="record/detail";type="detail";layoutName="detail";detailLayout=null;fieldsMode="detail";mode="detail";gridLayout=null;buttonsDisabled=!1;isNew=!1;buttonList=[{name:"edit",label:"Edit",title:"Ctrl+Space"}];dropdownItemList=[{name:"delete",label:"Remove"}];buttonEditList=[{name:"save",label:"Save",style:"primary",edit:!0,title:"Ctrl+Enter"},{name:"cancelEdit",label:"Cancel",edit:!0,title:"Esc"}];dropdownEditItemList=[];allActionItemsDisabled=!1;id=null;returnUrl=null;returnDispatchParams=null;middleView="views/record/detail-middle";sideView="views/record/detail-side";bottomView="views/record/detail-bottom";sideDisabled=!1;bottomDisabled=!1;gridLayoutType="record";editModeDisabled=!1;navigateButtonsDisabled=!1;readOnly=!1;isWide=!1;duplicateAction=!0;selfAssignAction=!1;printPdfAction=!0;convertCurrencyAction=!0;saveAndContinueEditingAction=!0;inlineEditDisabled=!1;portalLayoutDisabled=!1;panelSoftLockedTypeList=["default","acl","delimiter","dynamicLogic"];dynamicLogicDefs={};confirmLeaveDisabled=!1;setupHandlerType="record/detail";currentTab=0;middlePanelDefs=null;middlePanelDefsList=null;$middle=null;$bottom=null;$detailButtonContainer=null;blockUpdateWebSocketPeriod=500;stickButtonsFormBottomSelector;dynamicHandlerClassName;accessControlDisabled;inlineEditModeIsOn=!1;shortcutKeyCtrlEnterAction="save";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)}};events={"click .button-container .action":function(e){const t=e.currentTarget;let i=void 0;t.classList.contains("detail-action-item")?i=[...this.buttonList,...this.dropdownItemList]:t.classList.contains("edit-action-item")&&(i=[...this.buttonEditList,...this.dropdownEditItemList]),Espo.Utils.handleAction(this,e.originalEvent,t,{actionItems:i})},'click [data-action="showMoreDetailPanels"]':function(){this.showMoreDetailPanels()},"click .middle-tabs > button":function(e){e=parseInt($(e.currentTarget).attr("data-tab"));this.selectTab(e)}};actionEdit(){if(!this.editModeDisabled)return this.setEditMode(),this.focusOnFirstDiv(),void $(window).scrollTop(0);let e={id:this.model.id,model:this.model};this.options.rootUrl&&(e.rootUrl=this.options.rootUrl),this.getRouter().navigate("#"+this.scope+"/edit/"+this.model.id,{trigger:!1}),this.getRouter().dispatch(this.scope,"edit",e)}actionDelete(){this.delete()}actionSave(e){let t=this.mode;e=this.save((e=e||{}).options).catch(e=>(t===this.MODE_EDIT&&"error"===e&&this.setEditMode(),Promise.reject(e)));return this.lastSaveCancelReason&&"notModified"!==this.lastSaveCancelReason||(this.setDetailMode(),this.focusOnFirstDiv(),$(window).scrollTop(0)),e}actionCancelEdit(){this.cancelEdit(),this.focusOnFirstDiv(),$(window).scrollTop(0)}focusOnFirstDiv(){let e=this.$el.find("> div").get(0);e&&e.focus({preventScroll:!0})}actionSaveAndContinueEditing(e){this.save((e=e||{}).options).catch(()=>{})}actionSelfAssign(){let e={assignedUserId:this.getUser().id,assignedUserName:this.getUser().get("name")};if("getSelfAssignAttributes"in this){var t=this.getSelfAssignAttributes();if(t)for(var i in t)e[i]=t[i]}this.model.save(e,{patch:!0}).then(()=>{Espo.Ui.success(this.translate("Self-Assigned"))})}actionConvertCurrency(){this.createView("modalConvertCurrency","views/modals/convert-currency",{entityType:this.entityType,model:this.model},e=>{e.render(),this.listenToOnce(e,"after:update",e=>{let t=!1;for(var i in e)if(e[i]!==this.model.get(i)){t=!0;break}t?this.model.fetch().then(()=>{Espo.Ui.success(this.translate("done","messages"))}):Espo.Ui.warning(this.translate("notUpdated","messages"))})})}getSelfAssignAttributes(){return null}setupActionItems(){if(this.model.isNew()?(this.isNew=!0,this.removeActionItem("delete")):this.getMetadata().get(["clientDefs",this.scope,"removeDisabled"])&&this.removeActionItem("delete"),this.duplicateAction&&this.getAcl().check(this.entityType,"create")&&!this.getMetadata().get(["clientDefs",this.scope,"duplicateDisabled"])&&this.addDropdownItem({label:"Duplicate",name:"duplicate"}),this.selfAssignAction&&(!this.getAcl().check(this.entityType,"edit")||~this.getAcl().getScopeForbiddenFieldList(this.entityType).indexOf("assignedUser")||this.getUser().isPortal()||this.model.has("assignedUserId")&&(this.dropdownItemList.push({label:"Self-Assign",name:"selfAssign",hidden:!!this.model.get("assignedUserId")}),this.listenTo(this.model,"change:assignedUserId",()=>{this.model.get("assignedUserId")?this.hideActionItem("selfAssign"):this.showActionItem("selfAssign")}))),this.type===this.TYPE_DETAIL&&this.printPdfAction){let e=!0;(e=~(this.getHelper().getAppParam("templateEntityTypeList")||[]).indexOf(this.entityType)?e:!1)&&this.dropdownItemList.push({label:"Print to PDF",name:"printPdf"})}if(this.type===this.TYPE_DETAIL&&this.convertCurrencyAction&&this.getAcl().check(this.entityType,"edit")&&!this.getMetadata().get(["clientDefs",this.scope,"convertCurrencyDisabled"])&&this.getFieldManager().getEntityTypeFieldList(this.entityType,{type:"currency",acl:"edit"}).length&&this.addDropdownItem({label:"Convert Currency",name:"convertCurrency"}),this.type===this.TYPE_DETAIL&&this.getMetadata().get(["scopes",this.scope,"hasPersonalData"])&&"yes"===this.getAcl().getPermissionLevel("dataPrivacyPermission")&&this.dropdownItemList.push({label:"View Personal Data",name:"viewPersonalData"}),this.type===this.TYPE_DETAIL&&this.getMetadata().get(["scopes",this.scope,"stream"])&&this.addDropdownItem({label:"View Followers",name:"viewFollowers"}),this.type===this.TYPE_DETAIL){let e=new s.default(this.getMetadata(),this.getHelper(),this.getAcl(),this.getLanguage());e.setup(this,this.type,e=>this.wait(e),e=>this.addDropdownItem(e),e=>this.showActionItem(e),e=>this.hideActionItem(e)),this.saveAndContinueEditingAction&&this.dropdownEditItemList.push({name:"saveAndContinueEditing",label:"Save & Continue Editing",title:"Ctrl+S"})}}disableActionItems(){this.disableButtons()}enableActionItems(){this.enableButtons()}hideActionItem(e){for(var t of this.buttonList)if(t.name===e){t.hidden=!0;break}for(var i of this.dropdownItemList)if(i.name===e){i.hidden=!0;break}for(var s of this.dropdownEditItemList)if(s.name===e){s.hidden=!0;break}for(var a of this.buttonEditList)if(a.name===e){a.hidden=!0;break}this.isRendered()&&(this.$detailButtonContainer.find('li > .action[data-action="'+e+'"]').parent().addClass("hidden"),this.$detailButtonContainer.find('button.action[data-action="'+e+'"]').addClass("hidden"),this.isDropdownItemListEmpty()&&this.$dropdownItemListButton.addClass("hidden"),this.isDropdownEditItemListEmpty()&&this.$dropdownEditItemListButton.addClass("hidden"),this.adjustButtons())}showActionItem(e){for(var t of this.buttonList)if(t.name===e){t.hidden=!1;break}for(var i of this.dropdownItemList)if(i.name===e){i.hidden=!1;break}for(var s of this.dropdownEditItemList)if(s.name===e){s.hidden=!1;break}for(var a of this.buttonEditList)if(a.name===e){a.hidden=!1;break}this.isRendered()&&(this.$detailButtonContainer.find('li > .action[data-action="'+e+'"]').parent().removeClass("hidden"),this.$detailButtonContainer.find('button.action[data-action="'+e+'"]').removeClass("hidden"),this.isDropdownItemListEmpty()||this.$dropdownItemListButton.removeClass("hidden"),this.isDropdownEditItemListEmpty()||this.$dropdownEditItemListButton.removeClass("hidden"),this.adjustButtons())}disableActionItem(e){for(var t of this.buttonList)if(t.name===e){t.disabled=!0;break}for(var i of this.dropdownItemList)if(i.name===e){i.disabled=!0;break}for(var s of this.dropdownEditItemList)if(s.name===e){s.disabled=!0;break}for(var a of this.buttonEditList)if(a.name===e){a.disabled=!0;break}this.isRendered()&&(this.$detailButtonContainer.find('li > .action[data-action="'+e+'"]').parent().addClass("disabled").attr("disabled","disabled"),this.$detailButtonContainer.find('button.action[data-action="'+e+'"]').addClass("disabled").attr("disabled","disabled"))}enableActionItem(e){for(var t of this.buttonList)if(t.name===e){t.disabled=!1;break}for(var i of this.dropdownItemList)if(i.name===e){i.disabled=!1;break}for(var s of this.dropdownEditItemList)if(s.name===e){s.disabled=!1;break}for(var a of this.buttonEditList)if(a.name===e){a.disabled=!1;break}this.isRendered()&&(this.$detailButtonContainer.find('li > .action[data-action="'+e+'"]').parent().removeClass("disabled").removeAttr("disabled"),this.$detailButtonContainer.find('button.action[data-action="'+e+'"]').removeClass("disabled").removeAttr("disabled"))}hasAvailableActionItem(t){return!this.allActionItemsDisabled&&(this.type===this.TYPE_DETAIL&&this.mode===this.MODE_EDIT?-1!==this.buttonEditList.findIndex(e=>e.name===t&&!e.disabled&&!e.hidden)||-1!==this.dropdownEditItemList.findIndex(e=>e.name===t&&!e.disabled&&!e.hidden):-1!==this.buttonList.findIndex(e=>e.name===t&&!e.disabled&&!e.hidden)||-1!==this.dropdownItemList.findIndex(e=>e.name===t&&!e.disabled&&!e.hidden))}showPanel(s,a){if(!this.recordHelper.getPanelStateParam(s,"hiddenLocked")&&(a=a||"default",this.recordHelper.setPanelStateParam(s,"hidden"+Espo.Utils.upperCaseFirst(a)+"Locked",!1),"dynamicLogic"!==a||!1!==this.recordHelper.getPanelStateParam(s,"hidden"))){for(let e=0;e{let e=this.getBottomView();e&&("processShowPanel"in e?e.processShowPanel(s):"showPanel"in e&&e.showPanel(s))}),this.getSideView());i?"showPanel"in i&&i.showPanel(s):this.sideView&&this.once("ready",()=>{let e=this.getSideView();e&&("processShowPanel"in e?e.processShowPanel(s):"showPanel"in e&&e.showPanel(s))}),this.recordHelper.setPanelStateParam(s,"hidden",!1),this.middlePanelDefs[s]&&(this.controlTabVisibilityShow(this.middlePanelDefs[s].tabNumber),this.adjustMiddlePanels()),this.recordHelper.trigger("panel-show")}}hidePanel(s,e,t){if(t=t||"default",e&&this.recordHelper.setPanelStateParam(s,"hiddenLocked",!0),t&&this.recordHelper.setPanelStateParam(s,"hidden"+Espo.Utils.upperCaseFirst(t)+"Locked",!0),"dynamicLogic"!==t||!0!==this.recordHelper.getPanelStateParam(s,"hidden")){let e=this.getMiddleView(),t=(e&&e.hidePanelInternal(s),this.getBottomView()),i=(t?"hidePanel"in t&&t.hidePanel(s):this.bottomView&&this.once("ready",()=>{let e=this.getBottomView();e&&("processHidePanel"in e?e.processHidePanel(s):"hidePanel"in e&&e.hidePanel(s))}),this.getSideView());i?"hidePanel"in i&&i.hidePanel(s):this.sideView&&this.once("ready",()=>{let e=this.getSideView();e&&("processHidePanel"in e?e.processHidePanel(s):"hidePanel"in e&&e.hidePanel(s))}),this.recordHelper.setPanelStateParam(s,"hidden",!0),this.middlePanelDefs[s]&&(this.controlTabVisibilityHide(this.middlePanelDefs[s].tabNumber),this.adjustMiddlePanels())}}afterRender(){this.$middle=this.$el.find(".middle"),this.bottomView&&(this.$bottom=this.$el.find(".bottom")),this.initElementReferences(),this.adjustMiddlePanels(),this.adjustButtons(),this.initStickableButtonsContainer(),this.initFieldsControlBehaviour()}initFieldsControlBehaviour(){var e,t=this.getFieldViews();let i=null;for(e in t){var s=t[e];this.listenTo(s,"edit",e=>{i&&i.isEditMode()&&i.inlineEditClose(),i=e}),this.listenTo(s,"inline-edit-on",()=>{this.inlineEditModeIsOn=!0}),this.listenTo(s,"inline-edit-off",e=>{(e=e||{}).all||(this.inlineEditModeIsOn=!1,this.setIsNotChanged())}),this.listenTo(s,"after:inline-edit-off",e=>{this.updatedAttributes&&!e.noReset&&this.resetModelChanges()})}}initStickableButtonsContainer(){let h=this.$el.find(".detail-button-container"),e=this.$el.find(".detail-button-container.record-buttons");if(e.length){let s=this.getThemeManager().getParam("navbarHeight");var t=this.getThemeManager().getParam("screenWidthXs");let a=$(window.document).width(){let t=e.get(0),i=0;for(;t;)i+=isNaN(t.offsetTop)?0:t.offsetTop,t=t.offsetParent;return a?i:i-s})(e),l=e.outerHeight(),o=(i-=5,$("
").css("height",l+"px").html(" ").hide().insertAfter(e)),r=this.getMiddleView().$el,n=$(window),d=$("#navbar .navbar-right");!this.stickButtonsFormBottomSelector||(t=this.$el.find(this.stickButtonsFormBottomSelector)).length&&(r=t),n.off("scroll.detail-"+this.numId),n.on("scroll.detail-"+this.numId,()=>{var e=r.position().top+r.outerHeight(!1)-l,t=n.scrollTop();if(e<=t&&!this.stickButtonsContainerAllTheWay)return h.hide(),d.removeClass("has-sticked-bar"),void o.show();if(!a||!$("#navbar .navbar-body").hasClass("in")){if(t>i)return h.hasClass("stick-sub")||(h.addClass("stick-sub"),o.show()),d.addClass("has-sticked-bar"),void h.show();h.hasClass("stick-sub")&&(h.removeClass("stick-sub"),d.removeClass("has-sticked-bar"),o.hide()),h.show()}})}}fetch(){let t=super.fetch();if(this.hasView("side")){let e=this.getSideView();"fetch"in e&&(t=_.extend(t,e.fetch()))}if(this.hasView("bottom")){let e=this.getBottomView();"fetch"in e&&(t=_.extend(t,e.fetch()))}return t}setEditMode(){return this.trigger("before:set-edit-mode"),this.inlineEditModeIsOn=!1,this.$el.find(".record-buttons").addClass("hidden"),this.$el.find(".edit-buttons").removeClass("hidden"),new Promise(e=>{var t,i=this.getFieldViews(!0);let s=[];for(t in i){let e=i[t];e.readOnly||(e.isEditMode()&&(e.fetchToModel(),e.removeInlineEditLinks(),e.setIsInlineEditMode(!1)),s.push(e.setEditMode().then(()=>e.render())))}this.mode=this.MODE_EDIT,this.trigger("after:set-edit-mode"),this.trigger("after:mode-change"),Promise.all(s).then(()=>e())})}setDetailMode(){return this.trigger("before:set-detail-mode"),this.$el.find(".edit-buttons").addClass("hidden"),this.$el.find(".record-buttons").removeClass("hidden"),this.inlineEditModeIsOn=!1,new Promise(e=>{var t,i=this.getFieldViews(!0);let s=[];for(t in i){let e=i[t];e.isDetailMode()||(e.isEditMode()&&e.trigger("inline-edit-off",{all:!0}),s.push(e.setDetailMode().then(()=>e.render())))}this.mode=this.MODE_DETAIL,this.trigger("after:set-detail-mode"),this.trigger("after:mode-change"),Promise.all(s).then(()=>e())})}cancelEdit(){this.resetModelChanges(),this.setDetailMode(),this.setIsNotChanged()}resetModelChanges(){let e=!0;for(var t in this.updatedAttributes&&(this.attributes=this.updatedAttributes,this.updatedAttributes=null,e=!1),this.model.attributes)t in this.attributes||this.model.unset(t);this.model.set(this.attributes,{skipReRender:e})}delete(){this.confirm({message:this.translate("removeRecordConfirmation","messages",this.scope),confirmText:this.translate("Remove")},()=>{this.trigger("before:delete"),this.trigger("delete"),Espo.Ui.notify(" ... ");let e=this.model.collection;this.model.destroy({wait:!0}).then(()=>{e&&0{e.hidden||(t=!1)}),t}isDropdownEditItemListEmpty(){if(0===this.dropdownEditItemList.length)return!0;let t=!0;return this.dropdownEditItemList.forEach(e=>{e.hidden||(t=!1)}),t}setup(){if(void 0===this.model)throw new Error("Model has not been injected into record view.");this.recordHelper=this.options.recordHelper||new i.default(this.defaultFieldStates,this.defaultFieldStates),this._initInlineEditSave();let e=this.collection=this.model.collection;e&&(this.listenTo(this.model,"destroy",()=>{e.remove(this.model.id),e.trigger("sync",{})}),"indexOfRecord"in this.options?this.indexOfRecord=this.options.indexOfRecord:this.indexOfRecord=e.indexOf(this.model)),this.middlePanelDefs={},this.middlePanelDefsList=[],this.getUser().isPortal()&&!this.portalLayoutDisabled&&this.getMetadata().get(["clientDefs",this.scope,"additionalLayouts",this.layoutName+"Portal"])&&(this.layoutName+="Portal"),this.numId=Math.floor(1e4*Math.random()+1),$(window).on("fetch-record."+this.cid,()=>this.handleRecordUpdate()),this.once("remove",()=>{this.isChanged&&this.resetModelChanges(),this.setIsNotChanged(),$(window).off("scroll.detail-"+this.numId),$(window).off("fetch-record."+this.cid)}),this.id=Espo.Utils.toDom(this.entityType)+"-"+Espo.Utils.toDom(this.type)+"-"+this.numId,this.isNew=this.model.isNew(),this.editModeDisabled||"editModeDisabled"in this.options&&(this.editModeDisabled=this.options.editModeDisabled),this.confirmLeaveDisabled=this.options.confirmLeaveDisabled||this.confirmLeaveDisabled,this.buttonsDisabled=this.options.buttonsDisabled||this.buttonsDisabled,"buttonsPosition"in this.options&&!this.options.buttonsPosition&&(this.buttonsDisabled=!0),"isWide"in this.options&&(this.isWide=this.options.isWide),"sideView"in this.options&&(this.sideView=this.options.sideView),"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,this.readOnly||this.isNew||(this.readOnly=this.getMetadata().get(["clientDefs",this.scope,"editDisabled"])||!1),this.getMetadata().get(["clientDefs",this.scope,"createDisabled"])&&(this.duplicateAction=!1),(this.getConfig().get("currencyList")||[]).length<=1&&(this.convertCurrencyAction=!1),this.readOnlyLocked=this.readOnly,this.inlineEditDisabled=this.inlineEditDisabled||this.getMetadata().get(["clientDefs",this.scope,"inlineEditDisabled"])||!1,this.inlineEditDisabled=this.options.inlineEditDisabled||this.inlineEditDisabled,this.navigateButtonsDisabled=this.options.navigateButtonsDisabled||this.navigateButtonsDisabled,this.portalLayoutDisabled=this.options.portalLayoutDisabled||this.portalLayoutDisabled,this.dynamicLogicDefs=this.options.dynamicLogicDefs||this.dynamicLogicDefs,this.accessControlDisabled=this.options.accessControlDisabled||this.accessControlDisabled,this.setupActionItems(),this.setupBeforeFinal(),this.on("after:render",()=>{this.initElementReferences()}),!this.isNew&&this.getHelper().webSocketManager&&this.getMetadata().get(["scopes",this.entityType,"object"])&&(this.subscribeToWebSocket(),this.once("remove",()=>{this.isSubscribedToWebSocket&&this.unsubscribeFromWebSocket()})),this.wait(this.getHelper().processSetupHandlers(this,this.setupHandlerType)),this.initInlineEditDynamicWithLogicInteroperability(),this.forcePatchAttributeDependencyMap=this.getMetadata().get(["clientDefs",this.scope,"forcePatchAttributeDependencyMap"])||{}}setupBeforeFinal(){this.accessControlDisabled||this.manageAccess(),this.attributes=this.model.getClonedAttributes(),this.options.attributes&&this.model.set(this.options.attributes),this.listenTo(this.model,"sync",()=>{this.attributes=this.model.getClonedAttributes()}),this.listenTo(this.model,"change",(e,t)=>{if(t.sync)for(var i in e.attributes)e.hasChanged(i)&&(this.attributes[i]=Espo.Utils.cloneDeep(e.get(i)));else this.mode!==this.MODE_EDIT&&!this.inlineEditModeIsOn||this.setIsChanged()});var e=Espo.Utils.clone(this.getMetadata().get(["clientDefs",this.entityType,"formDependency"])||{}),e=(this.dependencyDefs=_.extend(e,this.dependencyDefs),this.initDependency(),Espo.Utils.clone(this.getMetadata().get(["clientDefs",this.entityType,"dynamicLogic"])||{}));this.dynamicLogicDefs=_.extend(e,this.dynamicLogicDefs),this.initDynamicLogic(),this.setupFieldLevelSecurity(),this.initDynamicHandler()}_initInlineEditSave(){this.listenTo(this.recordHelper,"inline-edit-save",(e,t)=>{this.inlineEditSave(e,t)})}inlineEditSave(e,t){let i=this.getFieldView(e);if(!i)throw new Error(`No field '${e}'.`);t=_.extend({inline:!0,field:e,afterValidate:()=>{t.bypassClose||i.inlineEditClose(!0)}},t||{}),this.save(t).then(()=>{i.trigger("after:inline-save"),i.trigger("after:save"),t.bypassClose&&(i.initialAttributes=this.model.getClonedAttributes())}).catch(e=>{if("notModified"===e)return t.bypassClose?void 0:void i.inlineEditClose(!0);"error"===e&&(t.bypassClose||i.inlineEdit())})}initInlineEditDynamicWithLogicInteroperability(){let i=!1,t=(e,t)=>{if(this.inlineEditModeIsOn&&!this.editModeDisabled&&!i){if("required"===e){let e=this.getFieldView(t);if(e.validateRequired){e.suspendValidationMessage();try{if(!e.validateRequired())return}catch(e){}}}i=!0,setTimeout(()=>i=!1,300),setTimeout(()=>{this.setEditMode(),this.getFieldViewList().forEach(e=>e.removeInlineEditLinks())},10)}};this.on("set-field-required",e=>t("required",e)),this.on("set-field-option-list",e=>t("options",e)),this.on("reset-field-option-list",e=>t("options",e))}initDynamicHandler(){let e=this.dynamicHandlerClassName||this.getMetadata().get(["clientDefs",this.scope,"dynamicHandler"]),s=l=>{this.listenTo(this.model,"change",(e,t)=>{"onChange"in l&&l.onChange.call(l,e,t);var i,s=e.changedAttributes();for(i in s){var a="onChange"+Espo.Utils.upperCaseFirst(i);a in l&&l[a].call(l,e,s[i],t)}}),"init"in l&&l.init()},a=(e&&this.wait(new Promise(t=>{Espo.loader.require(e,e=>{e=this.dynamicHandler=new e(this);s(e),t()})})),this.getMetadata().get(["clientDefs",this.scope,"dynamicHandlerList"])||[]);if(a.length){let i=this,t=[];a.forEach(e=>{t.push(new Promise(t=>{Espo.loader.require(e,e=>{t(new e(i))})}))}),this.wait(Promise.all(t).then(e=>{e.forEach(e=>{s(e)})}))}}setupFinal(){this.build(),this.shortcutKeys&&this.options.shortcutKeysEnabled&&(this.events["keydown.record-detail"]=e=>{var t,i,s=Espo.Utils.getKeyFromKeyEvent(e);"function"!=typeof this.shortcutKeys[s]?(t=this.shortcutKeys[s])&&(e.preventDefault(),e.stopPropagation(),"function"!=typeof this[i="action"+Espo.Utils.upperCaseFirst(t)]?this[t]():this[i]()):this.shortcutKeys[s].call(this,e.originalEvent)}),this.options.focusForCreate||this.once("after:render",()=>this.focusOnFirstDiv())}setIsChanged(){this.isChanged=!0,this.confirmLeaveDisabled||this.setConfirmLeaveOut(!0)}setIsNotChanged(){this.isChanged=!1,this.confirmLeaveDisabled||this.setConfirmLeaveOut(!1)}switchToModelByIndex(e){let t=this.model.collection||this.collection;if(t){var i=t.at(e);if(!i)throw new Error("Model is not found in collection by index.");var s=i.id,a=this.entityType||this.scope;this.getRouter().navigate("#"+a+"/view/"+s,{trigger:!1}),this.getRouter().dispatch(a,"view",{id:s,model:i,indexOfRecord:e,rootUrl:this.options.rootUrl})}}actionPrevious(){var e;if(this.model.abortLastFetch(),!this.model.collection){if(!this.collection)return;this.indexOfRecord--,this.indexOfRecord<0&&(this.indexOfRecord=0)}0=t.length-1)){let e=this.indexOfRecord+1;e<=t.length-1?this.switchToModelByIndex(e):t.fetch({more:!0,remove:!1}).then(()=>{this.switchToModelByIndex(e)})}}actionViewPersonalData(){this.createView("viewPersonalData","views/personal-data/modals/personal-data",{model:this.model},e=>{e.render(),this.listenToOnce(e,"erase",()=>{this.clearView("viewPersonalData"),this.model.fetch()})})}actionViewFollowers(e){var t=this.getMetadata().get(["clientDefs",this.entityType,"relationshipPanels","followers","viewModalView"])||this.getMetadata().get(["clientDefs","User","modalViews","relatedList"])||"views/modals/followers-list",i=!this.getUser().isAdmin()&&"no"===this.getAcl().getPermissionLevel("followerManagementPermission")&&"no"===this.getAcl().getPermissionLevel("portalPermission");let s={model:this.model,link:"followers",scope:"User",title:this.translate("Followers"),filtersDisabled:!0,url:this.entityType+"/"+this.model.id+"/followers",createDisabled:!0,selectDisabled:i,rowActionsView:"views/user/record/row-actions/relationship-followers"};if(e.viewOptions)for(var a in e.viewOptions)s[a]=e.viewOptions[a];Espo.Ui.notify(" ... "),this.createView("modalRelatedList",t,s,e=>{Espo.Ui.notify(!1),e.render(),this.listenTo(e,"action",(e,t)=>{Espo.Utils.handleAction(this,e,t)}),this.listenToOnce(e,"close",()=>{this.clearView("modalRelatedList")}),e.listenTo(this.model,"after:relate:followers",()=>{this.model.fetch()}),e.listenTo(this.model,"after:unrelate:followers",()=>{this.model.fetch()})})}actionPrintPdf(){this.createView("pdfTemplate","views/modals/select-template",{entityType:this.entityType},e=>{e.render(),this.listenToOnce(e,"select",e=>{this.clearView("pdfTemplate"),window.open("?entryPoint=pdf&entityType="+this.entityType+"&entityId="+this.model.id+"&templateId="+e.id,"_blank")})})}afterSave(){this.isNew?Espo.Ui.success(this.translate("Created")):Espo.Ui.success(this.translate("Saved")),this.enableActionItems(),this.setIsNotChanged(),setTimeout(()=>{this.unblockUpdateWebSocket()},this.blockUpdateWebSocketPeriod)}beforeSave(){Espo.Ui.notify(this.translate("saving","messages")),this.blockUpdateWebSocket()}beforeBeforeSave(){this.disableActionItems()}afterSaveError(){this.enableActionItems()}afterNotModified(){var e=this.translate("notModified","messages");Espo.Ui.warning(e),this.enableActionItems(),this.setIsNotChanged()}afterNotValid(){Espo.Ui.error(this.translate("Not valid")),this.enableActionItems()}errorHandlerDuplicate(e,t,i){return Espo.Ui.notify(!1),this.createView("duplicate","views/modals/duplicate",{scope:this.entityType,duplicates:e,model:this.model},e=>{e.render(),this.listenToOnce(e,"save",()=>{this.actionSave({options:{headers:{"X-Skip-Duplicate-Check":"true"}}}).then(()=>i())})}),!0}errorHandlerModified(e,t){Espo.Ui.notify(!1);let i=e.versionNumber,s=e.values||{},a=Object.keys(s),l=[];a.forEach(e=>{this.attributes[e]!==s[e]&&l.push(e)}),0!==l.length?this.createView("dialog","views/modals/resolve-save-conflict",{model:this.model,attributeList:l,currentAttributes:Espo.Utils.cloneDeep(this.model.attributes),originalAttributes:Espo.Utils.cloneDeep(this.attributes),actualAttributes:Espo.Utils.cloneDeep(s)}).then(e=>{e.render(),this.listenTo(e,"resolve",()=>{for(var e in this.model.set("versionNumber",i,{silent:!0}),this.attributes.versionNumber=i,s)this.setInitialAttributeValue(e,s[e])})}):setTimeout(()=>{this.model.set("versionNumber",i,{silent:!0}),this.attributes.versionNumber=i,t.inline&&t.field?this.inlineEditSave(t.field):this.actionSave()},5)}getMiddleView(){return this.getView("middle")}getSideView(){return this.getView("side")}getBottomView(){return this.getView("bottom")}setReadOnly(){this.readOnlyLocked||(this.readOnly=!0);let e=this.getBottomView(),t=(e&&"setReadOnly"in e&&e.setReadOnly(),this.getSideView());t&&"setReadOnly"in t&&t.setReadOnly(),this.getFieldList().forEach(e=>{this.setFieldReadOnly(e)})}setNotReadOnly(t){this.readOnlyLocked||(this.readOnly=!1);let e=this.getBottomView(),i=(e&&"setNotReadOnly"in e&&e.setNotReadOnly(t),this.getSideView());i&&"setNotReadOnly"in i&&i.setNotReadOnly(t),this.getFieldList().forEach(e=>{t&&this.recordHelper.getFieldStateParam(e,"readOnly")||this.setFieldNotReadOnly(e)})}manageAccessEdit(e){var t;this.isNew||(!(t=this.getAcl().checkModel(this.model,"edit",!0))||this.readOnlyLocked?(this.readOnly=!0,this.hideActionItem("edit"),this.selfAssignAction&&this.hideActionItem("selfAssign")):(this.showActionItem("edit"),this.selfAssignAction&&(this.hideActionItem("selfAssign"),this.model.has("assignedUserId")&&(this.model.get("assignedUserId")||this.showActionItem("selfAssign"))),this.readOnlyLocked||(this.readOnly&&e&&(this.isReady?this.setNotReadOnly(!0):this.on("ready",()=>this.setNotReadOnly(!0))),this.readOnly=!1)),null===t&&this.listenToOnce(this.model,"sync",()=>{this.manageAccessEdit(!0)}))}manageAccessDelete(){var e;this.isNew||((e=this.getAcl().checkModel(this.model,"delete",!0))?this.showActionItem("delete"):this.hideActionItem("delete"),null===e&&this.listenToOnce(this.model,"sync",()=>{this.manageAccessDelete(!0)}))}manageAccessStream(){var e;this.isNew||(~["no","own"].indexOf(this.getAcl().getLevel("User","read"))&&"no"===this.getAcl().getPermissionLevel("portalPermission")?this.hideActionItem("viewFollowers"):((e=this.getAcl().checkModel(this.model,"stream",!0))?this.showActionItem("viewFollowers"):this.hideActionItem("viewFollowers"),null===e&&this.listenToOnce(this.model,"sync",()=>{this.manageAccessStream(!0)})))}manageAccess(){this.manageAccessEdit(),this.manageAccessDelete(),this.manageAccessStream()}addButton(e,t){var i=e.name;if(i){for(var s of this.buttonList)if(s.name===i)return;t?this.buttonList.unshift(e):this.buttonList.push(e)}}addDropdownItem(e,t){if(e){var i=e.name;if(i){for(var s of this.dropdownItemList)if(s.name===i)return;t?this.dropdownItemList.unshift(e):this.dropdownItemList.push(e)}}else t?this.dropdownItemList.unshift(!1):this.dropdownItemList.push(!1)}addButtonEdit(e,t){var i=e.name;if(i){for(var s of this.buttonEditList)if(s.name===i)return;t?this.buttonEditList.unshift(e):this.buttonEditList.push(e)}}enableButtons(){this.allActionItemsDisabled=!1,this.$el.find(".button-container .actions-btn-group .action").removeAttr("disabled").removeClass("disabled"),this.$el.find(".button-container .actions-btn-group .dropdown-toggle").removeAttr("disabled").removeClass("disabled"),this.buttonList.filter(e=>e.disabled).forEach(e=>{this.$detailButtonContainer.find(`button.action[data-action="${e.name}"]`).addClass("disabled").attr("disabled","disabled")}),this.buttonEditList.filter(e=>e.disabled).forEach(e=>{this.$detailButtonContainer.find(`button.action[data-action="${e.name}"]`).addClass("disabled").attr("disabled","disabled")}),this.dropdownItemList.filter(e=>e.disabled).forEach(e=>{this.$detailButtonContainer.find(`li > .action[data-action="${e.name}"]`).parent().addClass("disabled").attr("disabled","disabled")}),this.dropdownEditItemList.filter(e=>e.disabled).forEach(e=>{this.$detailButtonContainer.find(`li > .action[data-action="${e.name}"]`).parent().addClass("disabled").attr("disabled","disabled")})}disableButtons(){this.allActionItemsDisabled=!0,this.$el.find(".button-container .actions-btn-group .action").attr("disabled","disabled").addClass("disabled"),this.$el.find(".button-container .actions-btn-group .dropdown-toggle").attr("disabled","disabled").addClass("disabled")}removeActionItem(e){this.removeButton(e)}removeButton(e){for(var[t,i]of this.buttonList.entries())if(i.name===e){this.buttonList.splice(t,1);break}for(var[s,a]of this.dropdownItemList.entries())if(a.name===e){this.dropdownItemList.splice(s,1);break}this.isRendered()&&this.$el.find('.detail-button-container .action[data-action="'+e+'"]').remove()}convertDetailLayout(t){let i=[];var h=this.getSelector()||"#"+this.id;this.panelFieldListMap={};let s=-1;for(let e=0;ethis.validateField(l),t.recordHelper=this.recordHelper,t.dataObject=this.options.dataObject||{},p.options)for(var m in p.options)void 0===t[m]&&(t[m]=p.options[m]);let s={name:l+"Field",view:a,field:l,fullSelector:h+' .middle .field[data-name="'+l+'"]',fullWidth:i,options:t};e&&(s.selector=e),"labelText"in p&&(t.labelText=p.labelText,s.customLabel=p.labelText),"customLabel"in p&&(s.customLabel=p.customLabel),"label"in p&&(s.label=p.label),a&&"object"==typeof a&&!s.customLabel&&!s.label&&a.getLabelText()&&(s.customLabel=a.getLabelText()),"customCode"in p&&(s.customCode=p.customCode),"noLabel"in p&&(s.noLabel=p.noLabel),"span"in p&&(s.span=p.span),o.push(s)}else console.warn("No 'name' specified in detail layout cell.")}else o.push(!1);n[d].push(o)}i.push(n)}return i}getGridLayout(t){if(null===this.gridLayout)return this.detailLayout?(this.gridLayout={type:this.gridLayoutType,layout:this.convertDetailLayout(this.detailLayout)},void t(this.gridLayout)):void this.getHelper().layoutManager.get(this.entityType,this.layoutName,e=>{"function"==typeof this.modifyDetailLayout&&(e=Espo.Utils.cloneDeep(e),this.modifyDetailLayout(e)),this.detailLayout=e,this.gridLayout={type:this.gridLayoutType,layout:this.convertDetailLayout(this.detailLayout)},t(this.gridLayout)});t(this.gridLayout)}createSideView(){var e=this.getSelector()||"#"+this.id;this.createView("side",this.sideView,{model:this.model,scope:this.scope,fullSelector:e+" .side",type:this.type,readOnly:this.readOnly,inlineEditDisabled:this.inlineEditDisabled,recordHelper:this.recordHelper,recordViewObject:this,isReturn:this.options.isReturn,dataObject:this.options.dataObject})}createMiddleView(t){let i=this.getSelector()||"#"+this.id;this.waitForView("middle"),this.getGridLayout(e=>{this.hasTabs()&&this.options.isReturn&&this.isStoredTabForThisRecord()&&this.selectStoredTab(),this.createView("middle",this.middleView,{model:this.model,scope:this.scope,type:this.type,layoutDefs:e,fullSelector:i+" .middle",layoutData:{model:this.model},recordHelper:this.recordHelper,recordViewObject:this,panelFieldListMap:this.panelFieldListMap},t)})}createBottomView(){var e=this.getSelector()||"#"+this.id;this.createView("bottom",this.bottomView,{model:this.model,scope:this.scope,fullSelector:e+" .bottom",readOnly:this.readOnly,type:this.type,inlineEditDisabled:this.inlineEditDisabled,recordHelper:this.recordHelper,recordViewObject:this,portalLayoutDisabled:this.portalLayoutDisabled,isReturn:this.options.isReturn,dataObject:this.options.dataObject})}build(e){!this.sideDisabled&&this.sideView&&this.createSideView(),this.middleView&&this.createMiddleView(e),!this.bottomDisabled&&this.bottomView&&this.createBottomView()}exitAfterCreate(){var e;return!(this.returnAfterCreate||!this.model.id)&&(e="#"+this.scope+"/view/"+this.model.id,this.getRouter().navigate(e,{trigger:!1}),this.getRouter().dispatch(this.scope,"view",{id:this.model.id,rootUrl:this.options.rootUrl,model:this.model,isAfterCreate:!0}),!0)}exit(e){if(e){var t="exitAfter"+Espo.Utils.upperCaseFirst(e);if(t in this)if(this[t]())return}let i,s;if(this.returnUrl)i=this.returnUrl;else{if("delete"===e)return i=this.options.rootUrl||"#"+this.scope,this.getRouter().navigate(i,{trigger:!1}),void this.getRouter().dispatch(this.scope,null,{isReturn:!0});this.model.id?(i="#"+this.scope+"/view/"+this.model.id,this.returnDispatchParams||(this.getRouter().navigate(i,{trigger:!1}),s={id:this.model.id,model:this.model},this.options.rootUrl&&(s.rootUrl=this.options.rootUrl),this.getRouter().dispatch(this.scope,"view",s))):i=this.options.rootUrl||"#"+this.scope}if(this.returnDispatchParams)return t=this.returnDispatchParams.controller,e=this.returnDispatchParams.action,s=this.returnDispatchParams.options||{},this.getRouter().navigate(i,{trigger:!1}),void this.getRouter().dispatch(t,e,s);this.getRouter().navigate(i,{trigger:!0})}subscribeToWebSocket(){var e="recordUpdate."+this.entityType+"."+this.model.id;this.recordUpdateWebSocketTopic=e,this.isSubscribedToWebSocket=!0,this.getHelper().webSocketManager.subscribe(e,()=>{this.handleRecordUpdate()})}unsubscribeFromWebSocket(){this.isSubscribedToWebSocket&&this.getHelper().webSocketManager.unsubscribe(this.recordUpdateWebSocketTopic)}handleRecordUpdate(){if(!this.updateWebSocketIsBlocked)if(this.inlineEditModeIsOn||this.mode===this.MODE_EDIT){let e=this.model.clone();void e.fetch().then(()=>{!this.inlineEditModeIsOn&&this.mode!==this.MODE_EDIT||(this.updatedAttributes=Espo.Utils.cloneDeep(e.attributes))})}else this.model.fetch({highlight:!0})}blockUpdateWebSocket(e){this.updateWebSocketIsBlocked=!0,e&&setTimeout(()=>{this.unblockUpdateWebSocket()},this.blockUpdateWebSocketPeriod)}unblockUpdateWebSocket(){this.updateWebSocketIsBlocked=!1}showMoreDetailPanels(){this.hidePanel("showMoreDelimiter"),this.underShowMoreDetailPanelList.forEach(e=>{this.showPanel(e)})}getTabCount(){if(!this.hasTabs())return 0;let t=1;return(this.detailLayout||[]).forEach(e=>{e.tabBreak&&t++}),t}hasTabs(){if(void 0!==this._hasMiddleTabs)return this._hasMiddleTabs;if(!this.detailLayout)return!1;for(var e of this.detailLayout)if(e.tabBreak)return this._hasMiddleTabs=!0;return this._hasMiddleTabs=!1}getMiddleTabDataList(){let a=this.currentTab,l=this.middlePanelDefsList;return l.filter((e,t)=>0===t||e.tabBreak).map((e,t)=>{let i=e.tabLabel,s=!1;return 0e.tabNumber===t).findIndex(e=>!this.recordHelper.getPanelStateParam(e.name,"hidden"))),i?"$label:"===i.substring(0,7)?i=this.translate(i.substring(7),"labels",this.scope):"$"===i[0]&&(i=this.translate(i.substring(1),"tabs",this.scope)):i=0===t?this.translate("Overview"):(t+1).toString(),{label:i,isActive:a===t,hidden:s}})}selectTab(e){this.currentTab=e,$(".popover.in").removeClass("in"),this.whenRendered().then(()=>{this.$el.find(".middle-tabs > button").removeClass("active"),this.$el.find(`.middle-tabs > button[data-tab="${e}"]`).addClass("active"),this.$el.find(".middle > .panel[data-tab]").addClass("tab-hidden"),this.$el.find(`.middle > .panel[data-tab="${e}"]`).removeClass("tab-hidden"),this.adjustMiddlePanels(),this.recordHelper.trigger("panel-show")}),this.storeTab()}storeTab(){this.getSessionStorage().set("tab_middle",this.currentTab),this.getSessionStorage().set("tab_middle_record",this.entityType+"_"+this.model.id)}selectStoredTab(){var e=this.getSessionStorage().get("tab_middle");0{let t=i.find(`> [data-tab="${e.toString()}"]`);t.addClass("invalid"),t.one("click",()=>{t.removeClass("invalid")})})}}}controlTabVisibilityShow(e){this.hasTabs()&&0!==e&&(this.isBeingRendered()?this.once("after:render",()=>this.controlTabVisibilityShow(e)):this.$el.find(`.middle-tabs > [data-tab="${e.toString()}"]`).removeClass("hidden"))}controlTabVisibilityHide(t){if(this.hasTabs()&&0!==t)if(this.isBeingRendered())this.once("after:render",()=>this.controlTabVisibilityHide(t));else{let e=this.middlePanelDefsList.filter(e=>e.tabNumber===t);if(-1===e.findIndex(e=>!this.recordHelper.getPanelStateParam(e.name,"hidden"))){let e=this.$el.find(`.middle-tabs > [data-tab="${t.toString()}"]`);e.addClass("hidden"),this.currentTab===t&&this.selectTab(0)}}}adjustMiddlePanels(){if(this.isRendered()&&this.$middle.length){let e=this.$middle.find("> .panel"),s=this.$bottom?this.$bottom.find("> .panel"):null,a=(e.removeClass("first").removeClass("last").removeClass("in-middle"),e.filter(":not(.tab-hidden):not(.hidden)"));a.each((e,t)=>{let i=$(t);if(e===a.length-1)return s&&s.first().hasClass("sticked")?0===e?void i.addClass("first"):void i.addClass("in-middle"):0===e?void 0:void i.addClass("last");0this.focusForEdit(),200))}handleShortcutKeyEscape(e){this.inlineEditModeIsOn||this.buttonsDisabled||this.type===this.TYPE_DETAIL&&this.mode===this.MODE_EDIT&&(e.preventDefault(),e.stopPropagation(),this.model.set(this.fetch()),this.isChanged?this.confirm(this.translate("confirmLeaveOutMessage","messages")).then(()=>this.actionCancelEdit()):this.actionCancelEdit())}handleShortcutKeyCtrlAltEnter(e){}handleShortcutKeyControlBackslash(a){if(this.hasTabs()){let s=this.$el.find(".middle-tabs > button:not(.hidden)");if(1!==s.length){a.preventDefault(),a.stopPropagation();let e=s.toArray().findIndex(e=>$(e).hasClass("active")),t=(++e>=s.length&&(e=0),$(s.get(e))),i=parseInt(t.attr("data-tab"));this.selectTab(i),this.mode!==this.MODE_EDIT?this.$el.find(`.middle-tabs button[data-tab="${i}"]`).focus():setTimeout(()=>{this.$middle.find(`.panel[data-tab="${i}"] .cell:not(.hidden)`).first().focus()},50)}}}handleShortcutKeyControlArrowLeft(t){if(!this.inlineEditModeIsOn&&!this.buttonsDisabled&&!this.navigateButtonsDisabled&&this.type===this.TYPE_DETAIL&&this.mode===this.MODE_DETAIL&&"TEXTAREA"!==t.target.tagName&&"INPUT"!==t.target.tagName){let e=this.$el.find('button[data-action="previous"]');e.length&&!e.hasClass("disabled")&&(t.preventDefault(),t.stopPropagation(),this.actionPrevious())}}handleShortcutKeyControlArrowRight(t){if(!this.inlineEditModeIsOn&&!this.buttonsDisabled&&!this.navigateButtonsDisabled&&this.type===this.TYPE_DETAIL&&this.mode===this.MODE_DETAIL&&"TEXTAREA"!==t.target.tagName&&"INPUT"!==t.target.tagName){let e=this.$el.find('button[data-action="next"]');e.length&&!e.hasClass("disabled")&&(t.preventDefault(),t.stopPropagation(),this.actionNext())}}getMode(){return this.mode}}e.default=l}),define("views/fields/link",["exports","views/fields/base","helpers/record-modal"],function(e,t,s){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,t=i(t),s=i(s);class a extends t.default{type="link";listTemplate="fields/link/list";detailTemplate="fields/link/detail";editTemplate="fields/link/edit";searchTemplate="fields/link/search";nameName;idName;foreignScope=null;selectRecordsView="views/modals/select-records";autocompleteDisabled=!1;createDisabled=!1;createButton=!1;forceCreateButton=!1;searchTypeList=["is","isEmpty","isNotEmpty","isNot","isOneOf","isNotOneOf"];selectFilterList=null;selectPrimaryFilterName=null;selectBoolFilterList=null;autocompleteMaxCount=null;forceSelectAllAttributes=!1;mandatorySelectAttributeList=null;autocompleteOnEmpty=!1;events={'auxclick a[href]:not([role="button"])':function(e){this.isReadMode()&&1===e.button&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),e.stopPropagation(),this.quickView())}};data(){let e=this.model.has(this.nameName)?this.model.get(this.nameName):this.model.get(this.idName),t=(null===e&&(e=this.model.get(this.idName)),this.isReadMode()&&!e&&this.model.get(this.idName)&&(e=this.translate(this.foreignScope,"scopeNames")),null);this.isDetailMode()&&(t=this.getHelper().getScopeColorIconHtml(this.foreignScope));var i=this.createButton&&(!this.createDisabled||this.forceCreateButton);return{...super.data(),idName:this.idName,nameName:this.nameName,idValue:this.model.get(this.idName),nameValue:e,foreignScope:this.foreignScope,valueIsSet:this.model.has(this.idName),iconHtml:t,url:this.getUrl(),createButton:i}}getUrl(){var e=this.model.get(this.idName);return e?"#"+this.foreignScope+"/view/"+e:null}getSelectFilters(){return null}getSelectBoolFilterList(){return this.selectBoolFilterList}getSelectPrimaryFilterName(){return this.selectPrimaryFilterName}getSelectFilterList(){return this.selectFilterList}getCreateAttributes(){let t=this.getMetadata().get(["clientDefs",this.entityType,"relationshipPanels",this.name,"createAttributeMap"])||{},i={};return Object.keys(t).forEach(e=>i[t[e]]=this.model.get(e)),i}setup(){this.nameName=this.name+"Name",this.idName=this.name+"Id",this.foreignScope=this.options.foreignScope||this.foreignScope,this.foreignScope=this.foreignScope||this.model.getFieldParam(this.name,"entity")||this.model.getLinkParam(this.name,"entity"),"createDisabled"in this.options&&(this.createDisabled=this.options.createDisabled),this.isListMode()||(this.addActionHandler("selectLink",()=>this.actionSelect()),this.addActionHandler("clearLink",()=>this.clearLink())),this.isSearchMode()&&(this.addActionHandler("selectLinkOneOf",()=>this.actionSelectOneOf()),this.events['click a[data-action="clearLinkOneOf"]']=e=>{e=$(e.currentTarget).data("id").toString();this.deleteLinkOneOf(e)}),this.createButton&&this.addActionHandler("createLink",()=>this.actionCreateLink()),this.panelDefs=this.getMetadata().get(["clientDefs",this.entityType,"relationshipPanels",this.name])||{},this.panelDefs.createDisabled&&(this.createDisabled=!0)}select(t){this.$elementName.val(t.get("name")||t.id),this.$elementId.val(t.get("id")),this.mode===this.MODE_SEARCH&&(this.searchData.idValue=t.get("id"),this.searchData.nameValue=t.get("name")||t.id),this.trigger("change"),this.getSelectFieldHandler().then(e=>{e.getAttributes(t).then(e=>{this.model.set(e)})})}clearLink(){this.$elementName.val(""),this.$elementId.val(""),this.trigger("change"),this.getSelectFieldHandler().then(e=>{e.getClearAttributes().then(e=>{this.model.set(e)})})}getSelectFieldHandler(){return this.panelDefs.selectFieldHandler?new Promise(t=>{Espo.loader.requirePromise(this.panelDefs.selectFieldHandler).then(e=>{e=new e(this.getHelper());t(e)})}):Promise.resolve({getClearAttributes:()=>Promise.resolve({}),getAttributes:()=>Promise.resolve({})})}setupSearch(){this.searchData.oneOfIdList=this.getSearchParamsData().oneOfIdList||this.searchParams.oneOfIdList||[],this.searchData.oneOfNameHash=this.getSearchParamsData().oneOfNameHash||this.searchParams.oneOfNameHash||{},~["is","isNot","equals"].indexOf(this.getSearchType())&&(this.searchData.idValue=this.getSearchParamsData().idValue||this.searchParams.idValue||this.searchParams.value,this.searchData.nameValue=this.getSearchParamsData().nameValue||this.searchParams.nameValue||this.searchParams.valueName),this.events["change select.search-type"]=e=>{e=$(e.currentTarget).val();this.handleSearchType(e)}}handleSearchType(e){~["is","isNot","isNotAndIsNotEmpty"].indexOf(e)?this.$el.find("div.primary").removeClass("hidden"):this.$el.find("div.primary").addClass("hidden"),~["isOneOf","isNotOneOf","isNotOneOfAndIsNotEmpty"].indexOf(e)?this.$el.find("div.one-of-container").removeClass("hidden"):this.$el.find("div.one-of-container").addClass("hidden")}getAutocompleteMaxCount(){return this.autocompleteMaxCount||this.getConfig().get("recordsPerPage")}getAutocompleteUrl(){let i=this.foreignScope+"?maxSize="+this.getAutocompleteMaxCount();if(!this.forceSelectAllAttributes){var t=this.mandatorySelectAttributeList||this.panelDefs.selectMandatoryAttributeList;let e=["id","name"];t&&(e=e.concat(t)),i+="&select="+e.join(",")}if(this.panelDefs.selectHandler)return new Promise(t=>{this._getSelectFilters().then(e=>{e.bool&&(i+="&"+$.param({boolFilterList:e.bool})),e.primary&&(i+="&"+$.param({primaryFilter:e.primary})),e.advanced&&(i+="&"+$.param({where:e.advanced})),t(i)})});var t=[...this.getSelectBoolFilterList()||[],...this.panelDefs.selectBoolFilterList||[]],e=this.getSelectPrimaryFilterName()||this.panelDefs.selectPrimaryFilterName;return t.length&&(i+="&"+$.param({boolFilterList:t})),e&&(i+="&"+$.param({primaryFilter:e})),i}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",()=>{""===this.$elementName.val()&&this.clearLink()}),this.$elementName.on("blur",e=>{setTimeout(()=>{this.mode===this.MODE_EDIT&&this.model.has(this.nameName)&&(e.currentTarget.value=this.model.get(this.nameName))},100),this.autocompleteDisabled||setTimeout(()=>this.$elementName.autocomplete("clear"),300)});let e=this.$elementName;if(!this.autocompleteDisabled){let s=!1;if(this.getEmptyAutocompleteResult()&&this.$elementName.on("keydown",e=>{"Tab"===e.code&&s&&e.stopImmediatePropagation()}),this.$elementName.autocomplete({beforeRender:e=>{this.$elementName.hasClass("input-sm")&&e.addClass("small")},lookup:(t,i)=>{var e;if(!this.autocompleteOnEmpty&&0===t.length)return s=!0,void((e=this.getEmptyAutocompleteResult())&&i(this._transformAutocompleteResult(e)));s=!1,Promise.resolve(this.getAutocompleteUrl(t)).then(e=>{Espo.Ajax.getRequest(e,{q:t}).then(e=>{i(this._transformAutocompleteResult(e))})})},minChars:0,triggerSelectOnValidInput:!1,autoSelectFirst:!0,noCache:!0,formatResult:e=>this.getHelper().escapeString(e.name),onSelect:t=>{this.getModelFactory().create(this.foreignScope,e=>{e.set(t.attributes),this.select(e),this.$elementName.focus()})}}),this.$elementName.off("focus.autocomplete"),this.$elementName.on("focus",()=>{this.$elementName.val()?this.$elementName.get(0).select():this.$elementName.autocomplete("onFocus")}),this.$elementName.attr("autocomplete","espo-"+this.name),this.once("render",()=>{e.autocomplete("dispose")}),this.once("remove",()=>{e.autocomplete("dispose")}),this.isSearchMode()){let i=this.$el.find("input.element-one-of");i.autocomplete({beforeRender:e=>{this.$elementName.hasClass("input-sm")&&e.addClass("small")},serviceUrl:()=>this.getAutocompleteUrl(),minChars:1,paramName:"q",noCache:!0,formatResult:e=>this.getHelper().escapeString(e.name),transformResult:e=>this._transformAutocompleteResult(JSON.parse(e)),onSelect:t=>{this.getModelFactory().create(this.foreignScope,e=>{e.set(t.attributes),this.selectOneOf([e]),i.val(""),setTimeout(()=>i.focus(),50)})}}),i.attr("autocomplete","espo-"+this.name),this.once("render",()=>{i.autocomplete("dispose")}),this.once("remove",()=>{i.autocomplete("dispose")}),this.$el.find("select.search-type").on("change",()=>{this.trigger("change")})}}e.on("change",()=>{this.isSearchMode()||this.model.get(this.idName)||e.val(this.model.get(this.nameName))})}var e;this.isSearchMode()&&(e=this.$el.find("select.search-type").val(),this.handleSearchType(e),~["isOneOf","isNotOneOf","isNotOneOfAndIsNotEmpty"].indexOf(e)&&this.searchData.oneOfIdList.forEach(e=>{this.addLinkOneOfHtml(e,this.searchData.oneOfNameHash[e])}))}_transformAutocompleteResult(e){const t=[];return e.list.forEach(e=>{t.push({id:e.id,name:e.name||e.id,data:e.id,value:e.name||e.id,attributes:e})}),{suggestions:t}}getValueForDisplay(){return this.model.get(this.nameName)}validateRequired(){var e;if(this.isRequired()&&null==this.model.get(this.idName))return e=this.translate("fieldIsRequired","messages").replace("{field}",this.getLabelText()),this.showValidationMessage(e),!0}deleteLinkOneOf(e){this.deleteLinkOneOfHtml(e);var t=this.searchData.oneOfIdList.indexOf(e);-1").addClass("link-"+e).addClass("list-group-item");return s.append($("").attr("role","button").addClass("pull-right").attr("data-id",e).attr("data-action","clearLinkOneOf").append($("").addClass("fas fa-times")),$("").text(t)," "),i.append(s),s}fetch(){var e={};return e[this.nameName]=this.$el.find('[data-name="'+this.nameName+'"]').val()||null,e[this.idName]=this.$el.find('[data-name="'+this.idName+'"]').val()||null,e}fetchSearch(){var e=this.$el.find("select.search-type").val(),t=this.$el.find('[data-name="'+this.idName+'"]').val();if(~["isOneOf","isNotOneOf"].indexOf(e)&&!this.searchData.oneOfIdList.length)return{type:"isNotNull",attribute:"id",data:{type:e}};if("isEmpty"===e)return{type:"isNull",attribute:this.idName,data:{type:e}};if("isNotEmpty"===e)return{type:"isNotNull",attribute:this.idName,data:{type:e}};if("isOneOf"===e)return{type:"in",attribute:this.idName,value:this.searchData.oneOfIdList,data:{type:e,oneOfIdList:this.searchData.oneOfIdList,oneOfNameHash:this.searchData.oneOfNameHash}};if("isNotOneOf"===e)return{type:"or",value:[{type:"notIn",attribute:this.idName,value:this.searchData.oneOfIdList},{type:"isNull",attribute:this.idName}],data:{type:e,oneOfIdList:this.searchData.oneOfIdList,oneOfNameHash:this.searchData.oneOfNameHash}};if("isNotOneOfAndIsNotEmpty"===e)return{type:"notIn",attribute:this.idName,value:this.searchData.oneOfIdList,data:{type:e,oneOfIdList:this.searchData.oneOfIdList,oneOfNameHash:this.searchData.oneOfNameHash}};if("isNot"===e){if(!t)return!1;var i=this.$el.find('[data-name="'+this.nameName+'"]').val();return{type:"or",value:[{type:"notEquals",attribute:this.idName,value:t},{type:"isNull",attribute:this.idName}],data:{type:e,idValue:t,nameValue:i}}}if("isNotAndIsNotEmpty"===e){if(!t)return!1;i=this.$el.find('[data-name="'+this.nameName+'"]').val();return{type:"notEquals",attribute:this.idName,value:t,data:{type:e,idValue:t,nameValue:i}}}if(!t)return!1;i=this.$el.find('[data-name="'+this.nameName+'"]').val();return{type:"equals",attribute:this.idName,value:t,data:{type:e,idValue:t,nameValue:i}}}getSearchType(){return this.getSearchParamsData().type||this.searchParams.typeFront||this.searchParams.type}quickView(){var t=this.model.get(this.idName);if(t){var i=this.foreignScope;let e=new s.default(this.getMetadata(),this.getAcl());e.showDetail(this,{id:t,scope:i})}}getCreateAttributesProvider(){return()=>{const i=this.getCreateAttributes()||{};return this.panelDefs.createHandler?new Promise(t=>{Espo.loader.requirePromise(this.panelDefs.createHandler).then(e=>new e(this.getHelper())).then(e=>{e.getAttributes(this.model).then(e=>{t({...i,...e})})})}):Promise.resolve(i)}}actionSelect(){Espo.Ui.notify(" ... ");var e=this.panelDefs;const t=e.selectModalView||this.getMetadata().get(["clientDefs",this.foreignScope,"modalViews","select"])||this.selectRecordsView,i=this.mandatorySelectAttributeList||e.selectMandatoryAttributeList,s=this.isEditMode()&&(!this.createDisabled||this.forceCreateButton),a=s?this.getCreateAttributesProvider():null;this._getSelectFilters().then(e=>{this.createView("dialog",t,{scope:this.foreignScope,createButton:s,filters:e.advanced,boolFilterList:e.bool,primaryFilterName:e.primary,mandatorySelectAttributeList:i,forceSelectAllAttributes:this.forceSelectAllAttributes,filterList:this.getSelectFilterList(),createAttributesProvider:a,layoutName:this.panelDefs.selectLayout},e=>{e.render(),Espo.Ui.notify(!1),this.listenToOnce(e,"select",e=>{this.clearView("dialog"),this.select(e)})})})}_getSelectFilters(){const e=this.panelDefs.selectHandler,a=this.getSelectBoolFilterList();var t;return!e||this.isSearchMode()?(t=a||this.panelDefs.selectBoolFilterList?[...a||[],...this.panelDefs.selectBoolFilterList||[]]:void 0,Promise.resolve({primary:this.getSelectPrimaryFilterName()||this.panelDefs.selectPrimaryFilterName,bool:t,advanced:this.getSelectFilters()||void 0})):new Promise(s=>{Espo.loader.requirePromise(e).then(e=>new e(this.getHelper())).then(e=>e.getFilters(this.model)).then(e=>{var t={...this.getSelectFilters()||{},...e.advanced||{}},i=this.getSelectPrimaryFilterName()||e.primary||this.panelDefs.selectPrimaryFilterName,e=a||e.bool||this.panelDefs.selectBoolFilterList?[...a||[],...e.bool||[],...this.panelDefs.selectBoolFilterList||[]]:void 0;s({bool:e,primary:i,advanced:t})})})}actionSelectOneOf(){Espo.Ui.notify(" ... ");var e=this.getMetadata().get(["clientDefs",this.foreignScope,"modalViews","select"])||this.selectRecordsView;this.createView("dialog",e,{scope:this.foreignScope,createButton:!1,filters:this.getSelectFilters(),boolFilterList:this.getSelectBoolFilterList(),primaryFilterName:this.getSelectPrimaryFilterName(),multiple:!0,layoutName:this.panelDefs.selectLayout},e=>{e.render(),Espo.Ui.notify(!1),this.listenToOnce(e,"select",e=>{this.clearView("dialog"),"[object Array]"!==Object.prototype.toString.call(e)&&(e=[e]),this.selectOneOf(e)})})}getEmptyAutocompleteResult(){}actionCreateLink(){const t=this.getMetadata().get(["clientDefs",this.foreignScope,"modalViews","edit"])||"views/modals/edit";Espo.Ui.notify(" ... "),this.getCreateAttributesProvider()().then(e=>{this.createView("dialog",t,{scope:this.foreignScope,fullFormDisabled:!0,attributes:e},t=>{t.render().then(()=>Espo.Ui.notify(!1)),this.listenToOnce(t,"after:save",e=>{t.close(),this.clearView("dialog"),this.select(e)})})})}selectOneOf(e){e.forEach(e=>{this.addLinkOneOf(e.id,e.get("name"))})}}e.default=a}),define("views/fields/float",["exports","views/fields/int"],function(e,t){"use strict";var i;Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;class s extends(t=(i=t)&&i.__esModule?i:{default:i}).default{type="float";editTemplate="fields/float/edit";decimalMark=".";validations=["required","float","range"];decimalPlacesRawValue=10;setup(){super.setup(),this.getPreferences().has("decimalMark")?this.decimalMark=this.getPreferences().get("decimalMark"):this.getConfig().has("decimalMark")&&(this.decimalMark=this.getConfig().get("decimalMark")),this.decimalMark||(this.decimalMark="."),this.decimalMark===this.thousandSeparator&&(this.thousandSeparator="")}setupAutoNumericOptions(){this.autoNumericOptions={digitGroupSeparator:this.thousandSeparator||"",decimalCharacter:this.decimalMark,modifyValueOnWheel:!1,selectOnFocus:!1,decimalPlaces:this.decimalPlacesRawValue,decimalPlacesRawValue:this.decimalPlacesRawValue,allowDecimalPadding:!1,showWarnings:!1,formulaMode:!0}}getValueForDisplay(){var e=isNaN(this.model.get(this.name))?null:this.model.get(this.name);return this.formatNumber(e)}formatNumber(e){return this.disableFormatting?e:this.formatNumberDetail(e)}formatNumberDetail(e){if(null===e)return"";var t=this.params.decimalPlaces;0===t?e=Math.round(e):t&&(e=Math.round(e*Math.pow(10,t))/Math.pow(10,t));let i=e.toString().split(".");if(i[0]=i[0].replace(/\B(?=(\d{3})+(?!\d))/g,this.thousandSeparator),0===t)return i[0];if(t){e=0;if(1e.startsWith(i))||t.startsWith(i)?s(e):0}}),t.allowCustomOptions&&(a.persist=!1,a.create=t.create,a.render={option_create:e=>$("
").addClass("create").append($("").text(e.input).addClass("text-bold")).append("…").get(0).outerHTML}),i.selectize(a)},focus:function(t){t=$(t);if(t[0]&&t[0].selectize){let e=t[0].selectize;e.focus()}},applyDefaultOptions:function(e){e=Espo.Utils.clone(e);var t,i={removeButton:!0,draggable:!1,selectOnTab:!1,delimiter:":,:",matchAnyWord:!1,allowCustomOptions:!1};for(t in i)t in e||(e[t]=i[t]);return e},loadBypassCtrlEnterPlugin:function(){if(!("bypass_ctrl_enter"in t.default.plugins)){const i=/Mac/.test(navigator.userAgent);t.default.define("bypass_ctrl_enter",function(){let e=this;this.onKeyDown=function(){let t=e.onKeyDown;return function(e){if("Enter"!==e.code||(i?!e.metaKey:!e.ctrlKey))return t.apply(this,arguments)}}()})}},loadRestoreOnBackspacePlugin:function(){"restore_on_backspace_espo"in t.default.plugins||t.default.define("restore_on_backspace_espo",function(s){s.text=s.text||function(e){return e[this.settings.labelField]};let e=this;this.onKeyDown=function(){let i=e.onKeyDown;return function(e){var t;return"Backspace"===e.code&&""===this.$control_input.val()&&!this.$activeItems.length&&0<=(t=this.caretPos-1)&&tthis.config.get("massActionIdleCountThreshold"))}process(e,t){return Espo.Ui.notify(!1),new Promise(i=>{this.view.createView("dialog","views/modals/mass-action",{id:e,action:t,scope:this.view.scope||this.view.entityType}).then(t=>{t.render(),i(t),this.view.listenToOnce(t,"success",e=>{i(e),this.view.listenToOnce(t,"close",()=>{t.trigger("close:success",e)})})})})}}}),define("helpers/export",["exports"],function(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;e.default=class{constructor(e){this.view=e,this.config=e.getConfig()}checkIsIdle(e){return!this.view.getUser().isPortal()&&(-1===(e=void 0===e?this.view.options.totalCount:e)||e>this.config.get("exportIdleCountThreshold"))}process(e){return Espo.Ui.notify(!1),new Promise(i=>{this.view.createView("dialog","views/export/modals/idle",{id:e}).then(t=>{t.render(),i(t),this.view.listenToOnce(t,"success",e=>{i(e),this.view.listenToOnce(t,"close",()=>{t.trigger("close:success",e)})})})})}}}),define("helpers/list/select-provider",["exports"],function(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;e.default=class{constructor(e,t,i){this.layoutManager=e,this.metadata=t,this.fieldManager=i}get(i,e){return new Promise(t=>{this.layoutManager.get(i,e||"list",e=>{e=this.getFromLayout(i,e);t(e)})})}getFromLayout(t,e){let i=[];return e.forEach(e=>{e.name&&(e=e.name,this.metadata.get(["entityDefs",t,"fields",e,"type"])&&(i=[this.fieldManager.getEntityTypeFieldAttributeList(t,e),...i]))}),i}}}),define("helpers/reg-exp-pattern",["exports"],function(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;e.default=class{constructor(e,t){this.metadata=e,this.language=t}validate(e,t,i,s){if(""===t||null===t)return null;let a="fieldNotMatchingPattern";var l,o;"$"===e[0]&&(l=e.slice(1),(o=this.metadata.get(["app","regExpPatterns",l,"pattern"]))&&(a+="$"+l,e=o));let r=new RegExp("^"+e+"$");if(r.test(t))return null;let n=this.language.translate(a,"messages").replace("{pattern}",e);return{message:n=i&&s?n.replace("{field}",this.language.translate(i,"fields",s)):n}}}}),define("web-socket-manager",["exports","js-base64"],function(e,a){"use strict";var t;Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,a=(t=a)&&t.__esModule?t:{default:t};e.default=class{constructor(t){this.config=t,this.subscribeQueue=[],this.isConnected=!1,this.connection=null,this.url="",this.protocolPart="";let e=this.config.get("webSocketUrl");if(e)0===e.indexOf("wss://")?(this.url=e.substring(6),this.protocolPart="wss://"):(this.url=e.substring(5),this.protocolPart="ws://");else{let e=this.config.get("siteUrl")||"";0===e.indexOf("https://")?(this.url=e.substring(8),this.protocolPart="wss://"):(this.url=e.substring(7),this.protocolPart="ws://"),~this.url.indexOf("/")&&(this.url=this.url.replace(/\/$/,""));var t="wss://"===this.protocolPart?443:8080,i=this.url.indexOf("/");~i?this.url=this.url.substring(0,i)+":"+t:this.url+=":"+t,"wss://"===this.protocolPart&&(this.url+="/wss")}}connect(t,i){var e=a.default.decode(t).split(":")[1],s=this.protocolPart+this.url;s+="?authToken="+e+"&userId="+i;try{this.connection=new ab.Session(s,()=>{this.isConnected=!0,this.subscribeQueue.forEach(e=>{this.subscribe(e.category,e.callback)}),this.subscribeQueue=[]},e=>{e===ab.CONNECTION_CLOSED&&(this.subscribeQueue=[]),e!==ab.CONNECTION_LOST&&e!==ab.CONNECTION_UNREACHABLE||setTimeout(()=>this.connect(t,i),3e3)},{skipSubprotocolCheck:!0})}catch(e){console.error(e.message),this.connection=null}}subscribe(t,e){if(this.connection)if(this.isConnected)try{this.connection.subscribe(t,e)}catch(e){e.message?console.error(e.message):console.error("WebSocket: Could not subscribe to "+t+".")}else this.subscribeQueue.push({category:t,callback:e})}unsubscribe(t,i){if(this.connection){this.subscribeQueue=this.subscribeQueue.filter(e=>e.category!==t&&e.callback!==i);try{this.connection.unsubscribe(t,i)}catch(e){e.message?console.error(e.message):console.error("WebSocket: Could not unsubscribe from "+t+".")}}}close(){if(this.connection){try{this.connection.close()}catch(e){console.error(e.message)}this.isConnected=!1}}}}),define("view-helper",["exports","marked","dompurify","handlebars"],function(e,i,s,v){"use strict";function t(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,s=t(s),v=t(v);e.default=class{constructor(){this._registerHandlebarsHelpers(),this.mdBeforeList=[{regex:/```\n?([\s\S]*?)```/g,value:function(e,t){return"
"+t.replace(/\*/g,"*").replace(/~/g,"~")+"
"}},{regex:/`([\s\S]*?)`/g,value:function(e,t){return""+t.replace(/\*/g,"*").replace(/~/g,"~")+""}}],i.marked.setOptions({breaks:!0,tables:!1}),s.default.addHook("beforeSanitizeAttributes",function(e){e instanceof HTMLAnchorElement&&(e.getAttribute("target")?e.targetBlank=!0:e.targetBlank=!1)}),s.default.addHook("afterSanitizeAttributes",function(e){if(e instanceof HTMLAnchorElement){const t=e.getAttribute("href");t&&!t.startsWith("#")&&e.setAttribute("rel","noopener noreferrer"),e.targetBlank&&(e.setAttribute("target","_blank"),e.setAttribute("rel","noopener noreferrer"))}})}layoutManager=null;settings=null;config=null;user=null;preferences=null;acl=null;modelFactory=null;collectionFactory=null;router=null;storage=null;sessionStorage=null;dateTime=null;language=null;metadata=null;fieldManager=null;cache=null;themeManager=null;webSocketManager=null;numberUtil=null;pageTitle=null;broadcastChannel=null;basePath="";appParams=null;_registerHandlebarsHelpers(){v.default.registerHelper("img",e=>new v.default.SafeString(`img`)),v.default.registerHelper("prop",(e,t)=>{if(t in e)return e[t]}),v.default.registerHelper("var",(e,t,i)=>{if(void 0===t)return null;let s=t[e];return i.hash.trim&&(s=s.trim()),new v.default.SafeString(s)}),v.default.registerHelper("concat",function(e,t){return e+t}),v.default.registerHelper("ifEqual",function(e,t,i){return e==t?i.fn(this):i.inverse(this)}),v.default.registerHelper("ifNotEqual",function(e,t,i){return e!=t?i.fn(this):i.inverse(this)}),v.default.registerHelper("ifPropEquals",function(e,t,i,s){return e[t]==i?s.fn(this):s.inverse(this)}),v.default.registerHelper("ifAttrEquals",function(e,t,i,s){return e.get(t)==i?s.fn(this):s.inverse(this)}),v.default.registerHelper("ifAttrNotEmpty",function(e,t,i){e=e.get(t);return null!=e?i.fn(this):i.inverse(this)}),v.default.registerHelper("ifNotEmptyHtml",function(e,t){return(e=e.replace(/\s/g,""))?t.fn(this):t.inverse(this)}),v.default.registerHelper("get",(e,t)=>e.get(t)),v.default.registerHelper("length",e=>e.length),v.default.registerHelper("translate",(e,t)=>{var i=t.hash.scope||null,t=t.hash.category||null;return"null"===e?"":this.language.translate(e,t,i)}),v.default.registerHelper("dropdownItem",(e,t)=>{var h=t.hash.scope||null,c=t.hash.label,i=t.hash.labelTranslation,s=t.hash.data,u=t.hash.hidden,a=t.hash.disabled,m=t.hash.title,p=t.hash.link,f=t.hash.action||e;const l=t.hash.iconHtml;var g=t.hash.iconClass;let o=t.hash.html||t.hash.text||(i?this.language.translatePath(i):this.language.translate(c,"labels",h));if(t.hash.html||(o=this.escapeString(o)),l)o=l+" "+o;else if(g){const l=$("").addClass(g).get(0).outerHTML;o=l+" "+o}const r=$("
  • ").addClass(u?"hidden":"").addClass(a?"disabled":""),n=$("").attr("role","button").attr("tabindex","0").attr("data-name",e).addClass(t.hash.className||"").addClass("action").html(o);if(f&&n.attr("data-action",f),r.append(n),p?n.attr("href",p):n.attr("role","button"),s)for(const d in s)n.attr("data-"+Espo.Utils.camelCaseToHyphen(d),s[d]);return a&&r.attr("disabled","disabled"),m&&n.attr("title",m),new v.default.SafeString(r.get(0).outerHTML)}),v.default.registerHelper("button",(e,t)=>{var i=t.hash.style||"default",s=t.hash.scope||null,h=t.hash.label||e,a=t.hash.labelTranslation,l=t.hash.link;const o=t.hash.iconHtml;var r=t.hash.iconClass;let n=t.hash.html||t.hash.text||(a?this.language.translatePath(a):this.language.translate(h,"labels",s));if(t.hash.html||(n=this.escapeString(n)),o)n=o+" "+n;else if(r){const o=$("").addClass(r).get(0).outerHTML;n=o+" "+n}const d=$(l?"":"
  • \r\n<% }); %>\r\n\r\n<%\r\nif (hasHiddenPanel) {\r\n%>\r\n
    \r\n \r\n \r\n \r\n
    \r\n<%\r\n}\r\n%>\r\n',"list-row":"<% _.each(layout, function (defs, key) { %>\r\n <%\r\n var width = null;\r\n if (defs.options && defs.options.defs && 'width' in defs.options.defs) {\r\n width = (defs.options.defs.width + '%') || null;\r\n }\r\n if (defs.options && defs.options.defs && 'widthPx' in defs.options.defs) {\r\n width = defs.options.defs.widthPx || null;\r\n }\r\n var align = false;\r\n if (defs.options && defs.options.defs) {\r\n align = defs.options.defs.align || false;\r\n }\r\n %>\r\n \" <% if (width) print(' width=\"'+width+'\"'); if (align) print(' align=\"'+align+'\"'); %>>\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( '');\r\n }\r\n %>\r\n \r\n<% }); %>\r\n","list-row-expanded":"<% if (layout.right) { %>\r\n
    \r\n {{{<%= layout.right.name %>}}}\r\n
    \r\n<% } %>\r\n<% _.each(layout.rows, function (row, key) { %>\r\n
    <% _.each(row, function (defs, key) { %>{{#ifNotEmptyHtml this.<%= defs.name %>}}\"><%\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( '');\r\n }\r\n %>{{/ifNotEmptyHtml}}<% }); %>
    \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 <%= '' %>\r\n<% }); %>\r\n","columns-2":"<% _.each(layout, function (row, rowNumber) { %>\r\n
    \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 <%= '' %>\r\n <% }); %>\r\n
    \r\n<% }); %>\r\n"}; //# sourceMappingURL=espo-main.js.map