/*
 COPYRIGHT 2009 ESRI

 TRADE SECRETS: ESRI PROPRIETARY AND CONFIDENTIAL
 Unpublished material - all rights reserved under the
 Copyright Laws of the United States and applicable international
 laws, treaties, and conventions.

 For additional information, contact:
 Environmental Systems Research Institute, Inc.
 Attn: Contracts and Legal Services Department
 380 New York Street
 Redlands, California, 92373
 USA

 email: contracts@esri.com
 */
//>>built
require({cache:{"url:esri/dijit/templates/MosaicRule.html":"<div data-dojo-attach-point=\"_mosaicRuleContainer\" class=\"mosaicRuleContainer\">\r\n  <table class=\"mosaicRuleTable\">\r\n    <col class=\"mosaicRuleColumn1\" />\r\n    <col class=\"mosaicRuleColumn2\" />\r\n    <tr>\r\n      <td colspan=\"2\">\r\n        <label data-dojo-attach-point=\"_mosaicRuleLabel\">${_i18n.widgets.mosaicRule.mosaicMethodLabel}</label>\r\n      </td>\r\n    </tr>\r\n    <tr>\r\n      <td colspan=\"2\">\r\n        <select data-dojo-attach-point=\"_mosaicRule\" id=\"MosaicMethod\" class=\"mosaicRuleSelectbox\">\r\n          <option>&lt;MosaicDefault&gt;</option>\r\n        </select>\r\n      </td>\r\n    </tr>\r\n    <tr data-dojo-attach-point=\"_orderFieldBlock\">\r\n      <td>\r\n        <label>${_i18n.widgets.mosaicRule.orderFieldLabel}</label>\r\n      </td>\r\n      <td>\r\n        <select data-dojo-attach-point=\"_orderField\" class=\"mosaicRuleSelectbox\">\r\n          <option>&lt;MosaicDefault&gt;</option>\r\n        </select>\r\n      </td>\r\n    </tr>\r\n    <tr data-dojo-attach-point=\"_orderValueTextBlock\">\r\n      <td>\r\n        <label>${_i18n.widgets.mosaicRule.orderValueLabel}</label>\r\n      </td>\r\n      <td>\r\n        <input type=\"text\" value=\"0\" data-dojo-attach-point=\"_orderValueText\" class=\"mosaicRuleOrderValueTextbox\" />\r\n        <input type=\"text\" data-dojo-attach-point=\"_orderValueDate\" data-dojo-type=\"dijit/form/DateTextBox\" class=\"mosaicRuleOrderValueDate\" />\r\n      </td>\r\n    </tr>\r\n    <tr data-dojo-attach-point=\"_lockRasterBlock\">\r\n      <td>\r\n        <label>${_i18n.widgets.mosaicRule.lockRasterIdLabel}</label>\r\n      </td>\r\n      <td>\r\n        <input type=\"text\" data-dojo-attach-point=\"_lockRaster\" class=\"mosaicRuleLockRasterTextbox\" />\r\n        <div data-dojo-type=\"dijit/form/DropDownButton\" data-dojo-attach-point=\"_lockRasterIdSelect\"\r\n          iconclass=\"mosaicRuleThreedotsIcon\" class=\"mosaicRuleDropdownIcon\" showlabel='false'>\r\n          <div data-dojo-type=\"dijit/TooltipDialog\" data-dojo-attach-point=\"_lockRasterTooltip\">\r\n            <div data-dojo-type=\"dijit/layout/ContentPane\" class=\"mosaicRuleLayerlistTooltip\">\r\n              <div data-dojo-attach-point=\"_layerList\">\r\n              </div>\r\n            </div>\r\n            <center>\r\n              <input data-dojo-attach-point=\"_aoi\" type=\"button\" value=\"${_i18n.widgets.mosaicRule.refreshLockRasterIdsLabel}\"></input></center>\r\n            </br>\r\n            <label data-dojo-attach-point=\"_lockRasterMsg\" />\r\n          </div>\r\n        </div>\r\n      </td>\r\n    </tr>\r\n    <tr data-dojo-attach-point=\"_descendingBlock\">\r\n      <td colspan=\"2\">\r\n        <input type=\"checkbox\" data-dojo-attach-point=\"_descending\" name=\"descending\"/>\r\n        <label class=\"mosaicRuleDescendingLabel\" for=\"descending\">${_i18n.widgets.mosaicRule.descendingLabel}</label>\r\n      </td>\r\n    </tr>\r\n    <tr>\r\n      <td colspan=\"3\">\r\n        <p/>\r\n      </td>\r\n    </tr>\r\n    <tr data-dojo-attach-point=\"_mosaicOperatorLabelBlock\">\r\n      <td colspan=\"2\">\r\n        <label>${_i18n.widgets.mosaicRule.mosaicOperatorLabel}</label>\r\n      </td>\r\n    </tr>\r\n    <tr data-dojo-attach-point=\"_mosaicOperatorBlock\">\r\n      <td colspan=\"2\">\r\n        <select data-dojo-attach-point=\"_mosaicOperator\" class=\"mosaicRuleSelectbox\">\r\n          <option>&lt;MosaicDefault&gt;</option>\r\n          <option>First</option>\r\n          <option>Blend</option>\r\n          <option>Last</option>\r\n          <option>Min</option>\r\n          <option>Max</option>\r\n          <option>Mean</option>\r\n        </select>\r\n      </td>\r\n    </tr>\r\n    <tr>\r\n      <td>\r\n        <label data-dojo-attach-point=\"_whereLabel\" for=\"where\">\r\n          ${_i18n.widgets.mosaicRule.queryLabel}</label>\r\n      </td>\r\n      <td>\r\n        <input type=\"text\" value=\"<where>\" class=\"mosaicRuleQueryTextbox\" data-dojo-attach-point=\"_where\" />\r\n        <div data-dojo-type=\"dijit/form/DropDownButton\" iconclass=\"mosaicRuleQueryIcon\" showlabel='false'\r\n          data-dojo-attach-point=\"_queryBlock\">\r\n          <span>Query</span>\r\n          <div data-dojo-type=\"dijit/TooltipDialog\" data-dojo-attach-point=\"_queryTooltip\">\r\n            <table class=\"mosaicRuleQueryTable\">\r\n              <tr>\r\n                <td>\r\n                  <label>${_i18n.widgets.mosaicRule.queryFieldLabel}</label>\r\n                </td>\r\n                <td>\r\n                  <select data-dojo-attach-point=\"_queryOrderField\" class=\"mosaicRuleSelectbox\">\r\n                    <option>&lt;None&gt;</option>\r\n                  </select>\r\n                </td>\r\n              </tr>\r\n              <tr>\r\n                <td>\r\n                  <label>${_i18n.widgets.mosaicRule.queryOperatorLabel}</label>\r\n                </td>\r\n                <td>\r\n                  <select data-dojo-attach-point=\"_queryOperator\" class=\"mosaicRuleSelectbox\">\r\n                    <option>&lt;None&gt;</option>\r\n                    <option>=</option>\r\n                    <option>&lt;&gt;</option>\r\n                    <option>&gt;</option>\r\n                    <option>&gt;=</option>\r\n                    <option>&lt;</option>\r\n                    <option>&lt;=</option>\r\n                    <option>LIKE</option>\r\n                    <option>AND</option>\r\n                    <option>OR</option>\r\n                    <option>NOT</option>\r\n                    <option>IS</option>\r\n                  </select>\r\n                </td>\r\n              </tr>\r\n              <tr>\r\n                <td>\r\n                  <label>${_i18n.widgets.mosaicRule.queryValueLabel}</label>\r\n                </td>\r\n                <td>\r\n                  <input type=\"text\" data-dojo-attach-point=\"_queryValue\" class=\"mosaicRuleTextbox\" />\r\n                </td>\r\n              </tr>\r\n            </table>\r\n          </div>\r\n        </div>\r\n      </td>\r\n    </tr>\r\n    <tr>\r\n      <td>\r\n      </td>\r\n      <td>\r\n        <input type=\"button\" data-dojo-attach-point=\"_apply\" value=\"APPLY\" size=\"15\" class=\"mosaicRuleApplyButton\" />\r\n      </td>\r\n    </tr>\r\n  </table>\r\n</div>\r\n"}});define("esri/dijit/MosaicRule",["dojo/_base/declare","dojo/_base/lang","dojo/_base/connect","dojo/_base/array","dojo/_base/Color","dojo/_base/window","dojo/dom-construct","dojo/i18n!esri/nls/jsapi","dojo/text!esri/dijit/templates/MosaicRule.html","dijit/_WidgetBase","dijit/_TemplatedMixin","dijit/_WidgetsInTemplateMixin","dojo/query","dojo/number","dojo/has","dojo/date/locale","dojo/dnd/Source","esri/kernel","esri/config","esri/layers/MosaicRule","esri/renderers/SimpleRenderer","esri/symbols/SimpleFillSymbol","esri/layers/GraphicsLayer","esri/tasks/ImageServiceIdentifyTask","esri/tasks/ImageServiceIdentifyParameters","esri/tasks/QueryTask","esri/tasks/query","esri/geometry/Polygon","esri/geometry/Point","esri/geometry/Extent","dijit/Calendar","dijit/form/DropDownButton","dijit/form/CheckBox","dijit/TooltipDialog","dijit/layout/ContentPane"],function(_1,_2,_3,_4,_5,_6,_7,_8,_9,_a,_b,_c,_d,_e,_f,_10,_11,_12,_13,_14,_15,_16,_17,_18,_19,_1a,_1b,_1c,_1d,_1e){var _1f=_1([_a,_b,_c],{declaredClass:"esri.dijit.MosaicRule",templateString:_9,widgetsInTemplate:true,layer:null,map:null,parent:null,hideApplyButton:false,hideLockRasterSelectionIdButton:false,_MosaicRuleObject:null,_fieldType:null,_identifyTask:null,_identify:null,_queryTask:null,_query:null,_graphicsLayer:null,_app:null,_initialExtent:null,_getpoint:null,_internalApplyMosaic:false,_previousOrderFieldIndex:-1,constructor:function(_20){_1.safeMixin(this,_20);this._i18n=_8;var _21=new _15(new _16().setColor(new _5([150,150,150,0.5])));this._graphicsLayer=new _17();this._graphicsLayer.setRenderer(_21);this.map.addLayer(this._graphicsLayer);},startup:function(){this.inherited(arguments);var _22=_2.hitch(this,"_onclickTooltip");var _23=_2.hitch(this,"_oncloseTooltip");var _24=_2.hitch(this,"_onclickLayerlist");var _25=_2.hitch(this,"_OnOpenQueryPopup");var _26=_2.hitch(this,"_OnCloseQueryPopup");var _27=_2.hitch(this,"_OnChangeMosaicRule");var _28=_2.hitch(this,"_OnChangeOrderField");var _29=_2.hitch(this,"_OnChangeLockRaster");var _2a=_2.hitch(this,"_OnClickCurrentExtent");var _2b=_2.hitch(this,"_OnChangeMosaicOperator");var _2c=_2.hitch(this,"_OnClickDescending");var _2d=_2.hitch(this,"_OnChangeQueryOrderField");var _2e=_2.hitch(this,"_OnChangeQueryOperator");var _2f=_2.hitch(this,"_OnKeyupQueryValue");var _30=_2.hitch(this,"_OnClickApplyMosaic");var _31=_2.hitch(this,"_OnClickResetMosaic");_3.connect(this._lockRasterTooltip,"onclick",_22);_3.connect(this._lockRasterTooltip,"onClose",_23);_3.connect(this._layerList,"onclick",_24);_3.connect(this._queryTooltip,"onOpen",_25);_3.connect(this._queryTooltip,"onClose",_26);_3.connect(this._mosaicRule,"onchange",_27);_3.connect(this._orderField,"onchange",_28);_3.connect(this._lockRaster,"onkeyup",_29);_3.connect(this._aoi,"onclick",_2a);_3.connect(this._mosaicOperator,"onchange",_2b);_3.connect(this._descending,"onclick",_2c);_3.connect(this._queryOrderField,"onchange",_2d);_3.connect(this._queryOperator,"onchange",_2e);_3.connect(this._queryValue,"onkeyup",_2f);_3.connect(this._apply,"onclick",_30);_3.subscribe("onMosaicRuleApply",_30);_3.subscribe("onMosaicRuleReset",_31);this._descending.checked=false;if(this.hideApplyButton){this._apply.style.display="none";}if(this.hideLockRasterSelectionIdButton){this._lockRasterIdSelect.domNode.style.display="none";this._lockRaster.style.width="100%";}this._where.style.display="none";this._whereLabel.style.display="none";this._queryBlock.domNode.style.display="none";},_init:function(){this._MosaicRuleObject=new _14();this._MosaicRuleObject.ascending=true;this._getpoint=0;this._fieldType=[];this._app={};_7.empty(this._layerList);this._orderValueDate.domNode.style.display="none";this._identifyTask=new _18(this.layer.url);this._identify=new _19();this._queryTask=new _1a(this.layer.url);this._query=new _1b();},_buildRasterList:function(){this._lockRasterMsg.style.display="";this._lockRasterMsg.innerHTML=this._i18n.widgets.mosaicRule.lockRasterRequestMsg;var _32=new _1e(this.layer.fullExtent.toJson());if(this.layer.fullExtent.contains(this.map.extent)){_32=new _1e(this.map.extent.toJson());}if(this.layer.version>=10&&this.map.wrapAround180){_32=_32._normalize(true);}var _33=new _1c(_32.spatialReference);_33.addRing([[_32.xmin,_32.ymin],[_32.xmin,_32.ymax],[_32.xmax,_32.ymax],[_32.xmax,_32.ymin],[_32.xmin,_32.ymin]]);var psX=(_32.xmax-_32.xmin)/(this.map.width*2);var psY=(_32.ymax-_32.ymin)/(this.map.height*2);var _34=_32.spatialReference;var _35=new _1d(psX,psY,_34);var _36=this._identifyTask;var _37=this._identify;if(this.layer.version>10.1){_36=this._queryTask;_37=this._query;}_37.geometry=_33;_37.pixelSize=_35;_37.returnGeometry=false;var _38=_2.hitch(this,"_errorRastersInAOI");var _39=_2.hitch(this,"_showRastersInAOI");_36.execute(_37,function(_3a){_39(_3a);},function(_3b){_38(_3b);});},_setLayerAttr:function(_3c){this.inherited(arguments);this.layer=_3c;_3.connect(this.layer,"onMosaicRuleChange",_2.hitch(this,"_onLayerMosaicRuleChange"));this._init();var i;for(i=this._mosaicRule.options.length-1;i>=0;i--){this._mosaicRule.remove(i);}for(i=this._mosaicOperator.options.length-1;i>=0;i--){this._mosaicOperator.remove(i);}i=this._orderField.options.length;while(i>0){this._orderField.remove(i-1);i=this._orderField.options.length;}this._orderValueText.value="";this._where.value="<where>";this._orderFieldBlock.style.display="";this._lockRasterBlock.style.display="";this._descendingBlock.style.display="";this._graphicsLayer.clear();var _3d=_2.hitch(this,"_initUsingServiceInfo");if(this.layer.loaded){this._initUsingServiceInfo(this.layer);}else{_3.connect(this.layer,"onLoad",_3d);}},_initUsingServiceInfo:function(_3e){if(!_3e.fields||_3e.fields.length===0){this._mosaicRuleLabel.innerHTML=this._i18n.widgets.mosaicRule.mosaicruleNotApplicable;this._hideAllControls();return;}var _3f=new _1e(_3e.extent);this._initialExtent=_3f;if(!this.hideLockRasterSelectionIdButton){this._buildRasterList();}this._populateOrderFieldsList(_3e.fields);if(_3e.sortField){this._MosaicRuleObject.sortField=_3e.sortField;}if(_3e.sortValue){this._orderValueText.value=_3e.sortValue;this._MosaicRuleObject.sortValue=_3e.sortValue;}var _40="None,ByAttribute,Center,Nadir,LockRaster,NorthWest,Seamline";if(_3e.hasOwnProperty("currentVersion")&&_3e.currentVersion>=10.1&&_3e.allowedMosaicMethods.length>1){_40=_3e.allowedMosaicMethods;if(_40.toLowerCase().indexOf("none")<0){_40=_40+",None";}}this._populateMosaicMethodsList(_40);var _41=_3e.defaultMosaicMethod;if(!_41){_41="northwest";}this._MosaicRuleObject.method=this._esriStringMosaicMethodToEnum(_41);this._populateMosaicOperatorsList(_3e.defaultMosaicMethod);this._MosaicRuleObject.operation=this._esriStringMosaicOperatorToEnum(_3e.mosaicOperator);this._MosaicRuleObject.ascending=true;var _42=(this.layer&&this.layer.mosaicRule)?this.layer.mosaicRule:this._MosaicRuleObject;this._setDefaultValues(_42);},_populateOrderFieldsList:function(_43){_43.sort(function(a,b){return a.alias.localeCompare(b.alias);});var t;for(t in _43){if(_43[t].type==="esriFieldTypeDouble"||_43[t].type==="esriFieldTypeSingle"||_43[t].type==="esriFieldTypeInteger"||_43[t].type==="esriFieldTypeSmallInteger"||_43[t].type==="esriFieldTypeOID"||_43[t].type==="esriFieldTypeDate"){this._orderField.add(new Option(_43[t].alias,_43[t].name),this._orderField.length);this._queryOrderField.add(new Option(_43[t].name),this._queryOrderField.length);this._fieldType.push(_43[t].type);}}if(this._orderField.children.length===0){this._orderField.add(new Option(this._i18n.widgets.mosaicRule.orderFieldNotFound,this._i18n.widgets.mosaicRule.orderFieldNotFound),true);}},_populateMosaicMethodsList:function(_44){if(_44.toLowerCase().indexOf("none")>=0){this._addItemToMosaicMethodList("none");}if(_44.toLowerCase().indexOf("byattribute")>=0){this._addItemToMosaicMethodList("byattribute");}if(_44.toLowerCase().indexOf("center")>=0){this._addItemToMosaicMethodList("center");}if(_44.toLowerCase().indexOf("northwest")>=0){this._addItemToMosaicMethodList("northwest");}if(_44.toLowerCase().indexOf("nadir")>=0){this._addItemToMosaicMethodList("nadir");}if(_44.toLowerCase().indexOf("seamline")>=0){this._addItemToMosaicMethodList("seamline");}if(_44.toLowerCase().indexOf("lockraster")>=0){this._addItemToMosaicMethodList("lockraster");}},_addItemToMosaicMethodList:function(_45){var _46=this._mosaicMethodNameToAlias(_45);this._mosaicRule.add(new Option(_46,_45),this._mosaicRule.length);},_populateMosaicOperatorsList:function(_47){var _48=this._mosaicOperator.options.length;var _49=_48?this._mosaicOperator.options[this._mosaicOperator.selectedIndex].value.toLowerCase():null;var i;for(i=_48-1;i>=0;i--){this._mosaicOperator.remove(i);}if(!_47||_47.toLowerCase()!=="seamline"){this._mosaicOperator.add(new Option(this._i18n.widgets.mosaicRule.firstAlias,"First"),0);this._mosaicOperator.add(new Option(this._i18n.widgets.mosaicRule.minAlias,"Min"),2);this._mosaicOperator.add(new Option(this._i18n.widgets.mosaicRule.maxAlias,"Max"),3);this._mosaicOperator.add(new Option(this._i18n.widgets.mosaicRule.averageAlias,"Mean"),4);this._mosaicOperator.add(new Option(this._i18n.widgets.mosaicRule.blendAlias,"Blend"),5);}else{this._mosaicOperator.add(new Option(this._i18n.widgets.mosaicRule.firstAlias,"First"),0);this._mosaicOperator.add(new Option(this._i18n.widgets.mosaicRule.blendAlias,"Blend"),1);}this._mosaicOperator.selectedIndex=0;if(_49!==null){for(i=this._mosaicOperator.options.length-1;i>=0;i--){var _4a=this._mosaicOperator.children[i].value;if(_4a.toLowerCase()===_49.toLowerCase()){this._mosaicOperator.selectedIndex=i;break;}}}},_onLayerMosaicRuleChange:function(){if(this._internalApplyMosaic){this._internalApplyMosaic=false;return;}this._setDefaultValues(this.layer.mosaicRule);},_setDefaultValues:function(_4b){if(!_4b){return;}var h;var _4c;if(_4b.sortField){for(h=0;h<this._orderField.children.length;h++){_4c=this._orderField.children[h].value;if(_4b.sortField.toLowerCase()===_4c.toLowerCase()){this._orderField.selectedIndex=h;this._OnChangeOrderField();break;}}}if(_4b.sortValue){this._orderValueText.value=_4b.sortValue;}var _4d=this._esriEnumMosaicOperatorToString(_4b.operation);for(h=0;h<this._mosaicOperator.children.length;h++){_4c=this._mosaicOperator.children[h].value;if(_4d.toLowerCase()===_4c.toLowerCase()){this._mosaicOperator.selectedIndex=h;this._OnChangeMosaicOperator();break;}}var _4e=this._esriEnumMosaicMethodToString(_4b.method);for(h=0;h<this._mosaicRule.children.length;h++){_4c=this._mosaicRule.children[h].value;if(_4e.toLowerCase()===_4c.toLowerCase()){this._mosaicRule.selectedIndex=h;this._OnChangeMosaicRule();break;}}if(_4e.toLowerCase()==="lockraster"&&_4b.lockRasterIds){this._lockRaster.value=_4b.lockRasterIds;}if(_4b.where){this._where.value=_4b.where;}if(_4b.ascending!==null){this._descending.checked=!_4b.ascending;}else{this._descending.checked=false;}},_selectAllCheckboxOnChange:function(){var _4f=_2.hitch(this,"_checkboxOnChange");var _50=_d(".mosaicRuleLayerlistSelectCheckbox",this._layerList);var _51=_d(".mosaicRuleLayerlistCheckbox",this._layerList);_50.forEach(function(_52){if(!_52.checked){_51.forEach(function(_53){_53.checked=false;_4f();});}else{_51.forEach(function(_54){_54.checked=true;_4f();});}});},_OnOpenQueryPopup:function(){this._where.disabled=true;},_OnCloseQueryPopup:function(){this._where.disabled=false;if(this._queryOrderField.options[this._queryOrderField.selectedIndex].text!=="<None>"){try{this._queryOrderField.add(new Option("<None>"),this._queryOrderField.options[0]);}catch(err1){this._queryOrderField.add(new Option("<None>"),0);}this._queryOrderField.selectedIndex=0;}if(this._queryOperator.options[this._queryOperator.selectedIndex].text!=="<None>"){try{this._queryOperator.add(new Option("<None>"),this._queryOperator.options[0]);}catch(err2){this._queryOperator.add(new Option("<None>"),0);}this._queryOperator.selectedIndex=0;}this._queryValue.value="";},_onclickLayerlist:function(){this._getpoint=1;},_onclickTooltip:function(){if(this._getpoint===0){this._app.dndSource.selectNone();this._graphicsLayer.clear();}this._getpoint=0;},_oncloseTooltip:function(){this._graphicsLayer.clear();},_checkboxOnChange:function(){var _55=[];var _56=0;var _57=0;var _58=_d(".mosaicRuleLayerlistSelectCheckbox",this._layerList);var _59=_d(".mosaicRuleLayerlistCheckbox",this._layerList);_59.forEach(function(_5a){_56++;if(_5a.checked===true){_57++;_55.push(parseInt(_5a.id,10));}});if(_57!==_56){_58.forEach(function(_5b){_5b.checked=false;});}if(_57===_56){_58.forEach(function(_5c){_5c.checked=true;});}if(_55.length===0){this._lockRaster.value=null;}else{this._lockRaster.value=_55;}},_selectRaster:function(){this._graphicsLayer.clear();var _5d=_2.hitch(this,"_setGraphicQuery");var _5e=this._app.dndSource.getSelectedNodes();_5e.forEach(function(_5f){var _60=_d(".mosaicRuleLayerlistCheckbox",_5f);_60.forEach(function(_61){_5d(_61.id);});});},_setGraphicQuery:function(id){var _62=_2.hitch(this,"_addResultsToMap");this._query.geometry=this._initialExtent;this._query.returnGeometry=true;this._query.where="OBJECTID = "+id;this._queryTask.execute(this._query,_62);},_addResultsToMap:function(_63){var _64=_2.hitch(this,"_addEachFeatureToMap");_63.features.forEach(_64);},_addEachFeatureToMap:function(_65){this._graphicsLayer.add(_65);},_reorderRaster:function(){var _66=_d(".mosaicRuleLayerlistCheckbox",this._layerList);var _67=[];_66.forEach(function(_68){if(_68.checked===true){_67.push(parseInt(_68.id,10));}});var len=_67.length;var chk=0;var a;for(a=0;a!==len/2;a++){chk=0;var k;for(k=0;k<_67.length-1;k++){if(_67[_67.length-1]===_67[k]){_67.splice((_67.length-1),1);chk=1;break;}}if(chk===0){break;}}if(_67.length===0){this._lockRaster.value=null;}else{this._lockRaster.value=_67;}},_showRastersInAOI:function(_69){this._graphicsLayer.clear();var _6a;if(_69&&_69.catalogItems){_6a=_69.catalogItems.features;}else{_6a=_69.features;}if((!_69||!_6a||_6a.length<1)&&!this.hideLockRasterSelectionIdButton){this._lockRasterMsg.innerHTML=this._i18n.widgets.mosaicRule.lockRasterRequestNoRasterMsg;return;}this._lockRasterMsg.innerHTML=this._i18n.widgets.mosaicRule.lockRasterRequestDoneMsg;this._lockRasterMsg.style.display="none";if(this._app.hasOwnProperty("dndSource")){this._app.dndSource.destroy();_7.empty(this._layerList);}var _6b=[];if(this.layer&&this.layer.mosaicRule&&this.layer.mosaicRule.lockRasterIds){_6b=this.layer.mosaicRule.lockRasterIds;}var _6c=[];var _6d=[];var _6e=_2.hitch(this,"_checkboxOnChange");var _6f=_2.hitch(this,"_selectAllCheckboxOnChange");var i;for(i=0;i<_6a.length;i++){var _70=_7.create("div");var _71=_7.create("input");_71.type="checkbox";_71.className="mosaicRuleLayerlistCheckbox";_71.id=_6a[i].attributes.OBJECTID;if(_6a[i].attributes.hasOwnProperty("checked")){if(_6a[i].attributes.checked){_71.checked=true;_6c.push(_6a[i].attributes.OBJECTID);}else{_71.checked=false;}}else{if(_6b.length===0){_71.checked=true;}else{_71.checked=(_4.indexOf(_6b,_6a[i].attributes.OBJECTID)===-1?false:true);}_6c.push(_6a[i].attributes.OBJECTID);}_3.connect(_71,"onchange",_6e);_70.appendChild(_71);var _72=_7.create("label");_72.appendChild(_6.doc.createTextNode(_6a[i].attributes.OBJECTID));_70.appendChild(_72);_6d.push(_70);}if(_6a.length>0){if(!_6a[0].attributes.hasOwnProperty("checked")&&_6b.length<=0){this._lockRaster.value=_6c;}}this._MosaicRuleObject.ascending=true;var _73=_7.create("input");_73.type="checkbox";_73.id="select";_73.name=this._i18n.widgets.mosaicRule.selectAllLabel;_73.className="mosaicRuleLayerlistSelectCheckbox";if(_69.hasOwnProperty("selectAll")){if(_69.selectAll){_73.checked=true;}else{_73.checked=false;}}else{_73.checked=true;}_3.connect(_73,"onchange",_6f);var _74=_7.create("div");_74.appendChild(_73);var _75=_7.create("label");_75.appendChild(_6.doc.createTextNode(this._i18n.widgets.mosaicRule.selectAllLabel));_74.appendChild(_75);this._layerList.appendChild(_74);this._app.dndSource=new _11(this._layerList);this._app.dndSource.insertNodes(false,_6d);var _76=_2.hitch(this,"_reorderRaster");var _77=_2.hitch(this,"_selectRaster");_3.connect(this._app.dndSource,"onDndDrop",_76);_3.connect(this._app.dndSource,"onMouseUp",_77);},_errorRastersInAOI:function(){this._lockRasterMsg.innerHTML=this._i18n.widgets.mosaicRule.lockRasterRequestErrorMsg;return;},_OnChangeLockRaster:function(){var _78={};var _79=[];var _7a=[];var _7b=this._lockRaster.value.split(",");var _7c=_d(".mosaicRuleLayerlistCheckbox",this._layerList);_7c.forEach(function(_7d){_79.push(_7d.id);_7d.checked=false;});var i;var x;if(_7b.length>0){for(i=0;i<_7b.length;i++){if(_7b[i].length!==0&&!isNaN(_7b[i])){var idx=_4.indexOf(_79,_7b[i]);if(idx!==-1){x={};x.attributes={};x.attributes.OBJECTID=_7b[i];x.attributes.checked=1;_7a.push(x);}}}}var _7e;for(i=0;i<_79.length;i++){_7e=0;var j;for(j=0;j<_7a.length;j++){if(_79[i]===_7a[j].attributes.OBJECTID){_7e=1;}}if(_7e===0){x={};x.attributes={};x.attributes.OBJECTID=_79[i];x.attributes.checked=0;_7a.push(x);}}_78.catalogItems={};_78.catalogItems.features=_7a;_78.selectAll=0;if(_79.length===_7b.length){_78.selectAll=1;}this._showRastersInAOI(_78);},_OnClickCurrentExtent:function(){this._buildRasterList();},_OnClickApplyMosaic:function(){var _7f=[];if(this._MosaicRuleObject.method===_14.METHOD_LOCKRASTER){var _80=this._lockRaster.value.split(",");if(_80.length>0){var i;for(i=0;i<_80.length;i++){if(_80[i].length===0||isNaN(_80[i])){_80.splice(i,1);i--;}}if(_80.length===0){return;}for(i=0;i<_80.length;i++){_7f.push(parseInt(_80[i],10));}this._MosaicRuleObject.lockRasterIds=_7f;}else{return;}}if(this._MosaicRuleObject.method===_14.METHOD_ATTRIBUTE){if(this._fieldType[this._orderField.selectedIndex]==="esriFieldTypeSmallInteger"||this._fieldType[this._orderField.selectedIndex]==="esriFieldTypeInteger"||this._fieldType[this._orderField.selectedIndex]==="esriFieldTypeDouble"||this._fieldType[this._orderField.selectedIndex]==="esriFieldTypeSingle"){this._MosaicRuleObject.sortValue=_e.parse(this._orderValueText.value);}else{this._MosaicRuleObject.sortValue=_10.format(this._orderValueDate.get("value"),{datePattern:"yyyy/MM/dd"});}}if(this._where.value!=="<where>"&&this._where.value.length>1){this._MosaicRuleObject.where=this._where.value;}else{this._MosaicRuleObject.where=null;}this._internalApplyMosaic=true;this.layer.setMosaicRule(this._MosaicRuleObject);},_OnClickResetMosaic:function(){if(!this.layer){return;}this.layer.mosaicRule=null;this._mosaicRule.options.length=0;this._orderField.options.length=0;this._previousOrderFieldIndex=-1;this._initUsingServiceInfo(this.layer);this._OnClickApplyMosaic();},_OnChangeOrderField:function(){var _81=this._orderField.children[this._orderField.selectedIndex].value;this._MosaicRuleObject.sortField=_81;var _82=this._fieldType[this._orderField.selectedIndex];switch(_82){case "esriFieldTypeOID":case "esriFieldTypeInteger":case "esriFieldTypeSmallInteger":case "esriFieldTypeDouble":case "esriFieldTypeSingle":this._orderValueTextBlock.style.display="";this._showDateControl(false);this._orderValueText.value=this._getDefaultOrderFieldValue(_82,_81);break;case "esriFieldTypeDate":this._orderValueTextBlock.style.display="";this._showDateControl(true);var _83=this._getDefaultOrderFieldValue(_82,_81);this._orderValueDate.set("value",_83);break;default:this._orderValueTextBlock.style.display="none";this._showDateControl(false);}this._previousOrderFieldIndex=this._orderField.selectedIndex;},_getDefaultOrderFieldValue:function(_84,_85){if(this._previousOrderFieldIndex<0){if(_84==="esriFieldTypeDate"){if(this.layer.sortField&&_85.toLowerCase()===this.layer.sortField.toLowerCase()&&this.layer.sortValue){return new Date(this.layer.sortValue);}return new Date();}return "0";}var _86=this._fieldType[this._previousOrderFieldIndex];var _87=this._orderValueText.value;if(_86==="esriFieldTypeDate"){_87=new Date(this._orderValueDate.get("value"));}var _88;var _89;var _8a;if(this.layer.timeInfo){_88=this.layer.timeInfo.startTimeField;_89=this.layer.timeInfo.endTimeField;if(this.layer.timeInfo.timeExtent){_8a=this.layer.timeInfo.timeExtent.endTime;}}if(_86&&_86!==_84){if(this._isFieldNumeric(_84)){return "0";}else{if(_84==="esriFieldTypeDate"){if((_88&&_85.toLowerCase()===_88.toLowerCase())||(_89&&_85.toLowerCase()===_89.toLowerCase())){return _8a;}if(this.layer.sortField&&_85.toLowerCase()===this.layer.sortField.toLowerCase()&&this.layer.sortValue){return new Date(this.layer.sortValue);}return new Date();}}return "";}return _87;},_isFieldNumeric:function(_8b){var _8c=false;if(_8b==="esriFieldTypeOID"||_8b==="esriFieldTypeInteger"||_8b==="esriFieldTypeSmallInteger"||_8b==="esriFieldTypeDouble"||_8b==="esriFieldTypeSingle"){_8c=true;}return _8c;},_OnChangeMosaicOperator:function(){this._MosaicRuleObject.operation=this._esriStringMosaicOperatorToEnum(this._mosaicOperator.options[this._mosaicOperator.selectedIndex].value);},_OnClickDescending:function(){this._MosaicRuleObject.ascending=false;if(!this._descending.checked){this._MosaicRuleObject.ascending=true;}},_OnChangeMosaicRule:function(){var _8d=this._mosaicRule.options[this._mosaicRule.selectedIndex].value;this._populateMosaicOperatorsList(_8d);this._OnChangeMosaicOperator();this._graphicsLayer.clear();this._lockRasterBlock.style.display="";this._orderFieldBlock.style.display="";this._descendingBlock.style.display="";if(this._MosaicRuleObject.ascending===null){this._MosaicRuleObject.ascending=!this._descending.checked;}this._apply.value="APPLY";switch(_8d.toLowerCase()){case "none":this._MosaicRuleObject.lockRasterIds=null;this._MosaicRuleObject.sortField=null;this._MosaicRuleObject.sortValue=null;this._orderValueTextBlock.style.display="none";this._lockRasterBlock.style.display="none";this._orderFieldBlock.style.display="none";this._MosaicRuleObject.method=_14.METHOD_NONE;break;case "byattribute":this._MosaicRuleObject.sortField=this._orderField.options[this._orderField.selectedIndex].value;this._MosaicRuleObject.lockRasterIds=null;this._lockRasterBlock.style.display="none";this._OnChangeOrderField();this._MosaicRuleObject.method=_14.METHOD_ATTRIBUTE;break;case "center":this._MosaicRuleObject.sortField=null;this._MosaicRuleObject.sortValue=null;this._MosaicRuleObject.lockRasterIds=null;this._orderValueTextBlock.style.display="none";this._lockRasterBlock.style.display="none";this._orderFieldBlock.style.display="none";this._MosaicRuleObject.method=_14.METHOD_CENTER;break;case "nadir":this._MosaicRuleObject.sortField=null;this._MosaicRuleObject.sortValue=null;this._MosaicRuleObject.lockRasterIds=null;this._orderValueTextBlock.style.display="none";this._lockRasterBlock.style.display="none";this._orderFieldBlock.style.display="none";this._MosaicRuleObject.method=_14.METHOD_NADIR;break;case "viewpoint":this._MosaicRuleObject.sortField=null;this._MosaicRuleObject.sortValue=null;this._MosaicRuleObject.lockRasterIds=null;this._orderValueTextBlock.style.display="none";this._lockRasterBlock.style.display="none";this._orderFieldBlock.style.display="none";this._MosaicRuleObject.method=_14.METHOD_VIEWPOINT;break;case "lockraster":this._MosaicRuleObject.sortField=null;this._MosaicRuleObject.sortValue=null;this._orderValueTextBlock.style.display="none";this._orderFieldBlock.style.display="none";this._MosaicRuleObject.method=_14.METHOD_LOCKRASTER;break;case "northwest":this._MosaicRuleObject.sortField=null;this._MosaicRuleObject.sortValue=null;this._MosaicRuleObject.lockRasterIds=null;this._orderValueTextBlock.style.display="none";this._lockRasterBlock.style.display="none";this._orderFieldBlock.style.display="none";this._MosaicRuleObject.method=_14.METHOD_NORTHWEST;break;case "seamline":this._MosaicRuleObject.ascending=null;this._MosaicRuleObject.sortField=null;this._MosaicRuleObject.sortValue=null;this._MosaicRuleObject.lockRasterIds=null;this._orderValueTextBlock.style.display="none";this._lockRasterBlock.style.display="none";this._orderFieldBlock.style.display="none";this._descendingBlock.style.display="none";this._MosaicRuleObject.method=_14.METHOD_SEAMLINE;break;default:console.log("info not available");}},_OnChangeQueryOrderField:function(){this._where.value="";var _8e=this._queryOrderField.children[0].innerText;if(!_8e){_8e=this._queryOrderField.children[0].text;}if(_8e==="<None>"){this._queryOrderField.remove(0);}this._where.value=this._queryOrderField.options[this._queryOrderField.selectedIndex].text;if(this._queryOperator.options[this._queryOperator.selectedIndex].text!=="<None>"){this._where.value=this._where.value+" "+this._queryOperator.options[this._queryOperator.selectedIndex].text;}if(this._queryValue.value.length>0){this._where.value=this._where.value+" "+this._queryValue.value;}},_OnChangeQueryOperator:function(){this._where.value="";var _8f=this._queryOperator.children[0].innerText;if(!_8f){_8f=this._queryOperator.children[0].text;}if(_8f==="<None>"){this._queryOperator.remove(0);}if(this._queryOrderField.options[this._queryOrderField.selectedIndex].text!=="<None>"){this._where.value=this._queryOrderField.options[this._queryOrderField.selectedIndex].text;}this._where.value=this._where.value+" "+this._queryOperator.options[this._queryOperator.selectedIndex].text;if(this._queryValue.value.length>0){this._where.value=this._where.value+" "+this._queryValue.value;}},_OnKeyupQueryValue:function(){this._where.value="";if(this._queryOrderField.options[this._queryOrderField.selectedIndex].text!=="<None>"){this._where.value=this._queryOrderField.options[this._queryOrderField.selectedIndex].text;}if(this._queryOperator.options[this._queryOperator.selectedIndex].text!=="<None>"){this._where.value=this._where.value+" "+this._queryOperator.options[this._queryOperator.selectedIndex].text;}this._where.value=this._where.value+" "+this._queryValue.value;},_esriEnumMosaicMethodToString:function(_90){var _91="none";switch(_90){case _14.METHOD_ATTRIBUTE:_91="byattribute";break;case _14.METHOD_CENTER:_91="center";break;case _14.METHOD_LOCKRASTER:_91="lockraster";break;case _14.METHOD_NADIR:_91="nadir";break;case _14.METHOD_NORTHWEST:_91="northwest";break;case _14.METHOD_SEAMLINE:_91="seamline";break;case _14.METHOD_VIEWPOINT:_91="viewpoint";break;}return _91;},_esriStringMosaicMethodToEnum:function(_92){if(!_92){return;}var _93=_14.METHOD_NONE;switch(_92.toLowerCase()){case "byattribute":_93=_14.METHOD_ATTRIBUTE;break;case "center":_93=_14.METHOD_CENTER;break;case "lockraster":_93=_14.METHOD_LOCKRASTER;break;case "nadir":_93=_14.METHOD_NADIR;break;case "northwest":_93=_14.METHOD_NORTHWEST;break;case "seamline":_93=_14.METHOD_SEAMLINE;break;case "viewpoint":_93=_14.METHOD_VIEWPOINT;break;}return _93;},_esriStringMosaicOperatorToEnum:function(_94){if(!_94){return;}switch(_94.toLowerCase()){case "first":return _14.OPERATION_FIRST;case "last":return _14.OPERATION_LAST;case "max":return _14.OPERATION_MAX;case "min":return _14.OPERATION_MIN;case "blend":return _14.OPERATION_BLEND;case "mean":return _14.OPERATION_MEAN;}},_esriEnumMosaicOperatorToString:function(_95){var _96="first";switch(_95){case _14.OPERATION_FIRST:_96="first";break;case _14.OPERATION_LAST:_96="last";break;case _14.OPERATION_MAX:_96="max";break;case _14.OPERATION_MIN:_96="min";break;case _14.OPERATION_BLEND:_96="blend";break;case _14.OPERATION_MEAN:_96="mean";break;}return _96;},_mosaicMethodNameToAlias:function(_97){if(!_97){return;}var _98="";switch(_97.toLowerCase()){case "none":_98=this._i18n.widgets.mosaicRule.noneAlias;break;case "byattribute":_98=this._i18n.widgets.mosaicRule.byAttributeAlias;break;case "center":_98=this._i18n.widgets.mosaicRule.centerAlias;break;case "lockraster":_98=this._i18n.widgets.mosaicRule.lockRasterAlias;break;case "nadir":_98=this._i18n.widgets.mosaicRule.nadirAlias;break;case "northwest":_98=this._i18n.widgets.mosaicRule.northWestAlias;break;case "seamline":_98=this._i18n.widgets.mosaicRule.seamlineAlias;break;case "viewpoint":_98=this._i18n.widgets.mosaicRule.viewPointAlias;break;}return _98;},_hideAllControls:function(){this._mosaicRule.style.display="none";this._mosaicOperatorLabelBlock.style.display="none";this._mosaicOperatorBlock.style.display="none";this._orderFieldBlock.style.display="none";this._orderValueTextBlock.style.display="none";this._lockRasterBlock.style.display="none";this._descendingBlock.style.display="none";this._apply.style.display="none";},_showDateControl:function(_99){if(_99){this._orderValueDate.domNode.style.display="";this._orderValueText.style.display="none";}else{this._orderValueDate.domNode.style.display="none";this._orderValueText.style.display="";}}});if(_f("extend-esri")){_2.setObject("dijit.MosaicRule",_1f,_12);}return _1f;});