/*
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","../../../../../Color","../../../../../core/maybe","../../../../../chunks/mat4","../../../../../chunks/mat4f64","../../../../../chunks/vec3","../../../../../chunks/vec3f64","../../../../../geometry/support/vectorStacks","../../../../../support/elevationInfoUtils","../../Manipulator3D","../dragEventPipeline3D","../ManipulatorType","../settings","./config","./Manipulation","./moveUtils","../snapping/SnapToScene","../../../webgl-engine/lib/basicInterfaces","../../../webgl-engine/lib/GeometryUtil","../../../webgl-engine/lib/Material","../../../webgl-engine/materials/ColorMaterial","../../../../interactive/dragEventPipeline","../../../../interactive/interfaces"],(function(e,t,a,i,n,r,o,s,l,c,u,p,d,_,h,f,M,g,m,S,v,T,y,w){"use strict";let D=function(e){function f(t){var a;return(a=e.call(this)||this)._snapToScene=new g.SnapToScene,a._discMaterial=a._createMaterial(),a._discMaterialTransparent=a._createMaterial(.5),a._scale=1,a._radius=h.DISC_RADIUS,a._view=t.view,a._tool=t.tool,null!=t.snapToScene&&(a.snapToScene=t.snapToScene),null!=t.radius&&(a._radius=t.radius),a._createManipulator(),a.forEachManipulator((e=>a._tool.manipulators.add(e))),a}t._inheritsLoose(f,e);var D=f.prototype;return D.destroy=function(){this.forEachManipulator((e=>{this._tool.manipulators.remove(e),e.destroy()})),this._tool=null,this._view=null,this._manipulator=null},D.forEachManipulator=function(e){e(this._manipulator,d.ManipulatorType.TRANSLATE_XY)},D.createGraphicDragPipeline=function(e,t,a){const n=t.graphic,r=c.getGraphicEffectiveElevationInfo(n),o=i.unwrap(n.geometry).spatialReference;return M.createGraphicMoveDragPipeline(t,a,(t=>this.createDragPipeline(((a,i,n,r,o)=>t(a,e(a,i,n,r,o),n)),r,o,n)),this._view.state.viewingMode)},D.createDragPipeline=function(e,t,a,i){const n=this._view;return y.createManipulatorDragEventPipeline(this._manipulator,((r,o,s,l,c)=>{const u=o.next(y.dragAtLocation(n,r.elevationAlignedLocation)).next(p.screenToMapXYAtLocation(n,r.elevationAlignedLocation,t,a,i)).next(this._snapToScene.createDragEventPipelineStep(n,t),this._snapToScene.next).next((e=>({...e,manipulatorType:d.ManipulatorType.TRANSLATE_XY}))).next(y.addScreenDelta());e(r,u,s,l,c)}))},D._updateManipulatorTransform=function(){const e=n.fromScaling(l.sm4d.get(),o.set(l.sv3d.get(),this.displayScale,this.displayScale,this.displayScale));this._manipulator.modelTransform=e},D._createManipulator=function(){const e=this._view;this._manipulator=new u.Manipulator3D({view:e,worldSized:!1,autoScaleRenderObjects:!1,focusMultiplier:1,touchMultiplier:1,collisionType:{type:"disc",direction:s.fromValues(0,0,1)},worldOriented:!0}),this._updateManipulator()},D._updateManipulator=function(){const e=S.createCylinderGeometry(h.DISC_HEIGHT,1,h.GEOMETRY_SEGMENTS,s.fromValues(0,0,1),s.fromValues(0,0,0)),t=n.fromScaling(r.create(),s.fromValues(this._radius,this._radius,this._radius));this._manipulator.renderObjects=[{geometry:e,material:this._discMaterial,transform:t,stateMask:w.ManipulatorStateFlags.Focused},{geometry:e,material:this._discMaterialTransparent,transform:t,stateMask:w.ManipulatorStateFlags.Unfocused}],this._manipulator.radius=h.DISC_COLLISION_RADIUS*(this._radius/h.DISC_RADIUS)},D._createMaterial=function(e=1){const t=a.toUnitRGBA(_.colors.main);return t[3]*=e,new T.ColorMaterial({color:t,transparent:1!==e,cullFace:m.CullFaceOptions.Back,renderOccluded:v.RenderOccludedFlag.Transparent})},t._createClass(f,[{key:"displayScale",get:function(){return this._scale},set:function(e){this._scale=e,this._updateManipulatorTransform()}},{key:"snapToScene",get:function(){return this._snapToScene.enabled},set:function(e){this._snapToScene.enabled=e}},{key:"radius",get:function(){return this._radius},set:function(e){e!==this._radius&&(this._radius=e,this._updateManipulator())}},{key:"test",get:function(){return{discManipulator:this._manipulator}}}]),f}(f.Manipulation);e.MoveXYDiscManipulation=D,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
