text: TC.control=TC.control||{};TC.control.FeatureInfoCommons||TC.syncLoadJS(TC.apiLocation+"TC/control/FeatureInfoCommons");!function(){TC.control.FeatureInfo=function(){TC.control.FeatureInfoCommons.apply(this,arguments);this.wrap=new TC.wrap.control.FeatureInfo(this);TC.Consts.classes.FROMLEFT="tc-fromleft";TC.Consts.classes.FROMRIGHT="tc-fromright"};TC.inherit(TC.control.FeatureInfo,TC.control.FeatureInfoCommons);var e=TC.control.FeatureInfo.prototype,t=function e(t,r){var o;if(Array.isArray(t))for(var a=0,s=(o=t.slice()).length;a<s;a++)o[a]=e(o[a]);else o="number"==typeof t?Math.round(t.toFixed(r)):t;return o};e.register=function(e){const t=this;return new Promise(function(r,o){TC.control.FeatureInfoCommons.prototype.register.call(t,e).then(function(e){document.createElement("div").appendChild(t.div);r(e)},e=>o(e))})};e.callback=function(e,t){const r=this;r.querying=!0;const o=r.getElevationTool();o.then(function(t){t&&(r.elevationRequest=t.getElevation({crs:r.map.crs,coordinates:[e]}))});if(r.map&&r.filterLayer){var a=r.getLocaleString("featureInfo"),s=TC.Util.extend({},r.map.options.styles.marker,r.markerStyle,{title:a,set:a,showsPopup:!1});r.filterLayer.clearFeatures();r.highlightedFeature=null;r.filterFeature=null;r.filterLayer.addMarker(e,s).then(function(t){r.map.putLayerOnTop(r.filterLayer);r.filterFeature=t;o.then(function(e){r.renderResults({coords:t.geometry,displayElevation:e,loading:!0},function(){r.displayResults()})});for(var a=!1,s=0;s<r.map.workLayers.length;s++){var n=r.map.workLayers[s];if(n.type===TC.Consts.layerType.WMS&&n.getVisibility()&&n.names.length>0){a=!0;break}}var l=r.map.getResolution();a?r.wrap.getFeatureInfo(e,l):setTimeout(function(){r.responseCallback({coords:e})})})}};e.responseCallback=function(e){const r=this;TC.control.FeatureInfoCommons.prototype.responseCallback.call(r,e);if(r.filterFeature){var o=e.services;if(o)for(var a=0;a<o.length;a++){for(var s=o[a],n=0;n<s.layers.length;n++)if(!s.layers[n].features.length){s.layers.splice(n,1);n-=1}if(!s.layers.length){o.splice(a,1);a-=1}}r.info.defaultFeature=e.defaultFeature;r.elevationRequest&&(e.displayElevation=!0);r.renderResults(e,function(){r.insertLinks();if(r.sharedFeatureInfo){r.div.querySelectorAll("ul."+r.CLASS+"-services li").forEach(function(e){e.classList.add(TC.Consts.classes.CHECKED)});for(var e,o=r.sharedFeatureInfo,a=0,s=r.info.services.length;a<s;a++){var n=r.info.services[a];if(n.mapLayers.some(function(e){return e.url===o.s})){for(var l=0,i=n.layers.length;l<i;l++){var c=n.layers[l];if(c.name===o.l){for(var u=0,f=c.features.length;u<f;u++){var C=c.features[u];if(C.id===o.f){e=C;var d=hex_md5(JSON.stringify({data:C.getData(),geometry:t(C.geometry,TC.Consts.DEGREE_PRECISION)}));o.h!==d&&TC.alert(r.getLocaleString("finfo.featureChanged.warning"));break}}break}}break}}if(e){r.highlightedFeature=e;r.map.addLayer({id:r.getUID(),type:TC.Consts.layerType.VECTOR,title:r.getLocaleString("foi"),owner:r,stealth:!0}).then(function(t){r.sharedFeatureLayer=t;r.filterLayer.clearFeatures();r.filterFeature=null;t.addFeature(e);r.map.zoomToFeatures([e])})}delete r.sharedFeatureInfo}else r.displayResults();r.div.querySelectorAll("ul."+r.CLASS+"-services label, ul."+r.CLASS+"-services a").forEach(function(e){e.addEventListener(TC.Consts.event.CLICK,function(e){e.stopPropagation()},{passive:!0})})})}};e.displayResultsCallback=function(){const e=this;TC.control.FeatureInfoCommons.prototype.displayResultsCallback.call(e);if(e.elevationRequest){const t=e.getDisplayControl();e.getDisplayTarget().querySelectorAll(`.${e.CLASS}-elev,.${e.CLASS}-height`).forEach(e=>e.classList.add(TC.Consts.classes.HIDDEN));e.elevationRequest.then(function(r){if(t.currentFeature&&r.length){const o=t.currentFeature.geometry,a=r[0];if(o[0]===a[0]&&o[1]===a[1]){const t=r.length?r[0].slice(2):null;e.displayElevation(t)}}})}else e.querying||e.info&&e.info.services||e.closeResults()};e.renderResults=function(e,t){const r=this;if(r.filterFeature){const o=r.filterFeature.geometry;if(e.coords&&o[0]===e.coords[0]&&o[1]===e.coords[1]){e.isGeo=r.map.wrap.isGeo();if(e.coords){e.crs=r.map.crs;e.coords=e.coords.map(function(t){const r=e.isGeo?TC.Consts.DEGREE_PRECISION:TC.Consts.METER_PRECISION;return TC.Util.formatCoord(t,r)})}r.renderData(e,t)}}};e.displayElevation=function(e){let t,r;if(Array.isArray(e)){t=e[0];r=e.length>1?e[1]:null}else{t=e;r=null}const o=this.map.options.locale||TC.Cfg.locale;let a=null===t?"-":TC.Util.formatNumber(Math.round(t),o)+" m",s=r?r.toLocaleString(o,{maximumFractionDigits:1})+" m":"-";const n=this.getDisplayTarget().querySelector(`.${this.CLASS}-elev`),l=this.getDisplayTarget().querySelector(`.${this.CLASS}-height`);n.classList.toggle(TC.Consts.classes.HIDDEN,null===t);l.classList.toggle(TC.Consts.classes.HIDDEN,!r);n.querySelector(`.${this.CLASS}-coords-val`).innerHTML=a;l.querySelector(`.${this.CLASS}-coords-val`).innerHTML=s};e.loadSharedFeature=function(e){const t=this;if(e){if(0===t.map.workLayers.filter(function(t,r){return t.type===TC.Consts.layerType.WMS&&t.url===e.s&&t.getDisgregatedLayerNames().indexOf(e.l)>=0}).length){TC.error(t.getLocaleString("sharedFeatureNotValid"),TC.Consts.msgErrorMode.TOAST);return}t.sharedFeatureInfo=e;TC.loadJS(!window.hex_md5,[TC.apiLocation+TC.Consts.url.HASH],function(){const r=[-100,-100];t.beforeRequest({xy:r});t.filterLayer.clearFeatures();t.filterFeature=null;t.filterLayer.addMarker(r).then(function(r){t.filterFeature=r;t.wrap.getFeatureInfo(e.xy,e.r,{serviceUrl:e.s,layerName:e.l,featureId:e.f})})})}}}();
  //# sourceMappingURL=../maps/control/FeatureInfo.min.js.map