{"version":3,"file":"glowWebGLRenderer.mjs","names":[],"sources":["../../../../../../src/plugins/AIComponents/VoiceVisualization/renderers/glowWebGLRenderer.ts"],"sourcesContent":["import type { VoiceFrame, VoiceRenderer } from './types';\n\nconst VERTEX = `\nattribute vec2 position;\nvoid main() {\n  gl_Position = vec4(position, 0.0, 1.0);\n}\n`;\n\n/**\n * The glow's fragment shader, GLSL ES 1.00. A line-for-line port of the AGSL glow in\n * stream-chat-android (itself ported from the iOS Metal glow), so the platforms look alike.\n * Pixels past the halo return at once, so only the glow itself costs.\n */\nconst FRAGMENT = `\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nuniform vec2 resolution;\nuniform vec4 col0;\nuniform vec4 col1;\nuniform vec4 col2;\nuniform vec4 col3;\nuniform vec4 col4;\nuniform float time;\nuniform float count;\nuniform float bright;\nuniform float sat;\nuniform float load;\nuniform float flow;\nuniform float flowSpin;\nuniform float orbSpin;\nuniform float react;\nuniform float dark;\nuniform float mic;\nuniform float voice;\nuniform float scale;\nuniform vec2 tap;\nuniform float tapTime;\nuniform vec2 hover;\nuniform float hoverAmt;\n\nfloat sq(float x) { return x * x; }\nfloat ss(float e0, float e1, float x) {\n  float t = clamp((x - e0) / (e1 - e0), 0.0, 1.0);\n  return t * t * (3.0 - 2.0 * t);\n}\nvec3 hsv2rgb(vec3 c) {\n  vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n  vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n  return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n}\nvec3 desat(vec3 c, float s) {\n  float l = dot(c, vec3(0.299, 0.587, 0.114));\n  return mix(vec3(l), c, s);\n}\nvec3 saturate3(vec3 c, float s) {\n  float l = dot(c, vec3(0.299, 0.587, 0.114));\n  return clamp(mix(vec3(l), c, s), 0.0, 1.0);\n}\nvec2 rot2(vec2 p, float a) {\n  float s = sin(a); float c = cos(a);\n  return vec2(c * p.x + s * p.y, -s * p.x + c * p.y);\n}\nvec3 vivid(vec4 hsv) {\n  return hsv2rgb(vec3(hsv.x, clamp(hsv.y + dark * 0.06, 0.0, 1.0), hsv.z));\n}\n// Waves spreading out from the last tap, fading within a second and a half.\nfloat tapRipple(vec2 p) {\n  float age = tapTime;\n  if (age > 1.5) return 0.0;\n  float d = distance(p, tap);\n  float front = age * 0.75;\n  float env = exp(-sq((d - front) / 0.14));\n  float decay = exp(-age * 2.6);\n  return sin(d * 34.0 - age * 24.0) * env * decay;\n}\n// A gentle ripple following a hovering pointer.\nfloat hoverRipple(vec2 p) {\n  if (hoverAmt <= 0.001) return 0.0;\n  float d = distance(p, hover);\n  float env = exp(-sq(d / 0.22));\n  return sin(d * 30.0 - time * 7.0) * env * hoverAmt * 0.6;\n}\nvec4 permute(vec4 x) { return mod(((x * 34.0) + 1.0) * x, 289.0); }\nvec4 taylorInvSqrt(vec4 r) { return 1.79284291400159 - 0.85373472095314 * r; }\nfloat snoise(vec3 v) {\n  const vec2 C = vec2(1.0 / 6.0, 1.0 / 3.0);\n  const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);\n  vec3 i = floor(v + dot(v, C.yyy));\n  vec3 x0 = v - i + dot(i, C.xxx);\n  vec3 g = step(x0.yzx, x0.xyz);\n  vec3 l = 1.0 - g;\n  vec3 i1 = min(g.xyz, l.zxy);\n  vec3 i2 = max(g.xyz, l.zxy);\n  vec3 x1 = x0 - i1 + 1.0 * C.xxx;\n  vec3 x2 = x0 - i2 + 2.0 * C.xxx;\n  vec3 x3 = x0 - 1.0 + 3.0 * C.xxx;\n  i = mod(i, 289.0);\n  vec4 p = permute(permute(permute(\n              i.z + vec4(0.0, i1.z, i2.z, 1.0))\n            + i.y + vec4(0.0, i1.y, i2.y, 1.0))\n            + i.x + vec4(0.0, i1.x, i2.x, 1.0));\n  float n_ = 1.0 / 7.0;\n  vec3 ns = n_ * D.wyz - D.xzx;\n  vec4 j = p - 49.0 * floor(p * ns.z * ns.z);\n  vec4 x_ = floor(j * ns.z);\n  vec4 y_ = floor(j - 7.0 * x_);\n  vec4 x = x_ * ns.x + ns.yyyy;\n  vec4 y = y_ * ns.x + ns.yyyy;\n  vec4 h = 1.0 - abs(x) - abs(y);\n  vec4 b0 = vec4(x.xy, y.xy);\n  vec4 b1 = vec4(x.zw, y.zw);\n  vec4 s0 = floor(b0) * 2.0 + 1.0;\n  vec4 s1 = floor(b1) * 2.0 + 1.0;\n  vec4 sh = -step(h, vec4(0.0));\n  vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy;\n  vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww;\n  vec3 p0 = vec3(a0.xy, h.x);\n  vec3 p1 = vec3(a0.zw, h.y);\n  vec3 p2 = vec3(a1.xy, h.z);\n  vec3 p3 = vec3(a1.zw, h.w);\n  vec4 norm = taylorInvSqrt(vec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3)));\n  p0 *= norm.x; p1 *= norm.y; p2 *= norm.z; p3 *= norm.w;\n  vec4 m = max(0.6 - vec4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0);\n  m = m * m;\n  return 42.0 * dot(m * m, vec4(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3)));\n}\nfloat speechEnv(float t) {\n  float gate = ss(-0.25, 0.35, snoise(vec3(t * 0.6, 21.0, 0.0)));\n  float syl = 0.55 + 0.45 * snoise(vec3(t * 3.0, 5.0, 0.0));\n  return clamp(gate * syl, 0.0, 1.0);\n}\n\nvoid main() {\n  // Centred, normalized to the shorter side, y up: gl_FragCoord already has y up.\n  float side = min(resolution.x, resolution.y);\n  vec2 q = (gl_FragCoord.xy - 0.5 * resolution) / side / scale;\n  float t = time;\n  float r = length(q);\n\n  float speak = ss(0.6, 1.0, react);\n  float speech = react * mix(0.55 + 0.25 * sin(t * 1.6), speechEnv(t), speak);\n  speech = mix(speech, mic, voice);\n  float speechSmooth = mix(speech, react * (0.55 + 0.25 * sin(t * 1.6)), 0.5 * speak);\n  float energy = 0.12 + 0.30 * react + 0.18 * flow + 0.28 * load + 0.06 * speechSmooth;\n  float R = 0.24 * (1.0 + speechSmooth * 0.20 + load * 0.05 * sin(t * 2.0) + react * 0.04 * sin(t * 1.6));\n  float p = r / R;\n  if (p > 2.2) {\n    gl_FragColor = vec4(0.0);\n    return;\n  }\n\n  float core = exp(-2.0 * p * p);\n  float body = ss(1.06, 0.62, p);\n\n  vec2 P = q / R;\n  float pl = length(P);\n  float nt = t * 0.15 + flowSpin * 0.05;\n  float nAmp = 0.20 + 0.28 * energy;\n  vec2 sp = P + nAmp * vec2(snoise(vec3(P * 0.7, nt)), snoise(vec3(P * 0.7 + 4.7, nt)));\n  float ang = atan(P.y, P.x);\n  float wave = (0.018 + 0.025 * energy) * sin(pl * 5.0 - t * 2.0) * ss(0.0, 0.4, pl);\n  sp += wave * vec2(-sin(ang), cos(ang));\n  sp = rot2(sp, flowSpin * 0.30);\n  vec2 gtoP = q - (hoverAmt > 0.001 ? hover : tap);\n  sp += (gtoP / (length(gtoP) + 1e-4)) * (tapRipple(q) + hoverRipple(q)) * 0.5;\n  float bt = t;\n  float a0 = orbSpin * 0.42 + 2.0 * snoise(vec3(bt * 0.12, 0.0, 0.0));\n  float a1 = -orbSpin * 0.34 + 2.0 * snoise(vec3(bt * 0.10, 5.0, 0.0)) + 2.0;\n  float a2 = orbSpin * 0.30 + 2.0 * snoise(vec3(bt * 0.11, 9.0, 0.0)) + 1.0;\n  float a3 = -orbSpin * 0.26 + 2.0 * snoise(vec3(bt * 0.09, 14.0, 0.0)) + 3.5;\n  vec2 c0 = 0.40 * vec2(cos(a0), sin(a0));\n  vec2 c1 = 0.38 * vec2(cos(a1), sin(a1));\n  vec2 c2c = 0.36 * vec2(cos(a2), sin(a2));\n  vec2 c3c = 0.34 * vec2(cos(a3), sin(a3));\n  float b0 = ss(1.15, 0.1, length(sp - c0));\n  float b1 = ss(1.30, 0.1, length(sp - c1));\n  float b2 = ss(1.20, 0.1, length(sp - c2c));\n  float b3 = ss(1.25, 0.1, length(sp - c3c));\n\n  vec3 k0 = saturate3(vivid(col0), 1.7);\n  vec3 kL = saturate3(clamp(vivid(col0) * 1.18, 0.0, 1.0), 1.3);\n  vec3 kD = saturate3(vivid(col0) * 0.85, 1.3);\n  vec3 colB = mix(kL, saturate3(vivid(col1), 1.7), clamp(count - 1.0, 0.0, 1.0));\n  vec3 colC = mix(kD, saturate3(vivid(col2), 1.7), clamp(count - 2.0, 0.0, 1.0));\n  vec3 colD = saturate3(vivid(col3), 1.7);\n  vec3 colE = saturate3(vivid(col4), 1.7);\n  vec3 base = saturate3(mix(vivid(col0), vec3(1.0), 0.06), 1.3);\n  vec3 col = base;\n  col = mix(col, k0, b0);\n  col = mix(col, colB, b1);\n  col = mix(col, colC, b0 * 0.5);\n  col = mix(col, colD, b2 * clamp(count - 3.0, 0.0, 1.0));\n  col = mix(col, colE, b3 * clamp(count - 4.0, 0.0, 1.0));\n  col = saturate3(col, 1.15);\n  col = clamp(col * 1.12, 0.0, 1.0);\n  col = desat(col, sat);\n\n  float z = sqrt(max(1.0 - p * p, 0.0));\n  vec3 nrm = normalize(vec3(q / R, z + 1e-4));\n  vec3 Ld = normalize(vec3(-0.35, 0.45, 0.85));\n  float diff = clamp(dot(nrm, Ld), 0.0, 1.0);\n  col *= 0.80 + 0.20 * diff;\n  float fres = pow(1.0 - clamp(nrm.z, 0.0, 1.0), 2.5);\n  col += fres * 0.10 * mix(vec3(1.0), k0, 0.6);\n\n  vec3 haloCol = mix(mix(vivid(col0), vec3(1.0), 0.75), mix(vivid(col0), vec3(1.0), 0.32), dark);\n  float halo = exp(-sq(max(r - R * 0.8, 0.0) / 0.09));\n  float haloA = halo * (mix(0.05, 0.10, dark) + 0.05 * react);\n  float waves = clamp(b0 + 0.8 * b1, 0.0, 1.0);\n  float bodyA = clamp(body * (0.15 + 0.60 * waves + 0.06 * core) * (0.92 + 0.08 * fres), 0.0, 1.0);\n  float fade = mix(1.0, 0.45 + 0.35 * sin(t * 2.0), load);\n  vec3 pm = col * bodyA + haloCol * haloA * (1.0 - bodyA);\n  float al = bodyA + haloA * (1.0 - bodyA);\n  float gain = bright * fade;\n  // Premultiplied, as the context is.\n  gl_FragColor = vec4(pm * gain, al * gain);\n}\n`;\n\nconst UNIFORMS = [\n  'resolution',\n  'col0',\n  'col1',\n  'col2',\n  'col3',\n  'col4',\n  'time',\n  'count',\n  'bright',\n  'sat',\n  'load',\n  'flow',\n  'flowSpin',\n  'orbSpin',\n  'react',\n  'dark',\n  'mic',\n  'voice',\n  'scale',\n  'tap',\n  'tapTime',\n  'hover',\n  'hoverAmt',\n] as const;\n\ntype Uniform = (typeof UNIFORMS)[number];\n\nconst compile = (gl: WebGLRenderingContext, type: number, source: string) => {\n  const shader = gl.createShader(type);\n  if (!shader) return null;\n  gl.shaderSource(shader, source);\n  gl.compileShader(shader);\n  if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n    gl.deleteShader(shader);\n    return null;\n  }\n  return shader;\n};\n\n/**\n * The one WebGL context every glow draws with, as iOS shares one renderer: the shader compiles\n * once, and a page with many glows stays far below the browser's limit on live contexts. Each\n * glow renders into a corner of its canvas and copies that onto its own 2D canvas.\n */\ntype SharedContext = {\n  canvas: HTMLCanvasElement;\n  gl: WebGLRenderingContext;\n  locations: Record<Uniform, WebGLUniformLocation | null>;\n  /** What each glow drawing with it does when the context is lost. */\n  users: Set<() => void>;\n  release: () => void;\n};\n\nlet shared: SharedContext | null = null;\n\nconst createSharedContext = (): SharedContext | null => {\n  const canvas = document.createElement('canvas');\n  let gl: WebGLRenderingContext | null = null;\n  try {\n    gl = canvas.getContext('webgl', {\n      alpha: true,\n      antialias: false,\n      depth: false,\n      premultipliedAlpha: true,\n      preserveDrawingBuffer: false,\n      stencil: false,\n    });\n  } catch {\n    gl = null;\n  }\n  if (!gl) return null;\n\n  const vertex = compile(gl, gl.VERTEX_SHADER, VERTEX);\n  const fragment = compile(gl, gl.FRAGMENT_SHADER, FRAGMENT);\n  const program = gl.createProgram();\n  if (!vertex || !fragment || !program) return null;\n  gl.attachShader(program, vertex);\n  gl.attachShader(program, fragment);\n  gl.linkProgram(program);\n  if (!gl.getProgramParameter(program, gl.LINK_STATUS)) return null;\n  gl.useProgram(program);\n\n  // One triangle covering the whole viewport.\n  const buffer = gl.createBuffer();\n  gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n  gl.bufferData(\n    gl.ARRAY_BUFFER,\n    new Float32Array([-1, -1, 3, -1, -1, 3]),\n    gl.STATIC_DRAW,\n  );\n  const position = gl.getAttribLocation(program, 'position');\n  gl.enableVertexAttribArray(position);\n  gl.vertexAttribPointer(position, 2, gl.FLOAT, false, 0, 0);\n\n  const locations = {} as Record<Uniform, WebGLUniformLocation | null>;\n  for (const name of UNIFORMS) locations[name] = gl.getUniformLocation(program, name);\n\n  const context: SharedContext = {\n    canvas,\n    gl,\n    locations,\n    release: () => {\n      canvas.removeEventListener('webglcontextlost', handleLost);\n      if (shared === context) shared = null;\n      if (gl?.isContextLost()) return;\n      gl?.deleteBuffer(buffer);\n      gl?.deleteProgram(program);\n      gl?.deleteShader(vertex);\n      gl?.deleteShader(fragment);\n      // Frees the context now rather than whenever it is garbage collected.\n      gl?.getExtension('WEBGL_lose_context')?.loseContext();\n    },\n    users: new Set(),\n  };\n  // Every glow drawing with it falls back, and the next glow to mount makes a new one.\n  const handleLost = (event: Event) => {\n    event.preventDefault();\n    if (shared === context) shared = null;\n    const users = [...context.users];\n    context.users.clear();\n    users.forEach((onLost) => onLost());\n  };\n  canvas.addEventListener('webglcontextlost', handleLost);\n  return context;\n};\n\n/**\n * The glow drawn by a WebGL shader, every pixel computed on the GPU: color masses warped by\n * noise, concentric waves, ripples from a tap or a hovering pointer, light and a halo.\n *\n * Returns null when WebGL is unavailable or the shader does not compile, so the caller can fall\n * back to CSS. `onLost` is called if the browser later drops the context.\n */\nexport const createGlowWebGLRenderer = (\n  canvas: HTMLCanvasElement,\n  onLost: () => void,\n): VoiceRenderer | null => {\n  const target = canvas.getContext('2d');\n  if (!target) return null;\n  shared ??= createSharedContext();\n  const context = shared;\n  if (!context) return null;\n\n  let lost = false;\n  const handleLost = () => {\n    lost = true;\n    onLost();\n  };\n  context.users.add(handleLost);\n\n  const draw = ({ dark, driver: d, height, width }: VoiceFrame) => {\n    target.clearRect(0, 0, width, height);\n    if (lost || width <= 0 || height <= 0) return;\n    const { canvas: source, gl, locations } = context;\n    // Large enough for the biggest glow, so glows of different sizes never resize it each frame.\n    if (source.width < width) source.width = width;\n    if (source.height < height) source.height = height;\n    // The glow renders into the bottom-left corner, which is the top-left of the image copied.\n    gl.viewport(0, 0, width, height);\n    gl.clearColor(0, 0, 0, 0);\n    gl.clear(gl.COLOR_BUFFER_BIT);\n    gl.uniform2f(locations.resolution, width, height);\n    for (let i = 0; i < 5; i++) {\n      const c = d.color(i);\n      gl.uniform4f(locations[`col${i}` as Uniform], c.hue, c.saturation, c.value, 0);\n    }\n    gl.uniform1f(locations.time, d.time);\n    gl.uniform1f(locations.count, d.count);\n    gl.uniform1f(locations.bright, d.bright);\n    gl.uniform1f(locations.sat, d.sat);\n    gl.uniform1f(locations.load, d.load);\n    gl.uniform1f(locations.flow, d.flow);\n    gl.uniform1f(locations.flowSpin, d.flowSpin);\n    gl.uniform1f(locations.orbSpin, d.orbSpin);\n    gl.uniform1f(locations.react, d.react);\n    gl.uniform1f(locations.dark, dark);\n    gl.uniform1f(locations.mic, d.mic);\n    gl.uniform1f(locations.voice, d.voice);\n    gl.uniform1f(locations.scale, d.scale);\n    gl.uniform2f(locations.tap, d.tapX, d.tapY);\n    gl.uniform1f(locations.tapTime, d.tapAge);\n    gl.uniform2f(locations.hover, d.hoverX, d.hoverY);\n    gl.uniform1f(locations.hoverAmt, d.hoverAmount);\n    gl.drawArrays(gl.TRIANGLES, 0, 3);\n    // Copied in the same task it was drawn, before the browser may discard the drawing buffer.\n    target.drawImage(\n      source,\n      0,\n      source.height - height,\n      width,\n      height,\n      0,\n      0,\n      width,\n      height,\n    );\n  };\n\n  const dispose = () => {\n    context.users.delete(handleLost);\n    if (!context.users.size) context.release();\n  };\n\n  return { dispose, draw };\n};\n"],"mappings":";AAEA,IAAM,SAAS;;;;;;;;;;;AAYf,IAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkNjB,IAAM,WAAW;CACf;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAIA,IAAM,WAAW,IAA2B,MAAc,WAAmB;CAC3E,MAAM,SAAS,GAAG,aAAa,IAAI;CACnC,IAAI,CAAC,QAAQ,OAAO;CACpB,GAAG,aAAa,QAAQ,MAAM;CAC9B,GAAG,cAAc,MAAM;CACvB,IAAI,CAAC,GAAG,mBAAmB,QAAQ,GAAG,cAAc,GAAG;EACrD,GAAG,aAAa,MAAM;EACtB,OAAO;CACT;CACA,OAAO;AACT;AAgBA,IAAI,SAA+B;AAEnC,IAAM,4BAAkD;CACtD,MAAM,SAAS,SAAS,cAAc,QAAQ;CAC9C,IAAI,KAAmC;CACvC,IAAI;EACF,KAAK,OAAO,WAAW,SAAS;GAC9B,OAAO;GACP,WAAW;GACX,OAAO;GACP,oBAAoB;GACpB,uBAAuB;GACvB,SAAS;EACX,CAAC;CACH,QAAQ;EACN,KAAK;CACP;CACA,IAAI,CAAC,IAAI,OAAO;CAEhB,MAAM,SAAS,QAAQ,IAAI,GAAG,eAAe,MAAM;CACnD,MAAM,WAAW,QA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