/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{colorVectorToColorAndOpacity as e}from"../../../core/colorUtils.js";import{invert as t}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{subtract as r,cross as o,transformMat4 as i,normalize as n}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{sv3d as c,sm4d as l}from"../../../geometry/support/vectorStacks.js";import{hydrateGeometry as a}from"../../../layers/graphics/hydratedFeatures.js";import{manipulatedObjectGeometry as s}from"./editingTools/manipulatedObjectUtils.js";import{computeCentroid as u}from"../layers/graphics/graphicUtils.js";import{ColorMaterial as m}from"../webgl-engine/materials/ColorMaterial.js";import{ShadedColorMaterial as g}from"../webgl-engine/materials/ShadedColorMaterial.js";function p(t,r=4,o=!0){const i=e(t),n=!(t[3]<1);return o?new g({color:i,writeDepth:n,cullFace:2,renderOccluded:r,isDecoration:!0}):new m({color:i,writeDepth:n,cullFace:2,renderOccluded:r,isDecoration:!0})}function d(t,r=4){const o=e(t);return new m({color:o,writeDepth:!0,cullFace:1,renderOccluded:r,isDecoration:!0})}const f=Object.freeze({calloutLength:40,calloutWidth:1,discRadius:27,focusMultiplier:1.1}),h=Object.freeze({autoScaleRenderObjects:!1,worldSized:!0});function j(e,n,a,s){const u=r(c.get(),e,a),m=w(u,o(c.get(),s,u),a,l.get());t(m,m);const g=i(c.get(),n,m);return Math.atan2(g[1],g[0])}function w(e,t,r,i){const l=n(c.get(),e),a=n(c.get(),t),s=o(c.get(),l,a);return i[0]=l[0],i[1]=l[1],i[2]=l[2],i[3]=0,i[4]=a[0],i[5]=a[1],i[6]=a[2],i[7]=0,i[8]=s[0],i[9]=s[1],i[10]=s[2],i[11]=0,i[12]=r[0],i[13]=r[1],i[14]=r[2],i[15]=1,i}function O(e,t){const r=e.getViewForGraphic(t);return null!=r&&"computeAttachmentOrigin"in r?r.computeAttachmentOrigin(t,e.spatialReference):null}function b(e,t){const r=t.origin;null==r?D(e,s(t)):e.elevationAlignedLocation=r}function D(e,t){if(null==t)return;const r="mesh"===t.type?t.origin:u(t);null!=r&&(e.location=a(r))}export{j as calculateInputRotationTransform,w as calculateTranslateRotateFromBases,p as createManipulatorMaterial,d as createManipulatorOutlineMaterial,O as getGraphicAttachmentOrigin,b as placeAtObject,f as rotateManipulatorDefaults,h as worldScaledManipulatorSettings};
