/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{create as t}from"../../../../core/libs/gl-matrix-2/factories/mat3f32.js";import{isForeverZero as e,getEndValue as a,getValue as s}from"./animatedValues.js";import{longSafetyTime as i}from"./utils.js";import r from"../webgl/brushes/WGLBrush.js";class l extends r{constructor(){super(...arguments),this._visualState={time:0,dvsMat3:t(),displayViewMat3:t(),displayOpacity:1,startTime:0,endTime:0}}dispose(){}prepareState(t){const{context:e}=t;e.setColorMask(!0,!0,!0,!0),e.setStencilFunction(514,0,255)}draw(t,r){const{requestRender:l,allowDelayedRender:n}=t,{items:o}=r,d=[];for(const m of o){m.attached||(m.resources.attach({context:t.context,getProgram:(e,a)=>t.painter.materialManager.getProgram(e,a)}),m.attached=!0);const o=t.time/1e3;if(t.animationsEnabled?e(m.displayOpacity,o)||o>m.endTime+m.style.slideoutDuration:0===a(m.displayOpacity))m.attached&&(m.resources.detach(),m.attached=!1);else{if(d.push(m),n&&!m.resources.ready&&null!=l)return void l();this._visualState.time=t.animationsEnabled?o:i,r.updateMatrix(t.state,m.resources.query),this._visualState.dvsMat3=r.transforms.displayViewScreenMat3,this._visualState.displayViewMat3=t.state.displayViewMat3,this._visualState.displayOpacity=t.animationsEnabled?s(m.displayOpacity,o):a(m.displayOpacity),this._visualState.startTime=m.startTime,this._visualState.endTime=m.endTime,m.style.render({context:t.context,getProgram:(e,a)=>t.painter.materialManager.getProgram(e,a)},this._visualState,m.resources),m.style.animated&&null!=l&&t.animationsEnabled&&l()}}r.items.splice(0,r.items.length,...d)}}export{l as default};
