// 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/DataAggregation/js/UI/templates/FieldMapping.html":'\x3cdiv class\x3d"pad-left-5 no-select"\x3e\r\n  \x3ctable class\x3d"page-table" cellpading\x3d"0"\x3e\r\n    \x3ctbody\x3e\r\n      \x3ctr\x3e\r\n        \x3ctd class\x3d"panel-title-td"\x3e\r\n          \x3cdiv class\x3d"panel-title-text" tabindex\x3d"0" role\x3d"region" aria-label\x3d"${nls.mapping.schemaMapping}${nls.fieldMapping.fieldMappingPageHint}"\x3e\r\n            ${nls.mapping.schemaMapping}\x3c/div\x3e\r\n        \x3c/td\x3e\r\n      \x3c/tr\x3e\r\n      \x3ctr class\x3d"task-instruction-row bottom-border-bold"\x3e\r\n        \x3ctd colspan\x3d"2" class\x3d"panel-title-hint-td"\x3e\r\n          \x3cdiv class\x3d"instruction"\x3e${nls.fieldMapping.fieldMappingPageHint}\x3c/div\x3e\r\n        \x3c/td\x3e\r\n      \x3c/tr\x3e\r\n      \x3ctr\x3e\r\n        \x3ctd class\x3d"pad-top-10"\x3e\r\n          \x3cdiv data-dojo-attach-point\x3d"fieldMappingTable"\x3e\x3c/div\x3e\r\n        \x3c/td\x3e\r\n      \x3c/tr\x3e\r\n    \x3c/tbody\x3e\r\n  \x3c/table\x3e\r\n\x3c/div\x3e'}});
define("dojo/_base/declare dojo/_base/lang dojo/_base/array dojo/dom-construct dojo/dom-class dojo/Deferred dijit/_WidgetBase dijit/_TemplatedMixin dijit/_WidgetsInTemplateMixin dojo/Evented dojo/text!./templates/FieldMapping.html jimu/dijit/SimpleTable jimu/dijit/formSelect".split(" "),function(n,g,k,p,l,m,q,r,t,u,v,w,x){return n([q,r,t,u],{baseClass:"cf-field-mapping",declaredClass:"CriticalFacilities.FieldMapping",templateString:v,_started:null,label:"FieldMapping",parent:null,nls:null,map:null,
appConfig:null,config:null,targetFields:[],sourceFields:[],_fieldsTable:null,theme:"",styleColor:"",constructor:function(b){g.mixin(this,b)},postCreate:function(){this.inherited(arguments);this._initFieldsTable();this._initFields(this.targetFields)},startup:function(){this._started=!0;this._updateAltIndexes()},targetLayerUpdate:function(b,a){this._fieldsTable.clear();this.parent._fieldMappingComplete=!1;this.emit("field-mapping-update",!1);this.targetFields=b;this.sourceFields=a;this._initFields(this.targetFields)},
onShown:function(){this.pageContainer.nextDisabled=!1;this.prevResult=this._getResults()},_updateAltIndexes:function(){this.pageContainer&&!this._startPageView&&(this._startPageView=this.pageContainer.getViewByTitle("StartPage"))&&(this.altBackIndex=this.altNextIndex=this._startPageView.index)},validate:function(b,a){var d=new m;"next-view"===b?d.resolve(this._nextView(a)):"back-view"===b?d.resolve(this._backView(a)):this._homeView(a).then(function(c){d.resolve(c)});return d},_nextView:function(b){if(b.currentView.label===
this.label){var a=this._getResults(),d=!1;b=Object.keys(a.results).map(function(c){return a.results[c]});k.forEach(b,function(c){"undefined"!==typeof c&&null!==c&&""!==c&&(d=!0)});this.parent._fieldMappingComplete=d;this.emit("field-mapping-update",d,a.results)}return!0},_backView:function(b){if(b.currentView.label===this.label){var a=!1;this._setPreviousResult(this.prevResult?this.prevResult.results:{});if(this.prevResult){var d=this.prevResult;b=Object.keys(d.results).map(function(c){return d.results[c]});
k.forEach(b,function(c){"undefined"!==typeof c&&null!==c&&""!==c&&(a=!0)})}this.parent._fieldMappingComplete=a;this.emit("field-mapping-update",a)}return!0},_homeView:function(b){var a=new m;this.pageContainer.getViewByTitle("Home").verifyClearSettings(b).then(function(d){a.resolve(d)});return a},_initFieldsTable:function(){var b=[{name:"targetField",type:"extension",hidden:!0,create:g.hitch(this,this._createTargetField),setValue:g.hitch(this,this._setTargetFieldValue),getValue:g.hitch(this,this._getTargetFieldValue)},
{name:"target",title:this.nls.fieldMapping.targetField,type:"text","class":"task-instruction-row"},{name:"label",title:this.nls.fieldMapping.sourceField,type:"extension",hidden:!1,create:g.hitch(this,this._createSelect),setValue:g.hitch(this,this._setSelectValue),getValue:g.hitch(this,this._getSelectValue)}];this._fieldsTable=new w({fields:b,selectable:!1,autoHeight:!0,_rowHeight:"LaunchpadTheme"===this.appConfig.theme.name?36:30});this._fieldsTable.placeAt(this.fieldMappingTable);this._fieldsTable.startup()},
_setTargetFieldValue:function(b,a){b.targetField=a},_getTargetFieldValue:function(b){return b.targetField},_createSelect:function(b){var a=b.parentNode.cells[0].targetField,d=new x({style:{display:"table",width:"100%",height:"28px"},"aria-label":a.label}),c=this._getSupportedFields(this.sourceFields,a.type,a.length),e=[{label:this.nls.warningsAndErrors.noValue,value:this.nls.warningsAndErrors.noValue}],f=this._getDefaultFieldName(c,a);k.forEach(c,function(h){e.push({label:h.label,value:h.value,selected:f===
h.value})});d.addOption(e);b.fieldsSelect=d;p.place(d.domNode,b);l.add(b,"float-left");l.add(b,"width-all");this.lastFieldSelect=d.domNode},_getSelectValue:function(b){return b.fieldsSelect.get("value")},_setSelectValue:function(b,a){b.fieldsSelect.set("value",a)},_initFields:function(b){k.forEach(b,g.hitch(this,function(a){this._fieldsTable.addRow({target:a.label,targetField:a})}))},_getSupportedFields:function(b,a,d){return b.filter(function(c){if(c.type){var e=c.type.supportsInt,f=c.type.supportsFloat,
h=c.type.supportsDate;c=c.type.maxLength;return"date"!==a&&c>d?!1:"other"===a||"domain"===a?!0:"int"===a||"domainInt"===a?e:"float"===a?f:"date"===a?h:!1}return!1})},_getDefaultFieldName:function(b,a){a=a.isRecognizedValues;for(var d=0;d<a.length;d++)for(var c=a[d],e=0;e<b.length;e++){var f=b[e];if(f.value.toString().toUpperCase()===c.toString().toUpperCase())return f.value}},setStyleColor:function(b){this.styleColor=b},updateImageNodes:function(){},_getResults:function(){var b=this._fieldsTable.getRows(),
a={},d=this.nls.warningsAndErrors.noValue,c=!1,e;k.forEach(b,function(f){var h=f.cells[2].fieldsSelect.getValue();h!==d?(f=f.cells[0].targetField.name,a[f]=h,c||(e=f,c=!0)):a[f.cells[0].targetField.name]=void 0});return{results:a,labelField:e}},_setPreviousResult:function(b){var a=this._fieldsTable.getRows(),d=this.nls.warningsAndErrors.noValue;k.forEach(a,function(c){var e=d,f=c.cells[0].targetField.name;b.hasOwnProperty(f)&&(e=b[f],void 0===e&&(e=d));c.cells[2].fieldsSelect.set("value",e)})}})});