/**
 * @license
 * Cesium - https://github.com/CesiumGS/cesium
 * Version 1.126
 *
 * 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 J}from"./chunk-BAH467HD.js";import{a as Nt}from"./chunk-YGC52UMX.js";import{a as zt}from"./chunk-XLESIVYV.js";import"./chunk-MNEOPOLK.js";import"./chunk-I4G5DYCC.js";import{a as ut}from"./chunk-WDSHVSF7.js";import{a as X}from"./chunk-HZQ2LRMY.js";import{b as Rt}from"./chunk-WV3AQKZG.js";import"./chunk-CZ6DDD6J.js";import"./chunk-26PPBGHW.js";import"./chunk-FMJWH3RL.js";import{a as yt}from"./chunk-E25VRLIZ.js";import{a as Vt}from"./chunk-FZEJ65E6.js";import{b as Mt,c as Pt,d as q}from"./chunk-SPFUTSGC.js";import{d as st}from"./chunk-E2NX4UJ2.js";import{f as Lt,h as E,i as At}from"./chunk-JBPQP6LH.js";import{a as Y}from"./chunk-NLPIV6OK.js";import{a as w,b as _t,c as G,d as H,e as ft}from"./chunk-IIT3SHXK.js";import{a as W}from"./chunk-DLCTHPIV.js";import"./chunk-GMF7KJHC.js";import"./chunk-NYFH7JC3.js";import{a as L}from"./chunk-I2ICH2LD.js";import{a as St,b as lt}from"./chunk-R6A52HT4.js";import{e as $}from"./chunk-D32DZSEC.js";var Tt=new w,Bt=new w,Ut=new w,Yt=new w,qt=new E,Zt=new G,Kt=new st,$t=new st;function Xt(t,e){let n=new Pt({attributes:new Vt,primitiveType:Mt.TRIANGLES});return n.attributes.position=new q({componentDatatype:Y.DOUBLE,componentsPerAttribute:3,values:e.positions}),t.normal&&(n.attributes.normal=new q({componentDatatype:Y.FLOAT,componentsPerAttribute:3,values:e.normals})),t.tangent&&(n.attributes.tangent=new q({componentDatatype:Y.FLOAT,componentsPerAttribute:3,values:e.tangents})),t.bitangent&&(n.attributes.bitangent=new q({componentDatatype:Y.FLOAT,componentsPerAttribute:3,values:e.bitangents})),n}function Gt(t,e,n,o){let a=t.length,r=e.normal?new Float32Array(a):void 0,i=e.tangent?new Float32Array(a):void 0,s=e.bitangent?new Float32Array(a):void 0,l=0,u=Yt,c=Ut,m=Bt;if(e.normal||e.tangent||e.bitangent)for(let p=0;p<a;p+=3){let a=w.fromArray(t,p,Tt),h=l+1,f=l+2;m=n.geodeticSurfaceNormal(a,m),(e.tangent||e.bitangent)&&(w.cross(w.UNIT_Z,m,c),ft.multiplyByVector(o,c,c),w.normalize(c,c),e.bitangent&&w.normalize(w.cross(m,c,u),u)),e.normal&&(r[l]=m.x,r[h]=m.y,r[f]=m.z),e.tangent&&(i[l]=c.x,i[h]=c.y,i[f]=c.z),e.bitangent&&(s[l]=u.x,s[h]=u.y,s[f]=u.z),l+=3}return Xt(e,{positions:t,normals:r,tangents:i,bitangents:s})}var Ct=new w,jt=new w;function te(t,e,n){let o=t.length,a=e.normal?new Float32Array(o):void 0,r=e.tangent?new Float32Array(o):void 0,i=e.bitangent?new Float32Array(o):void 0,s=0,l=0,u=0,c=!0,m=Yt,p=Ut,h=Bt;if(e.normal||e.tangent||e.bitangent)for(let f=0;f<o;f+=6){let g=w.fromArray(t,f,Tt),d=w.fromArray(t,(f+6)%o,Ct);if(c){let e=w.fromArray(t,(f+3)%o,jt);w.subtract(d,g,d),w.subtract(e,g,e),h=w.normalize(w.cross(e,d,h),h),c=!1}w.equalsEpsilon(d,g,W.EPSILON10)&&(c=!0),(e.tangent||e.bitangent)&&(m=n.geodeticSurfaceNormal(g,m),e.tangent&&(p=w.normalize(w.cross(m,h,p),p))),e.normal&&(a[s++]=h.x,a[s++]=h.y,a[s++]=h.z,a[s++]=h.x,a[s++]=h.y,a[s++]=h.z),e.tangent&&(r[l++]=p.x,r[l++]=p.y,r[l++]=p.z,r[l++]=p.x,r[l++]=p.y,r[l++]=p.z),e.bitangent&&(i[u++]=m.x,i[u++]=m.y,i[u++]=m.z,i[u++]=m.x,i[u++]=m.y,i[u++]=m.z)}return Xt(e,{positions:t,normals:a,tangents:r,bitangents:i})}function It(t,e){let n=t._vertexFormat,o=t._ellipsoid,a=e.height,r=e.width,i=e.northCap,s=e.southCap,l=0,u=a,c=a,m=0;i&&(l=1,c-=1,m+=1),s&&(u-=1,c-=1,m+=1),m+=r*c;let p=n.position?new Float64Array(3*m):void 0,h=n.st?new Float32Array(2*m):void 0,f=0,g=0,d=Tt,w=Zt,_=Number.MAX_VALUE,y=Number.MAX_VALUE,b=-Number.MAX_VALUE,A=-Number.MAX_VALUE;for(let k=l;k<u;++k)for(let t=0;t<r;++t)J.computePosition(e,o,n.st,k,t,d,w),p[f++]=d.x,p[f++]=d.y,p[f++]=d.z,n.st&&(h[g++]=w.x,h[g++]=w.y,_=Math.min(_,w.x),y=Math.min(y,w.y),b=Math.max(b,w.x),A=Math.max(A,w.y));if(i&&(J.computePosition(e,o,n.st,0,0,d,w),p[f++]=d.x,p[f++]=d.y,p[f++]=d.z,n.st&&(h[g++]=w.x,h[g++]=w.y,_=w.x,y=w.y,b=w.x,A=w.y)),s&&(J.computePosition(e,o,n.st,a-1,0,d,w),p[f++]=d.x,p[f++]=d.y,p[f]=d.z,n.st&&(h[g++]=w.x,h[g]=w.y,_=Math.min(_,w.x),y=Math.min(y,w.y),b=Math.max(b,w.x),A=Math.max(A,w.y))),n.st&&(_<0||y<0||b>1||A>1))for(let k=0;k<h.length;k+=2)h[k]=(h[k]-_)/(b-_),h[k+1]=(h[k+1]-y)/(A-y);let v=Gt(p,n,o,e.tangentRotationMatrix),E=6*(r-1)*(c-1);i&&(E+=3*(r-1)),s&&(E+=3*(r-1));let x,L=yt.createTypedArray(m,E),H=0,P=0;for(x=0;x<c-1;++x){for(let t=0;t<r-1;++t){let t=H,e=t+r,n=e+1,o=t+1;L[P++]=t,L[P++]=e,L[P++]=o,L[P++]=o,L[P++]=e,L[P++]=n,++H}++H}if(i||s){let t,e,n=m-1,o=m-1;if(i&&s&&(n=m-2),H=0,i)for(x=0;x<r-1;x++)t=H,e=t+1,L[P++]=n,L[P++]=t,L[P++]=e,++H;if(s)for(H=(c-1)*r,x=0;x<r-1;x++)t=H,e=t+1,L[P++]=t,L[P++]=o,L[P++]=e,++H}return v.indices=L,n.st&&(v.attributes.st=new q({componentDatatype:Y.FLOAT,componentsPerAttribute:2,values:h})),v}function ht(t,e,n,o,a){return t[e++]=o[n],t[e++]=o[n+1],t[e++]=o[n+2],t[e++]=a[n],t[e++]=a[n+1],t[e]=a[n+2],t}function dt(t,e,n,o){return t[e++]=o[n],t[e++]=o[n+1],t[e++]=o[n],t[e]=o[n+1],t}var Dt=new X;function ee(t,e){let n,o=t._shadowVolume,a=t._offsetAttribute,r=t._vertexFormat,i=t._extrudedHeight,s=t._surfaceHeight,l=t._ellipsoid,u=e.height,c=e.width;if(o){let e=X.clone(r,Dt);e.normal=!0,t._vertexFormat=e}let m=It(t,e);o&&(t._vertexFormat=r);let p=Rt.scaleToGeodeticHeight(m.attributes.position.values,s,l,!1);p=new Float64Array(p);let h=p.length,f=2*h,g=new Float64Array(f);g.set(p);let d=Rt.scaleToGeodeticHeight(m.attributes.position.values,i,l);g.set(d,h),m.attributes.position.values=g;let _,y,b=r.normal?new Float32Array(f):void 0,A=r.tangent?new Float32Array(f):void 0,v=r.bitangent?new Float32Array(f):void 0,E=r.st?new Float32Array(f/3*2):void 0;if(r.normal){for(y=m.attributes.normal.values,b.set(y),n=0;n<h;n++)y[n]=-y[n];b.set(y,h),m.attributes.normal.values=b}if(o){y=m.attributes.normal.values,r.normal||(m.attributes.normal=void 0);let t=new Float32Array(f);for(n=0;n<h;n++)y[n]=-y[n];t.set(y,h),m.attributes.extrudeDirection=new q({componentDatatype:Y.FLOAT,componentsPerAttribute:3,values:t})}let x,L=$(a);if(L){let t=h/3*2,e=new Uint8Array(t);a===ut.TOP?e=e.fill(1,0,t/2):(x=a===ut.NONE?0:1,e=e.fill(x)),m.attributes.applyOffset=new q({componentDatatype:Y.UNSIGNED_BYTE,componentsPerAttribute:1,values:e})}if(r.tangent){let t=m.attributes.tangent.values;for(A.set(t),n=0;n<h;n++)t[n]=-t[n];A.set(t,h),m.attributes.tangent.values=A}if(r.bitangent){let t=m.attributes.bitangent.values;v.set(t),v.set(t,h),m.attributes.bitangent.values=v}r.st&&(_=m.attributes.st.values,E.set(_),E.set(_,h/3*2),m.attributes.st.values=E);let H=m.indices,P=H.length,k=h/3,F=yt.createTypedArray(f/3,2*P);for(F.set(H),n=0;n<P;n+=3)F[n+P]=H[n+2]+k,F[n+1+P]=H[n+1]+k,F[n+2+P]=H[n]+k;m.indices=F;let R=e.northCap,D=e.southCap,T=u,N=2,O=0,j=4,I=4;R&&(N-=1,T-=1,O+=1,j-=2,I-=1),D&&(N-=1,T-=1,O+=1,j-=2,I-=1),O+=N*c+2*T-j;let S=2*(O+I),G=new Float64Array(3*S),C=o?new Float32Array(3*S):void 0,M=L?new Uint8Array(S):void 0,V=r.st?new Float32Array(2*S):void 0,J=a===ut.TOP;L&&!J&&(x=a===ut.ALL?1:0,M=M.fill(x));let U,z=0,Q=0,B=0,Z=0,K=c*T;for(n=0;n<K;n+=c)U=3*n,G=ht(G,z,U,p,d),z+=6,r.st&&(V=dt(V,Q,2*n,_),Q+=4),o&&(B+=3,C[B++]=y[U],C[B++]=y[U+1],C[B++]=y[U+2]),J&&(M[Z++]=1,Z+=1);if(D){let t=R?K+1:K;for(U=3*t,n=0;n<2;n++)G=ht(G,z,U,p,d),z+=6,r.st&&(V=dt(V,Q,2*t,_),Q+=4),o&&(B+=3,C[B++]=y[U],C[B++]=y[U+1],C[B++]=y[U+2]),J&&(M[Z++]=1,Z+=1)}else for(n=K-c;n<K;n++)U=3*n,G=ht(G,z,U,p,d),z+=6,r.st&&(V=dt(V,Q,2*n,_),Q+=4),o&&(B+=3,C[B++]=y[U],C[B++]=y[U+1],C[B++]=y[U+2]),J&&(M[Z++]=1,Z+=1);for(n=K-1;n>0;n-=c)U=3*n,G=ht(G,z,U,p,d),z+=6,r.st&&(V=dt(V,Q,2*n,_),Q+=4),o&&(B+=3,C[B++]=y[U],C[B++]=y[U+1],C[B++]=y[U+2]),J&&(M[Z++]=1,Z+=1);if(R){let t=K;for(U=3*t,n=0;n<2;n++)G=ht(G,z,U,p,d),z+=6,r.st&&(V=dt(V,Q,2*t,_),Q+=4),o&&(B+=3,C[B++]=y[U],C[B++]=y[U+1],C[B++]=y[U+2]),J&&(M[Z++]=1,Z+=1)}else for(n=c-1;n>=0;n--)U=3*n,G=ht(G,z,U,p,d),z+=6,r.st&&(V=dt(V,Q,2*n,_),Q+=4),o&&(B+=3,C[B++]=y[U],C[B++]=y[U+1],C[B++]=y[U+2]),J&&(M[Z++]=1,Z+=1);let tt=te(G,r,l);r.st&&(tt.attributes.st=new q({componentDatatype:Y.FLOAT,componentsPerAttribute:2,values:V})),o&&(tt.attributes.extrudeDirection=new q({componentDatatype:Y.FLOAT,componentsPerAttribute:3,values:C})),L&&(tt.attributes.applyOffset=new q({componentDatatype:Y.UNSIGNED_BYTE,componentsPerAttribute:1,values:M}));let et,nt,ot,at,rt=yt.createTypedArray(S,6*O);h=G.length/3;let it=0;for(n=0;n<h-1;n+=2){et=n,at=(et+2)%h;let t=w.fromArray(G,3*et,Ct),e=w.fromArray(G,3*at,jt);w.equalsEpsilon(t,e,W.EPSILON10)||(nt=(et+1)%h,ot=(nt+2)%h,rt[it++]=et,rt[it++]=nt,rt[it++]=at,rt[it++]=at,rt[it++]=nt,rt[it++]=ot)}return tt.indices=rt,tt=zt.combineInstances([new Nt({geometry:m}),new Nt({geometry:tt})]),tt[0]}var ne=[new w,new w,new w,new w],Wt=new _t,oe=new _t;function Ht(t,e,n,o,a){if(0===n)return E.clone(t,a);let r=J.computeOptions(t,e,n,0,qt,Wt),i=r.height,s=r.width,l=ne;return J.computePosition(r,o,!1,0,0,l[0]),J.computePosition(r,o,!1,0,s-1,l[1]),J.computePosition(r,o,!1,i-1,0,l[2]),J.computePosition(r,o,!1,i-1,s-1,l[3]),E.fromCartesianArray(l,o,a)}function Q(t){t=L(t,L.EMPTY_OBJECT);let e=t.rectangle;if(lt.typeOf.object("rectangle",e),E._validate(e),e.north<e.south)throw new St("options.rectangle.north must be greater than or equal to options.rectangle.south");let n=L(t.height,0),o=L(t.extrudedHeight,n);this._rectangle=E.clone(e),this._granularity=L(t.granularity,W.RADIANS_PER_DEGREE),this._ellipsoid=H.clone(L(t.ellipsoid,H.default)),this._surfaceHeight=Math.max(n,o),this._rotation=L(t.rotation,0),this._stRotation=L(t.stRotation,0),this._vertexFormat=X.clone(L(t.vertexFormat,X.DEFAULT)),this._extrudedHeight=Math.min(n,o),this._shadowVolume=L(t.shadowVolume,!1),this._workerName="createRectangleGeometry",this._offsetAttribute=t.offsetAttribute,this._rotatedRectangle=void 0,this._textureCoordinateRotationPoints=void 0}Q.packedLength=E.packedLength+H.packedLength+X.packedLength+7,Q.pack=function(t,e,n){return lt.typeOf.object("value",t),lt.defined("array",e),n=L(n,0),E.pack(t._rectangle,e,n),n+=E.packedLength,H.pack(t._ellipsoid,e,n),n+=H.packedLength,X.pack(t._vertexFormat,e,n),n+=X.packedLength,e[n++]=t._granularity,e[n++]=t._surfaceHeight,e[n++]=t._rotation,e[n++]=t._stRotation,e[n++]=t._extrudedHeight,e[n++]=t._shadowVolume?1:0,e[n]=L(t._offsetAttribute,-1),e};var Jt=new E,Qt=H.clone(H.UNIT_SPHERE),tt={rectangle:Jt,ellipsoid:Qt,vertexFormat:Dt,granularity:void 0,height:void 0,rotation:void 0,stRotation:void 0,extrudedHeight:void 0,shadowVolume:void 0,offsetAttribute:void 0};Q.unpack=function(t,e,n){lt.defined("array",t),e=L(e,0);let o=E.unpack(t,e,Jt);e+=E.packedLength;let a=H.unpack(t,e,Qt);e+=H.packedLength;let r=X.unpack(t,e,Dt);e+=X.packedLength;let i=t[e++],s=t[e++],l=t[e++],u=t[e++],c=t[e++],m=1===t[e++],p=t[e];return $(n)?(n._rectangle=E.clone(o,n._rectangle),n._ellipsoid=H.clone(a,n._ellipsoid),n._vertexFormat=X.clone(r,n._vertexFormat),n._granularity=i,n._surfaceHeight=s,n._rotation=l,n._stRotation=u,n._extrudedHeight=c,n._shadowVolume=m,n._offsetAttribute=-1===p?void 0:p,n):(tt.granularity=i,tt.height=s,tt.rotation=l,tt.stRotation=u,tt.extrudedHeight=c,tt.shadowVolume=m,tt.offsetAttribute=-1===p?void 0:p,new Q(tt))},Q.computeRectangle=function(t,e){t=L(t,L.EMPTY_OBJECT);let n=t.rectangle;if(lt.typeOf.object("rectangle",n),E._validate(n),n.north<n.south)throw new St("options.rectangle.north must be greater than or equal to options.rectangle.south");let o=L(t.granularity,W.RADIANS_PER_DEGREE),a=L(t.ellipsoid,H.default),r=L(t.rotation,0);return Ht(n,o,r,a,e)};var ie=new ft,Ft=new Lt,ae=new _t;Q.createGeometry=function(t){if(W.equalsEpsilon(t._rectangle.north,t._rectangle.south,W.EPSILON10)||W.equalsEpsilon(t._rectangle.east,t._rectangle.west,W.EPSILON10))return;let e=t._rectangle,n=t._ellipsoid,o=t._rotation,a=t._stRotation,r=t._vertexFormat,i=J.computeOptions(e,t._granularity,o,a,qt,Wt,oe),s=ie;if(0!==a||0!==o){let t=E.center(e,ae),o=n.geodeticSurfaceNormalCartographic(t,Ct);Lt.fromAxisAngle(o,-a,Ft),ft.fromQuaternion(Ft,s)}else ft.clone(ft.IDENTITY,s);let l,u,c=t._surfaceHeight,m=t._extrudedHeight,p=!W.equalsEpsilon(c,m,0,W.EPSILON2);if(i.lonScalar=1/t._rectangle.width,i.latScalar=1/t._rectangle.height,i.tangentRotationMatrix=s,e=t._rectangle,p){l=ee(t,i);let o=st.fromRectangle3D(e,n,c,$t),a=st.fromRectangle3D(e,n,m,Kt);u=st.union(o,a)}else{if(l=It(t,i),l.attributes.position.values=Rt.scaleToGeodeticHeight(l.attributes.position.values,c,n,!1),$(t._offsetAttribute)){let e=l.attributes.position.values.length,n=t._offsetAttribute===ut.NONE?0:1,o=new Uint8Array(e/3).fill(n);l.attributes.applyOffset=new q({componentDatatype:Y.UNSIGNED_BYTE,componentsPerAttribute:1,values:o})}u=st.fromRectangle3D(e,n,c)}return r.position||delete l.attributes.position,new Pt({attributes:l.attributes,indices:l.indices,primitiveType:l.primitiveType,boundingSphere:u,offsetAttribute:t._offsetAttribute})},Q.createShadowVolume=function(t,e,n){let o=t._granularity,a=t._ellipsoid,r=e(o,a),i=n(o,a);return new Q({rectangle:t._rectangle,rotation:t._rotation,ellipsoid:a,stRotation:t._stRotation,granularity:o,extrudedHeight:i,height:r,vertexFormat:X.POSITION_ONLY,shadowVolume:!0})};var vt=new E,se=[new G,new G,new G],re=new At,ce=new _t;function le(t){if(0===t._stRotation)return[0,0,0,1,1,0];let e=E.clone(t._rectangle,vt),n=t._granularity,o=t._ellipsoid,a=t._rotation-t._stRotation,r=Ht(e,n,a,o,vt),i=se;i[0].x=r.west,i[0].y=r.south,i[1].x=r.west,i[1].y=r.north,i[2].x=r.east,i[2].y=r.south;let s=t.rectangle,l=At.fromRotation(t._stRotation,re),u=E.center(s,ce);for(let f=0;f<3;++f){let t=i[f];t.x-=u.longitude,t.y-=u.latitude,At.multiplyByVector(l,t,t),t.x+=u.longitude,t.y+=u.latitude,t.x=(t.x-s.west)/s.width,t.y=(t.y-s.south)/s.height}let c=i[0],m=i[1],p=i[2],h=new Array(6);return G.pack(c,h),G.pack(m,h,2),G.pack(p,h,4),h}Object.defineProperties(Q.prototype,{rectangle:{get:function(){return $(this._rotatedRectangle)||(this._rotatedRectangle=Ht(this._rectangle,this._granularity,this._rotation,this._ellipsoid)),this._rotatedRectangle}},textureCoordinateRotationPoints:{get:function(){return $(this._textureCoordinateRotationPoints)||(this._textureCoordinateRotationPoints=le(this)),this._textureCoordinateRotationPoints}}});var Ot=Q;function fe(t,e){return $(e)&&(t=Ot.unpack(t,e)),t._ellipsoid=H.clone(t._ellipsoid),t._rectangle=E.clone(t._rectangle),Ot.createGeometry(t)}var Ye=fe;export{Ye as default};