import{T as g,a as h,h as x,j as _,i as f,g as c,c as d}from"./TileImage-B-0PORC6.js";class y extends g{constructor(e){super({extent:e.extent,origin:e.origin,origins:e.origins,resolutions:e.resolutions,tileSize:e.tileSize,tileSizes:e.tileSizes,sizes:e.sizes}),this.matrixIds_=e.matrixIds}getMatrixId(e){return this.matrixIds_[e]}getMatrixIds(){return this.matrixIds_}}class F extends h{constructor(e){e=e||{};const i=e.projection!==void 0?e.projection:"EPSG:3857",t=e.tileGrid!==void 0?e.tileGrid:x({extent:_(i),maxResolution:e.maxResolution,maxZoom:e.maxZoom,minZoom:e.minZoom,tileSize:e.tileSize});super({attributions:e.attributions,cacheSize:e.cacheSize,crossOrigin:e.crossOrigin,interpolate:e.interpolate,projection:i,reprojectionErrorThreshold:e.reprojectionErrorThreshold,tileGrid:t,tileLoadFunction:e.tileLoadFunction,tilePixelRatio:e.tilePixelRatio,tileUrlFunction:e.tileUrlFunction,url:e.url,urls:e.urls,wrapX:e.wrapX!==void 0?e.wrapX:!0,transition:e.transition,attributionsCollapsible:e.attributionsCollapsible,zDirection:e.zDirection}),this.gutter_=e.gutter!==void 0?e.gutter:0}getGutter(){return this.gutter_}}class b extends h{constructor(e){const i=e.requestEncoding!==void 0?e.requestEncoding:"KVP",t=e.tileGrid;let r=e.urls;r===void 0&&e.url!==void 0&&(r=f(e.url)),super({attributions:e.attributions,attributionsCollapsible:e.attributionsCollapsible,cacheSize:e.cacheSize,crossOrigin:e.crossOrigin,interpolate:e.interpolate,projection:e.projection,reprojectionErrorThreshold:e.reprojectionErrorThreshold,tileClass:e.tileClass,tileGrid:t,tileLoadFunction:e.tileLoadFunction,tilePixelRatio:e.tilePixelRatio,urls:r,wrapX:e.wrapX!==void 0?e.wrapX:!1,transition:e.transition,zDirection:e.zDirection}),this.version_=e.version!==void 0?e.version:"1.0.0",this.format_=e.format!==void 0?e.format:"image/jpeg",this.dimensions_=e.dimensions!==void 0?e.dimensions:{},this.layer_=e.layer,this.matrixSet_=e.matrixSet,this.style_=e.style,this.requestEncoding_=i,this.setKey(this.getKeyForDimensions_()),r&&r.length>0&&(this.tileUrlFunction=c(r.map(this.createFromWMTSTemplate.bind(this))))}setUrls(e){this.urls=e;const i=e.join(`
`);this.setTileUrlFunction(c(e.map(this.createFromWMTSTemplate.bind(this))),i)}getDimensions(){return this.dimensions_}getFormat(){return this.format_}getLayer(){return this.layer_}getMatrixSet(){return this.matrixSet_}getRequestEncoding(){return this.requestEncoding_}getStyle(){return this.style_}getVersion(){return this.version_}getKeyForDimensions_(){const e=this.urls?this.urls.slice(0):[];for(const i in this.dimensions_)e.push(i+"-"+this.dimensions_[i]);return e.join("/")}updateDimensions(e){Object.assign(this.dimensions_,e),this.setKey(this.getKeyForDimensions_())}createFromWMTSTemplate(e){const i=this.requestEncoding_,t={layer:this.layer_,style:this.style_,tilematrixset:this.matrixSet_};i=="KVP"&&Object.assign(t,{Service:"WMTS",Request:"GetTile",Version:this.version_,Format:this.format_}),e=i=="KVP"?d(e,t):e.replace(/\{(\w+?)\}/g,function(s,a){return a.toLowerCase()in t?t[a.toLowerCase()]:s});const r=this.tileGrid,m=this.dimensions_;return(function(s,a,S){if(!s)return;const l={TileMatrix:r.getMatrixId(s[0]),TileCol:s[1],TileRow:s[2]};Object.assign(l,m);let n=e;return i=="KVP"?n=d(n,l):n=n.replace(/\{(\w+?)\}/g,function(T,o){return encodeURIComponent(l[o])}),n})}}export{b as W,F as X,y as a};
