/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{simulationSettingsEqual as t}from"../../../support/flow/utils.js";function n(t){const n=t.toRgba();return[n[0]/255,n[1]/255,n[2]/255,n[3]]}function o(t){return{kind:"constant",value:[.1,.1,.1,1]}}function s(t){if(!t.hasVisualVariables("color"))return{kind:"constant",value:n(t.color)};const o=t.getVisualVariablesForType("color")[0],s=[],e=[];for(const a of o.stops)s.push(a.value),Array.prototype.push.apply(e,n(a.color));return{kind:"ramp",stops:s,values:e,count:o.stops.length}}function e(t){if(!t.hasVisualVariables("opacity"))return{kind:"constant",value:[1]};const n=t.getVisualVariablesForType("opacity")[0],o=[],s=[];for(const e of n.stops)o.push(e.value),s.push(e.opacity);return{kind:"ramp",stops:o,values:s,count:n.stops.length}}const a=8;function r(t){if("constant"===t.kind)return{constant:t.value,count:1,stops:new Array(a).fill(0),values:new Array(a).fill(t.value)};const n=Math.min(t.count,a),o=new Array(a).fill(t.stops[n-1]),s=new Array(a).fill(null).map((o,s)=>{const e=4*Math.min(s,n-1);return t.values.slice(e,e+4)});for(let e=0;e<n;e++)o[e]=t.stops[e];return{constant:[0,0,0,0],count:n,stops:o,values:s}}function i(t){if("constant"===t.kind)return{constant:t.value[0],count:1,stops:new Array(a).fill(0),values:new Array(a).fill(t.value[0])};const n=Math.min(t.count,a),o=new Array(a).fill(t.stops[n-1]),s=new Array(a).fill(t.values[n-1]);for(let e=0;e<n;e++)o[e]=t.stops[e],s[e]=t.values[e];return{constant:0,count:n,stops:o,values:s}}function u(t,n,o,s){switch(n){case"int":t.setUniform1iv(o,s);break;case"float":t.setUniform1fv(o,s);break;case"vec2":t.setUniform2fv(o,s);break;case"vec3":t.setUniform3fv(o,s);break;case"vec4":t.setUniform4fv(o,s)}}function l(t,n,o,s){"constant"===s.kind?u(t,o,`u_${n}`,s.value):(u(t,"float",`u_${n}_stops`,s.stops),u(t,o,`u_${n}_values`,s.values),t.setUniform1i(`u_${n}_count`,s.count))}function c(t,n){return t===n||null!=t&&null!=n&&t.equals(n)}function f(n,o){if(!t(n.simulationSettings,o.simulationSettings))return!1;if(!c(n.timeExtent,o.timeExtent))return!1;let s=!0;return s=s&&n.loadImagery===o.loadImagery,s=s&&n.createFlowMesh===o.createFlowMesh,s=s&&n.color.kind===o.color.kind,s=s&&n.opacity.kind===o.opacity.kind,s=s&&n.size.kind===o.size.kind,s}const p=36e5,v=3600;export{f as areStreamlinesCompatible,s as getColor,r as getFlowColorUniforms,i as getFlowFloatUniforms,o as getForegroundColor,e as getOpacity,p as longSafetyTime,u as setUniform,l as setUniforms,v as shortMarginTime,c as timeExtentsEqual,n as toRgba};
