/*
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","../../../../chunks/tslib.es6","../../../../core/Accessor","../../../../core/Handles","../../../../core/maybe","../../../../core/reactiveUtils","../../../../core/accessorSupport/decorators/property","../../../../core/arrayUtils","../../../../core/has","../../../../core/accessorSupport/ensureType","../../../../core/accessorSupport/decorators/subclass","../../../../chunks/mat4","../../../../chunks/vec3","../../../../chunks/vec4f64","../../../../geometry/support/vectorStacks","./sliceToolConfig","./sliceToolUtils","../../webgl-engine/materials/lineStippleUtils"],(function(e,i,t,s,a,l,n,r,o,u,c,d,p,h,_,y,v,V,m){"use strict";e.SliceVisualization=function(e){function t(i){var t;return(t=e.call(this,i)||this)._handles=new a,t._gridVisualElement=null,t._outlineVisualElement=null,t.state="pending",t.showGrid=!1,t.preview=!0,t}i._inheritsLoose(t,e);var s=t.prototype;return s.initialize=function(){this._initialize()},s._initialize=function(){var e=i._asyncToGenerator((function*(){if("destroyed"===this.state||"ready"===this.state)return;yield n.whenOnce((()=>this.view.ready));const e=this.analysisViewData;if(l.isNone(e))throw new Error("expected internal object to be valid");this._gridVisualElement=V.createGridVisualElement(this.view),this._outlineVisualElement=V.createOutlineVisualElement(this.view),this._handles.add([n.watch((()=>({visible:l.isSome(e.plane)&&this.analysisViewData.visible,active:this.analysisViewData.active,preview:this.preview,showGrid:this.showGrid})),(e=>this._updateMaterials(e)),n.syncAndInitial),n.watch((()=>e.plane),(e=>this._updatePlane(e)),n.syncAndInitial)],"internal"),this._set("state","ready")}));function t(){return e.apply(this,arguments)}return t}(),s.destroy=function(){"destroyed"!==this.state&&"pending"!==this.state&&(this._handles.destroy(),this._gridVisualElement=l.destroyMaybe(this._gridVisualElement),this._outlineVisualElement=l.destroyMaybe(this._outlineVisualElement),this.set("view",null),this._set("state","destroyed"))},s.whenReady=function(){var e=i._asyncToGenerator((function*(){yield n.whenOnce((()=>this.view.ready))}));function t(){return e.apply(this,arguments)}return t}(),s._updatePlane=function(e){if(l.isNone(e))return;const i=h.set(y.sv3d.get(),h.length(e.basis1),h.length(e.basis2),1),t=p.fromScaling(y.sm4d.get(),i),s=V.calculateBoundedPlaneTranslateRotate(e,y.sm4d.get()),a=p.multiply(t,s,t);this._outlineVisualElement.transform=a,this._gridVisualElement.transform=a},s._updateMaterials=function({visible:e,active:i,preview:t,showGrid:s}){this._outlineVisualElement.color=v.PLANE_OUTLINE_COLOR,this._outlineVisualElement.width=t?v.PLANE_PREVIEW_OUTLINE_WIDTH:v.PLANE_OUTLINE_WIDTH,this._outlineVisualElement.stipplePattern=i?null:m.createStipplePatternSimple(5),this._gridVisualElement.backgroundColor=v.PLANE_BACKGROUND_COLOR,this._gridVisualElement.gridColor=s?v.GRID_COLOR:_.ZEROS,this._gridVisualElement.visible=e,this._outlineVisualElement.visible=e},i._createClass(t,[{key:"ready",get:function(){return"ready"===this.state}}]),t}(s),t.__decorate([r.property({readOnly:!0})],e.SliceVisualization.prototype,"state",void 0),t.__decorate([r.property()],e.SliceVisualization.prototype,"view",void 0),t.__decorate([r.property()],e.SliceVisualization.prototype,"analysis",void 0),t.__decorate([r.property()],e.SliceVisualization.prototype,"analysisViewData",void 0),t.__decorate([r.property()],e.SliceVisualization.prototype,"ready",null),t.__decorate([r.property()],e.SliceVisualization.prototype,"showGrid",void 0),t.__decorate([r.property()],e.SliceVisualization.prototype,"preview",void 0),e.SliceVisualization=t.__decorate([d.subclass("esri.views.3d.analysis.Slice.SliceVisualization")],e.SliceVisualization),Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
