/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{valueInUnit as e}from"../../../../../core/quantity.js";import{createScreenPointArray as r,createRenderScreenPointArray3 as o}from"../../../../../core/screenUtils.js";import{getMetersPerUnitForSR as t}from"../../../../../core/units.js";import{fromValues as n}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{f as s,C as i,D as c,e as l,c as a}from"../../../../../chunks/vec32.js";import{create as m}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{geodesicCompatibleSpatialReference as p,inverseGeodeticSolver as f,InverseGeodeticSolverResult as u,directGeodeticSolver as d}from"../../../../../geometry/geodesicUtils.js";import{projectPoint as j}from"../../../../../geometry/projectionUtils.js";import{projectVectorToVector as g}from"../../../../../geometry/projection/projectVectorToVector.js";import{getNormal as y,fromPositionAndNormal as h,create as R}from"../../../../../geometry/support/plane.js";import{makeDehydratedPoint as v}from"../../../../../layers/graphics/dehydratedPoint.js";import{getZForElevationMode as x}from"../../../../../support/elevationInfoUtils.js";import{OffsetEdgeVertex as C}from"../../../../interactive/editGeometry/operations/OffsetEdgeVertex.js";function H(e,r,o){const t="on-the-ground"===o.mode?1:0;return new C(e,t,r,0)}function w(e,r,o){const t=m();if(!e.renderCoordsHelper.toRenderCoords(r,t))return null;const n=T(e,r,y(o.plane)),i=T(e,r,o.edgeDirection);if(null==n||null==i)return null;const c=s(m(),n,i);return h(t,c,R())}function T(e,r,o){const t=v(r.x+o[0],r.y+o[1],r.z+o[2],r.spatialReference),n=m(),s=m();return e.renderCoordsHelper.toRenderCoords(r,n)&&e.renderCoordsHelper.toRenderCoords(t,s)?i(s,n,s):null}function U(e,r,o){const t=y(e),c=i(m(),r,o),l=s(m(),c,t),a=s(m(),c,l);return n(c[0],c[1],c[2],0,l[0],l[1],l[2],0,a[0],a[1],a[2],0,0,0,0,1)}function q(e,r,t){const n=t.projectToRenderScreen(e,o()),s=t.projectToRenderScreen(r,o());return null!=n&&null!=s?c(l(n,n,s)):0}function A(e,o,t,n){const{elevationInfo:s,operations:i}=t;if(!i||!e)return null;const c=n.manipulator.elevationAlignedLocation,l=x(c,o,s),a=o.sceneIntersectionHelper.intersectElevationFromScreen(r(e.x,e.y),s,l);return a&&j(a,a,i.data.spatialReference)?a:null}function I(r,o,n,{data:{coordinateHelper:s,spatialReference:i}}){const c=e(r,"meters"),l=t(i),j=Math.sign(c*n.selectedArrow),h=p(i),R=y(n.plane),v=s.pointToXYZ(o),x=m();a(x,v,R,j*(M/l));const C=c*n.selectedArrow/l;if(!h||!g(v,i,v,h)||!g(x,i,x,h))return C;const H=new u;if(f(H,v,x,h),d(x,v,H.azimuth,c,h),!g(x,h,x,i))return C;const w=x[0]-o.x,T=x[1]-o.y,U=Math.sqrt(w*w+T*T)*j,[q,A]=R,I=Math.sqrt(q*q+A*A);return 0===I?0:U/I}const M=10;export{w as createEdgeOffsetIntersectionPlane,H as createEdgeOffsetOperation,U as edgeOffsetRotationMatrix,I as getDistanceInGeometrySR,A as getMapPointAtEdgeOffsetManipulatorElevation,q as screenEdgeLengthSquared};
