// 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
define("dojo/_base/declare dojo/_base/lang dojo/_base/array esri/geometry/Extent jimu/utils esri/dijit/AttributeInspector".split(" "),function(t,p,h,u,r,v){var g={};g.ATI=t([v],{constructor:function(){this._aiConnects=[];this._selection=[];this._toolTips=[]}});g.checkIfFieldAliasAlreadyExists=function(a,c){return 0<=a.split(",").indexOf(c)};g.pointToExtent=function(a,c,b){var d=a.extent.getWidth()/a.width;b*=d;return new u(c.x-b,c.y-b,c.x+b,c.y+b,a.spatialReference)};g.filterOnlyUpdatedAttributes=
function(a,c,b){if(null===c||void 0===c)return a;var d={},e;for(e in a)a.hasOwnProperty(e)&&(e===b.objectIdField||e===b.globalIdField?d[e]=a[e]:(null!==a[e]||""!==c[e])&&a[e]!==c[e]&&(d[e]=a[e]));return d};g.mergeFieldInfosWithConfiguration=function(a,c){var b=[],d=this.getDefaultEditableFieldInfos(a,!1);c&&c.fieldInfos?(h.forEach(c.fieldInfos,function(k){h.some(d,function(m){if(k.fieldName===m.fieldName)return b.push(this.mergeLastToFirst(m,k)),!0},this)},this),h.forEach(d,function(k){0===h.filter(b,
function(m){return m.fieldName===k.fieldName},this).length&&b.push(k)},this)):b=d;var e=[];a.layerObject.hasOwnProperty("globalIdField")&&void 0!==a.layerObject.globalIdField&&null!==a.layerObject.globalIdField&&e.push(a.layerObject.globalIdField);a.layerObject.hasOwnProperty("objectIdField")&&void 0!==a.layerObject.objectIdField&&null!==a.layerObject.objectIdField&&e.push(a.layerObject.objectIdField);if(a.layerObject.hasOwnProperty("editFieldsInfo")&&void 0!==a.layerObject.editFieldsInfo&&null!==
a.layerObject.editFieldsInfo)for(var f in a.layerObject.editFieldsInfo)a.layerObject.editFieldsInfo.hasOwnProperty(f)&&e.push(a.layerObject.editFieldsInfo[f]);return b=b.filter(function(k){return-1!==h.indexOf(e,k.fieldName)?!1:k.isEditableOnLayer})};g.getDefaultEditableFieldInfos=function(a,c){var b=[],d=this.getFieldInfosFromWebmap(a);a=this.getFieldInfosLayer(a);if(void 0===d||null===d)d=a;else{var e=[];h.forEach(a,function(f){0===h.filter(d,function(k){return k.name===f.fieldName}).length&&(f.isEditableOnLayer=
f.editable,e.push(f))});0<e.length&&(d=d.concat(e))}h.forEach(d,function(f){!1===f.hasOwnProperty("isEditableOnLayer")&&(f.isEditableOnLayer=f.editable);!1===f.editable&&(f.isEditable=f.editable);!1===f.isEditable&&(f.editable=f.isEditable);!0===f.editable&&(f.visible=!0);f.fieldName=f.name;!0===f.editable&&!0===c?b.push(p.clone(f)):!1===c&&b.push(p.clone(f))});return b};g.updatePopupDateFormat=function(a){var c={shortDate:{datePattern:"M/d/y"},shortDateLE:{datePattern:"d/M/y"},longMonthDayYear:{datePattern:"MMMM d, y"},
dayShortMonthYear:{datePattern:"d MMM y"},longDate:{datePattern:"EEEE, MMMM d, y",selector:"date"},shortDateShortTime:{datePattern:"M/d/y",timePattern:"h:mm a",timeEnabled:!0},shortDateLEShortTime:{datePattern:"d/M/y",timePattern:"h:mm a",timeEnabled:!0},shortDateShortTime24:{datePattern:"M/d/y",timePattern:"H:mm",timeEnabled:!0},shortDateLEShortTime24:{datePattern:"d/M/y",timePattern:"H:mm",timeEnabled:!0},shortDateLongTime:{datePattern:"M/d/y",timePattern:"h:mm:ss a",timeEnabled:!0},shortDateLELongTime:{datePattern:"d/M/y",
timePattern:"h:mm:ss a",timeEnabled:!0},shortDateLongTime24:{datePattern:"M/d/y",timePattern:"H:mm:ss",timeEnabled:!0},shortDateLELongTime24:{datePattern:"d/M/y",timePattern:"H:mm:ss",timeEnabled:!0},longMonthYear:{datePattern:"MMMM y"},shortMonthYear:{datePattern:"MMM y"},year:{datePattern:"y"}},b="",d;for(d in c)if(r.isEqual(a,c[d])){b=d;break}return b};g.getFieldInfosFromWebmap=function(a){var c=null,b=a.getPopupInfo();b&&b.fieldInfos&&(c=[],h.forEach(b.fieldInfos,function(d){h.some(a.layerObject.fields,
function(e){if(e.name===d.fieldName)return e=this.mergeFirstToLast(d,e),e.format&&e.format.dateFormat&&(e.format.dateFormat.hasOwnProperty("datePattern")||e.format.dateFormat.hasOwnProperty("timePattern"))&&(e.format.dateFormat=this.updatePopupDateFormat(e.format.dateFormat)),e.format&&e.format.dateFormat&&e.format.dateFormat.toLowerCase()&&0<=e.format.dateFormat.toLowerCase().indexOf("time")&&(e.format.time=!0),c.push(e),!0},this)},this));return c};g.getFieldInfosLayer=function(a){var c=[];a&&a.layerObject&&
h.forEach(a.layerObject.fields,function(b){var d=r.getDefaultPortalFieldInfo(b);d=this.mergeFirstToLast(d,b);d.format&&d.format.dateFormat&&(d.format.dateFormat.hasOwnProperty("datePattern")||d.format.dateFormat.hasOwnProperty("timePattern"))&&(d.format.dateFormat=this.updatePopupDateFormat(d.format.dateFormat));d.format&&d.format.dateFormat&&d.format.dateFormat.toLowerCase()&&0<=d.format.dateFormat.toLowerCase().indexOf("time")&&(d.format.time=!0);d.visible=!0;c.push(d)},this);return c};g.getConfigInfos=
function(a,c,b,d,e){var f=[],k=a.getLayerInfoArrayOfWebmap(),m=[];e&&(m=a.getTableInfoArrayOfWebmap(),k=k.concat(m));h.forEach(k,function(n){var q=!1;"Table"!==n.layerObject.type&&"Feature Layer"!==n.layerObject.type||!n.layerObject.url||(n.layerObject.isEditable&&n.layerObject.isEditable()&&b?q=!0:void 0!==b&&!1===b&&(q=!0));if(!0===q){var l=this.getConfigInfo(n,c);l.layerInfo=n;!0===l.featureLayer.layerAllowsDelete&&!1===l.featureLayer.layerAllowsCreate&&!1===l.featureLayer.layerAllowsUpdate?console.warn(l.layerInfo.title+
" delete only not supported"):d&&!0===d?!0===h.some(c,function(w){return w.featureLayer.id===l.featureLayer.id})&&f.push(l):f.push(l)}},this);return f};g.getConfigInfo=function(a,c){var b=null,d=this.createDefaultConfigInfo(a);!1===h.some(c,function(e){return e.featureLayer&&e.featureLayer.id===a.layerObject.id?(b=p.clone(e),b.fieldInfos=this.mergeFieldInfosWithConfiguration(a,b),b=this.mergeDefaultWithConfig(b,d),!0):!1},this)&&(b=d);return b};g.mergeDefaultWithConfig=function(a,c){a.featureLayer=
c.featureLayer;!0===a.allowDelete&&!1===a.featureLayer.layerAllowsDelete&&(a.allowDelete=!1);!1===a.disableGeometryUpdate&&!1===a.featureLayer.layerAllowGeometryUpdates&&(a.disableGeometryUpdate=!0);!1===a.featureLayer.layerAllowsCreate&&!0===a.featureLayer.layerAllowsUpdate&&(a.allowUpdateOnly=!0);return a};g.createDefaultConfigInfo=function(a){var c=!1,b=!1,d=!1,e=!1;try{var f=a.layerObject.getEditCapabilities();f.canCreate&&(c=!0);f.canUpdate&&(e=b=!0);f.canDelete&&(d=!0)}catch(k){a.layerObject.hasOwnProperty("capabilities")&&
(-1===String(a.layerObject.capabilities).indexOf("Update")&&-1===String(a.layerObject.capabilities).indexOf("Delete")&&-1===String(a.layerObject.capabilities).indexOf("Create")&&-1!==String(a.layerObject.capabilities).indexOf("Editing")?c=d=b=!0:(-1!==String(a.layerObject.capabilities).indexOf("Update")&&(e=b=!0),-1!==String(a.layerObject.capabilities).indexOf("Delete")&&(d=!0),-1!==String(a.layerObject.capabilities).indexOf("Create")&&(c=!0)))}a.layerObject.hasOwnProperty("allowGeometryUpdates")&&
(e=a.layerObject.allowGeometryUpdates);"Table"===a.layerObject.type&&a.layerObject.url&&a.getCapabilitiesOfWebMap()&&(b=a.getCapabilitiesOfWebMap(),a.layerObject.isEditable&&a.layerObject.isEditable()&&b&&-1<b.toLowerCase().indexOf("editing")?b=!0:d=b=c=!1,e=!1);e=e&&b;return{featureLayer:{id:a.layerObject.id,layerAllowsCreate:c,layerAllowsUpdate:b,layerAllowsDelete:d,layerAllowGeometryUpdates:e},disableGeometryUpdate:!e,allowUpdateOnly:!c,allowDelete:!1,fieldInfos:this.mergeFieldInfosWithConfiguration(a,
null),_editFlag:c||b?!0:!1}};g.mergeLastToFirst=function(){for(var a={},c=0,b=arguments.length,d;c<b;c++)for(d in arguments[c])arguments[c].hasOwnProperty(d)&&(a[d]=arguments[c][d]);return a};g.mergeFirstToLast=function(){for(var a={},c=arguments.length-1,b;0<=c;c--)for(b in arguments[c])arguments[c].hasOwnProperty(b)&&(a[b]=arguments[c][b]);return a};g.isObjectEmpty=function(a){if(a)for(var c in a)if(a.hasOwnProperty(c))return!1;return!0};g.addDateTimeFormat=function(a){a&&a.format&&null!==a.format&&
a.format.dateFormat&&null!==a.format.dateFormat&&0<=a.format.dateFormat.toString().toUpperCase().indexOf("TIME")&&(a.format.time=!0)};g.isDuplicateGroupName=function(a,c){var b=!1;h.some(c,p.hitch(this,function(d){if(a.toLowerCase()===d.toLowerCase())return b=!0}));return b};return g});