/**
 * @license
 * Cesium - https://github.com/CesiumGS/cesium
 * Version 1.122
 *
 * Copyright 2011-2022 Cesium Contributors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Columbus View (Pat. Pend.)
 *
 * Portions licensed separately.
 * See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
 */
import{a as st}from"./chunk-45FCQ3FJ.js";import{b as at,c as ht,d as nt}from"./chunk-N72XKOXM.js";import{a as et}from"./chunk-27UWHT4D.js";import{a as h,b as tt,c as v,d as vt}from"./chunk-RFPX772U.js";import{a as Y}from"./chunk-RAYRECQS.js";import{a as xt}from"./chunk-2NAI7YQ3.js";import{a as K}from"./chunk-6KLVDWWE.js";import{b as C}from"./chunk-6P5KAIBX.js";import{e as D}from"./chunk-4FSVUTPL.js";var ct={CLOCKWISE:xt.CW,COUNTER_CLOCKWISE:xt.CCW,validate:function(t){return t===ct.CLOCKWISE||t===ct.COUNTER_CLOCKWISE}},pt=Object.freeze(ct);function dt(t,e,n=2){let r,i,u,a=e&&e.length,l=a?e[0]*n:t.length,o=bt(t,0,l,n,!0),x=[];if(!o||o.next===o.prev)return x;if(a&&(o=It(t,e,o,n)),t.length>80*n){r=1/0,i=1/0;let e=-1/0,a=-1/0;for(let u=n;u<l;u+=n){let n=t[u],l=t[u+1];n<r&&(r=n),l<i&&(i=l),n>e&&(e=n),l>a&&(a=l)}u=Math.max(e-r,a-i),u=0!==u?32767/u:0}return rt(o,x,n,r,i,u,0),x}function bt(t,e,n,r,i){let u;if(i===jt(t,e,n,r)>0)for(let i=e;i<n;i+=r)u=wt(i/r|0,t[i],t[i+1],u);else for(let i=n-r;i>=e;i-=r)u=wt(i/r|0,t[i],t[i+1],u);return u&&ft(u,u.next)&&(ot(u),u=u.next),u}function N(t,e){if(!t)return t;e||(e=t);let n,r=t;do{if(n=!1,r.steiner||!ft(r,r.next)&&0!==b(r.prev,r,r.next))r=r.next;else{if(ot(r),r=e=r.prev,r===r.next)break;n=!0}}while(n||r!==e);return e}function rt(t,e,n,r,i,u,a){if(!t)return;!a&&u&&Nt(t,r,i,u);let l=t;for(;t.prev!==t.next;){let o=t.prev,x=t.next;if(u?Rt(t,r,i,u):Pt(t))e.push(o.i,t.i,x.i),ot(t),t=x.next,l=x.next;else if((t=x)===l){a?1===a?rt(t=zt(N(t),e),e,n,r,i,u,2):2===a&&Bt(t,e,n,r,i,u):rt(N(t),e,n,r,i,u,1);break}}}function Pt(t){let e=t.prev,n=t,r=t.next;if(b(e,n,r)>=0)return!1;let i=e.x,u=n.x,a=r.x,l=e.y,o=n.y,x=r.y,h=i<u?i<a?i:a:u<a?u:a,p=l<o?l<x?l:x:o<x?o:x,s=i>u?i>a?i:a:u>a?u:a,y=l>o?l>x?l:x:o>x?o:x,f=r.next;for(;f!==e;){if(f.x>=h&&f.x<=s&&f.y>=p&&f.y<=y&&V(i,l,u,o,a,x,f.x,f.y)&&b(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Rt(t,e,n,r){let i=t.prev,u=t,a=t.next;if(b(i,u,a)>=0)return!1;let l=i.x,o=u.x,x=a.x,h=i.y,p=u.y,s=a.y,y=l<o?l<x?l:x:o<x?o:x,f=h<p?h<s?h:s:p<s?p:s,c=l>o?l>x?l:x:o>x?o:x,m=h>p?h>s?h:s:p>s?p:s,v=yt(y,f,e,n,r),d=yt(c,m,e,n,r),g=t.prevZ,w=t.nextZ;for(;g&&g.z>=v&&w&&w.z<=d;){if(g.x>=y&&g.x<=c&&g.y>=f&&g.y<=m&&g!==i&&g!==a&&V(l,h,o,p,x,s,g.x,g.y)&&b(g.prev,g,g.next)>=0||(g=g.prevZ,w.x>=y&&w.x<=c&&w.y>=f&&w.y<=m&&w!==i&&w!==a&&V(l,h,o,p,x,s,w.x,w.y)&&b(w.prev,w,w.next)>=0))return!1;w=w.nextZ}for(;g&&g.z>=v;){if(g.x>=y&&g.x<=c&&g.y>=f&&g.y<=m&&g!==i&&g!==a&&V(l,h,o,p,x,s,g.x,g.y)&&b(g.prev,g,g.next)>=0)return!1;g=g.prevZ}for(;w&&w.z<=d;){if(w.x>=y&&w.x<=c&&w.y>=f&&w.y<=m&&w!==i&&w!==a&&V(l,h,o,p,x,s,w.x,w.y)&&b(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function zt(t,e){let n=t;do{let r=n.prev,i=n.next.next;!ft(r,i)&&St(r,n,n.next,i)&&it(r,i)&&it(i,r)&&(e.push(r.i,n.i,i.i),ot(n),ot(n.next),n=t=i),n=n.next}while(n!==t);return N(n)}function Bt(t,e,n,r,i,u){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.i!==t.i&&_t(a,t)){let l=At(a,t);return a=N(a,a.next),l=N(l,l.next),rt(a,e,n,r,i,u,0),void rt(l,e,n,r,i,u,0)}t=t.next}a=a.next}while(a!==t)}function It(t,e,n,r){let i=[];for(let n=0,u=e.length;n<u;n++){let a=bt(t,e[n]*r,n<u-1?e[n+1]*r:t.length,r,!1);a===a.next&&(a.steiner=!0),i.push(Ut(a))}i.sort(Wt);for(let t=0;t<i.length;t++)n=$t(i[t],n);return n}function Wt(t,e){return t.x-e.x}function $t(t,e){let n=Gt(t,e);if(!n)return e;let r=At(n,t);return N(r,r.next),N(n,n.next)}function Gt(t,e){let n,r=e,i=t.x,u=t.y,a=-1/0;do{if(u<=r.y&&u>=r.next.y&&r.next.y!==r.y){let t=r.x+(u-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(t<=i&&t>a&&(a=t,n=r.x<r.next.x?r:r.next,t===i))return n}r=r.next}while(r!==e);if(!n)return null;let l=n,o=n.x,x=n.y,h=1/0;r=n;do{if(i>=r.x&&r.x>=o&&i!==r.x&&V(u<x?i:a,u,o,x,u<x?a:i,u,r.x,r.y)){let e=Math.abs(u-r.y)/(i-r.x);it(r,t)&&(e<h||e===h&&(r.x>n.x||r.x===n.x&&Ht(n,r)))&&(n=r,h=e)}r=r.next}while(r!==l);return n}function Ht(t,e){return b(t.prev,t,e.prev)<0&&b(e.next,t,t.next)<0}function Nt(t,e,n,r){let i=t;do{0===i.z&&(i.z=yt(i.x,i.y,e,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,kt(i)}function kt(t){let e,n=1;do{let r,i=t;t=null;let u=null;for(e=0;i;){e++;let a=i,l=0;for(let t=0;t<n&&(l++,a=a.nextZ,a);t++);let o=n;for(;l>0||o>0&&a;)0!==l&&(0===o||!a||i.z<=a.z)?(r=i,i=i.nextZ,l--):(r=a,a=a.nextZ,o--),u?u.nextZ=r:t=r,r.prevZ=u,u=r;i=a}u.nextZ=null,n*=2}while(e>1);return t}function yt(t,e,n,r,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Ut(t){let e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next}while(e!==t);return n}function V(t,e,n,r,i,u,a,l){return(i-a)*(e-l)>=(t-a)*(u-l)&&(t-a)*(r-l)>=(n-a)*(e-l)&&(n-a)*(u-l)>=(i-a)*(r-l)}function _t(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!Kt(t,e)&&(it(t,e)&&it(e,t)&&Vt(t,e)&&(b(t.prev,t,e.prev)||b(t,e.prev,e))||ft(t,e)&&b(t.prev,t,t.next)>0&&b(e.prev,e,e.next)>0)}function b(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function ft(t,e){return t.x===e.x&&t.y===e.y}function St(t,e,n,r){let i=lt(b(t,e,n)),u=lt(b(t,e,r)),a=lt(b(n,r,t)),l=lt(b(n,r,e));return!!(i!==u&&a!==l||0===i&&ut(t,n,e)||0===u&&ut(t,r,e)||0===a&&ut(n,t,r)||0===l&&ut(n,e,r))}function ut(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function lt(t){return t>0?1:t<0?-1:0}function Kt(t,e){let n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&St(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}function it(t,e){return b(t.prev,t,t.next)<0?b(t,e,t.next)>=0&&b(t,t.prev,e)>=0:b(t,e,t.prev)<0||b(t,t.next,e)<0}function Vt(t,e){let n=t,r=!1,i=(t.x+e.x)/2,u=(t.y+e.y)/2;do{n.y>u!=n.next.y>u&&n.next.y!==n.y&&i<(n.next.x-n.x)*(u-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==t);return r}function At(t,e){let n=mt(t.i,t.x,t.y),r=mt(e.i,e.x,e.y),i=t.next,u=e.prev;return t.next=e,e.prev=t,n.next=i,i.prev=n,r.next=n,n.prev=r,u.next=r,r.prev=u,r}function wt(t,e,n,r){let i=mt(t,e,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function ot(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function mt(t,e,n){return{i:t,x:e,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function jt(t,e,n,r){let i=0;for(let u=e,a=n-r;u<n;u+=r)i+=(t[a]-t[u])*(t[u+1]+t[a+1]),a=u;return i}var qt=new h,Jt=new h,B={computeArea2D:function(t){C.defined("positions",t),C.typeOf.number.greaterThanOrEquals("positions.length",t.length,3);let e=t.length,n=0;for(let r=e-1,i=0;i<e;r=i++){let e=t[r],u=t[i];n+=e.x*u.y-u.x*e.y}return.5*n},computeWindingOrder2D:function(t){return B.computeArea2D(t)>0?pt.COUNTER_CLOCKWISE:pt.CLOCKWISE},triangulate:function(t,e){return C.defined("positions",t),dt(v.packArray(t),e,2)}},Tt=new h,Mt=new h,Zt=new h,Ct=new h,Et=new h,Ot=new h,R=new h,Lt=new v,Dt=new v,Ft=new v,j=new v;B.computeSubdivision=function(t,e,n,r,i){i=K(i,Y.RADIANS_PER_DEGREE);let u=D(r);C.typeOf.object("ellipsoid",t),C.defined("positions",e),C.defined("indices",n),C.typeOf.number.greaterThanOrEquals("indices.length",n.length,3),C.typeOf.number.equals("indices.length % 3","0",n.length%3,0),C.typeOf.number.greaterThan("granularity",i,0);let a,l=n.slice(0),o=e.length,x=new Array(3*o),p=new Array(2*o),s=0,y=0;for(a=0;a<o;a++){let t=e[a];if(x[s++]=t.x,x[s++]=t.y,x[s++]=t.z,u){let t=r[a];p[y++]=t.x,p[y++]=t.y}}let f=[],c={},m=t.maximumRadius,d=Y.chordLength(i,m),g=d*d;for(;l.length>0;){let t,e,n,r=l.pop(),i=l.pop(),o=l.pop(),s=h.fromArray(x,3*o,Tt),y=h.fromArray(x,3*i,Mt),d=h.fromArray(x,3*r,Zt);u&&(t=v.fromArray(p,2*o,Lt),e=v.fromArray(p,2*i,Dt),n=v.fromArray(p,2*r,Ft));let b,w,C,A=h.multiplyByScalar(h.normalize(s,Ct),m,Ct),S=h.multiplyByScalar(h.normalize(y,Et),m,Et),E=h.multiplyByScalar(h.normalize(d,Ot),m,Ot),O=h.magnitudeSquared(h.subtract(A,S,R)),Z=h.magnitudeSquared(h.subtract(S,E,R)),z=h.magnitudeSquared(h.subtract(E,A,R)),B=Math.max(O,Z,z);B>g?O===B?(b=`${Math.min(o,i)} ${Math.max(o,i)}`,a=c[b],D(a)||(w=h.add(s,y,R),h.multiplyByScalar(w,.5,w),x.push(w.x,w.y,w.z),a=x.length/3-1,c[b]=a,u&&(C=v.add(t,e,j),v.multiplyByScalar(C,.5,C),p.push(C.x,C.y))),l.push(o,a,r),l.push(a,i,r)):Z===B?(b=`${Math.min(i,r)} ${Math.max(i,r)}`,a=c[b],D(a)||(w=h.add(y,d,R),h.multiplyByScalar(w,.5,w),x.push(w.x,w.y,w.z),a=x.length/3-1,c[b]=a,u&&(C=v.add(e,n,j),v.multiplyByScalar(C,.5,C),p.push(C.x,C.y))),l.push(i,a,o),l.push(a,r,o)):z===B&&(b=`${Math.min(r,o)} ${Math.max(r,o)}`,a=c[b],D(a)||(w=h.add(d,s,R),h.multiplyByScalar(w,.5,w),x.push(w.x,w.y,w.z),a=x.length/3-1,c[b]=a,u&&(C=v.add(n,t,j),v.multiplyByScalar(C,.5,C),p.push(C.x,C.y))),l.push(r,a,i),l.push(a,o,i)):(f.push(o),f.push(i),f.push(r))}let b={attributes:{position:new nt({componentDatatype:et.DOUBLE,componentsPerAttribute:3,values:x})},indices:f,primitiveType:at.TRIANGLES};return u&&(b.attributes.st=new nt({componentDatatype:et.FLOAT,componentsPerAttribute:2,values:p})),new ht(b)};var Qt=new tt,Xt=new tt,Yt=new tt,gt=new tt;B.computeRhumbLineSubdivision=function(t,e,n,r,i){i=K(i,Y.RADIANS_PER_DEGREE);let u=D(r);C.typeOf.object("ellipsoid",t),C.defined("positions",e),C.defined("indices",n),C.typeOf.number.greaterThanOrEquals("indices.length",n.length,3),C.typeOf.number.equals("indices.length % 3","0",n.length%3,0),C.typeOf.number.greaterThan("granularity",i,0);let a,l=n.slice(0),o=e.length,x=new Array(3*o),p=new Array(2*o),s=0,y=0;for(a=0;a<o;a++){let t=e[a];if(x[s++]=t.x,x[s++]=t.y,x[s++]=t.z,u){let t=r[a];p[y++]=t.x,p[y++]=t.y}}let f=[],c={},m=t.maximumRadius,d=Y.chordLength(i,m),g=new st(void 0,void 0,t),b=new st(void 0,void 0,t),w=new st(void 0,void 0,t);for(;l.length>0;){let e,n,r,i=l.pop(),o=l.pop(),s=l.pop(),y=h.fromArray(x,3*s,Tt),m=h.fromArray(x,3*o,Mt),C=h.fromArray(x,3*i,Zt);u&&(e=v.fromArray(p,2*s,Lt),n=v.fromArray(p,2*o,Dt),r=v.fromArray(p,2*i,Ft));let A=t.cartesianToCartographic(y,Qt),S=t.cartesianToCartographic(m,Xt),E=t.cartesianToCartographic(C,Yt);g.setEndPoints(A,S);let O=g.surfaceDistance;b.setEndPoints(S,E);let Z=b.surfaceDistance;w.setEndPoints(E,A);let z,B,M,T,L,N=w.surfaceDistance,K=Math.max(O,Z,N);K>d?O===K?(z=`${Math.min(s,o)} ${Math.max(s,o)}`,a=c[z],D(a)||(B=g.interpolateUsingFraction(.5,gt),M=.5*(A.height+S.height),T=h.fromRadians(B.longitude,B.latitude,M,t,R),x.push(T.x,T.y,T.z),a=x.length/3-1,c[z]=a,u&&(L=v.add(e,n,j),v.multiplyByScalar(L,.5,L),p.push(L.x,L.y))),l.push(s,a,i),l.push(a,o,i)):Z===K?(z=`${Math.min(o,i)} ${Math.max(o,i)}`,a=c[z],D(a)||(B=b.interpolateUsingFraction(.5,gt),M=.5*(S.height+E.height),T=h.fromRadians(B.longitude,B.latitude,M,t,R),x.push(T.x,T.y,T.z),a=x.length/3-1,c[z]=a,u&&(L=v.add(n,r,j),v.multiplyByScalar(L,.5,L),p.push(L.x,L.y))),l.push(o,a,s),l.push(a,i,s)):N===K&&(z=`${Math.min(i,s)} ${Math.max(i,s)}`,a=c[z],D(a)||(B=w.interpolateUsingFraction(.5,gt),M=.5*(E.height+A.height),T=h.fromRadians(B.longitude,B.latitude,M,t,R),x.push(T.x,T.y,T.z),a=x.length/3-1,c[z]=a,u&&(L=v.add(r,e,j),v.multiplyByScalar(L,.5,L),p.push(L.x,L.y))),l.push(i,a,o),l.push(a,s,o)):(f.push(s),f.push(o),f.push(i))}let A={attributes:{position:new nt({componentDatatype:et.DOUBLE,componentsPerAttribute:3,values:x})},indices:f,primitiveType:at.TRIANGLES};return u&&(A.attributes.st=new nt({componentDatatype:et.FLOAT,componentsPerAttribute:2,values:p})),new ht(A)},B.scaleToGeodeticHeight=function(t,e,n,r){n=K(n,vt.default);let i=qt,u=Jt;if(e=K(e,0),r=K(r,!0),D(t)){let a=t.length;for(let l=0;l<a;l+=3)h.fromArray(t,l,u),r&&(u=n.scaleToGeodeticSurface(u,u)),0!==e&&(i=n.geodeticSurfaceNormal(u,i),h.multiplyByScalar(i,e,i),h.add(u,i,u)),t[l]=u.x,t[l+1]=u.y,t[l+2]=u.z}return t};var ge=B;export{pt as a,ge as b};