/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{acosClamped as t,reciprocalClamped as i}from"../../../../core/mathUtils.js";import{set as r}from"../../../../core/libs/gl-matrix-2/math/mat2.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat2f64.js";import{transformMat2 as e,set as a}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as h,UNIT_X as n}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{g as o,f as g,j as m,n as f,i as c,q as u,e as l,d as p}from"../../../../chunks/vec32.js";import{create as v}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{Frame2D as M}from"./PathExtruder.js";class b{constructor(){this.vLeft=v(),this.vRight=v(),this.vMinSiblingLength=0,this.frame=new M}setFrameFromUpVector(t){p(this.frame.up,t),c(y,this.vLeft,this.vRight),f(y,y),m(I,this.frame.up,o(y,this.frame.up)),l(D,y,I),f(D,D),g(this.frame.right,D,this.frame.up)}get foldingAngle(){return Math.PI-this.rotationAngle}}class R extends b{get rotationFrameUp(){return this.frame.up}get rotationRight(){return n}get rotationAngle(){m(w,this.frame.up,o(this.frame.up,this.vLeft)),l(w,this.vLeft,w),u(w,w),f(w,w),m(P,this.frame.up,o(this.frame.up,this.vRight)),l(P,this.vRight,P),f(P,P),g(U,this.rotationFrameUp,this.vLeft);return Math.sign(o(U,this.vRight))*(Math.PI-t(o(w,P)))}get maxStretchDistance(){return Math.abs(this.vMinSiblingLength/Math.cos(.5*this.foldingAngle))}applyMiterStretch(t,r){const s=this.rotationAngle;if(Math.abs(s)<=0)return r;const e=i(Math.cos(.5*s));return a(t,(e-1+1)*r[0],r[1])}}class x extends b{get rotationFrameUp(){const t=Math.sign(o(this.frame.right,this.vRight));return g(A,this.vRight,this.vLeft),m(A,A,t),f(A,A)}get rotationRight(){const t=this.rotationFrameUp,i=o(t,this.frame.up),r=o(t,this.frame.right);return m(S,this.frame.up,-r),m(F,this.frame.right,i),c(S,S,F),f(S,S),L(d,this.frame,S),d}get rotationAngle(){const i=Math.sign(o(this.frame.right,this.vRight));return u(U,this.vLeft),-i*(Math.PI-t(o(U,this.vRight)))}get maxStretchDistance(){return Math.abs(this.vMinSiblingLength*i(Math.cos(.5*this.foldingAngle)))}applyMiterStretch(t,s){const a=this.rotationAngle;if(0===Math.abs(a))return s;const h=i(Math.cos(.5*a)),n=this.rotationRight,o=r(k,1+(h-1)*n[0]*n[0],(h-1)*n[0]*n[1],(h-1)*n[0]*n[1],1+(h-1)*n[1]*n[1]);return e(t,s,o)}}function L(t,i,r){a(t,o(r,i.right),o(r,i.up))}function j(t){switch(t){case 0:return new R;case 1:return new x}}const A=v(),d=h(),S=v(),F=v(),U=v(),w=v(),P=v(),I=v(),y=v(),D=v(),k=s();export{b as PathVertex,j as newPathVertex};
