/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{equals as i}from"../../core/arrayUtils.js";import{ObjectStack as r}from"../../core/ObjectStack.js";import{set as n,invert as t}from"../../core/libs/gl-matrix-2/math/mat3.js";import{create as o}from"../../core/libs/gl-matrix-2/factories/mat3f64.js";import{d as e,e as c,f as s,n as a,g as u,a as f,h as g,i as m,j as d}from"../../chunks/vec32.js";import{clone as l,create as j}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{sv3d as p}from"./vectorStacks.js";function b(i){return i?h(l(i.origin),l(i.direction)):h(j(),j())}function h(i,r){return{origin:i,direction:r}}function x(r,n){return i(r.origin,n.origin)&&i(r.direction,n.direction)}function k(i,r){const n=O.get();return n.origin=i,n.direction=r,n}function v(i,r=b()){return q(i.origin,i.direction,r)}function S(i,r,n=b()){return e(n.origin,i),c(n.direction,r,i),n}function q(i,r,n=b()){return e(n.origin,i),e(n.direction,r),n}function w(i,r){const n=s(p.get(),a(p.get(),i.direction),c(p.get(),r,i.origin));return u(n,n)}function y(i,r,n){const t=u(i.direction,c(n,r,i.origin));return m(n,i.origin,d(n,i.direction,t)),n}function M(i,r,o,e){const c=i.origin,l=r.origin,j=i.direction,p=r.direction,b=u(a(z,j),a(A,p));if(Math.abs(b)>=1)return null;const h=s(z,j,p),x=f(U,l,c),k=n(B,j[0],j[1],j[2],-p[0],-p[1],-p[2],h[0],h[1],h[2]),v=t(B,k);if(null==v)return[o,e];const S=u(g(z,v[0],v[3],v[6]),x),q=u(g(A,v[1],v[4],v[7]),x);return m(o,c,d(U,j,S)),m(e,l,d(U,p,q)),[o,e]}const O=new r(()=>b()),U=j(),z=j(),A=j(),B=o();export{y as closestPoint,M as closestPoints,v as copy,b as create,w as distance2,x as equals,S as fromPoints,q as fromValues,k as wrap};
