/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import n from"../../../core/Collection.js";import{isEarth as t}from"../../../geometry/ellipsoidUtils.js";import{isCGCS2000 as e}from"../../../geometry/support/spatialReferenceUtils.js";import{getTileMaxtrixSetFromActiveLayer as r}from"../../../layers/support/layerUtils.js";import{isRasterTile as o,isImageWithType as i,isTileTexture as u,isVectorTile as l}from"./TerrainData.js";import{t as f}from"../../../chunks/terrainUtilsPlanar.js";import{t as c}from"../../../chunks/terrainUtilsSpherical.js";const a={1:c,2:f};function s(n,t){n||console.warn("Terrain: "+t)}let p=!1,m=!1;function y(n){m=n,p=p||n}function I(n){p=n}function d(n,t){if(p&&!n){const n=(new Error).stack?.slice(5);throw console.warn("Terrain internal: "+(t??"")+" at "+n),new Error("Assertion failed"+(t?": "+t:""))}}function E(n){return"imagery-tile"===n?.type||"wcs"===n?.type}function T(n){return"imagery-tile-3d"===n?.type}function h(n){return"tile-3d"===n?.type}function x(n){return"vector-tile-3d"===n?.type}function g(n){return"wmts-3d"===n?.type}function L(n){return"elevation-3d"===n?.type}function w(n){return"group"===n?.type}function v(n){return n&&(h(n)||g(n)||T(n)||x(n))}function C(n){return n&&(h(n)||T(n)||x(n)||g(n))}function j(n){return C(n)||L(n)}function b(n){return o(n?.sourceLayerInfo?.data)}function k(n){return U(n?.sourceLayerInfo)||!!n?.isVTLBackground}function F(n){return u(n?.sourceLayerInfo?.data)}function M(n){const t=n?.sourceLayerInfo?.data;return i(t)||t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof ImageData}function U(n){return l(n?.data)}function V(n){return null!=n&&"release"in n&&n.release(),null}function S(n){return"fetchTile"in n&&(!("hasOverriddenFetchTile"in n)||!1!==n.hasOverriddenFetchTile)}function D(n,t,e,r,o){return a[r].checkIfTileInfoSupportedForViewSR(n,e,t,o)}function O(n,t,e){let r=null,o=null;if("wmts"===n?.type){const i=H(n,t,e);r=i.tileInfo,o=i.fullExtent}else{o=E(n)?n.getCompatibleFullExtent(t):n.fullExtent;const i=2===e;if(E(n))r=n.getCompatibleTileInfo(t,o,i);else if("vector-tile"===n?.type){r=i&&!R(t)||W.force512VTL?n.tileInfo:n.tileInfo.getCompatibleForVTL(256)}else r=n.tileInfo}const i="tilemapCache"in n?n.tilemapCache?.effectiveMaxLOD:void 0;return null!=r&&null!=o&&null==D(r,o,t,e,i)?{tileInfo:r,fullExtent:o}:null}function H(t,e,o){const i=r(t);if(null!=i){if(!n.isCollection(i))return{tileInfo:i.tileInfo,fullExtent:i.fullExtent};{const n=i.find(n=>null==D(n.tileInfo,n.fullExtent,e,o));if(n)return{tileInfo:n.tileInfo,fullExtent:n.fullExtent}}}return{tileInfo:null,fullExtent:null}}function R(n){return n.isWGS84||n.isWebMercator||e(n)||!t(n)}const W={force512VTL:!1};function A(n){return"["+n[0]+","+n[1]+","+n[2]+"]"}function B(n){return"("+n[0]+","+n[1]+","+n[2]+")"}function G(n,t,e=$){return Math.abs(n-t)<e}function P(n){return 1===n?5:7===n?3:5===n?1:7}function q(n){return 0===n?4:2===n?6:4===n?0:2}function z(n){return 7===n||5===n}function J(n){return 7===n||1===n}function K(n){return 7===n||6===n||5===n}function N(n){return 1===n||2===n||3===n}function Q(n){return 3===n||4===n||5===n}function X(n){return 1===n||0===n||7===n}const Y=[0,2,4,6],Z=[1,3,5,7],$=1e-5;export{G as almostEquals,D as checkIfTileInfoSupportedForView,I as enableInternalTerrainChecks,p as enableTerrainInternalChecks,y as enableTerrainWaterproofChecks,m as enableWaterproofTests,$ as eps,H as getTileInfoAndExtentFromWMTSLayer,O as getTiledLayerInfo,d as internalAssert,v as isBlendableLayerView,N as isEast,L as isElevationLayerView,w as isGroupLayerView,M as isImageSourceRenderInfo,T as isImageryTileLayerView,b as isImageryTileRenderInfo,C as isMapTileLayerView,X as isNorth,J as isNorthCorner,E as isProjectableRasterLayer,Q as isSouth,j as isSurfaceLayerView,F as isTextureTileRenderInfo,h as isTileLayerView,x as isVectorTileLayerView,U as isVectorTilePerLayerInfo,k as isVectorTileRenderInfo,g as isWMTSLayerView,K as isWest,z as isWestCorner,A as lij2s,Z as neighborCornerIndices,Y as neighborEdgeIndices,P as oppositeCorner,q as oppositeEdge,V as releaseTerrainData,W as test,S as useFetchTileForLayer,B as v32s,R as vtlAssumes256PixelSizeAsDefault,s as weakAssert};
