(function(){"use strict";var e=['<div class="u8-datamodelinfoareaeditor">',"<h2>${infoAreaLabel}</h2>","<div>${infoAreaDetailsLabel}</div>","</div>"].join("");u8.Crm.Widgets.DataModelInfoAreaEditor=function(e,t){this.Widget(e,$.extend({},u8.Crm.Widgets.DataModelInfoAreaEditor.defaults,t));this._isCreated=false;if(this.infoArea){this._create()}else{u8.tools.created(this)}};u8.Crm.Widgets.DataModelInfoAreaEditor.defaults={};$.extend(u8.Crm.Widgets.DataModelInfoAreaEditor.prototype,{getInfoArea:function(){return this.infoArea},setInfoArea:function(e){if(!e||this._infoAreaId===e.infoAreaId){return this}this.infoArea=e;this._infoAreaId=e.infoAreaId;this._create()},_create:function(){$assert(u8.services.schema.isInfoAreaId(this._infoAreaId),"Specified info area id is not a valid info area id.");Function.chain(this._using,this._createViewModel.ifAlive(this),this._createView.ifAlive(this),u8.tools.created(this)).call(this)},_using:function(e){u8.using({texts:["DataModel"],types:["Schema"],schema:[this._infoAreaId]},e)},_createViewModel:function(e){this._viewModel={};var t=u8.services.schema.getInfoArea(this._infoAreaId);if(!t._isLoaded){return}var i=t.fields.filter(function(e){return e.category!=u8.Crm.Schema.FieldCategory.VirtualCore&&e.category!=u8.Crm.Schema.FieldCategory.WebCustomField});$.extend(this._viewModel,{infoAreaLabel:"{label} ({infoAreaId})".format(t),infoAreaDetailsLabel:$t("TXT_DataModel_4").format({fields:i.length,phone:i.filter(function(e){return e.telephoneDetails}).length,array:i.filter(function(e){return e.arrayFieldIds&&e.arrayFieldIds[0]===e.fieldId}).length,index:t.keys?t.keys.length:0,links:t.links?t.links.length:0})});return e()},_createView:function(t){var i=this.$(this.element);i.utml({template:e,data:this._viewModel,itemOptions:{parent:this}},t)}});u8.Crm.Widgets.DataModelInfoAreaEditor.makeClass({name:"DataModelInfoAreaEditor",deriveFrom:u8.Base.Widgets.Widget,events:["Create"]})})();