// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://@sbaseurl@/jsapi/jsapi/esri/copyright.txt and http://www.arcgis.com/apps/webappbuilder/copyright.txt for details.

//>>built
require({cache:{"url:widgets/CostAnalysis/create-load-project.html":'\x3cdiv\x3e\r\n  \x3cdiv class\x3d"esriCTCreateProjectContainer" data-dojo-attach-point\x3d"createLoadProjectContainer"\x3e\x3c/div\x3e\r\n  \x3cdiv data-dojo-attach-point\x3d"createProjectContainer"\x3e\x3c/div\x3e\r\n  \x3cdiv data-dojo-attach-point\x3d"loadProjectContainer"\x3e\x3c/div\x3e\r\n  \x3cdiv data-dojo-attach-point\x3d"updateEquationContainer" class\x3d"esriCTUpdateEquationMainContainer"\x3e\x3c/div\x3e\r\n\x3c/div\x3e'}});
define("dojo/_base/declare jimu/BaseWidget dojo/Evented dijit/_WidgetsInTemplateMixin dojo/text!./create-load-project.html dojo/_base/lang dojo/_base/array dojo/on dojo/dom-construct ./item-list dijit/form/ValidationTextBox jimu/dijit/formSelect esri/tasks/query esri/graphic esri/tasks/QueryTask esri/graphicsUtils dojo/Deferred esri/layers/FeatureLayer dojo/promise/all jimu/dijit/Message dojo/dom-style dojo/query ./update-project-cost dojo/dom-attr dijit/focus dojo/dom-class dojo/keys jimu/utils dojo/_base/event".split(" "),
function(I,J,K,L,M,d,l,m,p,N,E,O,r,F,v,G,t,y,B,H,C,q,P,z,x,Q,u,w,A){return I([J,K,L],{templateString:M,baseClass:"jimu-widget-cost-analysis-create-load-project",highlighterColor:"#000",projectLayer:null,paneListData:[],_numberFieldTypes:["esriFieldTypeSmallInteger","esriFieldTypeInteger","esriFieldTypeSingle","esriFieldTypeDouble"],projectNameOptions:[],projectNameField:null,projectDescField:null,_updateProjectCostWidget:null,projectNameTextBox:null,postCreate:function(){this.inherited(arguments);
this.projectNameField=this.config.projectLayerFields.PROJECTNAME;this.projectDescField=this.config.projectLayerFields.DESCRIPTION;this.paneListData=[];this.projectLayer=this.layerInfosObj.getLayerInfoById(this.config.projectSettings.projectLayer).layerObject;this.projectNameOptions=[{label:this.nls.createLoadProject.selectProject,value:"defaultSelectProjectNameOption"}];this._createProjectUI();this._loadProjectUI()},startup:function(){this.inherited(arguments);this._initializeData();this._fetchWidgetTopNode();
this.paneListData=[{title:this.nls.createLoadProject.createProjectPaneTitle,content:this.createProjectContainer,isOpen:!0,tabindex:"0",createProjectTab:!0,"aria-label":this.nls.createLoadProject.createProjectPaneTitle,role:"button",paneName:"creatProject"},{title:this.nls.createLoadProject.loadProjectPaneTitle,content:this.loadProjectContainer,isOpen:!1,loadProjectTab:!0,tabindex:"0","aria-label":this.nls.createLoadProject.loadProjectPaneTitle,role:"button",paneName:"loadProject"}];this.config.hasOwnProperty("updateCostEquationCheckBoxStatus")&&
this.config.updateCostEquationCheckBoxStatus&&this.paneListData.push({title:this.nls.updateCostEquationPanel.updateProjectCostTabLabel,content:this.updateEquationContainer,isOpen:!1,updateCostEquationWidget:!0,tabindex:"0","aria-label":this.nls.updateCostEquationPanel.updateProjectCostTabLabel,role:"button",paneName:"updateCostEquation"});this._createAndLoadProjectPanes();this._getProjectNamesOptions()},_initializeData:function(){this._updateProjectCostWidget=null},_showMessage:function(a){(new H({message:a})).message=
a},_createProjectUI:function(){var a=p.create("div",{"class":"esriCTCreateProjectWrapper"},this.createProjectContainer);var b=p.create("div",{"class":"esriCTFullwidth esriCTCreateProjectContent"},a);this.projectNameTextBox=new E({required:!0,trim:!0,placeHolder:this.nls.createLoadProject.projectNamePlaceHolder,title:this.nls.createLoadProject.projectNamePlaceHolder,maxLength:this._getFieldInfo(this.projectNameField).fieldLength,autofocus:!0,"class":"esriCTFullwidth esriCTCreateProjectContent esriCTEllipsis"},
b);this.projectNameTextBox.validator=d.hitch(this,function(f){return""===f?!1:this._validateProjectNameLocally(f)?!0:(this.projectNameTextBox.set("state","Error"),this.projectNameTextBox.set("invalidMessage",this.nls.createLoadProject.errorDuplicateProjectName),!1)});var c=this._getFieldInfo(this.projectDescField);b=p.create("div",{"class":"esriCTFullwidth esriCTCreateProjectContent"},a);var e=new E({required:c.nullable,trim:!0,placeHolder:this.nls.createLoadProject.projectDescPlaceHolder,"class":"esriCTFullwidth esriCTCreateProjectContent esriCTEllipsis",
title:this.nls.createLoadProject.projectDescPlaceHolder,maxLength:c.fieldLength},b);a=p.create("div",{"class":"esriCTFullwidth esriCTCreateLoadButtonWrap"},a);a=this._createButton(this.nls.createLoadProject.createLabel,a,"0");this.createLoadProjectButtonArray.push(a);this.own(m(a,"click",d.hitch(this,function(){this._createButtonClicked(e);this.projectNameTextBox.isValid()||x.focus(this.projectNameTextBox);e.isValid()||x.focus(e)})));this.own(m(a,"keydown",d.hitch(this,function(f){if(f.keyCode===
u.ENTER||f.keyCode===u.SPACE)A.stop(f),this._createButtonClicked(e),this.projectNameTextBox.isValid()||x.focus(this.projectNameTextBox),e.isValid()||x.focus(e)})));return this.createProjectContainer},_createButtonClicked:function(a){a.isValid()||(a.set("state","Error"),a.set("message",a.getErrorMessage()));this.projectNameTextBox.isValid()&&a.isValid()&&(this.loadingIndicator.show(),this._validateForDuplicateProjectName(w.sanitizeHTML(this.projectNameTextBox.get("value"))).then(d.hitch(this,function(b){b?
(this.loadingIndicator.hide(),this.projectNameTextBox.set("state","Error"),this._showMessage(this.nls.createLoadProject.errorDuplicateProjectName)):this._addProjectToLayer(w.sanitizeHTML(this.projectNameTextBox.get("value")),w.sanitizeHTML(a.get("value"))).then(d.hitch(this,function(c){this.loadingIndicator.hide();if(c&&c.success&&c.globalId){var e={label:w.sanitizeHTML(this.projectNameTextBox.get("value")),value:c.globalId,descValue:w.sanitizeHTML(a.get("value")),globalIdValue:c.globalId,objectIdValue:c.objectId};
this.projectNameSelect.addOption(e);this.emit("createProject",{name:w.sanitizeHTML(this.projectNameTextBox.get("value")),desc:w.sanitizeHTML(a.get("value")),projectId:c.globalId,objectId:c.objectId,projectIdField:this.projectLayer.globalIdField});this.projectNameTextBox.set("value"," ");a.set("value","")}else this._showMessage(this.nls.createLoadProject.errorInCreatingProject)}),d.hitch(this,function(){this.loadingIndicator.hide();this._showMessage(this.nls.createLoadProject.errorInCreatingProject)}))}),
d.hitch(this,function(){this.loadingIndicator.hide();this._showMessage(this.nls.createLoadProject.errorInCreatingProject)})))},_getFieldInfo:function(a){if(this.projectLayer&&this.projectLayer.getField(a)){a=this.projectLayer.getField(a);var b=a.length;var c=!a.nullable}return{fieldLength:b,nullable:c}},_createButton:function(a,b,c){return p.create("div",{"class":"jimu-btn esriCTEllipsis",innerHTML:a,title:a,role:"button",tabindex:c,"aria-label":a},b)},_loadProjectUI:function(){var a=p.create("div",
{"class":"esriCTLoadProjectWrapper"},this.loadProjectContainer);var b=p.create("div",{"class":"esriCTFullwidth esriCTCreateProjectContent"},a);a=p.create("div",{"class":"esriCTFullwidth esriCTCreateLoadButtonWrap"},a);this.projectNameSelect=new O({"aria-label":this.nls.createLoadProject.selectProject,"class":"esriCTFullwidth",options:this.projectNameOptions},p.create("div",{},b));this.projectNameSelect.startup();b=this._createButton(this.nls.createLoadProject.viewInMapLabel,a,"-1");this.own(m(b,"click",
d.hitch(this,function(){this.getProjectAssets("ViewProject")})));this.own(m(b,"keydown",d.hitch(this,function(c){if(c.keyCode===u.ENTER||c.keyCode===u.SPACE)A.stop(c),this.getProjectAssets("ViewProject")})));this.createLoadProjectButtonArray.push(b);b=this._createButton(this.nls.common.deleteText,a,"-1");this.createLoadProjectButtonArray.push(b);this.own(m(b,"click",d.hitch(this,this._deleteBtnClicked)));this.own(m(b,"keydown",d.hitch(this,function(c){if(c.keyCode===u.ENTER||c.keyCode===u.SPACE)A.stop(c),
this._deleteBtnClicked()})));a=this._createButton(this.nls.createLoadProject.loadLabel,a,"-1");this.createLoadProjectButtonArray.push(a);this.own(m(a,"click",d.hitch(this,function(){this.getProjectAssets("LoadProject")})));this.own(m(a,"keydown",d.hitch(this,function(c){if(c.keyCode===u.ENTER||c.keyCode===u.SPACE)A.stop(c),this.getProjectAssets("LoadProject")})));return this.loadProjectContainer},_deleteBtnClicked:function(){var a,b;(b=this.projectNameSelect._getSelectedOptionsAttr())&&b.value?a=
new H({message:this.nls.createLoadProject.deleteProjectConfirmationMsg,type:"question",maxWidth:375,buttons:[{label:this.nls.common.yes,onClick:d.hitch(this,function(){a.close();this.getProjectAssets("DeleteProject")})},{label:this.nls.common.no,onClick:d.hitch(this,function(){a.close()})}]}):this._showMessage(this.nls.createLoadProject.errorProjectNotSelected)},_checkIfProjectExist:function(a){var b=new t;var c=new v(this.projectLayer.url);var e=new r;e.outFields=[this.projectLayer.objectIdField,
this.projectLayer.globalIdField];e.returnGeometry=!1;e.where=this.projectLayer.globalIdField+" \x3d '"+a+"'";c.execute(e,d.hitch(this,function(f){f&&f.features&&0<f.features.length?b.resolve(!0):b.resolve(!1)}),d.hitch(this,function(){b.resolve(!1)}));return b.promise},getProjectAssets:function(a){var b,c,e,f,g;(g=this.projectNameSelect._getSelectedOptionsAttr())&&g.value?(this.loadingIndicator.show(),this._checkIfProjectExist(g.globalIdValue).then(d.hitch(this,function(h){h?(e=this.layerInfosObj.getTableInfoById(this.config.projectSettings.assetTable).layerObject,
f=new y(e.url),c=new v(f.url),b=new r,b.outFields=["*"],b.returnGeometry=!1,b.where=this.config.assetTableFields.PROJECTGUID+" \x3d '"+g.globalIdValue+"'",c.execute(b,d.hitch(this,function(k){this.loadingIndicator.hide();"ViewProject"===a?this._showProjectOnMap(g,k.features):"DeleteProject"===a?this._deleteProject(g,k.features):this._createAssetTemplateInfo(g,k.features)}),d.hitch(this,function(){this._showMessage(this.nls.createLoadProject.errorInLoadingProject);this.loadingIndicator.hide()}))):
(this.projectNameSelect.removeOption(g.globalIdValue),this._showMessage(this.nls.createLoadProject.errorProjectNotFound),this.emit("showCreateLoadPrjPanel"),this.loadingIndicator.hide())}),d.hitch(this,function(){this._showMessage(this.nls.createLoadProject.errorInLoadingProject);this.emit("showCreateLoadPrjPanel");this.loadingIndicator.hide()}))):this._showMessage(this.nls.createLoadProject.errorProjectNotSelected)},_createAssetTemplateInfo:function(a,b){var c=[];this.loadingIndicator.show();l.forEach(b,
d.hitch(this,function(e){(e=e.attributes[this.config.assetTableFields.GEOGRAPHYGUID])&&c.push(e)}));this._getRegionName(c).then(d.hitch(this,function(e){this.loadingIndicator.hide();var f=[];var g={};l.forEach(b,d.hitch(this,function(h){var k={};var n=h.attributes[this.config.assetTableFields.ASSETGUID];var D=h.attributes[this.config.assetTableFields.GEOGRAPHYGUID];f.push(n);k.COSTEQUATION=h.attributes[this.config.assetTableFields.COSTEQUATION];k.SCENARIO=h.attributes[this.config.assetTableFields.SCENARIO];
k.TEMPLATENAME=h.attributes[this.config.assetTableFields.TEMPLATENAME];k.GEOGRAPHYGUID=D;k.GEOGRAPHY=D?e[D]:null;k.OBJECTID=h.attributes[this.config.assetTableFields.OBJECTID];g[n]=k}));this._loadProject(a,f,g)}),d.hitch(this,function(){this.loadingIndicator.hide()}))},_getAssetRequestToLayer:function(a,b){var c=b.layerObject.id;var e=b.layerObject;e.clearSelection();var f=new t;b=new v(e.url);var g=new r;g.outFields=["*"];g.returnGeometry=!0;g.outSpatialReference=this.map.spatialReference;g.where=
e.globalIdField+" in ('"+a.join("','")+"')";b.execute(g,d.hitch(this,function(h){h&&h.features&&0<h.features.length?f.resolve({layerId:c,features:h.features}):f.resolve({layerId:c,features:[]})}),d.hitch(this,function(){f.resolve({layerId:c,features:[]})}));return f.promise},_getProjectAdditionalCost:function(a){var b;var c=new t;if(b=this.config.projectSettings.multiplierAdditionalCostTable){b=this.layerInfosObj.getTableInfoById(b).layerObject.url;var e=new v(b);b=new r;b.outFields=["*"];b.returnGeometry=
!1;b.where=this.config.projectMultiplierFields.PROJECTGUID+" \x3d '"+a+"'";e.execute(b,d.hitch(this,function(f){var g=[];f&&f.features&&(g=f.features);c.resolve(g)}),d.hitch(this,function(){c.resolve([])}))}else c.resolve([]);return c.promise},_getRegionName:function(a){var b=new t;if(this.config.projectSettings.costingGeometryLayer&&this.config.projectSettings.geographyField&&0<a.length){var c=this.layerInfosObj.getLayerInfoById(this.config.projectSettings.costingGeometryLayer).layerObject;var e=
new v(c.url);var f=new r;f.outFields=[this.config.projectSettings.geographyField,c.globalIdField];f.returnDistinctValues=!0;f.returnGeometry=!1;f.where=c.globalIdField+" in ('"+a.join("','")+"')";e.execute(f,d.hitch(this,function(g){var h={};g&&g.features&&l.forEach(g.features,d.hitch(this,function(k){h[k.attributes[c.globalIdField]]=k.attributes[this.config.projectSettings.geographyField]}));b.resolve(h)}),d.hitch(this,function(){b.resolve([])}))}else b.resolve([]);return b.promise},_selectFeaturesOnMap:function(a,
b){var c=this.layerInfosObj.getLayerInfoById(b).layerObject;var e=new t;b=new r;b.where=c.globalIdField+" in ('"+a.join("','")+"')";c.selectFeatures(b,y.SELECTION_NEW,d.hitch(this,function(f){f&&0<f.length?e.resolve(f):e.resolve([])}),d.hitch(this,function(){e.resolve([])}));return e.promise},_showProjectOnMap:function(a,b){var c=[],e=[];l.forEach(b,d.hitch(this,function(f){c.push(f.attributes[this.config.assetTableFields.ASSETGUID])}));0===c.length?this._showMessage(this.nls.createLoadProject.noAssetsToViewOnMap):
(this.loadingIndicator.show(),this._selectFeaturesOnMap([a.globalIdValue],this.config.projectSettings.projectLayer).then(d.hitch(this,function(f){var g=!1;0<f.length&&f[0].geometry&&(g=!0,this.map.setExtent(G.graphicsExtent(f).expand(1.5)));l.forEach(this.config.layerSettings,d.hitch(this,function(h){h.editable&&e.push(this._selectFeaturesOnMap(c,h.id))}));B(e).then(d.hitch(this,function(h){var k=[];this.loadingIndicator.hide();g||(l.forEach(h,d.hitch(this,function(n){k=k.concat(n)})),0<k.length?
this.map.setExtent(G.graphicsExtent(k).expand(1.5)):this._showMessage(this.nls.createLoadProject.noAssetsToViewOnMap))}))}),d.hitch(this,function(){this.loadingIndicator.hide();this._showMessage(this.nls.createLoadProject.errorInLoadingProject)})))},_deleteFromTable:function(a,b,c){if(a=this.layerInfosObj.getTableInfoById(a))a=a.layerObject;b=b+" \x3d '"+c+"'";a?b=this.appUtils.deleteFeatures(a.url,b):(b=new t,b.resolve(!1),b=b.promise);return b},_deleteProject:function(a,b){this.loadingIndicator.show();
this._getRelatedLabelPoint(a.globalIdValue,a,b)},_deleteDetailsRelatedToProject:function(a,b,c){var e=[],f=[];this.emit("deleteProject");this.loadingIndicator.show();l.forEach(c,d.hitch(this,function(g){e.push(g.attributes[this.config.assetTableFields.ASSETGUID])}));0<e.length&&l.forEach(this.config.layerSettings,d.hitch(this,function(g){if(g.editable){g=this.layerInfosObj.getLayerInfoById(g.id).layerObject;var h=g.globalIdField+" in ('"+e.join("','")+"')";f.push(this.appUtils.deleteFeatures(g.url,
h))}}));f.push(this._deleteFromTable(this.config.projectSettings.assetTable,this.config.assetTableFields.PROJECTGUID,a));f.push(this._deleteFromTable(this.config.projectSettings.multiplierAdditionalCostTable,this.config.projectMultiplierFields.PROJECTGUID,a));f.push(this.appUtils.deleteFeatures(this.projectLayer.url,this.projectLayer.globalIdField+" \x3d '"+b.globalIdValue+"'"));B(f).then(d.hitch(this,function(){this.loadingIndicator.hide();this.projectNameSelect.removeOption(a);this._showMessage(this.nls.createLoadProject.projectDeletedMsg);
this.projectLayer.clearSelection();this.projectLayer.refresh();l.forEach(this.config.layerSettings,d.hitch(this,function(g){g.editable&&(g=this.layerInfosObj.getLayerInfoById(g.id).layerObject,g.clearSelection(),g.refresh())}))}))},_loadProject:function(a,b,c){var e=[];this.loadingIndicator.show();if(0<b.length)l.forEach(this.config.layerSettings,d.hitch(this,function(g){var h=this.layerInfosObj.getLayerInfoById(g.id);h&&h.layerObject&&g.editable&&e.push(this._getAssetRequestToLayer(b,h))}));else{var f=
new t;e.push(f.promise);f.resolve(null)}B(e).then(d.hitch(this,function(g){var h={};var k={name:a.label,desc:a.descValue,projectId:a.globalIdValue,objectId:a.objectIdValue};this.selectedProjectFeatureAttr=a.prjAttributes;l.forEach(g,d.hitch(this,function(n){n&&(h[n.layerId]=n.features)}));this._getProjectAdditionalCost(a.globalIdValue).then(d.hitch(this,function(n){this.loadingIndicator.hide();this.emit("loadProject",{assetTemplateInfo:c,assetInfo:h,projectInfo:k,additionalCostInfo:n,projectIdField:this.projectLayer.globalIdField})}),
d.hitch(this,function(){this.loadingIndicator.hide()}))}),d.hitch(this,function(){this.loadingIndicator.hide()}))},_createAndLoadProjectPanes:function(){this.paneListData&&0<this.paneListData.length&&(this._createOrLoadPrj=new N({itemList:this.paneListData,openMultiple:!1,highlighterColor:this.config.selectedThemeColor},p.create("div",{},this.createLoadProjectContainer)),this.own(m(this._createOrLoadPrj,"refreshUpdateCostEquationWidget",d.hitch(this,function(){this._destroyUpdateCostEquationWidget();
this._getProjectNamesOptions()}))),this.own(m(this._createOrLoadPrj,"resetLoadProjectNameDropdown",d.hitch(this,function(){this.projectNameSelect.set("value","defaultSelectProjectNameOption")}))),this.own(m(this._createOrLoadPrj,"OnOpenCreatePanel",d.hitch(this,function(){var a=q(".esriCTCreateProjectContent",this.domNode);a&&a.length&&(this._updateTabindexOfInputDOM(a[0],"0"),this._updateTabindexOfInputDOM(a[1],"0"),this._updateTabindexOfDOM(this.createLoadProjectButtonArray[0],"0"),x.focus(a[0].domNode))}))),
this.own(m(this._createOrLoadPrj,"OnCloseCreatePanel",d.hitch(this,function(){var a=q(".esriCTCreateProjectContent",this.domNode);a&&a.length&&(this._updateTabindexOfInputDOM(a[0],"-1"),this._updateTabindexOfInputDOM(a[1],"-1"),this._updateTabindexOfDOM(this.createLoadProjectButtonArray[0],"-1"))}))),this.own(m(this._createOrLoadPrj,"OnOpenLoadPanel",d.hitch(this,function(){var a=q(".esriCTCreateProjectContent",this.domNode);a&&a.length&&(this._updateTabindexOfDOM(a[2].children[0],"0"),this._updateTabindexOfDOM(this.createLoadProjectButtonArray[1],
"0"),this._updateTabindexOfDOM(this.createLoadProjectButtonArray[2],"0"),this._updateTabindexOfDOM(this.createLoadProjectButtonArray[3],"0"),this.config.updateCostEquationCheckBoxStatus||this.updateLastFocusNode(this.createLoadProjectButtonArray[3],this.widgetDomNode),x.focus(a[2].children[0]))}))),this.own(m(this._createOrLoadPrj,"OnCloseLoadPanel",d.hitch(this,function(){var a;(a=q(".esriCTCreateProjectContent",this.domNode))&&a.length&&(this._updateTabindexOfDOM(a[2].children[0],"-1"),this._updateTabindexOfDOM(this.createLoadProjectButtonArray[1],
"-1"),this._updateTabindexOfDOM(this.createLoadProjectButtonArray[2],"-1"),this._updateTabindexOfDOM(this.createLoadProjectButtonArray[3],"-1"),this._getLastTitleContainerNode())}))),this._createOrLoadPrj.startup())},_getLastTitleContainerNode:function(){var a;var b=q(".esriCTItemTitleContainer",this.domNode);(a=b.length)&&this.updateLastFocusNode(b[a-1],this.widgetDomNode)},_getUpdateCostEquationProjectNameDOM:function(a,b){q(".esriCTProjectNameCheckBox",this.domNode).forEach(d.hitch(this,function(c,
e){z.set(c,"tabindex",a);b&&void 0===e&&this.updateLastFocusNode(c,this.widgetDomNode)}))},_updateTabindexOfDOM:function(a,b){z.set(a,"tabindex",b)},_updateTabindexOfInputDOM:function(a,b){q(".dijitInputInner",a).forEach(d.hitch(this,function(c){this._updateTabindexOfDOM(c,b)}))},_getProjectNamesOptions:function(){this.loadingIndicator.show();var a=new v(this.projectLayer.url);var b=new r;b.outFields=["*"];b.returnGeometry=!1;b.where="1\x3d1";a.execute(b,d.hitch(this,function(c){var e=[];c&&c.features&&
(e=c.features);this._populateProjectNameOptions(e);setTimeout(d.hitch(this,function(){this._displayUpdateCostEquationWidget()}),10)}),d.hitch(this,function(){this.loadingIndicator.hide()}))},_populateProjectNameOptions:function(a){this.projectNameOptions=[{label:this.nls.createLoadProject.selectProject,value:""}];l.forEach(a,d.hitch(this,function(b){this.projectNameField&&b.attributes[this.projectNameField]&&""!==d.trim(b.attributes[this.projectNameField])&&this.projectNameOptions.push({label:b.attributes[this.projectNameField],
value:b.attributes[this.projectLayer.globalIdField],descValue:b.attributes[this.projectDescField],globalIdValue:b.attributes[this.projectLayer.globalIdField],objectIdValue:b.attributes[this.projectLayer.objectIdField],prjAttributes:b.attributes})}));this.projectNameSelect.set("options",d.clone(this.projectNameOptions));this.loadingIndicator.hide()},_validateProjectNameLocally:function(a){var b=[];this.projectNameSelect&&0<this.projectNameSelect.options.length&&(b=l.filter(this.projectNameSelect.options,
function(c){return c.label.toUpperCase()===a.toUpperCase()}));return 0<b.length?!1:!0},_validateForDuplicateProjectName:function(a){var b=new t;var c=new v(this.projectLayer.url);var e=new r;e.outFields=[this.projectLayer.objectIdField,this.projectLayer.globalIdField];e.returnGeometry=!1;e.where="UPPER("+this.projectNameField+") \x3d '"+a.toUpperCase()+"'";c.execute(e,d.hitch(this,function(f){f&&f.features&&0<f.features.length?b.resolve(!0):b.resolve(!1)}),d.hitch(this,function(){b.resolve(!1)}));
return b.promise},_addProjectToLayer:function(a,b){var c=new t;var e=new F;e.attributes=0<this.projectLayer.templates.length?this.projectLayer.templates[0].prototype.attributes:this.projectLayer.types[0].templates[0].prototype.attributes;e.attributes[this.projectNameField]=a;e.attributes[this.projectDescField]=b;this.projectLayer.applyEdits([e],null,null,d.hitch(this,function(f){this.selectedProjectFeatureAttr=e.attributes;c.resolve(f[0])}),function(f){c.reject(f)});return c.promise},_fetchWidgetTopNode:function(){if(this.domNode.parentNode)var a=
this.domNode.parentNode;if(a.parentNode)var b=a.parentNode;if(b.parentNode)var c=b.parentNode;c&&(this._widgetTopNode=c)},_instantiateUpdateProjectCostWidget:function(){this._updateProjectCostWidget=new P({nls:this.nls,projectNameOptions:this.projectNameOptions,widgetTopNode:this._widgetTopNode,layerInfosObj:this.layerInfosObj,config:this.config,map:this.map,loadingIndicator:this.loadingIndicator,widgetDomNode:this.widgetDomNode,updateLastFocusNode:this.updateLastFocusNode,setTabindexOfUpdateProjectCost:this._setTabindexOfUpdateProjectCost},
p.create("div",{},this.updateEquationContainer));this.own(m(this._updateProjectCostWidget,"updateProjectCostWidgetLoaded",d.hitch(this,function(){Q.contains(this.updateEquationContainer.parentNode,"esriCTItemContentActive")?this._setTabindexOfUpdateProjectCost(!0,this.domNode):this._setTabindexOfUpdateProjectCost(!1,this.domNode)})));this._updateProjectCostWidget.startup()},_setTabindexOfUpdateProjectCost:function(a,b){var c=q(".esriCTProjectNameCheckBox",b);c.forEach(d.hitch(this,function(e){a?(z.set(e,
"tabindex","0"),c.length-1&&this.updateLastFocusNode(e,b)):(z.set(e,"tabindex","-1"),this._setUpdateCostEquationLastFocusNode(b))}))},_setUpdateCostEquationLastFocusNode:function(a){var b=q(".esriCTItemTitleContainer",a);this.updateLastFocusNode(b[2],a)},_resetHeight:function(){var a=C.getComputedStyle(this._widgetTopNode).height;a=parseFloat(a);a-=28;var b=q(".esriCTItemTitleContainer",this._widgetTopNode);l.forEach(b,d.hitch(this,function(c){c=C.getComputedStyle(c).height;c=parseFloat(c);a-=c}));
a-=30;C.set(this.updateEquationContainer,"height",a+"px")},_destroyUpdateCostEquationWidget:function(){this._updateProjectCostWidget&&this._updateProjectCostWidget.destroy();this._updateProjectCostWidget=null},_displayUpdateCostEquationWidget:function(){this.config.hasOwnProperty("updateCostEquationCheckBoxStatus")&&this.config.updateCostEquationCheckBoxStatus&&(this._resetHeight(),this._instantiateUpdateProjectCostWidget())},_deleteExistingLabelPoint:function(a,b,c,e){if(a&&0<a.length){var f=this.map.getLayer(this.config.projectSettings.pointLayerCentroid),
g=new y(f.url,{outFields:["*"]});g.onLoad=d.hitch(this,function(){var h=[];l.forEach(a,d.hitch(this,function(k){var n={};n[g.objectIdField]=k;k=new F(null,null,n,null);h.push(k)}));g.applyEdits(null,null,h,d.hitch(this,function(){this.map.getLayer(this.config.projectSettings.pointLayerCentroid).refresh();this._deleteDetailsRelatedToProject(b,c,e)}),d.hitch(this,function(){this._deleteDetailsRelatedToProject(b,c,e)}))})}else this._deleteDetailsRelatedToProject(b,c,e)},_getRelatedLabelPoint:function(a,
b,c){if(""!==this.config.projectSettings.pointLayerCentroid&&null!==this.config.projectSettings.pointLayerCentroid&&void 0!==this.config.projectSettings.pointLayerCentroid){var e,f=this.map.getLayer(this.config.projectSettings.pointLayerCentroid),g=new y(f.url,{outFields:["*"]});g.onLoad=d.hitch(this,function(){e=this._getFieldName(g,"projectid")+" \x3d '"+a+"'";var h=new r;h.where=e;g.queryIds(h,d.hitch(this,function(k){this._deleteExistingLabelPoint(k,a,b,c)}),d.hitch(this,function(){this._deleteDetailsRelatedToProject(a,
b,c)}))})}else this._deleteDetailsRelatedToProject(a,b,c)},_getFieldName:function(a,b){var c;l.forEach(a.fields,d.hitch(this,function(e){e.name.toLowerCase()===b.toLowerCase()&&(c=e.name)}));return c}})});