// 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/lang","dojo/_base/array"],function(f,g){return{transformOldConfigToNewConfigJson:function(a){var c={threats:[],generalSettings:{operationalLayer:{name:""},unit:"feet",defaultInputType:"interactive",layerToSelectFeatures:"",defaultThreatType:""}};a.hasOwnProperty("threatAnalysis")&&(a.threatAnalysis.hasOwnProperty("operationalLayer")&&a.threatAnalysis.operationalLayer.name&&(c.generalSettings.operationalLayer.name=a.threatAnalysis.operationalLayer.name),a.threatAnalysis.hasOwnProperty("unit")&&
(c.generalSettings.unit=a.threatAnalysis.unit));a.hasOwnProperty("threatTypes")&&g.forEach(a.threatTypes,f.hitch(this,function(b){c.threats.push(this._getConvertedThreatJson(b,!0,a.threatAnalysis.symbology))}));a.hasOwnProperty("lpgThreatTypes")&&g.forEach(a.lpgThreatTypes,f.hitch(this,function(b){c.threats.push(this._getConvertedThreatJson(b,!1,a.threatAnalysis.symbology))}));return c},_getConvertedThreatJson:function(a,c,b){var e=c?["Mandatory Evacuation Distance","Safe Evacuation Distance"]:["Fireball Diameter",
"Safe Distance"],d=c?[a.Bldg_Dist,a.Outdoor_Dist]:[a.Fireball_Dia,a.Safe_Dist];return{threatName:a.Threat,zones:[{name:e[0],distance:this._validateDistance(d[0]),symbol:{outlineColor:c?this._getSymbol(b.mandatoryOutlineColor):this._getSymbol(b.fireballDiaOutlineColor),fillColor:c?this._getSymbol(b.mandatoryFillColor):this._getSymbol(b.fireballDiaFillColor)}},{name:e[1],distance:this._validateDistance(d[1]),symbol:{outlineColor:c?this._getSymbol(b.safeOutlineColor):this._getSymbol(b.safeDistanceOutlineColor),
fillColor:c?this._getSymbol(b.safeFillColor):this._getSymbol(b.safeDistanceFillColor)}}]}},_getSymbol:function(a){return{color:a.color,transparency:a.transparency,type:a.type}},getDefaultThreats:function(a,c){var b=[],e=this._getDefaultSymbology();g.forEach(a,f.hitch(this,function(d){b.push(this._getConvertedThreatJson(d,!0,e))}));g.forEach(c,f.hitch(this,function(d){b.push(this._getConvertedThreatJson(d,!1,e))}));return b},_getDefaultSymbology:function(){return{mandatoryOutlineColor:{color:"#d10e40",
transparency:0,type:"esriSLSSolid"},mandatoryFillColor:{color:"#d10e40",transparency:.88,type:"esriSFSSolid"},safeOutlineColor:{color:"#ffffff",transparency:0,type:"esriSLSNull"},safeFillColor:{color:"#ffd700",transparency:.78,type:"esriSFSSolid"},fireballDiaOutlineColor:{color:"#d10e40",transparency:0,type:"esriSLSSolid"},fireballDiaFillColor:{color:"#d10e40",transparency:.88,type:"esriSFSSolid"},safeDistanceOutlineColor:{color:"#ffffff",transparency:0,type:"esriSLSNull"},safeDistanceFillColor:{color:"#ffd700",
transparency:.78,type:"esriSFSSolid"}}},_validateDistance:function(a){if(isNaN(a)||-1!==[null,void 0,""].indexOf(a)||0>=a)a=.01;return a}}});