/**
 * @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 M}from"./chunk-OWZATOOT.js";import{a as ht}from"./chunk-2H32TJK3.js";import"./chunk-AUO2K2B5.js";import"./chunk-55B3WQ6I.js";import{a as _t}from"./chunk-WDSHVSF7.js";import{a as G}from"./chunk-HZQ2LRMY.js";import"./chunk-EP544XEE.js";import"./chunk-MDIGQ5JT.js";import{b as yt}from"./chunk-WV3AQKZG.js";import{a as Pt}from"./chunk-K4QHJFYW.js";import"./chunk-CZ6DDD6J.js";import"./chunk-26PPBGHW.js";import"./chunk-FMJWH3RL.js";import{a as Nt}from"./chunk-E25VRLIZ.js";import{a as Ct}from"./chunk-FZEJ65E6.js";import{b as Mt,c as Vt,d as x}from"./chunk-SPFUTSGC.js";import{d as St}from"./chunk-E2NX4UJ2.js";import{h as Et}from"./chunk-JBPQP6LH.js";import{a as F}from"./chunk-NLPIV6OK.js";import{a as o,b as bt,d as I}from"./chunk-IIT3SHXK.js";import{a as st}from"./chunk-DLCTHPIV.js";import"./chunk-GMF7KJHC.js";import"./chunk-NYFH7JC3.js";import{a as B}from"./chunk-I2ICH2LD.js";import{b as it}from"./chunk-R6A52HT4.js";import{e as X}from"./chunk-D32DZSEC.js";var zt=new o,kt=new o,wt=new o,Tt=new o,jt=new o,Ht=new o,at=new o,ft=new o;function Ut(t,e){for(let o=0;o<t.length;o++)t[o]=e.scaleToGeodeticSurface(t[o],t[o]);return t}function Z(t,e,r,i,a,n){let s=t.normals,l=t.tangents,u=t.bitangents,d=o.normalize(o.cross(r,e,at),at);n.normal&&M.addAttribute(s,e,i,a),n.tangent&&M.addAttribute(l,d,i,a),n.bitangent&&M.addAttribute(u,r,i,a)}function Bt(t,e,r){let i,a,n,s=t.positions,l=t.corners,u=t.endPositions,d=t.lefts,m=t.normals,h=new Ct,f=0,c=0,p=0;for(a=0;a<s.length;a+=2)n=s[a].length-3,f+=n,p+=2*n,c+=s[a+1].length-3;for(f+=3,c+=3,a=0;a<l.length;a++){i=l[a];let t=l[a].leftPositions;X(t)?(n=t.length,f+=n,p+=n):(n=l[a].rightPositions.length,c+=n,p+=n)}let g,A=X(u);A&&(g=u[0].length-3,f+=g,c+=g,g/=3,p+=6*g);let b,y,_,w,v,T,I=f+c,k=new Float64Array(I),E=e.normal?new Float32Array(I):void 0,N=e.tangent?new Float32Array(I):void 0,j=e.bitangent?new Float32Array(I):void 0,P={normals:E,tangents:N,bitangents:j},O=0,D=I-1,B=zt,G=kt,H=g/2,L=Nt.createTypedArray(I/3,p),S=0;if(A){T=wt,v=Tt;let t=u[0];for(B=o.fromArray(m,0,B),G=o.fromArray(d,0,G),a=0;a<H;a++)T=o.fromArray(t,3*(H-1-a),T),v=o.fromArray(t,3*(H+a),v),M.addAttribute(k,v,O),M.addAttribute(k,T,void 0,D),Z(P,B,G,O,D,e),y=O/3,w=y+1,b=(D-2)/3,_=b-1,L[S++]=b,L[S++]=y,L[S++]=_,L[S++]=_,L[S++]=y,L[S++]=w,O+=3,D-=3}let W,V,R=0,K=0,Q=s[R++],C=s[R++];for(k.set(Q,O),k.set(C,D-C.length+1),G=o.fromArray(d,K,G),n=C.length-3,a=0;a<n;a+=3)W=r.geodeticSurfaceNormal(o.fromArray(Q,a,at),at),V=r.geodeticSurfaceNormal(o.fromArray(C,n-a,ft),ft),B=o.normalize(o.add(W,V,B),B),Z(P,B,G,O,D,e),y=O/3,w=y+1,b=(D-2)/3,_=b-1,L[S++]=b,L[S++]=y,L[S++]=_,L[S++]=_,L[S++]=y,L[S++]=w,O+=3,D-=3;for(W=r.geodeticSurfaceNormal(o.fromArray(Q,n,at),at),V=r.geodeticSurfaceNormal(o.fromArray(C,n,ft),ft),B=o.normalize(o.add(W,V,B),B),K+=3,a=0;a<l.length;a++){let t;i=l[a];let u,h,f=i.leftPositions,c=i.rightPositions,p=Ht,g=wt,A=Tt;if(B=o.fromArray(m,K,B),X(f)){for(Z(P,B,G,void 0,D,e),D-=3,u=w,h=_,t=0;t<f.length/3;t++)p=o.fromArray(f,3*t,p),L[S++]=u,L[S++]=h-t-1,L[S++]=h-t,M.addAttribute(k,p,void 0,D),g=o.fromArray(k,3*(h-t-1),g),A=o.fromArray(k,3*u,A),G=o.normalize(o.subtract(g,A,G),G),Z(P,B,G,void 0,D,e),D-=3;p=o.fromArray(k,3*u,p),g=o.subtract(o.fromArray(k,3*h,g),p,g),A=o.subtract(o.fromArray(k,3*(h-t),A),p,A),G=o.normalize(o.add(g,A,G),G),Z(P,B,G,O,void 0,e),O+=3}else{for(Z(P,B,G,O,void 0,e),O+=3,u=_,h=w,t=0;t<c.length/3;t++)p=o.fromArray(c,3*t,p),L[S++]=u,L[S++]=h+t,L[S++]=h+t+1,M.addAttribute(k,p,O),g=o.fromArray(k,3*u,g),A=o.fromArray(k,3*(h+t),A),G=o.normalize(o.subtract(g,A,G),G),Z(P,B,G,O,void 0,e),O+=3;p=o.fromArray(k,3*u,p),g=o.subtract(o.fromArray(k,3*(h+t),g),p,g),A=o.subtract(o.fromArray(k,3*h,A),p,A),G=o.normalize(o.negate(o.add(A,g,G),G),G),Z(P,B,G,void 0,D,e),D-=3}for(Q=s[R++],C=s[R++],Q.splice(0,3),C.splice(C.length-3,3),k.set(Q,O),k.set(C,D-C.length+1),n=C.length-3,K+=3,G=o.fromArray(d,K,G),t=0;t<C.length;t+=3)W=r.geodeticSurfaceNormal(o.fromArray(Q,t,at),at),V=r.geodeticSurfaceNormal(o.fromArray(C,n-t,ft),ft),B=o.normalize(o.add(W,V,B),B),Z(P,B,G,O,D,e),w=O/3,y=w-1,_=(D-2)/3,b=_+1,L[S++]=b,L[S++]=y,L[S++]=_,L[S++]=_,L[S++]=y,L[S++]=w,O+=3,D-=3;O-=3,D+=3}if(B=o.fromArray(m,m.length-3,B),Z(P,B,G,O,D,e),A){O+=3,D-=3,T=wt,v=Tt;let t=u[1];for(a=0;a<H;a++)T=o.fromArray(t,3*(g-a-1),T),v=o.fromArray(t,3*a,v),M.addAttribute(k,T,void 0,D),M.addAttribute(k,v,O),Z(P,B,G,O,D,e),w=O/3,y=w-1,_=(D-2)/3,b=_+1,L[S++]=b,L[S++]=y,L[S++]=_,L[S++]=_,L[S++]=y,L[S++]=w,O+=3,D-=3}if(h.position=new x({componentDatatype:F.DOUBLE,componentsPerAttribute:3,values:k}),e.st){let t,e,o=new Float32Array(I/3*2),r=0;if(A){f/=3,c/=3;let i=Math.PI/(g+1);e=1/(f-g+1),t=1/(c-g+1);let n,s=g/2;for(a=s+1;a<g+1;a++)n=st.PI_OVER_TWO+i*a,o[r++]=t*(1+Math.cos(n)),o[r++]=.5*(1+Math.sin(n));for(a=1;a<c-g+1;a++)o[r++]=a*t,o[r++]=0;for(a=g;a>s;a--)n=st.PI_OVER_TWO-a*i,o[r++]=1-t*(1+Math.cos(n)),o[r++]=.5*(1+Math.sin(n));for(a=s;a>0;a--)n=st.PI_OVER_TWO-i*a,o[r++]=1-e*(1+Math.cos(n)),o[r++]=.5*(1+Math.sin(n));for(a=f-g;a>0;a--)o[r++]=a*e,o[r++]=1;for(a=1;a<s+1;a++)n=st.PI_OVER_TWO+i*a,o[r++]=e*(1+Math.cos(n)),o[r++]=.5*(1+Math.sin(n))}else{for(f/=3,c/=3,e=1/(f-1),t=1/(c-1),a=0;a<c;a++)o[r++]=a*t,o[r++]=0;for(a=f;a>0;a--)o[r++]=(a-1)*e,o[r++]=1}h.st=new x({componentDatatype:F.FLOAT,componentsPerAttribute:2,values:o})}return e.normal&&(h.normal=new x({componentDatatype:F.FLOAT,componentsPerAttribute:3,values:P.normals})),e.tangent&&(h.tangent=new x({componentDatatype:F.FLOAT,componentsPerAttribute:3,values:P.tangents})),e.bitangent&&(h.bitangent=new x({componentDatatype:F.FLOAT,componentsPerAttribute:3,values:P.bitangents})),{attributes:h,indices:L}}function qt(t,e){if(!e.normal&&!e.tangent&&!e.bitangent&&!e.st)return t;let r,i,a=t.position.values;(e.normal||e.bitangent)&&(r=t.normal.values,i=t.bitangent.values);let n,s=t.position.values.length/18,l=3*s,u=2*s,d=2*l;if(e.normal||e.bitangent||e.tangent){let s=e.normal?new Float32Array(6*l):void 0,u=e.tangent?new Float32Array(6*l):void 0,m=e.bitangent?new Float32Array(6*l):void 0,h=zt,f=kt,c=wt,p=Tt,g=jt,A=Ht,b=d;for(n=0;n<l;n+=3){let t=b+d;h=o.fromArray(a,n,h),f=o.fromArray(a,n+l,f),c=o.fromArray(a,(n+3)%l,c),f=o.subtract(f,h,f),c=o.subtract(c,h,c),p=o.normalize(o.cross(f,c,p),p),e.normal&&(M.addAttribute(s,p,t),M.addAttribute(s,p,t+3),M.addAttribute(s,p,b),M.addAttribute(s,p,b+3)),(e.tangent||e.bitangent)&&(A=o.fromArray(r,n,A),e.bitangent&&(M.addAttribute(m,A,t),M.addAttribute(m,A,t+3),M.addAttribute(m,A,b),M.addAttribute(m,A,b+3)),e.tangent&&(g=o.normalize(o.cross(A,p,g),g),M.addAttribute(u,g,t),M.addAttribute(u,g,t+3),M.addAttribute(u,g,b),M.addAttribute(u,g,b+3))),b+=6}if(e.normal){for(s.set(r),n=0;n<l;n+=3)s[n+l]=-r[n],s[n+l+1]=-r[n+1],s[n+l+2]=-r[n+2];t.normal.values=s}else t.normal=void 0;if(e.bitangent?(m.set(i),m.set(i,l),t.bitangent.values=m):t.bitangent=void 0,e.tangent){let e=t.tangent.values;u.set(e),u.set(e,l),t.tangent.values=u}}if(e.st){let e=t.st.values,o=new Float32Array(6*u);o.set(e),o.set(e,u);let r=2*u;for(let t=0;t<2;t++){for(o[r++]=e[0],o[r++]=e[1],n=2;n<u;n+=2){let t=e[n],i=e[n+1];o[r++]=t,o[r++]=i,o[r++]=t,o[r++]=i}o[r++]=e[0],o[r++]=e[1]}t.st.values=o}return t}function Ot(t,e,o){o[e++]=t[0],o[e++]=t[1],o[e++]=t[2];for(let r=3;r<t.length;r+=3){let i=t[r],a=t[r+1],n=t[r+2];o[e++]=i,o[e++]=a,o[e++]=n,o[e++]=i,o[e++]=a,o[e++]=n}return o[e++]=t[0],o[e++]=t[1],o[e++]=t[2],o}function Jt(t,e){let o=new G({position:e.position,normal:e.normal||e.bitangent||t.shadowVolume,tangent:e.tangent,bitangent:e.normal||e.bitangent,st:e.st}),r=t.ellipsoid,i=M.computePositions(t),a=Bt(i,o,r),n=t.height,s=t.extrudedHeight,l=a.attributes,u=a.indices,d=l.position.values,m=d.length,h=new Float64Array(6*m),f=new Float64Array(m);f.set(d);let c=new Float64Array(4*m);d=yt.scaleToGeodeticHeight(d,n,r),c=Ot(d,0,c),f=yt.scaleToGeodeticHeight(f,s,r),c=Ot(f,2*m,c),h.set(d),h.set(f,m),h.set(c,2*m),l.position.values=h,l=qt(l,e);let p,g=m/3;if(t.shadowVolume){let t=l.normal.values;m=t.length;let o=new Float32Array(6*m);for(p=0;p<m;p++)t[p]=-t[p];o.set(t,m),o=Ot(t,4*m,o),l.extrudeDirection=new x({componentDatatype:F.FLOAT,componentsPerAttribute:3,values:o}),e.normal||(l.normal=void 0)}if(X(t.offsetAttribute)){let e=new Uint8Array(6*g);if(t.offsetAttribute===_t.TOP)e=e.fill(1,0,g).fill(1,2*g,4*g);else{let o=t.offsetAttribute===_t.NONE?0:1;e=e.fill(o)}l.applyOffset=new x({componentDatatype:F.UNSIGNED_BYTE,componentsPerAttribute:1,values:e})}let A=u.length,b=g+g,y=Nt.createTypedArray(h.length/3,2*A+3*b);y.set(u);let _,w,v,T,I=A;for(p=0;p<A;p+=3){let t=u[p],e=u[p+1],o=u[p+2];y[I++]=o+g,y[I++]=e+g,y[I++]=t+g}for(p=0;p<b;p+=2)_=p+b,w=_+b,v=_+1,T=w+1,y[I++]=_,y[I++]=w,y[I++]=v,y[I++]=v,y[I++]=w,y[I++]=T;return{attributes:l,indices:y}}var Dt=new o,gt=new o,Q=new bt;function Rt(t,e,r,i,a,n){let s=o.subtract(e,t,Dt);o.normalize(s,s);let l=r.geodeticSurfaceNormal(t,gt),u=o.cross(s,l,Dt);o.multiplyByScalar(u,i,u);let d=a.latitude,m=a.longitude,h=n.latitude,f=n.longitude;o.add(t,u,gt),r.cartesianToCartographic(gt,Q);let c=Q.latitude,p=Q.longitude;d=Math.min(d,c),m=Math.min(m,p),h=Math.max(h,c),f=Math.max(f,p),o.subtract(t,u,gt),r.cartesianToCartographic(gt,Q),c=Q.latitude,p=Q.longitude,d=Math.min(d,c),m=Math.min(m,p),h=Math.max(h,c),f=Math.max(f,p),a.latitude=d,a.longitude=m,n.latitude=h,n.longitude=f}var K=new o,pt=new o,W=new bt,j=new bt;function Yt(t,e,r,i,a){t=Ut(t,e);let n=Pt(t,o.equalsEpsilon),s=n.length;if(s<2||r<=0)return new Et;let l,u,d=.5*r;if(W.latitude=Number.POSITIVE_INFINITY,W.longitude=Number.POSITIVE_INFINITY,j.latitude=Number.NEGATIVE_INFINITY,j.longitude=Number.NEGATIVE_INFINITY,i===ht.ROUNDED){let t=n[0];o.subtract(t,n[1],K),o.normalize(K,K),o.multiplyByScalar(K,d,K),o.add(t,K,pt),e.cartesianToCartographic(pt,Q),l=Q.latitude,u=Q.longitude,W.latitude=Math.min(W.latitude,l),W.longitude=Math.min(W.longitude,u),j.latitude=Math.max(j.latitude,l),j.longitude=Math.max(j.longitude,u)}for(let o=0;o<s-1;++o)Rt(n[o],n[o+1],e,d,W,j);let m=n[s-1];o.subtract(m,n[s-2],K),o.normalize(K,K),o.multiplyByScalar(K,d,K),o.add(m,K,pt),Rt(m,pt,e,d,W,j),i===ht.ROUNDED&&(e.cartesianToCartographic(pt,Q),l=Q.latitude,u=Q.longitude,W.latitude=Math.min(W.latitude,l),W.longitude=Math.min(W.longitude,u),j.latitude=Math.max(j.latitude,l),j.longitude=Math.max(j.longitude,u));let h=X(a)?a:new Et;return h.north=j.latitude,h.south=W.latitude,h.east=j.longitude,h.west=W.longitude,h}function et(t){t=B(t,B.EMPTY_OBJECT);let e=t.positions,r=t.width;it.defined("options.positions",e),it.defined("options.width",r);let i=B(t.height,0),a=B(t.extrudedHeight,i);this._positions=e,this._ellipsoid=I.clone(B(t.ellipsoid,I.default)),this._vertexFormat=G.clone(B(t.vertexFormat,G.DEFAULT)),this._width=r,this._height=Math.max(i,a),this._extrudedHeight=Math.min(i,a),this._cornerType=B(t.cornerType,ht.ROUNDED),this._granularity=B(t.granularity,st.RADIANS_PER_DEGREE),this._shadowVolume=B(t.shadowVolume,!1),this._workerName="createCorridorGeometry",this._offsetAttribute=t.offsetAttribute,this._rectangle=void 0,this.packedLength=1+e.length*o.packedLength+I.packedLength+G.packedLength+7}et.pack=function(t,e,r){it.defined("value",t),it.defined("array",e),r=B(r,0);let i=t._positions,a=i.length;e[r++]=a;for(let n=0;n<a;++n,r+=o.packedLength)o.pack(i[n],e,r);return I.pack(t._ellipsoid,e,r),r+=I.packedLength,G.pack(t._vertexFormat,e,r),r+=G.packedLength,e[r++]=t._width,e[r++]=t._height,e[r++]=t._extrudedHeight,e[r++]=t._cornerType,e[r++]=t._granularity,e[r++]=t._shadowVolume?1:0,e[r]=B(t._offsetAttribute,-1),e};var It=I.clone(I.UNIT_SPHERE),Wt=new G,tt={positions:void 0,ellipsoid:It,vertexFormat:Wt,width:void 0,height:void 0,extrudedHeight:void 0,cornerType:void 0,granularity:void 0,shadowVolume:void 0,offsetAttribute:void 0};et.unpack=function(t,e,r){it.defined("array",t),e=B(e,0);let i=t[e++],a=new Array(i);for(let p=0;p<i;++p,e+=o.packedLength)a[p]=o.unpack(t,e);let n=I.unpack(t,e,It);e+=I.packedLength;let s=G.unpack(t,e,Wt);e+=G.packedLength;let l=t[e++],u=t[e++],d=t[e++],m=t[e++],h=t[e++],f=1===t[e++],c=t[e];return X(r)?(r._positions=a,r._ellipsoid=I.clone(n,r._ellipsoid),r._vertexFormat=G.clone(s,r._vertexFormat),r._width=l,r._height=u,r._extrudedHeight=d,r._cornerType=m,r._granularity=h,r._shadowVolume=f,r._offsetAttribute=-1===c?void 0:c,r):(tt.positions=a,tt.width=l,tt.height=u,tt.extrudedHeight=d,tt.cornerType=m,tt.granularity=h,tt.shadowVolume=f,tt.offsetAttribute=-1===c?void 0:c,new et(tt))},et.computeRectangle=function(t,e){t=B(t,B.EMPTY_OBJECT);let o=t.positions,r=t.width;it.defined("options.positions",o),it.defined("options.width",r);let i=B(t.ellipsoid,I.default),a=B(t.cornerType,ht.ROUNDED);return Yt(o,i,r,a,e)},et.createGeometry=function(t){let e=t._positions,r=t._width,i=t._ellipsoid;e=Ut(e,i);let a=Pt(e,o.equalsEpsilon);if(a.length<2||r<=0)return;let n,s=t._height,l=t._extrudedHeight,u=!st.equalsEpsilon(s,l,0,st.EPSILON2),d=t._vertexFormat,m={ellipsoid:i,positions:a,width:r,cornerType:t._cornerType,granularity:t._granularity,saveAttributes:!0};if(u)m.height=s,m.extrudedHeight=l,m.shadowVolume=t._shadowVolume,m.offsetAttribute=t._offsetAttribute,n=Jt(m,d);else{let e=M.computePositions(m);if(n=Bt(e,d,i),n.attributes.position.values=yt.scaleToGeodeticHeight(n.attributes.position.values,s,i),X(t._offsetAttribute)){let e=t._offsetAttribute===_t.NONE?0:1,o=n.attributes.position.values.length,r=new Uint8Array(o/3).fill(e);n.attributes.applyOffset=new x({componentDatatype:F.UNSIGNED_BYTE,componentsPerAttribute:1,values:r})}}let h=n.attributes,f=St.fromVertices(h.position.values,void 0,3);return d.position||(n.attributes.position.values=void 0),new Vt({attributes:h,indices:n.indices,primitiveType:Mt.TRIANGLES,boundingSphere:f,offsetAttribute:t._offsetAttribute})},et.createShadowVolume=function(t,e,o){let r=t._granularity,i=t._ellipsoid,a=e(r,i),n=o(r,i);return new et({positions:t._positions,width:t._width,cornerType:t._cornerType,ellipsoid:i,granularity:r,extrudedHeight:a,height:n,vertexFormat:G.POSITION_ONLY,shadowVolume:!0})},Object.defineProperties(et.prototype,{rectangle:{get:function(){return X(this._rectangle)||(this._rectangle=Yt(this._positions,this._ellipsoid,this._width,this._cornerType)),this._rectangle}},textureCoordinateRotationPoints:{get:function(){return[0,0,0,1,1,0]}}});var Lt=et;function Gt(t,e){return X(e)&&(t=Lt.unpack(t,e)),t._ellipsoid=I.clone(t._ellipsoid),Lt.createGeometry(t)}var Ae=Gt;export{Ae as default};