text: // All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  // See http://js.arcgis.com/3.15/esri/copyright.txt and http://www.arcgis.com/apps/webappbuilder/copyright.txt for details.
  
  //>>built
  require({cache:{"url:widgets/ParcelDrafter/PlanInfo.html":'\x3cdiv class\x3d"esriCTFullWidth"\x3e\r\n    \x3c!-- Parcel Layer Attribute list Parent--\x3e\r\n    \x3cdiv class\x3d"esriCTFullWidth" data-dojo-attach-point\x3d"parcelLayerRowNode"\x3e\r\n        \x3c!-- Parcel layer attribute list toggle node --\x3e\r\n        \x3cdiv class\x3d"esriCTParcelLayerParent" data-dojo-attach-point\x3d"expandCollapseParentNode"\x3e\r\n            \x3cdiv class\x3d"esriCTParcelLayerContainer esriCTEllipsis" data-dojo-attach-point\x3d"attributeListTitle"\x3e\x3c/div\x3e\r\n            \x3cdiv class\x3d"esriCTExpandCollapseParceLayer" data-dojo-attach-point\x3d"expandCollapseNode" tabindex\x3d"0"\r\n                role\x3d"button" aria-label\x3d"${nls.planInfo.showAttributeList}" title\x3d"${nls.planInfo.showAttributeList}"\x3e\r\n            \x3c/div\x3e\r\n        \x3c/div\x3e\r\n        \x3c!-- Parcel Layer Attribute List Section--\x3e\r\n        \x3cdiv class\x3d"esriCTParcelAttributeList esriCTHidden" data-dojo-attach-point\x3d"attributeListNode"\x3e\r\n            \x3c!-- Attribute Inspector --\x3e\r\n            \x3cdiv class\x3d"esriCTAttributeInspectorContainer" data-dojo-attach-point\x3d"attributeInspectorContainer"\x3e\r\n            \x3c/div\x3e\r\n            \x3c!-- Parcel name input container --\x3e\r\n            \x3cdiv class\x3d"esriCTFullWidth esriCTPlanSettingRow esriCTHidden" data-dojo-attach-point\x3d"parcelNameRow"\x3e\r\n                \x3cdiv class\x3d"esriCTFullWidth" data-dojo-attach-point\x3d"parcelName"\x3e\r\n                \x3c/div\x3e\r\n            \x3c/div\x3e\r\n            \x3c!-- DocumentType input container --\x3e\r\n            \x3cdiv class\x3d"esriCTFullWidth esriCTPlanSettingRow esriCTHidden" data-dojo-attach-point\x3d"documentTypeRow"\x3e\r\n                \x3cdiv class\x3d"esriCTFullWidth" data-dojo-attach-point\x3d"documentType"\x3e\r\n                \x3c/div\x3e\r\n            \x3c/div\x3e\r\n            \x3c!-- Plan name input container --\x3e\r\n            \x3cdiv class\x3d"esriCTFullWidth esriCTPlanSettingRow esriCTHidden" data-dojo-attach-point\x3d"planNameRow"\x3e\r\n                \x3cdiv class\x3d"esriCTFullWidth" data-dojo-attach-point\x3d"planName"\x3e\r\n                \x3c/div\x3e\r\n            \x3c/div\x3e\r\n        \x3c/div\x3e\r\n        \x3c!-- Save/Cancle button container --\x3e\r\n        \x3cdiv class\x3d"esriCTPlanInfoNode"\x3e\r\n            \x3cdiv class\x3d"esriCTPlanInfoButton jimu-btn jimu-trailing-margin1" title\x3d"${nls.common.save}"\r\n                data-dojo-attach-point\x3d"planInfoSaveButton" tabindex\x3d"0" role\x3d"button" aria-label\x3d"${nls.common.save}"\x3e\r\n                ${nls.common.save}\r\n            \x3c/div\x3e\r\n            \x3cdiv class\x3d"esriCTPlanInfoButton jimu-btn jimu-trailing-margin1 esriCTHidden"\r\n                title\x3d"${nls.common.deleteText}" data-dojo-attach-point\x3d"planInfoDeleteButton" tabindex\x3d"0"\r\n                role\x3d"button" aria-label\x3d"${nls.common.deleteText}"\x3e\r\n                ${nls.common.deleteText}\r\n            \x3c/div\x3e\r\n            \x3cdiv class\x3d"esriCTPlanInfoButton jimu-btn" title\x3d"${nls.common.cancel}"\r\n                data-dojo-attach-point\x3d"planInfoCancelButton" tabindex\x3d"0" role\x3d"button"\r\n                aria-label\x3d"${nls.common.cancel}"\x3e\r\n                ${nls.common.cancel}\r\n            \x3c/div\x3e\r\n        \x3c/div\x3e\r\n    \x3c/div\x3e\r\n\x3c/div\x3e'}});
  define("dojo/_base/declare jimu/BaseWidget dijit/_WidgetsInTemplateMixin dojo/text!./PlanInfo.html dojo/_base/lang dojo/_base/array dojo/Evented dojo/dom-attr dojo/dom-construct dojo/dom-class dojo/dom-style dojo/query dijit/registry dijit/form/ValidationTextBox dojo/store/Memory dijit/form/ComboBox dojo/on esri/geometry/Polyline esri/graphic esri/tasks/query esri/tasks/QueryTask esri/dijit/AttributeInspector esri/layers/FeatureLayer jimu/dijit/Message ./geometryUtils jimu/utils jimu/LayerInfos/LayerInfos dojo/keys dojo/aspect".split(" "),
  function(w,E,F,G,e,l,H,n,x,q,y,z,v,I,J,K,p,L,t,A,M,N,B,O,P,u,Q,r,C){return w([E,F,H],{baseClass:"jimu-widget-ParcelDrafter-PlanInfo",templateString:G,_itemList:null,_polygonLayer:null,parcelNameTextBox:null,planNameTextBox:null,documentTypeControl:null,planSettings:null,_savedPolygonObjectId:null,_savedPolyLines:null,fieldInfosForPolygonLayer:null,constructor:function(a){e.mixin(this,a)},postCreate:function(){this.inherited(arguments);Q.getInstance(this.map,this.map.itemInfo).then(e.hitch(this,function(a){this._layerInfosObj=
  a;this._init()}))},_init:function(){if(0<this._getFieldInfosForPolygonLayer().length)if(this._addGraphicToLocalLayer(),this.config.polygonLayer.attributeListTitle){var a=u.sanitizeHTML(this.config.polygonLayer.attributeListTitle);n.set(this.attributeListTitle,"innerHTML",a)}else a=this._layerInfosObj.getLayerInfoById(this.config.polygonLayer.id),n.set(this.attributeListTitle,"innerHTML",a.layerObject.name);else q.add(this.expandCollapseParentNode,"esriCTHidden");q.add(this.domNode,"esriCTFullWidth");
  this.own(p(this.planInfoCancelButton,"click",e.hitch(this,function(){this.emit("cancelTraversedParcel")})));this.own(p(this.planInfoCancelButton,"keydown",e.hitch(this,function(b){b.keyCode!==r.ENTER&&b.keyCode!==r.SPACE||this.emit("cancelTraversedParcel")})));this.own(p(this.planInfoSaveButton,"click",e.hitch(this,function(){this.emit("saveTraversedParcel")})));this.own(p(this.planInfoSaveButton,"keydown",e.hitch(this,function(b){b.keyCode!==r.ENTER&&b.keyCode!==r.SPACE||this.emit("saveTraversedParcel")})));
  this.own(p(this.planInfoDeleteButton,"click",e.hitch(this,this.deleteParcel)));this.own(p(this.planInfoDeleteButton,"keydown",e.hitch(this,function(b){b.keyCode!==r.ENTER&&b.keyCode!==r.SPACE||this.deleteParcel()})));this.own(p(this.expandCollapseNode,"click",e.hitch(this,this._onExpandCollapseClicked)));this.own(p(this.expandCollapseNode,"keydown",e.hitch(this,function(b){if(b.keyCode===r.ENTER||b.keyCode===r.SPACE)b.preventDefault(),this._onExpandCollapseClicked()})))},_onExpandCollapseClicked:function(){q.toggle(this.expandCollapseNode,
  "esriCTCollapsedParceLayer");q.toggle(this.attributeListNode,"esriCTHidden");var a=this.nls.planInfo.showAttributeList;q.contains(this.expandCollapseNode,"esriCTCollapsedParceLayer")&&(a=this.nls.planInfo.hideAttributeList);n.set(this.expandCollapseNode,"aria-label",a);n.set(this.expandCollapseNode,"title",a)},resetValues:function(){q.contains(this.expandCollapseNode,"esriCTCollapsedParceLayer")&&this._onExpandCollapseClicked();this._addGraphicToLocalLayer();this.parcelNameTextBox&&this.parcelNameTextBox.set("value",
  "");this.planNameTextBox&&this.planNameTextBox.set("value","");this.documentTypeControl&&(this.config.polygonLayer.documentType.domain?this.documentTypeControl.set("item",null):this.documentTypeControl.set("value",""));q.add(this.planInfoDeleteButton,"esriCTHidden")},_showMessage:function(a){this.emit("showMessage",a)},_createDocumentTypeControl:function(){this.config.polygonLayer.documentType.domain?(this.documentTypeControl=this._createFieldSelect(this.config.polygonLayer.documentType,this.documentType,
  this.nls.planInfo.parcelDocumentTypeText,!this.config.polygonLayer.documentType.nullable),this.own(p(this.documentTypeControl,"change",e.hitch(this,function(a){""===a||null===a||void 0===a||this.documentTypeControl.store.data.some(function(b){return b.name===a})||(this.documentTypeControl.set("item",null),this._showMessage(this.nls.planInfo.enterValidDocumentTypeMessage))})))):this.documentTypeControl=this._createFieldInputs(this.config.polygonLayer.documentType,this.documentType,this.nls.planInfo.parcelDocumentTypeText,
  !this.config.polygonLayer.documentType.nullable)},_createFieldInputs:function(a,b,c,d){a.alias&&(c=a.alias);c=d?c+" "+this.nls.planInfo.requiredText:c+" "+this.nls.planInfo.optionalText;c=new I({placeHolder:c,"class":"esriCTFullWidth",required:d,"aria-label":c});0<=this.numberFieldTypes.indexOf(a.type)&&(c.validator=e.hitch(this,function(f){return""===f||this.validateNumericField(f,a.type)?!0:!1}));c.placeAt(b);return c},_createFieldSelect:function(a,b,c,d){var f=this._createDocTypeDataArr();f=new J({data:f});
  a&&a.alias&&(c=a.alias);c=d?c+" "+this.nls.planInfo.requiredText:c+" "+this.nls.planInfo.optionalText;this.selectBox=new K({placeHolder:c,"class":"esriCTFullWidth",required:d,store:f},b);n.set(this.selectBox.domNode,"aria-label",c);n.set(this.selectBox.domNode,"role","combobox");n.set(this.selectBox.domNode,"aria-expanded","false");C.after(this.selectBox,"loadAndOpenDropDown",e.hitch(this,function(){n.set(this.selectBox.domNode,"aria-expanded","true")}));C.after(this.selectBox,"closeDropDown",e.hitch(this,
  function(){n.set(this.selectBox.domNode,"aria-expanded","false")}));return this.selectBox},_createDocTypeDataArr:function(){var a=[];this.config.polygonLayer.documentType.domain.codedValues&&l.forEach(this.config.polygonLayer.documentType.domain.codedValues,e.hitch(this,function(b){a.push({name:b.name,id:b.code})}));return a},saveData:function(a){if(a.miscloseDetails&&(0===a.miscloseDetails.LengthConversions.meters||a.appliedCompassRule))this._saveParcel(a);else var b=new O({message:this.nls.planInfo.saveNonClosedParcelConfirmationMessage,
  type:"question",buttons:[{label:this.nls.common.yes,onClick:e.hitch(this,function(){b.close();this._saveParcel(a)})},{label:this.nls.common.no}]})},_saveParcel:function(a){this._itemList=a.itemList;this.planSettings=a.planSettings;0===a.polygonDeleteArr.length?this._createPolygonData(a):this._deletePolygonBeforeSaving(a)},_createParcelPolygon:function(){var a,b,c;var d=[];var f=this.parcelLinesGraphicsLayer.graphics;for(a=0;a<this._itemList.length;a++)if(this._itemList[a].LineSymbol.type===this.config.BoundaryLineType)for(b=
  0;b<this._itemList[a].graphic.geometry.paths.length;b++)d.push(this._itemList[a].graphic.geometry.paths[b]);0<d.length&&(c=P.getPolygonFromPolyLines(d,!1,!0,f[0].geometry.spatialReference))&&(this.parcelPolygonGraphicsLayer.clear(),a=new t(c),this.parcelPolygonGraphicsLayer.add(a),c=this.parcelPolygonGraphicsLayer.graphics[0].geometry);return c},_createPolygonData:function(a){this.loading.show();var b=[];var c={};var d=this.polygonLayerUnit;this.documentTypeControl&&(this.config.polygonLayer.documentType.domain?
  this.documentTypeControl.hasOwnProperty("item")&&this.documentTypeControl.item&&this.documentTypeControl.item.hasOwnProperty("id"):""!==this.documentTypeControl.get("value")&&this.documentTypeControl.get("value"));var f=!1;if(a.miscloseDetails&&(0===a.miscloseDetails.LengthConversions.meters||a.appliedCompassRule))var g=this._createParcelPolygon();else g={},f=!0;g?(f&&(g=null),this._currentFeatureDetails&&this._currentFeatureDetails.attributes&&(c=e.clone(this._currentFeatureDetails.attributes)),
  c[this.config.polygonLayer.rotation.name]=a.rotation,c[this.config.polygonLayer.scale.name]=a.scale,a.miscloseDetails&&(c[this.config.polygonLayer.miscloseRatio.name]=a.miscloseDetails.miscloseValue,c[this.config.polygonLayer.miscloseDistance.name]=this._getValueAccToFeatureLayerUnit(d,a.miscloseDetails,"LengthConversions")),this.config.polygonLayer.statedArea.hasOwnProperty("name")&&(c[this.config.polygonLayer.statedArea.name]=a.statedArea),a=new t(g,null,c),b.push(a),this._saveParcelPolygon(b)):
  this._showMessage(this.nls.planInfo.unableToCreatePolygonParcel)},setParcelInformation:function(a,b){var c=this.map.getLayer(this.config.polygonLayer.id).objectIdField;this._savedPolygonObjectId=a[0].attributes[c];var d=e.clone(a[0].attributes);d[c]=d[c]?d[c]:0;this._addGraphicToLocalLayer(d);this._savedPolyLines=b;q.remove(this.planInfoDeleteButton,"esriCTHidden");this.parcelNameTextBox&&this.parcelNameTextBox.set("value",a[0].attributes[this.config.polygonLayer.parcelName.name]);this.planNameTextBox&&
  this.planNameTextBox.set("value",a[0].attributes[this.config.polygonLayer.planName.name]);this.documentTypeControl&&(a=a[0].attributes[this.config.polygonLayer.documentType.name],null!==a&&""!==a&&void 0!==a&&(this.config.polygonLayer.documentType.domain?this.documentTypeControl.set("item",this.documentTypeControl.store.get(a)):this.documentTypeControl.set("value",a)))},_rollbackSavedPolygon:function(){var a;var b={attributes:{}};if((a=this.map.getLayer(this.config.polygonLayer.id))&&null!==this._savedPolygonObjectId){b.attributes[a.objectIdField]=
  this._savedPolygonObjectId;var c=a.applyEdits(null,null,[b])}return c},_rollbackSavedPolyLines:function(a){var b,c;var d=[];var f=this.map.getLayer(this.config.polylineLayer.id);l.forEach(a,e.hitch(this,function(g){b={attributes:{}};g.hasOwnProperty("objectId")?(b.attributes[f.objectIdField]=g.objectId,d.push(b)):g.attributes.hasOwnProperty(f.objectIdField)&&(b.attributes[f.objectIdField]=g.attributes[f.objectIdField],d.push(b))}));f&&0<d.length&&(c=f.applyEdits(null,null,d));return c},_deletePolygonBeforeSaving:function(a){(this._polygonLayer=
  this.map.getLayer(this.config.polygonLayer.id))?this._polygonLayer.applyEdits(null,null,a.polygonDeleteArr,e.hitch(this,function(){this._deleteLinesBeforeSaving(a)}),e.hitch(this,function(){this._showMessage(this.nls.planInfo.unableToSavePolygonParcel)})):this._showMessage(this.nls.planInfo.unableToSavePolygonParcel)},_deleteLinesBeforeSaving:function(a){var b;(b=this.map.getLayer(this.config.polylineLayer.id))?b.applyEdits(null,null,a.polylineDeleteArr,e.hitch(this,function(){this._createPolygonData(a)}),
  e.hitch(this,function(){this._showMessage(this.nls.planInfo.unableToUpdateParcelLines)})):this._showMessage(this.nls.planInfo.unableToUpdateParcelLines)},_saveParcelPolygon:function(a){(this._polygonLayer=this.map.getLayer(this.config.polygonLayer.id))?(this._savedPolygonObjectId=null,this._polygonLayer.applyEdits(a,null,null,e.hitch(this,function(b){b&&0<b.length&&b[0].success?(this._savedPolygonObjectId=b[0].objectId,this._polygonLayer.refresh(),b=new A,b.objectIds=[this._savedPolygonObjectId],
  b.returnGeometry=!1,b.outFields=[this.config.polygonLayer.relatedGUID.name],(new M(this._polygonLayer.url)).execute(b,e.hitch(this,function(c){this.loading.hide();this._createPolylineData(c.features[0].attributes[this.config.polygonLayer.relatedGUID.name])}),e.hitch(this,function(){this.loading.hide();this._showMessage(this.nls.planInfo.unableToSaveParcelLines)}))):(this.loading.hide(),this._showMessage(this.nls.planInfo.unableToSavePolygonParcel))}),e.hitch(this,function(){this.loading.hide();this._showMessage(this.nls.planInfo.unableToSavePolygonParcel)}))):
  (this.loading.hide(),this._showMessage(this.nls.planInfo.unableToSavePolygonParcel))},_getValueAccToFeatureLayerUnit:function(a,b,c){if(b.hasOwnProperty(c)&&b[c])switch(a){case "meters":case "degrees":return b[c].meters;case "feet":return b[c].feet;case "uSSurveyFeet":return b[c].uSSurveyFeet;default:return null}else return null},_getCurrentLineFeatures:function(){for(var a=[],b=0;b<this._itemList.length;b++)a.push(this._itemList[b].graphic);return a},_createPolylineData:function(a){this.loading.show();
  var b=this._getCurrentLineFeatures();var c=this.polylineLayerUnit;var d=this._itemList;var f=[];for(var g=0;g<b.length;g++){var k={};var h=d[g];k[this.config.polylineLayer.bearing.name]=h.BearingConversions.naDD;k[this.config.polylineLayer.distance.name]=this._getValueAccToFeatureLayerUnit(c,h,"LengthConversions");k[this.config.polylineLayer.lineType.name]=h.LineSymbol.type;k[this.config.polylineLayer.radius.name]=this._getValueAccToFeatureLayerUnit(c,h,"RadiusConversions");null!==k[this.config.polylineLayer.radius.name]&&
  ""!==k[this.config.polylineLayer.radius.name]&&void 0!==k[this.config.polylineLayer.radius.name]?(k[this.config.polylineLayer.arcLength.name]=this._getValueAccToFeatureLayerUnit(c,h,"ArcLengthConversions"),h=this._getValueAccToFeatureLayerUnit(c,h,"ChordLengthConversions"),k[this.config.polylineLayer.chordLength.name]=h,k[this.config.polylineLayer.distance.name]=h):(k[this.config.polylineLayer.arcLength.name]=null,k[this.config.polylineLayer.chordLength.name]=null);k[this.config.polylineLayer.relatedGUID.name]=
  a;k[this.config.polylineLayer.sequenceId.name]=g;h=b[g].geometry.toJson();h=new L(h);k=new t(h,null,k,null);f.push(k)}this._saveParcelLines(f)},_saveParcelLines:function(a){var b;(b=this.map.getLayer(this.config.polylineLayer.id))?b.applyEdits(a,null,null,e.hitch(this,function(c){var d=[],f=[];l.forEach(c,function(g){g.success?f.push(g):d.push(g)});0<d.length?(this._rollbackSavedPolygon(),0<f.length&&d.length!==a.length&&this._rollbackSavedPolyLines(f),this._showMessage(this.nls.planInfo.unableToSaveParcelLines)):
  (this._showParcelSavedAndDeleteMsg(this.nls.planInfo.parcelSavedSuccessMessage),this._savedPolygonObjectId=null,this.emit("displayMainPageAfterSave",!1));this.loading.hide()}),e.hitch(this,function(){this._rollbackSavedPolygon();this.loading.hide();this._showMessage(this.nls.planInfo.unableToSaveParcelLines)})):(this._rollbackSavedPolygon(),this.loading.hide(),this._showMessage(this.nls.planInfo.unableToSaveParcelLines))},_validateRequiredFields:function(){var a=[],b=this._currentFeatureDetails;if(!b)return a;
  var c=b.getLayer();c=l.filter(c.fields,e.hitch(this,function(d){return!1===d.nullable&&!0===d.editable}));l.forEach(c,e.hitch(this,function(d){if(b.attributes.hasOwnProperty(d.name))if("undefined"===b.attributes[d.name])a.push(d.name);else if(null===b.attributes[d.name])a.push(d.name);else switch(d.type){case "esriFieldTypeString":(""===b.attributes[d.name]||b.attributes[d.name]&&""===b.attributes[d.name].trim())&&a.push(d.name)}else a.push(d.name)}));return a},_validateAttributes:function(){var a=
  [],b;a=this._validateRequiredFields();var c=z("td.atiLabel",this._attributeInspector.domNode),d=[];this._clonedProjectPolygonLayerObject.globalIdField&&d.push(this._clonedProjectPolygonLayerObject.globalIdField);this._clonedProjectPolygonLayerObject.objectIdField&&d.push(this._clonedProjectPolygonLayerObject.objectIdField);c&&l.forEach(c,e.hitch(this,function(f){var g=n.get(f,"data-fieldname");-1===d.indexOf(g)&&(g=this._getAttrInspectorRowInfo(f))&&(0>a.indexOf(g[1])?g[0].isValid&&!g[0].isValid()?
  (a.push(g[1]),b||(b=g[0])):1<f.parentNode.childNodes[1].childNodes.length&&(f=f.parentNode.childNodes[1].childNodes[1],f=v.getEnclosingWidget(f),f.isValid&&!f.isValid()&&(a.push(g[1]),b||(b=f))):b||(b=g[0]))}));b&&(q.contains(this.expandCollapseNode,"esriCTCollapsedParceLayer")||this._onExpandCollapseClicked(),b.focus());return a},validateParcelDetails:function(a){var b={};if(this._attributeInspector){var c=this._validateAttributes();if(c&&0<c.length)return b.status=!1,b.message="",b}if(this.config.polygonLayer.statedArea&&
  this.config.polygonLayer.statedArea.hasOwnProperty("name")&&(!this.config.polygonLayer.statedArea.nullable&&(null===a||""===a)||null!==a&&""!==a&&-1<this.numberFieldTypes.indexOf(this.config.polygonLayer.statedArea.type)&&!this.validateNumericField(a,this.config.polygonLayer.statedArea.type)))return b.status=!1,b.message=this.nls.planInfo.enterValidStatedAreaNameMessage,b;b.status=!0;return b},deleteParcel:function(){this.loading.show();this._rollbackSavedPolygon().then(e.hitch(this,function(){this._rollbackSavedPolyLines(this._savedPolyLines).then(e.hitch(this,
  function(){this.loading.hide();this._showParcelSavedAndDeleteMsg(this.nls.planInfo.parcelDeletedSuccessMessage);this._savedPolygonObjectId=null;this.emit("displayMainPageAfterSave",!1)}),e.hitch(this,function(){this.loading.hide();this._savedPolygonObjectId=null;this._showParcelSavedAndDeleteMsg(this.nls.planInfo.parcelDeleteErrorMessage);this.emit("displayMainPageAfterSave",!1)}))}),e.hitch(this,function(){this.loading.hide();this._savedPolygonObjectId=null;this._showParcelSavedAndDeleteMsg(this.nls.planInfo.parcelDeleteErrorMessage);
  this.emit("displayMainPageAfterSave",!1)}))},setPlanInfoCancelBtnAsLastNode:function(){u.initLastFocusNode(this.widgetDomNode,this.planInfoCancelButton)},_showParcelSavedAndDeleteMsg:function(a){this.emit("showParcelSavedAndDeleteMsg",a)},mergeFirstToLast:function(){for(var a={},b=arguments.length-1,c;0<=b;b--)for(c in arguments[b])arguments[b].hasOwnProperty(c)&&(a[c]=arguments[b][c]);return a},_getFieldInfosFromLayer:function(a){var b=[];a&&a.layerObject&&l.forEach(a.layerObject.fields,function(c){var d=
  u.getDefaultPortalFieldInfo(c);d=this.mergeFirstToLast(d,c);d.format&&d.format.dateFormat&&d.format.dateFormat.toLowerCase()&&0<=d.format.dateFormat.toLowerCase().indexOf("time")&&(d.format.time=!0);d.visible=!0;b.push(d)},this);return b},_createFieldsDetailsObject:function(a){var b={};l.forEach(a,e.hitch(this,function(c){b[c.name]=c.type}));return b},getFieldInfoByFieldName:function(a,b){var c={};l.some(a,function(d){if(d.name===b)return e.mixin(c,d),!0});return c},_getFieldInfosForPolygonLayer:function(){if(this.fieldInfosForPolygonLayer)return this.fieldInfosForPolygonLayer;
  var a=[],b=[this.config.polygonLayer.rotation.name,this.config.polygonLayer.scale.name,this.config.polygonLayer.miscloseRatio.name,this.config.polygonLayer.miscloseDistance.name,this.config.polygonLayer.statedArea.name],c=this._layerInfosObj.getLayerInfoById(this.config.polygonLayer.id),d=this._createFieldsDetailsObject(c.layerObject.fields);var f=this._getFieldInfosFromLayer(c);if(this.config.hasOwnProperty("useFieldInfosFromWebmap")&&this.config.useFieldInfosFromWebmap&&c.controlPopupInfo&&c.controlPopupInfo.enablePopup&&
  c.controlPopupInfo.infoTemplate)f=e.clone(c.controlPopupInfo.infoTemplate.info.fieldInfos);else if(this.config.polygonLayer.hasOwnProperty("additionalFieldsInfo")&&0<this.config.polygonLayer.additionalFieldsInfo.length){var g=[];l.forEach(this.config.polygonLayer.additionalFieldsInfo,function(h){var m=this.getFieldInfoByFieldName(f,h.fieldName);m=e.mixin(m,h);!m.nullable&&m.editable&&(m.visible=!0,m.isEditable=!0);g.push(m)},this);f=g}else this.config.polygonLayer.documentType.hasOwnProperty("name")&&
  a.push(this.config.polygonLayer.documentType.name),this.config.polygonLayer.parcelName.hasOwnProperty("name")&&a.push(this.config.polygonLayer.parcelName.name),this.config.polygonLayer.planName.hasOwnProperty("name")&&a.push(this.config.polygonLayer.planName.name);var k=[];l.forEach(f,e.hitch(this,function(h){a&&0<a.length&&0>a.indexOf(h.fieldName)&&(h.visible=!1);-1<b.indexOf(h.fieldName)&&(h.visible=!1);h.visible&&d[h.fieldName]&&"esriFieldTypeRaster"!==d[h.fieldName]&&"esriFieldTypeBlob"!==d[h.fieldName]&&
  "esriFieldTypeXML"!==d[h.fieldName]&&(h.format&&h.format.dateFormat&&h.format.dateFormat.toLowerCase()&&0<=h.format.dateFormat.toLowerCase().indexOf("time")&&(h.format.time=!0),k.push(h))}));return this.fieldInfosForPolygonLayer=k},_clearAttributeInspectorData:function(){this._attributeInspector&&(this._attributeInspector.layerInfos&&l.forEach(this._attributeInspector.layerInfos,function(a){a=a.featureLayer;a.clearSelection();a.refresh()}),this._attributeInspector.destroy())},_add508SupportToATI:function(){var a;
  this._attributeInspector&&this._attributeInspector.domNode&&(a=z("td.atiLabel",this._attributeInspector.domNode))&&l.forEach(a,e.hitch(this,function(b){var c=this._getAttrInspectorRowInfo(b);c&&(c[0].set("aria-label",c[1]),1<b.parentNode.childNodes[1].childNodes.length&&(b=b.parentNode.childNodes[1].childNodes[1],b=v.getEnclosingWidget(b),b.set("aria-label",c[1])))}))},_getAttrInspectorRowInfo:function(a){try{if(a&&a.parentNode){var b=a.parentNode.childNodes[1].childNodes[0];return[v.getEnclosingWidget(b),
  a.childNodes[0].data,b]}return null}catch(c){return console.log(c),null}},_getCurrentFieldDijit:function(a){var b;l.some(this._attributeInspector._currentLInfo.fieldInfos,e.hitch(this,function(c){if(c.name===a||c.field&&c.field.name===a||c.fieldName===a)return b=c.dijit,!0}));return b},_addGraphicToLocalLayer:function(a){var b,c,d,f;if((f=this._getFieldInfosForPolygonLayer())&&0!=f.length){this._clearAttributeInspectorData();this._removeClonedProjectPolygonLayer();var g=this.map.getLayer(this.config.polygonLayer.id);
  this._clonedProjectPolygonLayerObject=this._cloneProjectPolygonLayer(g,f);var k=this.own(p(this._clonedProjectPolygonLayerObject,"load",e.hitch(this,function(){k&&k[0]&&k[0].remove();b=this._layerInfosObj.getLayerInfoById(this._clonedProjectPolygonLayerObject.originalLayerId);b.featureLayer=this._clonedProjectPolygonLayerObject;this._createAttributeInspector(f);c=new t(null,null,a?a:{},null);c.preEditAttrs=JSON.parse(JSON.stringify(c.attributes));this._clonedProjectPolygonLayerObject.applyEdits([c],
  null,null,e.hitch(this,function(h){d=new A;d.objectIds=[h[0].objectId];this._clonedProjectPolygonLayerObject.selectFeatures(d,B.SELECTION_NEW,e.hitch(this,function(){var m=this._attributeInspector.attributeTable.childNodes[0];n.set(m,"cellspacing","5");n.set(m,"cellpadding","5");this._currentFeatureDetails=c;this._add508SupportToATI();this._attributeInspector.attachmentEditor&&y.set(this._attributeInspector.attachmentEditor,"display","none");this._attributeInspector.editorTrackingInfoDiv&&y.set(this._attributeInspector.editorTrackingInfoDiv,
  "display","none");if(m=this._clonedProjectPolygonLayerObject.objectIdField){var D=this._getCurrentFieldDijit(m);D&&c.preEditAttrs[m]&&D.set("value",c.preEditAttrs[m])}}),e.hitch(this,function(){}))}),e.hitch(this,function(){}))}),e.hitch(this,function(){})))}},_removeClonedProjectPolygonLayer:function(){this._clonedProjectPolygonLayerObject&&null!==this._clonedProjectPolygonLayerObject&&(this._clonedProjectPolygonLayerObject.clearSelection(),this._clonedProjectPolygonLayerObject.clear(),this.map.removeLayer(this._clonedProjectPolygonLayerObject),
  this._clonedProjectPolygonLayerObject=null)},_filterFields:function(a,b){var c=[];l.forEach(b,e.hitch(this,function(d){d.visible&&l.forEach(a.fields,e.hitch(this,function(f){f.hasOwnProperty("name")&&d.hasOwnProperty("fieldName")&&f.name===d.fieldName&&c.push(f)}))}));a.fields=c},_cloneProjectPolygonLayer:function(a,b){var c=u.getFeatureLayerDefinition(a);this._filterFields(c,b);c.id="clonedPolygonLayer"+this.id;c.name=a.name+this.id;b={layerDefinition:c};c=a.fields.map(function(d){return d.name});
  b=new B(b,{outFields:c});b.visible=!0;b.renderer=a.renderer;b.originalLayerId=a.id;b._wabProperties={isTemporaryLayer:!0};this.map.addLayer(b);return b},_processLayerFields:function(a){l.forEach(a,function(b){void 0!==b.domain&&null!==b.domain&&void 0!==b.domain.type&&null!==b.domain.type&&"range"===b.domain.type&&!1===b.domain.hasOwnProperty("range")&&(b.domain.range=[b.domain.minValue,b.domain.maxValue])});return a},_createAttributeInspector:function(a){x.empty(this.attributeInspectorContainer);
  this._attributeInspector=new (w([N],{constructor:function(){this._aiConnects=[];this._selection=[];this._toolTips=[]}}))({layerInfos:[{featureLayer:this._clonedProjectPolygonLayerObject,fieldInfos:a}]},x.create("div",{"class":"esriCTAttributeInspectorWidgetContainer"}));this.own(p(this._attributeInspector,"attribute-change",e.hitch(this,function(b){this._currentFeatureDetails&&(this._currentFeatureDetails.attributes[b.fieldName]=b.fieldValue)})));this._attributeInspector.startup();this.attributeInspectorContainer.appendChild(this._attributeInspector.domNode)}})});