// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://js.arcgis.com/3.23/esri/copyright.txt for details.
//>>built
define("esri/dijit/geoenrichment/utils/JsonXmlConverter",["dojo/_base/declare"],function(q){function l(a){return String(a).replace(/&/g,"\x26amp;").replace(/</g,"\x26lt;").replace(/>/g,"\x26gt;")}function m(a,b){return void 0!==a?!1===b?l(a):l(a).replace(/"/g,"\x26quot;").replace(/'/g,"\x26apos;"):""}function n(a){return void 0!==a?String(a).replace(/&apos;/g,"'").replace(/&quot;/g,'"').replace(/&gt;/g,"\x3e").replace(/&lt;/g,"\x3c").replace(/&amp;/g,"\x26"):""}function r(a,b,c,d){return g(c,d)+"\x3c"+
a+(b?p(b):"")+"\x3e"}function t(a,b,c){return g(b,c)+"\x3c/"+a+"\x3e"+(c?"\n":"")}function u(a,b,c,d){return g(c,d)+"\x3c"+a+(b?p(b):"")+" /\x3e"+(d?"\n":"")}function v(a,b,c){a=m(a,!1);return g(b,c)+a+(c?"\n":"")}function p(a){var b="",c;for(c in a){var d=a[c];Array.isArray(d)&&(d=d.join(";"));void 0!==d&&(b+=" "+c+'\x3d"'+m(d)+'"')}return b}function g(a,b){if(!b)return"";for(var c="",d=0;d<a;d++)c+="     ";return c}return q(null,{parseJson:function(a,b){function c(a,b){a.text||"#text"==a.name?f+=
v(a.text,b,d):a.name&&(a.tags&&a.tags.length?(f+=r(a.name,a.attributes,b,d),a.tags&&a.tags.forEach(function(a){c(a,b+1)}),f+=t(a.name,b,d)):f+=u(a.name,a.attributes,b,d))}var d=b&&b.prettify,f="";b&&b.addDocumentOptions&&(f+='\x3c?xml version\x3d"1.0" encoding\x3d"utf-8"?\x3e');c(a,0);return f=decodeURIComponent(encodeURIComponent(f).replace("%19",""))},parseXml:function(a,b){function c(a,b){a.name=b.nodeName;a.innerHTML=b.innerHTML;if(b.attributes&&b.attributes.length){a.attributes={};for(var h=
0;h<b.attributes.length;h++){var g=b.attributes[h],e=g.value;if(!0===e||"true"===e)e=!0;else if(!1===e||"false"===e)e=!1;else if(d&&e){var k=Number(e);isNaN(k)||(e=k)}a.attributes[g.nodeName]=e}}if(b.childNodes&&b.childNodes.length)for(a.tags=[],h=0;h<b.childNodes.length;h++){if(e=g=b.childNodes[h],"#text"!=e.nodeName||(f?e.nodeValue.trim():e.nodeValue))e={},a.tags.push(e),c(e,g)}else"#text"==b.nodeName&&(a.text=n(b.nodeValue))}var d=b&&b.parseNumbers,f=b&&b.ignoreWhiteSpacedTextNodes,f=void 0===
f?!0:f,g=(new DOMParser).parseFromString(a,"text/xml"),k={};c(k,g.childNodes[0]);return k},queryJson:function(a,b,c){function d(a,g){a.tags&&a.tags.forEach(function(a){(b.test?b.test(a.name):a.name==b)&&f.push(a);c&&0==g||d(a,g+1)})}var f=[];d(a,0);return f},getInnerHTML:function(a){return a.innerHTML?a.innerHTML.trim():this.parseJson(a).replace(/^<[^<]*>/,"").replace(/<\/[^<]*>$/,"").trim()},_IS_RICH_RE:/<.+>.*<\/.+>|<br\s*\/>|<\/br>/,_UNRICH_RE:/<.{1,3}>|<\/.{1,3}>|<br\s*\/>|<\/br>/g,isRichText:function(a){return(a=
String(a))&&this._IS_RICH_RE.test(a)},unrichHTML:function(a){if(!a)return"";a=n(String(a).trim()).replace(this._UNRICH_RE,"");0===a.indexOf("\x3c")&&-1!==a.indexOf("\x3e")&&(a="");return a}})()});