/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../../../chunks/_rollupPluginBabelHelpers","../../../../../core/colorUtils","../../../../../core/Evented","../../../../../core/mathUtils","../../../../../core/maybe","../../../../../chunks/mat4","../../../../../chunks/mat4f64","../../../../../chunks/vec3","../../../../../chunks/vec3f64","../../Manipulator3D","../../manipulatorUtils","../dragEventPipeline3D","../ManipulatorType","../settings","./config","./Manipulation","./moveUtils","../../../webgl-engine/lib/GeometryUtil","../../../webgl-engine/lib/Material","../../../../interactive/dragEventPipeline","../../../../interactive/interfaces"],(function(e,t,a,r,i,n,o,s,l,u,c,p,d,M,m,g,h,_,f,v,y,S){"use strict";let w=function(e){function h(t){var a;return(a=e.call(this)||this)._radius=g.DISC_RADIUS,a.events=new r,a._tool=t.tool,a._view=t.view,null!=t.radius&&(a._radius=t.radius),a._createManipulator(),a.forEachManipulator((e=>a._tool.manipulators.add(e))),a}t._inheritsLoose(h,e);var w=h.prototype;return w.destroy=function(){this.forEachManipulator((e=>{this._tool.manipulators.remove(e),e.destroy()}))},w.forEachManipulator=function(e){e(this._manipulator,M.ManipulatorType.TRANSLATE_Z)},w.createGraphicDragPipeline=function(e,t,a){const r=n.unwrap(t.graphic.geometry).spatialReference;return _.createGraphicMoveDragPipeline(t,a,(t=>this.createDragPipeline(((a,r,i,n,o)=>t(a,e(a,r,i,n,o),i)),r)),this._view.state.viewingMode)},w.createDragPipeline=function(e,t){const a=this._view;return y.createManipulatorDragEventPipeline(this._manipulator,((r,i,n,o,s)=>{const l=i.next((e=>({...e,manipulatorType:M.ManipulatorType.TRANSLATE_Z}))).next(d.screenToZConstrained(a,r.renderLocation,t)).next(y.addScreenDelta());e(r,l,n,o,s)}))},w._updateManipulator=function(){const e=this._radius/g.DISC_RADIUS,t=m.settings.zManipulator.height*e,r=m.settings.zManipulator.coneHeight*e,i=m.settings.zManipulator.coneWidth*e,n=m.settings.zManipulator.width*e,l=[u.fromValues(0,0,0),u.fromValues(0,0,t)],c=f.createTubeGeometry(l,n/2,16,!1),d=f.createConeGeometry(r,i/2,16,!1),M=[u.fromValues(0,0,0),u.fromValues(0,0,t+r)],h=e=>{const a=s.create();if(o.translate(a,a,[0,0,t]),o.rotateX(a,a,Math.PI/2),e){const t=1+2*e/i;o.scale(a,a,[t,t,t])}return a},_=h(0),y=(e,t)=>{const r=a.darken(m.settings.zManipulator.color,t);return[r.r/255,r.g/255,r.b/255,m.settings.zManipulator.color.a*e]},w=p.createManipulatorMaterial(y(1,.25),v.RenderOccludedFlag.Occlude),b=p.createManipulatorMaterial(y(1,0),v.RenderOccludedFlag.Occlude),k=p.createManipulatorMaterial(y(.7,0),m.settings.zManipulator.renderOccluded),D=p.createManipulatorMaterial(y(.85,0),m.settings.zManipulator.renderOccluded);this._manipulator.renderObjects=[{geometry:d,transform:_,material:w,stateMask:S.ManipulatorStateFlags.Unfocused},{geometry:c,material:w,stateMask:S.ManipulatorStateFlags.Unfocused},{geometry:d,transform:_,material:b,stateMask:S.ManipulatorStateFlags.Focused},{geometry:c,material:b,stateMask:S.ManipulatorStateFlags.Focused},{geometry:d,transform:_,material:k,stateMask:S.ManipulatorStateFlags.Unfocused},{geometry:c,material:k,stateMask:S.ManipulatorStateFlags.Unfocused},{geometry:d,transform:_,material:D,stateMask:S.ManipulatorStateFlags.Focused},{geometry:c,material:D,stateMask:S.ManipulatorStateFlags.Focused}],this._manipulator.radius=n/2+2,this._manipulator.collisionType={type:"line",paths:[M]}},w._createManipulator=function(){const e=new c.Manipulator3D({view:this._view,autoScaleRenderObjects:!1,worldSized:!1,selectable:!1,cursor:"ns-resize",elevationInfo:this.elevationInfo,worldOriented:!0,collisionPriority:1.6});e.applyObjectTransform=e=>{const t=this._view.state.camera,a=b;this._view.renderCoordsHelper.toRenderCoords(this._manipulator.elevationAlignedLocation,a);const r=l.dist(t.eye,a),n=t.computeRenderPixelSizeAtDist(r),o=l.subtract(k,a,t.eye);l.normalize(o,o);const s=D;this._view.renderCoordsHelper.worldUpAtPosition(b,s);const u=Math.abs(l.dot(o,s)),c=l.cross(k,o,s),p=l.cross(k,c,s),d=i.clamp(u,.01,1),M=1-Math.sqrt(1-d*d)/d/t.fullWidth,h=this._radius/g.DISC_RADIUS,_=m.settings.zManipulator.width*h;l.scale(p,l.normalize(p,p),(1/M-1)*r+n*_),e[12]-=k[0],e[13]-=k[1],e[14]-=k[2]},this._manipulator=e,this._updateManipulator()},t._createClass(h,[{key:"radius",get:function(){return this._radius},set:function(e){e!==this._radius&&(this._radius=e,this._updateManipulator())}},{key:"test",get:function(){return{manipulator:this._manipulator}}}]),h}(h.Manipulation);const b=u.create(),k=u.create(),D=u.create();e.MoveZManipulation=w,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
