// 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/Geoprocessing/editors/DataFileEditor.html":'\x3cdiv\x3e\r\n  \x3cdiv data-dojo-attach-point\x3d"modeSelection" style\x3d"display:none"\x3e\r\n    \x3cdiv class\x3d"field"\x3e\r\n      \x3cinput name\x3d"${uniqueID}_dataFileMode" data-dojo-type\x3d"dijit/form/RadioButton" data-dojo-attach-point\x3d"urlMode"\r\n        style\x3d"font-size: 12px;" id\x3d"${uniqueID}_gpSettingFileUrl"\x3e\r\n        \x3clabel style\x3d"width: auto;" for\x3d"${uniqueID}_gpSettingFileUrl" class\x3d"jimu-leading-margin05"\x3e${nls.useUrlForGPInput}\x3c/label\x3e\r\n      \x3cinput name\x3d"${uniqueID}_dataFileMode" data-dojo-type\x3d"dijit/form/RadioButton" data-dojo-attach-point\x3d"itemMode"\r\n        style\x3d"font-size: 12px;" class\x3d"jimu-leading-margin35" id\x3d"${uniqueID}_gpSettingFileItem"\x3e\r\n      \x3clabel style\x3d"width: auto;"\r\n        class\x3d"jimu-leading-margin05" for\x3d"${uniqueID}_gpSettingFileItem"\x3e${nls.useUploadForGPInput}\x3c/label\x3e\r\n    \x3c/div\x3e\r\n  \x3c/div\x3e\r\n  \x3cdiv\x3e\r\n    \x3cdiv data-dojo-attach-point\x3d"settingNode"\x3e\r\n      \x3cdiv data-dojo-attach-point\x3d"urlNode" data-dojo-props\x3d"label:urlNode"\x3e\r\n        \x3cdiv\x3e\r\n          \x3cinput type\x3d"text" data-dojo-attach-point\x3d"urlEditor" style\x3d"width:100%"\r\n            data-dojo-type\x3d"jimu/dijit/URLInput" data-dojo-props\x3d"rest:false" class\x3d"common-input"/\x3e\r\n        \x3c/div\x3e\r\n      \x3c/div\x3e\r\n      \x3cdiv data-dojo-attach-point\x3d"fileNode" data-dojo-props\x3d"label:fileNode"\x3e\r\n        \x3cdiv\x3e\r\n          \x3cform data-dojo-attach-point\x3d"fileForm"\r\n                enctype\x3d"multipart/form-data"\r\n                method\x3d"POST" data-dojo-type\x3d"dijit/form/Form"\x3e\r\n            \x3cinput id\x3d"${uniqueID}_file" type\x3d"file" multiple\x3d"false" name\x3d"file"\r\n              data-dojo-attach-point\x3d"fileInput"\r\n              data-dojo-attach-event\x3d"onChange: _onUpload" style\x3d"display:none"/\x3e\r\n            \x3cdiv class\x3d"jimu-btn jimu-leading-margin10 jimu-float-leading"\x3e\r\n              \x3clabel class\x3d"file-input-label" for\x3d"${uniqueID}_file"\x3e\r\n                ${nls.selectFileToUpload}\r\n              \x3c/label\x3e\r\n            \x3c/div\x3e\r\n            \x3cinput type\x3d"hidden" name\x3d"f" value\x3d"json"/\x3e\r\n          \x3c/form\x3e\r\n          \x3cspan data-dojo-attach-point\x3d"uploadFileName" class\x3d"jimu-leading-margin2"\x3e\x3c/span\x3e\r\n        \x3c/div\x3e\r\n      \x3c/div\x3e\r\n    \x3c/div\x3e\r\n  \x3c/div\x3e\r\n\x3c/div\x3e\r\n'}});
define("dojo/_base/declare dojo/_base/lang dojo/_base/html dojo/_base/array dojo/dom-style dojo/dom-attr dojo/on dojo/Deferred dojo/text!./DataFileEditor.html dijit/_TemplatedMixin dijit/_WidgetsInTemplateMixin esri/tasks/DataFile esri/request jimu/dijit/ViewStack jimu/dijit/Message jimu/utils ../BaseEditor ../utils dijit/form/Form jimu/dijit/URLInput dijit/form/RadioButton".split(" "),function(l,e,m,n,f,c,g,h,p,q,r,t,u,v,k,w,x,y){return l([x,q,r],{baseClass:"jimu-gp-editor-base jimu-gp-editor-datafile",
templateString:p,editorName:"DataFileEditor",mode:"url",_url:"",_itemID:null,uniqueID:null,constructor:function(){this.inherited(arguments);this.uniqueID=y.uniqueId()},postCreate:function(){this.inherited(arguments);this.value&&this.parseDefaultValue();c.set(this.urlEditor,"tooltip",this.param.tooltip);"setting"===this.context?(this.viewStack=null,f.set(this.fileNode,"display","none")):(this.viewStack=new v({viewType:"dom",views:[this.urlNode,this.fileNode]}),this.viewStack.placeAt(this.settingNode),
this.viewStack.startup());!0===this.config.serverInfo.supportsUpload&&f.set(this.modeSelection,"display","");this.own(g(this.urlMode,"click",e.hitch(this,this._onUrlModeSelect)));this.own(g(this.itemMode,"click",e.hitch(this,this._onItemModeSelect)));"item"===this.mode&&this.config.serverInfo.supportsUpload?(this.itemMode.set("checked",!0),this._onItemModeSelect()):(this.urlMode.set("checked",!0),this._onUrlModeSelect(),this.urlEditor.set("value",this._url));if(this.param.filter&&this.param.filter.type&&
"file"===this.param.filter.type.toLowerCase()&&this.param.filter.list&&0<this.param.filter.list.length){var b=n.map(this.param.filter.list,function(a){return"."+a});m.setAttr(this.fileInput,"accept",b.join(","))}},parseDefaultValue:function(){0===this.value.indexOf("itemID:")?this.mode="item":(0===this.value.indexOf("url:")&&(this._url=this.value.substring(4)),this.mode="url")},hasValidValue:function(){if("item"===this.mode)return!0;if("url"===this.mode)return this.urlEditor.isValid()},getValue:function(){return"url"===
this.mode?"url:"+this._getUrl():"item"===this.mode?"itemID:":""},getGPValue:function(){var b=new h,a=new t;"url"===this.mode?a.url=this._getUrl():a.itemID=this.itemIDInput;a.url||a.itemID?b.resolve(a):b.resolve(null);return b},_getUrl:function(){return this.urlEditor.isValid()?this.urlEditor.get("value"):""},_onUrlModeSelect:function(){this.mode="url";this.viewStack?this.viewStack.switchView(0):f.set(this.urlNode,"display","block")},_onItemModeSelect:function(){this.mode="item";this.viewStack?this.viewStack.switchView(1):
f.set(this.urlNode,"display","none")},_onUpload:function(){c.get(this.fileInput,"value")&&this._doUpload().then(e.hitch(this,function(b){b&&new k({message:this.nls.uploadSuccess})}),function(b){new k({message:b.message||b})})},_doUpload:function(){var b=new h,a=c.get(this.fileInput,"value");a=a.replace(/\\/g,"/");a=a.substr(a.lastIndexOf("/")+1);u({url:this.config.serverInfo.url+"uploads/upload",form:this.fileForm.domNode,handleAs:"json"}).then(e.hitch(this,function(d){d.success&&(this.itemIDInput=
d.item.itemID,c.set(this.fileInput,"value",""),c.set(this.uploadFileName,"innerHTML",w.sanitizeHTML(a)));b.resolve(d.success)}),function(d){b.reject(d)});return b}})});