@glass-sdk/liquid-glass 0.0.2 → 0.0.3-beta.1

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.
Files changed (146) hide show
  1. package/CHANGELOG.md +124 -0
  2. package/README.md +66 -149
  3. package/dist/core/concentric.js +20 -3
  4. package/dist/core/corner-options.js +12 -0
  5. package/dist/core/corner-path.js +118 -0
  6. package/dist/core/materials.js +264 -32
  7. package/dist/core/optics.js +1 -2
  8. package/dist/core/progressive.js +1 -2
  9. package/dist/core/shape.js +18 -28
  10. package/dist/core/spring.js +5 -10
  11. package/dist/core.js +5 -6
  12. package/dist/dom/backdrop-glass.js +46 -0
  13. package/dist/dom/compose-layers.js +42 -31
  14. package/dist/dom/composited.js +136 -0
  15. package/dist/dom/control-motion.js +58 -47
  16. package/dist/dom/engine.js +1 -2
  17. package/dist/dom/escaped-layers.js +179 -0
  18. package/dist/dom/filter-bounds.js +42 -13
  19. package/dist/dom/filter-budget.js +1 -2
  20. package/dist/dom/filter-chain.js +40 -0
  21. package/dist/dom/filter-groups.js +33 -14
  22. package/dist/dom/filter-paint-root.js +8 -6
  23. package/dist/dom/filter-patch.js +94 -55
  24. package/dist/dom/filter-reach.js +32 -19
  25. package/dist/dom/filter-stages.js +1 -2
  26. package/dist/dom/fixed-shape.js +23 -16
  27. package/dist/dom/foreground.js +16 -17
  28. package/dist/dom/interaction.js +65 -92
  29. package/dist/dom/layout-rect.js +42 -0
  30. package/dist/dom/layout-size.js +28 -0
  31. package/dist/dom/lens-layers.js +250 -136
  32. package/dist/dom/map-encoder.js +16 -13
  33. package/dist/dom/map-encoder.worker.js +2 -3
  34. package/dist/dom/map-encoding.js +49 -12
  35. package/dist/dom/map-image.js +29 -7
  36. package/dist/dom/map-store.js +1 -2
  37. package/dist/dom/maps.js +133 -83
  38. package/dist/dom/material-graph.js +108 -29
  39. package/dist/dom/media-mirror.js +244 -0
  40. package/dist/dom/page-zoom.js +19 -18
  41. package/dist/dom/png.js +1 -2
  42. package/dist/dom/progressive.js +152 -147
  43. package/dist/dom/renderer.js +1 -2
  44. package/dist/dom/sampling-bounds.js +1 -2
  45. package/dist/dom/selection.js +133 -79
  46. package/dist/dom/shape-attributes.js +9 -0
  47. package/dist/dom/shape-effects.js +14 -0
  48. package/dist/dom/shape-geometry.js +3 -0
  49. package/dist/dom/shape-layout.js +115 -116
  50. package/dist/dom/shared-backdrop.js +33 -25
  51. package/dist/dom/specular.js +116 -0
  52. package/dist/dom/ticker.js +28 -19
  53. package/dist/dom/tint-color.js +24 -0
  54. package/dist/dom/warm.js +63 -59
  55. package/dist/dom.js +591 -505
  56. package/dist/gpu/geometry.js +2 -3
  57. package/dist/gpu/maps.js +1109 -7
  58. package/dist/gpu/planes.js +2 -3
  59. package/dist/gpu.js +66 -64
  60. package/dist/index.js +12 -10
  61. package/dist/react/button.js +12 -11
  62. package/dist/react/color-picker.js +199 -0
  63. package/dist/react/control-thumb.js +4 -5
  64. package/dist/react/menu.js +82 -111
  65. package/dist/react/merged-ref.js +1 -2
  66. package/dist/react/progressive.js +1 -2
  67. package/dist/react/scene.js +71 -55
  68. package/dist/react/shape.js +67 -47
  69. package/dist/react/slider.js +81 -0
  70. package/dist/react/surface.js +90 -56
  71. package/dist/react/switch.js +101 -0
  72. package/dist/react/tabs.js +85 -63
  73. package/dist/react/toolbar.js +38 -123
  74. package/dist/react/value-control-motion.js +1 -2
  75. package/dist/styles.css +517 -111
  76. package/dist/types/core/concentric.d.ts +8 -0
  77. package/dist/types/core/corner-options.d.ts +4 -0
  78. package/dist/types/core/corner-path.d.ts +8 -0
  79. package/dist/types/core/index.d.ts +3 -5
  80. package/dist/types/core/materials.d.ts +100 -28
  81. package/dist/types/core/shape.d.ts +4 -6
  82. package/dist/types/core/spring.d.ts +8 -12
  83. package/dist/types/dom/backdrop-glass.d.ts +38 -0
  84. package/dist/types/dom/compose-layers.d.ts +4 -0
  85. package/dist/types/dom/composited.d.ts +61 -0
  86. package/dist/types/dom/escaped-layers.d.ts +32 -0
  87. package/dist/types/dom/filter-bounds.d.ts +4 -0
  88. package/dist/types/dom/filter-chain.d.ts +6 -0
  89. package/dist/types/dom/filter-groups.d.ts +1 -1
  90. package/dist/types/dom/filter-paint-root.d.ts +3 -0
  91. package/dist/types/dom/filter-patch.d.ts +5 -0
  92. package/dist/types/dom/filter-reach.d.ts +9 -9
  93. package/dist/types/dom/foreground.d.ts +2 -1
  94. package/dist/types/dom/index.d.ts +8 -19
  95. package/dist/types/dom/interaction.d.ts +8 -8
  96. package/dist/types/dom/layout-rect.d.ts +17 -0
  97. package/dist/types/dom/layout-size.d.ts +11 -0
  98. package/dist/types/dom/lens-layers.d.ts +18 -10
  99. package/dist/types/dom/map-encoder.d.ts +5 -2
  100. package/dist/types/dom/map-encoding.d.ts +12 -3
  101. package/dist/types/dom/map-image.d.ts +7 -1
  102. package/dist/types/dom/maps.d.ts +25 -7
  103. package/dist/types/dom/material-graph.d.ts +73 -10
  104. package/dist/types/dom/media-mirror.d.ts +49 -0
  105. package/dist/types/dom/progressive.d.ts +2 -5
  106. package/dist/types/dom/sampling-bounds.d.ts +1 -3
  107. package/dist/types/dom/selection.d.ts +29 -4
  108. package/dist/types/dom/shape-attributes.d.ts +6 -0
  109. package/dist/types/dom/shape-effects.d.ts +10 -0
  110. package/dist/types/dom/shape-geometry.d.ts +6 -0
  111. package/dist/types/dom/shape-layout.d.ts +2 -4
  112. package/dist/types/dom/shared-backdrop.d.ts +7 -3
  113. package/dist/types/dom/specular.d.ts +50 -0
  114. package/dist/types/dom/ticker.d.ts +4 -1
  115. package/dist/types/dom/tint-color.d.ts +11 -0
  116. package/dist/types/dom/warm.d.ts +8 -2
  117. package/dist/types/gpu/geometry.d.ts +2 -0
  118. package/dist/types/gpu/planes.d.ts +3 -2
  119. package/dist/types/index.d.ts +1 -1
  120. package/dist/types/react/button.d.ts +1 -1
  121. package/dist/types/react/color-picker.d.ts +26 -0
  122. package/dist/types/react/index.d.ts +14 -10
  123. package/dist/types/react/menu.d.ts +4 -5
  124. package/dist/types/react/progressive.d.ts +1 -1
  125. package/dist/types/react/scene.d.ts +4 -2
  126. package/dist/types/react/shape.d.ts +11 -1
  127. package/dist/types/react/slider.d.ts +14 -0
  128. package/dist/types/react/surface.d.ts +11 -22
  129. package/dist/types/react/switch.d.ts +9 -0
  130. package/dist/types/react/tabs.d.ts +3 -3
  131. package/dist/types/react/toolbar.d.ts +1 -1
  132. package/package.json +46 -40
  133. package/dist/core/morph-path.js +0 -206
  134. package/dist/core/union.js +0 -117
  135. package/dist/dom/compound-field.js +0 -23
  136. package/dist/dom/exit-handoff.js +0 -14
  137. package/dist/dom/map-blend.js +0 -8
  138. package/dist/dom/morph.js +0 -296
  139. package/dist/react/value-controls.js +0 -176
  140. package/dist/types/core/morph-path.d.ts +0 -110
  141. package/dist/types/core/union.d.ts +0 -20
  142. package/dist/types/dom/compound-field.d.ts +0 -35
  143. package/dist/types/dom/exit-handoff.d.ts +0 -7
  144. package/dist/types/dom/map-blend.d.ts +0 -22
  145. package/dist/types/dom/morph.d.ts +0 -78
  146. package/dist/types/react/value-controls.d.ts +0 -20
@@ -1,163 +1,277 @@
1
- import { materials as e } from "../core/materials.js";
2
- import { mapImage as t, mapUrl as n } from "./map-image.js";
3
- import { patchFilters as r } from "./filter-patch.js";
4
- import { progressiveGraph as i } from "./progressive.js";
5
- import { blendMapImage as a } from "./map-blend.js";
6
- import { frostMarkup as o, overlayTintMarkup as s, tintChannels as c, tintMarkup as l, toneMarkup as u } from "./material-graph.js";
7
- //#region src/dom/lens-layers.ts
8
- var d = 0, f = "http://www.w3.org/2000/svg", p = /^(area|base|br|col|embed|hr|img|input|link|meta|source|track|wbr)$/i;
9
- function m(m) {
10
- let h = ++d, g = m.ownerDocument, _ = g.createElementNS(f, "svg");
11
- _.setAttribute("aria-hidden", "true"), _.setAttribute("width", "0"), _.setAttribute("height", "0"), _.style.position = "absolute", _.style.pointerEvents = "none";
12
- let v = g.createElementNS(f, "defs");
13
- _.append(v), g.body.append(_);
14
- let y = /* @__PURE__ */ new Map(), b, x = (e, t, n) => {
15
- e.written.get(t) !== n && (e.written.set(t, n), e.element.style.setProperty(t, n));
16
- }, S = (e, t) => {
17
- t.element.remove(), t.isolation ? t.host.style.isolation = t.isolation : t.host.style.removeProperty("isolation"), y.delete(e);
18
- }, C = (e) => `-moz-element(#${CSS.escape(e.id)})`;
1
+ import { aberrationFor as e, glassRecipe as t, glassSize as n, outlineFor as r } from "../core/materials.js";
2
+ import { patchFilters as i } from "./filter-patch.js";
3
+ import { mapImage as a, mapUrl as o } from "./map-image.js";
4
+ import { touchMaps as s } from "./maps.js";
5
+ import { backdropColor as c, fillMarkup as l, frostMarkup as u, lightMarkup as d, outlineMarkup as f, overlayTintMarkup as p, refractMarkup as m, tintChannels as h, tintMarkup as g, toneMarkup as _ } from "./material-graph.js";
6
+ import { progressiveGraph as v } from "./progressive.js";
7
+ // src/dom/lens-layers.ts
8
+ var y = 0, b = "http://www.w3.org/2000/svg", x = /^(area|base|br|col|embed|hr|img|input|link|meta|source|track|wbr)$/i;
9
+ function S(S) {
10
+ let C = ++y, w = S.ownerDocument, T = w.createElementNS(b, "svg");
11
+ T.setAttribute("aria-hidden", "true"), T.setAttribute("width", "0"), T.setAttribute("height", "0"), T.style.position = "absolute", T.style.pointerEvents = "none";
12
+ let E = w.createElementNS(b, "defs");
13
+ T.append(E), w.body.append(T);
14
+ let D = /* @__PURE__ */ new Map(), O, k = (e, t, n, r) => {
15
+ let i = r ? `${r} ${t}` : t;
16
+ e.written.get(i) !== n && (e.written.set(i, n), (r ? e.split[r] : e.element).style.setProperty(t, n));
17
+ }, ee = (e) => {
18
+ if (e.split) return e.split;
19
+ let t = Object.fromEntries([
20
+ "glass",
21
+ "source",
22
+ "refracted",
23
+ "light",
24
+ "rim"
25
+ ].map((e) => {
26
+ let t = w.createElement("div");
27
+ return Object.assign(t.style, {
28
+ position: "absolute",
29
+ inset: "0",
30
+ pointerEvents: "none",
31
+ backgroundRepeat: "no-repeat",
32
+ maskRepeat: "no-repeat"
33
+ }), [e, t];
34
+ }));
35
+ return t.refracted.style.inset = "auto", t.light.style.mixBlendMode = "plus-lighter", t.glass.append(t.source, t.refracted), e.element.append(t.glass, t.light, t.rim), e.split = t;
36
+ }, A = (e, t, n) => {
37
+ s(e);
38
+ let r = e.capsule, i = r ? r.cap * n.height / r.height : 0;
39
+ if (!r || n.width < i * 2) return [{
40
+ url: e[t],
41
+ left: n.left,
42
+ width: n.width
43
+ }];
44
+ let [a, o, c] = r.planes[t];
45
+ return [
46
+ {
47
+ url: c,
48
+ left: n.left + n.width - i,
49
+ width: i
50
+ },
51
+ {
52
+ url: a,
53
+ left: n.left,
54
+ width: i
55
+ },
56
+ {
57
+ url: o,
58
+ left: n.left + i - .5,
59
+ width: n.width - i * 2 + 1
60
+ }
61
+ ];
62
+ }, j = (e) => {
63
+ let t = e.backdrop;
64
+ t && (e.backdrop = void 0, t.value ? e.host.style.setProperty("backdrop-filter", t.value, t.priority) : e.host.style.removeProperty("backdrop-filter"));
65
+ }, M = (e, t) => {
66
+ j(t), t.element.remove(), t.hostId && t.host.id === t.hostId && t.host.removeAttribute("id"), t.isolation ? t.host.style.isolation = t.isolation : t.host.style.removeProperty("isolation"), D.delete(e);
67
+ }, N = (e) => `-moz-element(#${CSS.escape(e.id)})`, P = (e, t, n, r, i) => {
68
+ k(e, `${n}-image`, r.length ? r.map((e) => `url("${e.url}")`).join(", ") : "none", t), k(e, `${n}-position`, r.map((e) => `${e.left}px ${i.top}px`).join(", "), t), k(e, `${n}-size`, r.map((e) => `${e.width}px ${i.height}px`).join(", "), t);
69
+ }, F = (e) => `<filter id="${e}" x="0" y="0" width="1" height="1" filterUnits="objectBoundingBox" primitiveUnits="userSpaceOnUse" color-interpolation-filters="sRGB">`, te = (e, t, r, i, a) => {
70
+ let o = e.options, s = e.frame, d = h(o);
71
+ k(t, "left", `${r.left}px`), k(t, "top", `${r.top}px`), k(t, "width", `${r.width}px`), k(t, "height", `${r.height}px`), k(t, "opacity", "1");
72
+ let f = n(e.options, e.w, e.h), m = (e, t) => {
73
+ let n = [], r = e;
74
+ if (t) {
75
+ let t = u("l", r, o, f, 1 / Math.max(s.sx, s.sy));
76
+ n.push(t.markup), r = t.result;
77
+ let i = l("l", r, e, o, f, 1 / Math.max(s.sx, s.sy));
78
+ n.push(i.markup), r = i.result;
79
+ }
80
+ return n.push(_("l", o, f, r)), d && n.push(g("l", o, d).markup), n.join("");
81
+ }, v = [];
82
+ if (e.mode === "backdrop") {
83
+ let n = a ? `<feFlood flood-color="${a}" result="lback"/><feMerge result="lbacked"><feMergeNode in="lback"/><feMergeNode in="SourceGraphic"/></feMerge>` : "";
84
+ v.push(`${F(`${t.base}-backdrop`)}${n}${m(a ? "lbacked" : "SourceGraphic", !0)}</filter>`), P(t, void 0, "background", [...A(e.maps, "light", i), ...A(e.maps, "rim", i)], i);
85
+ } else ee(t), k(t, "display", "block", "glass"), k(t, "display", "none", "source"), k(t, "display", "none", "refracted"), k(t, "display", "block", "light"), k(t, "display", "block", "rim"), k(t, "background-color", c, "glass"), P(t, "glass", "mask", A(e.maps, "field", i), i), P(t, "light", "background", A(e.maps, "light", i), i), P(t, "rim", "background", A(e.maps, "rim", i), i), v.push(`${F(`${t.base}-material`)}${m("SourceGraphic", !1)}</filter>`);
86
+ return d && v.push(`${F(`${t.base}-light`)}${p("SourceGraphic", "llight", d)}</filter>`), v;
87
+ }, I = (e, t, n) => {
88
+ let r = (e) => `url("#${t(e)}")`, i = n.has(`${e.base}-light`) ? r(`${e.base}-light`) : "none";
89
+ if (e.mode === "flat") {
90
+ k(e, "filter", "none"), k(e, "filter", r(`${e.base}-material`), "glass"), k(e, "filter", i, "light");
91
+ return;
92
+ }
93
+ let a = e.host.style;
94
+ e.backdrop ??= {
95
+ value: a.getPropertyValue("backdrop-filter"),
96
+ priority: a.getPropertyPriority("backdrop-filter")
97
+ };
98
+ let o = r(`${e.base}-backdrop`);
99
+ a.getPropertyValue("backdrop-filter") !== o && a.setProperty("backdrop-filter", o), k(e, "filter", i);
100
+ };
19
101
  return {
20
- update(d, f, m, _) {
21
- b?.element !== f && (b && w(), b = {
22
- element: f,
23
- original: f.getAttribute("id"),
24
- id: f.id || `lg-content-${h}`
25
- }, f.id ||= b.id);
26
- let T = /* @__PURE__ */ new Set(), E = [], D = [];
27
- for (let t of d) {
28
- if (p.test(t.element.tagName)) continue;
29
- T.add(t.serial);
30
- let n = y.get(t.serial);
31
- if (n && n.host !== t.element && (S(t.serial, n), n = void 0), !n) {
32
- let e = g.createElement("div");
33
- e.className = "lg-glass-layer", e.setAttribute("aria-hidden", "true"), e.id = `lg-layer-${h}-${t.serial}`, n = {
34
- element: e,
35
- host: t.element,
36
- base: `lg-lens-${h}-${t.serial}`,
37
- isolation: t.element.style.isolation,
38
- written: /* @__PURE__ */ new Map()
39
- }, t.element.style.isolation = "isolate", t.element.append(e), y.set(t.serial, n);
102
+ update(s, y, b, S, T = !1, j = "") {
103
+ y && O?.element !== y && (O && L(), O = {
104
+ element: y,
105
+ original: y.getAttribute("id"),
106
+ id: y.id || `lg-content-${C}`
107
+ }, y.id ||= O.id);
108
+ let F = /* @__PURE__ */ new Set(), R = [], z = [];
109
+ for (let e of s) {
110
+ if (x.test(e.element.tagName)) continue;
111
+ F.add(e.serial);
112
+ let r = D.get(e.serial);
113
+ if (r && (r.host !== e.element || r.mode !== e.mode) && (M(e.serial, r), r = void 0), !r) {
114
+ let t = w.createElement("div");
115
+ t.className = "lg-glass-layer", t.setAttribute("aria-hidden", "true"), t.id = `lg-layer-${C}-${e.serial}`, r = {
116
+ element: t,
117
+ host: e.element,
118
+ base: `lg-lens-${C}-${e.serial}`,
119
+ isolation: e.element.style.isolation,
120
+ written: /* @__PURE__ */ new Map(),
121
+ mode: e.mode
122
+ }, e.element.style.isolation = "isolate", e.element.append(t), D.set(e.serial, r);
40
123
  }
41
- let r = t.options, i = t.frame, a = r.material === "regular" ? Math.max(e.regular.blur, (r.appearance === "dark" ? e.regular.dark : e.regular.light).fillSigma) : 0, o = Math.ceil(3 * a + t.refraction + 4), s = {
42
- left: m.left + t.x - 2,
43
- top: m.top + t.y - 2,
44
- width: t.w + 4,
45
- height: t.h + 4
46
- }, c = {
47
- left: s.left - o,
48
- top: s.top - o,
49
- width: s.width + 2 * o,
50
- height: s.height + 2 * o
51
- };
52
- n.screen = c;
53
- let l = {
54
- left: (c.left - i.left) / i.sx - i.clientLeft,
55
- top: (c.top - i.top) / i.sy - i.clientTop,
56
- width: c.width / i.sx,
57
- height: c.height / i.sy
58
- }, u = {
59
- left: o / i.sx,
60
- top: o / i.sy,
61
- width: s.width / i.sx,
62
- height: s.height / i.sy
124
+ let i = e.options, a = e.frame, o = t(i, n(e.options, e.w, e.h)), s = Math.max(o.blur, o.fill), c = e.mode === "copy" ? Math.ceil(3 * s + e.refraction + 4) : 0, l = (e) => Math.round(e * 16) / 16, u = Math.ceil(c / Math.max(a.sx, a.sy)), d = {
125
+ left: u,
126
+ top: u,
127
+ width: l((e.layoutWidth ?? e.w / a.sx) + 4),
128
+ height: l((e.layoutHeight ?? e.h / a.sy) + 4)
129
+ }, f = {
130
+ left: (b.left + e.x - a.left) / a.sx - a.clientLeft - 2 - u,
131
+ top: (b.top + e.y - a.top) / a.sy - a.clientTop - 2 - u,
132
+ width: d.width + 2 * u,
133
+ height: d.height + 2 * u
134
+ }, p = {
135
+ left: a.left + (f.left + a.clientLeft) * a.sx,
136
+ top: a.top + (f.top + a.clientTop) * a.sy,
137
+ width: f.width * a.sx,
138
+ height: f.height * a.sy
63
139
  };
64
- D.push({
65
- lens: t,
66
- layer: n,
67
- screen: c,
68
- local: l,
69
- lens_: u
140
+ r.screen = p, z.push({
141
+ lens: e,
142
+ layer: r,
143
+ screen: p,
144
+ local: f,
145
+ lens_: d
70
146
  });
71
147
  }
72
- for (let [e, t] of y) T.has(e) || S(e, t);
73
- for (let { lens: e, layer: n, screen: r, local: d, lens_: p } of D) {
74
- let h = e.frame, g = e.options, v = (e, t) => [(e - r.left) / h.sx, (t - r.top) / h.sy], b = [];
75
- for (let t of [...e.parents, ...[...e.beneath].reverse()]) {
76
- let e = y.get(t.serial);
77
- e?.screen && e !== n && b.push({
78
- image: C(e.element),
79
- box: e.screen
148
+ for (let [e, t] of D) F.has(e) || M(e, t);
149
+ for (let { lens: i, layer: o, screen: s, local: x, lens_: w } of z) {
150
+ if (i.mode !== "copy") {
151
+ R.push(...te(i, o, x, w, j));
152
+ continue;
153
+ }
154
+ if (!y) continue;
155
+ let E = i.frame, O = i.options, M = (e, t) => [(e - s.left) / E.sx, (t - s.top) / E.sy], F = [];
156
+ for (let e of [...i.parents, ...[...i.beneath].reverse()]) {
157
+ let t = D.get(e.serial);
158
+ if (!t?.screen || t === o) continue;
159
+ if (i.parents.includes(e)) {
160
+ F.push({
161
+ image: N(t.element),
162
+ box: t.screen
163
+ });
164
+ continue;
165
+ }
166
+ let n = t.host;
167
+ if (i.beneath.some((t) => t !== e && t.element.contains(n))) continue;
168
+ n.id ||= t.hostId = `lg-surface-${C}-${e.serial}`;
169
+ let r = n.getBoundingClientRect(), a = y.getBoundingClientRect();
170
+ F.push({
171
+ image: N(n),
172
+ box: {
173
+ left: r.left - a.left,
174
+ top: r.top - a.top,
175
+ width: r.width,
176
+ height: r.height
177
+ }
80
178
  });
81
179
  }
82
- let S = e.parents[0], w = S && y.get(S.serial)?.screen, T = S && w && S.opacity >= .999 && w.left <= r.left && w.top <= r.top && w.left + w.width >= r.left + r.width && w.top + w.height >= r.top + r.height;
83
- T || b.push({
84
- image: C(f),
85
- box: m
180
+ let I = i.parents[0], L = I && D.get(I.serial)?.screen, z = I && L && I.opacity >= .999 && L.left <= s.left && L.top <= s.top && L.left + L.width >= s.left + s.width && L.top + L.height >= s.top + s.height;
181
+ z || F.push({
182
+ image: N(y),
183
+ box: b
86
184
  });
87
- let D = T || !_ ? [] : _.regions.flatMap((e) => {
88
- let [t, n] = v(m.left + _.left + e.x, m.top + _.top + e.y), r = {
185
+ let B = z || !S ? [] : S.regions.flatMap((e) => {
186
+ let [t, n] = M(b.left + S.left + e.x, b.top + S.top + e.y), r = {
89
187
  ...e,
90
188
  x: t,
91
189
  y: n,
92
- width: e.width / h.sx,
93
- height: e.height / h.sy,
94
- blur: e.blur / Math.max(h.sx, h.sy),
95
- refraction: e.refraction / Math.max(h.sx, h.sy)
190
+ width: e.width / E.sx,
191
+ height: e.height / E.sy,
192
+ blur: e.blur / Math.max(E.sx, E.sy),
193
+ refraction: e.refraction / Math.max(E.sx, E.sy)
96
194
  }, i = 3 * r.blur + r.refraction;
97
- return r.x < d.width + i && r.x + r.width > -i && r.y < d.height + i && r.y + r.height > -i ? [r] : [];
195
+ return r.x < x.width + i && r.x + r.width > -i && r.y < x.height + i && r.y + r.height > -i ? [r] : [];
98
196
  });
99
- D.length && E.push(i(`${n.base}-blur`, D, d.width, d.height, "gecko")), x(n, "left", `${d.left}px`), x(n, "top", `${d.top}px`), x(n, "width", `${d.width}px`), x(n, "height", `${d.height}px`), x(n, "opacity", String(Math.round(e.opacity * 1e3) / 1e3)), x(n, "background-image", b.map((e) => e.image).join(", ")), x(n, "background-position", b.map((e) => {
100
- let [t, n] = v(e.box.left, e.box.top);
197
+ B.length && R.push(v(`${o.base}-blur`, B, x.width, x.height, "gecko"));
198
+ let V = n(i.options, i.w, i.h), ne = t(O, V), H = ne.blur > 0 || ne.fill > 0, U = H ? "source" : void 0;
199
+ H && ee(o), o.split && (k(o, "display", H ? "block" : "none", "glass"), k(o, "display", H ? "block" : "none", "light"), k(o, "display", H ? "block" : "none", "rim")), k(o, "left", `${x.left}px`), k(o, "top", `${x.top}px`), k(o, "width", `${x.width}px`), k(o, "height", `${x.height}px`), k(o, "opacity", String(Math.round(i.opacity * 1e3) / 1e3)), o.split && k(o, "background-image", H ? "none" : F.map((e) => e.image).join(", ")), k(o, "background-image", F.map((e) => e.image).join(", "), U);
200
+ let W = T ? c : "", G = (e, t) => {
201
+ (e || o.written.has(t ? `${t} background-color` : "background-color")) && k(o, "background-color", e, t);
202
+ };
203
+ G(H ? "" : W), o.split && G(H ? W : "", "source"), k(o, "background-position", F.map((e) => {
204
+ let [t, n] = M(e.box.left, e.box.top);
101
205
  return `${t}px ${n}px`;
102
- }).join(", ")), x(n, "background-size", b.map((e) => `${e.box.width / h.sx}px ${e.box.height / h.sy}px`).join(", "));
103
- let O = `x="${p.left}" y="${p.top}" width="${p.width}" height="${p.height}"`, k = (n, r) => {
104
- if (!e.place) return t(e.maps, n, r, p.left, p.top, p.width, p.height);
105
- let i = (e) => {
106
- let [t, n] = v(m.left + e.x, m.top + e.y);
107
- return {
108
- maps: e.maps,
109
- x: t,
110
- y: n,
111
- w: e.w / h.sx,
112
- h: e.h / h.sy
113
- };
114
- }, [o, s] = v(m.left + e.x, m.top + e.y);
115
- return a(n, r, {
116
- a: i(e.place.a),
117
- b: i(e.place.b),
118
- mix: e.place.mix
119
- }, {
120
- x: o,
121
- y: s,
122
- w: e.w / h.sx,
123
- h: e.h / h.sy
124
- });
125
- }, A = Math.max(h.sx, h.sy), j = "SourceGraphic", M = [k("field", "lfield")];
126
- if (g.material === "regular") {
127
- let e = o("l", j, g, 1 / A);
128
- M.push(e.markup), j = e.result;
206
+ }).join(", "), U), k(o, "background-size", F.map((e) => `${e.box.width / E.sx}px ${e.box.height / E.sy}px`).join(", "), U);
207
+ let K = `x="${w.left}" y="${w.top}" width="${w.width}" height="${w.height}"`, q = (e, t) => a(i.maps, e, t, w.left, w.top, w.width, w.height), J = Math.max(E.sx, E.sy), Y = (e) => `<filter id="${e}" x="0" y="0" width="1" height="1" filterUnits="objectBoundingBox" primitiveUnits="userSpaceOnUse" color-interpolation-filters="sRGB">`;
208
+ if (H) {
209
+ let e = h(O), t = u("l", "SourceGraphic", O, V, 1 / J), n = l("l", t.result, "SourceGraphic", O, V, 1 / J), r = Math.ceil(i.refraction / J) + 2, s = B.length > 0 ? {
210
+ left: 0,
211
+ top: 0,
212
+ width: x.width,
213
+ height: x.height
214
+ } : {
215
+ left: Math.max(0, w.left - r),
216
+ top: Math.max(0, w.top - r),
217
+ width: Math.min(x.width, w.left + w.width + r) - Math.max(0, w.left - r),
218
+ height: Math.min(x.height, w.top + w.height + r) - Math.max(0, w.top - r)
219
+ }, c = {
220
+ left: w.left - s.left,
221
+ top: w.top - s.top,
222
+ width: w.width,
223
+ height: w.height
224
+ }, d = `x="${c.left}" y="${c.top}" width="${c.width}" height="${c.height}"`, f = `<feDisplacementMap in="SourceGraphic" in2="lfield" scale="${2 * i.refraction / J}" xChannelSelector="R" yChannelSelector="G" ${d}`;
225
+ R.push(`${Y(o.base)}${a(i.maps, "field", "lfield", c.left, c.top, c.width, c.height)}${f}/></filter>`, `${Y(`${o.base}-material`)}${t.markup}${n.markup}${_("l", O, V, n.result)}${e ? g("l", O, e).markup : ""}</filter>`, ...e ? [`${Y(`${o.base}-light`)}${p("SourceGraphic", "llight", e)}</filter>`] : []);
226
+ for (let [e, t] of Object.entries({
227
+ left: s.left,
228
+ top: s.top,
229
+ width: s.width,
230
+ height: s.height
231
+ })) k(o, e, `${t}px`, "refracted");
232
+ k(o, "background-image", F.map((e) => e.image).join(", "), "refracted"), G(W, "refracted"), k(o, "background-position", F.map((e) => {
233
+ let [t, n] = M(e.box.left, e.box.top);
234
+ return `${t - s.left}px ${n - s.top}px`;
235
+ }).join(", "), "refracted"), k(o, "background-size", F.map((e) => `${e.box.width / E.sx}px ${e.box.height / E.sy}px`).join(", "), "refracted"), P(o, "refracted", "mask", A(i.maps, "field", c), c), P(o, "glass", "mask", A(i.maps, "field", w), w), P(o, "light", "background", A(i.maps, "light", w), w), P(o, "rim", "background", A(i.maps, "rim", w), w);
236
+ continue;
129
237
  }
130
- M.push(`<feDisplacementMap in="${j}" in2="lfield" scale="${2 * e.refraction / A}" xChannelSelector="R" yChannelSelector="G" ${O} result="lrefracted"/>`, u("l", g, e.parents.length > 0));
131
- let N = "lcolor", P = "loverlay", F = c(g);
132
- if (F) {
133
- let e = l("l", g, F);
134
- M.push(e.markup), N = e.color, P = "ltintOverlay";
238
+ let X = "SourceGraphic", Z = [q("field", "lfield")], re = u("l", X, O, V, 1 / J);
239
+ Z.push(re.markup), X = re.result, Z.push(m("l", X, i.refraction / J, e(O, V) / J).replace(/<feDisplacementMap\b/g, `<feDisplacementMap ${K}`));
240
+ let ie = l("l", "lrefracted", "SourceGraphic", O, V, 1 / J);
241
+ Z.push(ie.markup, _("l", O, V, ie.result));
242
+ let ae = "lcolor", Q = "llight", $ = h(O);
243
+ if ($) {
244
+ let e = g("l", O, $);
245
+ Z.push(e.markup), ae = e.color, Q = "ltintLight";
135
246
  }
136
- M.push(`<feComposite in="${N}" in2="lfield" operator="in" ${O} result="linside"/>`, k("overlay", "loverlay"), ...F ? [s("loverlay", P, g, F)] : [], `<feMerge ${O} result="lglass"><feMergeNode in="linside"/><feMergeNode in="${P}"/></feMerge>`);
137
- let I = M.join("").replace(/<(feComponentTransfer|feColorMatrix)\b(?![^>]*\sx=")([^>]*?)(\/?)>/g, `<$1$2 ${O}$3>`);
138
- E.push(`<filter id="${n.base}" x="0" y="0" width="1" height="1" filterUnits="objectBoundingBox" primitiveUnits="userSpaceOnUse" color-interpolation-filters="sRGB">${I}</filter>`);
247
+ Z.push(q("light", "llight"), ...$ ? [p("llight", Q, $)] : [], d("l", ae, Q, "lfield", O.material).replace(/<feComposite\b/g, `<feComposite ${K}`), q("rim", "lrim"), f("l", "SourceGraphic", "lrim", 1, r(O, V)), `<feComposite in="lrim" in2="lfield" operator="in" ${K} result="lring"/>`, `<feMerge ${K} result="lglass"><feMergeNode in="loutline"/><feMergeNode in="llitInside"/><feMergeNode in="lring"/></feMerge>`);
248
+ let oe = Z.join("").replace(/<(feComponentTransfer|feColorMatrix)\b(?![^>]*\sx=")([^>]*?)(\/?)>/g, `<$1$2 ${K}$3>`);
249
+ R.push(`${Y(o.base)}${oe}</filter>`);
139
250
  }
140
- let O = r(v, E, n), k = new Set(E.map((e) => /id="([^"]+)"/.exec(e)[1]));
141
- for (let { layer: e } of D) {
142
- let t = `${e.base}-blur`;
143
- x(e, "filter", [k.has(t) ? `url("#${O(t)}")` : "", `url("#${O(e.base)}")`].filter(Boolean).join(" "));
251
+ let B = i(E, R, o), V = new Set(R.map((e) => /id="([^"]+)"/.exec(e)[1]));
252
+ for (let { lens: e, layer: t } of z) {
253
+ if (e.mode !== "copy") {
254
+ I(t, B, V);
255
+ continue;
256
+ }
257
+ let n = `${t.base}-blur`, r = [V.has(n) ? `url("#${B(n)}")` : "", `url("#${B(t.base)}")`].filter(Boolean).join(" "), i = t.split && t.written.get("glass display") === "block";
258
+ t.split && k(t, "filter", i ? "none" : r), i ? (k(t, "filter", r, "refracted"), k(t, "filter", V.has(n) ? `url("#${B(n)}")` : "none", "source"), k(t, "filter", `url("#${B(`${t.base}-material`)}")`, "glass"), k(t, "filter", V.has(`${t.base}-light`) ? `url("#${B(`${t.base}-light`)}")` : "none", "light")) : k(t, "filter", r);
144
259
  }
145
260
  },
146
261
  owns(e) {
147
- if (_.contains(e)) return !0;
148
- for (let t of y.values()) if (t.element.contains(e)) return !0;
262
+ if (T.contains(e)) return !0;
263
+ for (let t of D.values()) if (t.element.contains(e)) return !0;
149
264
  return !1;
150
265
  },
151
266
  dispose() {
152
- for (let [e, t] of y) S(e, t);
153
- _.remove(), w();
267
+ for (let [e, t] of D) M(e, t);
268
+ T.remove(), L();
154
269
  }
155
270
  };
156
- function w() {
157
- if (!b) return;
158
- let { element: e, original: t, id: n } = b;
159
- e.id === n && t === null && e.removeAttribute("id"), b = void 0;
271
+ function L() {
272
+ if (!O) return;
273
+ let { element: e, original: t, id: n } = O;
274
+ e.id === n && t === null && e.removeAttribute("id"), O = void 0;
160
275
  }
161
276
  }
162
- //#endregion
163
- export { m as createLensLayers };
277
+ export { S as createLensLayers };
@@ -1,5 +1,5 @@
1
1
  import { encodeMapPixels as e } from "./map-encoding.js";
2
- //#region src/dom/map-encoder.ts
2
+ // src/dom/map-encoder.ts
3
3
  var t, n = !1, r, i = 0, a = /* @__PURE__ */ new Map();
4
4
  async function o() {
5
5
  if (!n) return t || (r ??= import("./map-encoder.worker.js").then(({ default: e }) => {
@@ -19,29 +19,32 @@ async function o() {
19
19
  n = !0;
20
20
  }));
21
21
  }
22
- async function s(t, n, r, s) {
23
- let c = await o();
24
- if (c) try {
22
+ async function s(t, n, r, s, c) {
23
+ let l = await o();
24
+ if (l) try {
25
25
  return await new Promise((e, o) => {
26
- let l = ++i;
27
- a.set(l, {
26
+ let u = ++i;
27
+ a.set(u, {
28
28
  resolve: e,
29
29
  reject: o
30
30
  });
31
31
  try {
32
- c.postMessage({
33
- id: l,
32
+ l.postMessage({
33
+ id: u,
34
34
  pixels: t,
35
35
  width: n,
36
36
  height: r,
37
- cap: s
37
+ cap: s,
38
+ nine: c
38
39
  });
39
40
  } catch (e) {
40
- a.delete(l), o(e);
41
+ a.delete(u), o(e);
41
42
  }
42
43
  });
43
44
  } catch {}
44
- return e(t, n, r, s);
45
+ return e(t, n, r, s, c);
45
46
  }
46
- //#endregion
47
- export { s as encodeMaterialPixels };
47
+ function c() {
48
+ o();
49
+ }
50
+ export { s as encodeMaterialPixels, c as warmMapEncoder };
@@ -1,5 +1,5 @@
1
- //#region src/dom/map-encoder.worker.ts?worker&inline
2
- var e = "(function(){let e=/* @__PURE__ */ new Int32Array(256);for(let t=0;t<256;t++){let n=t;for(let e=0;e<8;e++)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n}function t(t,n=0,r=t.length){let i=-1;for(let a=n;a<r;a++)i=e[(i^t[a])&255]^i>>>8;return(i^-1)>>>0}function n(e){let t=1,n=0;for(let r=0;r<e.length;){let i=Math.min(e.length,r+3800);for(;r<i;r++)t+=e[r],n+=t;t%=65521,n%=65521}return(n<<16|t)>>>0}function r(e){let t=Math.max(1,Math.ceil(e.length/65535)),r=new Uint8Array(2+e.length+t*5+4);r[0]=120,r[1]=1;let i=2;for(let n=0;n<t;n++){let a=n*65535,o=Math.min(65535,e.length-a);r[i++]=+(n===t-1),r[i++]=o&255,r[i++]=o>>>8,r[i++]=~o&255,r[i++]=~o>>>8&255,r.set(e.subarray(a,a+o),i),i+=o}let a=n(e);return r[i++]=a>>>24,r[i++]=a>>>16&255,r[i++]=a>>>8&255,r[i++]=a&255,r}async function i(e){if(typeof CompressionStream>`u`)return r(e);try{let t=new Blob([e]).stream().pipeThrough(new CompressionStream(`deflate`));return new Uint8Array(await new Response(t).arrayBuffer())}catch{return r(e)}}function a(e,n){let r=new Uint8Array(12+n.length),i=new DataView(r.buffer);i.setUint32(0,n.length);for(let t=0;t<4;t++)r[4+t]=e.charCodeAt(t);return r.set(n,8),i.setUint32(8+n.length,t(r,4,8+n.length)),r}function o(e,t,n,r){let i=e*4,a=new Uint8Array((i+1)*t);for(let e=0;e<t;e++){let t=e*r,o=e*(i+1);a[o]=1;for(let e=0;e<4;e++)a[o+1+e]=n[t+e];for(let e=4;e<i;e++)a[o+1+e]=n[t+e]-n[t+e-4]&255}return a}function s(e,t,n){let r=/* @__PURE__ */ new Uint8Array(13),i=new DataView(r.buffer);i.setUint32(0,e),i.setUint32(4,t),r[8]=8,r[9]=6,r[10]=0,r[11]=0,r[12]=0;let o=[new Uint8Array([137,80,78,71,13,10,26,10]),a(`IHDR`,r),a(`IDAT`,n),a(`IEND`,/* @__PURE__ */ new Uint8Array)],s=new Uint8Array(o.reduce((e,t)=>e+t.length,0)),c=0;for(let e of o)s.set(e,c),c+=e.length;return s}async function c(e,t,n,r=e*4){return s(e,t,await i(o(e,t,n,r)))}let l=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;function u(e){let t=``,n=e.length-e.length%3;for(let r=0;r<n;r+=3){let n=e[r]<<16|e[r+1]<<8|e[r+2];t+=l[n>>>18]+l[n>>>12&63]+l[n>>>6&63]+l[n&63]}if(e.length-n===1){let r=e[n]<<16;t+=l[r>>>18]+l[r>>>12&63]+`==`}else if(e.length-n===2){let r=e[n]<<16|e[n+1]<<8;t+=l[r>>>18]+l[r>>>12&63]+l[r>>>6&63]+`=`}return t}async function d(e,t,n,r){return`data:image/png;base64,${u(await c(e,t,n,r))}`}function f(e,t,n,r){let i=t*4,a=r===void 0?[[0,t]]:[[0,t],[0,r],[r,t-2*r],[t-r,r]];return Promise.all(Array.from({length:2},(t,r)=>{let o=r*n*i;return Promise.all(a.map(([t,r])=>d(r,n,e.subarray(o+t*4,o+n*i),i)))}))}let p=Promise.resolve();self.onmessage=({data:{id:e,pixels:t,width:n,height:r,cap:i}})=>{p=p.then(async()=>{try{self.postMessage({id:e,planes:await f(t,n,r,i)})}catch(t){self.postMessage({id:e,error:String(t)})}})}})();", t = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", e], { type: "text/javascript;charset=utf-8" });
1
+ // src/dom/map-encoder.worker.ts?worker&inline
2
+ var e = "(function(){let e=/* @__PURE__ */ new Int32Array(256);for(let t=0;t<256;t++){let n=t;for(let e=0;e<8;e++)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n}function t(t,n=0,r=t.length){let i=-1;for(let a=n;a<r;a++)i=e[(i^t[a])&255]^i>>>8;return(i^-1)>>>0}function n(e){let t=1,n=0;for(let r=0;r<e.length;){let i=Math.min(e.length,r+3800);for(;r<i;r++)t+=e[r],n+=t;t%=65521,n%=65521}return(n<<16|t)>>>0}function r(e){let t=Math.max(1,Math.ceil(e.length/65535)),r=new Uint8Array(2+e.length+t*5+4);r[0]=120,r[1]=1;let i=2;for(let n=0;n<t;n++){let a=n*65535,o=Math.min(65535,e.length-a);r[i++]=+(n===t-1),r[i++]=o&255,r[i++]=o>>>8,r[i++]=~o&255,r[i++]=~o>>>8&255,r.set(e.subarray(a,a+o),i),i+=o}let a=n(e);return r[i++]=a>>>24,r[i++]=a>>>16&255,r[i++]=a>>>8&255,r[i++]=a&255,r}async function i(e){if(typeof CompressionStream>`u`)return r(e);try{let t=new Blob([e]).stream().pipeThrough(new CompressionStream(`deflate`));return new Uint8Array(await new Response(t).arrayBuffer())}catch{return r(e)}}function a(e,n){let r=new Uint8Array(12+n.length),i=new DataView(r.buffer);i.setUint32(0,n.length);for(let t=0;t<4;t++)r[4+t]=e.charCodeAt(t);return r.set(n,8),i.setUint32(8+n.length,t(r,4,8+n.length)),r}function o(e,t,n,r){let i=e*4,a=new Uint8Array((i+1)*t);for(let e=0;e<t;e++){let t=e*r,o=e*(i+1);a[o]=1;for(let e=0;e<4;e++)a[o+1+e]=n[t+e];for(let e=4;e<i;e++)a[o+1+e]=n[t+e]-n[t+e-4]&255}return a}function s(e,t,n){let r=/* @__PURE__ */ new Uint8Array(13),i=new DataView(r.buffer);i.setUint32(0,e),i.setUint32(4,t),r[8]=8,r[9]=6,r[10]=0,r[11]=0,r[12]=0;let o=[new Uint8Array([137,80,78,71,13,10,26,10]),a(`IHDR`,r),a(`IDAT`,n),a(`IEND`,/* @__PURE__ */ new Uint8Array)],s=new Uint8Array(o.reduce((e,t)=>e+t.length,0)),c=0;for(let e of o)s.set(e,c),c+=e.length;return s}async function c(e,t,n,r=e*4){return s(e,t,await i(o(e,t,n,r)))}let l=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;function u(e){let t=``,n=e.length-e.length%3;for(let r=0;r<n;r+=3){let n=e[r]<<16|e[r+1]<<8|e[r+2];t+=l[n>>>18]+l[n>>>12&63]+l[n>>>6&63]+l[n&63]}if(e.length-n===1){let r=e[n]<<16;t+=l[r>>>18]+l[r>>>12&63]+`==`}else if(e.length-n===2){let r=e[n]<<16|e[n+1]<<8;t+=l[r>>>18]+l[r>>>12&63]+l[r>>>6&63]+`=`}return t}async function d(e,t,n,r){return`data:image/png;base64,${u(await c(e,t,n,r))}`}function f(e,t,n,r,i){let a=t*4,o=[[0,0,t,n]];if(r!==void 0&&o.push([0,0,r,n],[r,0,t-2*r,n],[t-r,0,r,n]),i){let e=Math.max(1,Math.min(i.x,Math.ceil(t/2))),r=Math.max(1,Math.min(i.y,Math.ceil(n/2))),a=Math.floor(t/2),s=Math.floor(n/2);for(let[i,c]of[[0,r],[s,1],[n-r,r]])o.push([0,i,e,c],[a,i,1,c],[t-e,i,e,c])}return Promise.all(Array.from({length:3},(t,r)=>{let i=r*n*a;return Promise.all(o.map(([t,n,r,o])=>d(r,o,e.subarray(i+n*a+t*4,i+(n+o)*a),a)))}))}let p=Promise.resolve();self.onmessage=({data:{id:e,pixels:t,width:n,height:r,cap:i,nine:a}})=>{p=p.then(async()=>{try{self.postMessage({id:e,planes:await f(t,n,r,i,a)})}catch(t){self.postMessage({id:e,error:String(t)})}})}})();", t = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", e], { type: "text/javascript;charset=utf-8" });
3
3
  function n(n) {
4
4
  let r;
5
5
  try {
@@ -12,5 +12,4 @@ function n(n) {
12
12
  return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(e), { name: n?.name });
13
13
  }
14
14
  }
15
- //#endregion
16
15
  export { n as default };
@@ -1,17 +1,54 @@
1
1
  import { pngDataUrl as e } from "./png.js";
2
2
  import "../gpu/planes.js";
3
- //#region src/dom/map-encoding.ts
4
- function t(t, n, r, i) {
5
- let a = n * 4, o = i === void 0 ? [[0, n]] : [
6
- [0, n],
7
- [0, i],
8
- [i, n - 2 * i],
9
- [n - i, i]
10
- ];
11
- return Promise.all(Array.from({ length: 2 }, (n, i) => {
12
- let s = i * r * a;
13
- return Promise.all(o.map(([n, i]) => e(i, r, t.subarray(s + n * 4, s + r * a), a)));
3
+ // src/dom/map-encoding.ts
4
+ function t(t, n, r, i, a) {
5
+ let o = n * 4, s = [[
6
+ 0,
7
+ 0,
8
+ n,
9
+ r
10
+ ]];
11
+ if (i !== void 0 && s.push([
12
+ 0,
13
+ 0,
14
+ i,
15
+ r
16
+ ], [
17
+ i,
18
+ 0,
19
+ n - 2 * i,
20
+ r
21
+ ], [
22
+ n - i,
23
+ 0,
24
+ i,
25
+ r
26
+ ]), a) {
27
+ let e = Math.max(1, Math.min(a.x, Math.ceil(n / 2))), t = Math.max(1, Math.min(a.y, Math.ceil(r / 2))), i = Math.floor(n / 2), o = Math.floor(r / 2);
28
+ for (let [a, c] of [
29
+ [0, t],
30
+ [o, 1],
31
+ [r - t, t]
32
+ ]) s.push([
33
+ 0,
34
+ a,
35
+ e,
36
+ c
37
+ ], [
38
+ i,
39
+ a,
40
+ 1,
41
+ c
42
+ ], [
43
+ n - e,
44
+ a,
45
+ e,
46
+ c
47
+ ]);
48
+ }
49
+ return Promise.all(Array.from({ length: 3 }, (n, i) => {
50
+ let a = i * r * o;
51
+ return Promise.all(s.map(([n, r, i, s]) => e(i, s, t.subarray(a + r * o + n * 4, a + (r + s) * o), o)));
14
52
  }));
15
53
  }
16
- //#endregion
17
54
  export { t as encodeMapPixels };
@@ -1,11 +1,12 @@
1
1
  import { touchMaps as e } from "./maps.js";
2
- //#region src/dom/map-image.ts
2
+ // src/dom/map-image.ts
3
3
  var t = {
4
4
  field: "field",
5
- overlay: "overlay"
5
+ rim: "rim",
6
+ light: "light"
6
7
  }, n = (e, n) => `s${e}${t[n]}`;
7
8
  function r(e) {
8
- if (!(e.outline || e.radius !== "capsule" || !Number.isFinite(e.width) || !Number.isFinite(e.height) || e.height <= 0 || e.width < e.height * 2)) return {
9
+ if (!(e.outline || e.radius !== "capsule" || !Number.isFinite(e.width) || !Number.isFinite(e.height) || e.height <= 0 || e.width < (e.material === "lens" ? 0 : e.height * 2))) return {
9
10
  ...e,
10
11
  width: e.height * 3
11
12
  };
@@ -23,12 +24,33 @@ function l(e) {
23
24
  t && (i.delete(e), a.delete(t));
24
25
  }
25
26
  function u(t, n, r, i, a, o, c, l = 1, u = 1) {
26
- let d = (e, t, n, r) => `<feImage data-map="${s(e)}" x="${t / l}" y="${a / u}" width="${n / l}" height="${c / u}" preserveAspectRatio="none" result="${r}"/>`;
27
+ let d = (e, t, n, r, i = "none") => `<feImage data-map="${s(e)}" x="${t / l}" y="${a / u}" width="${n / l}" height="${c / u}" preserveAspectRatio="${i}" result="${r}"/>`;
27
28
  e(t);
28
29
  let f = t.capsule, p = f ? f.cap * c / f.height : 0;
29
- if (!f || o < p * 2) return d(t[n], i, o, r);
30
+ if (!f) return d(t[n], i, o, r);
30
31
  let [m, h, g] = f.planes[n];
32
+ if (o < p * 2) {
33
+ let e = o / 2;
34
+ return d(m, i, e + .5, `${r}L`, "xMinYMid slice") + d(g, i + e - .5, e + .5, `${r}R`, "xMaxYMid slice") + `<feMerge result="${r}" x="${i / l}" y="${a / u}" width="${o / l}" height="${c / u}"><feMergeNode in="${r}L"/><feMergeNode in="${r}R"/></feMerge>`;
35
+ }
31
36
  return d(h, i + p - .5, o - p * 2 + 1, `${r}M`) + d(m, i, p, `${r}L`) + d(g, i + o - p, p, `${r}R`) + `<feMerge result="${r}" x="${i / l}" y="${a / u}" width="${o / l}" height="${c / u}"><feMergeNode in="${r}M"/><feMergeNode in="${r}L"/><feMergeNode in="${r}R"/></feMerge>`;
32
37
  }
33
- //#endregion
34
- export { r as capsuleMapGeometry, u as mapImage, s as mapToken, c as mapUrl, l as releaseMapToken, n as surfaceMapResult };
38
+ function d(t, n, r, i, a, o, c, l = 1) {
39
+ let d = t.nine;
40
+ if (!d) return u(t, n, r, i, a, o, c);
41
+ e(t);
42
+ let f = d.planes[n], p = (e) => Math.round(e / l) * l, m = (e, t, n) => {
43
+ let r = p(e), i = p(e + t), a = Math.min(p(n), p((i - r) / 2));
44
+ return [
45
+ [r, a],
46
+ [r + a, i - r - 2 * a],
47
+ [i - a, a]
48
+ ];
49
+ }, h = m(i, o, d.x), g = m(a, c, d.y), _ = [], v = "";
50
+ return g.forEach(([e, t], n) => h.forEach(([i, a], o) => {
51
+ if (a < .01 || t < .01) return;
52
+ let c = `${r}${n}${o}`;
53
+ _.push(c), v += `<feImage data-map="${s(f[n * 3 + o])}" x="${i}" y="${e}" width="${a}" height="${t}" preserveAspectRatio="none" result="${c}"/>`;
54
+ })), `${v}<feMerge result="${r}" x="${i}" y="${a}" width="${o}" height="${c}">${_.map((e) => `<feMergeNode in="${e}"/>`).join("")}</feMerge>`;
55
+ }
56
+ export { r as capsuleMapGeometry, u as mapImage, s as mapToken, c as mapUrl, d as nineMapImage, l as releaseMapToken, n as surfaceMapResult };