/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{__decorate as t}from"tslib";import{subclass as e}from"../../../../core/accessorSupport/decorators.js";import{createFlowFieldFromDataTiled as s,valuesPerFlowVertex as a}from"./loadUtils.js";import{createFlowFieldFromData as i,traceFlowPaths as r}from"../../../support/flow/dataUtils.js";let o=class{constructor(){this._tileData=new Map}async generateStreamlines(t){const{flowData:e,flowExtentInfo:s,needsMagnitude:a,simulationSettings:r,startPositions:o}=t,n=l(i(r,e),r,s.modelSize,a,o);return{result:{streamlines:n},transferList:n?.map(t=>t.vertices.buffer)}}async generateTiledStreamlines(t){const{flowDataTiles:e,flowExtentInfo:a,needsMagnitude:i,reset:r,simulationSettings:o,startPositions:n}=t;this._updateTileData(e,r);const f=l(s(o,this._tileData,a),o,a.modelSize,i,n);return{result:{streamlines:f},transferList:f?.map(t=>t.vertices.buffer)??[]}}_updateTileData(t,e){if(e)for(const s of this._tileData.keys())t.has(s)||this._tileData.delete(s);t.forEach((t,e)=>{"delete"===t.type?this._tileData.delete(e):"on-worker"!==t.type&&"invalid"!==t.type&&this._tileData.set(e,t.data)})}};o=t([e("esri.views.3d.support.flow.FlowWorker")],o);const n=o;function l(t,e,s,i,o){if(null==t)return;const n=r(e,t,s[0],s[1],{positions:o}),l=[],f=a(i);for(const{vertices:a,stage:r}of n){const t=new Float32Array(a.length*f);for(let e=0;e<a.length;e++)t[e*f]=a[e].x,t[e*f+1]=a[e].y,t[e*f+2]=a[e].time,i&&(t[e*f+3]=a[e].speed);l.push({vertices:t,stage:r,hasMagnitude:i})}return l}export{n as default};
