define(["exports","./Cartographic-67e73ef9","./when-92c6cf3c","./Check-52a7d806","./buildModuleUrl-3d15f25c","./Math-92c3b5f7","./PrimitiveType-cdfe443e"],(function(e,t,r,n,i,a,o){"use strict";var u={};function s(e,t,r){var n=e+t;return a.e.sign(e)!==a.e.sign(t)&&Math.abs(n/Math.max(Math.abs(e),Math.abs(t)))u&&u/o0?[w/e,r/w]:[r/w,w/e]};var f={};function c(e,t,r,n){var i,a,o=e,u=t/3,s=r/3,f=n,c=o*s,w=u*f,h=u*u,l=s*s,p=o*s-h,d=o*f-u*s,m=u*f-l,b=4*p*m-d*d;if(b<0){var g,v,q;h*w>=c*l?(g=o,v=p,q=-2*u*p+o*d):(g=f,v=m,q=-f*d+2*s*m);var M=-(q<0?-1:1)*Math.abs(g)*Math.sqrt(-b),y=(a=-q+M)/2,R=y<0?-Math.pow(-y,1/3):Math.pow(y,1/3),S=a===M?-R:-v/R;return i=v<=0?R+S:-q/(R*R+S*S+v),h*w>=c*l?[(i-u)/o]:[-f/(i+s)]}var O=p,P=-2*u*p+o*d,N=m,L=-f*d+2*s*m,E=Math.sqrt(b),I=Math.sqrt(3)/2,C=Math.abs(Math.atan2(o*E,-P)/3);i=2*Math.sqrt(-O);var x=Math.cos(C);a=i*x;var z=i*(-x/2-I*Math.sin(C)),T=a+z>2*u?a-u:z-u,U=o,W=T/U;C=Math.abs(Math.atan2(f*E,-L)/3);var B=-f,Z=(a=(i=2*Math.sqrt(-N))*(x=Math.cos(C)))+(z=i*(-x/2-I*Math.sin(C)))<2*s?a+s:z+s,V=B/Z,A=-T*Z-U*B,D=(s*A-u*(T*B))/(-u*A+s*(U*Z));return W<=D?W<=V?D<=V?[W,D,V]:[W,V,D]:[V,W,D]:W<=V?[D,W,V]:D<=V?[D,V,W]:[V,D,W]}f.computeDiscriminant=function(e,t,r,i){if("number"!=typeof e)throw new n.t("a is a required number.");if("number"!=typeof t)throw new n.t("b is a required number.");if("number"!=typeof r)throw new n.t("c is a required number.");if("number"!=typeof i)throw new n.t("d is a required number.");var a=t*t,o=r*r;return 18*e*t*r*i+a*o-27*(e*e)*(i*i)-4*(e*o*r+a*t*i)},f.computeRealRoots=function(e,t,r,i){if("number"!=typeof e)throw new n.t("a is a required number.");if("number"!=typeof t)throw new n.t("b is a required number.");if("number"!=typeof r)throw new n.t("c is a required number.");if("number"!=typeof i)throw new n.t("d is a required number.");var a,o;if(0===e)return u.computeRealRoots(t,r,i);if(0===t){if(0===r){if(0===i)return[0,0,0];var s=(o=-i/e)<0?-Math.pow(-o,1/3):Math.pow(o,1/3);return[s,s,s]}return 0===i?0===(a=u.computeRealRoots(e,0,r)).Length?[0]:[a[0],0,a[1]]:c(e,0,r,i)}return 0===r?0===i?(o=-t/e)<0?[o,0,0]:[0,0,o]:c(e,t,0,i):0===i?0===(a=u.computeRealRoots(e,t,r)).length?[0]:a[1]<=0?[a[0],a[1],0]:a[0]>=0?[0,a[0],a[1]]:[a[0],0,a[1]]:c(e,t,r,i)};var w={};function h(e,t,r,n){var i=e*e,o=t-3*i/8,s=r-t*e/2+i*e/8,c=n-r*e/4+t*i/16-3*i*i/256,w=f.computeRealRoots(1,2*o,o*o-4*c,-s*s);if(w.length>0){var h=-e/4,l=w[w.length-1];if(Math.abs(l)=0&&b>=0){var g=Math.sqrt(m),v=Math.sqrt(b);return[h-v,h-g,h+g,h+v]}if(m>=0&&b<0)return[h-(d=Math.sqrt(m)),h+d];if(m<0&&b>=0)return[h-(d=Math.sqrt(b)),h+d]}return[]}if(l>0){var q=Math.sqrt(l),M=(o+l-s/q)/2,y=(o+l+s/q)/2,R=u.computeRealRoots(1,q,M),S=u.computeRealRoots(1,-q,y);return 0!==R.length?(R[0]+=h,R[1]+=h,0!==S.length?(S[0]+=h,S[1]+=h,R[1]<=S[0]?[R[0],R[1],S[0],S[1]]:S[1]<=R[0]?[S[0],S[1],R[0],R[1]]:R[0]>=S[0]&&R[1]<=S[1]?[S[0],R[0],R[1],S[1]]:S[0]>=R[0]&&S[1]<=R[1]?[R[0],S[0],S[1],R[1]]:R[0]>S[0]&&R[0]0){var h,l,p,d,m,b,g=w[0],v=t-g,q=v*v,M=e/2,y=v/2,R=q-4*n,S=q+4*Math.abs(n),O=i-4*g,P=i+4*Math.abs(g);if(g<0||R*P=I[0]&&E[1]<=I[1]?[I[0],E[0],E[1],I[1]]:I[0]>=E[0]&&I[1]<=E[1]?[E[0],I[0],I[1],E[1]]:E[0]>I[0]&&E[0]S)||(c=t.t.cross(f,M,q),(h=t.t.dot(d,c))<0||w+h>S))return;l=t.t.dot(y,c)/S}else{if(Math.abs(S)1||(c=t.t.cross(f,M,q),(h=t.t.dot(d,c)*O)<0||w+h>1))return;l=t.t.dot(y,c)*O}return l},d.rayTriangle=function(e,n,i,a,o,u){var s=d.rayTriangleParametric(e,n,i,a,o);if(r.e(s)&&!(s<0))return r.e(u)||(u=new t.t),t.t.multiplyByScalar(e.direction,s,u),t.t.add(e.origin,u,u)};var M=new p;d.lineSegmentTriangle=function(e,i,a,o,u,s,f){if(!r.e(e))throw new n.t("v0 is required.");if(!r.e(i))throw new n.t("v1 is required.");if(!r.e(a))throw new n.t("p0 is required.");if(!r.e(o))throw new n.t("p1 is required.");if(!r.e(u))throw new n.t("p2 is required.");var c=M;t.t.clone(e,c.origin),t.t.subtract(i,e,c.direction),t.t.normalize(c.direction,c.direction);var w=d.rayTriangleParametric(c,a,o,u,s);if(!(!r.e(w)||w<0||w>t.t.distance(e,i)))return r.e(f)||(f=new t.t),t.t.multiplyByScalar(c.direction,w,f),t.t.add(c.origin,f,f)};var y={root0:0,root1:0};function R(e,n,a){r.e(a)||(a=new i.o);var o=e.origin,u=e.direction,s=n.center,f=n.radius*n.radius,c=t.t.subtract(o,s,g),w=function(e,t,r,n){var i=t*t-4*e*r;if(!(i<0)){if(i>0){var a=1/(2*e),o=Math.sqrt(i),u=(-t+o)*a,s=(-t-o)*a;return uf))return o.start=Math.max(o.start,0),o.stop=Math.min(o.stop,f),o};var O=new t.t,P=new t.t;function N(e,t,r){var n=e+t;return a.e.sign(e)!==a.e.sign(t)&&Math.abs(n/Math.max(Math.abs(e),Math.abs(t)))0?g.push(new t.t(i,s*T,s*-B)):0!==B?(g.push(new t.t(i,s*T,s*-B)),g.push(new t.t(i,s*T,s*B)),++z):g.push(new t.t(i,s*T,s*B))}return g}d.rayEllipsoid=function(e,a){if(!r.e(e))throw new n.t("ray is required.");if(!r.e(a))throw new n.t("ellipsoid is required.");var o,u,s,f,c,w=a.oneOverRadii,h=t.t.multiplyComponents(w,e.origin,O),l=t.t.multiplyComponents(w,e.direction,P),p=t.t.magnitudeSquared(h),d=t.t.dot(h,l);if(p>1){if(d>=0)return;var m=d*d;if(o=p-1,m<(s=(u=t.t.magnitudeSquared(l))*o))return;if(m>s){f=d*d-s;var b=(c=-d+Math.sqrt(f))/u,g=o/c;return b=0)return u}var c=r.e(this.rayEllipsoid(e,i)),w=i.transformPositionToScaledSpace(s,E),h=t.t.normalize(w,w),l=t.t.mostOrthogonalAxis(w,x),p=t.t.normalize(t.t.cross(l,h,I),I),d=t.t.normalize(t.t.cross(h,p,C),C),m=T;m[0]=h.x,m[1]=h.y,m[2]=h.z,m[3]=p.x,m[4]=p.y,m[5]=p.z,m[6]=d.x,m[7]=d.y,m[8]=d.z;var b=o.p.transpose(m,U),g=o.p.fromScale(i.radii,W),v=o.p.fromScale(i.oneOverRadii,B),q=Z;q[0]=0,q[1]=-s.z,q[2]=s.y,q[3]=s.z,q[4]=0,q[5]=-s.x,q[6]=-s.y,q[7]=s.x,q[8]=0;var M,y,R=o.p.multiply(o.p.multiply(b,v,V),q,V),S=o.p.multiply(o.p.multiply(R,g,A),m,A),O=o.p.multiplyByVector(R,u,z),P=L(S,t.t.negate(O,E),0,0,1),N=P.length;if(N>0){for(var F=t.t.clone(t.t.ZERO,j),G=Number.NEGATIVE_INFINITY,Y=0;YG&&(G=_,F=t.t.clone(M,F))}var H=i.cartesianToCartographic(F,k);return G=a.e.clamp(G,0,1),y=t.t.magnitude(t.t.subtract(F,u,x))*Math.sqrt(1-G*G),y=c?-y:y,H.height=y,i.cartographicToCartesian(H,new t.t)}};var F=new t.t;d.lineSegmentPlane=function(e,i,o,u){if(!r.e(e))throw new n.t("endPoint0 is required.");if(!r.e(i))throw new n.t("endPoint1 is required.");if(!r.e(o))throw new n.t("plane is required.");r.e(u)||(u=new t.t);var s=t.t.subtract(i,e,F),f=o.normal,c=t.t.dot(f,s);if(!(Math.abs(c)1))return t.t.multiplyByScalar(s,h,u),t.t.add(e,u,u),u}},d.trianglePlaneIntersection=function(e,i,a,o){if(!(r.e(e)&&r.e(i)&&r.e(a)&&r.e(o)))throw new n.t("p0, p1, p2, and plane are required.");var u,s,f=o.normal,c=o.distance,w=t.t.dot(f,e)+c<0,h=t.t.dot(f,i)+c<0,l=t.t.dot(f,a)+c<0,p=0;if(p+=w?1:0,p+=h?1:0,(1===(p+=l?1:0)||2===p)&&(u=new t.t,s=new t.t),1===p){if(w)return d.lineSegmentPlane(e,i,o,u),d.lineSegmentPlane(e,a,o,s),{positions:[e,i,a,u,s],indices:[0,3,4,1,2,4,1,4,3]};if(h)return d.lineSegmentPlane(i,a,o,u),d.lineSegmentPlane(i,e,o,s),{positions:[e,i,a,u,s],indices:[1,3,4,2,0,4,2,4,3]};if(l)return d.lineSegmentPlane(a,e,o,u),d.lineSegmentPlane(a,i,o,s),{positions:[e,i,a,u,s],indices:[2,3,4,0,1,4,0,4,3]}}else if(2===p){if(!w)return d.lineSegmentPlane(i,e,o,u),d.lineSegmentPlane(a,e,o,s),{positions:[e,i,a,u,s],indices:[1,2,4,1,4,3,0,3,4]};if(!h)return d.lineSegmentPlane(a,i,o,u),d.lineSegmentPlane(e,i,o,s),{positions:[e,i,a,u,s],indices:[2,0,4,2,4,3,1,3,4]};if(!l)return d.lineSegmentPlane(e,a,o,u),d.lineSegmentPlane(i,a,o,s),{positions:[e,i,a,u,s],indices:[0,1,4,0,4,3,2,3,4]}}},e.f=p,e.g=d}));