UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

1 lines • 27.1 kB
"use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[309],{13043(e,t,i){function r(e,t){if(e&&t)for(const i of e.children)if(i.localName in t){const e=t[i.localName];if("function"==typeof e){const t=e(i);t&&r(i,t)}else r(i,e)}}function*s(e,t){for(const i of e.children)if(i.localName in t){const e=t[i.localName];"function"==typeof e?yield e(i):yield*s(i,e)}}i.d(t,{i:()=>s,p:()=>r})},20309(e,t,i){i.r(t),i.d(t,{default:()=>de});var r,s=i(5482),l=i(11254),o=i(4576),n=i(7762),a=i(49186),c=i(4718),u=i(25728),p=i(74887),d=i(36708),m=i(84952),h=i(91429),y=i(5443),f=i(4146),g=i(47314),w=i(63074),v=i(16131),M=i(8303),x=i(54310),C=i(25036),I=i(33446),S=i(87045),T=i(65509),L=i(83703),A=i(25482);let b=r=class extends A.o{constructor(e){super(e),this.fullExtent=null,this.id=null,this.tileInfo=null}clone(){const e=new r;return this.hasOwnProperty("fullExtent")&&(e.fullExtent=this.fullExtent?.clone()??null),this.hasOwnProperty("id")&&(e.id=this.id),this.hasOwnProperty("tileInfo")&&(e.tileInfo=this.tileInfo?.clone()??null),e}};(0,s.Cg)([(0,h.MZ)({type:y.A,json:{read:{source:"fullExtent"}}})],b.prototype,"fullExtent",void 0),(0,s.Cg)([(0,h.MZ)({type:String,json:{read:{source:"id"}}})],b.prototype,"id",void 0),(0,s.Cg)([(0,h.MZ)({type:S.A,json:{read:{source:"tileInfo"}}})],b.prototype,"tileInfo",void 0),b=r=(0,s.Cg)([(0,h.$K)("esri.layers.support.TileMatrixSet")],b);const P=b;var E;let O=E=class extends A.o{constructor(e){super(e),this.id=null,this.title=null,this.description=null,this.legendUrl=null}clone(){const e=new E;return this.hasOwnProperty("description")&&(e.description=this.description),this.hasOwnProperty("id")&&(e.id=this.id),this.hasOwnProperty("isDefault")&&(e.isDefault=this.isDefault),this.hasOwnProperty("keywords")&&(e.keywords=this.keywords&&this.keywords.slice()),this.hasOwnProperty("legendUrl")&&(e.legendUrl=this.legendUrl),this.hasOwnProperty("title")&&(e.title=this.title),e}};(0,s.Cg)([(0,h.MZ)({json:{read:{source:"id"}}})],O.prototype,"id",void 0),(0,s.Cg)([(0,h.MZ)({json:{read:{source:"title"}}})],O.prototype,"title",void 0),(0,s.Cg)([(0,h.MZ)({json:{read:{source:"abstract"}}})],O.prototype,"description",void 0),(0,s.Cg)([(0,h.MZ)({json:{read:{source:"legendUrl"}}})],O.prototype,"legendUrl",void 0),(0,s.Cg)([(0,h.MZ)({json:{read:{source:"isDefault"}}})],O.prototype,"isDefault",void 0),(0,s.Cg)([(0,h.MZ)({json:{read:{source:"keywords"}}})],O.prototype,"keywords",void 0),O=E=(0,s.Cg)([(0,h.$K)("esri.layers.support.WMTSStyle")],O);const R=O;var F,Z=i(36005);let V=F=class extends A.o{constructor(e){super(e),this.description=null,this.fullExtent=null,this.fullExtents=null,this.id=null,this.imageFormats=null,this.layer=null,this.parent=null,this.styles=null,this.title=null,this.tileMatrixSetId=null,this.tileMatrixSets=null}readFullExtent(e,t){return(e=t.fullExtent)?y.A.fromJSON(e):null}readFullExtents(e,t){return t.fullExtents?.length?t.fullExtents.map(e=>y.A.fromJSON(e)):t.tileMatrixSets?.map(e=>y.A.fromJSON(e.fullExtent)).filter(e=>e)??[]}get imageFormat(){let e=this._get("imageFormat");return e||(e=this.imageFormats?.length?this.imageFormats[0]:""),e}set imageFormat(e){const t=this.imageFormats;e&&(e.includes("image/")||t&&!t.includes(e))&&(e.includes("image/")||(e="image/"+e),t&&!t.includes(e))?console.error("The layer doesn't support the format of "+e):this._set("imageFormat",e)}get styleId(){let e=this._get("styleId");return e||(e=this.styles?.at(0)?.id??""),e}set styleId(e){this._set("styleId",e)}get tileMatrixSet(){return this.tileMatrixSets?.find(({id:e})=>e===this.tileMatrixSetId)??null}clone(){const e=new F;return this.hasOwnProperty("description")&&(e.description=this.description),this.hasOwnProperty("imageFormats")&&(e.imageFormats=this.imageFormats?.slice()??null),this.hasOwnProperty("imageFormat")&&(e.imageFormat=this.imageFormat),this.hasOwnProperty("fullExtent")&&(e.fullExtent=this.fullExtent?.clone()),this.hasOwnProperty("id")&&(e.id=this.id),this.hasOwnProperty("layer")&&(e.layer=this.layer),this.hasOwnProperty("styleId")&&(e.styleId=this.styleId),this.hasOwnProperty("styles")&&(e.styles=this.styles?.clone()),this.hasOwnProperty("tileMatrixSetId")&&(e.tileMatrixSetId=this.tileMatrixSetId),this.hasOwnProperty("tileMatrixSets")&&(e.tileMatrixSets=this.tileMatrixSets?.clone()),this.hasOwnProperty("title")&&(e.title=this.title),e}};(0,s.Cg)([(0,h.MZ)()],V.prototype,"description",void 0),(0,s.Cg)([(0,h.MZ)({type:y.A})],V.prototype,"fullExtent",void 0),(0,s.Cg)([(0,Z.w)("fullExtent",["fullExtent"])],V.prototype,"readFullExtent",null),(0,s.Cg)([(0,h.MZ)({readOnly:!0})],V.prototype,"fullExtents",void 0),(0,s.Cg)([(0,Z.w)("fullExtents",["fullExtents","tileMatrixSets"])],V.prototype,"readFullExtents",null),(0,s.Cg)([(0,h.MZ)()],V.prototype,"id",void 0),(0,s.Cg)([(0,h.MZ)()],V.prototype,"imageFormat",null),(0,s.Cg)([(0,h.MZ)({json:{read:{source:"formats"}}})],V.prototype,"imageFormats",void 0),(0,s.Cg)([(0,h.MZ)()],V.prototype,"layer",void 0),(0,s.Cg)([(0,h.MZ)()],V.prototype,"parent",void 0),(0,s.Cg)([(0,h.MZ)()],V.prototype,"styleId",null),(0,s.Cg)([(0,h.MZ)({type:n.A.ofType(R),json:{read:{source:"styles"}}})],V.prototype,"styles",void 0),(0,s.Cg)([(0,h.MZ)({json:{write:{ignoreOrigin:!0}}})],V.prototype,"title",void 0),(0,s.Cg)([(0,h.MZ)()],V.prototype,"tileMatrixSetId",void 0),(0,s.Cg)([(0,h.MZ)({readOnly:!0})],V.prototype,"tileMatrixSet",null),(0,s.Cg)([(0,h.MZ)({type:n.A.ofType(P),json:{read:{source:"tileMatrixSets"}}})],V.prototype,"tileMatrixSets",void 0),V=F=(0,s.Cg)([(0,h.$K)("esri.layers.support.WMTSSublayer")],V);var U=i(73941),j=i(86738),_=i(22530),N=i(38458),k=i(13043),D=i(91806);const W=90.71428571428571;function K(e){const t=e.replaceAll(/ows:/gi,"");return(new DOMParser).parseFromString(t,"text/xml")}function B(e){if(!H("Contents",e.documentElement))throw new a.A("wmtslayer:wmts-capabilities-xml-is-not-valid","the wmts get capabilities response is not compliant")}function $(e){return e.nodeType===Node.ELEMENT_NODE}function H(e,t){for(let i=0;i<t.childNodes.length;i++){const r=t.childNodes[i];if($(r)&&r.nodeName===e)return r}return null}function J(e,t){const i=[];for(let r=0;r<t.childNodes.length;r++){const s=t.childNodes[r];$(s)&&s.nodeName===e&&i.push(s)}return i}function q(e,t){const i=[];for(let r=0;r<t.childNodes.length;r++){const s=t.childNodes[r];$(s)&&s.nodeName===e&&i.push(s)}return i.map(e=>e.textContent).filter(o.Ru)}function G(e,t){return e.split(">").forEach(e=>{t&&(t=H(e,t))}),t&&t.textContent}function z(e,t,i,r){let s;return Array.prototype.slice.call(r.childNodes).some(r=>{if(r.nodeName.includes(e)){const e=H(t,r),l=e?.textContent;if(l===i||i.split(":")&&i.split(":")[1]===l)return s=r,!0}return!1}),s}function Q(e,t,i,r,s){const l=G("Abstract",t),o=q("Format",t);return{id:e,fullExtent:Y(t),fullExtents:ee(t),description:l,formats:o,styles:te(t,r),title:G("Title",t),tileMatrixSets:ie(s,t,i)}}function X(e,t){const i=[],r=e.layerMap?.get(t);if(!r)return null;const s=J("ResourceURL",r),l=J("Dimension",r);let o,n,a,c;return l.length&&(o=G("Identifier",l[0]),n=q("Default",l[0])||q("Value",l[0])),l.length>1&&(a=G("Identifier",l[1]),c=q("Default",l[1])||q("Value",l[1])),e.dimensionMap.set(t,{dimensions:n,dimensions2:c}),s.forEach(e=>{let t=e.getAttribute("template");if("tile"===e.getAttribute("resourceType")){if(o&&n.length)if(t.includes("{"+o+"}"))t=t.replace("{"+o+"}","{dimensionValue}");else{const e=t.toLowerCase().indexOf("{"+o.toLowerCase()+"}");e>-1&&(t=t.slice(0,e)+"{dimensionValue}"+t.slice(e+o.length+2))}if(a&&c.length)if(t.includes("{"+a+"}"))t=t.replace("{"+a+"}","{dimensionValue2}");else{const e=t.toLowerCase().indexOf("{"+a.toLowerCase()+"}");e>-1&&(t=t.slice(0,e)+"{dimensionValue2}"+t.slice(e+a.length+2))}i.push({template:t,format:e.getAttribute("format"),resourceType:"tile"})}}),i}function Y(e){const t=H("WGS84BoundingBox",e),i=t?G("LowerCorner",t).split(" "):["-180","-90"],r=t?G("UpperCorner",t).split(" "):["180","90"];return{xmin:parseFloat(i[0]),ymin:parseFloat(i[1]),xmax:parseFloat(r[0]),ymax:parseFloat(r[1]),spatialReference:{wkid:4326}}}function ee(e){const t=[];return(0,k.p)(e,{BoundingBox:e=>{if(!e.getAttribute("crs"))return;const i=e.getAttribute("crs").toLowerCase(),r=re(i),s=i.includes("epsg")&&(0,N.m)(r.wkid);let l,o,n,a;(0,k.p)(e,{LowerCorner:e=>{[l,o]=e.textContent.split(" ").map(e=>Number.parseFloat(e)),s&&([l,o]=[o,l])},UpperCorner:e=>{[n,a]=e.textContent.split(" ").map(e=>Number.parseFloat(e)),s&&([n,a]=[a,n])}}),t.push({xmin:l,ymin:o,xmax:n,ymax:a,spatialReference:r})}}),t}function te(e,t){return J("Style",e).map(e=>{const i=H("LegendURL",e),r=H("Keywords",e),s=r?q("Keyword",r):[];let l=i?.getAttribute("xlink:href");return t&&(l=l?.replace(/^http:/i,"https:")),{abstract:G("Abstract",e),id:G("Identifier",e),isDefault:"true"===e.getAttribute("isDefault"),keywords:s,legendUrl:l,title:G("Title",e)}})}function ie(e,t,i){return J("TileMatrixSetLink",t).map(t=>function(e,t,i){const r=H("TileMatrixSet",t).textContent,s=q("TileMatrix",t),l=i.find(e=>{const t=H("Identifier",e),i=t?.textContent;return!!(i===r||r.split(":")&&r.split(":")[1]===i)}),o=H("TileMatrixSetLimits",t),n=o&&J("TileMatrixLimits",o),a=new Map;if(n?.length)for(const e of n){const t=H("TileMatrix",e).textContent,i=+H("MinTileRow",e).textContent,r=+H("MaxTileRow",e).textContent,s=+H("MinTileCol",e).textContent,l=+H("MaxTileCol",e).textContent;a.set(t,{minCol:s,maxCol:l,minRow:i,maxRow:r})}const c=G("SupportedCRS",l).toLowerCase(),u=function(e,t){return se(H("TileMatrix",e),t)}(l,c),p=u.spatialReference,d=H("TileMatrix",l),m=[parseInt(G("TileWidth",d),10),parseInt(G("TileHeight",d),10)],h=[];s.length?s.forEach((e,t)=>{const i=z("TileMatrix","Identifier",e,l);h.push(le(i,c,t,r,a))}):J("TileMatrix",l).forEach((e,t)=>{h.push(le(e,c,t,r,a))});const f=function(e,t,i,r,s){const l=H("BoundingBox",t);let o,n,a,c,u,p;if(l&&(o=G("LowerCorner",l).split(" "),n=G("UpperCorner",l).split(" ")),o&&o.length>1&&n&&n.length>1)a=parseFloat(o[0]),u=parseFloat(o[1]),c=parseFloat(n[0]),p=parseFloat(n[1]);else{const e=H("TileMatrix",t),l=parseInt(G("MatrixWidth",e),10),o=parseInt(G("MatrixHeight",e),10);a=i.x,p=i.y,c=a+l*r[0]*s.resolution,u=p-o*r[1]*s.resolution}return function(e,t,i){return"1.0.0"===e&&(0,N.m)(t.wkid)&&!(i.spatialReference.isGeographic&&i.x<-90&&i.y>=-90)}(e,i.spatialReference,i)?new y.A(u,a,p,c,i.spatialReference):new y.A(a,u,c,p,i.spatialReference)}(e,l,u,m,h[0]).toJSON(),g=new S.A({dpi:96,spatialReference:p,size:m,origin:u,lods:h}).toJSON();return{id:r,fullExtent:f,tileInfo:g}}(e,t,i))}function re(e){e=e.toLowerCase();let t=parseInt(e.split(":").pop(),10);900913!==t&&3857!==t||(t=102100);const i=function(e){return e.includes("crs84")||e.includes("crs:84")?4326:e.includes("crs83")||e.includes("crs:83")?4269:e.includes("crs27")||e.includes("crs:27")?4267:null}(e);return null!=i&&(t=i),{wkid:t}}function se(e,t){const i=re(t),[r,s]=G("TopLeftCorner",e).split(" ").map(e=>parseFloat(e)),l=t.includes("epsg")&&(0,N.m)(i.wkid);return new j.A(l?{x:s,y:r,spatialReference:i}:{x:r,y:s,spatialReference:i})}function le(e,t,i,r,s){const l=re(t),o=G("Identifier",e);let n=parseFloat(G("ScaleDenominator",e));const a=oe(l.wkid,n,r);n*=96/W;const c=+G("MatrixWidth",e),u=+G("MatrixHeight",e),{maxCol:p=c-1,maxRow:d=u-1,minCol:m=0,minRow:h=0}=s.get(o)??{},{x:y,y:f}=se(e,t);return new D.A({cols:[m,p],level:i,levelValue:o,origin:[y,f],scale:n,resolution:a,rows:[h,d]})}function oe(e,t,i){let r;return r=_.A.hasOwnProperty(""+e)?_.A.values[_.A[e]]:"default028mm"===i?6370997*Math.PI/180:(0,U.y7)(e).metersPerDegree,7*t/25e3/r}var ne,ae=i(43937);const ce={"image/png":".png","image/png8":".png","image/png24":".png","image/png32":".png","image/jpg":".jpg","image/jpeg":".jpeg","image/gif":".gif","image/bmp":".bmp","image/tiff":".tif","image/jpgpng":"","image/jpegpng":"","image/unknown":""},ue=new Set(["version","service","request","layer","style","format","tilematrixset","tilematrix","tilerow","tilecol"]);let pe=ne=class extends((0,w.dM)((0,x.J)((0,C.j)((0,v.q)((0,M.A)((0,u.M)(f.A))))))){constructor(...e){super(...e),this.activeLayer=null,this.copyright="",this.customParameters=null,this.customLayerParameters=null,this.fullExtent=null,this.operationalLayerType="WebTiledLayer",this.resourceInfo=null,this.serviceMode="RESTful",this.sublayers=null,this.type="wmts",this.version="1.0.0",this.addHandles([(0,d.wB)(()=>this.activeLayer,(e,t)=>{t&&!this.sublayers?.includes(t)&&(t.layer=null,t.parent=null),e&&(e.layer=this,e.parent=this)},d.OH),(0,d.on)(()=>this.sublayers,"after-add",({item:e})=>{e.layer=this,e.parent=this},d.OH),(0,d.on)(()=>this.sublayers,"after-remove",({item:e})=>{e.layer=null,e.parent=null},d.OH),(0,d.wB)(()=>this.sublayers,(e,t)=>{if(t)for(const e of t)e.layer=null,e.parent=null;if(e)for(const t of e)t.layer=this,t.parent=this},d.OH)])}normalizeCtorArgs(e,t){return"string"==typeof e?{url:e,...t}:e}load(e){return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["WMTS"]},e).catch(p.QP).then(()=>this._fetchService(e)).catch(e=>{throw(0,p.QP)(e),new a.A("wmtslayer:unsupported-service-data","Invalid response from the WMTS service.",{error:e})})),Promise.resolve(this)}readActiveLayerFromService(e,t,i){this.activeLayer||(this.activeLayer=new V);let r=t.layers.find(e=>e.id===this.activeLayer.id);return r||(r=t.layers[0]),this.activeLayer.read(r,i),this.activeLayer}readActiveLayerFromItemOrWebDoc(e,t){const{templateUrl:i,wmtsInfo:r}=t,s=i?this._getLowerCasedUrlParams(i):null,l=r?.layerIdentifier;let o=null;const n=r?.tileMatrixSet;n&&(Array.isArray(n)?n.length&&(o=n[0]):o=n);const a=s?.format,c=s?.style;return new V({id:l,imageFormat:a,styleId:c,tileMatrixSetId:o})}writeActiveLayer(e,t,i,r){const{activeLayer:s,loaded:l}=this,{id:o,tileMatrixSet:n,tileMatrixSetId:a,imageFormat:c,styleId:u}=s;t.templateUrl=l?this.getUrlTemplate(o,a,c,u):void 0,t.tileInfo=l?n?.tileInfo?.toJSON(r)??null:void 0,t.wmtsInfo={...t.wmtsInfo,layerIdentifier:o,tileMatrixSet:a}}readCustomParameters(e,t){const i=t.wmtsInfo;return i?this._mergeParams(i.customParameters,i.url):null}get fullExtents(){return this.activeLayer.fullExtents}readServiceMode(e,t){return t.templateUrl.includes("?")?"KVP":"RESTful"}readSublayersFromService(e,t,i){return function(e,t){return e.map(e=>{const i=new V;return i.read(e,t),i})}(t.layers,i)}get supportedSpatialReferences(){return this.activeLayer.tileMatrixSets?.map(e=>e.tileInfo?.spatialReference).toArray().filter(o.Ru)??[]}get tilemapCache(){const e=this.activeLayer?.tileMatrixSet?.tileInfo;return e?new T.A(e):void 0}get title(){return this.activeLayer?.title??"Layer"}set title(e){this._overrideIfSome("title",e)}get url(){return this._get("url")}set url(e){e&&e.endsWith("/")?this._set("url",e.slice(0,-1)):this._set("url",e)}createWebTileLayer(e){const t=this.getUrlTemplate(this.activeLayer.id,this.activeLayer.tileMatrixSetId,this.activeLayer.imageFormat,this.activeLayer.styleId),i=this._getTileMatrixSetById(e.tileMatrixSetId),r=i?.tileInfo,s=e.fullExtent,l=new L.x({layerIdentifier:e.id,tileMatrixSet:e.tileMatrixSetId,url:this.url});return this.customLayerParameters&&(l.customLayerParameters=this.customLayerParameters),this.customParameters&&(l.customParameters=this.customParameters),new g.default({fullExtent:s,urlTemplate:t,tileInfo:r,wmtsInfo:l})}async fetchTile(e,t,i,r={}){const{signal:s}=r,o=this.getTileUrl(e,t,i),{data:n}=await(0,l.A)(o,{responseType:"image",signal:s});return n}async fetchImageBitmapTile(e,t,i,r={}){const{signal:s}=r;if(this.fetchTile!==ne.prototype.fetchTile){const l=await this.fetchTile(e,t,i,r);return(0,I.C)(l,e,t,i,s)}const o=this.getTileUrl(e,t,i),{data:n}=await(0,l.A)(o,{responseType:"blob",signal:s});return(0,I.C)(n,e,t,i,s)}findSublayerById(e){return this.sublayers?.find(t=>t.id===e)}getTileUrl(e,t,i){const r=this._getTileMatrixSetById(this.activeLayer.tileMatrixSetId),s=r?.tileInfo?.lods[e],l=s?s.levelValue||`${s.level}`:`${e}`;let o=this.resourceInfo?"":function(e,t,i,r,s,l,o,n){const a=function(e,t,i){const r=X(e,t),s=r?.filter(e=>e.format===i);return(s?.length?s:r)??[]}(e,t,r);if(!(a?.length>0))return"";const{dimensionMap:c}=e,u=c.get(t).dimensions?.[0],p=c.get(t).dimensions2?.[0];return a[o%a.length].template.replaceAll(/\{Style\}/gi,s??"").replaceAll(/\{TileMatrixSet\}/gi,i??"").replaceAll(/\{TileMatrix\}/gi,l).replaceAll(/\{TileRow\}/gi,""+o).replaceAll(/\{TileCol\}/gi,""+n).replaceAll(/\{dimensionValue\}/gi,u).replaceAll(/\{dimensionValue2\}/gi,p)}({dimensionMap:this.dimensionMap,layerMap:this.layerMap},this.activeLayer.id,this.activeLayer.tileMatrixSetId,this.activeLayer.imageFormat,this.activeLayer.styleId,l,t,i);return o||(o=this.getUrlTemplate(this.activeLayer.id,this.activeLayer.tileMatrixSetId,this.activeLayer.imageFormat,this.activeLayer.styleId).replaceAll(/\{level\}/gi,l).replaceAll(/\{row\}/gi,`${t}`).replaceAll(/\{col\}/gi,`${i}`)),o=this._appendCustomLayerParameters(o),o}getUrlTemplate(e,t,i,r){if(!this.resourceInfo){const i=function(e,t,i,r){const{dimensionMap:s}=e,l=X(e,t);let o="";if(l&&l.length>0){const e=s.get(t).dimensions?.[0],n=s.get(t).dimensions2?.[0];o=l[0].template,o.endsWith(".xxx")&&(o=o.slice(0,-4)),o=o.replaceAll(/\{Style\}/gi,r),o=o.replaceAll(/\{TileMatrixSet\}/gi,i),o=o.replaceAll(/\{TileMatrix\}/gi,"{level}"),o=o.replaceAll(/\{TileRow\}/gi,"{row}"),o=o.replaceAll(/\{TileCol\}/gi,"{col}"),o=o.replaceAll(/\{dimensionValue\}/gi,e),o=o.replaceAll(/\{dimensionValue2\}/gi,n)}return o}({dimensionMap:this.dimensionMap,layerMap:this.layerMap},e,t,r);if(i)return i}if("KVP"===this.serviceMode)return this.url+"?SERVICE=WMTS&VERSION="+this.version+"&REQUEST=GetTile&LAYER="+e+"&STYLE="+r+"&FORMAT="+i+"&TILEMATRIXSET="+t+"&TILEMATRIX={level}&TILEROW={row}&TILECOL={col}";if("RESTful"===this.serviceMode){let s="";const l=i.toLowerCase();return ce[l]&&(s=ce[l]),this.url+e+"/"+r+"/"+t+"/{level}/{row}/{col}"+s}return""}async _fetchService(e){if(this.resourceInfo)return"KVP"!==this.resourceInfo.serviceMode||this.url.includes("?")||(this.url+="?"),function(e){for(const t of e.layers)for(const e of t.tileMatrixSets??[]){const{tileInfo:t}=e;if(t&&96!==t.dpi){for(const i of t.lods??[])i.scale=96*i.scale/t.dpi,i.resolution=oe(t.spatialReference?.wkid,i.scale*W/96,e.id);t.dpi=96}}}(this.resourceInfo),void this.read(this.resourceInfo,{origin:"service"});let t=null;try{const{data:i}=await this._getCapabilities(this.serviceMode,e);t=K(i),B(t)}catch{const i="KVP"===this.serviceMode?"RESTful":"KVP";try{const{data:r}=await this._getCapabilities(i,e);t=K(r),B(t),this.serviceMode=i}catch(e){throw new a.A("wmtslayer:unsupported-service-data","Services does not support RESTful or KVP service modes.",{error:e})}}const{serviceMode:i,url:r}=this,s=function(e,t){const i=e.documentElement,r=new Map,s=new Map,l=H("Contents",i);if(!l)throw new a.A("wmtslayer:wmts-capabilities-xml-is-not-valid","Can't retrieve xml capabilities element");const o=H("OperationsMetadata",i),n=o?.querySelector("[name='GetTile']"),c=n?.getElementsByTagName("Get"),u=c&&Array.prototype.slice.call(c),p=t.url?.indexOf("https"),d=void 0!==p&&p>-1;let m,h,y=t.serviceMode,f=t?.url;if(u?.length&&u.some(e=>{const t=H("Constraint",e);return!t||z("AllowedValues","Value",y,t)?(f=e.attributes[0].nodeValue,!0):(!t||z("AllowedValues","Value","RESTful",t)||z("AllowedValues","Value","REST",t)?h=e.attributes[0].nodeValue:t&&!z("AllowedValues","Value","KVP",t)||(m=e.attributes[0].nodeValue),!1)}),!f)if(h)f=h,y="RESTful";else if(m)f=m,y="KVP";else{const e=H("ServiceMetadataURL",i);f=e?.getAttribute("xlink:href")}const g=f.indexOf("1.0.0/");-1===g&&"RESTful"===y?f+="/":g>-1&&(f=f.slice(0,g)),"KVP"===y&&(f+=g>-1?"":"?"),d&&(f=f.replace(/^http:/i,"https:"));const w=G("ServiceIdentification>ServiceTypeVersion",i),v=G("ServiceIdentification>AccessConstraints",i),M=v&&/^none$/i.test(v)?null:v,x=J("Layer",l),C=J("TileMatrixSet",l),I=x.map(e=>{const t=G("Identifier",e);return r.set(t,e),Q(t,e,C,d,w)});return{copyright:M,dimensionMap:s,layerMap:r,layers:I,serviceMode:y,tileUrl:f}}(t,{serviceMode:i,url:r});this.read(s,{origin:"service"})}async _getCapabilities(e,t){const i=this._getCapabilitiesUrl(e);return await(0,l.A)(i,{...t,responseType:"text"})}_getTileMatrixSetById(e){const t=this.findSublayerById(this.activeLayer.id);return t?.tileMatrixSets?.find(({id:t})=>t===e)}_appendCustomParameters(e){return this._appendParameters(e,this.customParameters)}_appendCustomLayerParameters(e){return this._appendParameters(e,{...(0,c.o8)(this.customParameters),...this.customLayerParameters})}_appendParameters(e,t){const i=(0,m.An)(e),r={...i.query,...t},s=(0,m.x0)(r);return""===s?i.path:`${i.path}?${s}`}_getCapabilitiesUrl(e){this.url=(0,m.An)(this.url).path;let t=this.url;switch(e){case"KVP":t+=`?request=GetCapabilities&service=WMTS&version=${this.version}`;break;case"RESTful":{const e=`/${this.version}/WMTSCapabilities.xml`,i=new RegExp(e,"i");t=t.replace(i,""),t+=e;break}}return this._appendCustomParameters(t)}_getLowerCasedUrlParams(e){if(!e)return null;const t=(0,m.An)(e).query;if(!t)return null;const i={};return Object.keys(t).forEach(e=>{i[e.toLowerCase()]=t[e]}),i}_mergeParams(e,t){const i=this._getLowerCasedUrlParams(t);if(i){const t=Object.keys(i);t.length&&(e=e?(0,c.o8)(e):{},t.forEach(t=>{e.hasOwnProperty(t)||ue.has(t)||(e[t]=i[t])}))}return e}};(0,s.Cg)([(0,h.MZ)()],pe.prototype,"dimensionMap",void 0),(0,s.Cg)([(0,h.MZ)()],pe.prototype,"layerMap",void 0),(0,s.Cg)([(0,h.MZ)({type:V,json:{origins:{"web-document":{write:{ignoreOrigin:!0}}}}})],pe.prototype,"activeLayer",void 0),(0,s.Cg)([(0,Z.w)("service","activeLayer",["layers"])],pe.prototype,"readActiveLayerFromService",null),(0,s.Cg)([(0,Z.w)(["web-document","portal-item"],"activeLayer",["wmtsInfo"])],pe.prototype,"readActiveLayerFromItemOrWebDoc",null),(0,s.Cg)([(0,ae.K)(["web-document","portal-item"],"activeLayer",{templateUrl:{type:String},tileInfo:{type:S.A},"wmtsInfo.layerIdentifier":{type:String},"wmtsInfo.tileMatrixSet":{type:String}})],pe.prototype,"writeActiveLayer",null),(0,s.Cg)([(0,h.MZ)({type:String,value:"",json:{write:!0}})],pe.prototype,"copyright",void 0),(0,s.Cg)([(0,h.MZ)({type:["show","hide"]})],pe.prototype,"listMode",void 0),(0,s.Cg)([(0,h.MZ)({json:{read:!0,write:!0}})],pe.prototype,"blendMode",void 0),(0,s.Cg)([(0,h.MZ)({json:{origins:{"web-document":{read:{source:["wmtsInfo.customParameters","wmtsInfo.url"]},write:{target:"wmtsInfo.customParameters"}},"portal-item":{read:{source:["wmtsInfo.customParameters","wmtsInfo.url"]},write:{target:"wmtsInfo.customParameters"}}}}})],pe.prototype,"customParameters",void 0),(0,s.Cg)([(0,Z.w)(["portal-item","web-document"],"customParameters")],pe.prototype,"readCustomParameters",null),(0,s.Cg)([(0,h.MZ)({json:{origins:{"web-document":{read:{source:"wmtsInfo.customLayerParameters"},write:{target:"wmtsInfo.customLayerParameters"}},"portal-item":{read:{source:"wmtsInfo.customLayerParameters"},write:{target:"wmtsInfo.customLayerParameters"}}}}})],pe.prototype,"customLayerParameters",void 0),(0,s.Cg)([(0,h.MZ)({type:y.A,json:{write:{ignoreOrigin:!0},origins:{"web-document":{read:{source:"fullExtent"}},"portal-item":{read:{source:"fullExtent"}}}}})],pe.prototype,"fullExtent",void 0),(0,s.Cg)([(0,h.MZ)({readOnly:!0})],pe.prototype,"fullExtents",null),(0,s.Cg)([(0,h.MZ)({type:["WebTiledLayer"]})],pe.prototype,"operationalLayerType",void 0),(0,s.Cg)([(0,h.MZ)()],pe.prototype,"resourceInfo",void 0),(0,s.Cg)([(0,h.MZ)()],pe.prototype,"serviceMode",void 0),(0,s.Cg)([(0,Z.w)(["portal-item","web-document"],"serviceMode",["templateUrl"])],pe.prototype,"readServiceMode",null),(0,s.Cg)([(0,h.MZ)({type:n.A.ofType(V)})],pe.prototype,"sublayers",void 0),(0,s.Cg)([(0,Z.w)("service","sublayers",["layers"])],pe.prototype,"readSublayersFromService",null),(0,s.Cg)([(0,h.MZ)({readOnly:!0})],pe.prototype,"supportedSpatialReferences",null),(0,s.Cg)([(0,h.MZ)({readOnly:!0})],pe.prototype,"tilemapCache",null),(0,s.Cg)([(0,h.MZ)({json:{read:{source:"title"}}})],pe.prototype,"title",null),(0,s.Cg)([(0,h.MZ)({json:{read:!1},readOnly:!0,value:"wmts"})],pe.prototype,"type",void 0),(0,s.Cg)([(0,h.MZ)({json:{origins:{service:{read:{source:"tileUrl"}},"web-document":{read:{source:"wmtsInfo.url"},write:{target:"wmtsInfo.url"}},"portal-item":{read:{source:"wmtsInfo.url"},write:{target:"wmtsInfo.url"}}}}})],pe.prototype,"url",null),(0,s.Cg)([(0,h.MZ)()],pe.prototype,"version",void 0),pe=ne=(0,s.Cg)([(0,h.$K)("esri.layers.WMTSLayer")],pe);const de=pe},38458(e,t,i){i.d(t,{m:()=>s});const r=[[3819,3819],[3821,3824],[3889,3889],[3906,3906],[4001,4025],[4027,4036],[4039,4047],[4052,4055],[4074,4075],[4080,4081],[4120,4176],[4178,4185],[4188,4216],[4218,4289],[4291,4304],[4306,4319],[4322,4326],[4463,4463],[4470,4470],[4475,4475],[4483,4483],[4490,4490],[4555,4558],[4600,4646],[4657,4765],[4801,4811],[4813,4821],[4823,4824],[4901,4904],[5013,5013],[5132,5132],[5228,5229],[5233,5233],[5246,5246],[5252,5252],[5264,5264],[5324,5340],[5354,5354],[5360,5360],[5365,5365],[5370,5373],[5381,5381],[5393,5393],[5451,5451],[5464,5464],[5467,5467],[5489,5489],[5524,5524],[5527,5527],[5546,5546],[2044,2045],[2081,2083],[2085,2086],[2093,2093],[2096,2098],[2105,2132],[2169,2170],[2176,2180],[2193,2193],[2200,2200],[2206,2212],[2319,2319],[2320,2462],[2523,2549],[2551,2735],[2738,2758],[2935,2941],[2953,2953],[3006,3030],[3034,3035],[3038,3051],[3058,3059],[3068,3068],[3114,3118],[3126,3138],[3150,3151],[3300,3301],[3328,3335],[3346,3346],[3350,3352],[3366,3366],[3389,3390],[3416,3417],[3833,3841],[3844,3850],[3854,3854],[3873,3885],[3907,3910],[4026,4026],[4037,4038],[4417,4417],[4434,4434],[4491,4554],[4839,4839],[5048,5048],[5105,5130],[5253,5259],[5269,5275],[5343,5349],[5479,5482],[5518,5519],[5520,5520],[20004,20032],[20064,20092],[21413,21423],[21473,21483],[21896,21899],[22171,22177],[22181,22187],[22191,22197],[25884,25884],[27205,27232],[27391,27398],[27492,27492],[28402,28432],[28462,28492],[30161,30179],[30800,30800],[31251,31259],[31275,31279],[31281,31290],[31466,31700]];function s(e){return null!=e&&r.some(([t,i])=>e>=t&&e<=i)}},65509(e,t,i){i.d(t,{A:()=>l});var r=i(49186),s=i(74887);class l{constructor(e,t=0,i=e.lods[e.lods.length-1].level){this.tileInfo=e,this.minLOD=t,this.maxLOD=i,e.lodAt(t)||(this.minLOD=e.lods[0].level),e.lodAt(i)||(this.maxLOD=e.lods[e.lods.length-1].level)}get effectiveMinLOD(){return this.minLOD??this.tileInfo.lods[0].level}get effectiveMaxLOD(){return this.maxLOD??this.tileInfo.lods[this.tileInfo.lods.length-1].level}getAvailability(e,t,i){const r=this.tileInfo?.lodAt(e);return!r||e<this.minLOD||e>this.maxLOD?"unavailable":r.cols&&r.rows?i>=r.cols[0]&&i<=r.cols[1]&&t>=r.rows[0]&&t<=r.rows[1]?"unknown":"unavailable":"unknown"}async fetchAvailability(e,t,i,l){await(0,s.NO)(l);const o=this.getAvailability(e,t,i);if("unavailable"===o)throw new r.A("tile-map:tile-unavailable","Tile is not available",{level:e,row:t,col:i});return o}async fetchAvailabilityUpsample(e,t,i,r,l){await(0,s.NO)(l),r.level=e,r.row=t,r.col=i;const o=this.tileInfo;return o.updateTileInfo(r),this.fetchAvailability(e,t,i,l).catch(e=>{if((0,s.zf)(e))throw e;if(o.upsampleTile(r))return this.fetchAvailabilityUpsample(r.level,r.row,r.col,r,l);throw e})}}}}]);