/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/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,isCreateBitmapResult 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 s={1:c,2:f};function a(n,t){n||console.warn("Terrain: "+t)}let p=!1,m=!1;function y(n){m=n,p=p||n}function d(n){p=n}function I(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 h(n){return"imagery-tile"===n?.type||"wcs"===n?.type}function x(n){return"imagery-tile-3d"===n?.type}function E(n){return"tile-3d"===n?.type}function T(n){return"vector-tile-3d"===n?.type}function g(n){return"wmts-3d"===n?.type}function w(n){return"elevation-3d"===n?.type}function L(n){return"group"===n?.type}function j(n){return n&&(E(n)||g(n)||x(n)||T(n))}function v(n){return n&&(E(n)||x(n)||T(n)||g(n))}function C(n){return v(n)||w(n)}function b(n){return o(n?.sourceLayerInfo?.data)}function k(n){return V(n?.sourceLayerInfo)||!!n?.isVTLBackground}function F(n){return u(n?.sourceLayerInfo?.data)}function U(n){const t=n?.sourceLayerInfo?.data;return i(t)}function V(n){return l(n?.data)}function S(n){return null!=n&&"release"in n&&n.release(),null}function M(n){return"fetchTile"in n&&(!("hasOverriddenFetchTile"in n)||!1!==n.hasOverriddenFetchTile)}function O(n,t,e,r,o){return s[r].checkIfTileInfoSupportedForViewSR(n,e,t,o)}function D(n,t,e){let r=null,o=null;if("wmts"===n?.type){const i=R(n,t,e);r=i.tileInfo,o=i.fullExtent}else{o=h(n)?n.getCompatibleFullExtent(t):n.fullExtent;const i=2===e;if(h(n))r=n.getCompatibleTileInfo(t,o,i);else if("vector-tile"===n?.type){r=i&&!W(t)||A.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==O(r,o,t,e,i)?{tileInfo:r,fullExtent:o}:null}function R(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==O(n.tileInfo,n.fullExtent,e,o));if(n)return{tileInfo:n.tileInfo,fullExtent:n.fullExtent}}}return{tileInfo:null,fullExtent:null}}function W(n){return n.isWGS84||n.isWebMercator||e(n)||!t(n)}const A={force512VTL:!1};function B(n){return"["+n[0]+","+n[1]+","+n[2]+"]"}function G(n){return"("+n[0]+","+n[1]+","+n[2]+")"}function P(n,t,e=$){return Math.abs(n-t)<e}function q(n){return 1===n?5:7===n?3:5===n?1:7}function z(n){return 0===n?4:2===n?6:4===n?0:2}function H(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{P as almostEquals,O as checkIfTileInfoSupportedForView,d as enableInternalTerrainChecks,p as enableTerrainInternalChecks,y as enableTerrainWaterproofChecks,m as enableWaterproofTests,$ as eps,R as getTileInfoAndExtentFromWMTSLayer,D as getTiledLayerInfo,I as internalAssert,j as isBlendableLayerView,N as isEast,w as isElevationLayerView,L as isGroupLayerView,U as isImageSourceRenderInfo,x as isImageryTileLayerView,b as isImageryTileRenderInfo,v as isMapTileLayerView,X as isNorth,J as isNorthCorner,h as isProjectableRasterLayer,Q as isSouth,C as isSurfaceLayerView,F as isTextureTileRenderInfo,E as isTileLayerView,T as isVectorTileLayerView,V as isVectorTilePerLayerInfo,k as isVectorTileRenderInfo,g as isWMTSLayerView,K as isWest,H as isWestCorner,B as lij2s,Z as neighborCornerIndices,Y as neighborEdgeIndices,q as oppositeCorner,z as oppositeEdge,S as releaseTerrainData,A as test,M as useFetchTileForLayer,G as v32s,W as vtlAssumes256PixelSizeAsDefault,a as weakAssert};
