vireglass 2.1.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -1
- package/dist/{chunk-3PGYF2NK.js → chunk-CTTZNZFV.js} +3 -3
- package/dist/{chunk-3PGYF2NK.js.map → chunk-CTTZNZFV.js.map} +1 -1
- package/dist/{chunk-FL5UZPY5.js → chunk-H5QTBF67.js} +4 -4
- package/dist/{chunk-FL5UZPY5.js.map → chunk-H5QTBF67.js.map} +1 -1
- package/dist/{chunk-TTOKBARR.js → chunk-MMPK6DCK.js} +10 -3
- package/dist/chunk-MMPK6DCK.js.map +1 -0
- package/dist/{chunk-BZC2WHCK.js → chunk-PM2SWCSF.js} +4 -4
- package/dist/{chunk-BZC2WHCK.js.map → chunk-PM2SWCSF.js.map} +1 -1
- package/dist/{chunk-P2ZOODXD.js → chunk-SLRPHDV7.js} +3 -3
- package/dist/{chunk-P2ZOODXD.js.map → chunk-SLRPHDV7.js.map} +1 -1
- package/dist/dom.cjs +48 -20
- package/dist/dom.cjs.map +1 -1
- package/dist/dom.d.cts +15 -3
- package/dist/dom.d.ts +15 -3
- package/dist/dom.js +44 -23
- package/dist/dom.js.map +1 -1
- package/dist/index.cjs +1 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +5 -5
- package/dist/law.cjs +8 -1
- package/dist/law.cjs.map +1 -1
- package/dist/law.d.cts +7 -0
- package/dist/law.d.ts +7 -0
- package/dist/law.js +1 -1
- package/dist/reference.js +2 -2
- package/dist/web/index.cjs +262 -153
- package/dist/web/index.cjs.map +1 -1
- package/dist/web/index.d.cts +88 -2
- package/dist/web/index.d.ts +88 -2
- package/dist/web/index.js +257 -156
- package/dist/web/index.js.map +1 -1
- package/docs/law.md +2 -2
- package/package.json +13 -9
- package/src/dom/body.ts +24 -9
- package/src/dom/index.ts +44 -10
- package/src/dom/probe.ts +27 -3
- package/src/law.ts +7 -0
- package/src/targets/glsl.ts +4 -0
- package/src/web/gl.ts +57 -4
- package/src/web/gpu-timer.ts +111 -0
- package/src/web/index.ts +1 -0
- package/src/web/renderer.ts +305 -218
- package/dist/chunk-TTOKBARR.js.map +0 -1
package/dist/dom.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/dom/displacement.ts","../src/spectral.ts","../src/dom/spectral-map.ts","../src/dom/map-cache.ts","../src/dom/probe.ts","../src/dom/support.ts","../src/dom/shadow.ts","../src/dom/body.ts","../src/dom/preferences.ts","../src/dom/rim.ts","../src/dom/nesting.ts","../src/dom/scroll-edge.ts","../src/dom/group.ts","../src/dom/index.ts"],"names":["BEVEL_SAMPLES","mapDensity","smoothstep","clamp01","to255","r","g","b"],"mappings":";;;;;;;AAmBA,IAAM,UAAA,GAAa,IAAA;AAYnB,IAAM,WAAA,GAAc,IAAA;AACpB,IAAM,YAAY,GAAA,GAAM,WAAA;AAYxB,IAAM,aAAA,GAAgB,CAAA;AAGtB,SAAS,UAAA,CAAW,QAAA,EAA6B,KAAA,EAAe,GAAA,EAAqB;AACnF,EAAA,IAAI,KAAA,IAAS,GAAG,OAAO,GAAA;AACvB,EAAA,OAAO,IAAA,CAAK,GAAA,CAAI,GAAA,EAAK,aAAA,GAAgB,KAAK,CAAA;AAC5C;AAIA,SAAS,MAAA,CAAO,cAAsB,KAAA,EAAuB;AAC3D,EAAA,MAAM,UAAU,IAAA,CAAK,KAAA,CAAM,GAAA,IAAO,YAAA,GAAe,QAAQ,GAAA,CAAI,CAAA;AAC7D,EAAA,OAAO,OAAA,GAAU,CAAA,GAAI,CAAA,GAAI,OAAA,GAAU,MAAM,GAAA,GAAM,OAAA;AACjD;AAKA,SAAS,aAAa,CAAA,EAAmB;AACvC,EAAA,MAAM,MAAM,IAAA,CAAK,GAAA,CAAI,IAAI,IAAA,CAAK,IAAA,CAAK,KAAK,GAAA,CAAI,CAAA,GAAI,CAAA,GA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IAAA,IAAQ,MAAA;AACjB,MAAA,KAAA,EAAM;AAAA,IACR,CAAA;AAAA,IACA,iBAAiB,IAAA,EAAM;AACrB,MAAA,IAAI,aAAa,WAAA,EAAa;AAC9B,MAAA,MAAM,QAAA,GAAW,IAAA,CAAK,QAAA,IAAY,eAAA,CAAgB,EAAE,CAAA;AACpD,MAAA,IAAI,CAAC,IAAA,EAAM;AACT,QAAA,SAAA,CAAU,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,QAAQ,CAAA;AAC3B,QAAA;AAAA,MACF;AACA,MAAA,MAAM,IAAA,GAAO,GAAG,qBAAA,EAAsB;AACtC,MAAA,SAAA;AAAA,QACE,IAAA,CAAK,KAAA,IAAS,IAAA,CAAK,IAAA,GAAO,KAAK,KAAA,GAAQ,CAAA,CAAA;AAAA,QACvC,IAAA,CAAK,KAAA,IAAS,IAAA,CAAK,GAAA,GAAM,KAAK,MAAA,GAAS,CAAA,CAAA;AAAA,QACvC,IAAA,CAAK,QAAA;AAAA,QACL;AAAA,OACF;AAAA,IACF,CAAA;AAAA,IACA,SAAS,IAAA,EAAM;AACb,MAAA,KAAA,GAAQ,IAAA,IAAQ,IAAA,CAAK,SAAA,GAAY,CAAA,GAAI,IAAA,GAAO,IAAA;AAC5C,MAAA,MAAA,GAAS,EAAA;AACT,MAAA,KAAA,EAAM;AAAA,IACR,CAAA;AAAA,IACA;AAAA,GACF;AACA,EAAA,QAAA,CAAS,GAAA,CAAI,IAAI,MAAM,CAAA;AACvB,EAAA,OAAO,MAAA;AACT","file":"dom.js","sourcesContent":["// The DOM renderer's own optics: an `feDisplacementMap` source built from the same causes as the\n// GL/AGSL shaders, so a page refracting live content still reads as the same material. See\n// `docs/superpowers/specs/2026-09-19-vireglass-over-live-dom.md` for the technique this encodes.\nimport { bevelDp, thicknessDp, type VireGlassGeometry } from '../geometry';\nimport { BEVEL } from '../law';\nimport type { VireGlassOptics } from '../material';\nimport {\n sceneDistance,\n sceneGradient,\n touchWarp,\n type MorphShape,\n type TouchWarp,\n} from '../sdf';\n\nexport type DisplacementMap = { url: string; width: number; height: number; scale: number };\n\n/** dp of rim displacement per dp of size-adjusted thickness, at full refraction strength (ior →\n * 1.6). Tuned so the product default (V5: ior 1.5, thickness 28dp) lands well under `MAX_SCALE`\n * before it's ever clamped — the ceiling below is what actually limits denser glass. */\nconst SCALE_GAIN = 0.75;\n\n/**\n * `feDisplacementMap` displaces by `scale * (channel / 255 - 0.5)`: a full channel swing spans\n * ±scale/2, and one 8-bit step is `scale/255` px — not `scale/127`, which an earlier version of\n * this file assumed and which rendered every material at half its derived refraction.\n *\n * Measured in Chromium on 2026-09-19: at scale 40 (0.157 px/step) a high-contrast edge visibly\n * terraces; at scale 12 (0.047 px/step) it does not. The ceiling sits between them and nearer\n * the clean end — thick, high-index glass is flattened to it instead of its derived scale,\n * trading rim depth for an edge without stairs.\n */\nconst MAX_STEP_PX = 0.09;\nconst MAX_SCALE = 255 * MAX_STEP_PX;\n\n/**\n * Samples across the bevel band, which is the only place the map carries anything. Everything\n * inside it is a constant, and `feImage` stretches whatever it is given over the element anyway,\n * so resolving the element is wasted work: a sheet at device resolution is 197 000 pixels of\n * per-pixel maths and a PNG encode, 120 ms on attach and far past a frame during interaction.\n *\n * Eight samples describe a profile that is smooth by construction. The measured cost falls with\n * the square of the reduction, and `check:dom` measures the displacement afterwards to say\n * whether anything was lost.\n */\nconst BEVEL_SAMPLES = 8;\n\n/** Resolution the map is built at: enough to resolve the bevel, never more than the element. */\nfunction mapDensity(geometry: VireGlassGeometry, bevel: number, dpr: number): number {\n if (bevel <= 0) return dpr;\n return Math.min(dpr, BEVEL_SAMPLES / bevel);\n}\n\n/** True neutral is the unrepresentable 127.5; 128 is the nearest byte and leaves a residual\n * 0.002 of the scale, far below one step and below a pixel at any usable scale. */\nfunction encode(displacement: number, scale: number): number {\n const channel = Math.round(255 * (displacement / scale + 0.5));\n return channel < 0 ? 0 : channel > 255 ? 255 : channel;\n}\n\n/** Mirrors the shader's `vgBevelSlope`, renormalized into 0..1: curvature concentrated at the\n * rim, the middle left flat. A plain linear ramp from `vgBevelT` alone reads as a chamfer, not a\n * lens — the same reason the shader doesn't use it raw either. */\nfunction bevelProfile(t: number): number {\n const raw = Math.min(t / Math.sqrt(Math.max(1 - t * t * BEVEL.sphere, BEVEL.floor)), BEVEL.slopeMax);\n return raw / BEVEL.slopeMax;\n}\n\nexport type DisplacementState = {\n /** Finger response (docs/reference.md §5): the field around the touch deforms, so the silhouette\n * the backdrop bends along deforms with it. */\n touch?: TouchWarp;\n /** Smooth-union neighbours (§5): shapes merging into one and splitting apart. */\n smoothing?: number;\n morph?: MorphShape;\n morph2?: MorphShape;\n /** Any number of shapes flowing into this one. `morph`/`morph2` are the first two, kept so a\n * caller that only ever had two does not have to change. */\n morphs?: readonly MorphShape[];\n};\n\n/**\n * The raw pixel buffer, with no canvas involved — the part actually worth unit-testing.\n * `buildDisplacementMap` below is a thin DOM wrapper around this.\n *\n * Encoding: R = x offset, G = y offset, 128 = no shift, one step = `scale/255` px; B = 128\n * (unused), A = 255 (opaque, `feImage` would otherwise composite the map against page black).\n * The offset points INWARD — the rim samples the backdrop from inside the shape, a convex thick\n * lens. Displacement lives only in the bevel band (`bevelDp`); the flat middle is exactly 128/128.\n */\nexport function renderDisplacementPixels(\n optics: VireGlassOptics,\n geometry: VireGlassGeometry,\n dpr: number,\n state: DisplacementState = {},\n): { data: Uint8ClampedArray; width: number; height: number; scale: number } {\n const bevel = bevelDp(geometry, optics);\n const density = mapDensity(geometry, bevel, dpr);\n const width = Math.max(1, Math.round(geometry.width * density));\n const height = Math.max(1, Math.round(geometry.height * density));\n const rawScale = optics.refraction * thicknessDp(geometry, optics) * SCALE_GAIN;\n const scale = Math.min(rawScale, MAX_SCALE);\n const smoothing = state.smoothing ?? 0;\n // One list, whichever way the caller expressed it.\n const shapes: (MorphShape | undefined)[] = [state.morph, state.morph2, ...(state.morphs ?? [])];\n\n const data = new Uint8ClampedArray(width * height * 4);\n const halfW = geometry.width / 2;\n const halfH = geometry.height / 2;\n\n for (let py = 0; py < height; py += 1) {\n const y = (py + 0.5) / density - halfH;\n for (let px = 0; px < width; px += 1) {\n const x = (px + 0.5) / density - halfW;\n const i = (py * width + px) * 4;\n // Warp the FIELD first, then read the scene at the warped point — the shader's own order.\n const [wx, wy] = state.touch ? touchWarp(x, y, state.touch) : [x, y];\n const sd = sceneDistance(wx, wy, geometry.width, geometry.height, geometry.cornerRadius, smoothing, ...shapes);\n const t = Math.min(Math.max((sd + bevel) / bevel, 0), 1);\n if (t <= 0 || scale <= 0) {\n data[i] = 128;\n data[i + 1] = 128;\n data[i + 2] = 128;\n data[i + 3] = 255;\n continue;\n }\n const [gx, gy] = sceneGradient(wx, wy, geometry.width, geometry.height, geometry.cornerRadius, smoothing, ...shapes);\n // The rim reaches half the scale: the encoding can only span ±scale/2, so the derived\n // displacement is expressed as a fraction of that half-range.\n const magnitude = bevelProfile(t) * (scale / 2);\n const dx = -gx * magnitude;\n const dy = -gy * magnitude;\n // Inverse of the spec's own formula: channel = 255 * (displacement / scale + 0.5).\n data[i] = encode(dx, scale);\n data[i + 1] = encode(dy, scale);\n data[i + 2] = 128;\n data[i + 3] = 255;\n }\n }\n\n return { data, width, height, scale };\n}\n\nfunction hasCanvasSupport(): boolean {\n return typeof document !== 'undefined' && typeof document.createElement === 'function';\n}\n\n/** Builds the map at device-pixel resolution so it stays sharp once the browser stretches it back\n * over the element's CSS-px box (`feImage` fills the filter region regardless of source size). */\nexport function buildDisplacementMap(\n optics: VireGlassOptics,\n geometry: VireGlassGeometry,\n dpr: number,\n state: DisplacementState = {},\n): DisplacementMap {\n if (!hasCanvasSupport()) {\n throw new Error('vireglass/dom: buildDisplacementMap requires a DOM (canvas)');\n }\n const { data, width, height, scale } = renderDisplacementPixels(optics, geometry, dpr, state);\n const canvas = document.createElement('canvas');\n canvas.width = width;\n canvas.height = height;\n const ctx = canvas.getContext('2d');\n if (!ctx) throw new Error('vireglass/dom: 2D canvas context unavailable');\n const imageData = ctx.createImageData(width, height);\n imageData.data.set(data);\n ctx.putImageData(imageData, 0, 0);\n return { url: canvas.toDataURL('image/png'), width, height, scale };\n}\n","// The spectral edge (docs/reference.md §1). Dispersion, diffraction and interference are ONE\n// cause — a dependence on wavelength — and one hue multiplier, normalised to its own mean, so they\n// colour what passes through without brightening it.\n//\n// JS twins of the lens shader's `vgInterference`, `vgDiffraction` and the rim profile they read\n// from. Same reason as the SDF's twins: the DOM path needs this geometry as numbers, and a second\n// version that drifts is the defect the parity gate exists for.\nimport { LENS, SPECTRAL } from './law';\n\nconst TAU = 6.28318530718;\nconst LAMBDA: readonly [number, number, number] = [LENS.lambdaR, LENS.lambdaG, LENS.lambdaB];\n\nconst clamp01 = (v: number) => (v < 0 ? 0 : v > 1 ? 1 : v);\n\n/** Normalises a triple to its own mean — the step that makes these hues rather than gains. */\nfunction toHue(v: [number, number, number]): [number, number, number] {\n const mean = Math.max((v[0] + v[1] + v[2]) / 3, 0.001);\n return [v[0] / mean, v[1] / mean, v[2] / mean];\n}\n\n/** Mirrors `vgRimQd`: the derivative of the rim's height profile. */\nexport function rimSlopeCurve(x: number): number {\n const k = 1 - clamp01(x);\n return (k * k * k) / Math.pow(Math.max(1 - k * k * k * k, 1e-5), 0.75);\n}\n\n/** Mirrors `vgSlope`: the top face's slope at distance `e` inside the silhouette. */\nexport function surfaceSlope(e: number, bevel: number, rim: number, thick: number): number {\n if (e >= bevel || bevel <= 0) return 0;\n return Math.min(((thick - rim) / bevel) * rimSlopeCurve(e / bevel), LENS.slopeMax);\n}\n\n/** The normal's z, which is what both spectral terms are measured against. `N = normalize([n·s, 1])`\n * in the shader, so its z is simply the slope resolved back to unit length. */\nexport function surfaceCosine(slope: number): number {\n return 1 / Math.sqrt(1 + slope * slope);\n}\n\n/** Thin-film interference: optical path difference 2·n·d·cosθt, each channel with its own λ. */\nexport function interference(cosI: number, filmNm: number): [number, number, number] {\n const sinT2 = (1 - cosI * cosI) / (LENS.filmIor * LENS.filmIor);\n const cosT = Math.sqrt(Math.max(1 - sinT2, 0));\n const opd = 2 * LENS.filmIor * filmNm * cosT;\n return toHue([\n 0.5 + 0.5 * Math.cos((TAU * opd) / LAMBDA[0] + Math.PI),\n 0.5 + 0.5 * Math.cos((TAU * opd) / LAMBDA[1] + Math.PI),\n 0.5 + 0.5 * Math.cos((TAU * opd) / LAMBDA[2] + Math.PI),\n ]);\n}\n\n/** Edge diffraction: fringes get denser as the bevel sharpens. A hue, not a brightness. */\nexport function diffraction(distFromEdge: number, bevel: number): [number, number, number] {\n const phase = (TAU * SPECTRAL.diffractionFringes * distFromEdge) / Math.max(bevel, 1);\n const f = (lambda: number) => 0.5 + 0.5 * Math.cos((phase * SPECTRAL.referenceLambda) / lambda);\n return toHue([f(LAMBDA[0]), f(LAMBDA[1]), f(LAMBDA[2])]);\n}\n\nfunction smoothstep(edge0: number, edge1: number, x: number): number {\n const t = clamp01((x - edge0) / (edge1 - edge0));\n return t * t * (3 - 2 * t);\n}\n\n/**\n * Both terms at one point, weighted as the lens weights them: interference by `iridescence` across\n * the bevel, diffraction by its own strength but only within `diffractionOnset` of the silhouette.\n *\n * `e` is the distance inside the edge; everything else comes from the resolved optics.\n */\nexport function spectralHue(\n e: number,\n bevel: number,\n rim: number,\n thick: number,\n optics: { film: number; iridescence: number; diffraction: number },\n): [number, number, number] {\n let r = 1;\n let g = 1;\n let b = 1;\n\n // `t` is 1 at the silhouette and 0 at the inner edge of the bevel, as below.\n const t = 1 - clamp01(bevel > 0 ? e / bevel : 1);\n\n if (optics.iridescence > 0.001) {\n // Windowed to the edge, for the same reason diffraction is: §2 puts the iridescence on the\n // opposing arc, and an arc is at the silhouette. Unwindowed, the surface angle stops changing a\n // third of the way in and the film paints the rest of the bevel one flat colour.\n const w = optics.iridescence * smoothstep(SPECTRAL.iridescenceOnset, 1, t);\n if (w > 0) {\n const cosI = clamp01(surfaceCosine(surfaceSlope(e, bevel, rim, thick)));\n const i = interference(cosI, optics.film);\n r += (i[0] - 1) * w;\n g += (i[1] - 1) * w;\n b += (i[2] - 1) * w;\n }\n }\n\n if (optics.diffraction > 0.001) {\n // The fringes live at the outer end of the bevel, which is what makes this an EDGE effect\n // rather than a sheen over it.\n const w = optics.diffraction * smoothstep(SPECTRAL.diffractionOnset, 1, t);\n if (w > 0) {\n const d = diffraction(e, bevel);\n r += (d[0] - 1) * w;\n g += (d[1] - 1) * w;\n b += (d[2] - 1) * w;\n }\n }\n\n return [r, g, b];\n}\n","// The spectral edge, baked into an image (docs/reference.md §1).\n//\n// Diffraction and interference are hue multipliers that vary per pixel across the bevel, and an\n// SVG filter has no way to evaluate a function per pixel. But it can MULTIPLY by an image:\n// `feComposite operator=\"arithmetic\"` with k1 set is a product, so the hue can be baked and\n// applied in one pass.\n//\n// The multiplier exceeds 1 wherever a channel is boosted, and eight bits cannot carry that, so the\n// map stores the hue divided by a headroom the filter multiplies back. Without the headroom every\n// boosted channel would clip to white and the fringes would read as a bright rim rather than a\n// coloured one.\nimport { bevelDp, rimDp, thicknessDp, type VireGlassGeometry } from '../geometry';\nimport type { VireGlassOptics } from '../material';\nimport { sdfRoundedRect } from '../sdf';\nimport { spectralHue } from '../spectral';\n\nexport type SpectralMap = { url: string; width: number; height: number; headroom: number };\n\n/** A hue normalised to its own mean cannot exceed the number of channels; in practice it stays\n * well under two. Two is the smallest headroom that never clips. */\nconst HEADROOM = 2;\n\n/**\n * The hue map is sampled like the displacement map — across the bevel, not across the element. It\n * needs MORE samples than the displacement does, because fringes oscillate where the displacement\n * is monotonic, and undersampling a fringe pattern aliases it into a different one.\n */\nconst BEVEL_SAMPLES = 24;\n\nfunction mapDensity(bevel: number, dpr: number): number {\n if (bevel <= 0) return dpr;\n return Math.min(dpr, BEVEL_SAMPLES / bevel);\n}\n\nexport function renderSpectralPixels(\n optics: VireGlassOptics,\n geometry: VireGlassGeometry,\n dpr: number,\n): { data: Uint8ClampedArray; width: number; height: number; headroom: number } {\n const bevel = bevelDp(geometry, optics);\n const density = mapDensity(bevel, dpr);\n const width = Math.max(1, Math.round(geometry.width * density));\n const height = Math.max(1, Math.round(geometry.height * density));\n const rim = rimDp(geometry, optics);\n const thick = thicknessDp(geometry, optics);\n\n const data = new Uint8ClampedArray(width * height * 4);\n const halfW = geometry.width / 2;\n const halfH = geometry.height / 2;\n const neutral = Math.round((1 / HEADROOM) * 255);\n\n for (let py = 0; py < height; py += 1) {\n const y = (py + 0.5) / density - halfH;\n for (let px = 0; px < width; px += 1) {\n const x = (px + 0.5) / density - halfW;\n const i = (py * width + px) * 4;\n const sd = sdfRoundedRect(x, y, geometry.width, geometry.height, geometry.cornerRadius);\n const e = Math.max(-sd, 0);\n if (e >= bevel) {\n // Past the bevel the glass is plain: a neutral multiplier, not a missing one.\n data[i] = neutral;\n data[i + 1] = neutral;\n data[i + 2] = neutral;\n data[i + 3] = 255;\n continue;\n }\n const [r, g, b] = spectralHue(e, bevel, rim, thick, optics);\n data[i] = Math.round((r / HEADROOM) * 255);\n data[i + 1] = Math.round((g / HEADROOM) * 255);\n data[i + 2] = Math.round((b / HEADROOM) * 255);\n data[i + 3] = 255;\n }\n }\n\n return { data, width, height, headroom: HEADROOM };\n}\n\n/** Whether this material has a spectral edge at all. Three extra filter primitives and a per-pixel\n * bake are not worth paying for a multiplier that is flat 1. */\nexport function hasSpectralEdge(optics: VireGlassOptics): boolean {\n return optics.iridescence > 0.001 || optics.diffraction > 0.001;\n}\n\nexport function buildSpectralMap(\n optics: VireGlassOptics,\n geometry: VireGlassGeometry,\n dpr: number,\n): SpectralMap {\n if (typeof document === 'undefined' || typeof document.createElement !== 'function') {\n throw new Error('vireglass/dom: buildSpectralMap requires a DOM (canvas)');\n }\n const { data, width, height, headroom } = renderSpectralPixels(optics, geometry, dpr);\n const canvas = document.createElement('canvas');\n canvas.width = width;\n canvas.height = height;\n const ctx = canvas.getContext('2d');\n if (!ctx) throw new Error('vireglass/dom: 2D canvas context unavailable');\n const image = ctx.createImageData(width, height);\n image.data.set(data);\n ctx.putImageData(image, 0, 0);\n return { url: canvas.toDataURL('image/png'), width, height, headroom };\n}\n","// Maps are pure functions of geometry, optics and density — the same element twice, or four\n// identical buttons in a tab bar, produce byte-identical PNGs. Building each one again is the\n// single largest avoidable cost in this renderer: a sheet's hue map is tens of milliseconds, and\n// it happens on every attach, every remount and every re-attach after a theme change.\n//\n// Small and strict on purpose. A page has a handful of distinct glass shapes, not hundreds; a\n// cache that grew without bound would hold megabytes of data URIs alive for a screen nobody is\n// looking at any more.\nconst LIMIT = 24;\n\nconst store = new Map<string, unknown>();\n\nexport function cached<T>(key: string, build: () => T): T {\n const hit = store.get(key);\n if (hit !== undefined) {\n // Re-inserting moves it to the end: the oldest key is the one evicted, not the most used one.\n store.delete(key);\n store.set(key, hit);\n return hit as T;\n }\n const value = build();\n store.set(key, value);\n if (store.size > LIMIT) {\n const oldest = store.keys().next();\n if (!oldest.done) store.delete(oldest.value);\n }\n return value;\n}\n\n/** Test-only: the cache is process-wide, and a suite that measures build cost needs it cold. */\nexport function clearMapCache(): void {\n store.clear();\n}\n\nexport function mapCacheSize(): number {\n return store.size;\n}\n","// Backdrop sample for the DOM renderer — the web-DOM counterpart to the WebGL downsample probe\n// (`web/probe.ts`) and the native capture on Android. The web canvas can read the pixels it just\n// drew; a page CANNOT read what's actually rendered behind an arbitrary element — that boundary\n// is the whole reason `backdrop-filter` exists as a browser primitive rather than a pixel API. So\n// this probes DECLARED STYLES instead: walk the stacking order under a grid of sample points and\n// read `background-color` (falling back to `color`) rather than any real pixel.\nimport type { BackdropSample } from '../adaptation';\n\n/** A modest grid: this runs on scroll, not per frame. `elementsFromPoint` walks the whole\n * stacking context at every sample point — a fine grid shows up in a profiler, a coarse one is\n * still plenty to tell \"flat\" from \"busy\" for the adaptation decision. */\nconst GRID_COLS = 5;\nconst GRID_ROWS = 5;\n\nexport type RgbColor = { r: number; g: number; b: number; a: number };\n\n/**\n * Parses `rgb()`/`rgba()` exactly as `getComputedStyle` emits them — every engine normalizes a\n * resolved color to one of these two forms, so there's nothing here worth a dependency for.\n * Returns `null` for anything else (a keyword that didn't resolve, a malformed value).\n */\nexport function parseColor(value: string): RgbColor | null {\n const match = /rgba?\\(\\s*([\\d.]+)\\s*,\\s*([\\d.]+)\\s*,\\s*([\\d.]+)\\s*(?:,\\s*([\\d.]+))?\\s*\\)/i.exec(value);\n if (!match) return null;\n const r = Number(match[1]);\n const g = Number(match[2]);\n const b = Number(match[3]);\n const a = match[4] === undefined ? 1 : Number(match[4]);\n if (!Number.isFinite(r) || !Number.isFinite(g) || !Number.isFinite(b) || !Number.isFinite(a)) return null;\n return { r, g, b, a };\n}\n\nfunction luma(r: number, g: number, b: number): number {\n return 0.2126 * r + 0.7152 * g + 0.0722 * b;\n}\n\n/**\n * Same statistic the WebGL probe computes on its downsample grid (`web/probe.ts`, `rectStats`):\n * mean luma, twice the mean deviation for `busy`, 10th/90th percentile for `lo`/`hi`. A different\n * formula here would mean the ink-polarity decision quietly drifts between renderers on the same\n * page. `samples` are 0..255 per channel, matching what `parseColor` returns.\n */\nexport function statsFromSamples(samples: readonly RgbColor[]): BackdropSample {\n const n = samples.length;\n if (n === 0) return { luma: 0.5, busy: 0, lo: 0.5, hi: 0.5, r: 0.5, g: 0.5, b: 0.5 };\n\n const lumas: number[] = [];\n let sr = 0;\n let sg = 0;\n let sb = 0;\n for (const s of samples) {\n const r = s.r / 255;\n const g = s.g / 255;\n const b = s.b / 255;\n lumas.push(luma(r, g, b));\n sr += r;\n sg += g;\n sb += b;\n }\n\n let mean = 0;\n for (const v of lumas) mean += v;\n mean /= n;\n\n let busy = 0;\n for (const v of lumas) busy += Math.abs(v - mean);\n busy = Math.min((busy / n) * 2, 1);\n\n const sorted = [...lumas].sort((a, b) => a - b);\n const percentile = (p: number) => {\n const idx = p * (n - 1);\n const lo = Math.floor(idx);\n const hi = Math.ceil(idx);\n return sorted[lo] + (sorted[hi] - sorted[lo]) * (idx - lo);\n };\n\n return {\n luma: mean,\n busy,\n lo: percentile(0.1),\n hi: percentile(0.9),\n r: sr / n,\n g: sg / n,\n b: sb / n,\n };\n}\n\n/**\n * Composites a stack of backgrounds front to back, the way the compositor does.\n *\n * Taking the first layer with any alpha at all instead is wrong by a lot, not a little: a list row\n * tinted `rgba(255,255,255,0.028)` over a near-black page reads as pure WHITE, and the glass then\n * adapts to a backdrop that does not exist. That is most real interfaces.\n */\nexport function compositeLayers(layers: readonly RgbColor[]): RgbColor | null {\n let r = 0;\n let g = 0;\n let b = 0;\n let a = 0;\n for (const layer of layers) {\n const share = layer.a * (1 - a);\n if (share <= 0) continue;\n r += layer.r * share;\n g += layer.g * share;\n b += layer.b * share;\n a += share;\n if (a >= 0.999) break;\n }\n if (a <= 0.001) return null;\n // Normalised by coverage: what reached the eye, as an opaque colour. A stack that never became\n // opaque sits over the page's own background, which is the caller's floor layer.\n return { r: r / a, g: g / a, b: b / a, a };\n}\n\n/** Walks the stack at one point, skipping the glass element itself (it would otherwise probe its\n * own background) and its descendants. */\nfunction sampleColorAt(el: HTMLElement, x: number, y: number): RgbColor | null {\n const stack = document.elementsFromPoint(x, y);\n const behind = stack.filter((node) => node !== el && !el.contains(node));\n const layers: RgbColor[] = [];\n for (const node of behind) {\n const bg = parseColor(getComputedStyle(node).backgroundColor);\n // `rgba(0, 0, 0, 0)` is what \"transparent\" resolves to almost everywhere: it contributes\n // nothing and must not shadow a real colour further down.\n if (bg && bg.a > 0.001) layers.push(bg);\n }\n const composited = compositeLayers(layers);\n if (composited) return composited;\n const topmost = behind[0];\n if (!topmost) return null;\n return parseColor(getComputedStyle(topmost).color);\n}\n\nexport type ProbeOptions = {\n /** Grid density override — wider for a hero element, narrower for a tight control. */\n cols?: number;\n rows?: number;\n};\n\n/**\n * Backdrop sample for the glass element from its live surroundings, blind to images/video/canvas\n * by construction (the caller overrides with its own sample there — cover art already knows its\n * own accent; see `attachGlass`'s `sample` option).\n */\nexport function probeBackdrop(el: HTMLElement, opts: ProbeOptions = {}): BackdropSample {\n const cols = opts.cols ?? GRID_COLS;\n const rows = opts.rows ?? GRID_ROWS;\n const rect = el.getBoundingClientRect();\n // A hidden or not-yet-laid-out element has no backdrop to speak of. Sampling it anyway collapses\n // the whole grid onto one corner point and reports whatever unrelated thing sits there as a\n // confident, perfectly flat reading.\n if (rect.width <= 0 || rect.height <= 0) return statsFromSamples([]);\n const samples: RgbColor[] = [];\n for (let j = 0; j < rows; j += 1) {\n const y = rect.top + ((j + 0.5) / rows) * rect.height;\n for (let i = 0; i < cols; i += 1) {\n const x = rect.left + ((i + 0.5) / cols) * rect.width;\n const color = sampleColorAt(el, x, y);\n if (color) samples.push(color);\n }\n }\n return statsFromSamples(samples);\n}\n","// Feature detection BY MEASUREMENT, never by sniffing the user agent — the agent string is the\n// first thing to lie about this after an engine update.\n//\n// Firefox does not support `url()` inside `backdrop-filter` and has closed the request as not\n// planned (bug 1578503). Safari doesn't support `backdrop-filter` with `url()` yet either, though\n// WebKit has patches in flight. Both can change without notice, so this asks the engine directly.\n\nlet backdropFilterSupport: boolean | null = null;\nlet svgBackdropFilterSupport: boolean | null = null;\n\n// `CSS.supports`, not a detached element read back through `getComputedStyle`: Chromium resolves\n// no style at all for an element outside the document, so that probe answered \"unsupported\" in the\n// very engine where the displacement demonstrably works.\n//\n// This answers that the engine PARSES the value. An engine could in principle parse `url()` and\n// render nothing; a host that meets one can override the decision through `attachGlass` instead of\n// being stuck with a wrong automatic answer.\nfunction probeProperty(property: string, value: string): boolean {\n if (typeof CSS === 'undefined' || typeof CSS.supports !== 'function') return false;\n return CSS.supports(property, value);\n}\n\n/** Any `backdrop-filter` at all (e.g. `blur()`) — the fallback path's own requirement. */\nexport function supportsBackdropFilter(): boolean {\n if (backdropFilterSupport === null) {\n backdropFilterSupport =\n probeProperty('backdrop-filter', 'blur(1px)') || probeProperty('-webkit-backdrop-filter', 'blur(1px)');\n }\n return backdropFilterSupport;\n}\n\n/** `url(#filter)` specifically — the SVG displacement path's requirement. Checked separately from\n * `supportsBackdropFilter()`: an engine can support plain blur without supporting a filter\n * reference, which is exactly the Firefox case. */\nexport function supportsSvgBackdropFilter(): boolean {\n if (svgBackdropFilterSupport === null) {\n svgBackdropFilterSupport = probeProperty('backdrop-filter', 'url(#vireglass-support-probe)');\n }\n return svgBackdropFilterSupport;\n}\n\n/** Test-only: the two probes above cache after their first call, and a suite that stubs the DOM\n * differently per test needs a way to invalidate that. */\nexport function resetSupportCache(): void {\n backdropFilterSupport = null;\n svgBackdropFilterSupport = null;\n}\n","// Adaptive shadow (docs/reference.md §4). The law itself — density keyed to what is behind the\n// element, size keyed to its own half-size — lives in `../geometry` as `shadowOpacityFrom` and\n// `shadowReachDp`; this turns those into a CSS `box-shadow`.\nimport { ambientFrom, type BackdropSample } from '../adaptation';\nimport { shadowOpacity, shadowOpacityFrom, shadowReachDp, type VireGlassGeometry } from '../geometry';\nimport { SHADOW, SHADOW_GAP } from '../law';\nimport { shadowTint } from '../shadow-tint';\n\n/**\n * The model carries shadow density as a multiplier the shader applies to its own per-pixel term,\n * so the DOM path has to convert it to one flat alpha. That conversion is not a taste constant:\n * §4 records both ends measured off reference frames 711–723 — 19.9% over text, 4.0% over a flat\n * light backdrop — and `shadowOpacity` spans exactly those two cases. Two measured points, one line.\n */\nconst FLAT_DENSITY = shadowOpacity(0);\nconst BUSY_DENSITY = shadowOpacity(1);\n\nexport function shadowAlphaFrom(sample: { busy: number }): number {\n const t = (shadowOpacityFrom(sample) - FLAT_DENSITY) / (BUSY_DENSITY - FLAT_DENSITY);\n const alpha = SHADOW.alphaFlat + t * (SHADOW.alphaBusy - SHADOW.alphaFlat);\n return Math.min(Math.max(alpha, 0), 1);\n}\n\nconst to255 = (v: number) => Math.round(Math.min(Math.max(v, 0), 1) * 255);\n\n/**\n * Symmetric and blur-only: §4 gives a density and a size, never a direction. The reference calls\n * the shadow \"soft, small\" — blur carries both.\n *\n * The colour is NOT black. \"The light reflects, scatters, and bleeds into the shadow as well —\n * much like it would in the physical world\" (219 @8:22). A black shadow leaves an element over\n * colourful content hanging above a grey blob, which is the one thing that reads as pasted on.\n */\n/**\n * `appear` is the same gate the surface shader puts on the shadow (`u_shadow * u_appear`, line\n * 176). An element that is not there yet does not cast: a shadow under nothing is the one part of\n * materialising that gives the trick away.\n */\nexport function boxShadowCss(\n geometry: VireGlassGeometry,\n sample: BackdropSample | { busy: number },\n appear = 1,\n): string {\n const reach = shadowReachDp(geometry);\n const present = appear < 0 ? 0 : appear > 1 ? 1 : appear;\n const alpha = shadowAlphaFrom(sample) * present;\n const ambient = 'luma' in sample ? ambientFrom(sample as BackdropSample) : null;\n if (!ambient) return `0 0 ${reach.toFixed(1)}px rgba(0, 0, 0, ${alpha.toFixed(3)})`;\n\n const [r, g, b] = shadowTint(ambient);\n const spill = SHADOW_GAP.tint;\n return (\n `0 0 ${reach.toFixed(1)}px ` +\n `rgba(${to255(r * spill)}, ${to255(g * spill)}, ${to255(b * spill)}, ${alpha.toFixed(3)})`\n );\n}\n","// The glass BODY (docs/reference.md §3): how dense the medium has to be over this particular\n// backdrop, and which way it tints.\n//\n// The law is the lens shader's, lines 444–482, ported to one value per element instead of one per\n// pixel — the DOM path has a single backdrop sample, not a plane. Constants keep their names from\n// the shader so the two stay comparable.\nimport { BODY } from '../law';\nimport type { VireGlassOptics } from '../material';\n\nconst {\n capLoose: BODY_CAP_LOOSE,\n capTight: BODY_CAP_TIGHT,\n tintDark: TINT_DARK,\n tintLight: TINT_LIGHT,\n groundSpan: GROUND_SPAN,\n busyEdge: BUSY_EDGE,\n darkSideFrom: DARK_SIDE_FROM,\n darkSideTo: DARK_SIDE_TO,\n maxDemand: MAX_DEMAND,\n} = BODY;\n\nconst clamp = (v: number, lo: number, hi: number) => (v < lo ? lo : v > hi ? hi : v);\nconst mix = (a: number, b: number, t: number) => a + (b - a) * t;\n\nfunction smoothstep(edge0: number, edge1: number, x: number): number {\n const t = clamp((x - edge0) / (edge1 - edge0), 0, 1);\n return t * t * (3 - 2 * t);\n}\n\n/** Only the two figures the law reads — the same narrowing `shadowOpacityFrom` uses. */\nexport type BodyBackdrop = { luma: number; busy: number };\n\nexport type GlassBody = {\n /** How much medium stands between the backdrop and the eye, 0…1. */\n density: number;\n /** Lightness the body tints toward. */\n tintLuma: number;\n};\n\n/**\n * `ink` is POLARITY, 1 light and 0 dark, matching the shader's uniform. The requirements are\n * evaluated at both ends and blended by it — computing at the current polarity alone makes the\n * glass dip toward the middle while a recolor is in flight.\n */\nexport function resolveBody(optics: VireGlassOptics, sample: BodyBackdrop, ink: number): GlassBody {\n const strict = clamp(optics.legibility * 2, 0, 1);\n const capLight = mix(BODY_CAP_LOOSE, BODY_CAP_TIGHT, strict);\n const floorDark = 1 - capLight;\n const pol = clamp(ink, 0, 1);\n // With no ink on it, the model promises transparent glass: the requirement fades out with\n // legibility rather than standing at a floor.\n const demand = clamp(optics.legibility * 4, 0, 1);\n\n const mean = clamp(sample.luma, 0, 1);\n const busy = Math.max(sample.busy, 0);\n\n // Direction of the tint follows the element's AVERAGE lightness, not a local spot: on a\n // gradient a local threshold cuts a diagonal step across the body.\n const darkSide = smoothstep(DARK_SIDE_FROM, DARK_SIDE_TO, mean);\n const away = mix(TINT_LIGHT, TINT_DARK, darkSide);\n const tintLuma = mix(away, mix(TINT_LIGHT, TINT_DARK, pol), demand);\n\n // How much medium it takes to push the lightness under the ink past its threshold, measured\n // from whichever edge of the backdrop's spread is closer to the ink — a light ink drowns in a\n // light patch right beneath it, and the average knows nothing about that patch.\n const edge = busy * BUSY_EDGE;\n const inkHi = Math.min(mean + edge, 1);\n const inkLo = Math.max(mean - edge, 0);\n const needForLight = inkHi > capLight ? clamp((inkHi - capLight) / Math.max(inkHi - TINT_DARK, 1e-4), 0, MAX_DEMAND) : 0;\n const needForDark = inkLo < floorDark ? clamp((floorDark - inkLo) / Math.max(TINT_LIGHT - inkLo, 1e-4), 0, MAX_DEMAND) : 0;\n const needForInk = mix(needForDark, needForLight, pol) * demand;\n\n // Fine texture the body has to stop being a window for, the same way roughness does it.\n const ground = busy * optics.legibility * GROUND_SPAN;\n\n return { density: Math.max(Math.max(optics.bodyDensity, ground), needForInk), tintLuma };\n}\n\n/**\n * PRESENCE (§3): over a uniform backdrop there is nothing to refract and the glass honestly\n * disappears — right for a piece of background, wrong for a control. The sign comes from the\n * BACKDROP, not from ink polarity: lighter over dark, darker over light. It is a minimum, not an\n * addition, so a body that is already dense enough is left alone.\n */\nexport function withPresence(body: GlassBody, optics: VireGlassOptics, sample: BodyBackdrop): GlassBody {\n if (optics.presence <= 0) return body;\n const mean = clamp(sample.luma, 0, 1);\n const lighter = mean < 0.5;\n const target = lighter ? Math.min(mean + optics.presence, 1) : Math.max(mean - optics.presence, 0);\n const separation = Math.abs(target - mean);\n const reached = Math.abs(body.tintLuma - mean) * body.density;\n if (reached >= separation) return body;\n const needed = separation / Math.max(Math.abs((lighter ? TINT_LIGHT : TINT_DARK) - mean), 1e-4);\n return {\n density: Math.max(body.density, Math.min(needed, MAX_DEMAND)),\n tintLuma: lighter ? Math.max(body.tintLuma, mean) : Math.min(body.tintLuma, mean),\n };\n}\n","// System accessibility on the web (docs/reference.md §9). The three settings the reference names\n// all have media queries, so nothing here has to be asked of the host: the browser already knows.\n//\n// `reduceMotion` leaves optics alone — it is about motion, and motion is computed by the\n// deformation model, which takes it as `elastic: false`. The element keeps answering a finger; it\n// stops springing and rippling.\nimport { NO_ACCESSIBILITY, type VireGlassAccessibility } from '../accessibility';\n\nconst QUERIES = {\n reduceTransparency: '(prefers-reduced-transparency: reduce)',\n increaseContrast: '(prefers-contrast: more)',\n reduceMotion: '(prefers-reduced-motion: reduce)',\n} as const;\n\nfunction matches(query: string): boolean {\n if (typeof matchMedia !== 'function') return false;\n try {\n return matchMedia(query).matches;\n } catch {\n // An engine that does not know a query throws rather than answering false. Not knowing it is\n // an answer of \"not set\", not a reason to fail.\n return false;\n }\n}\n\nexport function systemAccessibility(): VireGlassAccessibility {\n if (typeof matchMedia !== 'function') return NO_ACCESSIBILITY;\n return {\n reduceTransparency: matches(QUERIES.reduceTransparency),\n increaseContrast: matches(QUERIES.increaseContrast),\n reduceMotion: matches(QUERIES.reduceMotion),\n };\n}\n\n/** Fires whenever any of the three changes. The material has to follow a setting turned on while\n * the page is open, not only one that was on when it loaded. */\nexport function watchAccessibility(onChange: (next: VireGlassAccessibility) => void): () => void {\n if (typeof matchMedia !== 'function') return () => {};\n const lists: MediaQueryList[] = [];\n const handler = () => onChange(systemAccessibility());\n for (const query of Object.values(QUERIES)) {\n try {\n const list = matchMedia(query);\n list.addEventListener('change', handler);\n lists.push(list);\n } catch {\n // Same as above: an unknown query simply has nothing to watch.\n }\n }\n return () => {\n for (const list of lists) list.removeEventListener('change', handler);\n };\n}\n","// Rim light (docs/reference.md §2): a hairline along the silhouette — \"not a band and not a\n// bevel\" — carrying two opposing arcs, the rest of it outlined by a thin dark line, and its colour\n// taken from the environment.\n//\n// Every number here is the lens shader's own. The key-light lobe is `lens-shader.ts` line 375\n// verbatim (exponent 3, opposing arc at 0.45), and the dark edge is its line 528 (a 0.22\n// darkening at the silhouette). The only thing that differs is the primitive: a conic gradient\n// sampled at fixed angles instead of a per-pixel normal.\nimport { RIM } from '../law';\nimport type { VireGlassOptics } from '../material';\n\nconst { lobeExponent: LOBE_EXPONENT, opposingArc: OPPOSING_ARC, darkEdge: DARK_EDGE } = RIM;\n\n/** One stop every 7.5°. Fine enough that a cubic lobe reads as a smooth arc rather than a fan. */\nconst STOPS = 48;\n\n/**\n * Screen space has y pointing down; a CSS conic gradient starts at 12 o'clock and runs clockwise.\n * A point at conic angle φ therefore has outward normal `(sin φ, -cos φ)`, which is what the lobe\n * is measured against.\n */\nexport function lightConicAngle(light: readonly [number, number]): number {\n const [lx, ly] = light;\n const deg = (Math.atan2(lx, -ly) * 180) / Math.PI;\n return (deg + 360) % 360;\n}\n\n/** The shader's key-light lobe, evaluated for a rim point whose normal sits `deltaDeg` away from\n * the light. Both arcs come out of this one expression — that is why they are opposed. */\nexport function rimLobe(deltaDeg: number, specular: number): number {\n const facing = Math.cos((deltaDeg * Math.PI) / 180);\n const front = facing > 0 ? Math.pow(facing, LOBE_EXPONENT) : 0;\n const back = facing < 0 ? Math.pow(-facing, LOBE_EXPONENT) : 0;\n return specular * (front + OPPOSING_ARC * back);\n}\n\nconst clamp01 = (v: number) => (v < 0 ? 0 : v > 1 ? 1 : v);\nconst to255 = (v: number) => Math.round(clamp01(v) * 255);\n\nexport type RimAmbient = readonly [number, number, number];\n\n/**\n * The gradient for the hairline. Colour comes from the environment — \"over a yellow flower the rim\n * is yellow, over sky it is blue\" (§2) — lifted toward white where the key light lands. Away from\n * both arcs only the dark edge remains.\n *\n * The opposing arc carries an iridescent fringe (§2), so `iridescence` pulls its channels apart\n * rather than lifting them together.\n */\nexport function rimGradientCss(\n optics: VireGlassOptics,\n ambient: RimAmbient,\n light: readonly [number, number],\n appear = 1,\n): string {\n const present = clamp01(appear);\n const start = lightConicAngle(light);\n const [ar, ag, ab] = ambient;\n const stops: string[] = [];\n\n for (let i = 0; i <= STOPS; i += 1) {\n const angle = (i / STOPS) * 360;\n const key = rimLobe(angle, optics.specular);\n const facing = Math.cos((angle * Math.PI) / 180);\n // The far arc is where dispersion shows as a fringe; the near one is a clean specular.\n const fringe = facing < 0 ? optics.iridescence * OPPOSING_ARC : 0;\n const lift = clamp01(key * optics.fresnel);\n\n const r = ar + (1 - ar) * clamp01(lift + fringe);\n const g = ag + (1 - ag) * lift;\n const b = ab + (1 - ab) * clamp01(lift - fringe);\n\n // Scaled, not floored: the dark edge is the one part of the rim that survives facing away from\n // the light, so leaving it unscaled leaves a hairline drawn around an element that is not there.\n const alpha = clamp01(DARK_EDGE + lift * (1 - DARK_EDGE)) * present;\n // Below the arcs the line is the dark edge itself, not a dim copy of the environment.\n const colour = lift > 0.001\n ? `rgba(${to255(r)},${to255(g)},${to255(b)},${alpha.toFixed(3)})`\n : `rgba(0,0,0,${alpha.toFixed(3)})`;\n stops.push(`${colour} ${angle.toFixed(1)}deg`);\n }\n\n return `conic-gradient(from ${start.toFixed(1)}deg, ${stops.join(', ')})`;\n}\n\nexport const RIM_WIDTH_PX = RIM.widthPx;\n\n/**\n * The border for increased contrast (§9: elements become \"predominantly black or white\" and are\n * highlighted \"with a contrasting border\").\n *\n * Not a gradient: the two arcs above are a light source reflecting off a curved edge, and under\n * this setting the edge is not reporting where the light is, it is separating the element from\n * everything around it. It has to hold at every angle, including the one facing away from the key\n * light where the ordinary rim falls back to a dim dark line.\n */\nexport function contrastRimCss(bodyLuma: number, rimLuma: number): string {\n const v = to255(rimLuma);\n // Opaque on purpose. A border that lets the backdrop through is the thing this setting exists\n // to replace, and the body behind it is already at its own pole.\n void bodyLuma;\n return `conic-gradient(rgb(${v},${v},${v}) 0deg, rgb(${v},${v},${v}) 360deg)`;\n}\n","// Glass inside glass (docs/reference.md §6). 219 @11:50 puts it among the principles: \"avoid\n// putting [glass] within or on top of other glass elements to maintain hierarchy and prevent\n// clutter.\" S 32:54 (\"Building CNN for iOS 26\") is the same rule reported from the other side, by a\n// team that had already shipped it: \"Applying the glass effect to both a parent and child views led to visual redundancy.\n// Double translucency, layered blur, and unpredictable rendering.\"\n//\n// On this renderer it is not only a matter of hierarchy. `backdrop-filter` samples what is already\n// composited behind the element, so a nested pane's backdrop is the outer pane's OUTPUT: the\n// displacement is applied twice to the same pixels and the two blurs multiply. The inner element\n// does not look like thicker glass, it looks like a mistake.\n//\n// Overlap is a different case and not this function's business — a sheet over a bar is two panes in\n// the stacking order, which is what two panes of glass actually do. Only containment is wrong.\nconst WARNED = new WeakSet<Element>();\n\n/** Set by `attachGlass`; exported so the check does not have to know the attribute's spelling. */\nexport const GLASS_ATTR = 'data-vireglass';\n\nexport function warnIfNested(el: Element): void {\n if (WARNED.has(el)) return;\n const outer = el.parentElement?.closest(`[${GLASS_ATTR}]`);\n if (!outer) return;\n WARNED.add(el);\n // Warned, not refused: where an element sits is the host's layout, and a library that silently\n // declines to render is harder to debug than one that says what is wrong.\n const where = outer.tagName.toLowerCase() + (outer.id ? `#${outer.id}` : '');\n console.warn(\n `vireglass: glass inside glass — this element is a descendant of <${where}>, which is also glass. ` +\n `Its backdrop is the outer element's output, so the refraction is applied twice and the blurs ` +\n `multiply. Put the glass on one of the two.`,\n );\n}\n","// The scroll edge (docs/reference.md §10). Not the material's job but the SCREEN's: it sits over\n// the content beneath a panel, and the glass sees a backdrop that is already dimmed. The rules are\n// the core's (`../scroll-edge`); this attaches them to a real scroller and a real element.\nimport { SCROLL_EDGE } from '../law';\nimport { scrollEdgeStrength, scrollEdgeStyle, type ScrollEdgeStyle } from '../scroll-edge';\n\nexport type ScrollEdgeHandle = { update(): void; destroy(): void };\n\nexport type ScrollEdgeOptions = {\n /** Which edge of the scroller the panel sits at. */\n side?: 'top' | 'bottom';\n /** A view pinned under the panel — column headers — gets a flat band with no gradient (§10). */\n pinned?: boolean;\n /** Ink polarity of the nearest glass, 1 light and 0 dark. The edge style follows it: light ink\n * means dark glass and the content fades into a light dimming; dark ink means the opposite. */\n ink?: () => number;\n};\n\n/**\n * What the effect actually is. 356 @11:32: \"they don't block or darken like overlays.\"\n *\n * So the soft style is a BLUR with a mask, not a painted gradient: the content under the panel\n * goes out of focus into the background, which is what 219 @9:16 means by dissolving it, and\n * nothing is laid over it. The first version of this painted black at 22% down the ramp — an\n * overlay, doing the one thing the reference names as wrong.\n *\n * `dim` is the other soft form and it does carry a tone, because 219 @9:33 asks for one: over dark\n * content the glass turns dark and \"the effect intelligently switches to apply a subtle dimming\n * instead\". Dimming is a reduction in luminance. This painted white, which lightened the content\n * it was supposed to be pushing down.\n */\nexport type EdgePaint = { filter: string; mask: string; tone: string };\n\nexport function paintFor(style: ScrollEdgeStyle, side: 'top' | 'bottom'): EdgePaint {\n const direction = side === 'top' ? 'to top' : 'to bottom';\n if (style === 'hard') {\n // A flat band rather than a gradual fade (219 @9:41), and a stronger boundary (356 @12:12).\n return {\n filter: `blur(${SCROLL_EDGE.hardBlurDp}px)`,\n mask: '',\n tone: `linear-gradient(${direction}, rgba(0,0,0,${SCROLL_EDGE.hardAlpha}) 0 100%)`,\n };\n }\n const ramp = `linear-gradient(${direction}, rgba(0,0,0,1) 0%, rgba(0,0,0,0) 100%)`;\n return {\n filter: `blur(${SCROLL_EDGE.dissolveBlurDp}px)`,\n mask: ramp,\n tone:\n style === 'dim'\n ? `linear-gradient(${direction}, rgba(0,0,0,${SCROLL_EDGE.dimAlpha}) 0%, rgba(0,0,0,0) 100%)`\n : 'none',\n };\n}\n\n/**\n * Paints the edge onto `edgeEl` — an element the host positions along the scroller's edge, under\n * the glass. It is the host's because §10 puts this on the screen, not on the material: the glass\n * must SEE the result, which means the effect has to be behind it in the stack.\n */\nexport function attachScrollEdge(\n scroller: HTMLElement,\n edgeEl: HTMLElement,\n opts: ScrollEdgeOptions = {},\n): ScrollEdgeHandle {\n const side = opts.side ?? 'top';\n let destroyed = false;\n\n function update(): void {\n if (destroyed) return;\n const maxScroll = Math.max(scroller.scrollHeight - scroller.clientHeight, 0);\n const strength = scrollEdgeStrength(side, scroller.scrollTop, maxScroll);\n const inkLight = (opts.ink?.() ?? 1) > 0.5;\n const style = scrollEdgeStyle(inkLight, opts.pinned);\n const paint = paintFor(style, side);\n // The blur is what dissolves the content; the mask is what makes it a ramp rather than a step.\n edgeEl.style.setProperty('backdrop-filter', paint.filter);\n edgeEl.style.setProperty('-webkit-backdrop-filter', paint.filter);\n if (paint.mask) {\n edgeEl.style.setProperty('mask-image', paint.mask);\n edgeEl.style.setProperty('-webkit-mask-image', paint.mask);\n } else {\n edgeEl.style.removeProperty('mask-image');\n edgeEl.style.removeProperty('-webkit-mask-image');\n }\n edgeEl.style.setProperty('background-image', paint.tone);\n edgeEl.style.setProperty('opacity', strength.toFixed(3));\n }\n\n const onScroll = () => update();\n scroller.addEventListener('scroll', onScroll, { passive: true });\n update();\n\n return {\n update,\n destroy() {\n destroyed = true;\n scroller.removeEventListener('scroll', onScroll);\n edgeEl.style.removeProperty('backdrop-filter');\n edgeEl.style.removeProperty('-webkit-backdrop-filter');\n edgeEl.style.removeProperty('mask-image');\n edgeEl.style.removeProperty('-webkit-mask-image');\n edgeEl.style.removeProperty('background-image');\n edgeEl.style.removeProperty('opacity');\n },\n };\n}\n","// A row of glass that agrees with itself.\n//\n// Each element probing on its own is not merely wasteful — it is wrong. Neighbouring pieces of one\n// control sit over slightly different patches of backdrop, reach different polarities, and a tab\n// bar ends up with two light glyphs and two dark ones. §3 is explicit that small elements switch\n// WHOLESALE; a group is what \"wholesale\" means when the element is really four of them.\n//\n// Every decision is the core's (`../group-model`): the lightness plane, the smoothing, the polarity\n// requirement and its hysteresis. This binds them to real elements.\nimport { createGroupState, type GroupPlane } from '../group-model';\nimport { TOUCH } from '../law';\nimport { probeBackdrop } from './probe';\nimport type { BackdropSample } from '../adaptation';\nimport type { GlassHandle } from './index';\n\nexport type GroupEntry = {\n el: HTMLElement;\n handle: GlassHandle;\n /** Set by the group: pass it to this member's own `attachGlass` as `onGlow`. */\n onGlow?: (glow: { pageX: number; pageY: number; strength: number } | null) => void;\n /** How strongly this member needs its ink to stay legible. The strictest in the group wins. */\n legibility?: number;\n};\n\nexport type GlassGroupHandle = {\n /** Re-read every member and settle on one answer for all of them. */\n update(): void;\n /** The polarity the whole group agreed on, 1 light and 0 dark. */\n ink(): number;\n /** The group's current estimate, or null before the first reading. */\n plane(): GroupPlane | null;\n /** Spread a glow from one member to the rest. Members wired through `onGlow` call this for you. */\n carryGlow(from: number, glow: { pageX: number; pageY: number; strength: number } | null): void;\n destroy(): void;\n};\n\nexport type GlassGroupOptions = {\n /** Where a member reads its backdrop. Defaults to the DOM probe. */\n probe?: (el: HTMLElement) => BackdropSample;\n};\n\nexport function createGlassGroup(\n members: readonly GroupEntry[],\n opts: GlassGroupOptions = {},\n): GlassGroupHandle {\n let polarity = 1;\n let destroyed = false;\n\n const state = createGroupState({\n plane: () => {},\n flip: (next) => {\n polarity = next;\n // One flip, everyone at once — that is the whole point of the group.\n for (const { handle } of members) handle.update();\n },\n });\n\n /**\n * \"Starting right under your fingertips, the glow spreads throughout the element and onto any\n * Liquid Glass elements nearby\" (§5, 219 @12:11). The element being touched cannot know who is\n * nearby; the group does.\n */\n function carryGlow(from: number, glow: { pageX: number; pageY: number; strength: number } | null): void {\n members.forEach(({ el, handle }, index) => {\n if (index === from) return;\n if (!glow) {\n handle.setNeighbourGlow(null);\n return;\n }\n const rect = el.getBoundingClientRect();\n const cx = rect.left + rect.width / 2;\n const cy = rect.top + rect.height / 2;\n const reach = (Math.min(rect.width, rect.height) / 2) * TOUCH.glowReach;\n const distance = Math.hypot(glow.pageX - cx, glow.pageY - cy);\n // Falls off with distance and stops: a glow that reached the whole screen would read as the\n // page flashing rather than as light travelling through neighbouring glass.\n const falloff = reach > 0 ? Math.max(0, 1 - distance / reach) : 0;\n handle.setNeighbourGlow(falloff <= 0 ? null : { ...glow, strength: glow.strength * falloff });\n });\n }\n\n /** Wire each member's own touch to the rest of the group. */\n function connect(): void {\n members.forEach((entry, index) => {\n entry.onGlow = (glow) => carryGlow(index, glow);\n });\n }\n\n function update(): void {\n if (destroyed) return;\n const probe = opts.probe ?? probeBackdrop;\n members.forEach(({ el, legibility }, index) => {\n const rect = el.getBoundingClientRect();\n // A member with no box has nothing behind it to read; reporting it anyway would drag the\n // group's estimate toward whatever sits at the page's origin.\n if (rect.width <= 0 || rect.height <= 0) {\n state.release(String(index));\n return;\n }\n state.report(\n String(index),\n rect.left + rect.width / 2,\n rect.top + rect.height / 2,\n probe(el),\n legibility ?? 0,\n );\n });\n }\n\n connect();\n update();\n\n return {\n update,\n ink: () => polarity,\n plane: () => state.plane(),\n carryGlow,\n destroy() {\n destroyed = true;\n carryGlow(-1, null);\n members.forEach((_, index) => state.release(String(index)));\n },\n };\n}\n","// The third VireGlass renderer: refracts LIVE DOM via `backdrop-filter: url(#svg-filter)` with an\n// `feDisplacementMap`, instead of drawing its own backdrop like the WebGL2 and AGSL renderers do.\n//\n// Everything is derived from the same model the shaders read, and where a law already exists in\n// the core or in the shader text, this mirrors it rather than restating it: the rim's two arcs are\n// the lens's own key-light lobe, the shadow is `shadowOpacityFrom`, dispersion is the shader's\n// per-channel index shift, and the finger response is `createDeform` driving the same `touchWarp`.\n//\n// Even the spectral edge, which looked impossible: a filter graph cannot evaluate a function per\n// pixel, but it can MULTIPLY by an image, so diffraction and interference are baked into one and\n// applied with an arithmetic composite.\n// See `docs/superpowers/specs/2026-09-19-vireglass-over-live-dom.md` for the technique and the\n// three findings that make it work (objectBoundingBox, prefiltering the source, the 8-bit step).\nimport { ambientFrom, INK_DARK, INK_LIGHT, shouldInkBeLight, type BackdropSample } from '../adaptation';\nimport { buildDisplacementMap } from './displacement';\nimport { buildSpectralMap, hasSpectralEdge, type SpectralMap } from './spectral-map';\nimport { cached } from './map-cache';\nimport { roundedRectGeometry, type VireGlassGeometry } from '../geometry';\nimport { resolveOptics, VIREGLASS_MATERIAL, type VireGlassMaterial, type VireGlassOptics } from '../material';\nimport { probeBackdrop } from './probe';\nimport { supportsSvgBackdropFilter } from './support';\nimport { boxShadowCss } from './shadow';\nimport { resolveBody, withPresence } from './body';\nimport { systemAccessibility, watchAccessibility } from './preferences';\nimport { applyAccessibility, contrastRimLuma, elasticAllowed, type VireGlassAccessibility } from '../accessibility';\nimport { applyGlassScale, GLASS_SCALE_DEFAULT } from '../glass-scale';\nimport { applyAppear } from '../appear';\nimport { accentAmount, accentTone } from '../accent';\nimport type { VireGlassAccent } from '../adapters';\nimport { concentricRadius } from '../concentric';\nimport { RIM_WIDTH_PX, contrastRimCss, rimGradientCss } from './rim';\nimport { GLASS_ATTR, warnIfNested } from './nesting';\nimport { REST_LIGHT } from '../adapters';\nimport { refractionStrength } from '../optics';\nimport { DISPERSION, TOUCH } from '../law';\nimport type { MorphShape } from '../sdf';\nimport { createDeform, raiseIntoGlass, type DeformSample } from '../touch-response';\nimport { halfMinDp, MAX_STRETCH } from '../geometry';\n\nexport * from './support';\nexport * from './probe';\nexport * from './displacement';\nexport * from './rim';\nexport * from './shadow';\nexport * from './body';\nexport * from './preferences';\nexport * from './scroll-edge';\nexport * from './group';\nexport * from './spectral-map';\nexport * from './map-cache';\n\nconst SVG_NS = 'http://www.w3.org/2000/svg';\nconst FILTER_HOST_ATTR = 'data-vireglass-filters';\n\nlet filterCounter = 0;\n\n/** Live instances keyed by element, so a second attach can retire the first rather than orphan\n * its filter. Weak: a detached element takes its entry with it. */\nconst attached = new WeakMap<HTMLElement, GlassHandle>();\n\nconst TOUCH_RADIUS_FRACTION = TOUCH.radiusOfHalfSize;\n\nconst WAVE_OF_TRAVEL = TOUCH.waveOfTravel;\nconst RELEASE_WAVE = TOUCH.releaseWave;\n\nfunction waveImpulse(g: VireGlassGeometry): number {\n return halfMinDp(g) * MAX_STRETCH * WAVE_OF_TRAVEL;\n}\n\nconst STYLE_ATTR = 'data-vireglass-styles';\n\n\n/**\n * The hairline rim (docs/reference.md §2) needs a layer of its own over the element. A stylesheet\n * rule on `::after` keeps it out of the host's markup — injecting a child node would fight any\n * framework that owns these children.\n *\n * The mask pair is what makes it a ring rather than a fill: the same box painted twice, once\n * clipped to the content box, composited so only the padding band survives.\n */\nfunction ensureRimStyles(): void {\n if (document.querySelector(`style[${STYLE_ATTR}]`)) return;\n const style = document.createElement('style');\n style.setAttribute(STYLE_ATTR, '');\n style.textContent =\n `[${GLASS_ATTR}]::after{content:'';position:absolute;inset:0;border-radius:inherit;pointer-events:none;padding:var(--vireglass-rim-width,1px);background:var(--vireglass-rim,none);-webkit-mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);-webkit-mask-composite:xor;mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);mask-composite:exclude}` +\n // The touch glow (§5) lights the material from the point of contact. Below the content, above\n // the refraction — it is light inside the glass, not a film over the label.\n `[${GLASS_ATTR}]::before{content:'';position:absolute;inset:0;border-radius:inherit;pointer-events:none;background:var(--vireglass-glow,none);opacity:var(--vireglass-glow-opacity,0)}`;\n document.head.appendChild(style);\n}\n\nfunction getFilterHost(): SVGSVGElement {\n const existing = document.querySelector<SVGSVGElement>(`svg[${FILTER_HOST_ATTR}]`);\n if (existing) return existing;\n const svg = document.createElementNS(SVG_NS, 'svg');\n svg.setAttribute(FILTER_HOST_ATTR, '');\n svg.setAttribute('width', '0');\n svg.setAttribute('height', '0');\n svg.setAttribute('aria-hidden', 'true');\n svg.style.position = 'absolute';\n svg.style.pointerEvents = 'none';\n svg.appendChild(document.createElementNS(SVG_NS, 'defs'));\n document.body.appendChild(svg);\n return svg;\n}\n\n/**\n * Finding #1 (do not re-litigate): `objectBoundingBox` with an explicit unit box. `userSpaceOnUse`\n * measures from something other than the element's own box and the displacement smears across\n * the page instead of staying at the rim.\n */\nfunction buildFilterElement(\n id: string,\n mapUrl: string,\n optics: VireGlassOptics,\n scale: number,\n spectral: SpectralMap | null,\n): SVGFilterElement {\n const filter = document.createElementNS(SVG_NS, 'filter');\n filter.setAttribute('id', id);\n filter.setAttribute('filterUnits', 'objectBoundingBox');\n filter.setAttribute('x', '0');\n filter.setAttribute('y', '0');\n filter.setAttribute('width', '1');\n filter.setAttribute('height', '1');\n // Without this the spec's default is linearRGB: the browser gamma-linearises the map's bytes\n // before reading them, so 128 stops meaning \"no shift\" and the flat middle of the glass drifts\n // by several pixels. Measured at ~57px of spurious displacement at scale 200.\n filter.setAttribute('color-interpolation-filters', 'sRGB');\n\n const feImage = document.createElementNS(SVG_NS, 'feImage');\n feImage.setAttribute('href', mapUrl);\n feImage.setAttribute('preserveAspectRatio', 'none');\n feImage.setAttribute('result', 'map');\n\n // Finding #2: prefiltering the source before displacement. This is `roughness`, not a hack —\n // without it, fine texture (1px diagonals) resamples into chevrons under the displacement.\n const feBlur = document.createElementNS(SVG_NS, 'feGaussianBlur');\n feBlur.setAttribute('in', 'SourceGraphic');\n feBlur.setAttribute('stdDeviation', String(Math.max(optics.blur, 0)));\n feBlur.setAttribute('result', 'blurred');\n\n filter.append(feImage, feBlur);\n\n // DISPERSION (docs/reference.md §1, and `lens-shader.ts` lines 283–284 for the law): the channels\n // refract at different indices — red at `ior - 0.4 * iorSpread`, blue at `ior + 0.6 * iorSpread`,\n // green at the base. One displacement pass cannot do that, so each channel gets its own and they\n // are summed back. Three passes instead of one, so it only runs when the spread is worth paying\n // for.\n const spread = optics.iorSpread;\n if (spread > 1e-4) {\n const base = refractionStrength(optics.ior);\n const ratio = (shift: number) => (base > 0 ? refractionStrength(optics.ior + shift) / base : 1);\n const channels: Array<[string, number, string]> = [\n ['dR', scale * ratio(DISPERSION.redShift * spread), '1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0'],\n ['dG', scale, '0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0'],\n ['dB', scale * ratio(DISPERSION.blueShift * spread), '0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0'],\n ];\n for (const [name, chScale, matrix] of channels) {\n const pass = document.createElementNS(SVG_NS, 'feDisplacementMap');\n pass.setAttribute('in', 'blurred');\n pass.setAttribute('in2', 'map');\n pass.setAttribute('scale', String(chScale));\n pass.setAttribute('xChannelSelector', 'R');\n pass.setAttribute('yChannelSelector', 'G');\n pass.setAttribute('result', `${name}raw`);\n const only = document.createElementNS(SVG_NS, 'feColorMatrix');\n only.setAttribute('in', `${name}raw`);\n only.setAttribute('type', 'matrix');\n only.setAttribute('values', matrix);\n only.setAttribute('result', name);\n filter.append(pass, only);\n }\n // Arithmetic add, not a blend: every channel is isolated, so the sum is the recombined colour.\n // Alpha stays at 1 on all three and clamps, which is what an opaque backdrop wants.\n const rg = document.createElementNS(SVG_NS, 'feComposite');\n rg.setAttribute('in', 'dR');\n rg.setAttribute('in2', 'dG');\n rg.setAttribute('operator', 'arithmetic');\n rg.setAttribute('k1', '0');\n rg.setAttribute('k2', '1');\n rg.setAttribute('k3', '1');\n rg.setAttribute('k4', '0');\n rg.setAttribute('result', 'dRG');\n const rgb = document.createElementNS(SVG_NS, 'feComposite');\n rgb.setAttribute('in', 'dRG');\n rgb.setAttribute('in2', 'dB');\n rgb.setAttribute('operator', 'arithmetic');\n rgb.setAttribute('k1', '0');\n rgb.setAttribute('k2', '1');\n rgb.setAttribute('k3', '1');\n rgb.setAttribute('k4', '0');\n rgb.setAttribute('result', 'refracted');\n filter.append(rg, rgb);\n return withSpectral(filter, spectral);\n }\n\n const feDisplace = document.createElementNS(SVG_NS, 'feDisplacementMap');\n feDisplace.setAttribute('in', 'blurred');\n feDisplace.setAttribute('in2', 'map');\n feDisplace.setAttribute('scale', String(scale));\n feDisplace.setAttribute('xChannelSelector', 'R');\n feDisplace.setAttribute('yChannelSelector', 'G');\n feDisplace.setAttribute('result', 'refracted');\n filter.append(feDisplace);\n return withSpectral(filter, spectral);\n}\n\n/**\n * Multiplies the refracted frame by the baked hue (docs/reference.md §1). `feComposite` in\n * arithmetic mode with `k1` is a per-pixel product, which is the only way a filter graph can apply\n * a function of position. The headroom the bake divided by is multiplied back here.\n */\nfunction withSpectral(filter: SVGFilterElement, spectral: SpectralMap | null): SVGFilterElement {\n if (!spectral) return filter;\n const image = document.createElementNS(SVG_NS, 'feImage');\n image.setAttribute('href', spectral.url);\n image.setAttribute('preserveAspectRatio', 'none');\n image.setAttribute('result', 'hue');\n const product = document.createElementNS(SVG_NS, 'feComposite');\n product.setAttribute('in', 'refracted');\n product.setAttribute('in2', 'hue');\n product.setAttribute('operator', 'arithmetic');\n product.setAttribute('k1', String(spectral.headroom));\n product.setAttribute('k2', '0');\n product.setAttribute('k3', '0');\n product.setAttribute('k4', '0');\n filter.append(image, product);\n return filter;\n}\n\nfunction measureGeometry(el: HTMLElement): VireGlassGeometry {\n const rect = el.getBoundingClientRect();\n // Uniform corner radius only, matching `VireGlassGeometry` itself — a per-corner or elliptical\n // radius isn't modeled by any renderer in this package.\n const radius = parseFloat(getComputedStyle(el).borderTopLeftRadius) || 0;\n return roundedRectGeometry(rect.width, rect.height, radius);\n}\n\nfunction devicePixelRatio(): number {\n return typeof window !== 'undefined' && window.devicePixelRatio ? window.devicePixelRatio : 1;\n}\n\n/**\n * No SVG filter reference support (Firefox, older Safari): a real path, not a stub — the Android\n * renderer degrades to an affine magnifier below API 33 and that's documented as normal too. Blur\n * and saturation stand in for refraction's optical effect; the tint carries what refraction can't:\n * a body of glass, not just a smudge over whatever's behind it.\n */\nfunction fallbackFilterCss(optics: VireGlassOptics): string {\n const blurPx = Math.max(optics.blur, 1.5);\n const saturate = 1 + optics.colorPickup;\n return `blur(${blurPx}px) saturate(${saturate})`;\n}\n\nconst to255 = (v: number) => Math.round(Math.min(Math.max(v, 0), 1) * 255);\n\nfunction rgbCss(r: number, g: number, b: number): string {\n return `rgb(${to255(r)} ${to255(g)} ${to255(b)})`;\n}\n\n/**\n * The body, from the model's own law (`./body`, ported from the lens shader §3): density is what\n * legibility and presence demand over THIS backdrop, `tintLuma` is the lightness it tints toward,\n * and the hue is the surroundings' — glass has no colour of its own, only the colour of what lies\n * beneath it. A flat fill in place of a tint is what breaks the material.\n */\nfunction bodyCss(\n optics: VireGlassOptics,\n sample: BackdropSample,\n ink: number,\n accent?: VireGlassAccent,\n): string {\n const body = withPresence(resolveBody(optics, sample, ink), optics, sample);\n\n // A tinted element takes its colour from the accent rather than from its surroundings, but it is\n // still the MEDIUM that is coloured: the amount stays short of one so the content keeps coming\n // through. A fill at full opacity is the thing §7 says breaks the material.\n if (accent) {\n const [r, g, b] = accentTone(accent.color, sample.luma);\n const amount = Math.max(accentAmount(accent), body.density);\n return `rgba(${to255(r)}, ${to255(g)}, ${to255(b)}, ${amount.toFixed(3)})`;\n }\n\n const [r, g, b] = ambientFrom(sample);\n const hue = (c: number) => body.tintLuma + (c - body.tintLuma) * optics.colorPickup;\n return `rgba(${to255(hue(r))}, ${to255(hue(g))}, ${to255(hue(b))}, ${body.density.toFixed(3)})`;\n}\n\nexport type AttachGlassOptions = {\n material?: Partial<VireGlassMaterial>;\n /** Defaults to the element's measured box (size + `border-radius`). */\n geometry?: VireGlassGeometry;\n /** Key-light direction in screen space; defaults to the light at rest. */\n light?: readonly [number, number];\n /** Whether `attachGlass` writes `box-shadow` itself. Turn it off if the host owns that property —\n * is always emitted either way. */\n shadow?: boolean;\n /**\n * The user's clear-to-tinted preference (§3). iOS 27 made it continuous and apps get it without\n * recompiling, so the material has to stay usable across the WHOLE range, not at one point.\n */\n scale?: number;\n /** System accessibility (§9). Read from the browser's own media queries unless supplied. */\n accessibility?: VireGlassAccessibility;\n /**\n * Tint for a primary action (§7). A colour that belongs to the medium, generating a range of\n * tones from the backdrop's brightness — not a fill. Use it on the one element that should stand\n * out: \"when every element is tinted, nothing stands out\" (219 @17:31).\n */\n accent?: VireGlassAccent;\n /** Initial presence, 0 to 1 (§1). Defaults to fully present. */\n appear?: number;\n /**\n * `'interactive'` is glass that is not there until it is touched (S 42:34, \"Building Tide Guide\"): \"this effect doesn't\n * change the appearance of a view until you interact with it... as you start sliding it, the\n * interactive effect adds a soft, subtle highlight\". The element carries no material at rest and\n * materialises under the finger — §1's materialising, driven by touch instead of by the host.\n *\n * It is what makes glass usable on a control that is not chrome: a slider thumb, a chart scrubber,\n * a card. Permanent glass there would be glass in the content layer, which §6 says to avoid.\n */\n variant?: 'present' | 'interactive';\n /** Called while this element is being touched, so a group can carry the glow to its neighbours\n * (§5). Wired for you by `createGlassGroup`. */\n onGlow?: (glow: { pageX: number; pageY: number; strength: number } | null) => void;\n /** Pointer response (§5). On by default. */\n interactive?: boolean;\n /** Overrides the probe entirely — images and video are invisible to it, and the host app\n * already knows its own cover-art accent. */\n sample?: BackdropSample;\n};\n\n/**\n * Shapes this element flows into (docs/reference.md §5): merging with a neighbour, or splitting\n * into parts across two bridges. Offsets and sizes are CSS px relative to this element's centre.\n *\n * `smoothing` is the width of the bridge — zero leaves the element alone. What each shape MEANS\n * (a menu growing out of its button, a control breaking into segments) is the host's choreography;\n * the material only knows how two silhouettes join.\n */\nexport type GlassMorph = {\n smoothing: number;\n shape?: MorphShape;\n shape2?: MorphShape;\n /**\n * Any number of shapes flowing into this one. Several independent elements becoming one whole is\n * the behaviour; how many of them there are is the host's business, and it used to be the\n * material's — the count lived in the field NAMES, so a fourth element had nowhere to go.\n *\n * `shape` and `shape2` still work and come first.\n */\n shapes?: readonly MorphShape[];\n};\n\nexport type GlassHandle = {\n update(): void;\n /**\n * How present the material is, 0 to 1 (docs/reference.md §1). Drive this to bring glass in and\n * out — NOT opacity. \"Instead of fading, Liquid Glass objects materialize in and out by\n * gradually modulating the light bending and lensing\" (219 @2:55). A faded element shows the\n * backdrop through a veil; one that is still arriving shows it undistorted.\n */\n setAppear(t: number): void;\n /** Tint the element, or clear it with null (§7). */\n setAccent(accent: VireGlassAccent | null): void;\n /** A glow that started on a neighbour, in page coordinates (§5). Null clears it. */\n setNeighbourGlow(glow: { pageX: number; pageY: number; strength: number } | null): void;\n setMorph(morph: GlassMorph | null): void;\n destroy(): void;\n};\n\nexport function attachGlass(el: HTMLElement, opts: AttachGlassOptions = {}): GlassHandle {\n if (typeof document === 'undefined') {\n throw new Error('vireglass/dom: attachGlass requires a browser DOM');\n }\n\n // One live instance per element. Re-attaching without destroying the previous handle used to\n // leave its filter in the shared <defs> forever, unreferenced, while the element quietly moved\n // to the new id.\n attached.get(el)?.destroy();\n\n const id = `vireglass-filter-${(filterCounter += 1)}`;\n const svgSupported = supportsSvgBackdropFilter();\n let wasLight = (opts.material?.ink ?? VIREGLASS_MATERIAL.ink) > 0.5;\n let filterEl: SVGFilterElement | null = null;\n let destroyed = false;\n let mapKey = '';\n let morph: GlassMorph | null = null;\n const onlyWhenTouched = opts.variant === 'interactive';\n let appear = onlyWhenTouched ? 0 : (opts.appear ?? 1);\n let accent = opts.accent;\n // Read once at attach, then followed: a setting turned on while the page is open has to reach\n // the material, not wait for a reload.\n let a11y = systemAccessibility();\n const stopWatchingA11y = watchAccessibility((next) => {\n a11y = next;\n mapKey = '';\n deform.setElastic(elasticAllowed(opts.accessibility ?? a11y));\n apply();\n });\n\n warnIfNested(el);\n\n ensureRimStyles();\n el.setAttribute(GLASS_ATTR, '');\n // `inset: 0` on the rim needs a positioned ancestor. Only taken over when the host left it at\n // the initial value, and put back on destroy.\n const positionWasStatic = getComputedStyle(el).position === 'static';\n if (positionWasStatic) el.style.setProperty('position', 'relative');\n\n /**\n * Causes to effects, then the user's scale, then accessibility — in that order. §9 is explicit\n * that a system setting outranks the material preset: even a transparent preset moves to the\n * edge of the scale under increased contrast, because the user needs contrast more than they\n * need the aesthetic.\n */\n function optics(patch?: Partial<VireGlassMaterial>): VireGlassOptics {\n const base = resolveOptics(patch ?? opts.material);\n const scaled = applyGlassScale(base, opts.scale ?? GLASS_SCALE_DEFAULT);\n const settled = applyAccessibility(scaled, opts.accessibility ?? a11y);\n // Appearance last, and by modulating the lens rather than by fading the element: §1 is\n // explicit that opacity is the wrong instrument for this.\n return applyAppear(settled, appear);\n }\n\n function morphState() {\n if (!morph) return {};\n return { smoothing: morph.smoothing, morph: morph.shape, morph2: morph.shape2, morphs: morph.shapes };\n }\n\n function morphKey(): string {\n if (!morph) return '0';\n const part = (s?: MorphShape) =>\n s ? `${s.offsetX},${s.offsetY},${s.width},${s.height},${s.cornerRadius}` : '-';\n return `${morph.smoothing}/${part(morph.shape)}/${part(morph.shape2)}`;\n }\n\n function apply(): void {\n if (destroyed) return;\n const geometry = opts.geometry ?? measureGeometry(el);\n const opticsNow = optics();\n const sample = opts.sample ?? probeBackdrop(el);\n\n if (svgSupported) {\n // The map depends only on geometry, optics and density — never on the backdrop. Rebuilding\n // it on every scroll would re-run a per-pixel loop and a PNG encode for a picture that did\n // not change; the refraction itself updates in the compositor with no JS at all.\n const key = `a${appear.toFixed(3)}|m${morphKey()}|${geometry.width}x${geometry.height}r${geometry.cornerRadius}@${devicePixelRatio()}:${opticsNow.refraction}:${opticsNow.refractionScale}:${opticsNow.bevelDp}:${opticsNow.blur}`;\n if (key !== mapKey || !filterEl) {\n // Keyed by exactly what the maps are functions of, which is exactly the cache key above.\n const map = cached(`d|${key}`, () => buildDisplacementMap(opticsNow, geometry, devicePixelRatio(), morphState()));\n const defs = getFilterHost().querySelector('defs') as SVGDefsElement;\n const hue = hasSpectralEdge(opticsNow)\n ? cached(`h|${key}`, () => buildSpectralMap(opticsNow, geometry, devicePixelRatio()))\n : null;\n const next = buildFilterElement(id, map.url, opticsNow, map.scale, hue);\n if (filterEl?.parentNode) defs.replaceChild(next, filterEl);\n else defs.appendChild(next);\n filterEl = next;\n mapKey = key;\n }\n el.style.setProperty('backdrop-filter', `url(#${id})`);\n el.style.setProperty('-webkit-backdrop-filter', `url(#${id})`);\n } else {\n el.style.setProperty('backdrop-filter', fallbackFilterCss(opticsNow));\n el.style.setProperty('-webkit-backdrop-filter', fallbackFilterCss(opticsNow));\n el.style.backgroundColor = bodyCss(opticsNow, sample, wasLight ? 1 : 0, accent);\n }\n\n const light = shouldInkBeLight(sample, wasLight);\n wasLight = light;\n const [tr, tg, tb] = ambientFrom(sample);\n el.style.setProperty('--vireglass-ink', light ? '1' : '0');\n el.style.setProperty('--vireglass-tint', `${tr} ${tg} ${tb}`);\n el.style.setProperty('--vireglass-body-density', String(opticsNow.bodyDensity));\n\n // The raw numbers above are the model's own values; these are the same thing in a form CSS\n // can actually consume. Without them a host has to convert in script, which is the work this\n // renderer exists to do.\n const inkLevel = Math.round((light ? INK_LIGHT : INK_DARK) * 255);\n el.style.setProperty('--vireglass-ink-color', `rgb(${inkLevel} ${inkLevel} ${inkLevel})`);\n el.style.setProperty('--vireglass-tint-color', rgbCss(tr, tg, tb));\n el.style.setProperty('--vireglass-body-color', bodyCss(opticsNow, sample, light ? 1 : 0, accent));\n\n // Rim and shadow follow the SAMPLE, not just the geometry, so they sit outside the map's\n // cache key: the environment they take their colour and density from moves under a scroll\n // while the silhouette does not.\n // §9: under increased contrast the hairline stops reporting where the light is and starts\n // separating the element from what is behind it, so it is measured from the body, not the\n // environment.\n const pole = withPresence(resolveBody(opticsNow, sample, light ? 1 : 0), opticsNow, sample).tintLuma;\n el.style.setProperty(\n '--vireglass-rim',\n (opts.accessibility ?? a11y).increaseContrast\n ? contrastRimCss(pole, contrastRimLuma(pole))\n : rimGradientCss(opticsNow, [tr, tg, tb], opts.light ?? REST_LIGHT, appear),\n );\n el.style.setProperty('--vireglass-rim-width', `${RIM_WIDTH_PX}px`);\n\n // §11: a rounded child inside glass has to be concentric with it, or the two curves fight.\n // Emitted rather than applied — the inset is the host's, and CSS can do the arithmetic.\n el.style.setProperty('--vireglass-radius', `${geometry.cornerRadius}px`);\n el.style.setProperty('--vireglass-radius-min', `${concentricRadius(geometry.cornerRadius, geometry.cornerRadius, 0)}px`);\n\n const shadow = boxShadowCss(geometry, sample, appear);\n el.style.setProperty('--vireglass-shadow', shadow);\n if (opts.shadow !== false) el.style.setProperty('box-shadow', shadow);\n }\n\n apply();\n\n // INTERACTION (docs/reference.md §5). The physics is the core's — `createDeform` carries the\n // spring, the press attack and the wave, at its own fixed step. What lives here is only the\n // plumbing: pointer in, map and glow out.\n const deform = createDeform({ elastic: elasticAllowed(opts.accessibility ?? a11y) });\n let frame: number | null = null;\n let lastFrameAt = 0;\n let interacting = false;\n\n function localPoint(e: PointerEvent): [number, number] {\n const rect = el.getBoundingClientRect();\n return [e.clientX - rect.left - rect.width / 2, e.clientY - rect.top - rect.height / 2];\n }\n\n function paintInteraction(sampleOut: DeformSample): void {\n const geometry = opts.geometry ?? measureGeometry(el);\n const base = optics();\n // Under the finger a matte control stops being frosted and becomes a lens (§5, M 4:10–4:30).\n const rise = raiseIntoGlass(sampleOut.press);\n // The same chain as at rest — the user's scale and the system's settings do not stop\n // applying because a finger is down.\n const risen = optics({ ...opts.material, roughness: (opts.material?.roughness ?? VIREGLASS_MATERIAL.roughness) * rise.solid });\n\n // A reduced-resolution map while the finger is down: `feImage` stretches it over the element\n // regardless, the displacement is smooth, and a full device-pixel rebuild plus a PNG encode\n // every frame does not hold a frame budget.\n const map = buildDisplacementMap(risen, geometry, interacting ? 1 : devicePixelRatio(), {\n ...morphState(),\n touch: {\n x: sampleOut.touchX,\n y: sampleOut.touchY,\n pullX: sampleOut.pullX,\n pullY: sampleOut.pullY,\n press: sampleOut.press,\n radius: halfMinDp(geometry) * TOUCH_RADIUS_FRACTION,\n waveAmp: sampleOut.waveAmp,\n wavePhase: sampleOut.wavePhase,\n },\n });\n if (filterEl) {\n const feImage = filterEl.querySelector('feImage');\n const feDisplace = filterEl.querySelector('feDisplacementMap');\n feImage?.setAttribute('href', map.url);\n feDisplace?.setAttribute('scale', String(map.scale));\n }\n mapKey = '';\n\n paintGlow(sampleOut.touchX, sampleOut.touchY, sampleOut.active * base.edgeLight, geometry);\n\n // \"the glow spreads throughout the element and onto any Liquid Glass elements NEARBY\" (§5,\n // 219 @12:11). This element cannot know who is nearby; the group does, so it is told.\n const rect = el.getBoundingClientRect();\n opts.onGlow?.({\n pageX: rect.left + rect.width / 2 + sampleOut.touchX,\n pageY: rect.top + rect.height / 2 + sampleOut.touchY,\n strength: sampleOut.active,\n });\n }\n\n /**\n * The glow is a CONCENTRATION of the surroundings, not the glass's own whiteness: over a dark\n * backdrop the element lightens but never turns white, and ink over it stays legible.\n *\n * `x` and `y` are relative to the element's centre and may fall outside it — a glow that started\n * next door still has a direction, and dropping it to the centre would make a neighbour brighten\n * uniformly rather than from the side the finger is on.\n */\n function paintGlow(x: number, y: number, strength: number, geometry: VireGlassGeometry): void {\n if (strength <= 0.001) {\n el.style.setProperty('--vireglass-glow-opacity', '0');\n return;\n }\n const [gr, gg, gb] = ambientFrom(opts.sample ?? probeBackdrop(el));\n const cx = ((x + geometry.width / 2) / geometry.width) * 100;\n const cy = ((y + geometry.height / 2) / geometry.height) * 100;\n const reach = halfMinDp(geometry) * TOUCH_RADIUS_FRACTION;\n el.style.setProperty(\n '--vireglass-glow',\n `radial-gradient(circle ${reach.toFixed(0)}px at ${cx.toFixed(1)}% ${cy.toFixed(1)}%, rgba(${to255(gr)},${to255(gg)},${to255(gb)},1) 0%, rgba(${to255(gr)},${to255(gg)},${to255(gb)},0) 100%)`,\n );\n el.style.setProperty('--vireglass-glow-opacity', strength.toFixed(3));\n }\n\n function tick(now: number): void {\n if (destroyed) return;\n const dt = lastFrameAt ? (now - lastFrameAt) / 1000 : 1 / 60;\n lastFrameAt = now;\n deform.step(dt);\n const s = deform.sample();\n // The interactive variant materialises with the touch rather than being held present. `active`\n // rather than `press`: press is the depth of the dent, active is simply whether a finger is\n // there, and the material arriving has to track the second.\n if (onlyWhenTouched) appear = s.active;\n paintInteraction(s);\n if (deform.idle()) {\n interacting = false;\n frame = null;\n lastFrameAt = 0;\n // Settled: put the full-resolution map back and drop the glow.\n el.style.setProperty('--vireglass-glow-opacity', '0');\n opts.onGlow?.(null);\n apply();\n return;\n }\n frame = requestAnimationFrame(tick);\n }\n\n function run(): void {\n if (frame === null && !destroyed) frame = requestAnimationFrame(tick);\n }\n\n let grabX = 0;\n let grabY = 0;\n\n function onDown(e: PointerEvent): void {\n const [x, y] = localPoint(e);\n const geometry = opts.geometry ?? measureGeometry(el);\n interacting = true;\n grabX = x;\n grabY = y;\n // Pointer capture, or a drag that leaves the element stops reporting and the deformation\n // freezes mid-pull with the finger still down.\n el.setPointerCapture?.(e.pointerId);\n deform.grab(x, y, waveImpulse(geometry));\n run();\n }\n function onMove(e: PointerEvent): void {\n if (!interacting) return;\n const [x, y] = localPoint(e);\n const geometry = opts.geometry ?? measureGeometry(el);\n // `drag` takes the travel FROM the grab point, and saturates it against the limit itself.\n deform.drag(x - grabX, y - grabY, halfMinDp(geometry) * MAX_STRETCH);\n run();\n }\n function onUp(e?: PointerEvent): void {\n if (!interacting) return;\n const geometry = opts.geometry ?? measureGeometry(el);\n if (e) el.releasePointerCapture?.(e.pointerId);\n // Lifting throws a second, weaker ring (§5) — the core caps the sum, so this only has to be\n // the smaller impulse.\n deform.release(waveImpulse(geometry) * RELEASE_WAVE);\n run();\n }\n\n if (opts.interactive !== false) {\n el.addEventListener('pointerdown', onDown);\n el.addEventListener('pointermove', onMove);\n el.addEventListener('pointerup', onUp);\n el.addEventListener('pointercancel', onUp);\n el.addEventListener('pointerleave', onUp);\n }\n\n // The \"listener\" `destroy()` has to remove: geometry defaults to the measured box, so a resize\n // of the element itself has to rebuild the map, or the displacement drifts from the element's\n // actual silhouette as soon as its layout changes.\n let resizeObserver: ResizeObserver | null = null;\n if (!opts.geometry && typeof ResizeObserver !== 'undefined') {\n resizeObserver = new ResizeObserver(() => apply());\n resizeObserver.observe(el);\n }\n\n function destroy(): void {\n destroyed = true;\n stopWatchingA11y();\n if (attached.get(el) === handle) attached.delete(el);\n if (frame !== null) cancelAnimationFrame(frame);\n frame = null;\n el.removeEventListener('pointerdown', onDown);\n el.removeEventListener('pointermove', onMove);\n el.removeEventListener('pointerup', onUp);\n el.removeEventListener('pointercancel', onUp);\n el.removeEventListener('pointerleave', onUp);\n el.style.removeProperty('--vireglass-glow');\n el.style.removeProperty('--vireglass-glow-opacity');\n resizeObserver?.disconnect();\n resizeObserver = null;\n if (filterEl?.parentNode) filterEl.parentNode.removeChild(filterEl);\n filterEl = null;\n mapKey = '';\n el.style.removeProperty('backdrop-filter');\n el.style.removeProperty('-webkit-backdrop-filter');\n el.style.removeProperty('background-color');\n el.style.removeProperty('--vireglass-ink');\n el.style.removeProperty('--vireglass-tint');\n el.style.removeProperty('--vireglass-body-density');\n el.style.removeProperty('--vireglass-ink-color');\n el.style.removeProperty('--vireglass-tint-color');\n el.style.removeProperty('--vireglass-body-color');\n el.style.removeProperty('--vireglass-rim');\n el.style.removeProperty('--vireglass-rim-width');\n el.style.removeProperty('--vireglass-shadow');\n el.style.removeProperty('--vireglass-radius');\n el.style.removeProperty('--vireglass-radius-min');\n el.style.removeProperty('box-shadow');\n el.removeAttribute(GLASS_ATTR);\n if (positionWasStatic) el.style.removeProperty('position');\n }\n\n const handle: GlassHandle = {\n update: apply,\n setAppear(t) {\n const next = t < 0 ? 0 : t > 1 ? 1 : t;\n if (next === appear) return;\n appear = next;\n apply();\n },\n setAccent(next) {\n accent = next ?? undefined;\n apply();\n },\n setNeighbourGlow(glow) {\n if (destroyed || interacting) return;\n const geometry = opts.geometry ?? measureGeometry(el);\n if (!glow) {\n paintGlow(0, 0, 0, geometry);\n return;\n }\n const rect = el.getBoundingClientRect();\n paintGlow(\n glow.pageX - (rect.left + rect.width / 2),\n glow.pageY - (rect.top + rect.height / 2),\n glow.strength,\n geometry,\n );\n },\n setMorph(next) {\n morph = next && next.smoothing > 0 ? next : null;\n mapKey = '';\n apply();\n },\n destroy,\n };\n attached.set(el, handle);\n return handle;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/dom/displacement.ts","../src/spectral.ts","../src/dom/spectral-map.ts","../src/dom/map-cache.ts","../src/dom/probe.ts","../src/dom/support.ts","../src/dom/shadow.ts","../src/dom/body.ts","../src/dom/preferences.ts","../src/dom/rim.ts","../src/dom/nesting.ts","../src/dom/scroll-edge.ts","../src/dom/group.ts","../src/dom/index.ts"],"names":["BEVEL_SAMPLES","mapDensity","smoothstep","clamp01","to255","r","g","b"],"mappings":";;;;;;;AAmBA,IAAM,UAAA,GAAa,IAAA;AAYnB,IAAM,WAAA,GAAc,IAAA;AACpB,IAAM,YAAY,GAAA,GAAM,WAAA;AAYxB,IAAM,aAAA,GAAgB,CAAA;AAGtB,SAAS,UAAA,CAAW,QAAA,EAA6B,KAAA,EAAe,GAAA,EAAqB;AACnF,EAAA,IAAI,KAAA,IAAS,GAAG,OAAO,GAAA;AACvB,EAAA,OAAO,IAAA,CAAK,GAAA,CAAI,GAAA,EAAK,aAAA,GAAgB,KAAK,CAAA;AAC5C;AAIA,SAAS,MAAA,CAAO,cAAsB,KAAA,EAAuB;AAC3D,EAAA,MAAM,UAAU,IAAA,CAAK,KAAA,CAAM,GAAA,IAAO,YAAA,GAAe,QAAQ,GAAA,CAAI,CAAA;AAC7D,EAAA,OAAO,OAAA,GAAU,CAAA,GAAI,CAAA,GAAI,OAAA,GAAU,MAAM,GAAA,GAAM,OAAA;AACjD;AAKA,SAAS,aAAa,CAAA,EAAmB;AACvC,EAAA,MAAM,MAAM,IAAA,CAAK,GAAA,CA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AU,IAAA,EAAM;AACd,MAAA,MAAA,GAAS,IAAA,IAAQ,MAAA;AACjB,MAAA,KAAA,EAAM;AAAA,IACR,CAAA;AAAA,IACA,iBAAiB,IAAA,EAAM;AACrB,MAAA,IAAI,aAAa,WAAA,EAAa;AAC9B,MAAA,MAAM,QAAA,GAAW,IAAA,CAAK,QAAA,IAAY,eAAA,CAAgB,EAAE,CAAA;AACpD,MAAA,IAAI,CAAC,IAAA,EAAM;AACT,QAAA,SAAA,CAAU,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,QAAQ,CAAA;AAC3B,QAAA;AAAA,MACF;AACA,MAAA,MAAM,IAAA,GAAO,GAAG,qBAAA,EAAsB;AACtC,MAAA,SAAA;AAAA,QACE,IAAA,CAAK,KAAA,IAAS,IAAA,CAAK,IAAA,GAAO,KAAK,KAAA,GAAQ,CAAA,CAAA;AAAA,QACvC,IAAA,CAAK,KAAA,IAAS,IAAA,CAAK,GAAA,GAAM,KAAK,MAAA,GAAS,CAAA,CAAA;AAAA,QACvC,IAAA,CAAK,QAAA;AAAA,QACL;AAAA,OACF;AAAA,IACF,CAAA;AAAA,IACA,SAAS,IAAA,EAAM;AACb,MAAA,KAAA,GAAQ,IAAA,IAAQ,IAAA,CAAK,SAAA,GAAY,CAAA,GAAI,IAAA,GAAO,IAAA;AAC5C,MAAA,MAAA,GAAS,EAAA;AACT,MAAA,KAAA,EAAM;AAAA,IACR,CAAA;AAAA,IACA;AAAA,GACF;AACA,EAAA,QAAA,CAAS,GAAA,CAAI,IAAI,MAAM,CAAA;AACvB,EAAA,OAAO,MAAA;AACT","file":"dom.js","sourcesContent":["// The DOM renderer's own optics: an `feDisplacementMap` source built from the same causes as the\n// GL/AGSL shaders, so a page refracting live content still reads as the same material. See\n// `docs/superpowers/specs/2026-09-19-vireglass-over-live-dom.md` for the technique this encodes.\nimport { bevelDp, thicknessDp, type VireGlassGeometry } from '../geometry';\nimport { BEVEL } from '../law';\nimport type { VireGlassOptics } from '../material';\nimport {\n sceneDistance,\n sceneGradient,\n touchWarp,\n type MorphShape,\n type TouchWarp,\n} from '../sdf';\n\nexport type DisplacementMap = { url: string; width: number; height: number; scale: number };\n\n/** dp of rim displacement per dp of size-adjusted thickness, at full refraction strength (ior →\n * 1.6). Tuned so the product default (V5: ior 1.5, thickness 28dp) lands well under `MAX_SCALE`\n * before it's ever clamped — the ceiling below is what actually limits denser glass. */\nconst SCALE_GAIN = 0.75;\n\n/**\n * `feDisplacementMap` displaces by `scale * (channel / 255 - 0.5)`: a full channel swing spans\n * ±scale/2, and one 8-bit step is `scale/255` px — not `scale/127`, which an earlier version of\n * this file assumed and which rendered every material at half its derived refraction.\n *\n * Measured in Chromium on 2026-09-19: at scale 40 (0.157 px/step) a high-contrast edge visibly\n * terraces; at scale 12 (0.047 px/step) it does not. The ceiling sits between them and nearer\n * the clean end — thick, high-index glass is flattened to it instead of its derived scale,\n * trading rim depth for an edge without stairs.\n */\nconst MAX_STEP_PX = 0.09;\nconst MAX_SCALE = 255 * MAX_STEP_PX;\n\n/**\n * Samples across the bevel band, which is the only place the map carries anything. Everything\n * inside it is a constant, and `feImage` stretches whatever it is given over the element anyway,\n * so resolving the element is wasted work: a sheet at device resolution is 197 000 pixels of\n * per-pixel maths and a PNG encode, 120 ms on attach and far past a frame during interaction.\n *\n * Eight samples describe a profile that is smooth by construction. The measured cost falls with\n * the square of the reduction, and `check:dom` measures the displacement afterwards to say\n * whether anything was lost.\n */\nconst BEVEL_SAMPLES = 8;\n\n/** Resolution the map is built at: enough to resolve the bevel, never more than the element. */\nfunction mapDensity(geometry: VireGlassGeometry, bevel: number, dpr: number): number {\n if (bevel <= 0) return dpr;\n return Math.min(dpr, BEVEL_SAMPLES / bevel);\n}\n\n/** True neutral is the unrepresentable 127.5; 128 is the nearest byte and leaves a residual\n * 0.002 of the scale, far below one step and below a pixel at any usable scale. */\nfunction encode(displacement: number, scale: number): number {\n const channel = Math.round(255 * (displacement / scale + 0.5));\n return channel < 0 ? 0 : channel > 255 ? 255 : channel;\n}\n\n/** Mirrors the shader's `vgBevelSlope`, renormalized into 0..1: curvature concentrated at the\n * rim, the middle left flat. A plain linear ramp from `vgBevelT` alone reads as a chamfer, not a\n * lens — the same reason the shader doesn't use it raw either. */\nfunction bevelProfile(t: number): number {\n const raw = Math.min(t / Math.sqrt(Math.max(1 - t * t * BEVEL.sphere, BEVEL.floor)), BEVEL.slopeMax);\n return raw / BEVEL.slopeMax;\n}\n\nexport type DisplacementState = {\n /** Finger response (docs/reference.md §5): the field around the touch deforms, so the silhouette\n * the backdrop bends along deforms with it. */\n touch?: TouchWarp;\n /** Smooth-union neighbours (§5): shapes merging into one and splitting apart. */\n smoothing?: number;\n morph?: MorphShape;\n morph2?: MorphShape;\n /** Any number of shapes flowing into this one. `morph`/`morph2` are the first two, kept so a\n * caller that only ever had two does not have to change. */\n morphs?: readonly MorphShape[];\n};\n\n/**\n * The raw pixel buffer, with no canvas involved — the part actually worth unit-testing.\n * `buildDisplacementMap` below is a thin DOM wrapper around this.\n *\n * Encoding: R = x offset, G = y offset, 128 = no shift, one step = `scale/255` px; B = 128\n * (unused), A = 255 (opaque, `feImage` would otherwise composite the map against page black).\n * The offset points INWARD — the rim samples the backdrop from inside the shape, a convex thick\n * lens. Displacement lives only in the bevel band (`bevelDp`); the flat middle is exactly 128/128.\n */\nexport function renderDisplacementPixels(\n optics: VireGlassOptics,\n geometry: VireGlassGeometry,\n dpr: number,\n state: DisplacementState = {},\n): { data: Uint8ClampedArray; width: number; height: number; scale: number } {\n const bevel = bevelDp(geometry, optics);\n const density = mapDensity(geometry, bevel, dpr);\n const width = Math.max(1, Math.round(geometry.width * density));\n const height = Math.max(1, Math.round(geometry.height * density));\n const rawScale = optics.refraction * thicknessDp(geometry, optics) * SCALE_GAIN;\n const scale = Math.min(rawScale, MAX_SCALE);\n const smoothing = state.smoothing ?? 0;\n // One list, whichever way the caller expressed it.\n const shapes: (MorphShape | undefined)[] = [state.morph, state.morph2, ...(state.morphs ?? [])];\n\n const data = new Uint8ClampedArray(width * height * 4);\n const halfW = geometry.width / 2;\n const halfH = geometry.height / 2;\n\n for (let py = 0; py < height; py += 1) {\n const y = (py + 0.5) / density - halfH;\n for (let px = 0; px < width; px += 1) {\n const x = (px + 0.5) / density - halfW;\n const i = (py * width + px) * 4;\n // Warp the FIELD first, then read the scene at the warped point — the shader's own order.\n const [wx, wy] = state.touch ? touchWarp(x, y, state.touch) : [x, y];\n const sd = sceneDistance(wx, wy, geometry.width, geometry.height, geometry.cornerRadius, smoothing, ...shapes);\n const t = Math.min(Math.max((sd + bevel) / bevel, 0), 1);\n if (t <= 0 || scale <= 0) {\n data[i] = 128;\n data[i + 1] = 128;\n data[i + 2] = 128;\n data[i + 3] = 255;\n continue;\n }\n const [gx, gy] = sceneGradient(wx, wy, geometry.width, geometry.height, geometry.cornerRadius, smoothing, ...shapes);\n // The rim reaches half the scale: the encoding can only span ±scale/2, so the derived\n // displacement is expressed as a fraction of that half-range.\n const magnitude = bevelProfile(t) * (scale / 2);\n const dx = -gx * magnitude;\n const dy = -gy * magnitude;\n // Inverse of the spec's own formula: channel = 255 * (displacement / scale + 0.5).\n data[i] = encode(dx, scale);\n data[i + 1] = encode(dy, scale);\n data[i + 2] = 128;\n data[i + 3] = 255;\n }\n }\n\n return { data, width, height, scale };\n}\n\nfunction hasCanvasSupport(): boolean {\n return typeof document !== 'undefined' && typeof document.createElement === 'function';\n}\n\n/** Builds the map at device-pixel resolution so it stays sharp once the browser stretches it back\n * over the element's CSS-px box (`feImage` fills the filter region regardless of source size). */\nexport function buildDisplacementMap(\n optics: VireGlassOptics,\n geometry: VireGlassGeometry,\n dpr: number,\n state: DisplacementState = {},\n): DisplacementMap {\n if (!hasCanvasSupport()) {\n throw new Error('vireglass/dom: buildDisplacementMap requires a DOM (canvas)');\n }\n const { data, width, height, scale } = renderDisplacementPixels(optics, geometry, dpr, state);\n const canvas = document.createElement('canvas');\n canvas.width = width;\n canvas.height = height;\n const ctx = canvas.getContext('2d');\n if (!ctx) throw new Error('vireglass/dom: 2D canvas context unavailable');\n const imageData = ctx.createImageData(width, height);\n imageData.data.set(data);\n ctx.putImageData(imageData, 0, 0);\n return { url: canvas.toDataURL('image/png'), width, height, scale };\n}\n","// The spectral edge (docs/reference.md §1). Dispersion, diffraction and interference are ONE\n// cause — a dependence on wavelength — and one hue multiplier, normalised to its own mean, so they\n// colour what passes through without brightening it.\n//\n// JS twins of the lens shader's `vgInterference`, `vgDiffraction` and the rim profile they read\n// from. Same reason as the SDF's twins: the DOM path needs this geometry as numbers, and a second\n// version that drifts is the defect the parity gate exists for.\nimport { LENS, SPECTRAL } from './law';\n\nconst TAU = 6.28318530718;\nconst LAMBDA: readonly [number, number, number] = [LENS.lambdaR, LENS.lambdaG, LENS.lambdaB];\n\nconst clamp01 = (v: number) => (v < 0 ? 0 : v > 1 ? 1 : v);\n\n/** Normalises a triple to its own mean — the step that makes these hues rather than gains. */\nfunction toHue(v: [number, number, number]): [number, number, number] {\n const mean = Math.max((v[0] + v[1] + v[2]) / 3, 0.001);\n return [v[0] / mean, v[1] / mean, v[2] / mean];\n}\n\n/** Mirrors `vgRimQd`: the derivative of the rim's height profile. */\nexport function rimSlopeCurve(x: number): number {\n const k = 1 - clamp01(x);\n return (k * k * k) / Math.pow(Math.max(1 - k * k * k * k, 1e-5), 0.75);\n}\n\n/** Mirrors `vgSlope`: the top face's slope at distance `e` inside the silhouette. */\nexport function surfaceSlope(e: number, bevel: number, rim: number, thick: number): number {\n if (e >= bevel || bevel <= 0) return 0;\n return Math.min(((thick - rim) / bevel) * rimSlopeCurve(e / bevel), LENS.slopeMax);\n}\n\n/** The normal's z, which is what both spectral terms are measured against. `N = normalize([n·s, 1])`\n * in the shader, so its z is simply the slope resolved back to unit length. */\nexport function surfaceCosine(slope: number): number {\n return 1 / Math.sqrt(1 + slope * slope);\n}\n\n/** Thin-film interference: optical path difference 2·n·d·cosθt, each channel with its own λ. */\nexport function interference(cosI: number, filmNm: number): [number, number, number] {\n const sinT2 = (1 - cosI * cosI) / (LENS.filmIor * LENS.filmIor);\n const cosT = Math.sqrt(Math.max(1 - sinT2, 0));\n const opd = 2 * LENS.filmIor * filmNm * cosT;\n return toHue([\n 0.5 + 0.5 * Math.cos((TAU * opd) / LAMBDA[0] + Math.PI),\n 0.5 + 0.5 * Math.cos((TAU * opd) / LAMBDA[1] + Math.PI),\n 0.5 + 0.5 * Math.cos((TAU * opd) / LAMBDA[2] + Math.PI),\n ]);\n}\n\n/** Edge diffraction: fringes get denser as the bevel sharpens. A hue, not a brightness. */\nexport function diffraction(distFromEdge: number, bevel: number): [number, number, number] {\n const phase = (TAU * SPECTRAL.diffractionFringes * distFromEdge) / Math.max(bevel, 1);\n const f = (lambda: number) => 0.5 + 0.5 * Math.cos((phase * SPECTRAL.referenceLambda) / lambda);\n return toHue([f(LAMBDA[0]), f(LAMBDA[1]), f(LAMBDA[2])]);\n}\n\nfunction smoothstep(edge0: number, edge1: number, x: number): number {\n const t = clamp01((x - edge0) / (edge1 - edge0));\n return t * t * (3 - 2 * t);\n}\n\n/**\n * Both terms at one point, weighted as the lens weights them: interference by `iridescence` across\n * the bevel, diffraction by its own strength but only within `diffractionOnset` of the silhouette.\n *\n * `e` is the distance inside the edge; everything else comes from the resolved optics.\n */\nexport function spectralHue(\n e: number,\n bevel: number,\n rim: number,\n thick: number,\n optics: { film: number; iridescence: number; diffraction: number },\n): [number, number, number] {\n let r = 1;\n let g = 1;\n let b = 1;\n\n // `t` is 1 at the silhouette and 0 at the inner edge of the bevel, as below.\n const t = 1 - clamp01(bevel > 0 ? e / bevel : 1);\n\n if (optics.iridescence > 0.001) {\n // Windowed to the edge, for the same reason diffraction is: §2 puts the iridescence on the\n // opposing arc, and an arc is at the silhouette. Unwindowed, the surface angle stops changing a\n // third of the way in and the film paints the rest of the bevel one flat colour.\n const w = optics.iridescence * smoothstep(SPECTRAL.iridescenceOnset, 1, t);\n if (w > 0) {\n const cosI = clamp01(surfaceCosine(surfaceSlope(e, bevel, rim, thick)));\n const i = interference(cosI, optics.film);\n r += (i[0] - 1) * w;\n g += (i[1] - 1) * w;\n b += (i[2] - 1) * w;\n }\n }\n\n if (optics.diffraction > 0.001) {\n // The fringes live at the outer end of the bevel, which is what makes this an EDGE effect\n // rather than a sheen over it.\n const w = optics.diffraction * smoothstep(SPECTRAL.diffractionOnset, 1, t);\n if (w > 0) {\n const d = diffraction(e, bevel);\n r += (d[0] - 1) * w;\n g += (d[1] - 1) * w;\n b += (d[2] - 1) * w;\n }\n }\n\n return [r, g, b];\n}\n","// The spectral edge, baked into an image (docs/reference.md §1).\n//\n// Diffraction and interference are hue multipliers that vary per pixel across the bevel, and an\n// SVG filter has no way to evaluate a function per pixel. But it can MULTIPLY by an image:\n// `feComposite operator=\"arithmetic\"` with k1 set is a product, so the hue can be baked and\n// applied in one pass.\n//\n// The multiplier exceeds 1 wherever a channel is boosted, and eight bits cannot carry that, so the\n// map stores the hue divided by a headroom the filter multiplies back. Without the headroom every\n// boosted channel would clip to white and the fringes would read as a bright rim rather than a\n// coloured one.\nimport { bevelDp, rimDp, thicknessDp, type VireGlassGeometry } from '../geometry';\nimport type { VireGlassOptics } from '../material';\nimport { sdfRoundedRect } from '../sdf';\nimport { spectralHue } from '../spectral';\n\nexport type SpectralMap = { url: string; width: number; height: number; headroom: number };\n\n/** A hue normalised to its own mean cannot exceed the number of channels; in practice it stays\n * well under two. Two is the smallest headroom that never clips. */\nconst HEADROOM = 2;\n\n/**\n * The hue map is sampled like the displacement map — across the bevel, not across the element. It\n * needs MORE samples than the displacement does, because fringes oscillate where the displacement\n * is monotonic, and undersampling a fringe pattern aliases it into a different one.\n */\nconst BEVEL_SAMPLES = 24;\n\nfunction mapDensity(bevel: number, dpr: number): number {\n if (bevel <= 0) return dpr;\n return Math.min(dpr, BEVEL_SAMPLES / bevel);\n}\n\nexport function renderSpectralPixels(\n optics: VireGlassOptics,\n geometry: VireGlassGeometry,\n dpr: number,\n): { data: Uint8ClampedArray; width: number; height: number; headroom: number } {\n const bevel = bevelDp(geometry, optics);\n const density = mapDensity(bevel, dpr);\n const width = Math.max(1, Math.round(geometry.width * density));\n const height = Math.max(1, Math.round(geometry.height * density));\n const rim = rimDp(geometry, optics);\n const thick = thicknessDp(geometry, optics);\n\n const data = new Uint8ClampedArray(width * height * 4);\n const halfW = geometry.width / 2;\n const halfH = geometry.height / 2;\n const neutral = Math.round((1 / HEADROOM) * 255);\n\n for (let py = 0; py < height; py += 1) {\n const y = (py + 0.5) / density - halfH;\n for (let px = 0; px < width; px += 1) {\n const x = (px + 0.5) / density - halfW;\n const i = (py * width + px) * 4;\n const sd = sdfRoundedRect(x, y, geometry.width, geometry.height, geometry.cornerRadius);\n const e = Math.max(-sd, 0);\n if (e >= bevel) {\n // Past the bevel the glass is plain: a neutral multiplier, not a missing one.\n data[i] = neutral;\n data[i + 1] = neutral;\n data[i + 2] = neutral;\n data[i + 3] = 255;\n continue;\n }\n const [r, g, b] = spectralHue(e, bevel, rim, thick, optics);\n data[i] = Math.round((r / HEADROOM) * 255);\n data[i + 1] = Math.round((g / HEADROOM) * 255);\n data[i + 2] = Math.round((b / HEADROOM) * 255);\n data[i + 3] = 255;\n }\n }\n\n return { data, width, height, headroom: HEADROOM };\n}\n\n/** Whether this material has a spectral edge at all. Three extra filter primitives and a per-pixel\n * bake are not worth paying for a multiplier that is flat 1. */\nexport function hasSpectralEdge(optics: VireGlassOptics): boolean {\n return optics.iridescence > 0.001 || optics.diffraction > 0.001;\n}\n\nexport function buildSpectralMap(\n optics: VireGlassOptics,\n geometry: VireGlassGeometry,\n dpr: number,\n): SpectralMap {\n if (typeof document === 'undefined' || typeof document.createElement !== 'function') {\n throw new Error('vireglass/dom: buildSpectralMap requires a DOM (canvas)');\n }\n const { data, width, height, headroom } = renderSpectralPixels(optics, geometry, dpr);\n const canvas = document.createElement('canvas');\n canvas.width = width;\n canvas.height = height;\n const ctx = canvas.getContext('2d');\n if (!ctx) throw new Error('vireglass/dom: 2D canvas context unavailable');\n const image = ctx.createImageData(width, height);\n image.data.set(data);\n ctx.putImageData(image, 0, 0);\n return { url: canvas.toDataURL('image/png'), width, height, headroom };\n}\n","// Maps are pure functions of geometry, optics and density — the same element twice, or four\n// identical buttons in a tab bar, produce byte-identical PNGs. Building each one again is the\n// single largest avoidable cost in this renderer: a sheet's hue map is tens of milliseconds, and\n// it happens on every attach, every remount and every re-attach after a theme change.\n//\n// Small and strict on purpose. A page has a handful of distinct glass shapes, not hundreds; a\n// cache that grew without bound would hold megabytes of data URIs alive for a screen nobody is\n// looking at any more.\nconst LIMIT = 24;\n\nconst store = new Map<string, unknown>();\n\nexport function cached<T>(key: string, build: () => T): T {\n const hit = store.get(key);\n if (hit !== undefined) {\n // Re-inserting moves it to the end: the oldest key is the one evicted, not the most used one.\n store.delete(key);\n store.set(key, hit);\n return hit as T;\n }\n const value = build();\n store.set(key, value);\n if (store.size > LIMIT) {\n const oldest = store.keys().next();\n if (!oldest.done) store.delete(oldest.value);\n }\n return value;\n}\n\n/** Test-only: the cache is process-wide, and a suite that measures build cost needs it cold. */\nexport function clearMapCache(): void {\n store.clear();\n}\n\nexport function mapCacheSize(): number {\n return store.size;\n}\n","// Backdrop sample for the DOM renderer — the web-DOM counterpart to the WebGL downsample probe\n// (`web/probe.ts`) and the native capture on Android. The web canvas can read the pixels it just\n// drew; a page CANNOT read what's actually rendered behind an arbitrary element — that boundary\n// is the whole reason `backdrop-filter` exists as a browser primitive rather than a pixel API. So\n// this probes DECLARED STYLES instead: walk the stacking order under a grid of sample points and\n// read `background-color` (falling back to `color`) rather than any real pixel.\nimport type { BackdropSample } from '../adaptation';\n\n/** A modest grid: this runs on scroll, not per frame. `elementsFromPoint` walks the whole\n * stacking context at every sample point — a fine grid shows up in a profiler, a coarse one is\n * still plenty to tell \"flat\" from \"busy\" for the adaptation decision. */\nconst GRID_COLS = 5;\nconst GRID_ROWS = 5;\n\nexport type RgbColor = { r: number; g: number; b: number; a: number };\n\n/**\n * Parses `rgb()`/`rgba()` exactly as `getComputedStyle` emits them — every engine normalizes a\n * resolved color to one of these two forms, so there's nothing here worth a dependency for.\n * Returns `null` for anything else (a keyword that didn't resolve, a malformed value).\n */\nexport function parseColor(value: string): RgbColor | null {\n const match = /rgba?\\(\\s*([\\d.]+)\\s*,\\s*([\\d.]+)\\s*,\\s*([\\d.]+)\\s*(?:,\\s*([\\d.]+))?\\s*\\)/i.exec(value);\n if (!match) return null;\n const r = Number(match[1]);\n const g = Number(match[2]);\n const b = Number(match[3]);\n const a = match[4] === undefined ? 1 : Number(match[4]);\n if (!Number.isFinite(r) || !Number.isFinite(g) || !Number.isFinite(b) || !Number.isFinite(a)) return null;\n return { r, g, b, a };\n}\n\nfunction luma(r: number, g: number, b: number): number {\n return 0.2126 * r + 0.7152 * g + 0.0722 * b;\n}\n\n/**\n * Same statistic the WebGL probe computes on its downsample grid (`web/probe.ts`, `rectStats`):\n * mean luma, twice the mean deviation for `busy`, 10th/90th percentile for `lo`/`hi`. A different\n * formula here would mean the ink-polarity decision quietly drifts between renderers on the same\n * page. `samples` are 0..255 per channel, matching what `parseColor` returns.\n */\nexport function statsFromSamples(samples: readonly RgbColor[]): BackdropSample {\n const n = samples.length;\n if (n === 0) return { luma: 0.5, busy: 0, lo: 0.5, hi: 0.5, r: 0.5, g: 0.5, b: 0.5 };\n\n const lumas: number[] = [];\n let sr = 0;\n let sg = 0;\n let sb = 0;\n for (const s of samples) {\n const r = s.r / 255;\n const g = s.g / 255;\n const b = s.b / 255;\n lumas.push(luma(r, g, b));\n sr += r;\n sg += g;\n sb += b;\n }\n\n let mean = 0;\n for (const v of lumas) mean += v;\n mean /= n;\n\n let busy = 0;\n for (const v of lumas) busy += Math.abs(v - mean);\n busy = Math.min((busy / n) * 2, 1);\n\n const sorted = [...lumas].sort((a, b) => a - b);\n const percentile = (p: number) => {\n const idx = p * (n - 1);\n const lo = Math.floor(idx);\n const hi = Math.ceil(idx);\n return sorted[lo] + (sorted[hi] - sorted[lo]) * (idx - lo);\n };\n\n return {\n luma: mean,\n busy,\n lo: percentile(0.1),\n hi: percentile(0.9),\n r: sr / n,\n g: sg / n,\n b: sb / n,\n };\n}\n\n/**\n * Composites a stack of backgrounds front to back, the way the compositor does.\n *\n * Taking the first layer with any alpha at all instead is wrong by a lot, not a little: a list row\n * tinted `rgba(255,255,255,0.028)` over a near-black page reads as pure WHITE, and the glass then\n * adapts to a backdrop that does not exist. That is most real interfaces.\n */\nexport function compositeLayers(layers: readonly RgbColor[]): RgbColor | null {\n let r = 0;\n let g = 0;\n let b = 0;\n let a = 0;\n for (const layer of layers) {\n const share = layer.a * (1 - a);\n if (share <= 0) continue;\n r += layer.r * share;\n g += layer.g * share;\n b += layer.b * share;\n a += share;\n if (a >= 0.999) break;\n }\n if (a <= 0.001) return null;\n // Normalised by coverage: what reached the eye, as an opaque colour. A stack that never became\n // opaque sits over the page's own background, which is the caller's floor layer.\n return { r: r / a, g: g / a, b: b / a, a };\n}\n\n/** Walks the stack at one point, skipping the glass element itself (it would otherwise probe its\n * own background) and its descendants. */\nfunction sampleColorAt(el: HTMLElement, x: number, y: number): RgbColor | null {\n const stack = document.elementsFromPoint(x, y);\n const behind = stack.filter((node) => node !== el && !el.contains(node));\n const layers: RgbColor[] = [];\n for (const node of behind) {\n const bg = parseColor(getComputedStyle(node).backgroundColor);\n // `rgba(0, 0, 0, 0)` is what \"transparent\" resolves to almost everywhere: it contributes\n // nothing and must not shadow a real colour further down.\n if (bg && bg.a > 0.001) layers.push(bg);\n }\n const composited = compositeLayers(layers);\n if (composited) return composited;\n return canvasColor(el);\n}\n\n/**\n * The page's own background — the floor everything else is composited over.\n *\n * Reached whenever nothing in the stack is opaque, which is not an edge case: CSS propagates the\n * body's background to the CANVAS, so `getComputedStyle` reports `<html>` and often `<body>` as\n * transparent on a perfectly ordinary white page. Any element past the end of the body's box —\n * a widget pinned to a corner, say — sees a stack of nothing.\n *\n * This used to fall back to the topmost element's `color`, which is its TEXT colour: a white page\n * with black text read as black, and the material dressed itself for a dark backdrop over a light\n * one. The propagation rule says where to look instead — the root element's background, then the\n * body's, then the user agent's white.\n */\nfunction canvasColor(el: HTMLElement): RgbColor | null {\n const doc = el.ownerDocument;\n for (const node of [doc.documentElement, doc.body]) {\n if (!node) continue;\n const bg = parseColor(getComputedStyle(node).backgroundColor);\n if (bg && bg.a > 0.001) return bg.a >= 0.999 ? bg : compositeLayers([bg, WHITE]);\n }\n return WHITE;\n}\n\n/** What a browser paints the canvas when nobody says otherwise. */\nconst WHITE: RgbColor = { r: 255, g: 255, b: 255, a: 1 };\n\nexport type ProbeOptions = {\n /** Grid density override — wider for a hero element, narrower for a tight control. */\n cols?: number;\n rows?: number;\n};\n\n/**\n * Backdrop sample for the glass element from its live surroundings, blind to images/video/canvas\n * by construction (the caller overrides with its own sample there — cover art already knows its\n * own accent; see `attachGlass`'s `sample` option).\n */\nexport function probeBackdrop(el: HTMLElement, opts: ProbeOptions = {}): BackdropSample {\n const cols = opts.cols ?? GRID_COLS;\n const rows = opts.rows ?? GRID_ROWS;\n const rect = el.getBoundingClientRect();\n // A hidden or not-yet-laid-out element has no backdrop to speak of. Sampling it anyway collapses\n // the whole grid onto one corner point and reports whatever unrelated thing sits there as a\n // confident, perfectly flat reading.\n if (rect.width <= 0 || rect.height <= 0) return statsFromSamples([]);\n const samples: RgbColor[] = [];\n for (let j = 0; j < rows; j += 1) {\n const y = rect.top + ((j + 0.5) / rows) * rect.height;\n for (let i = 0; i < cols; i += 1) {\n const x = rect.left + ((i + 0.5) / cols) * rect.width;\n const color = sampleColorAt(el, x, y);\n if (color) samples.push(color);\n }\n }\n return statsFromSamples(samples);\n}\n","// Feature detection BY MEASUREMENT, never by sniffing the user agent — the agent string is the\n// first thing to lie about this after an engine update.\n//\n// Firefox does not support `url()` inside `backdrop-filter` and has closed the request as not\n// planned (bug 1578503). Safari doesn't support `backdrop-filter` with `url()` yet either, though\n// WebKit has patches in flight. Both can change without notice, so this asks the engine directly.\n\nlet backdropFilterSupport: boolean | null = null;\nlet svgBackdropFilterSupport: boolean | null = null;\n\n// `CSS.supports`, not a detached element read back through `getComputedStyle`: Chromium resolves\n// no style at all for an element outside the document, so that probe answered \"unsupported\" in the\n// very engine where the displacement demonstrably works.\n//\n// This answers that the engine PARSES the value. An engine could in principle parse `url()` and\n// render nothing; a host that meets one can override the decision through `attachGlass` instead of\n// being stuck with a wrong automatic answer.\nfunction probeProperty(property: string, value: string): boolean {\n if (typeof CSS === 'undefined' || typeof CSS.supports !== 'function') return false;\n return CSS.supports(property, value);\n}\n\n/** Any `backdrop-filter` at all (e.g. `blur()`) — the fallback path's own requirement. */\nexport function supportsBackdropFilter(): boolean {\n if (backdropFilterSupport === null) {\n backdropFilterSupport =\n probeProperty('backdrop-filter', 'blur(1px)') || probeProperty('-webkit-backdrop-filter', 'blur(1px)');\n }\n return backdropFilterSupport;\n}\n\n/** `url(#filter)` specifically — the SVG displacement path's requirement. Checked separately from\n * `supportsBackdropFilter()`: an engine can support plain blur without supporting a filter\n * reference, which is exactly the Firefox case. */\nexport function supportsSvgBackdropFilter(): boolean {\n if (svgBackdropFilterSupport === null) {\n svgBackdropFilterSupport = probeProperty('backdrop-filter', 'url(#vireglass-support-probe)');\n }\n return svgBackdropFilterSupport;\n}\n\n/** Test-only: the two probes above cache after their first call, and a suite that stubs the DOM\n * differently per test needs a way to invalidate that. */\nexport function resetSupportCache(): void {\n backdropFilterSupport = null;\n svgBackdropFilterSupport = null;\n}\n","// Adaptive shadow (docs/reference.md §4). The law itself — density keyed to what is behind the\n// element, size keyed to its own half-size — lives in `../geometry` as `shadowOpacityFrom` and\n// `shadowReachDp`; this turns those into a CSS `box-shadow`.\nimport { ambientFrom, type BackdropSample } from '../adaptation';\nimport { shadowOpacity, shadowOpacityFrom, shadowReachDp, type VireGlassGeometry } from '../geometry';\nimport { SHADOW, SHADOW_GAP } from '../law';\nimport { shadowTint } from '../shadow-tint';\n\n/**\n * The model carries shadow density as a multiplier the shader applies to its own per-pixel term,\n * so the DOM path has to convert it to one flat alpha. That conversion is not a taste constant:\n * §4 records both ends measured off reference frames 711–723 — 19.9% over text, 4.0% over a flat\n * light backdrop — and `shadowOpacity` spans exactly those two cases. Two measured points, one line.\n */\nconst FLAT_DENSITY = shadowOpacity(0);\nconst BUSY_DENSITY = shadowOpacity(1);\n\nexport function shadowAlphaFrom(sample: { busy: number }): number {\n const t = (shadowOpacityFrom(sample) - FLAT_DENSITY) / (BUSY_DENSITY - FLAT_DENSITY);\n const alpha = SHADOW.alphaFlat + t * (SHADOW.alphaBusy - SHADOW.alphaFlat);\n return Math.min(Math.max(alpha, 0), 1);\n}\n\nconst to255 = (v: number) => Math.round(Math.min(Math.max(v, 0), 1) * 255);\n\n/**\n * Symmetric and blur-only: §4 gives a density and a size, never a direction. The reference calls\n * the shadow \"soft, small\" — blur carries both.\n *\n * The colour is NOT black. \"The light reflects, scatters, and bleeds into the shadow as well —\n * much like it would in the physical world\" (219 @8:22). A black shadow leaves an element over\n * colourful content hanging above a grey blob, which is the one thing that reads as pasted on.\n */\n/**\n * `appear` is the same gate the surface shader puts on the shadow (`u_shadow * u_appear`, line\n * 176). An element that is not there yet does not cast: a shadow under nothing is the one part of\n * materialising that gives the trick away.\n */\nexport function boxShadowCss(\n geometry: VireGlassGeometry,\n sample: BackdropSample | { busy: number },\n appear = 1,\n): string {\n const reach = shadowReachDp(geometry);\n const present = appear < 0 ? 0 : appear > 1 ? 1 : appear;\n const alpha = shadowAlphaFrom(sample) * present;\n const ambient = 'luma' in sample ? ambientFrom(sample as BackdropSample) : null;\n if (!ambient) return `0 0 ${reach.toFixed(1)}px rgba(0, 0, 0, ${alpha.toFixed(3)})`;\n\n const [r, g, b] = shadowTint(ambient);\n const spill = SHADOW_GAP.tint;\n return (\n `0 0 ${reach.toFixed(1)}px ` +\n `rgba(${to255(r * spill)}, ${to255(g * spill)}, ${to255(b * spill)}, ${alpha.toFixed(3)})`\n );\n}\n","// The glass BODY (docs/reference.md §3): how dense the medium has to be over this particular\n// backdrop, and which way it tints.\n//\n// The law is the lens shader's, lines 444–482, ported to one value per element instead of one per\n// pixel — the DOM path has a single backdrop sample, not a plane. Constants keep their names from\n// the shader so the two stay comparable.\nimport { BODY } from '../law';\nimport type { VireGlassOptics } from '../material';\n\nconst {\n capLoose: BODY_CAP_LOOSE,\n capTight: BODY_CAP_TIGHT,\n tintDark: TINT_DARK,\n tintLight: TINT_LIGHT,\n groundSpan: GROUND_SPAN,\n busyEdge: BUSY_EDGE,\n darkSideFrom: DARK_SIDE_FROM,\n darkSideTo: DARK_SIDE_TO,\n maxDemand: MAX_DEMAND,\n} = BODY;\n\nconst clamp = (v: number, lo: number, hi: number) => (v < lo ? lo : v > hi ? hi : v);\nconst mix = (a: number, b: number, t: number) => a + (b - a) * t;\n\nfunction smoothstep(edge0: number, edge1: number, x: number): number {\n const t = clamp((x - edge0) / (edge1 - edge0), 0, 1);\n return t * t * (3 - 2 * t);\n}\n\n/** Only the two figures the law reads — the same narrowing `shadowOpacityFrom` uses. */\nexport type BodyBackdrop = { luma: number; busy: number };\n\nexport type GlassBody = {\n /** How much medium stands between the backdrop and the eye, 0…1. */\n density: number;\n /** Lightness the body tints toward. */\n tintLuma: number;\n};\n\n/**\n * `ink` is POLARITY, 1 light and 0 dark, matching the shader's uniform. The requirements are\n * evaluated at both ends and blended by it — computing at the current polarity alone makes the\n * glass dip toward the middle while a recolor is in flight.\n */\nexport function resolveBody(optics: VireGlassOptics, sample: BodyBackdrop, ink: number): GlassBody {\n const strict = clamp(optics.legibility * 2, 0, 1);\n const capLight = mix(BODY_CAP_LOOSE, BODY_CAP_TIGHT, strict);\n const floorDark = 1 - capLight;\n const pol = clamp(ink, 0, 1);\n // With no ink on it, the model promises transparent glass: the requirement fades out with\n // legibility rather than standing at a floor.\n const demand = clamp(optics.legibility * 4, 0, 1);\n\n const mean = clamp(sample.luma, 0, 1);\n const busy = Math.max(sample.busy, 0);\n\n // Direction of the tint follows the element's AVERAGE lightness, not a local spot: on a\n // gradient a local threshold cuts a diagonal step across the body.\n const darkSide = smoothstep(DARK_SIDE_FROM, DARK_SIDE_TO, mean);\n const away = mix(TINT_LIGHT, TINT_DARK, darkSide);\n const tintLuma = mix(away, mix(TINT_LIGHT, TINT_DARK, pol), demand);\n\n // How much medium it takes to push the lightness under the ink past its threshold, measured\n // from whichever edge of the backdrop's spread is closer to the ink — a light ink drowns in a\n // light patch right beneath it, and the average knows nothing about that patch.\n const edge = busy * BUSY_EDGE;\n const inkHi = Math.min(mean + edge, 1);\n const inkLo = Math.max(mean - edge, 0);\n const needForLight = inkHi > capLight ? clamp((inkHi - capLight) / Math.max(inkHi - TINT_DARK, 1e-4), 0, MAX_DEMAND) : 0;\n const needForDark = inkLo < floorDark ? clamp((floorDark - inkLo) / Math.max(TINT_LIGHT - inkLo, 1e-4), 0, MAX_DEMAND) : 0;\n const needForInk = mix(needForDark, needForLight, pol) * demand;\n\n // Fine texture the body has to stop being a window for, the same way roughness does it.\n const ground = busy * optics.legibility * GROUND_SPAN;\n\n return { density: Math.max(Math.max(optics.bodyDensity, ground), needForInk), tintLuma };\n}\n\n/**\n * PRESENCE (§3): over a uniform backdrop there is nothing to refract and the glass honestly\n * disappears — right for a piece of background, wrong for a control. It is a MINIMUM, not an\n * addition, so a body that already stands apart is left alone.\n *\n * The direction is the body's own. The previous version decided \"lighter over dark, darker over\n * light\" from the backdrop alone, and then, when the body disagreed, clamped `tintLuma` to the\n * backdrop's mean — the one value that separates from nothing. Light ink over a dark backdrop puts\n * the body at 0.07 against a backdrop of 0.12: already separating, downward, and the clamp pulled\n * it back onto the backdrop. Measured on the default material at presence 0.08: exactly 0.0000 at\n * backdrops of 0.12, 0.20 and 0.35.\n *\n * What the demand is DIVIDED by is deliberately the distance to the tint's pole rather than to the\n * body's own tint. Dividing by the latter is arithmetically tighter and asks for far more density\n * wherever the two are close — enough to drive it to the ceiling over a dark backdrop and stop the\n * glass being a window at all, which check:optics says plainly. Presence is a floor on visibility,\n * not a licence to go opaque.\n */\nexport function withPresence(body: GlassBody, optics: VireGlassOptics, sample: BodyBackdrop): GlassBody {\n if (optics.presence <= 0) return body;\n const mean = clamp(sample.luma, 0, 1);\n // Whichever side the body is already on; with nothing to go on, the side with more room.\n const above = Math.abs(body.tintLuma - mean) > 1e-4 ? body.tintLuma > mean : mean < 0.5;\n const pole = above ? TINT_LIGHT : TINT_DARK;\n const separation = Math.min(optics.presence, Math.abs(pole - mean));\n const reached = Math.abs(body.tintLuma - mean) * body.density;\n if (reached >= separation) return body;\n const needed = separation / Math.max(Math.abs(pole - mean), 1e-4);\n return {\n density: Math.max(body.density, Math.min(needed, BODY.presenceDemand)),\n // Left where the tint law put it, unless it landed exactly on the backdrop — which is the\n // case that used to be created here rather than avoided.\n tintLuma: Math.abs(body.tintLuma - mean) > 1e-4 ? body.tintLuma : pole,\n };\n}\n","// System accessibility on the web (docs/reference.md §9). The three settings the reference names\n// all have media queries, so nothing here has to be asked of the host: the browser already knows.\n//\n// `reduceMotion` leaves optics alone — it is about motion, and motion is computed by the\n// deformation model, which takes it as `elastic: false`. The element keeps answering a finger; it\n// stops springing and rippling.\nimport { NO_ACCESSIBILITY, type VireGlassAccessibility } from '../accessibility';\n\nconst QUERIES = {\n reduceTransparency: '(prefers-reduced-transparency: reduce)',\n increaseContrast: '(prefers-contrast: more)',\n reduceMotion: '(prefers-reduced-motion: reduce)',\n} as const;\n\nfunction matches(query: string): boolean {\n if (typeof matchMedia !== 'function') return false;\n try {\n return matchMedia(query).matches;\n } catch {\n // An engine that does not know a query throws rather than answering false. Not knowing it is\n // an answer of \"not set\", not a reason to fail.\n return false;\n }\n}\n\nexport function systemAccessibility(): VireGlassAccessibility {\n if (typeof matchMedia !== 'function') return NO_ACCESSIBILITY;\n return {\n reduceTransparency: matches(QUERIES.reduceTransparency),\n increaseContrast: matches(QUERIES.increaseContrast),\n reduceMotion: matches(QUERIES.reduceMotion),\n };\n}\n\n/** Fires whenever any of the three changes. The material has to follow a setting turned on while\n * the page is open, not only one that was on when it loaded. */\nexport function watchAccessibility(onChange: (next: VireGlassAccessibility) => void): () => void {\n if (typeof matchMedia !== 'function') return () => {};\n const lists: MediaQueryList[] = [];\n const handler = () => onChange(systemAccessibility());\n for (const query of Object.values(QUERIES)) {\n try {\n const list = matchMedia(query);\n list.addEventListener('change', handler);\n lists.push(list);\n } catch {\n // Same as above: an unknown query simply has nothing to watch.\n }\n }\n return () => {\n for (const list of lists) list.removeEventListener('change', handler);\n };\n}\n","// Rim light (docs/reference.md §2): a hairline along the silhouette — \"not a band and not a\n// bevel\" — carrying two opposing arcs, the rest of it outlined by a thin dark line, and its colour\n// taken from the environment.\n//\n// Every number here is the lens shader's own. The key-light lobe is `lens-shader.ts` line 375\n// verbatim (exponent 3, opposing arc at 0.45), and the dark edge is its line 528 (a 0.22\n// darkening at the silhouette). The only thing that differs is the primitive: a conic gradient\n// sampled at fixed angles instead of a per-pixel normal.\nimport { RIM } from '../law';\nimport type { VireGlassOptics } from '../material';\n\nconst { lobeExponent: LOBE_EXPONENT, opposingArc: OPPOSING_ARC, darkEdge: DARK_EDGE } = RIM;\n\n/** One stop every 7.5°. Fine enough that a cubic lobe reads as a smooth arc rather than a fan. */\nconst STOPS = 48;\n\n/**\n * Screen space has y pointing down; a CSS conic gradient starts at 12 o'clock and runs clockwise.\n * A point at conic angle φ therefore has outward normal `(sin φ, -cos φ)`, which is what the lobe\n * is measured against.\n */\nexport function lightConicAngle(light: readonly [number, number]): number {\n const [lx, ly] = light;\n const deg = (Math.atan2(lx, -ly) * 180) / Math.PI;\n return (deg + 360) % 360;\n}\n\n/** The shader's key-light lobe, evaluated for a rim point whose normal sits `deltaDeg` away from\n * the light. Both arcs come out of this one expression — that is why they are opposed. */\nexport function rimLobe(deltaDeg: number, specular: number): number {\n const facing = Math.cos((deltaDeg * Math.PI) / 180);\n const front = facing > 0 ? Math.pow(facing, LOBE_EXPONENT) : 0;\n const back = facing < 0 ? Math.pow(-facing, LOBE_EXPONENT) : 0;\n return specular * (front + OPPOSING_ARC * back);\n}\n\nconst clamp01 = (v: number) => (v < 0 ? 0 : v > 1 ? 1 : v);\nconst to255 = (v: number) => Math.round(clamp01(v) * 255);\n\nexport type RimAmbient = readonly [number, number, number];\n\n/**\n * The gradient for the hairline. Colour comes from the environment — \"over a yellow flower the rim\n * is yellow, over sky it is blue\" (§2) — lifted toward white where the key light lands. Away from\n * both arcs only the dark edge remains.\n *\n * The opposing arc carries an iridescent fringe (§2), so `iridescence` pulls its channels apart\n * rather than lifting them together.\n */\nexport function rimGradientCss(\n optics: VireGlassOptics,\n ambient: RimAmbient,\n light: readonly [number, number],\n appear = 1,\n): string {\n const present = clamp01(appear);\n const start = lightConicAngle(light);\n const [ar, ag, ab] = ambient;\n const stops: string[] = [];\n\n for (let i = 0; i <= STOPS; i += 1) {\n const angle = (i / STOPS) * 360;\n const key = rimLobe(angle, optics.specular);\n const facing = Math.cos((angle * Math.PI) / 180);\n // The far arc is where dispersion shows as a fringe; the near one is a clean specular.\n const fringe = facing < 0 ? optics.iridescence * OPPOSING_ARC : 0;\n const lift = clamp01(key * optics.fresnel);\n\n const r = ar + (1 - ar) * clamp01(lift + fringe);\n const g = ag + (1 - ag) * lift;\n const b = ab + (1 - ab) * clamp01(lift - fringe);\n\n // Scaled, not floored: the dark edge is the one part of the rim that survives facing away from\n // the light, so leaving it unscaled leaves a hairline drawn around an element that is not there.\n const alpha = clamp01(DARK_EDGE + lift * (1 - DARK_EDGE)) * present;\n // Below the arcs the line is the dark edge itself, not a dim copy of the environment.\n const colour = lift > 0.001\n ? `rgba(${to255(r)},${to255(g)},${to255(b)},${alpha.toFixed(3)})`\n : `rgba(0,0,0,${alpha.toFixed(3)})`;\n stops.push(`${colour} ${angle.toFixed(1)}deg`);\n }\n\n return `conic-gradient(from ${start.toFixed(1)}deg, ${stops.join(', ')})`;\n}\n\nexport const RIM_WIDTH_PX = RIM.widthPx;\n\n/**\n * The border for increased contrast (§9: elements become \"predominantly black or white\" and are\n * highlighted \"with a contrasting border\").\n *\n * Not a gradient: the two arcs above are a light source reflecting off a curved edge, and under\n * this setting the edge is not reporting where the light is, it is separating the element from\n * everything around it. It has to hold at every angle, including the one facing away from the key\n * light where the ordinary rim falls back to a dim dark line.\n */\nexport function contrastRimCss(bodyLuma: number, rimLuma: number): string {\n const v = to255(rimLuma);\n // Opaque on purpose. A border that lets the backdrop through is the thing this setting exists\n // to replace, and the body behind it is already at its own pole.\n void bodyLuma;\n return `conic-gradient(rgb(${v},${v},${v}) 0deg, rgb(${v},${v},${v}) 360deg)`;\n}\n","// Glass inside glass (docs/reference.md §6). 219 @11:50 puts it among the principles: \"avoid\n// putting [glass] within or on top of other glass elements to maintain hierarchy and prevent\n// clutter.\" S 32:54 (\"Building CNN for iOS 26\") is the same rule reported from the other side, by a\n// team that had already shipped it: \"Applying the glass effect to both a parent and child views led to visual redundancy.\n// Double translucency, layered blur, and unpredictable rendering.\"\n//\n// On this renderer it is not only a matter of hierarchy. `backdrop-filter` samples what is already\n// composited behind the element, so a nested pane's backdrop is the outer pane's OUTPUT: the\n// displacement is applied twice to the same pixels and the two blurs multiply. The inner element\n// does not look like thicker glass, it looks like a mistake.\n//\n// Overlap is a different case and not this function's business — a sheet over a bar is two panes in\n// the stacking order, which is what two panes of glass actually do. Only containment is wrong.\nconst WARNED = new WeakSet<Element>();\n\n/** Set by `attachGlass`; exported so the check does not have to know the attribute's spelling. */\nexport const GLASS_ATTR = 'data-vireglass';\n\nexport function warnIfNested(el: Element): void {\n if (WARNED.has(el)) return;\n const outer = el.parentElement?.closest(`[${GLASS_ATTR}]`);\n if (!outer) return;\n WARNED.add(el);\n // Warned, not refused: where an element sits is the host's layout, and a library that silently\n // declines to render is harder to debug than one that says what is wrong.\n const where = outer.tagName.toLowerCase() + (outer.id ? `#${outer.id}` : '');\n console.warn(\n `vireglass: glass inside glass — this element is a descendant of <${where}>, which is also glass. ` +\n `Its backdrop is the outer element's output, so the refraction is applied twice and the blurs ` +\n `multiply. Put the glass on one of the two.`,\n );\n}\n","// The scroll edge (docs/reference.md §10). Not the material's job but the SCREEN's: it sits over\n// the content beneath a panel, and the glass sees a backdrop that is already dimmed. The rules are\n// the core's (`../scroll-edge`); this attaches them to a real scroller and a real element.\nimport { SCROLL_EDGE } from '../law';\nimport { scrollEdgeStrength, scrollEdgeStyle, type ScrollEdgeStyle } from '../scroll-edge';\n\nexport type ScrollEdgeHandle = { update(): void; destroy(): void };\n\nexport type ScrollEdgeOptions = {\n /** Which edge of the scroller the panel sits at. */\n side?: 'top' | 'bottom';\n /** A view pinned under the panel — column headers — gets a flat band with no gradient (§10). */\n pinned?: boolean;\n /** Ink polarity of the nearest glass, 1 light and 0 dark. The edge style follows it: light ink\n * means dark glass and the content fades into a light dimming; dark ink means the opposite. */\n ink?: () => number;\n};\n\n/**\n * What the effect actually is. 356 @11:32: \"they don't block or darken like overlays.\"\n *\n * So the soft style is a BLUR with a mask, not a painted gradient: the content under the panel\n * goes out of focus into the background, which is what 219 @9:16 means by dissolving it, and\n * nothing is laid over it. The first version of this painted black at 22% down the ramp — an\n * overlay, doing the one thing the reference names as wrong.\n *\n * `dim` is the other soft form and it does carry a tone, because 219 @9:33 asks for one: over dark\n * content the glass turns dark and \"the effect intelligently switches to apply a subtle dimming\n * instead\". Dimming is a reduction in luminance. This painted white, which lightened the content\n * it was supposed to be pushing down.\n */\nexport type EdgePaint = { filter: string; mask: string; tone: string };\n\nexport function paintFor(style: ScrollEdgeStyle, side: 'top' | 'bottom'): EdgePaint {\n const direction = side === 'top' ? 'to top' : 'to bottom';\n if (style === 'hard') {\n // A flat band rather than a gradual fade (219 @9:41), and a stronger boundary (356 @12:12).\n return {\n filter: `blur(${SCROLL_EDGE.hardBlurDp}px)`,\n mask: '',\n tone: `linear-gradient(${direction}, rgba(0,0,0,${SCROLL_EDGE.hardAlpha}) 0 100%)`,\n };\n }\n const ramp = `linear-gradient(${direction}, rgba(0,0,0,1) 0%, rgba(0,0,0,0) 100%)`;\n return {\n filter: `blur(${SCROLL_EDGE.dissolveBlurDp}px)`,\n mask: ramp,\n tone:\n style === 'dim'\n ? `linear-gradient(${direction}, rgba(0,0,0,${SCROLL_EDGE.dimAlpha}) 0%, rgba(0,0,0,0) 100%)`\n : 'none',\n };\n}\n\n/**\n * Paints the edge onto `edgeEl` — an element the host positions along the scroller's edge, under\n * the glass. It is the host's because §10 puts this on the screen, not on the material: the glass\n * must SEE the result, which means the effect has to be behind it in the stack.\n */\nexport function attachScrollEdge(\n scroller: HTMLElement,\n edgeEl: HTMLElement,\n opts: ScrollEdgeOptions = {},\n): ScrollEdgeHandle {\n const side = opts.side ?? 'top';\n let destroyed = false;\n\n function update(): void {\n if (destroyed) return;\n const maxScroll = Math.max(scroller.scrollHeight - scroller.clientHeight, 0);\n const strength = scrollEdgeStrength(side, scroller.scrollTop, maxScroll);\n const inkLight = (opts.ink?.() ?? 1) > 0.5;\n const style = scrollEdgeStyle(inkLight, opts.pinned);\n const paint = paintFor(style, side);\n // The blur is what dissolves the content; the mask is what makes it a ramp rather than a step.\n edgeEl.style.setProperty('backdrop-filter', paint.filter);\n edgeEl.style.setProperty('-webkit-backdrop-filter', paint.filter);\n if (paint.mask) {\n edgeEl.style.setProperty('mask-image', paint.mask);\n edgeEl.style.setProperty('-webkit-mask-image', paint.mask);\n } else {\n edgeEl.style.removeProperty('mask-image');\n edgeEl.style.removeProperty('-webkit-mask-image');\n }\n edgeEl.style.setProperty('background-image', paint.tone);\n edgeEl.style.setProperty('opacity', strength.toFixed(3));\n }\n\n const onScroll = () => update();\n scroller.addEventListener('scroll', onScroll, { passive: true });\n update();\n\n return {\n update,\n destroy() {\n destroyed = true;\n scroller.removeEventListener('scroll', onScroll);\n edgeEl.style.removeProperty('backdrop-filter');\n edgeEl.style.removeProperty('-webkit-backdrop-filter');\n edgeEl.style.removeProperty('mask-image');\n edgeEl.style.removeProperty('-webkit-mask-image');\n edgeEl.style.removeProperty('background-image');\n edgeEl.style.removeProperty('opacity');\n },\n };\n}\n","// A row of glass that agrees with itself.\n//\n// Each element probing on its own is not merely wasteful — it is wrong. Neighbouring pieces of one\n// control sit over slightly different patches of backdrop, reach different polarities, and a tab\n// bar ends up with two light glyphs and two dark ones. §3 is explicit that small elements switch\n// WHOLESALE; a group is what \"wholesale\" means when the element is really four of them.\n//\n// Every decision is the core's (`../group-model`): the lightness plane, the smoothing, the polarity\n// requirement and its hysteresis. This binds them to real elements.\nimport { createGroupState, type GroupPlane } from '../group-model';\nimport { TOUCH } from '../law';\nimport { probeBackdrop } from './probe';\nimport type { BackdropSample } from '../adaptation';\nimport type { GlassHandle } from './index';\n\nexport type GroupEntry = {\n el: HTMLElement;\n handle: GlassHandle;\n /** Set by the group: pass it to this member's own `attachGlass` as `onGlow`. */\n onGlow?: (glow: { pageX: number; pageY: number; strength: number } | null) => void;\n /** How strongly this member needs its ink to stay legible. The strictest in the group wins. */\n legibility?: number;\n};\n\nexport type GlassGroupHandle = {\n /** Re-read every member and settle on one answer for all of them. */\n update(): void;\n /** The polarity the whole group agreed on, 1 light and 0 dark. */\n ink(): number;\n /** The group's current estimate, or null before the first reading. */\n plane(): GroupPlane | null;\n /** Spread a glow from one member to the rest. Members wired through `onGlow` call this for you. */\n carryGlow(from: number, glow: { pageX: number; pageY: number; strength: number } | null): void;\n destroy(): void;\n};\n\nexport type GlassGroupOptions = {\n /** Where a member reads its backdrop. Defaults to the DOM probe. */\n probe?: (el: HTMLElement) => BackdropSample;\n};\n\nexport function createGlassGroup(\n members: readonly GroupEntry[],\n opts: GlassGroupOptions = {},\n): GlassGroupHandle {\n let polarity = 1;\n let destroyed = false;\n\n const state = createGroupState({\n plane: () => {},\n flip: (next) => {\n polarity = next;\n // One flip, everyone at once — that is the whole point of the group.\n for (const { handle } of members) handle.update();\n },\n });\n\n /**\n * \"Starting right under your fingertips, the glow spreads throughout the element and onto any\n * Liquid Glass elements nearby\" (§5, 219 @12:11). The element being touched cannot know who is\n * nearby; the group does.\n */\n function carryGlow(from: number, glow: { pageX: number; pageY: number; strength: number } | null): void {\n members.forEach(({ el, handle }, index) => {\n if (index === from) return;\n if (!glow) {\n handle.setNeighbourGlow(null);\n return;\n }\n const rect = el.getBoundingClientRect();\n const cx = rect.left + rect.width / 2;\n const cy = rect.top + rect.height / 2;\n const reach = (Math.min(rect.width, rect.height) / 2) * TOUCH.glowReach;\n const distance = Math.hypot(glow.pageX - cx, glow.pageY - cy);\n // Falls off with distance and stops: a glow that reached the whole screen would read as the\n // page flashing rather than as light travelling through neighbouring glass.\n const falloff = reach > 0 ? Math.max(0, 1 - distance / reach) : 0;\n handle.setNeighbourGlow(falloff <= 0 ? null : { ...glow, strength: glow.strength * falloff });\n });\n }\n\n /** Wire each member's own touch to the rest of the group. */\n function connect(): void {\n members.forEach((entry, index) => {\n entry.onGlow = (glow) => carryGlow(index, glow);\n });\n }\n\n function update(): void {\n if (destroyed) return;\n const probe = opts.probe ?? probeBackdrop;\n members.forEach(({ el, legibility }, index) => {\n const rect = el.getBoundingClientRect();\n // A member with no box has nothing behind it to read; reporting it anyway would drag the\n // group's estimate toward whatever sits at the page's origin.\n if (rect.width <= 0 || rect.height <= 0) {\n state.release(String(index));\n return;\n }\n state.report(\n String(index),\n rect.left + rect.width / 2,\n rect.top + rect.height / 2,\n probe(el),\n legibility ?? 0,\n );\n });\n }\n\n connect();\n update();\n\n return {\n update,\n ink: () => polarity,\n plane: () => state.plane(),\n carryGlow,\n destroy() {\n destroyed = true;\n carryGlow(-1, null);\n members.forEach((_, index) => state.release(String(index)));\n },\n };\n}\n","// The third VireGlass renderer: refracts LIVE DOM via `backdrop-filter: url(#svg-filter)` with an\n// `feDisplacementMap`, instead of drawing its own backdrop like the WebGL2 and AGSL renderers do.\n//\n// Everything is derived from the same model the shaders read, and where a law already exists in\n// the core or in the shader text, this mirrors it rather than restating it: the rim's two arcs are\n// the lens's own key-light lobe, the shadow is `shadowOpacityFrom`, dispersion is the shader's\n// per-channel index shift, and the finger response is `createDeform` driving the same `touchWarp`.\n//\n// Even the spectral edge, which looked impossible: a filter graph cannot evaluate a function per\n// pixel, but it can MULTIPLY by an image, so diffraction and interference are baked into one and\n// applied with an arithmetic composite.\n// See `docs/superpowers/specs/2026-09-19-vireglass-over-live-dom.md` for the technique and the\n// three findings that make it work (objectBoundingBox, prefiltering the source, the 8-bit step).\nimport { ambientFrom, INK_DARK, INK_LIGHT, shouldInkBeLight, type BackdropSample } from '../adaptation';\nimport { buildDisplacementMap } from './displacement';\nimport { buildSpectralMap, hasSpectralEdge, type SpectralMap } from './spectral-map';\nimport { cached } from './map-cache';\nimport { roundedRectGeometry, type VireGlassGeometry } from '../geometry';\nimport { resolveOptics, VIREGLASS_MATERIAL, type VireGlassMaterial, type VireGlassOptics } from '../material';\nimport { probeBackdrop } from './probe';\nimport { supportsSvgBackdropFilter } from './support';\nimport { boxShadowCss } from './shadow';\nimport { resolveBody, withPresence } from './body';\nimport { systemAccessibility, watchAccessibility } from './preferences';\nimport { applyAccessibility, contrastRimLuma, elasticAllowed, type VireGlassAccessibility } from '../accessibility';\nimport { applyGlassScale, GLASS_SCALE_DEFAULT } from '../glass-scale';\nimport { applyAppear } from '../appear';\nimport { accentAmount, accentTone } from '../accent';\nimport type { VireGlassAccent } from '../adapters';\nimport { concentricRadius } from '../concentric';\nimport { RIM_WIDTH_PX, contrastRimCss, rimGradientCss } from './rim';\nimport { GLASS_ATTR, warnIfNested } from './nesting';\nimport { REST_LIGHT } from '../adapters';\nimport { refractionStrength } from '../optics';\nimport { DISPERSION, TOUCH } from '../law';\nimport type { MorphShape } from '../sdf';\nimport { createDeform, raiseIntoGlass, type DeformSample } from '../touch-response';\nimport { halfMinDp, MAX_STRETCH } from '../geometry';\n\nexport * from './support';\nexport * from './probe';\nexport * from './displacement';\nexport * from './rim';\nexport * from './shadow';\nexport * from './body';\nexport * from './preferences';\nexport * from './scroll-edge';\nexport * from './group';\nexport * from './spectral-map';\nexport * from './map-cache';\n\nconst SVG_NS = 'http://www.w3.org/2000/svg';\nconst FILTER_HOST_ATTR = 'data-vireglass-filters';\n\nlet filterCounter = 0;\n\n/** Live instances keyed by element, so a second attach can retire the first rather than orphan\n * its filter. Weak: a detached element takes its entry with it. */\nconst attached = new WeakMap<HTMLElement, GlassHandle>();\n\nconst TOUCH_RADIUS_FRACTION = TOUCH.radiusOfHalfSize;\n\nconst WAVE_OF_TRAVEL = TOUCH.waveOfTravel;\nconst RELEASE_WAVE = TOUCH.releaseWave;\n\nfunction waveImpulse(g: VireGlassGeometry): number {\n return halfMinDp(g) * MAX_STRETCH * WAVE_OF_TRAVEL;\n}\n\nconst STYLE_ATTR = 'data-vireglass-styles';\n\n\n/**\n * The hairline rim (docs/reference.md §2) needs a layer of its own over the element. A stylesheet\n * rule on `::after` keeps it out of the host's markup — injecting a child node would fight any\n * framework that owns these children.\n *\n * The mask pair is what makes it a ring rather than a fill: the same box painted twice, once\n * clipped to the content box, composited so only the padding band survives.\n */\n/**\n * Where the filter and the rim styles go.\n *\n * `backdrop-filter: url(#id)` resolves the reference in the element's OWN tree. From inside a\n * shadow root, a filter parked on the page is not found — and the failure is silent, because the\n * reference is valid CSS: the element gets no backdrop at all, not even the blur fallback. A\n * widget in a shadow root (which is how you survive a page full of global `!important`) came out\n * with no material whatsoever.\n *\n * So the host is the element's own root node, which is the shadow root when there is one and the\n * document otherwise. Nothing to configure and nothing to get wrong.\n */\nfunction hostFor(el: Element): Document | ShadowRoot {\n const root = el.getRootNode();\n return root instanceof ShadowRoot ? root : el.ownerDocument ?? document;\n}\n\n/** A shadow root has no `<head>`; a style element goes straight into it. */\nfunction styleParent(host: Document | ShadowRoot): Node {\n return host instanceof ShadowRoot ? host : host.head;\n}\n\nfunction ensureRimStyles(host: Document | ShadowRoot): void {\n if (host.querySelector(`style[${STYLE_ATTR}]`)) return;\n const style = document.createElement('style');\n style.setAttribute(STYLE_ATTR, '');\n style.textContent =\n `[${GLASS_ATTR}]::after{content:'';position:absolute;inset:0;border-radius:inherit;pointer-events:none;padding:var(--vireglass-rim-width,1px);background:var(--vireglass-rim,none);-webkit-mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);-webkit-mask-composite:xor;mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);mask-composite:exclude}` +\n // The touch glow (§5) lights the material from the point of contact. Below the content, above\n // the refraction — it is light inside the glass, not a film over the label.\n `[${GLASS_ATTR}]::before{content:'';position:absolute;inset:0;border-radius:inherit;pointer-events:none;background:var(--vireglass-glow,none);opacity:var(--vireglass-glow-opacity,0)}`;\n styleParent(host).appendChild(style);\n}\n\nfunction getFilterHost(host: Document | ShadowRoot): SVGSVGElement {\n const existing = host.querySelector<SVGSVGElement>(`svg[${FILTER_HOST_ATTR}]`);\n if (existing) return existing;\n const svg = document.createElementNS(SVG_NS, 'svg');\n svg.setAttribute(FILTER_HOST_ATTR, '');\n svg.setAttribute('width', '0');\n svg.setAttribute('height', '0');\n svg.setAttribute('aria-hidden', 'true');\n svg.style.position = 'absolute';\n svg.style.pointerEvents = 'none';\n svg.appendChild(document.createElementNS(SVG_NS, 'defs'));\n // A shadow root takes the svg directly; a document takes it on the body.\n (host instanceof ShadowRoot ? host : host.body).appendChild(svg);\n return svg;\n}\n\n/**\n * Finding #1 (do not re-litigate): `objectBoundingBox` with an explicit unit box. `userSpaceOnUse`\n * measures from something other than the element's own box and the displacement smears across\n * the page instead of staying at the rim.\n */\nfunction buildFilterElement(\n id: string,\n mapUrl: string,\n optics: VireGlassOptics,\n scale: number,\n spectral: SpectralMap | null,\n): SVGFilterElement {\n const filter = document.createElementNS(SVG_NS, 'filter');\n filter.setAttribute('id', id);\n filter.setAttribute('filterUnits', 'objectBoundingBox');\n filter.setAttribute('x', '0');\n filter.setAttribute('y', '0');\n filter.setAttribute('width', '1');\n filter.setAttribute('height', '1');\n // Without this the spec's default is linearRGB: the browser gamma-linearises the map's bytes\n // before reading them, so 128 stops meaning \"no shift\" and the flat middle of the glass drifts\n // by several pixels. Measured at ~57px of spurious displacement at scale 200.\n filter.setAttribute('color-interpolation-filters', 'sRGB');\n\n const feImage = document.createElementNS(SVG_NS, 'feImage');\n feImage.setAttribute('href', mapUrl);\n feImage.setAttribute('preserveAspectRatio', 'none');\n feImage.setAttribute('result', 'map');\n\n // Finding #2: prefiltering the source before displacement. This is `roughness`, not a hack —\n // without it, fine texture (1px diagonals) resamples into chevrons under the displacement.\n const feBlur = document.createElementNS(SVG_NS, 'feGaussianBlur');\n feBlur.setAttribute('in', 'SourceGraphic');\n feBlur.setAttribute('stdDeviation', String(Math.max(optics.blur, 0)));\n feBlur.setAttribute('result', 'blurred');\n\n filter.append(feImage, feBlur);\n\n // DISPERSION (docs/reference.md §1, and `lens-shader.ts` lines 283–284 for the law): the channels\n // refract at different indices — red at `ior - 0.4 * iorSpread`, blue at `ior + 0.6 * iorSpread`,\n // green at the base. One displacement pass cannot do that, so each channel gets its own and they\n // are summed back. Three passes instead of one, so it only runs when the spread is worth paying\n // for.\n const spread = optics.iorSpread;\n if (spread > 1e-4) {\n const base = refractionStrength(optics.ior);\n const ratio = (shift: number) => (base > 0 ? refractionStrength(optics.ior + shift) / base : 1);\n const channels: Array<[string, number, string]> = [\n ['dR', scale * ratio(DISPERSION.redShift * spread), '1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0'],\n ['dG', scale, '0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0'],\n ['dB', scale * ratio(DISPERSION.blueShift * spread), '0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0'],\n ];\n for (const [name, chScale, matrix] of channels) {\n const pass = document.createElementNS(SVG_NS, 'feDisplacementMap');\n pass.setAttribute('in', 'blurred');\n pass.setAttribute('in2', 'map');\n pass.setAttribute('scale', String(chScale));\n pass.setAttribute('xChannelSelector', 'R');\n pass.setAttribute('yChannelSelector', 'G');\n pass.setAttribute('result', `${name}raw`);\n // Each channel displaces by its own share of the base scale. The share is stored on the\n // element itself: under a press the scale is recomputed every frame, with nowhere else to\n // recover the shares from.\n pass.setAttribute('data-vireglass-ratio', String(scale > 0 ? chScale / scale : 1));\n const only = document.createElementNS(SVG_NS, 'feColorMatrix');\n only.setAttribute('in', `${name}raw`);\n only.setAttribute('type', 'matrix');\n only.setAttribute('values', matrix);\n only.setAttribute('result', name);\n filter.append(pass, only);\n }\n // Arithmetic add, not a blend: every channel is isolated, so the sum is the recombined colour.\n // Alpha stays at 1 on all three and clamps, which is what an opaque backdrop wants.\n const rg = document.createElementNS(SVG_NS, 'feComposite');\n rg.setAttribute('in', 'dR');\n rg.setAttribute('in2', 'dG');\n rg.setAttribute('operator', 'arithmetic');\n rg.setAttribute('k1', '0');\n rg.setAttribute('k2', '1');\n rg.setAttribute('k3', '1');\n rg.setAttribute('k4', '0');\n rg.setAttribute('result', 'dRG');\n const rgb = document.createElementNS(SVG_NS, 'feComposite');\n rgb.setAttribute('in', 'dRG');\n rgb.setAttribute('in2', 'dB');\n rgb.setAttribute('operator', 'arithmetic');\n rgb.setAttribute('k1', '0');\n rgb.setAttribute('k2', '1');\n rgb.setAttribute('k3', '1');\n rgb.setAttribute('k4', '0');\n rgb.setAttribute('result', 'refracted');\n filter.append(rg, rgb);\n return withSpectral(filter, spectral);\n }\n\n const feDisplace = document.createElementNS(SVG_NS, 'feDisplacementMap');\n feDisplace.setAttribute('in', 'blurred');\n feDisplace.setAttribute('in2', 'map');\n feDisplace.setAttribute('scale', String(scale));\n feDisplace.setAttribute('xChannelSelector', 'R');\n feDisplace.setAttribute('yChannelSelector', 'G');\n feDisplace.setAttribute('result', 'refracted');\n filter.append(feDisplace);\n return withSpectral(filter, spectral);\n}\n\n/**\n * Multiplies the refracted frame by the baked hue (docs/reference.md §1). `feComposite` in\n * arithmetic mode with `k1` is a per-pixel product, which is the only way a filter graph can apply\n * a function of position. The headroom the bake divided by is multiplied back here.\n */\nfunction withSpectral(filter: SVGFilterElement, spectral: SpectralMap | null): SVGFilterElement {\n if (!spectral) return filter;\n const image = document.createElementNS(SVG_NS, 'feImage');\n image.setAttribute('href', spectral.url);\n image.setAttribute('preserveAspectRatio', 'none');\n image.setAttribute('result', 'hue');\n const product = document.createElementNS(SVG_NS, 'feComposite');\n product.setAttribute('in', 'refracted');\n product.setAttribute('in2', 'hue');\n product.setAttribute('operator', 'arithmetic');\n product.setAttribute('k1', String(spectral.headroom));\n product.setAttribute('k2', '0');\n product.setAttribute('k3', '0');\n product.setAttribute('k4', '0');\n filter.append(image, product);\n return filter;\n}\n\nfunction measureGeometry(el: HTMLElement): VireGlassGeometry {\n const rect = el.getBoundingClientRect();\n // Uniform corner radius only, matching `VireGlassGeometry` itself — a per-corner or elliptical\n // radius isn't modeled by any renderer in this package.\n const radius = parseFloat(getComputedStyle(el).borderTopLeftRadius) || 0;\n return roundedRectGeometry(rect.width, rect.height, radius);\n}\n\nfunction devicePixelRatio(): number {\n return typeof window !== 'undefined' && window.devicePixelRatio ? window.devicePixelRatio : 1;\n}\n\n/**\n * No SVG filter reference support (Firefox, older Safari): a real path, not a stub — the Android\n * renderer degrades to an affine magnifier below API 33 and that's documented as normal too. Blur\n * and saturation stand in for refraction's optical effect; the tint carries what refraction can't:\n * a body of glass, not just a smudge over whatever's behind it.\n */\nfunction fallbackFilterCss(optics: VireGlassOptics): string {\n const blurPx = Math.max(optics.blur, 1.5);\n const saturate = 1 + optics.colorPickup;\n return `blur(${blurPx}px) saturate(${saturate})`;\n}\n\nconst to255 = (v: number) => Math.round(Math.min(Math.max(v, 0), 1) * 255);\n\nfunction rgbCss(r: number, g: number, b: number): string {\n return `rgb(${to255(r)} ${to255(g)} ${to255(b)})`;\n}\n\n/**\n * The body, from the model's own law (`./body`, ported from the lens shader §3): density is what\n * legibility and presence demand over THIS backdrop, `tintLuma` is the lightness it tints toward,\n * and the hue is the surroundings' — glass has no colour of its own, only the colour of what lies\n * beneath it. A flat fill in place of a tint is what breaks the material.\n */\nfunction bodyCss(\n optics: VireGlassOptics,\n sample: BackdropSample,\n ink: number,\n accent?: VireGlassAccent,\n): string {\n const body = withPresence(resolveBody(optics, sample, ink), optics, sample);\n\n // A tinted element takes its colour from the accent rather than from its surroundings, but it is\n // still the MEDIUM that is coloured: the amount stays short of one so the content keeps coming\n // through. A fill at full opacity is the thing §7 says breaks the material.\n if (accent) {\n const [r, g, b] = accentTone(accent.color, sample.luma);\n const amount = Math.max(accentAmount(accent), body.density);\n return `rgba(${to255(r)}, ${to255(g)}, ${to255(b)}, ${amount.toFixed(3)})`;\n }\n\n const [r, g, b] = ambientFrom(sample);\n const hue = (c: number) => body.tintLuma + (c - body.tintLuma) * optics.colorPickup;\n return `rgba(${to255(hue(r))}, ${to255(hue(g))}, ${to255(hue(b))}, ${body.density.toFixed(3)})`;\n}\n\nexport type AttachGlassOptions = {\n material?: Partial<VireGlassMaterial>;\n /** Defaults to the element's measured box (size + `border-radius`). */\n geometry?: VireGlassGeometry;\n /** Key-light direction in screen space; defaults to the light at rest. */\n light?: readonly [number, number];\n /** Whether `attachGlass` writes `box-shadow` itself. Turn it off if the host owns that property —\n * is always emitted either way. */\n shadow?: boolean;\n /**\n * The user's clear-to-tinted preference (§3). iOS 27 made it continuous and apps get it without\n * recompiling, so the material has to stay usable across the WHOLE range, not at one point.\n */\n scale?: number;\n /** System accessibility (§9). Read from the browser's own media queries unless supplied. */\n accessibility?: VireGlassAccessibility;\n /**\n * Tint for a primary action (§7). A colour that belongs to the medium, generating a range of\n * tones from the backdrop's brightness — not a fill. Use it on the one element that should stand\n * out: \"when every element is tinted, nothing stands out\" (219 @17:31).\n */\n accent?: VireGlassAccent;\n /** Initial presence, 0 to 1 (§1). Defaults to fully present. */\n appear?: number;\n /**\n * `'interactive'` is glass that is not there until it is touched (S 42:34, \"Building Tide Guide\"): \"this effect doesn't\n * change the appearance of a view until you interact with it... as you start sliding it, the\n * interactive effect adds a soft, subtle highlight\". The element carries no material at rest and\n * materialises under the finger — §1's materialising, driven by touch instead of by the host.\n *\n * It is what makes glass usable on a control that is not chrome: a slider thumb, a chart scrubber,\n * a card. Permanent glass there would be glass in the content layer, which §6 says to avoid.\n */\n variant?: 'present' | 'interactive';\n /** Called while this element is being touched, so a group can carry the glow to its neighbours\n * (§5). Wired for you by `createGlassGroup`. */\n onGlow?: (glow: { pageX: number; pageY: number; strength: number } | null) => void;\n /** Pointer response (§5). On by default. */\n interactive?: boolean;\n /** Overrides the probe entirely — images and video are invisible to it, and the host app\n * already knows its own cover-art accent. */\n sample?: BackdropSample;\n};\n\n/**\n * Shapes this element flows into (docs/reference.md §5): merging with a neighbour, or splitting\n * into parts across two bridges. Offsets and sizes are CSS px relative to this element's centre.\n *\n * `smoothing` is the width of the bridge — zero leaves the element alone. What each shape MEANS\n * (a menu growing out of its button, a control breaking into segments) is the host's choreography;\n * the material only knows how two silhouettes join.\n */\nexport type GlassMorph = {\n smoothing: number;\n shape?: MorphShape;\n shape2?: MorphShape;\n /**\n * Any number of shapes flowing into this one. Several independent elements becoming one whole is\n * the behaviour; how many of them there are is the host's business, and it used to be the\n * material's — the count lived in the field NAMES, so a fourth element had nowhere to go.\n *\n * `shape` and `shape2` still work and come first.\n */\n shapes?: readonly MorphShape[];\n};\n\nexport type GlassHandle = {\n update(): void;\n /**\n * How present the material is, 0 to 1 (docs/reference.md §1). Drive this to bring glass in and\n * out — NOT opacity. \"Instead of fading, Liquid Glass objects materialize in and out by\n * gradually modulating the light bending and lensing\" (219 @2:55). A faded element shows the\n * backdrop through a veil; one that is still arriving shows it undistorted.\n */\n setAppear(t: number): void;\n /** Tint the element, or clear it with null (§7). */\n setAccent(accent: VireGlassAccent | null): void;\n /** A glow that started on a neighbour, in page coordinates (§5). Null clears it. */\n setNeighbourGlow(glow: { pageX: number; pageY: number; strength: number } | null): void;\n setMorph(morph: GlassMorph | null): void;\n destroy(): void;\n};\n\nexport function attachGlass(el: HTMLElement, opts: AttachGlassOptions = {}): GlassHandle {\n if (typeof document === 'undefined') {\n throw new Error('vireglass/dom: attachGlass requires a browser DOM');\n }\n\n // One live instance per element. Re-attaching without destroying the previous handle used to\n // leave its filter in the shared <defs> forever, unreferenced, while the element quietly moved\n // to the new id.\n attached.get(el)?.destroy();\n\n const id = `vireglass-filter-${(filterCounter += 1)}`;\n const svgSupported = supportsSvgBackdropFilter();\n let wasLight = (opts.material?.ink ?? VIREGLASS_MATERIAL.ink) > 0.5;\n let filterEl: SVGFilterElement | null = null;\n let destroyed = false;\n let mapKey = '';\n let morph: GlassMorph | null = null;\n const onlyWhenTouched = opts.variant === 'interactive';\n let appear = onlyWhenTouched ? 0 : (opts.appear ?? 1);\n let accent = opts.accent;\n // Read once at attach, then followed: a setting turned on while the page is open has to reach\n // the material, not wait for a reload.\n let a11y = systemAccessibility();\n const stopWatchingA11y = watchAccessibility((next) => {\n a11y = next;\n mapKey = '';\n deform.setElastic(elasticAllowed(opts.accessibility ?? a11y));\n apply();\n });\n\n warnIfNested(el);\n\n // The element's own tree: a shadow root when it is in one, the document otherwise.\n const host = hostFor(el);\n ensureRimStyles(host);\n el.setAttribute(GLASS_ATTR, '');\n // `inset: 0` on the rim needs a positioned ancestor. Only taken over when the host left it at\n // the initial value, and put back on destroy.\n const positionWasStatic = getComputedStyle(el).position === 'static';\n if (positionWasStatic) el.style.setProperty('position', 'relative');\n\n /**\n * Causes to effects, then the user's scale, then accessibility — in that order. §9 is explicit\n * that a system setting outranks the material preset: even a transparent preset moves to the\n * edge of the scale under increased contrast, because the user needs contrast more than they\n * need the aesthetic.\n */\n function optics(patch?: Partial<VireGlassMaterial>): VireGlassOptics {\n const base = resolveOptics(patch ?? opts.material);\n const scaled = applyGlassScale(base, opts.scale ?? GLASS_SCALE_DEFAULT);\n const settled = applyAccessibility(scaled, opts.accessibility ?? a11y);\n // Appearance last, and by modulating the lens rather than by fading the element: §1 is\n // explicit that opacity is the wrong instrument for this.\n return applyAppear(settled, appear);\n }\n\n function morphState() {\n if (!morph) return {};\n return { smoothing: morph.smoothing, morph: morph.shape, morph2: morph.shape2, morphs: morph.shapes };\n }\n\n function morphKey(): string {\n if (!morph) return '0';\n const part = (s?: MorphShape) =>\n s ? `${s.offsetX},${s.offsetY},${s.width},${s.height},${s.cornerRadius}` : '-';\n return `${morph.smoothing}/${part(morph.shape)}/${part(morph.shape2)}`;\n }\n\n function apply(): void {\n if (destroyed) return;\n const geometry = opts.geometry ?? measureGeometry(el);\n const opticsNow = optics();\n const sample = opts.sample ?? probeBackdrop(el);\n\n if (svgSupported) {\n // The map depends only on geometry, optics and density — never on the backdrop. Rebuilding\n // it on every scroll would re-run a per-pixel loop and a PNG encode for a picture that did\n // not change; the refraction itself updates in the compositor with no JS at all.\n const key = `a${appear.toFixed(3)}|m${morphKey()}|${geometry.width}x${geometry.height}r${geometry.cornerRadius}@${devicePixelRatio()}:${opticsNow.refraction}:${opticsNow.refractionScale}:${opticsNow.bevelDp}:${opticsNow.blur}`;\n if (key !== mapKey || !filterEl) {\n // Keyed by exactly what the maps are functions of, which is exactly the cache key above.\n const map = cached(`d|${key}`, () => buildDisplacementMap(opticsNow, geometry, devicePixelRatio(), morphState()));\n const defs = getFilterHost(host).querySelector('defs') as SVGDefsElement;\n const hue = hasSpectralEdge(opticsNow)\n ? cached(`h|${key}`, () => buildSpectralMap(opticsNow, geometry, devicePixelRatio()))\n : null;\n const next = buildFilterElement(id, map.url, opticsNow, map.scale, hue);\n if (filterEl?.parentNode) defs.replaceChild(next, filterEl);\n else defs.appendChild(next);\n filterEl = next;\n mapKey = key;\n }\n el.style.setProperty('backdrop-filter', `url(#${id})`);\n el.style.setProperty('-webkit-backdrop-filter', `url(#${id})`);\n } else {\n el.style.setProperty('backdrop-filter', fallbackFilterCss(opticsNow));\n el.style.setProperty('-webkit-backdrop-filter', fallbackFilterCss(opticsNow));\n el.style.backgroundColor = bodyCss(opticsNow, sample, wasLight ? 1 : 0, accent);\n }\n\n const light = shouldInkBeLight(sample, wasLight);\n wasLight = light;\n const [tr, tg, tb] = ambientFrom(sample);\n el.style.setProperty('--vireglass-ink', light ? '1' : '0');\n el.style.setProperty('--vireglass-tint', `${tr} ${tg} ${tb}`);\n el.style.setProperty('--vireglass-body-density', String(opticsNow.bodyDensity));\n\n // The raw numbers above are the model's own values; these are the same thing in a form CSS\n // can actually consume. Without them a host has to convert in script, which is the work this\n // renderer exists to do.\n const inkLevel = Math.round((light ? INK_LIGHT : INK_DARK) * 255);\n el.style.setProperty('--vireglass-ink-color', `rgb(${inkLevel} ${inkLevel} ${inkLevel})`);\n el.style.setProperty('--vireglass-tint-color', rgbCss(tr, tg, tb));\n el.style.setProperty('--vireglass-body-color', bodyCss(opticsNow, sample, light ? 1 : 0, accent));\n\n // Rim and shadow follow the SAMPLE, not just the geometry, so they sit outside the map's\n // cache key: the environment they take their colour and density from moves under a scroll\n // while the silhouette does not.\n // §9: under increased contrast the hairline stops reporting where the light is and starts\n // separating the element from what is behind it, so it is measured from the body, not the\n // environment.\n const pole = withPresence(resolveBody(opticsNow, sample, light ? 1 : 0), opticsNow, sample).tintLuma;\n el.style.setProperty(\n '--vireglass-rim',\n (opts.accessibility ?? a11y).increaseContrast\n ? contrastRimCss(pole, contrastRimLuma(pole))\n : rimGradientCss(opticsNow, [tr, tg, tb], opts.light ?? REST_LIGHT, appear),\n );\n el.style.setProperty('--vireglass-rim-width', `${RIM_WIDTH_PX}px`);\n\n // §11: a rounded child inside glass has to be concentric with it, or the two curves fight.\n // Emitted rather than applied — the inset is the host's, and CSS can do the arithmetic.\n el.style.setProperty('--vireglass-radius', `${geometry.cornerRadius}px`);\n el.style.setProperty('--vireglass-radius-min', `${concentricRadius(geometry.cornerRadius, geometry.cornerRadius, 0)}px`);\n\n const shadow = boxShadowCss(geometry, sample, appear);\n el.style.setProperty('--vireglass-shadow', shadow);\n if (opts.shadow !== false) el.style.setProperty('box-shadow', shadow);\n }\n\n apply();\n\n // INTERACTION (docs/reference.md §5). The physics is the core's — `createDeform` carries the\n // spring, the press attack and the wave, at its own fixed step. What lives here is only the\n // plumbing: pointer in, map and glow out.\n const deform = createDeform({ elastic: elasticAllowed(opts.accessibility ?? a11y) });\n let frame: number | null = null;\n let lastFrameAt = 0;\n let interacting = false;\n\n function localPoint(e: PointerEvent): [number, number] {\n const rect = el.getBoundingClientRect();\n return [e.clientX - rect.left - rect.width / 2, e.clientY - rect.top - rect.height / 2];\n }\n\n function paintInteraction(sampleOut: DeformSample): void {\n const geometry = opts.geometry ?? measureGeometry(el);\n const base = optics();\n // Under the finger a matte control stops being frosted and becomes a lens (§5, M 4:10–4:30).\n const rise = raiseIntoGlass(sampleOut.press);\n // The same chain as at rest — the user's scale and the system's settings do not stop\n // applying because a finger is down.\n const risen = optics({ ...opts.material, roughness: (opts.material?.roughness ?? VIREGLASS_MATERIAL.roughness) * rise.solid });\n\n // A reduced-resolution map while the finger is down: `feImage` stretches it over the element\n // regardless, the displacement is smooth, and a full device-pixel rebuild plus a PNG encode\n // every frame does not hold a frame budget.\n const map = buildDisplacementMap(risen, geometry, interacting ? 1 : devicePixelRatio(), {\n ...morphState(),\n touch: {\n x: sampleOut.touchX,\n y: sampleOut.touchY,\n pullX: sampleOut.pullX,\n pullY: sampleOut.pullY,\n press: sampleOut.press,\n radius: halfMinDp(geometry) * TOUCH_RADIUS_FRACTION,\n waveAmp: sampleOut.waveAmp,\n wavePhase: sampleOut.wavePhase,\n },\n });\n if (filterEl) {\n const feImage = filterEl.querySelector('feImage');\n feImage?.setAttribute('href', map.url);\n // EVERY pass, not the first. With dispersion there are three at different scales, and\n // querySelector returned only red: under a finger it got the undispersed scale while green\n // and blue kept their attach-time values, and the coloured rim stopped following the finger.\n for (const pass of filterEl.querySelectorAll('feDisplacementMap')) {\n const ratio = Number(pass.getAttribute('data-vireglass-ratio') ?? 1);\n pass.setAttribute('scale', String(map.scale * (Number.isFinite(ratio) ? ratio : 1)));\n }\n }\n mapKey = '';\n\n paintGlow(sampleOut.touchX, sampleOut.touchY, sampleOut.active * base.edgeLight, geometry);\n\n // \"the glow spreads throughout the element and onto any Liquid Glass elements NEARBY\" (§5,\n // 219 @12:11). This element cannot know who is nearby; the group does, so it is told.\n const rect = el.getBoundingClientRect();\n opts.onGlow?.({\n pageX: rect.left + rect.width / 2 + sampleOut.touchX,\n pageY: rect.top + rect.height / 2 + sampleOut.touchY,\n strength: sampleOut.active,\n });\n }\n\n /**\n * The glow is a CONCENTRATION of the surroundings, not the glass's own whiteness: over a dark\n * backdrop the element lightens but never turns white, and ink over it stays legible.\n *\n * `x` and `y` are relative to the element's centre and may fall outside it — a glow that started\n * next door still has a direction, and dropping it to the centre would make a neighbour brighten\n * uniformly rather than from the side the finger is on.\n */\n function paintGlow(x: number, y: number, strength: number, geometry: VireGlassGeometry): void {\n if (strength <= 0.001) {\n el.style.setProperty('--vireglass-glow-opacity', '0');\n return;\n }\n const [gr, gg, gb] = ambientFrom(opts.sample ?? probeBackdrop(el));\n const cx = ((x + geometry.width / 2) / geometry.width) * 100;\n const cy = ((y + geometry.height / 2) / geometry.height) * 100;\n const reach = halfMinDp(geometry) * TOUCH_RADIUS_FRACTION;\n el.style.setProperty(\n '--vireglass-glow',\n `radial-gradient(circle ${reach.toFixed(0)}px at ${cx.toFixed(1)}% ${cy.toFixed(1)}%, rgba(${to255(gr)},${to255(gg)},${to255(gb)},1) 0%, rgba(${to255(gr)},${to255(gg)},${to255(gb)},0) 100%)`,\n );\n el.style.setProperty('--vireglass-glow-opacity', strength.toFixed(3));\n }\n\n function tick(now: number): void {\n if (destroyed) return;\n const dt = lastFrameAt ? (now - lastFrameAt) / 1000 : 1 / 60;\n lastFrameAt = now;\n deform.step(dt);\n const s = deform.sample();\n // The interactive variant materialises with the touch rather than being held present. `active`\n // rather than `press`: press is the depth of the dent, active is simply whether a finger is\n // there, and the material arriving has to track the second.\n if (onlyWhenTouched) appear = s.active;\n paintInteraction(s);\n if (deform.idle()) {\n interacting = false;\n frame = null;\n lastFrameAt = 0;\n // Settled: put the full-resolution map back and drop the glow.\n el.style.setProperty('--vireglass-glow-opacity', '0');\n opts.onGlow?.(null);\n apply();\n return;\n }\n frame = requestAnimationFrame(tick);\n }\n\n function run(): void {\n if (frame === null && !destroyed) frame = requestAnimationFrame(tick);\n }\n\n let grabX = 0;\n let grabY = 0;\n\n function onDown(e: PointerEvent): void {\n const [x, y] = localPoint(e);\n const geometry = opts.geometry ?? measureGeometry(el);\n interacting = true;\n grabX = x;\n grabY = y;\n // Pointer capture, or a drag that leaves the element stops reporting and the deformation\n // freezes mid-pull with the finger still down.\n el.setPointerCapture?.(e.pointerId);\n deform.grab(x, y, waveImpulse(geometry));\n run();\n }\n function onMove(e: PointerEvent): void {\n if (!interacting) return;\n const [x, y] = localPoint(e);\n const geometry = opts.geometry ?? measureGeometry(el);\n // `drag` takes the travel FROM the grab point, and saturates it against the limit itself.\n deform.drag(x - grabX, y - grabY, halfMinDp(geometry) * MAX_STRETCH);\n run();\n }\n function onUp(e?: PointerEvent): void {\n if (!interacting) return;\n const geometry = opts.geometry ?? measureGeometry(el);\n if (e) el.releasePointerCapture?.(e.pointerId);\n // Lifting throws a second, weaker ring (§5) — the core caps the sum, so this only has to be\n // the smaller impulse.\n deform.release(waveImpulse(geometry) * RELEASE_WAVE);\n run();\n }\n\n if (opts.interactive !== false) {\n el.addEventListener('pointerdown', onDown);\n el.addEventListener('pointermove', onMove);\n el.addEventListener('pointerup', onUp);\n el.addEventListener('pointercancel', onUp);\n el.addEventListener('pointerleave', onUp);\n }\n\n // The \"listener\" `destroy()` has to remove: geometry defaults to the measured box, so a resize\n // of the element itself has to rebuild the map, or the displacement drifts from the element's\n // actual silhouette as soon as its layout changes.\n let resizeObserver: ResizeObserver | null = null;\n if (!opts.geometry && typeof ResizeObserver !== 'undefined') {\n resizeObserver = new ResizeObserver(() => apply());\n resizeObserver.observe(el);\n }\n\n function destroy(): void {\n destroyed = true;\n stopWatchingA11y();\n if (attached.get(el) === handle) attached.delete(el);\n if (frame !== null) cancelAnimationFrame(frame);\n frame = null;\n el.removeEventListener('pointerdown', onDown);\n el.removeEventListener('pointermove', onMove);\n el.removeEventListener('pointerup', onUp);\n el.removeEventListener('pointercancel', onUp);\n el.removeEventListener('pointerleave', onUp);\n el.style.removeProperty('--vireglass-glow');\n el.style.removeProperty('--vireglass-glow-opacity');\n resizeObserver?.disconnect();\n resizeObserver = null;\n if (filterEl?.parentNode) filterEl.parentNode.removeChild(filterEl);\n filterEl = null;\n mapKey = '';\n el.style.removeProperty('backdrop-filter');\n el.style.removeProperty('-webkit-backdrop-filter');\n el.style.removeProperty('background-color');\n el.style.removeProperty('--vireglass-ink');\n el.style.removeProperty('--vireglass-tint');\n el.style.removeProperty('--vireglass-body-density');\n el.style.removeProperty('--vireglass-ink-color');\n el.style.removeProperty('--vireglass-tint-color');\n el.style.removeProperty('--vireglass-body-color');\n el.style.removeProperty('--vireglass-rim');\n el.style.removeProperty('--vireglass-rim-width');\n el.style.removeProperty('--vireglass-shadow');\n el.style.removeProperty('--vireglass-radius');\n el.style.removeProperty('--vireglass-radius-min');\n el.style.removeProperty('box-shadow');\n el.removeAttribute(GLASS_ATTR);\n if (positionWasStatic) el.style.removeProperty('position');\n }\n\n const handle: GlassHandle = {\n update: apply,\n setAppear(t) {\n const next = t < 0 ? 0 : t > 1 ? 1 : t;\n if (next === appear) return;\n appear = next;\n apply();\n },\n setAccent(next) {\n accent = next ?? undefined;\n apply();\n },\n setNeighbourGlow(glow) {\n if (destroyed || interacting) return;\n const geometry = opts.geometry ?? measureGeometry(el);\n if (!glow) {\n paintGlow(0, 0, 0, geometry);\n return;\n }\n const rect = el.getBoundingClientRect();\n paintGlow(\n glow.pageX - (rect.left + rect.width / 2),\n glow.pageY - (rect.top + rect.height / 2),\n glow.strength,\n geometry,\n );\n },\n setMorph(next) {\n morph = next && next.smoothing > 0 ? next : null;\n mapKey = '';\n apply();\n },\n destroy,\n };\n attached.set(el, handle);\n return handle;\n}\n"]}
|