text: function tXml(e,t){"use strict";t=t||{};var r=0,a="<",i="<".charCodeAt(0),n=">",o=">".charCodeAt(0),s="-".charCodeAt(0),l="/".charCodeAt(0),u="!".charCodeAt(0),f="'".charCodeAt(0),c='"'.charCodeAt(0),p="[".charCodeAt(0),h="]".charCodeAt(0);function d(){for(var t=[];e[r];){if(e.charCodeAt(r)==i){if(e.charCodeAt(r+1)===l){r=e.indexOf(n,r);return t}if(e.charCodeAt(r+1)===u){var a=e.charCodeAt(r+2);if(a!=p){if(a==s){for(;-1!==r&&(e.charCodeAt(r)!==o||e.charCodeAt(r-1)!=s||e.charCodeAt(r-2)!=s||-1==r);)r=e.indexOf(n,r+1);-1===r&&(r=e.length)}else{r+=2;for(;e.charCodeAt(r)!==o;)r++}r++;continue}}var f=C();t.push(f)}else{var c=y();c.trim().length>0&&t.push(c)}r++}return t}function y(){var t=r;-2===(r=e.indexOf(a,r)-1)&&(r=e.length);return e.slice(t,r+1)}var g="\n\t>/= ";function m(){for(var t=r,a=e[r];-1===g.indexOf(a);)":"===(a=e[++r])&&(t=++r);return e.slice(t,r)}var v=["img","br","input","meta","link"];function C(){var t={};r++;if(e.charCodeAt(r)===u&&e.charCodeAt(r+1)===p){for(var a=r+8;e.charCodeAt(r)!==o||e.charCodeAt(r-1)!==h||e.charCodeAt(r-2)!==h;)r++;return e.slice(a,r-2)}t.tagName=m();for(var i=!1;e.charCodeAt(r)!==o;){var n=e.charCodeAt(r);if(n>64&&n<91||n>96&&n<123){for(var s=m(),y=e.charCodeAt(r);y!==f&&y!==c&&!(y>64&&y<91||y>96&&y<123)&&y!==o;){r++;y=e.charCodeAt(r)}if(!i){t.attributes={};i=!0}if(y===f||y===c)var g=T();else{g=null;r--}t.attributes[s]=g}r++}if(e.charCodeAt(r-1)!==l)if("script"==t.tagName){a=r+1;r=e.indexOf("<\/script>",r);t.children=[e.slice(a,r-1)];r+=8}else if("style"==t.tagName){a=r+1;r=e.indexOf("</style>",r);t.children=[e.slice(a,r-1)];r+=7}else if(-1==v.indexOf(t.tagName)){r++;t.children=d()}return t}function T(){var t=e[r],a=++r;r=e.indexOf(t,a);return e.slice(a,r)}var x,F=null;if(void 0!==t.attrValue){t.attrName=t.attrName||"id";for(F=[];-1!==(r=(x=void 0,(x=new RegExp("\\s"+t.attrName+"\\s*=['\"]"+t.attrValue+"['\"]").exec(e))?x.index:-1));){-1!==(r=e.lastIndexOf("<",r))&&F.push(C());e=e.substr(r);r=0}}else F=d();t.filter&&(F=tXml.filter(F,t.filter));t.simplify&&(F=tXml.simplify(F));return F}tXml.simplify=function(e){var t={};if(!e||!e.length)return"";if(1===e.length&&"string"==typeof e[0])return e[0];e.forEach(function(e){if("object"==typeof e){t[e.tagName]||(t[e.tagName]=[]);var r=tXml.simplify(e.children);t[e.tagName].push(r);e.attributes&&(r._attributes=e.attributes)}});for(var r in t)1==t[r].length&&(t[r]=t[r][0]);return t};tXml.filter=function(e,t){var r=[];e.forEach(function(e){"object"==typeof e&&t(e)&&r.push(e);if(e.children){var a=tXml.filter(e.children,t);r=r.concat(a)}});return r};tXml.stringify=function(e){var t="";function r(e){if(e)for(var r=0;r<e.length;r++)"string"==typeof e[r]?t+=e[r].trim():a(e[r])}function a(e){t+="<"+e.tagName;for(var a in e.attributes)null===e.attributes[a]?t+=" "+a:-1===e.attributes[a].indexOf('"')?t+=" "+a+'="'+e.attributes[a].trim()+'"':t+=" "+a+"='"+e.attributes[a].trim()+"'";t+=">";r(e.children);t+="</"+e.tagName+">"}r(e);return t};tXml.toContentString=function(e){if(Array.isArray(e)){var t="";e.forEach(function(e){t=(t+=" "+tXml.toContentString(e)).trim()});return t}return"object"==typeof e?tXml.toContentString(e.children):" "+e};tXml.getElementById=function(e,t,r){var a=tXml(e,{attrValue:t,simplify:r});return r?a:a[0]};tXml.getElementsByClassName=function(e,t,r){return tXml(e,{attrName:"class",attrValue:"[a-zA-Z0-9-s ]*"+t+"[a-zA-Z0-9-s ]*",simplify:r})};"object"==typeof module&&(module.exports=tXml);!function(){var e,t,r,a,i,n,o,s,l,u,f,c=function(e){return e.href},p=function(e,t){if(e.hasOwnProperty(t)){for(var r=e[t],a=r.length?r:[r],i=0,n=a.length;i<n;i++){var o=a[i];o.OnlineResource=c(o.OnlineResource)}e[t]=a}},h=[!1,!0],d=function(e){return e.split(" ").map(function(e){return parseFloat(e)})},y=function(e){for(var t=e.length?e:[e],r=new Array(t.length),a=0,i=t.length;a<i;a++){var n=t[a];if(!n.Constraint.length){n.Constraint=[n.Constraint];for(var o=0,s=n.Constraint.length;o<s;o++){var l=n.Constraint[o].AllowedValues;"string"==typeof l.Value&&(l.Value=[l.Value])}}r[a]={Constraint:n.Constraint,href:n.href}}return r},g=(e=["name","Name"],t=["Parameter","Constraint"],r=function(t){return t.reduce(function(t,r,a){if(e.some(e=>r.hasOwnProperty(e))){var i=e.find(e=>r.hasOwnProperty(e)),n=r[i].substring(r[i].indexOf(":")+1);delete r[i];t[n]=r.hasOwnProperty("AllowedValues")&&r.AllowedValues.Value||r;return t}return(0===a?[]:t).concat(r)},{})},a=function(t){var a={};return a=t instanceof Array?r(t):t.hasOwnProperty("AllowedValues")&&t.AllowedValues.Value&&e.find(e=>t.hasOwnProperty(e))&&(a[t[e.find(e=>t.hasOwnProperty(e))]]=t.AllowedValues.Value)&&a||t},i="1.0.0",n="1.1.0",o="2.0.0",s=function(e,s){switch(s){case i:var l=e.Capability.Request;if(l.GetFeature){var u=[];for(var f in l.GetFeature.ResultFormat)u.push(f.toLowerCase());l.GetFeature.outputFormat=u,delete l.GetFeature.ResultFormat,l.GetFeature.Operations=e.FeatureTypeList.Operations}return l;case n:return{};case o:var c={};for(var f in e.OperationsMetadata){var p={};if(e.OperationsMetadata[f]instanceof Array){p[f]=r(e.OperationsMetadata[f]);for(var h in p[f])p[f][h]=(e=>{var i={};if(e instanceof Array)return r(e);for(k in e)t.find(e=>k===e)?i=Object.assign(i,a(e[t.find(e=>k===e)])):i[k]=e[k];return i})(p[f][h]);c=Object.assign(c,p[f])}}return c}return null},l=function(e,t){switch(t){case i:e.FeatureTypeList.FeatureType=e.FeatureTypeList.FeatureType instanceof Array?e.FeatureTypeList.FeatureType:[e.FeatureTypeList.FeatureType];for(var r={},a=0;a<e.FeatureTypeList.FeatureType.length;a++){r[(s=e.FeatureTypeList.FeatureType[a].Name).substring(s.indexOf(":")+1)]=e.FeatureTypeList.FeatureType[a]}return r;case n:return{};case o:e.FeatureTypeList.FeatureType=e.FeatureTypeList.FeatureType instanceof Array?e.FeatureTypeList.FeatureType:[e.FeatureTypeList.FeatureType];for(r={},a=0;a<e.FeatureTypeList.FeatureType.length;a++){var s;r[(s=e.FeatureTypeList.FeatureType[a].Name).substring(s.indexOf(":")+1)]=e.FeatureTypeList.FeatureType[a]}return r}return null},u=function(e,t){switch(t){case i:return e.Filter_Capabilities;case n:return{};case o:return e.Filter_Capabilities}return null},f=function(e,t){switch(t){case i:var r={};for(var a in e)"string"==typeof e[a]&&(r[a]=e[a]);return r;case n:return{};case o:r={};for(var a in e)"string"==typeof e[a]&&(r[a]=e[a]);return r}return{}},{Promises:function(e){var t=(e=e).substring(e.indexOf("://")<0?0:e.indexOf("://")+3);if(TC.capabilities[t])return Promise.resolve(TC.capabilities[t]);var r={SERVICE:"WFS",VERSION:"2.0.0",REQUEST:"GetCapabilities"};return new Promise(function(a,i){TC.ajax({url:TC.proxify(e)+"?"+TC.Util.getParamString(r),method:"GET"}).then(function(e){var r=WFSCapabilities.Parse(e.data),i=r.Operations.GetCapabilities.DCP&&r.Operations.GetCapabilities.DCP.HTTP.Get["xlink:href"]||r.Operations.GetCapabilities.DCPType[0].HTTP.Get.onlineResource;TC.capabilities[i]=r,TC.capabilities[t]=r,a(WFSCapabilities.Parse(e.data))})})},Parse:function(){var e,t,r,a,c=arguments[0];switch(c.version){case i:e=i;break;case n:e=n;break;case o:e=o}t=s(c,e),r=l(c,e),a=u(c,e);var p=f(c,e),h={Operations:t,FeatureTypes:r,Filters:a};return Object.assign(h,p),h}}),m=function(e){var t=e.WMS_Capabilities||e["?xml"]&&(e["?xml"].WMS_Capabilities||e["?xml"].WMT_MS_Capabilities);if(t){!function e(t,r){t.hasOwnProperty("queryable")&&(t.queryable=h[t.queryable]);var a;if(t.hasOwnProperty("EX_GeographicBoundingBox")){a=t.EX_GeographicBoundingBox;t.EX_GeographicBoundingBox=[parseFloat(a.westBoundLongitude),parseFloat(a.southBoundLatitude),parseFloat(a.eastBoundLongitude),parseFloat(a.northBoundLatitude)]}if(t.hasOwnProperty("BoundingBox")){a=t.BoundingBox;a=t.BoundingBox.length?t.BoundingBox:[t.BoundingBox];t.BoundingBox=a.map(function(e){return{crs:e.CRS,extent:[parseFloat(e.minx),parseFloat(e.miny),parseFloat(e.maxx),parseFloat(e.maxy)],res:new Array(2)}})}t.hasOwnProperty("Attribution")&&t.Attribution.OnlineResource&&(t.Attribution.OnlineResource=c(t.Attribution.OnlineResource));p(t,"AuthorityURL");p(t,"MetadataURL");if(t.Style){t.Style.length||(t.Style=[t.Style]);for(var i=0,n=t.Style.length;i<n;i++)p(t.Style[i],"LegendURL")}var o="string"==typeof t.CRS?[t.CRS]:t.CRS;r&&t.CRS&&(t.CRS=o.concat(r));if(t.Layer){var s=t.Layer[1]?t.Layer:[t.Layer];t.Layer=s;for(i=0,n=s.length;i<n;i++)e(s[i],o)}}(t.Capability.Layer);var r=t.Capability.Request;!function(e){if(e){for(var t=e.DCPType.length?e.DCPType:[e.DCPType],r=0,a=t.length;r<a;r++){var i=t[r];for(var n in i){var o=i[n];for(var s in o){var l=o[s];l.OnlineResource=c(l.OnlineResource)}}}e.DCPType=t}}(r.GetMap);r.GetFeatureInfo&&(r.GetFeatureInfo.Format="string"==typeof r.GetFeatureInfo.Format?[r.GetFeatureInfo.Format]:r.GetFeatureInfo.Format)}return t},v=function(e){var t=e["?xml"]&&e["?xml"].Capabilities;if(t){!function(e){e.Layer.length||(e.Layer=[e.Layer]);for(var t=e.Layer,r=0,a=t.length;r<a;r++){var i=t[r];"string"==typeof i.Format&&(i.Format=[i.Format]);i.ResourceURL&&!i.ResourceURL.length&&(i.ResourceURL=[i.ResourceURL]);i.Style.length||(i.Style=[i.Style]);i.TileMatrixSetLink.length||(i.TileMatrixSetLink=[i.TileMatrixSetLink]);for(var n=0,o=i.TileMatrixSetLink.length;n<o;n++){var s=i.TileMatrixSetLink[n];if(s.TileMatrixSetLimits){s.TileMatrixSetLimits=s.TileMatrixSetLimits.TileMatrixLimits;for(var l=0,u=s.TileMatrixSetLimits.length;l<u;l++){var f=s.TileMatrixSetLimits[l];f.MaxTileCol=parseInt(f.MaxTileCol);f.MaxTileRow=parseInt(f.MaxTileRow);f.MinTileCol=parseInt(f.MinTileCol);f.MinTileRow=parseInt(f.MinTileRow)}}else s.TileMatrixSetLimits=[]}if(i.WGS84BoundingBox){var c=d(i.WGS84BoundingBox.LowerCorner),p=d(i.WGS84BoundingBox.UpperCorner);i.WGS84BoundingBox=[c[0],c[1],p[0],p[1]]}}}(t.Contents);!function(e){e.TileMatrixSet.length||(e.TileMatrixSet=[e.TileMatrixSet]);for(var t=e.TileMatrixSet,r=0,a=t.length;r<a;r++){var i=t[r];i.SupportedCRS=i.SupportedCRS.trim();for(var n=0,o=i.TileMatrix.length;n<o;n++){var s=i.TileMatrix[n];s.MatrixHeight=parseInt(s.MatrixHeight);s.MatrixWidth=parseInt(s.MatrixWidth);s.TileHeight=parseInt(s.TileHeight);s.TileWidth=parseInt(s.TileWidth);s.ScaleDenominator=parseFloat(s.ScaleDenominator);s.TopLeftCorner=d(s.TopLeftCorner)}}}(t.Contents);!function(e){for(var t=e.Operation.length?e.Operation:[e.Operation],r=0,a=t.length;r<a;r++){var i=t[r];for(var n in i.DCP){var o=i.DCP[n];for(var s in o)o[s]=y(o[s])}e[i.name]={DCP:i.DCP}}delete e.Operation}(t.OperationsMetadata)}return t};onmessage=function(e){var t,r=function e(t,r){var a={};if(!(t&&t.length||r))return"";if(1===(t=t||[]).length&&"string"==typeof t[0])return t[0];t.forEach(function(t){if("object"==typeof t){var r=t.tagName.indexOf("ows:"),i=r<0?t.tagName:t.tagName.substr(r+4);a[i]||(a[i]=[]);var n=e(t.children,t.attributes);a[i].push(n);if(t.attributes)for(var o in t.attributes)n[o]=t.attributes[o]}});for(var i in a)1==a[i].length&&(a[i]=a[i][0]);return a}(tXml(e.data.text));switch(e.data.type){case"WMS":t=m(r);break;case"WMTS":t=v(r);break;case"WFS":t=function(e){var t=e.WFS_Capabilities||e["?xml"]&&e["?xml"].WFS_Capabilities;if(t){t=g.Parse(t);for(var r in t)if("string"==typeof t[r]&&0===t[r].indexOf("http")){t["xmlns:"+r]=t[r];delete t[r]}delete t.updateSequence}return t}(r)}postMessage({state:t?"success":"error",capabilities:t})}}();
  //# sourceMappingURL=../maps/workers/tc-caps-web-worker.min.js.map