uxml-preview 0.5.0 → 0.5.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.
package/dist/index.js CHANGED
@@ -1,154 +1,211 @@
1
- import { loadYoga as tt, PositionType as ne, Direction as be, Edge as q, BoxSizing as nt, FlexDirection as G, Wrap as Y, Justify as P, Align as W, Display as st, Overflow as rt } from "yoga-layout/load";
2
- function J(e) {
1
+ import { loadYoga as it, PositionType as re, Direction as Se, Edge as J, BoxSizing as at, FlexDirection as G, Wrap as K, Justify as B, Align as L, Display as lt, Overflow as ct } from "yoga-layout/load";
2
+ const je = {
3
+ // VisualElement is the base class and carries no class of its own.
4
+ VisualElement: { hasText: !1, classes: [], parts: [] },
5
+ Label: { hasText: !0, classes: ["unity-label"], parts: [] },
6
+ Button: { hasText: !0, classes: ["unity-button"], parts: [] },
7
+ // Image draws a texture, not text. Its picture reaches this renderer through
8
+ // `background-image` in USS, which `resolveAsset` can turn into something a
9
+ // browser will load; a texture assigned from C# has no path to follow here.
10
+ Image: { hasText: !1, classes: ["unity-image"], parts: [] },
11
+ /**
12
+ * Four elements from one tag. The names below are observed in
13
+ * `tests/golden/unity/scrollview-*.json`, not taken from documentation — the
14
+ * middle one, `unity-content-and-vertical-scroll-container`, is not in
15
+ * Unity's manual diagram at all and was found by dumping.
16
+ *
17
+ * The styles are inference, unlike the names: they are how this renderer
18
+ * reproduces the measured geometry, and the three `scrollview-*` golden cases
19
+ * are what decides whether the inference is right.
20
+ */
21
+ ScrollView: {
22
+ hasText: !1,
23
+ classes: ["unity-scroll-view"],
24
+ parts: [
25
+ // Fills the ScrollView's content box, and lays the viewport out beside
26
+ // the vertical scrollbar — hence row.
27
+ {
28
+ name: "unity-content-and-vertical-scroll-container",
29
+ style: { "flex-grow": "1", "flex-direction": "row" }
30
+ },
31
+ // What actually clips. Takes whatever width the scrollbar leaves.
32
+ { name: "unity-content-viewport", style: { "flex-grow": "1", overflow: "hidden" } },
33
+ // `flex-shrink: 0` is the whole reason a ScrollView is not one box:
34
+ // this grows to the content's height instead of being squeezed into the
35
+ // viewport's, so children keep their sizes and the viewport crops them.
36
+ // Without it three 60px children in a 100px view come out 33/34/33.
37
+ { name: "unity-content-container", style: { "flex-shrink": "0" } }
38
+ ]
39
+ }
40
+ }, ie = { hasText: !1, classes: [], parts: [] }, ut = "UXML", dt = /* @__PURE__ */ new Set(["Style", "Template", "AttributeOverrides", "Bindings", "Columns"]);
41
+ function de(e) {
42
+ return dt.has(e.name.local);
43
+ }
44
+ function Y(e) {
45
+ var t;
46
+ if (((t = e.derived) == null ? void 0 : t.kind) === "template-container") return { spec: ie, fallback: !1 };
47
+ const n = je[e.name.local];
48
+ return n !== void 0 ? { spec: n, fallback: !1 } : ft(e) ? { spec: ie, fallback: !1 } : { spec: ie, fallback: !0 };
49
+ }
50
+ function ft(e) {
51
+ return e.name.local === ut;
52
+ }
53
+ function pt(e) {
54
+ return Y(e).spec.classes;
55
+ }
56
+ function ht() {
57
+ return Object.keys(je);
58
+ }
59
+ function X(e) {
3
60
  const n = (t, s) => !Number.isInteger(t) || t < 0 || t > 1114111 || t >= 55296 && t <= 57343 ? s : String.fromCodePoint(t);
4
61
  return e.replace(/&#x([0-9a-f]+);/gi, (t, s) => n(parseInt(s, 16), t)).replace(/&#(\d+);/g, (t, s) => n(Number(s), t)).replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&amp;/g, "&");
5
62
  }
6
- function ye(e) {
63
+ function $e(e) {
7
64
  return e !== void 0 && /[A-Za-z0-9_.:-]/.test(e);
8
65
  }
9
- function xe(e) {
66
+ function Te(e) {
10
67
  return e !== void 0 && /[A-Za-z_]/.test(e);
11
68
  }
12
- function it(e) {
69
+ function mt(e) {
13
70
  return e === " " || e === " " || e === `
14
71
  ` || e === "\r";
15
72
  }
16
- function Re(e) {
73
+ function ze(e) {
17
74
  const n = [];
18
75
  let t = 0, s = 0;
19
- const i = () => s++;
20
- function r(a, f, l) {
76
+ const r = () => s++;
77
+ function o(c, u, p) {
21
78
  n.push({
22
79
  kind: "malformed",
23
- message: a,
24
- at: { in: "uxml", span: { start: f, end: l } }
80
+ message: c,
81
+ at: { in: "uxml", span: { start: u, end: p } }
25
82
  });
26
83
  }
27
- function u() {
28
- for (; it(e[t]); ) t++;
84
+ function d() {
85
+ for (; mt(e[t]); ) t++;
29
86
  }
30
- function c() {
87
+ function a() {
31
88
  for (; ; ) {
32
- const a = e.indexOf("<", t);
33
- if (a < 0) {
89
+ const c = e.indexOf("<", t);
90
+ if (c < 0) {
34
91
  t = e.length;
35
92
  return;
36
93
  }
37
- const f = e[a + 1];
38
- if (f === "!") {
39
- if (e.startsWith("<!--", a)) {
40
- const l = e.indexOf("-->", a + 4);
41
- t = l < 0 ? e.length : l + 3;
42
- } else if (e.startsWith("<![CDATA[", a)) {
43
- const l = e.indexOf("]]>", a + 9);
44
- t = l < 0 ? e.length : l + 3;
94
+ const u = e[c + 1];
95
+ if (u === "!") {
96
+ if (e.startsWith("<!--", c)) {
97
+ const p = e.indexOf("-->", c + 4);
98
+ t = p < 0 ? e.length : p + 3;
99
+ } else if (e.startsWith("<![CDATA[", c)) {
100
+ const p = e.indexOf("]]>", c + 9);
101
+ t = p < 0 ? e.length : p + 3;
45
102
  } else {
46
- const l = e.indexOf(">", a);
47
- t = l < 0 ? e.length : l + 1;
103
+ const p = e.indexOf(">", c);
104
+ t = p < 0 ? e.length : p + 1;
48
105
  }
49
106
  continue;
50
107
  }
51
- if (f === "?") {
52
- const l = e.indexOf("?>", a + 2);
53
- t = l < 0 ? e.length : l + 2;
108
+ if (u === "?") {
109
+ const p = e.indexOf("?>", c + 2);
110
+ t = p < 0 ? e.length : p + 2;
54
111
  continue;
55
112
  }
56
- t = a;
113
+ t = c;
57
114
  return;
58
115
  }
59
116
  }
60
- function v() {
61
- const a = t;
62
- for (; ye(e[t]); ) t++;
63
- const f = e.slice(a, t), l = f.indexOf(":");
64
- return l < 0 ? { prefix: null, local: f } : { prefix: f.slice(0, l), local: f.slice(l + 1) };
65
- }
66
- function d() {
67
- const a = t;
68
- for (; ye(e[t]); ) t++;
69
- if (t === a) return null;
70
- const f = e.slice(a, t), l = t;
71
- if (u(), e[t] !== "=")
72
- return t = l, r(`attribute "${f}" has no value`, a, l), { name: f, value: "", span: { start: a, end: l } };
73
- t++, u();
74
- const h = e[t];
75
- if (h !== '"' && h !== "'")
76
- return r(`attribute "${f}" has an unquoted value`, a, t), { name: f, value: "", span: { start: a, end: t } };
117
+ function x() {
118
+ const c = t;
119
+ for (; $e(e[t]); ) t++;
120
+ const u = e.slice(c, t), p = u.indexOf(":");
121
+ return p < 0 ? { prefix: null, local: u } : { prefix: u.slice(0, p), local: u.slice(p + 1) };
122
+ }
123
+ function h() {
124
+ const c = t;
125
+ for (; $e(e[t]); ) t++;
126
+ if (t === c) return null;
127
+ const u = e.slice(c, t), p = t;
128
+ if (d(), e[t] !== "=")
129
+ return t = p, o(`attribute "${u}" has no value`, c, p), { name: u, value: "", span: { start: c, end: p } };
130
+ t++, d();
131
+ const i = e[t];
132
+ if (i !== '"' && i !== "'")
133
+ return o(`attribute "${u}" has an unquoted value`, c, t), { name: u, value: "", span: { start: c, end: t } };
77
134
  t++;
78
- const g = t, p = e.indexOf(h, t);
79
- return p < 0 ? (r(`attribute "${f}" has an unterminated value`, a, e.length), t = e.length, { name: f, value: e.slice(g), span: { start: a, end: t } }) : (t = p + 1, { name: f, value: e.slice(g, p), span: { start: a, end: t } });
135
+ const y = t, k = e.indexOf(i, t);
136
+ return k < 0 ? (o(`attribute "${u}" has an unterminated value`, c, e.length), t = e.length, { name: u, value: e.slice(y), span: { start: c, end: t } }) : (t = k + 1, { name: u, value: e.slice(y, k), span: { start: c, end: t } });
80
137
  }
81
- function o() {
82
- const a = t;
138
+ function l() {
139
+ const c = t;
83
140
  t++;
84
- const f = v(), l = [];
85
- let h = !1;
141
+ const u = x(), p = [];
142
+ let i = !1;
86
143
  for (; ; ) {
87
- u();
88
- const k = e[t];
89
- if (k === void 0) {
90
- r("unterminated open tag", a, e.length);
144
+ d();
145
+ const w = e[t];
146
+ if (w === void 0) {
147
+ o("unterminated open tag", c, e.length);
91
148
  break;
92
149
  }
93
- if (k === ">") {
150
+ if (w === ">") {
94
151
  t++;
95
152
  break;
96
153
  }
97
- if (k === "/" && e[t + 1] === ">") {
98
- t += 2, h = !0;
154
+ if (w === "/" && e[t + 1] === ">") {
155
+ t += 2, i = !0;
99
156
  break;
100
157
  }
101
- const x = d();
102
- if (x === null) {
158
+ const g = h();
159
+ if (g === null) {
103
160
  t++;
104
161
  continue;
105
162
  }
106
- l.push(x);
163
+ p.push(g);
107
164
  }
108
- const g = { start: a, end: t };
109
- if (h)
165
+ const y = { start: c, end: t };
166
+ if (i)
110
167
  return {
111
- id: i(),
112
- name: f,
113
- attributes: l,
168
+ id: r(),
169
+ name: u,
170
+ attributes: p,
114
171
  children: [],
115
- spans: { openTag: g, inner: { start: t, end: t }, closeTag: null },
172
+ spans: { openTag: y, inner: { start: t, end: t }, closeTag: null },
116
173
  tagDirty: !1,
117
174
  childrenDirty: !1
118
175
  };
119
- const p = t, b = [];
176
+ const k = t, f = [];
120
177
  for (; ; ) {
121
- if (c(), t >= e.length) {
122
- r(`unterminated element <${Ce(f)}>`, a, e.length);
178
+ if (a(), t >= e.length) {
179
+ o(`unterminated element <${Le(u)}>`, c, e.length);
123
180
  break;
124
181
  }
125
- const k = e[t + 1];
126
- if (k === "/") break;
127
- if (!xe(k)) {
182
+ const w = e[t + 1];
183
+ if (w === "/") break;
184
+ if (!Te(w)) {
128
185
  t++;
129
186
  continue;
130
187
  }
131
- b.push(o());
188
+ f.push(l());
132
189
  }
133
190
  const m = t;
134
- let y = null;
191
+ let v = null;
135
192
  if (e.startsWith("</", t)) {
136
- const k = e.indexOf(">", t), x = k < 0 ? e.length : k + 1;
137
- k < 0 && r("unterminated end tag", t, x), y = { start: t, end: x }, t = x;
193
+ const w = e.indexOf(">", t), g = w < 0 ? e.length : w + 1;
194
+ w < 0 && o("unterminated end tag", t, g), v = { start: t, end: g }, t = g;
138
195
  }
139
196
  return {
140
- id: i(),
141
- name: f,
142
- attributes: l,
143
- children: b,
144
- spans: { openTag: g, inner: { start: p, end: m }, closeTag: y },
197
+ id: r(),
198
+ name: u,
199
+ attributes: p,
200
+ children: f,
201
+ spans: { openTag: y, inner: { start: k, end: m }, closeTag: v },
145
202
  tagDirty: !1,
146
203
  childrenDirty: !1
147
204
  };
148
205
  }
149
- return c(), t < e.length && xe(e[t + 1]) ? { root: o(), warnings: n } : (r("no root element", 0, 0), {
206
+ return a(), t < e.length && Te(e[t + 1]) ? { root: l(), warnings: n } : (o("no root element", 0, 0), {
150
207
  root: {
151
- id: i(),
208
+ id: r(),
152
209
  name: { prefix: null, local: "" },
153
210
  attributes: [],
154
211
  children: [],
@@ -159,56 +216,57 @@ function Re(e) {
159
216
  warnings: n
160
217
  });
161
218
  }
162
- function Ce(e) {
219
+ function Le(e) {
163
220
  return e.prefix === null ? e.local : `${e.prefix}:${e.local}`;
164
221
  }
165
- let Me;
166
- function ot(e) {
167
- Me = e;
222
+ let Ue;
223
+ function gt(e) {
224
+ Ue = e;
168
225
  }
169
- const Ue = /* @__PURE__ */ new WeakMap();
170
- function lt(e, n) {
171
- Ue.set(e, n);
226
+ const _e = /* @__PURE__ */ new WeakMap();
227
+ function yt(e, n) {
228
+ _e.set(e, n);
172
229
  }
173
- function bn(e) {
174
- return Re(e).root.children.filter((t) => t.name.local === "Template").flatMap((t) => {
175
- const s = Le(t, "src");
176
- return s === void 0 || s.length === 0 ? [] : [J(s)];
230
+ function Cn(e) {
231
+ return ze(e).root.children.filter((t) => t.name.local === "Template").flatMap((t) => {
232
+ const s = We(t, "src");
233
+ return s === void 0 || s.length === 0 ? [] : [X(s)];
177
234
  });
178
235
  }
179
- const ke = 32;
180
- function Le(e, n) {
236
+ const Ie = 32;
237
+ function We(e, n) {
181
238
  var t;
182
239
  return (t = e.attributes.find((s) => s.name === n)) == null ? void 0 : t.value;
183
240
  }
184
- function U(e, n) {
185
- const t = Le(e, n);
186
- return t === void 0 ? void 0 : J(t);
241
+ function j(e, n) {
242
+ const t = We(e, n);
243
+ return t === void 0 ? void 0 : X(t);
187
244
  }
188
- function We(e) {
245
+ function Pe(e) {
189
246
  const n = /* @__PURE__ */ new Map();
190
247
  for (const t of e.root.children) {
191
248
  if (t.name.local !== "Template") continue;
192
- const s = U(t, "name"), i = U(t, "src");
193
- s === void 0 || s.length === 0 || i === void 0 || i.length === 0 || n.set(s, { name: s, src: i, node: t });
249
+ const s = j(t, "name"), r = j(t, "src");
250
+ s === void 0 || s.length === 0 || r === void 0 || r.length === 0 || n.set(s, { name: s, src: r, node: t });
194
251
  }
195
252
  return n;
196
253
  }
197
- function ze(e, n) {
254
+ function Fe(e, n) {
198
255
  return JSON.stringify([e, n]);
199
256
  }
200
- function at(e) {
257
+ function bt(e) {
201
258
  return /(?:^|\/)Packages\//i.test(e) || /PackageCache/i.test(e);
202
259
  }
203
- function j(e, n, t, s, i) {
260
+ function F(e, n, t, s, r, o = {}) {
204
261
  e.push({
205
262
  kind: n,
206
263
  message: t,
207
264
  ...s === void 0 ? {} : { node: s.id },
208
- ...i === void 0 ? {} : { sourceDocument: i }
265
+ ...r === void 0 ? {} : { sourceDocument: r },
266
+ ...o
209
267
  });
210
268
  }
211
- function ee(e, n = 0, t = void 0) {
269
+ function se(e, n = 0, t = void 0) {
212
270
  return {
213
271
  ...e,
214
272
  span: {
@@ -218,140 +276,146 @@ function ee(e, n = 0, t = void 0) {
218
276
  ...t === void 0 ? {} : { sourceDocument: t }
219
277
  };
220
278
  }
221
- function _e(e) {
279
+ function Be(e) {
222
280
  return { prefix: e.prefix, local: e.local };
223
281
  }
224
- function Se() {
282
+ function Ee() {
225
283
  return { start: 0, end: 0 };
226
284
  }
227
- function se(e, n) {
285
+ function ae(e, n) {
228
286
  return { start: e.start + n, end: e.end + n };
229
287
  }
230
- function ct(e, n, t, s, i) {
288
+ function vt(e, n, t, s, r) {
231
289
  return {
232
290
  id: e,
233
291
  name: n,
234
292
  attributes: t,
235
293
  children: s,
236
- spans: { openTag: Se(), inner: Se(), closeTag: null },
294
+ spans: { openTag: Ee(), inner: Ee(), closeTag: null },
237
295
  tagDirty: !1,
238
296
  childrenDirty: !1,
239
- ...i === void 0 ? {} : { derived: { kind: "template-container", instance: i } }
297
+ ...r === void 0 ? {} : { derived: { kind: "template-container", instance: r } }
240
298
  };
241
299
  }
242
- function ut(e, n, t) {
243
- const s = e.items.map((i) => i.kind !== "import" || i.resolvedSheet === void 0 ? i.kind === "rule" ? {
244
- ...i,
300
+ function wt(e, n, t) {
301
+ const s = e.items.map((r) => r.kind !== "import" || r.resolvedSheet === void 0 ? r.kind === "rule" ? {
302
+ ...r,
245
303
  rule: {
246
- ...i.rule,
247
- selectors: i.rule.selectors.map((r) => ({
248
- ...r,
249
- parts: r.parts.map((u) => ({ ...u, simple: [...u.simple] }))
304
+ ...r.rule,
305
+ selectors: r.rule.selectors.map((o) => ({
306
+ ...o,
307
+ parts: o.parts.map((d) => ({ ...d, simple: [...d.simple] }))
250
308
  })),
251
- declarations: i.rule.declarations.map((r) => ({ ...r }))
309
+ declarations: r.rule.declarations.map((o) => ({ ...o }))
252
310
  }
253
- } : { ...i } : { ...i, resolvedSheet: i.resolvedSheet + n });
311
+ } : { ...r } : { ...r, resolvedSheet: r.resolvedSheet + n });
254
312
  return { ...e, items: s, sourceDocumentFrom: t };
255
313
  }
256
- function dt(e, n) {
314
+ function xt(e, n) {
257
315
  const t = n.sheetOffsets.get(e.document);
258
316
  if (t !== void 0) return t;
259
- const s = n.sheets.length, i = e.document.sheets.map((u, c) => s + c), r = e.document.sheets.map(() => e.url);
260
- return e.document.sheets.forEach((u, c) => {
261
- for (const v of u.items)
262
- v.kind === "import" && v.resolvedSheet !== void 0 && (r[v.resolvedSheet] = u.origin ?? e.url);
263
- }), n.sheetOffsets.set(e.document, i), e.document.sheets.forEach(
264
- (u, c) => n.sheets.push(ut(u, s, r[c]))
265
- ), i;
266
- }
267
- function je(e, n) {
317
+ const s = n.sheets.length, r = e.document.sheets.map((d, a) => s + a), o = e.document.sheets.map(() => e.url);
318
+ return e.document.sheets.forEach((d, a) => {
319
+ for (const x of d.items)
320
+ x.kind === "import" && x.resolvedSheet !== void 0 && (o[x.resolvedSheet] = d.origin ?? e.url);
321
+ }), n.sheetOffsets.set(e.document, r), e.document.sheets.forEach(
322
+ (d, a) => n.sheets.push(wt(d, s, o[a]))
323
+ ), r;
324
+ }
325
+ function He(e, n) {
268
326
  const t = n.sourceOffsets.get(e);
269
327
  if (t !== void 0) return t;
270
328
  const s = n.sourceLength + 1;
271
329
  return n.sourceOffsets.set(e, s), n.sources.push(`
272
330
  ${e.source}`), n.sourceLength += e.source.length + 1, s;
273
331
  }
274
- function ft(e, n, t, s, i) {
275
- for (const r of e.document.styleRoots ?? []) {
276
- const u = n[r.sheet];
277
- if (u === void 0) continue;
278
- const c = t.nodes.get(r.scope) ?? s.id;
279
- i.styleRoots.push({ sheet: u, scope: c });
332
+ function kt(e, n, t, s, r) {
333
+ for (const o of e.document.styleRoots ?? []) {
334
+ const d = n[o.sheet];
335
+ if (d === void 0) continue;
336
+ const a = t.nodes.get(o.scope) ?? s.id;
337
+ r.styleRoots.push({ sheet: d, scope: a });
280
338
  }
281
339
  }
282
- function pt(e) {
340
+ function St(e) {
283
341
  return e.map((n) => {
284
- const t = U(n, "name"), s = U(n, "slot");
342
+ const t = j(n, "name"), s = j(n, "slot");
285
343
  return `<${n.name.local}${t === void 0 ? "" : ` name="${t}"`}${s === void 0 ? "" : ` slot="${s}"`}>`;
286
344
  });
287
345
  }
288
- function Fe(e, n) {
289
- const t = U(e, "slot-name");
346
+ function Ve(e, n) {
347
+ const t = j(e, "slot-name");
290
348
  t !== void 0 && t.length > 0 && n.add(t);
291
- for (const s of e.children) Fe(s, n);
349
+ for (const s of e.children) Ve(s, n);
292
350
  }
293
- function V(e, n, t, s, i) {
294
- const r = /* @__PURE__ */ new Set();
295
- t !== null && Fe(t.document.root, r), !(r.size === 0 && n.length === 0) && j(
296
- i.warnings,
351
+ function q(e, n, t, s, r) {
352
+ const o = /* @__PURE__ */ new Set();
353
+ t !== null && Ve(t.document.root, o), !(o.size === 0 && n.length === 0) && F(
354
+ r.warnings,
297
355
  "template-slot-unsupported",
298
- `Template slots are unsupported; defined slot names: ${t === null ? "(unavailable)" : r.size === 0 ? "(none)" : [...r].join(", ")}; children not placed: ${n.length === 0 ? "(none)" : pt(n).join(", ")}`,
356
+ `Template slots are unsupported; defined slot names: ${t === null ? "(unavailable)" : o.size === 0 ? "(none)" : [...o].join(", ")}; children not placed: ${n.length === 0 ? "(none)" : St(n).join(", ")}`,
299
357
  e,
300
- s
358
+ s,
359
+ { reason: "not-rendered" }
301
360
  );
302
361
  }
303
- function pe(e, n) {
304
- if (e.name.local !== "Style" && e.name.local !== "Template" && e.name.local !== "AttributeOverrides") {
305
- const t = U(e, "name");
362
+ function ge(e, n) {
363
+ if (!de(e)) {
364
+ const t = j(e, "name");
306
365
  t !== void 0 && t.length > 0 && n.set(t, (n.get(t) ?? 0) + 1);
307
366
  }
308
- for (const t of e.children) pe(t, n);
367
+ for (const t of e.children) ge(t, n);
309
368
  }
310
- function Pe(e, n, t) {
311
- U(e, "name") === n && t.push(e);
312
- for (const s of e.children) Pe(s, n, t);
369
+ function Ye(e, n, t) {
370
+ j(e, "name") === n && t.push(e);
371
+ for (const s of e.children) Ye(s, n, t);
313
372
  }
314
- function ht(e, n, t, s, i) {
373
+ function $t(e, n, t, s, r) {
315
374
  if (n.length === 0) return;
316
- const r = /* @__PURE__ */ new Map();
317
- pe(e, r);
318
- for (const u of n) {
319
- const c = U(u, "element-name"), v = U(u, "style");
320
- if (v !== void 0 && j(
321
- i.warnings,
375
+ const o = /* @__PURE__ */ new Map();
376
+ ge(e, o);
377
+ for (const d of n) {
378
+ const a = j(d, "element-name"), x = j(d, "style");
379
+ if (x !== void 0 && F(
380
+ r.warnings,
322
381
  "override-style-ignored",
323
- `AttributeOverrides style for element-name "${c ?? "(missing)"}" was ignored with value "${v}"; Unity ignores style AttributeOverrides, so this matches Unity and is not a preview limitation.`,
324
- u,
325
- s ?? void 0
326
- ), c === void 0 || c.length === 0) continue;
327
- const d = [];
328
- if (Pe(e, c, d), d.length === 0) {
329
- const o = [...r.keys()];
330
- j(
331
- i.warnings,
382
+ `AttributeOverrides style for element-name "${a ?? "(missing)"}" was ignored with value "${x}"`,
383
+ d,
384
+ s ?? void 0,
385
+ {
386
+ reason: "matches-unity",
387
+ ...a === void 0 ? {} : { subject: { kind: "name", name: a } }
388
+ }
389
+ ), a === void 0 || a.length === 0) continue;
390
+ const h = [];
391
+ if (Ye(e, a, h), h.length === 0) {
392
+ const l = [...o.keys()];
393
+ F(
394
+ r.warnings,
332
395
  "override-target-missing",
333
- `AttributeOverrides target "${c}" matched no element; available names: ${o.length === 0 ? "(none)" : o.join(", ")}`,
334
- u,
335
- s ?? void 0
396
+ `AttributeOverrides target "${a}" matched no element; available names: ${l.length === 0 ? "(none)" : l.join(", ")}`,
397
+ d,
398
+ s ?? void 0,
399
+ { reason: "invalid-value", subject: { kind: "name", name: a } }
336
400
  );
337
401
  continue;
338
402
  }
339
- for (const o of d)
340
- for (const a of u.attributes) {
341
- if (a.name === "element-name" || a.name === "style") continue;
342
- const f = o.attributes.find((l) => l.name === a.name);
343
- f === void 0 ? o.attributes.push(ee(a, t, s)) : (f.value = a.value, f.sourceDocument = s);
403
+ for (const l of h)
404
+ for (const c of d.attributes) {
405
+ if (c.name === "element-name" || c.name === "style") continue;
406
+ const u = l.attributes.find((p) => p.name === c.name);
407
+ u === void 0 ? l.attributes.push(se(c, t, s)) : (u.value = c.value, u.sourceDocument = s);
344
408
  }
345
409
  }
346
410
  }
347
- function Be(e) {
348
- return e.name.local === "Template" || e.name.local === "Instance" ? !0 : e.children.some(Be);
411
+ function qe(e) {
412
+ return e.name.local === "Template" || e.name.local === "Instance" ? !0 : e.children.some(qe);
349
413
  }
350
- function mt(e, n) {
414
+ function Tt(e, n) {
351
415
  let t = 0;
352
- const s = (i) => {
353
- t = Math.max(t, Number(i.id) + 1);
354
- for (const r of i.children) s(r);
416
+ const s = (r) => {
417
+ t = Math.max(t, Number(r.id) + 1);
418
+ for (const o of r.children) s(o);
355
419
  };
356
420
  return s(e.root), {
357
421
  resolver: n,
@@ -368,101 +432,103 @@ function mt(e, n) {
368
432
  stack: []
369
433
  };
370
434
  }
371
- function gt(e, n, t) {
372
- var v;
373
- const s = ze(e.src, n);
435
+ function It(e, n, t) {
436
+ var x;
437
+ const s = Fe(e.src, n);
374
438
  if (t.cache.has(s)) return t.cache.get(s) ?? null;
375
- const i = ((v = t.resolver) == null ? void 0 : v.call(t, e.src, n)) ?? null;
376
- if (i === null)
377
- return t.cache.set(s, null), j(
439
+ const r = ((x = t.resolver) == null ? void 0 : x.call(t, e.src, n)) ?? null;
440
+ if (r === null)
441
+ return t.cache.set(s, null), F(
378
442
  t.warnings,
379
443
  "template-src-unresolved",
380
444
  `Template "${e.name}" src "${e.src}" could not be resolved from ${n === null ? "the entry UXML" : `"${n}"`}; attempted resolveImport("${e.src}", ${n === null ? "null" : `"${n}"`}); internal filesystem search paths: none`,
381
445
  e.node,
382
- n ?? void 0
383
- ), at(e.src) && j(
446
+ n ?? void 0,
447
+ { subject: { kind: "import", url: e.src, from: n } }
448
+ ), bt(e.src) && F(
384
449
  t.warnings,
385
450
  "package-path-not-searched",
386
451
  `Template src "${e.src}" was unresolved; the resolver returned no source and the core does not independently search Unity Packages/Library/PackageCache paths`,
387
452
  e.node,
388
- n ?? void 0
453
+ n ?? void 0,
454
+ { reason: "not-rendered", subject: { kind: "import", url: e.src, from: n } }
389
455
  ), null;
390
- const r = Me;
391
- if (r === void 0)
456
+ const o = Ue;
457
+ if (o === void 0)
392
458
  throw new Error("template parser is not registered; import parse from src/index before expansion");
393
- const u = r(
394
- i,
395
- t.resolver === void 0 ? void 0 : (d, o) => t.resolver(d, o ?? e.src)
396
- ), c = {
459
+ const d = o(
460
+ r,
461
+ t.resolver === void 0 ? void 0 : (h, l) => t.resolver(h, l ?? e.src)
462
+ ), a = {
397
463
  url: e.src,
398
464
  from: n,
399
- document: u,
400
- declarations: We(u)
465
+ document: d,
466
+ declarations: Pe(d)
401
467
  };
402
- return t.cache.set(s, c), c;
468
+ return t.cache.set(s, a), a;
403
469
  }
404
- function wt(e, n, t) {
405
- var s, i;
470
+ function Et(e, n, t) {
471
+ var s, r;
406
472
  if (!t.reportedWarnings.has(e.document)) {
407
473
  t.reportedWarnings.add(e.document);
408
- for (const r of e.document.warnings)
409
- ((s = r.at) == null ? void 0 : s.in) === "uss" ? t.warnings.push({
410
- ...r,
411
- at: { ...r.at, sheet: n[r.at.sheet] ?? r.at.sheet },
412
- sourceDocument: ((i = e.document.sheets[r.at.sheet]) == null ? void 0 : i.origin) ?? e.url
413
- }) : t.warnings.push({ ...r, sourceDocument: e.url });
414
- }
415
- }
416
- function te(e, n, t, s, i, r) {
417
- const u = i ? e.id : n.nextId(), c = s === null ? 0 : n.sourceOffsets.get(s.document) ?? 0, v = c === 0 || s === null ? void 0 : s.url, d = {
418
- id: u,
419
- name: _e(e.name),
420
- attributes: e.attributes.map((o) => ee(o, c, v)),
474
+ for (const o of e.document.warnings)
475
+ ((s = o.at) == null ? void 0 : s.in) === "uss" ? t.warnings.push({
476
+ ...o,
477
+ at: { ...o.at, sheet: n[o.at.sheet] ?? o.at.sheet },
478
+ sourceDocument: ((r = e.document.sheets[o.at.sheet]) == null ? void 0 : r.origin) ?? e.url
479
+ }) : t.warnings.push({ ...o, sourceDocument: e.url });
480
+ }
481
+ }
482
+ function oe(e, n, t, s, r, o) {
483
+ const d = r ? e.id : n.nextId(), a = s === null ? 0 : n.sourceOffsets.get(s.document) ?? 0, x = a === 0 || s === null ? void 0 : s.url, h = {
484
+ id: d,
485
+ name: Be(e.name),
486
+ attributes: e.attributes.map((l) => se(l, a, x)),
421
487
  children: [],
422
488
  spans: {
423
- openTag: se(e.spans.openTag, c),
424
- inner: se(e.spans.inner, c),
425
- closeTag: e.spans.closeTag === null ? null : se(e.spans.closeTag, c)
489
+ openTag: ae(e.spans.openTag, a),
490
+ inner: ae(e.spans.inner, a),
491
+ closeTag: e.spans.closeTag === null ? null : ae(e.spans.closeTag, a)
426
492
  },
427
493
  tagDirty: e.tagDirty,
428
494
  childrenDirty: e.childrenDirty,
429
- ...c === 0 || s === null ? {} : {
495
+ ...a === 0 || s === null ? {} : {
430
496
  sourceDocument: s.url,
431
497
  sourceDocumentFrom: s.from,
432
498
  sourceNode: e.id
433
499
  }
434
500
  };
435
- t.nodes.set(e.id, d.id);
436
- for (const o of e.children)
437
- if (!(o.name.local === "Template" || o.name.local === "Style")) {
438
- if (o.name.local === "Instance") {
439
- d.children.push(he(o, n, s, t, r + 1));
501
+ t.nodes.set(e.id, h.id);
502
+ for (const l of e.children)
503
+ if (!(l.name.local === "Template" || l.name.local === "Style")) {
504
+ if (l.name.local === "Instance") {
505
+ h.children.push(ye(l, n, s, t, o + 1));
440
506
  continue;
441
507
  }
442
- o.name.local !== "AttributeOverrides" && U(o, "slot") === void 0 && d.children.push(te(o, n, t, s, i, r));
508
+ l.name.local !== "AttributeOverrides" && j(l, "slot") === void 0 && h.children.push(oe(l, n, t, s, r, o));
443
509
  }
444
- return d;
445
- }
446
- function vt(e, n, t, s) {
447
- je(e.document, t);
448
- const i = { nodes: /* @__PURE__ */ new Map([[e.document.root.id, n.id]]) };
449
- for (const r of e.document.root.children)
450
- if (!(r.name.local === "Template" || r.name.local === "Style")) {
451
- if (r.name.local === "Instance") {
452
- n.children.push(he(r, t, e, i, s + 1));
510
+ return h;
511
+ }
512
+ function Ot(e, n, t, s) {
513
+ He(e.document, t);
514
+ const r = { nodes: /* @__PURE__ */ new Map([[e.document.root.id, n.id]]) };
515
+ for (const o of e.document.root.children)
516
+ if (!(o.name.local === "Template" || o.name.local === "Style")) {
517
+ if (o.name.local === "Instance") {
518
+ n.children.push(ye(o, t, e, r, s + 1));
453
519
  continue;
454
520
  }
455
- r.name.local !== "AttributeOverrides" && U(r, "slot") === void 0 && n.children.push(te(r, t, i, e, !1, s));
521
+ o.name.local !== "AttributeOverrides" && j(o, "slot") === void 0 && n.children.push(oe(o, t, r, e, !1, s));
456
522
  }
457
- return i;
523
+ return r;
458
524
  }
459
- function he(e, n, t, s, i) {
460
- const r = ct(
525
+ function ye(e, n, t, s, r) {
526
+ const o = vt(
461
527
  n.nextId(),
462
528
  { prefix: e.name.prefix, local: "TemplateContainer" },
463
- e.attributes.filter((b) => b.name !== "template").map(
464
- (b) => ee(
465
- b,
529
+ e.attributes.filter((f) => f.name !== "template").map(
530
+ (f) => se(
531
+ f,
466
532
  t === null ? 0 : n.sourceOffsets.get(t.document) ?? 0,
467
533
  t === null || t.url.length === 0 ? null : t.url
468
534
  )
@@ -470,74 +536,80 @@ function he(e, n, t, s, i) {
470
536
  [],
471
537
  e.id
472
538
  );
473
- t !== null && (r.sourceDocument = t.url.length > 0 ? t.url : null, r.sourceDocumentFrom = t.from), s.nodes.set(e.id, r.id);
474
- const u = U(e, "template"), c = e.children.filter((b) => U(b, "slot") !== void 0), v = t === null || t.url.length === 0 ? void 0 : t.url, d = t == null ? void 0 : t.declarations.get(u ?? "");
475
- if (d === void 0)
476
- return V(e, c, null, v, n), j(
539
+ t !== null && (o.sourceDocument = t.url.length > 0 ? t.url : null, o.sourceDocumentFrom = t.from), s.nodes.set(e.id, o.id);
540
+ const d = j(e, "template"), a = e.children.filter((f) => j(f, "slot") !== void 0), x = t === null || t.url.length === 0 ? void 0 : t.url, h = t == null ? void 0 : t.declarations.get(d ?? "");
541
+ if (h === void 0)
542
+ return q(e, a, null, x, n), F(
477
543
  n.warnings,
478
544
  "template-not-declared",
479
- `Instance${u === void 0 ? "" : ` template "${u}"`} has no matching Template declaration`,
545
+ `Instance${d === void 0 ? "" : ` template "${d}"`} has no matching Template declaration`,
480
546
  e,
481
- v
482
- ), r;
483
- const o = t === null || t.url.length === 0 ? null : t.url, a = {
484
- key: JSON.stringify([d.name, d.src, o]),
485
- label: `${d.name}@${d.src}`
486
- }, f = n.stack.findIndex((b) => b.key === a.key);
487
- if (f >= 0) {
488
- const b = n.cache.get(ze(d.src, o)) ?? null;
489
- V(e, c, b, v, n);
490
- const m = [...n.stack.slice(f), a].map((y) => y.label).join(" -> ");
491
- return j(
547
+ x,
548
+ {
549
+ reason: "invalid-value",
550
+ ...d === void 0 ? {} : { subject: { kind: "name", name: d } }
551
+ }
552
+ ), o;
553
+ const l = t === null || t.url.length === 0 ? null : t.url, c = {
554
+ key: JSON.stringify([h.name, h.src, l]),
555
+ label: `${h.name}@${h.src}`
556
+ }, u = n.stack.findIndex((f) => f.key === c.key);
557
+ if (u >= 0) {
558
+ const f = n.cache.get(Fe(h.src, l)) ?? null;
559
+ q(e, a, f, x, n);
560
+ const m = [...n.stack.slice(u), c].map((v) => v.label).join(" -> ");
561
+ return F(
492
562
  n.warnings,
493
563
  "template-cycle",
494
564
  `Template cycle detected: ${m}`,
495
565
  e,
496
- v
497
- ), r;
566
+ x,
567
+ { reason: "invalid-value" }
568
+ ), o;
498
569
  }
499
- if (i >= ke)
500
- return V(e, c, null, v, n), j(
570
+ if (r >= Ie)
571
+ return q(e, a, null, x, n), F(
501
572
  n.warnings,
502
573
  "template-depth-exceeded",
503
- `Template expansion exceeded the depth limit ${ke}: ${[
574
+ `Template expansion exceeded the depth limit ${Ie}: ${[
504
575
  ...n.stack,
505
- a
506
- ].map((b) => b.label).join(" -> ")}`,
576
+ c
577
+ ].map((f) => f.label).join(" -> ")}`,
507
578
  e,
508
- v
509
- ), r;
510
- const l = gt(d, o, n);
511
- if (l === null)
512
- return V(e, c, null, v, n), r;
513
- je(l.document, n), n.stack.push(a);
514
- const h = vt(l, r, n, i);
579
+ x,
580
+ { reason: "not-rendered" }
581
+ ), o;
582
+ const p = It(h, l, n);
583
+ if (p === null)
584
+ return q(e, a, null, x, n), o;
585
+ He(p.document, n), n.stack.push(c);
586
+ const i = Ot(p, o, n, r);
515
587
  n.stack.pop();
516
- const g = dt(l, n);
517
- wt(l, g, n), ft(l, g, h, r, n);
518
- const p = e.children.filter((b) => b.name.local === "AttributeOverrides");
519
- V(e, c, l, v, n), ht(
520
- r,
521
- p,
588
+ const y = xt(p, n);
589
+ Et(p, y, n), kt(p, y, i, o, n);
590
+ const k = e.children.filter((f) => f.name.local === "AttributeOverrides");
591
+ q(e, a, p, x, n), $t(
592
+ o,
593
+ k,
522
594
  t === null ? 0 : n.sourceOffsets.get(t.document) ?? 0,
523
595
  t === null || t.url.length === 0 ? null : t.url,
524
596
  n
525
597
  );
526
- for (const b of e.children)
527
- b.name.local === "AttributeOverrides" || b.name.local === "Style" || U(b, "slot") !== void 0 || r.children.push(te(b, n, s, t, !1, i));
528
- return r;
598
+ for (const f of e.children)
599
+ f.name.local === "AttributeOverrides" || f.name.local === "Style" || j(f, "slot") !== void 0 || o.children.push(oe(f, n, s, t, !1, r));
600
+ return o;
529
601
  }
530
- function bt(e) {
531
- if (!Be(e.root)) return { document: e, warnings: [] };
532
- const n = mt(e, Ue.get(e)), t = n.styleRoots.length, s = {
602
+ function Dt(e) {
603
+ if (!qe(e.root)) return { document: e, warnings: [] };
604
+ const n = Tt(e, _e.get(e)), t = n.styleRoots.length, s = {
533
605
  url: "",
534
606
  from: null,
535
607
  document: e,
536
- declarations: We(e)
537
- }, i = { nodes: /* @__PURE__ */ new Map([[e.root.id, e.root.id]]) }, r = {
608
+ declarations: Pe(e)
609
+ }, r = { nodes: /* @__PURE__ */ new Map([[e.root.id, e.root.id]]) }, o = {
538
610
  id: e.root.id,
539
- name: _e(e.root.name),
540
- attributes: e.root.attributes.map((c) => ee(c)),
611
+ name: Be(e.root.name),
612
+ attributes: e.root.attributes.map((a) => se(a)),
541
613
  children: [],
542
614
  spans: {
543
615
  openTag: { ...e.root.spans.openTag },
@@ -547,30 +619,33 @@ function bt(e) {
547
619
  tagDirty: e.root.tagDirty,
548
620
  childrenDirty: e.root.childrenDirty
549
621
  };
550
- for (const c of e.root.children)
551
- if (!(c.name.local === "Template" || c.name.local === "Style")) {
552
- if (c.name.local === "Instance") {
553
- r.children.push(he(c, n, s, i, 0));
622
+ for (const a of e.root.children)
623
+ if (!(a.name.local === "Template" || a.name.local === "Style")) {
624
+ if (a.name.local === "Instance") {
625
+ o.children.push(ye(a, n, s, r, 0));
554
626
  continue;
555
627
  }
556
- c.name.local !== "AttributeOverrides" && U(c, "slot") === void 0 && r.children.push(te(c, n, i, s, !0, 0));
628
+ a.name.local !== "AttributeOverrides" && j(a, "slot") === void 0 && o.children.push(oe(a, n, r, s, !0, 0));
557
629
  }
558
- for (let c = 0; c < t; c++) {
559
- const v = n.styleRoots[c], d = i.nodes.get(v.scope);
560
- d !== void 0 && (n.styleRoots[c] = { ...v, scope: d });
561
- }
562
- const u = /* @__PURE__ */ new Map();
563
- pe(r, u);
564
- for (const [c, v] of u)
565
- v > 1 && j(
630
+ for (let a = 0; a < t; a++) {
631
+ const x = n.styleRoots[a], h = r.nodes.get(x.scope);
632
+ h !== void 0 && (n.styleRoots[a] = { ...x, scope: h });
633
+ }
634
+ const d = /* @__PURE__ */ new Map();
635
+ ge(o, d);
636
+ for (const [a, x] of d)
637
+ x > 1 && F(
566
638
  n.warnings,
567
639
  "duplicate-name-in-tree",
568
- `name "${c}" occurs ${v} times after template expansion`
640
+ `name "${a}" occurs ${x} times after template expansion`,
641
+ void 0,
642
+ void 0,
643
+ { reason: "matches-unity", subject: { kind: "name", name: a } }
569
644
  );
570
645
  return {
571
646
  document: {
572
647
  ...e,
573
- root: r,
648
+ root: o,
574
649
  source: n.sources.join(""),
575
650
  sheets: n.sheets,
576
651
  styleRoots: n.styleRoots
@@ -578,64 +653,7 @@ function bt(e) {
578
653
  warnings: n.warnings
579
654
  };
580
655
  }
581
- const He = {
582
- // VisualElement is the base class and carries no class of its own.
583
- VisualElement: { hasText: !1, classes: [], parts: [] },
584
- Label: { hasText: !0, classes: ["unity-label"], parts: [] },
585
- Button: { hasText: !0, classes: ["unity-button"], parts: [] },
586
- // Image draws a texture, not text. Its picture reaches this renderer through
587
- // `background-image` in USS, which `resolveAsset` can turn into something a
588
- // browser will load; a texture assigned from C# has no path to follow here.
589
- Image: { hasText: !1, classes: ["unity-image"], parts: [] },
590
- /**
591
- * Four elements from one tag. The names below are observed in
592
- * `tests/golden/unity/scrollview-*.json`, not taken from documentation — the
593
- * middle one, `unity-content-and-vertical-scroll-container`, is not in
594
- * Unity's manual diagram at all and was found by dumping.
595
- *
596
- * The styles are inference, unlike the names: they are how this renderer
597
- * reproduces the measured geometry, and the three `scrollview-*` golden cases
598
- * are what decides whether the inference is right.
599
- */
600
- ScrollView: {
601
- hasText: !1,
602
- classes: ["unity-scroll-view"],
603
- parts: [
604
- // Fills the ScrollView's content box, and lays the viewport out beside
605
- // the vertical scrollbar — hence row.
606
- {
607
- name: "unity-content-and-vertical-scroll-container",
608
- style: { "flex-grow": "1", "flex-direction": "row" }
609
- },
610
- // What actually clips. Takes whatever width the scrollbar leaves.
611
- { name: "unity-content-viewport", style: { "flex-grow": "1", overflow: "hidden" } },
612
- // `flex-shrink: 0` is the whole reason a ScrollView is not one box:
613
- // this grows to the content's height instead of being squeezed into the
614
- // viewport's, so children keep their sizes and the viewport crops them.
615
- // Without it three 60px children in a 100px view come out 33/34/33.
616
- { name: "unity-content-container", style: { "flex-shrink": "0" } }
617
- ]
618
- }
619
- }, re = { hasText: !1, classes: [], parts: [] }, yt = "UXML", xt = /* @__PURE__ */ new Set(["Style"]);
620
- function kt(e) {
621
- return xt.has(e.name.local);
622
- }
623
- function H(e) {
624
- var t;
625
- if (((t = e.derived) == null ? void 0 : t.kind) === "template-container") return { spec: re, fallback: !1 };
626
- const n = He[e.name.local];
627
- return n !== void 0 ? { spec: n, fallback: !1 } : St(e) ? { spec: re, fallback: !1 } : { spec: re, fallback: !0 };
628
- }
629
- function St(e) {
630
- return e.name.local === yt;
631
- }
632
- function $t(e) {
633
- return H(e).spec.classes;
634
- }
635
- function Tt() {
636
- return Object.keys(He);
637
- }
638
- const Z = "6000.0.40f1", Ve = `:disabled {
656
+ const te = "6000.0.40f1", Je = `:disabled {
639
657
  opacity: 0.5;
640
658
  }
641
659
 
@@ -643,42 +661,220 @@ const Z = "6000.0.40f1", Ve = `:disabled {
643
661
  margin: 1px 3px;
644
662
  -unity-text-align: middle-center;
645
663
  }
646
- `, Ot = 13;
647
- function Et(e) {
648
- return e ? Ot : 0;
649
- }
650
- const Nt = /* @__PURE__ */ new Set([
651
- "color",
652
- "font-size",
653
- "letter-spacing",
654
- "word-spacing",
655
- "visibility",
656
- "white-space",
657
- "-unity-font",
658
- "-unity-font-definition",
659
- "-unity-font-style",
660
- "-unity-paragraph-spacing",
661
- "-unity-text-align",
662
- "-unity-text-outline-color",
663
- "-unity-text-outline-width"
664
- ]);
665
- function Dt(e) {
666
- return e.startsWith("--") || Nt.has(e);
664
+ `, Mt = 13;
665
+ function Rt(e) {
666
+ return e ? Mt : 0;
667
+ }
668
+ const At = {
669
+ yoga: "A flexbox style input of Yoga, which UI Toolkit lays out with (CLAUDE.md rule 1); many are compared in the golden set",
670
+ box: "Margin, padding and border widths are part of the box Yoga sizes and places",
671
+ aspectRatio: "Yoga sizes a box from aspect-ratio, which Unity passes through from 6.3",
672
+ all: "Resets every property at once, layout properties included",
673
+ textSize: "Font size sets the measured size of an auto-sized text element",
674
+ textMeasureInferred: "Changes glyph metrics or spacing, which feed the text measurement that sizes an auto-sized text element",
675
+ autoSizeInferred: "Fits the text to the element box rather than the box to the text",
676
+ renderingModeInferred: "Chooses how glyphs are rasterised in the Editor, not how they are measured",
677
+ ellipsisInferred: "Truncates text inside a box that is already sized",
678
+ textAlign: "Places text inside its box; the box does not move (the Step 6 eye check saw it only by looking)",
679
+ textEffectInferred: "Draws around glyphs that are already placed",
680
+ colour: "Colour and corner rounding of a box that is already placed",
681
+ visibility: "Hidden elements keep their space; only display: none removes it",
682
+ transform: "Transforms apply after layout and do not move siblings (Unity Manual, USS transform)",
683
+ background: "Draws inside the box; a VisualElement is not sized by its background",
684
+ overflowInferred: "Clips descendants; with this Yoga version hidden never moved a box (property sheet), and Unity runs Yoga too",
685
+ clipBoxInferred: "Chooses the clipping rectangle, not any box",
686
+ effectInferred: "Post-processes pixels that are already drawn",
687
+ cursor: "Pointer appearance only; nothing is drawn or laid out",
688
+ timeInferred: "Changes values over time; a settled frame, which is what this preview draws, is unaffected"
689
+ }, Ct = {
690
+ /** Row count of each table on the date above. A test holds the data to these. */
691
+ counts: { "6000.0": 95, "6000.3": 99, "6000.6": 102 }
692
+ }, Nt = [
693
+ ["align-content", "6000.0", !1, "layout", "layout", "yoga"],
694
+ ["align-items", "6000.0", !1, "layout", "layout", "yoga"],
695
+ ["align-self", "6000.0", !1, "layout", "layout", "yoga"],
696
+ ["all", "6000.0", !1, "none", "layout", "all"],
697
+ ["animation-play-state", "6000.6", !1, "none", "none", "timeInferred"],
698
+ ["aspect-ratio", "6000.3", !1, "none", "layout", "aspectRatio"],
699
+ ["backdrop-filter", "6000.6", !1, "none", "paint", "effectInferred"],
700
+ ["background-color", "6000.0", !1, "paint", "paint", "colour"],
701
+ ["background-image", "6000.0", !1, "paint", "paint", "background"],
702
+ ["background-position", "6000.0", !1, "paint", "paint", "background"],
703
+ ["background-position-x", "6000.0", !1, "none", "paint", "background"],
704
+ ["background-position-y", "6000.0", !1, "none", "paint", "background"],
705
+ ["background-repeat", "6000.0", !1, "paint", "paint", "background"],
706
+ ["background-size", "6000.0", !1, "paint", "paint", "background"],
707
+ ["border-bottom-color", "6000.0", !1, "paint", "paint", "colour"],
708
+ ["border-bottom-left-radius", "6000.0", !1, "paint", "paint", "colour"],
709
+ ["border-bottom-right-radius", "6000.0", !1, "paint", "paint", "colour"],
710
+ ["border-bottom-width", "6000.0", !1, "layout", "layout", "box"],
711
+ ["border-color", "6000.0", !1, "paint", "paint", "colour"],
712
+ ["border-left-color", "6000.0", !1, "paint", "paint", "colour"],
713
+ ["border-left-width", "6000.0", !1, "layout", "layout", "box"],
714
+ ["border-radius", "6000.0", !1, "paint", "paint", "colour"],
715
+ ["border-right-color", "6000.0", !1, "paint", "paint", "colour"],
716
+ ["border-right-width", "6000.0", !1, "layout", "layout", "box"],
717
+ ["border-top-color", "6000.0", !1, "paint", "paint", "colour"],
718
+ ["border-top-left-radius", "6000.0", !1, "paint", "paint", "colour"],
719
+ ["border-top-right-radius", "6000.0", !1, "paint", "paint", "colour"],
720
+ ["border-top-width", "6000.0", !1, "layout", "layout", "box"],
721
+ ["border-width", "6000.0", !1, "layout", "layout", "box"],
722
+ ["bottom", "6000.0", !1, "layout", "layout", "yoga"],
723
+ ["color", "6000.0", !0, "paint", "paint", "colour"],
724
+ ["cursor", "6000.0", !1, "paint", "none", "cursor"],
725
+ ["display", "6000.0", !1, "layout", "layout", "yoga"],
726
+ ["filter", "6000.3", !1, "none", "paint", "effectInferred"],
727
+ ["flex", "6000.0", !1, "layout", "layout", "yoga"],
728
+ ["flex-basis", "6000.0", !1, "layout", "layout", "yoga"],
729
+ ["flex-direction", "6000.0", !1, "layout", "layout", "yoga"],
730
+ ["flex-grow", "6000.0", !1, "layout", "layout", "yoga"],
731
+ ["flex-shrink", "6000.0", !1, "layout", "layout", "yoga"],
732
+ ["flex-wrap", "6000.0", !1, "layout", "layout", "yoga"],
733
+ ["font-size", "6000.0", !0, "layout", "layout", "textSize"],
734
+ ["height", "6000.0", !1, "layout", "layout", "yoga"],
735
+ ["justify-content", "6000.0", !1, "layout", "layout", "yoga"],
736
+ ["left", "6000.0", !1, "layout", "layout", "yoga"],
737
+ ["letter-spacing", "6000.0", !0, "paint", "layout", "textMeasureInferred"],
738
+ ["margin", "6000.0", !1, "layout", "layout", "box"],
739
+ ["margin-bottom", "6000.0", !1, "layout", "layout", "box"],
740
+ ["margin-left", "6000.0", !1, "layout", "layout", "box"],
741
+ ["margin-right", "6000.0", !1, "layout", "layout", "box"],
742
+ ["margin-top", "6000.0", !1, "layout", "layout", "box"],
743
+ ["max-height", "6000.0", !1, "layout", "layout", "yoga"],
744
+ ["max-width", "6000.0", !1, "layout", "layout", "yoga"],
745
+ ["min-height", "6000.0", !1, "layout", "layout", "yoga"],
746
+ ["min-width", "6000.0", !1, "layout", "layout", "yoga"],
747
+ ["opacity", "6000.0", !1, "paint", "paint", "colour"],
748
+ // Yoga is told about `hidden`, but at this Yoga version it never moves a box;
749
+ // what shows is the clipping, which is the CSS mapping's.
750
+ ["overflow", "6000.0", !1, "paint", "paint", "overflowInferred"],
751
+ ["padding", "6000.0", !1, "layout", "layout", "box"],
752
+ ["padding-bottom", "6000.0", !1, "layout", "layout", "box"],
753
+ ["padding-left", "6000.0", !1, "layout", "layout", "box"],
754
+ ["padding-right", "6000.0", !1, "layout", "layout", "box"],
755
+ ["padding-top", "6000.0", !1, "layout", "layout", "box"],
756
+ ["position", "6000.0", !1, "layout", "layout", "yoga"],
757
+ ["right", "6000.0", !1, "layout", "layout", "yoga"],
758
+ ["rotate", "6000.0", !1, "paint", "paint", "transform"],
759
+ ["scale", "6000.0", !1, "paint", "paint", "transform"],
760
+ ["text-overflow", "6000.0", !1, "paint", "paint", "ellipsisInferred"],
761
+ ["text-shadow", "6000.0", !0, "none", "paint", "textEffectInferred"],
762
+ ["top", "6000.0", !1, "layout", "layout", "yoga"],
763
+ ["transform-origin", "6000.0", !1, "paint", "paint", "transform"],
764
+ ["transition", "6000.0", !1, "none", "none", "timeInferred"],
765
+ ["transition-delay", "6000.0", !1, "none", "none", "timeInferred"],
766
+ ["transition-duration", "6000.0", !1, "none", "none", "timeInferred"],
767
+ ["transition-property", "6000.0", !1, "none", "none", "timeInferred"],
768
+ ["transition-timing-function", "6000.0", !1, "none", "none", "timeInferred"],
769
+ ["translate", "6000.0", !1, "paint", "paint", "transform"],
770
+ ["-unity-animation-clip", "6000.6", !1, "none", "none", "timeInferred"],
771
+ ["-unity-background-image-tint-color", "6000.0", !1, "none", "paint", "background"],
772
+ ["-unity-background-scale-mode", "6000.0", !1, "paint", "paint", "background"],
773
+ ["-unity-editor-text-rendering-mode", "6000.0", !0, "none", "paint", "renderingModeInferred"],
774
+ ["-unity-font", "6000.0", !0, "none", "layout", "textMeasureInferred"],
775
+ ["-unity-font-definition", "6000.0", !0, "none", "layout", "textMeasureInferred"],
776
+ ["-unity-font-style", "6000.0", !0, "layout", "layout", "textMeasureInferred"],
777
+ ["-unity-material", "6000.3", !0, "none", "paint", "effectInferred"],
778
+ ["-unity-overflow-clip-box", "6000.0", !1, "none", "paint", "clipBoxInferred"],
779
+ ["-unity-paragraph-spacing", "6000.0", !0, "none", "layout", "textMeasureInferred"],
780
+ ["-unity-slice-bottom", "6000.0", !1, "none", "paint", "background"],
781
+ ["-unity-slice-left", "6000.0", !1, "none", "paint", "background"],
782
+ ["-unity-slice-right", "6000.0", !1, "none", "paint", "background"],
783
+ ["-unity-slice-scale", "6000.0", !1, "none", "paint", "background"],
784
+ ["-unity-slice-top", "6000.0", !1, "none", "paint", "background"],
785
+ ["-unity-slice-type", "6000.0", !1, "none", "paint", "background"],
786
+ ["-unity-text-align", "6000.0", !0, "paint", "paint", "textAlign"],
787
+ ["-unity-text-auto-size", "6000.3", !0, "none", "paint", "autoSizeInferred"],
788
+ ["-unity-text-generator", "6000.0", !0, "none", "layout", "textMeasureInferred"],
789
+ ["-unity-text-outline", "6000.0", !1, "none", "paint", "textEffectInferred"],
790
+ ["-unity-text-outline-color", "6000.0", !0, "none", "paint", "textEffectInferred"],
791
+ ["-unity-text-outline-width", "6000.0", !0, "none", "paint", "textEffectInferred"],
792
+ ["-unity-text-overflow-position", "6000.0", !1, "none", "paint", "ellipsisInferred"],
793
+ ["visibility", "6000.0", !0, "paint", "paint", "visibility"],
794
+ ["white-space", "6000.0", !0, "layout", "layout", "textMeasureInferred"],
795
+ ["width", "6000.0", !1, "layout", "layout", "yoga"],
796
+ ["word-spacing", "6000.0", !0, "paint", "layout", "textMeasureInferred"]
797
+ ], Ge = Nt.map(
798
+ ([e, n, t, s, r, o]) => ({
799
+ name: e,
800
+ since: n,
801
+ inherited: t,
802
+ handling: s,
803
+ unity: r,
804
+ basis: At[o],
805
+ inferred: o.endsWith("Inferred")
806
+ })
807
+ ), jt = new Map(Ge.map((e) => [e.name, e]));
808
+ function zt(e) {
809
+ return jt.get(e);
810
+ }
811
+ const Lt = {
812
+ "font-family": ["-unity-font-definition"],
813
+ "font-weight": ["-unity-font-style"],
814
+ "font-style": ["-unity-font-style"],
815
+ "text-align": ["-unity-text-align"],
816
+ transform: ["translate", "rotate", "scale"],
817
+ "border-image": ["-unity-slice-left", "-unity-slice-top", "-unity-slice-right", "-unity-slice-bottom"],
818
+ "vertical-align": ["-unity-text-align"],
819
+ font: ["font-size", "-unity-font-definition", "-unity-font-style"],
820
+ inset: ["top", "right", "bottom", "left"],
821
+ "overflow-x": ["overflow"],
822
+ "overflow-y": ["overflow"]
823
+ }, Ut = {
824
+ "aspect-ratio": "not applied to layout by this preview",
825
+ "-unity-font": "font not loaded by this preview; the browser default is used",
826
+ "-unity-font-definition": "font not loaded by this preview; the browser default is used",
827
+ transition: "not animated by this preview",
828
+ "transition-delay": "not animated by this preview",
829
+ "transition-duration": "not animated by this preview",
830
+ "transition-property": "not animated by this preview",
831
+ "transition-timing-function": "not animated by this preview",
832
+ "animation-play-state": "not animated by this preview",
833
+ "-unity-animation-clip": "not animated by this preview"
834
+ }, _t = `6.${Object.keys(Ct.counts).sort().at(-1).slice(5)}`;
835
+ function Wt(e) {
836
+ return `Unity 6.${e.slice(5)}+`;
837
+ }
838
+ function Xe(e, n) {
839
+ if (e.startsWith("--")) return null;
840
+ const t = zt(e);
841
+ if (t === void 0) {
842
+ const o = Lt[e];
843
+ return {
844
+ message: `${e}: not in the USS property reference up to Unity ${_t}; ignored` + (o === void 0 ? "" : `; USS uses ${o.join(", ")}`),
845
+ reason: "not-uss",
846
+ subject: { kind: "property", property: e, value: n, ...o === void 0 ? {} : { replacements: o } }
847
+ };
848
+ }
849
+ const s = t.unity === "layout", r = t.since === "6000.0" ? "" : ` (${Wt(t.since)})`;
850
+ return t.handling === "paint" && s ? {
851
+ message: `${e}${r}: drawn, but left out of text measurement by this preview`,
852
+ reason: "not-rendered",
853
+ subject: { kind: "property", property: e, value: n, since: t.since, affectsLayout: s, applied: "paint" }
854
+ } : t.handling !== "none" ? null : {
855
+ message: `${e}${r}: ${Ut[e] ?? "not drawn by this preview"}`,
856
+ reason: "not-rendered",
857
+ subject: { kind: "property", property: e, value: n, since: t.since, affectsLayout: s }
858
+ };
667
859
  }
668
- function $e(e) {
860
+ const Pt = ["hover", "active", "inactive", "focus", "disabled", "enabled", "checked"], Ft = new Set(Ge.filter((e) => e.inherited).map((e) => e.name));
861
+ function Bt(e) {
862
+ return e.startsWith("--") || Ft.has(e);
863
+ }
864
+ function Oe(e) {
669
865
  const n = [];
670
866
  let t = 0, s = -1;
671
- for (let i = 0; i < e.length; i++) {
672
- const r = e[i];
673
- r === "(" ? t++ : r === ")" && (t = Math.max(0, t - 1)), t === 0 && /\s/.test(r) ? s >= 0 && (n.push(e.slice(s, i)), s = -1) : s < 0 && (s = i);
867
+ for (let r = 0; r < e.length; r++) {
868
+ const o = e[r];
869
+ o === "(" ? t++ : o === ")" && (t = Math.max(0, t - 1)), t === 0 && /\s/.test(o) ? s >= 0 && (n.push(e.slice(s, r)), s = -1) : s < 0 && (s = r);
674
870
  }
675
871
  return s >= 0 && n.push(e.slice(s)), n;
676
872
  }
677
- function At(e) {
678
- const [n, t, s, i] = e;
679
- return n === void 0 ? null : t === void 0 ? [n, n, n, n] : s === void 0 ? [n, t, n, t] : i === void 0 ? [n, t, s, t] : [n, t, s, i];
873
+ function Ht(e) {
874
+ const [n, t, s, r] = e;
875
+ return n === void 0 ? null : t === void 0 ? [n, n, n, n] : s === void 0 ? [n, t, n, t] : r === void 0 ? [n, t, s, t] : [n, t, s, r];
680
876
  }
681
- const It = {
877
+ const Vt = {
682
878
  margin: ["margin-top", "margin-right", "margin-bottom", "margin-left"],
683
879
  padding: ["padding-top", "padding-right", "padding-bottom", "padding-left"],
684
880
  "border-width": [
@@ -701,21 +897,21 @@ const It = {
701
897
  "border-bottom-left-radius"
702
898
  ]
703
899
  };
704
- function Te(e) {
900
+ function De(e) {
705
901
  return /^-?(\d+\.?\d*|\.\d+)$/.test(e);
706
902
  }
707
- function Rt(e) {
903
+ function Yt(e) {
708
904
  const [n, t, s] = e;
709
- return n === void 0 ? [] : n === "none" ? [["flex-grow", "0"], ["flex-shrink", "0"], ["flex-basis", "auto"]] : n === "auto" ? [["flex-grow", "1"], ["flex-shrink", "1"], ["flex-basis", "auto"]] : t === void 0 ? Te(n) ? [["flex-grow", n], ["flex-shrink", "1"], ["flex-basis", "0"]] : [["flex-grow", "1"], ["flex-shrink", "1"], ["flex-basis", n]] : s === void 0 ? Te(t) ? [["flex-grow", n], ["flex-shrink", t], ["flex-basis", "0"]] : [["flex-grow", n], ["flex-shrink", "1"], ["flex-basis", t]] : [["flex-grow", n], ["flex-shrink", t], ["flex-basis", s]];
905
+ return n === void 0 ? [] : n === "none" ? [["flex-grow", "0"], ["flex-shrink", "0"], ["flex-basis", "auto"]] : n === "auto" ? [["flex-grow", "1"], ["flex-shrink", "1"], ["flex-basis", "auto"]] : t === void 0 ? De(n) ? [["flex-grow", n], ["flex-shrink", "1"], ["flex-basis", "0"]] : [["flex-grow", "1"], ["flex-shrink", "1"], ["flex-basis", n]] : s === void 0 ? De(t) ? [["flex-grow", n], ["flex-shrink", t], ["flex-basis", "0"]] : [["flex-grow", n], ["flex-shrink", "1"], ["flex-basis", t]] : [["flex-grow", n], ["flex-shrink", t], ["flex-basis", s]];
710
906
  }
711
- function ie(e, n) {
712
- if (e === "flex") return Rt($e(n));
713
- const t = It[e];
907
+ function le(e, n) {
908
+ if (e === "flex") return Yt(Oe(n));
909
+ const t = Vt[e];
714
910
  if (t === void 0) return [[e, n]];
715
- const s = At($e(n));
716
- return s === null ? [[e, n]] : t.map((i, r) => [i, s[r]]);
911
+ const s = Ht(Oe(n));
912
+ return s === null ? [[e, n]] : t.map((r, o) => [r, s[o]]);
717
913
  }
718
- const ae = {
914
+ const fe = {
719
915
  "align-content": "flex-start",
720
916
  "align-items": "stretch",
721
917
  "align-self": "auto",
@@ -751,314 +947,335 @@ const ae = {
751
947
  "padding-right": "0",
752
948
  "padding-top": "0",
753
949
  "font-size": "12px"
754
- }, Ct = ["em", "rem", "vh", "vw", "vmin", "vmax", "pt", "cm", "in"];
755
- function Q(e) {
950
+ }, qt = ["em", "rem", "vh", "vw", "vmin", "vmax", "pt", "cm", "in"];
951
+ function ne(e) {
756
952
  const n = e.trim();
757
- if (n === "") return { length: null, problem: "empty value" };
953
+ if (n === "") return { length: null, problem: "empty value", reason: "invalid-value" };
758
954
  if (n === "auto") return { length: { kind: "auto" } };
759
955
  if (n === "none") return { length: { kind: "none" } };
760
956
  if (n === "initial") return { length: { kind: "auto" } };
761
957
  if (n.startsWith("calc("))
762
- return { length: null, problem: "calc() is not supported in USS" };
958
+ return { length: null, problem: "calc() is not evaluated", reason: "not-uss" };
763
959
  const t = /^(-?(?:\d+\.?\d*|\.\d+))([a-z%]*)$/i.exec(n);
764
- if (t === null) return { length: null, problem: `cannot read "${n}" as a length` };
765
- const s = Number(t[1]), i = t[2].toLowerCase();
766
- return i === "" || i === "px" ? { length: { kind: "px", value: s } } : i === "%" ? { length: { kind: "percent", value: s } } : Ct.includes(i) ? { length: null, problem: `"${i}" is not a USS unit` } : { length: null, problem: `unknown unit "${i}"` };
960
+ if (t === null)
961
+ return { length: null, problem: `cannot read "${n}" as a length`, reason: "invalid-value" };
962
+ const s = Number(t[1]), r = t[2].toLowerCase();
963
+ return r === "" || r === "px" ? { length: { kind: "px", value: s } } : r === "%" ? { length: { kind: "percent", value: s } } : qt.includes(r) ? { length: null, problem: `unit "${r}" not recognised`, reason: "not-uss" } : { length: null, problem: `unknown unit "${r}"`, reason: "invalid-value" };
767
964
  }
768
- function Oe(e) {
965
+ function Me(e) {
769
966
  const n = e.trim();
770
967
  return /^-?(\d+\.?\d*|\.\d+)$/.test(n) ? Number(n) : null;
771
968
  }
772
- let me = null;
773
- async function yn() {
774
- me ?? (me = await tt());
775
- }
776
- function xn() {
777
- return me !== null;
778
- }
779
- let K = 0;
780
- function kn() {
781
- return K;
782
- }
783
- const oe = {
784
- auto: W.Auto,
785
- "flex-start": W.FlexStart,
786
- center: W.Center,
787
- "flex-end": W.FlexEnd,
788
- stretch: W.Stretch,
789
- baseline: W.Baseline,
790
- "space-between": W.SpaceBetween,
791
- "space-around": W.SpaceAround,
792
- "space-evenly": W.SpaceEvenly
793
- }, Mt = {
794
- "flex-start": P.FlexStart,
795
- center: P.Center,
796
- "flex-end": P.FlexEnd,
797
- "space-between": P.SpaceBetween,
798
- "space-around": P.SpaceAround,
799
- "space-evenly": P.SpaceEvenly
800
- }, Ut = {
969
+ let be = null;
970
+ async function Nn() {
971
+ be ?? (be = await it());
972
+ }
973
+ function jn() {
974
+ return be !== null;
975
+ }
976
+ let Q = 0;
977
+ function zn() {
978
+ return Q;
979
+ }
980
+ const ce = {
981
+ auto: L.Auto,
982
+ "flex-start": L.FlexStart,
983
+ center: L.Center,
984
+ "flex-end": L.FlexEnd,
985
+ stretch: L.Stretch,
986
+ baseline: L.Baseline,
987
+ "space-between": L.SpaceBetween,
988
+ "space-around": L.SpaceAround,
989
+ "space-evenly": L.SpaceEvenly
990
+ }, Jt = {
991
+ "flex-start": B.FlexStart,
992
+ center: B.Center,
993
+ "flex-end": B.FlexEnd,
994
+ "space-between": B.SpaceBetween,
995
+ "space-around": B.SpaceAround,
996
+ "space-evenly": B.SpaceEvenly
997
+ }, Gt = {
801
998
  column: G.Column,
802
999
  "column-reverse": G.ColumnReverse,
803
1000
  row: G.Row,
804
1001
  "row-reverse": G.RowReverse
805
- }, Lt = {
806
- nowrap: Y.NoWrap,
807
- wrap: Y.Wrap,
808
- "wrap-reverse": Y.WrapReverse
809
- }, Wt = [
810
- ["left", q.Left],
811
- ["top", q.Top],
812
- ["right", q.Right],
813
- ["bottom", q.Bottom]
1002
+ }, Xt = {
1003
+ nowrap: K.NoWrap,
1004
+ wrap: K.Wrap,
1005
+ "wrap-reverse": K.WrapReverse
1006
+ }, Zt = [
1007
+ ["left", J.Left],
1008
+ ["top", J.Top],
1009
+ ["right", J.Right],
1010
+ ["bottom", J.Bottom]
814
1011
  ];
815
- function zt(e, n, t, s) {
816
- const i = me;
817
- if (i === null)
1012
+ function Kt(e, n, t, s) {
1013
+ const r = be;
1014
+ if (r === null)
818
1015
  throw new Error("loadLayoutEngine() must be awaited before rendering");
819
- const r = [], u = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), v = [], d = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
820
- let a = 0, f = !1, l = !1;
821
- const h = (w, S) => {
822
- var T;
823
- return ((T = w.get(S)) == null ? void 0 : T.value) ?? ae[S] ?? "";
1016
+ const o = [], d = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), x = [], h = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
1017
+ let c = 0, u = !1, p = !1;
1018
+ const i = (b, S) => {
1019
+ var I;
1020
+ return ((I = b.get(S)) == null ? void 0 : I.value) ?? fe[S] ?? "";
824
1021
  };
825
- function g(w, S) {
826
- r.push({ kind: "unsupported-property", message: w, node: S.id });
827
- }
828
- function p(w, S, T) {
829
- const N = h(w, S);
830
- if (N === "") return null;
831
- const { length: D, problem: A } = Q(N);
832
- return A !== void 0 && g(`${S}: ${A}`, T), D;
833
- }
834
- function b(w) {
835
- if (w !== null)
836
- switch (w.kind) {
1022
+ function y(b, S, I, E) {
1023
+ var D;
1024
+ (E == null ? void 0 : E.origin.kind) !== "inherited" && o.push({
1025
+ kind: "unsupported-property",
1026
+ message: b,
1027
+ node: S.id,
1028
+ ...I,
1029
+ ...E === void 0 ? {} : ((D = s.locate) == null ? void 0 : D.call(s, E.origin)) ?? {}
1030
+ });
1031
+ }
1032
+ function k(b, S, I) {
1033
+ const E = i(b, S);
1034
+ if (E === "") return null;
1035
+ const { length: D, problem: M, reason: A } = ne(E);
1036
+ return M !== void 0 && y(
1037
+ `${S}: ${M}`,
1038
+ I,
1039
+ {
1040
+ ...A === void 0 ? {} : { reason: A },
1041
+ subject: { kind: "property", property: S, value: E }
1042
+ },
1043
+ b.get(S)
1044
+ ), D;
1045
+ }
1046
+ function f(b) {
1047
+ if (b !== null)
1048
+ switch (b.kind) {
837
1049
  case "px":
838
- return w.value;
1050
+ return b.value;
839
1051
  case "percent":
840
- return `${w.value}%`;
1052
+ return `${b.value}%`;
841
1053
  case "auto":
842
1054
  return "auto";
843
1055
  case "none":
844
1056
  return;
845
1057
  }
846
1058
  }
847
- function m(w) {
848
- if (w !== null) {
849
- if (w.kind === "px") return w.value;
850
- if (w.kind === "percent") return `${w.value}%`;
1059
+ function m(b) {
1060
+ if (b !== null) {
1061
+ if (b.kind === "px") return b.value;
1062
+ if (b.kind === "percent") return `${b.value}%`;
851
1063
  }
852
1064
  }
853
- function y(w, S, T) {
854
- w.setBoxSizing(nt.BorderBox), w.setFlexDirection(Ut[h(S, "flex-direction")] ?? G.Column), w.setFlexWrap(Lt[h(S, "flex-wrap")] ?? Y.NoWrap), w.setJustifyContent(Mt[h(S, "justify-content")] ?? P.FlexStart), w.setAlignItems(oe[h(S, "align-items")] ?? W.Stretch), w.setAlignSelf(oe[h(S, "align-self")] ?? W.Auto), w.setAlignContent(oe[h(S, "align-content")] ?? W.FlexStart), w.setFlexGrow(Oe(h(S, "flex-grow")) ?? 0), w.setFlexShrink(Oe(h(S, "flex-shrink")) ?? 1), w.setFlexBasis(b(p(S, "flex-basis", T)));
855
- const N = h(S, "position");
856
- (N === "fixed" || N === "sticky") && g(`position: ${N} is not supported in USS; treated as relative`, T), w.setPositionType(
857
- N === "absolute" ? ne.Absolute : ne.Relative
858
- ), h(S, "display") === "none" && w.setDisplay(st.None);
859
- const D = h(S, "overflow");
860
- D === "hidden" ? w.setOverflow(rt.Hidden) : (D === "auto" || D === "scroll") && g(`overflow: ${D} needs a ScrollView element in USS`, T), w.setWidth(b(p(S, "width", T))), w.setHeight(b(p(S, "height", T))), w.setMinWidth(m(p(S, "min-width", T))), w.setMinHeight(m(p(S, "min-height", T))), w.setMaxWidth(m(p(S, "max-width", T))), w.setMaxHeight(m(p(S, "max-height", T)));
861
- for (const [A, I] of Wt) {
862
- w.setMargin(I, m(p(S, `margin-${A}`, T))), w.setPadding(I, m(p(S, `padding-${A}`, T)));
863
- const _ = m(p(S, `border-${A}-width`, T));
864
- w.setBorder(I, typeof _ == "number" ? _ : void 0), w.setPosition(I, m(p(S, A, T)));
1065
+ function v(b, S, I) {
1066
+ b.setBoxSizing(at.BorderBox), b.setFlexDirection(Gt[i(S, "flex-direction")] ?? G.Column), b.setFlexWrap(Xt[i(S, "flex-wrap")] ?? K.NoWrap), b.setJustifyContent(Jt[i(S, "justify-content")] ?? B.FlexStart), b.setAlignItems(ce[i(S, "align-items")] ?? L.Stretch), b.setAlignSelf(ce[i(S, "align-self")] ?? L.Auto), b.setAlignContent(ce[i(S, "align-content")] ?? L.FlexStart), b.setFlexGrow(Me(i(S, "flex-grow")) ?? 0), b.setFlexShrink(Me(i(S, "flex-shrink")) ?? 1), b.setFlexBasis(f(k(S, "flex-basis", I)));
1067
+ const E = i(S, "position");
1068
+ (E === "fixed" || E === "sticky") && y(`position: ${E} treated as relative`, I, {
1069
+ reason: "not-uss",
1070
+ subject: { kind: "property", property: "position", value: E }
1071
+ }, S.get("position")), b.setPositionType(
1072
+ E === "absolute" ? re.Absolute : re.Relative
1073
+ );
1074
+ const D = i(S, "display");
1075
+ D === "none" ? b.setDisplay(lt.None) : D !== "flex" && D !== "initial" && y(`display: ${D} laid out as flex`, I, {
1076
+ reason: "invalid-value",
1077
+ subject: { kind: "property", property: "display", value: D }
1078
+ }, S.get("display"));
1079
+ const M = i(S, "overflow");
1080
+ M === "hidden" ? b.setOverflow(ct.Hidden) : (M === "auto" || M === "scroll") && y(`overflow: ${M} ignored; nothing scrolls`, I, {
1081
+ reason: "not-uss",
1082
+ subject: { kind: "property", property: "overflow", value: M }
1083
+ }, S.get("overflow")), b.setWidth(f(k(S, "width", I))), b.setHeight(f(k(S, "height", I))), b.setMinWidth(m(k(S, "min-width", I))), b.setMinHeight(m(k(S, "min-height", I))), b.setMaxWidth(m(k(S, "max-width", I))), b.setMaxHeight(m(k(S, "max-height", I)));
1084
+ for (const [A, U] of Zt) {
1085
+ b.setMargin(U, m(k(S, `margin-${A}`, I))), b.setPadding(U, m(k(S, `padding-${A}`, I)));
1086
+ const _ = m(k(S, `border-${A}-width`, I));
1087
+ b.setBorder(U, typeof _ == "number" ? _ : void 0), b.setPosition(U, m(k(S, A, I)));
865
1088
  }
866
1089
  }
867
- function k(w) {
1090
+ function w(b) {
868
1091
  var S;
869
- return (S = w.attributes.find((T) => T.name === "text")) == null ? void 0 : S.value;
1092
+ return (S = b.attributes.find((I) => I.name === "text")) == null ? void 0 : S.value;
870
1093
  }
871
- const x = ["text", "label"];
872
- function $(w) {
873
- return x.filter(
874
- (S) => w.attributes.some((T) => T.name === S && T.value.length > 0)
1094
+ const g = ["text", "label"];
1095
+ function $(b) {
1096
+ return g.filter(
1097
+ (S) => b.attributes.some((I) => I.name === S && I.value.length > 0)
875
1098
  );
876
1099
  }
877
- function O(w, S) {
878
- if (kt(w)) return;
879
- const T = n.get(w.id) ?? /* @__PURE__ */ new Map(), N = i.Node.create();
880
- a++, K++, d.set(w, N), v.push(w), y(N, T, w), S !== null && S.insertChild(N, S.getChildCount());
881
- const { spec: D, fallback: A } = H(w), I = k(w), _ = D.hasText && I !== void 0 && I.length > 0;
882
- if (A) {
883
- const R = $(w);
884
- r.push({
1100
+ let T = !1;
1101
+ function O(b, S) {
1102
+ if (de(b)) {
1103
+ b.name.local === "Bindings" && !T && (T = !0, o.push({
1104
+ kind: "unsupported-control",
1105
+ message: "Data bindings are not evaluated in this preview; bound values show as written",
1106
+ node: b.id,
1107
+ reason: "not-rendered",
1108
+ subject: { kind: "control", type: "Bindings" }
1109
+ }));
1110
+ return;
1111
+ }
1112
+ const I = n.get(b.id) ?? /* @__PURE__ */ new Map(), E = r.Node.create();
1113
+ c++, Q++, h.set(b, E), x.push(b), v(E, I, b), S !== null && S.insertChild(E, S.getChildCount());
1114
+ const { spec: D, fallback: M } = Y(b), A = w(b), U = D.hasText && A !== void 0 && A.length > 0;
1115
+ if (M) {
1116
+ const C = $(b);
1117
+ o.push({
885
1118
  kind: "unsupported-control",
886
- message: `<${w.name.local}> has no renderer in this version and is drawn as a plain VisualElement` + (R.length === 0 ? "" : `; its ${R.join(" and ")} attribute${R.length > 1 ? "s are" : " is"} not drawn, because Unity draws that through a child element`),
887
- node: w.id
1119
+ message: `<${b.name.local}> has no renderer in this version and is drawn as a plain VisualElement` + (C.length === 0 ? "" : `; its ${C.join(" and ")} attribute${C.length > 1 ? "s are" : " is"} not drawn`),
1120
+ node: b.id,
1121
+ reason: "not-rendered",
1122
+ subject: { kind: "control", type: b.name.local }
888
1123
  });
889
1124
  }
890
- if (_) {
891
- w.children.length > 0 && g(
892
- `<${w.name.local}> has both a text attribute and children; children are not drawn`,
893
- w
1125
+ if (U) {
1126
+ b.children.some((N) => !de(N)) && y(
1127
+ `<${b.name.local}> has both a text attribute and children; children are not drawn`,
1128
+ b,
1129
+ { reason: "not-rendered", subject: { kind: "control", type: b.name.local } }
894
1130
  );
895
- const R = p(T, "font-size", w), z = {
896
- fontSize: R !== null && R.kind === "px" ? R.value : 12,
897
- fontStyle: h(T, "-unity-font-style") || "normal",
898
- whiteSpace: h(T, "white-space") || "normal"
1131
+ const C = k(I, "font-size", b), P = {
1132
+ fontSize: C !== null && C.kind === "px" ? C.value : 12,
1133
+ fontStyle: i(I, "-unity-font-style") || "normal",
1134
+ whiteSpace: i(I, "white-space") || "normal"
899
1135
  };
900
- N.setMeasureFunc(
901
- (M) => s.measureText(
902
- I,
903
- z,
904
- Number.isFinite(M) ? M : 0
1136
+ E.setMeasureFunc(
1137
+ (N) => s.measureText(
1138
+ A,
1139
+ P,
1140
+ Number.isFinite(N) ? N : 0
905
1141
  )
906
1142
  );
907
1143
  return;
908
1144
  }
909
- let F = N;
1145
+ let _ = E;
910
1146
  if (D.parts.length > 0) {
911
- l || (l = !0, r.push({
1147
+ p || (p = !0, o.push({
912
1148
  kind: "version-dependent",
913
- message: `<${w.name.local}> is drawn with the implicit child elements Unity builds for it, and their geometry was measured on Unity ${Z}. Other versions may differ; see src/controls/theme.ts.`,
914
- node: w.id
1149
+ message: `<${b.name.local}> drawn with built-in child elements measured on Unity ${te}`,
1150
+ node: b.id,
1151
+ reason: "version-dependent",
1152
+ subject: { kind: "control", type: b.name.local }
915
1153
  }));
916
- const R = [], z = [], M = t.get(w.id);
917
- for (const we of D.parts) {
918
- const ve = (M == null ? void 0 : M.get(we.name)) ?? /* @__PURE__ */ new Map(), X = i.Node.create();
919
- a++, K++, y(X, ve, w), F.insertChild(X, F.getChildCount()), F = X, z.push(X), R.push({
920
- name: we.name,
921
- owner: w.id,
1154
+ const C = [], P = [], N = t.get(b.id);
1155
+ for (const xe of D.parts) {
1156
+ const ke = (N == null ? void 0 : N.get(xe.name)) ?? /* @__PURE__ */ new Map(), Z = r.Node.create();
1157
+ c++, Q++, v(Z, ke, b), _.insertChild(Z, _.getChildCount()), _ = Z, P.push(Z), C.push({
1158
+ name: xe.name,
1159
+ owner: b.id,
922
1160
  box: { left: 0, top: 0, width: 0, height: 0 },
923
- style: ve
1161
+ style: ke
924
1162
  });
925
1163
  }
926
- c.set(w.id, R), o.set(w.id, z);
1164
+ a.set(b.id, C), l.set(b.id, P);
927
1165
  }
928
- for (const R of w.children) O(R, F);
1166
+ for (const C of b.children) O(C, _);
929
1167
  }
930
1168
  O(e, null);
931
- const E = d.get(e);
932
- E.setWidth(s.size.width), E.setHeight(s.size.height), E.setPositionType(ne.Relative), E.calculateLayout(s.size.width, s.size.height, be.LTR);
933
- const C = /* @__PURE__ */ new Map();
934
- for (let w = 0; w < 3; w++) {
1169
+ const R = h.get(e);
1170
+ R.setWidth(s.size.width), R.setHeight(s.size.height), R.setPositionType(re.Relative), R.calculateLayout(s.size.width, s.size.height, Se.LTR);
1171
+ const z = /* @__PURE__ */ new Map();
1172
+ for (let b = 0; b < 3; b++) {
935
1173
  let S = !1;
936
- for (const [T, N] of c) {
937
- const D = o.get(T);
1174
+ for (const [I, E] of a) {
1175
+ const D = l.get(I);
938
1176
  if (D === void 0) continue;
939
- const A = N.findIndex((M) => M.name === "unity-content-viewport"), I = N.findIndex((M) => M.name === "unity-content-container");
940
- if (A === -1 || I === -1) continue;
941
- const _ = D[A].getComputedLayout(), R = D[I].getComputedLayout().height > _.height + 0.01, z = Et(R);
942
- (C.get(T) ?? 0) !== z && (C.set(T, z), D[A].setMargin(q.Right, z), S = !0);
1177
+ const M = E.findIndex((N) => N.name === "unity-content-viewport"), A = E.findIndex((N) => N.name === "unity-content-container");
1178
+ if (M === -1 || A === -1) continue;
1179
+ const U = D[M].getComputedLayout(), C = D[A].getComputedLayout().height > U.height + 0.01, P = Rt(C);
1180
+ (z.get(I) ?? 0) !== P && (z.set(I, P), D[M].setMargin(J.Right, P), S = !0);
943
1181
  }
944
1182
  if (!S) break;
945
- E.calculateLayout(s.size.width, s.size.height, be.LTR);
946
- }
947
- function L(w, S, T) {
948
- const N = d.get(w);
949
- if (N === void 0) return;
950
- const D = N.getComputedLayout();
951
- let A = S + D.left, I = T + D.top;
952
- u.set(w.id, { left: A, top: I, width: D.width, height: D.height });
953
- const _ = c.get(w.id), F = o.get(w.id);
954
- _ !== void 0 && F !== void 0 && _.forEach((R, z) => {
955
- const M = F[z].getComputedLayout();
956
- A += M.left, I += M.top, R.box = { left: A, top: I, width: M.width, height: M.height };
1183
+ R.calculateLayout(s.size.width, s.size.height, Se.LTR);
1184
+ }
1185
+ function W(b, S, I) {
1186
+ const E = h.get(b);
1187
+ if (E === void 0) return;
1188
+ const D = E.getComputedLayout();
1189
+ let M = S + D.left, A = I + D.top;
1190
+ d.set(b.id, { left: M, top: A, width: D.width, height: D.height });
1191
+ const U = a.get(b.id), _ = l.get(b.id);
1192
+ U !== void 0 && _ !== void 0 && U.forEach((C, P) => {
1193
+ const N = _[P].getComputedLayout();
1194
+ M += N.left, A += N.top, C.box = { left: M, top: A, width: N.width, height: N.height };
957
1195
  });
958
- for (const R of w.children) L(R, A, I);
1196
+ for (const C of b.children) W(C, M, A);
959
1197
  }
960
- return L(e, 0, 0), {
961
- boxes: u,
962
- parts: c,
963
- painted: v,
964
- warnings: r,
1198
+ return W(e, 0, 0), {
1199
+ boxes: d,
1200
+ parts: a,
1201
+ painted: x,
1202
+ warnings: o,
965
1203
  dispose() {
966
- f || (f = !0, E.freeRecursive(), K -= a, d.clear(), o.clear());
1204
+ u || (u = !0, R.freeRecursive(), Q -= c, h.clear(), l.clear());
967
1205
  }
968
1206
  };
969
1207
  }
970
- const _t = 1.2;
971
- function jt(e) {
1208
+ const Qt = 1.2;
1209
+ function en(e) {
972
1210
  var t;
973
1211
  let n = null;
974
1212
  if (e !== void 0) {
975
1213
  const s = e.createElement("canvas");
976
1214
  n = ((t = s.getContext) == null ? void 0 : t.call(s, "2d")) ?? null;
977
1215
  }
978
- return (s, i, r) => {
979
- const u = i.fontSize * _t, c = (l) => {
1216
+ return (s, r, o) => {
1217
+ const d = r.fontSize * Qt, a = (p) => {
980
1218
  if (n === null)
981
- return l.length * i.fontSize * 0.5;
982
- const h = i.fontStyle.includes("bold") ? "bold" : "normal", g = i.fontStyle.includes("italic") ? "italic" : "normal";
983
- return n.font = `${g} ${h} ${i.fontSize}px sans-serif`, n.measureText(l).width;
1219
+ return p.length * r.fontSize * 0.5;
1220
+ const i = r.fontStyle.includes("bold") ? "bold" : "normal", y = r.fontStyle.includes("italic") ? "italic" : "normal";
1221
+ return n.font = `${y} ${i} ${r.fontSize}px sans-serif`, n.measureText(p).width;
984
1222
  };
985
- if (!(i.whiteSpace !== "nowrap" && i.whiteSpace !== "pre") || r <= 0) {
986
- const l = s.split(`
1223
+ if (!(r.whiteSpace !== "nowrap" && r.whiteSpace !== "pre") || o <= 0) {
1224
+ const p = s.split(`
987
1225
  `);
988
- return { width: l.reduce((g, p) => Math.max(g, c(p)), 0), height: l.length * u };
1226
+ return { width: p.reduce((y, k) => Math.max(y, a(k)), 0), height: p.length * d };
989
1227
  }
990
- const d = s.split(/\s+/).filter((l) => l.length > 0);
991
- let o = 1, a = 0, f = 0;
992
- for (const l of d) {
993
- const h = c(l), g = a === 0 ? 0 : c(" ");
994
- a > 0 && a + g + h > r ? (f = Math.max(f, a), o++, a = h) : a += g + h;
1228
+ const h = s.split(/\s+/).filter((p) => p.length > 0);
1229
+ let l = 1, c = 0, u = 0;
1230
+ for (const p of h) {
1231
+ const i = a(p), y = c === 0 ? 0 : a(" ");
1232
+ c > 0 && c + y + i > o ? (u = Math.max(u, c), l++, c = i) : c += y + i;
995
1233
  }
996
- return f = Math.max(f, a), { width: f, height: o * u };
1234
+ return u = Math.max(u, c), { width: u, height: l * d };
997
1235
  };
998
1236
  }
999
- const Ft = /* @__PURE__ */ new Set([
1000
- "box-shadow",
1001
- "filter",
1002
- "backdrop-filter",
1003
- "mix-blend-mode",
1004
- "background-blend-mode",
1005
- "clip-path",
1006
- "mask",
1007
- "outline",
1008
- "line-height",
1009
- "text-transform",
1010
- "text-decoration",
1011
- "z-index",
1012
- "float",
1013
- "clear",
1014
- "border-style"
1015
- ]), Pt = /* @__PURE__ */ new Set([
1016
- "gap",
1017
- "row-gap",
1018
- "column-gap",
1019
- "aspect-ratio",
1020
- "background-size",
1021
- "background-position",
1022
- "background-repeat",
1023
- "overflow-wrap",
1024
- "word-break"
1025
- ]), Ee = ["top", "right", "bottom", "left"], Bt = {
1237
+ const tn = ["top", "right", "bottom", "left"], nn = {
1026
1238
  normal: { weight: "normal", style: "normal" },
1027
1239
  bold: { weight: "bold", style: "normal" },
1028
1240
  italic: { weight: "normal", style: "italic" },
1029
1241
  "bold-and-italic": { weight: "bold", style: "italic" }
1030
- }, Ht = {
1242
+ }, sn = {
1031
1243
  upper: "flex-start",
1032
1244
  middle: "center",
1033
1245
  lower: "flex-end"
1034
- }, Vt = {
1246
+ }, on = {
1035
1247
  left: "flex-start",
1036
1248
  center: "center",
1037
1249
  right: "flex-end"
1038
- }, le = {
1250
+ }, ue = {
1039
1251
  "stretch-to-fill": "100% 100%",
1040
1252
  "scale-and-crop": "cover",
1041
1253
  "scale-to-fit": "contain"
1042
- }, Ne = "stretch-to-fill";
1043
- function qt(e) {
1044
- const n = /^(url|resource)\(\s*(["']?)(.*?)\2\s*\)$/.exec(J(e).trim());
1254
+ }, Re = "stretch-to-fill";
1255
+ function rn(e) {
1256
+ const n = /^(url|resource)\(\s*(["']?)(.*?)\2\s*\)$/.exec(X(e).trim());
1045
1257
  return n === null ? null : { form: n[1], path: n[3] };
1046
1258
  }
1047
- function De(e, n, t = {}) {
1048
- var g;
1049
- const s = {}, i = [], r = (p) => {
1050
- var b;
1051
- return (b = e.get(p)) == null ? void 0 : b.value;
1052
- }, u = (p, b) => {
1053
- i.push({ kind: p, message: b, node: n });
1054
- };
1259
+ function Ae(e, n, t = {}) {
1260
+ var k;
1261
+ const s = {}, r = [], o = (f) => {
1262
+ var m;
1263
+ return (m = e.get(f)) == null ? void 0 : m.value;
1264
+ }, d = (f, m, v = {}) => {
1265
+ var $, T, O;
1266
+ const w = (($ = v.subject) == null ? void 0 : $.kind) === "property" ? v.subject.property : ((T = v.subject) == null ? void 0 : T.kind) === "asset" ? "background-image" : void 0, g = w === void 0 ? void 0 : e.get(w);
1267
+ (g == null ? void 0 : g.origin.kind) !== "inherited" && r.push({
1268
+ kind: f,
1269
+ message: m,
1270
+ node: n,
1271
+ ...v,
1272
+ ...g === void 0 ? {} : ((O = t.locate) == null ? void 0 : O.call(t, g.origin)) ?? {}
1273
+ });
1274
+ }, a = (f, m = o(f)) => ({
1275
+ subject: { kind: "property", property: f, ...m === void 0 ? {} : { value: m } }
1276
+ });
1055
1277
  s["box-sizing"] = "border-box";
1056
- for (const [p] of e)
1057
- Ft.has(p) ? u("unsupported-property", `${p} does not exist in USS and is ignored`) : Pt.has(p) && u(
1058
- "version-dependent",
1059
- `${p} depends on the Unity version; verify it in your project`
1060
- );
1061
- const c = [
1278
+ const x = [
1062
1279
  "background-color",
1063
1280
  "color",
1064
1281
  "opacity",
@@ -1071,388 +1288,395 @@ function De(e, n, t = {}) {
1071
1288
  "font-size",
1072
1289
  "transform-origin"
1073
1290
  ];
1074
- for (const p of c) {
1075
- const b = r(p);
1076
- b !== void 0 && (s[p] = b);
1077
- }
1078
- r("display") === "none" && (s.display = "none"), r("overflow") === "hidden" && (s.overflow = "hidden");
1079
- for (const p of Ee) {
1080
- const b = r(`border-${p}-width`);
1081
- if (b !== void 0 && b !== "0") {
1082
- const { length: k, problem: x } = Q(b);
1083
- k === null || k.kind !== "px" ? u(
1291
+ for (const f of x) {
1292
+ const m = o(f);
1293
+ m !== void 0 && (s[f] = m);
1294
+ }
1295
+ o("display") === "none" && (s.display = "none"), o("overflow") === "hidden" && (s.overflow = "hidden");
1296
+ for (const f of tn) {
1297
+ const m = o(`border-${f}-width`);
1298
+ if (m !== void 0 && m !== "0") {
1299
+ const { length: g, problem: $ } = ne(m);
1300
+ g === null || g.kind !== "px" ? d(
1084
1301
  "unsupported-property",
1085
- `border-${p}-width: ${x ?? `"${b}" is not a pixel length`}; ignored`
1086
- ) : (s[`border-${p}-width`] = `${k.value}px`, s[`border-${p}-style`] = "solid");
1302
+ `border-${f}-width: ${$ ?? `"${m}" is not a pixel length`}; ignored`,
1303
+ { reason: "invalid-value", ...a(`border-${f}-width`) }
1304
+ ) : (s[`border-${f}-width`] = `${g.value}px`, s[`border-${f}-style`] = "solid");
1087
1305
  }
1088
- const m = r(`border-${p}-color`);
1089
- m !== void 0 && (s[`border-${p}-color`] = m);
1090
- const y = r(`padding-${p}`);
1091
- y !== void 0 && y !== "0" && (s[`padding-${p}`] = y);
1306
+ const v = o(`border-${f}-color`);
1307
+ v !== void 0 && (s[`border-${f}-color`] = v);
1308
+ const w = o(`padding-${f}`);
1309
+ w !== void 0 && w !== "0" && (s[`padding-${f}`] = w);
1092
1310
  }
1093
- for (const p of [
1311
+ for (const f of [
1094
1312
  "top-left",
1095
1313
  "top-right",
1096
1314
  "bottom-right",
1097
1315
  "bottom-left"
1098
1316
  ]) {
1099
- const b = r(`border-${p}-radius`);
1100
- b !== void 0 && (s[`border-${p}-radius`] = b);
1101
- }
1102
- const v = r("-unity-font-style");
1103
- if (v !== void 0) {
1104
- const p = Bt[v];
1105
- p === void 0 ? u("unsupported-property", `-unity-font-style: ${v} is not a USS value`) : (s["font-weight"] = p.weight, s["font-style"] = p.style);
1106
- }
1107
- const d = r("-unity-text-align");
1108
- if (d !== void 0) {
1109
- const [p, b] = d.split("-"), m = Ht[p ?? ""], y = Vt[b ?? ""];
1110
- m === void 0 || y === void 0 ? u("unsupported-property", `-unity-text-align: ${d} is not a USS value`) : (s["align-items"] = m, s["justify-content"] = y);
1111
- }
1112
- const o = [], a = r("translate");
1113
- a !== void 0 && o.push(`translate(${a.replace(/\s+/, ", ")})`);
1114
- const f = r("rotate");
1115
- f !== void 0 && o.push(`rotate(${f})`);
1116
- const l = r("scale");
1117
- l !== void 0 && o.push(`scale(${l.replace(/\s+/, ", ")})`), o.length > 0 && (s.transform = o.join(" "));
1118
- const h = r("background-image");
1119
- if (h !== void 0 && h !== "none") {
1120
- const p = qt(h);
1121
- if (p === null)
1122
- u("asset-unresolved", `background-image: cannot read "${h}" as an asset path`);
1317
+ const m = o(`border-${f}-radius`);
1318
+ m !== void 0 && (s[`border-${f}-radius`] = m);
1319
+ }
1320
+ const h = o("-unity-font-style");
1321
+ if (h !== void 0) {
1322
+ const f = nn[h];
1323
+ f === void 0 ? d("unsupported-property", `-unity-font-style: "${h}" ignored`, {
1324
+ reason: "invalid-value",
1325
+ ...a("-unity-font-style")
1326
+ }) : (s["font-weight"] = f.weight, s["font-style"] = f.style);
1327
+ }
1328
+ const l = o("-unity-text-align");
1329
+ if (l !== void 0) {
1330
+ const [f, m] = l.split("-"), v = sn[f ?? ""], w = on[m ?? ""];
1331
+ v === void 0 || w === void 0 ? d("unsupported-property", `-unity-text-align: "${l}" ignored`, {
1332
+ reason: "invalid-value",
1333
+ ...a("-unity-text-align")
1334
+ }) : (s["align-items"] = v, s["justify-content"] = w);
1335
+ }
1336
+ const c = [], u = o("translate");
1337
+ u !== void 0 && c.push(`translate(${u.replace(/\s+/, ", ")})`);
1338
+ const p = o("rotate");
1339
+ p !== void 0 && c.push(`rotate(${p})`);
1340
+ const i = o("scale");
1341
+ i !== void 0 && c.push(`scale(${i.replace(/\s+/, ", ")})`), c.length > 0 && (s.transform = c.join(" "));
1342
+ const y = o("background-image");
1343
+ if (y !== void 0 && y !== "none") {
1344
+ const f = rn(y);
1345
+ if (f === null)
1346
+ d("unsupported-property", `background-image: "${y}" is not an asset reference; ignored`, {
1347
+ reason: "not-uss",
1348
+ ...a("background-image")
1349
+ });
1123
1350
  else {
1124
- const { form: b, path: m } = p, y = ((g = t.resolveAsset) == null ? void 0 : g.call(t, m, b)) ?? null;
1125
- if (y === null)
1126
- s["background-image"] = "repeating-linear-gradient(45deg, rgba(255,0,255,0.35) 0 6px, rgba(0,0,0,0) 6px 12px)", u("asset-unresolved", `background-image: "${m}" was not resolved`);
1351
+ const { form: m, path: v } = f, w = ((k = t.resolveAsset) == null ? void 0 : k.call(t, v, m)) ?? null;
1352
+ if (w === null)
1353
+ s["background-image"] = "repeating-linear-gradient(45deg, rgba(255,0,255,0.35) 0 6px, rgba(0,0,0,0) 6px 12px)", d("asset-unresolved", `background-image: "${v}" was not resolved`, {
1354
+ subject: { kind: "asset", path: v, form: m }
1355
+ });
1127
1356
  else {
1128
- s["background-image"] = `url("${y}")`, s["background-repeat"] = r("background-repeat") ?? "no-repeat", s["background-position"] = r("background-position") ?? "center";
1129
- const k = r("background-size"), x = r("-unity-background-scale-mode") ?? Ne, $ = le[x];
1130
- $ === void 0 && u(
1357
+ s["background-image"] = `url("${w}")`, s["background-repeat"] = o("background-repeat") ?? "no-repeat", s["background-position"] = o("background-position") ?? "center";
1358
+ const g = o("background-size"), $ = o("-unity-background-scale-mode") ?? Re, T = ue[$];
1359
+ T === void 0 && d(
1131
1360
  "unsupported-property",
1132
- `-unity-background-scale-mode: ${x} is not a USS value; expected one of ${Object.keys(le).join(", ")}`
1133
- ), s["background-size"] = k ?? $ ?? le[Ne];
1361
+ `-unity-background-scale-mode: "${$}" ignored; expected one of ${Object.keys(ue).join(", ")}`,
1362
+ { reason: "invalid-value", ...a("-unity-background-scale-mode", $) }
1363
+ ), s["background-size"] = g ?? T ?? ue[Re];
1134
1364
  }
1135
1365
  }
1136
1366
  }
1137
- return r("-unity-background-image-tint-color") !== void 0 && u(
1138
- "unsupported-property",
1139
- "-unity-background-image-tint-color has no CSS equivalent and is not drawn"
1140
- ), Ee.some((p) => r(`-unity-slice-${p}`) !== void 0) && u("unsupported-property", "-unity-slice-* (9-slice) is not drawn in this preview"), r("-unity-font-definition") !== void 0 && u(
1141
- "unsupported-property",
1142
- "-unity-font-definition names a Unity font asset; the browser default is used"
1143
- ), { declarations: s, warnings: i };
1144
- }
1145
- const Gt = "data-uxml-node", Jt = "data-uxml-part", Xt = "data-uxml-part-owner";
1146
- function Yt(e, n, t, s, i, r) {
1147
- const u = [], c = /* @__PURE__ */ new Map();
1148
- function v(f) {
1149
- const l = s.get(f.id), h = (g) => {
1367
+ return { declarations: s, warnings: r };
1368
+ }
1369
+ const an = "data-uxml-node", ln = "data-uxml-part", cn = "data-uxml-part-owner";
1370
+ function un(e, n, t, s, r, o) {
1371
+ const d = [], a = /* @__PURE__ */ new Map();
1372
+ function x(u) {
1373
+ const p = s.get(u.id), i = (y) => {
1150
1374
  var m;
1151
- const p = ((m = l == null ? void 0 : l.get(g)) == null ? void 0 : m.value) ?? ae[g] ?? "0", { length: b } = Q(p);
1152
- return b !== null && b.kind === "px" ? b.value : 0;
1375
+ const k = ((m = p == null ? void 0 : p.get(y)) == null ? void 0 : m.value) ?? fe[y] ?? "0", { length: f } = ne(k);
1376
+ return f !== null && f.kind === "px" ? f.value : 0;
1153
1377
  };
1154
- return { left: h("border-left-width"), top: h("border-top-width") };
1378
+ return { left: i("border-left-width"), top: i("border-top-width") };
1155
1379
  }
1156
- function d(f) {
1157
- const l = (h) => {
1158
- var b;
1159
- const g = ((b = f.style.get(h)) == null ? void 0 : b.value) ?? ae[h] ?? "0", { length: p } = Q(g);
1160
- return p !== null && p.kind === "px" ? p.value : 0;
1380
+ function h(u) {
1381
+ const p = (i) => {
1382
+ var f;
1383
+ const y = ((f = u.style.get(i)) == null ? void 0 : f.value) ?? fe[i] ?? "0", { length: k } = ne(y);
1384
+ return k !== null && k.kind === "px" ? k.value : 0;
1161
1385
  };
1162
- return { left: l("border-left-width"), top: l("border-top-width") };
1163
- }
1164
- function o(f, l, h) {
1165
- var E;
1166
- const g = n.get(f.id);
1167
- if (g === void 0) return null;
1168
- const p = r.document.createElement("div");
1169
- p.setAttribute(Gt, String(f.id));
1170
- const b = s.get(f.id) ?? /* @__PURE__ */ new Map(), m = De(b, f.id, r);
1171
- u.push(...m.warnings);
1172
- const y = l === null ? 0 : g.left - l.left - h.left, k = l === null ? 0 : g.top - l.top - h.top, x = {
1386
+ return { left: p("border-left-width"), top: p("border-top-width") };
1387
+ }
1388
+ function l(u, p, i) {
1389
+ var O;
1390
+ const y = n.get(u.id);
1391
+ if (y === void 0) return null;
1392
+ const k = o.document.createElement("div");
1393
+ k.setAttribute(an, String(u.id));
1394
+ const f = s.get(u.id) ?? /* @__PURE__ */ new Map(), m = Ae(f, u.id, o);
1395
+ d.push(...m.warnings);
1396
+ const v = p === null ? 0 : y.left - p.left - i.left, w = p === null ? 0 : y.top - p.top - i.top, g = {
1173
1397
  position: "absolute",
1174
- left: `${y}px`,
1175
- top: `${k}px`,
1176
- width: `${g.width}px`,
1177
- height: `${g.height}px`,
1398
+ left: `${v}px`,
1399
+ top: `${w}px`,
1400
+ width: `${y.width}px`,
1401
+ height: `${y.height}px`,
1178
1402
  margin: "0",
1179
1403
  ...m.declarations
1180
1404
  };
1181
- for (const [C, L] of Object.entries(x))
1182
- p.style.setProperty(C, L);
1183
- const { spec: $ } = H(f), O = (E = f.attributes.find((C) => C.name === "text")) == null ? void 0 : E.value;
1184
- if ($.hasText && O !== void 0 && O.length > 0)
1185
- p.style.setProperty("display", m.declarations.display ?? "flex"), m.declarations["align-items"] === void 0 && p.style.setProperty("align-items", "flex-start"), m.declarations["justify-content"] === void 0 && p.style.setProperty("justify-content", "flex-start"), p.textContent = J(O);
1405
+ for (const [R, z] of Object.entries(g))
1406
+ k.style.setProperty(R, z);
1407
+ const { spec: $ } = Y(u), T = (O = u.attributes.find((R) => R.name === "text")) == null ? void 0 : O.value;
1408
+ if ($.hasText && T !== void 0 && T.length > 0)
1409
+ k.style.setProperty("display", m.declarations.display ?? "flex"), m.declarations["align-items"] === void 0 && k.style.setProperty("align-items", "flex-start"), m.declarations["justify-content"] === void 0 && k.style.setProperty("justify-content", "flex-start"), k.textContent = X(T);
1186
1410
  else {
1187
- let C = p, L = g, w = v(f);
1188
- for (const S of t.get(f.id) ?? []) {
1189
- const T = r.document.createElement("div");
1190
- T.setAttribute(Jt, S.name), T.setAttribute(Xt, String(f.id));
1191
- const N = De(S.style, f.id, r);
1192
- u.push(...N.warnings);
1193
- const D = {
1411
+ let R = k, z = y, W = x(u);
1412
+ for (const b of t.get(u.id) ?? []) {
1413
+ const S = o.document.createElement("div");
1414
+ S.setAttribute(ln, b.name), S.setAttribute(cn, String(u.id));
1415
+ const I = Ae(b.style, u.id, o);
1416
+ d.push(...I.warnings);
1417
+ const E = {
1194
1418
  position: "absolute",
1195
- left: `${S.box.left - L.left - w.left}px`,
1196
- top: `${S.box.top - L.top - w.top}px`,
1197
- width: `${S.box.width}px`,
1198
- height: `${S.box.height}px`,
1419
+ left: `${b.box.left - z.left - W.left}px`,
1420
+ top: `${b.box.top - z.top - W.top}px`,
1421
+ width: `${b.box.width}px`,
1422
+ height: `${b.box.height}px`,
1199
1423
  margin: "0",
1200
- ...N.declarations
1424
+ ...I.declarations
1201
1425
  };
1202
- for (const [A, I] of Object.entries(D))
1203
- T.style.setProperty(A, I);
1204
- C.appendChild(T), C = T, L = S.box, w = d(S);
1426
+ for (const [D, M] of Object.entries(E))
1427
+ S.style.setProperty(D, M);
1428
+ R.appendChild(S), R = S, z = b.box, W = h(b);
1205
1429
  }
1206
- for (const S of f.children) {
1207
- const T = o(S, L, w);
1208
- T !== null && C.appendChild(T);
1430
+ for (const b of u.children) {
1431
+ const S = l(b, z, W);
1432
+ S !== null && R.appendChild(S);
1209
1433
  }
1210
1434
  }
1211
- return c.set(f.id, p), p;
1435
+ return a.set(u.id, k), k;
1212
1436
  }
1213
- i.replaceChildren();
1214
- const a = o(e, null, { left: 0, top: 0 });
1215
- return a !== null && (a.style.setProperty("position", "relative"), i.appendChild(a)), { warnings: u, elements: c };
1437
+ r.replaceChildren();
1438
+ const c = l(e, null, { left: 0, top: 0 });
1439
+ return c !== null && (c.style.setProperty("position", "relative"), r.appendChild(c)), { warnings: d, elements: a };
1216
1440
  }
1217
- const Ae = /[A-Za-z0-9_-]/;
1218
- function B(e) {
1441
+ const Ce = /[A-Za-z0-9_-]/;
1442
+ function V(e) {
1219
1443
  return e === " " || e === " " || e === `
1220
1444
  ` || e === "\r" || e === "\f";
1221
1445
  }
1222
- function ce(e, n, t) {
1223
- let s = n, i = 0;
1446
+ function pe(e, n, t) {
1447
+ let s = n, r = 0;
1224
1448
  for (; s < e.length; ) {
1225
- const r = e[s];
1226
- if (r === '"' || r === "'") {
1227
- const u = e.indexOf(r, s + 1);
1228
- s = u < 0 ? e.length : u + 1;
1449
+ const o = e[s];
1450
+ if (o === '"' || o === "'") {
1451
+ const d = e.indexOf(o, s + 1);
1452
+ s = d < 0 ? e.length : d + 1;
1229
1453
  continue;
1230
1454
  }
1231
- if (r === "/" && e[s + 1] === "*") {
1232
- const u = e.indexOf("*/", s + 2);
1233
- s = u < 0 ? e.length : u + 2;
1455
+ if (o === "/" && e[s + 1] === "*") {
1456
+ const d = e.indexOf("*/", s + 2);
1457
+ s = d < 0 ? e.length : d + 2;
1234
1458
  continue;
1235
1459
  }
1236
- if (r === "(" || r === "[")
1237
- i++;
1238
- else if (r === ")" || r === "]")
1239
- i > 0 && i--;
1240
- else if (i === 0 && t.includes(r))
1460
+ if (o === "(" || o === "[")
1461
+ r++;
1462
+ else if (o === ")" || o === "]")
1463
+ r > 0 && r--;
1464
+ else if (r === 0 && t.includes(o))
1241
1465
  return s;
1242
1466
  s++;
1243
1467
  }
1244
1468
  return e.length;
1245
1469
  }
1246
- function qe(e, n, t) {
1247
- let s = n, i = t;
1248
- for (; s < i && B(e[s]); ) s++;
1249
- for (; i > s && B(e[i - 1]); ) i--;
1250
- return { start: s, end: i };
1251
- }
1252
- function Ge(e, n, t, s) {
1253
- const i = [];
1254
- let r = n;
1255
- for (; r < t; ) {
1256
- for (; r < t && (B(e[r]) || e.startsWith("/*", r)); )
1257
- if (e.startsWith("/*", r)) {
1258
- const o = e.indexOf("*/", r + 2);
1259
- r = o < 0 ? t : o + 2;
1470
+ function Ze(e, n, t) {
1471
+ let s = n, r = t;
1472
+ for (; s < r && V(e[s]); ) s++;
1473
+ for (; r > s && V(e[r - 1]); ) r--;
1474
+ return { start: s, end: r };
1475
+ }
1476
+ function Ke(e, n, t, s) {
1477
+ const r = [];
1478
+ let o = n;
1479
+ for (; o < t; ) {
1480
+ for (; o < t && (V(e[o]) || e.startsWith("/*", o)); )
1481
+ if (e.startsWith("/*", o)) {
1482
+ const l = e.indexOf("*/", o + 2);
1483
+ o = l < 0 ? t : l + 2;
1260
1484
  } else
1261
- r++;
1262
- if (r >= t) break;
1263
- if (e[r] === ";") {
1264
- r++;
1485
+ o++;
1486
+ if (o >= t) break;
1487
+ if (e[o] === ";") {
1488
+ o++;
1265
1489
  continue;
1266
1490
  }
1267
- const u = r, c = ce(e, u, ":;}");
1268
- if (c >= t || e[c] !== ":") {
1269
- const o = Math.min(c, t);
1270
- s == null || s("declaration without a value", u, o), r = o + 1;
1491
+ const d = o, a = pe(e, d, ":;}");
1492
+ if (a >= t || e[a] !== ":") {
1493
+ const l = Math.min(a, t);
1494
+ s == null || s("declaration without a value", d, l), o = l + 1;
1271
1495
  continue;
1272
1496
  }
1273
- const v = Math.min(ce(e, c + 1, ";}"), t), d = qe(e, c + 1, v);
1274
- i.push({
1275
- property: e.slice(u, c).trim(),
1276
- value: e.slice(d.start, d.end),
1277
- span: { start: u, end: d.end },
1497
+ const x = Math.min(pe(e, a + 1, ";}"), t), h = Ze(e, a + 1, x);
1498
+ r.push({
1499
+ property: e.slice(d, a).trim(),
1500
+ value: e.slice(h.start, h.end),
1501
+ span: { start: d, end: h.end },
1278
1502
  dirty: !1
1279
- }), r = v + 1;
1503
+ }), o = x + 1;
1280
1504
  }
1281
- return i;
1505
+ return r;
1282
1506
  }
1283
- function Kt(e) {
1507
+ function dn(e) {
1284
1508
  const n = e.span.end - 1 - e.value.length;
1285
1509
  return n < e.span.start ? null : n;
1286
1510
  }
1287
- function ge(e, n = null, t = 0) {
1288
- const s = [], i = [];
1289
- let r = 0;
1290
- function u(m, y, k) {
1511
+ function ve(e, n = null, t = 0) {
1512
+ const s = [], r = [];
1513
+ let o = 0;
1514
+ function d(m, v, w) {
1291
1515
  s.push({
1292
1516
  kind: "malformed",
1293
1517
  message: m,
1294
- at: { in: "uss", sheet: t, span: { start: y, end: k } }
1518
+ at: { in: "uss", sheet: t, span: { start: v, end: w } }
1295
1519
  });
1296
1520
  }
1297
- function c() {
1521
+ function a() {
1298
1522
  for (; ; ) {
1299
- for (; B(e[r]); ) r++;
1300
- if (e.startsWith("/*", r)) {
1301
- const m = e.indexOf("*/", r + 2);
1302
- r = m < 0 ? e.length : m + 2;
1523
+ for (; V(e[o]); ) o++;
1524
+ if (e.startsWith("/*", o)) {
1525
+ const m = e.indexOf("*/", o + 2);
1526
+ o = m < 0 ? e.length : m + 2;
1303
1527
  continue;
1304
1528
  }
1305
1529
  return;
1306
1530
  }
1307
1531
  }
1308
- const v = (m, y) => ce(e, m, y), d = (m, y) => qe(e, m, y);
1309
- function o(m) {
1310
- let y = m + 1, k = 1;
1311
- for (; y < e.length; ) {
1312
- const x = e[y];
1313
- if (x === '"' || x === "'") {
1314
- const $ = e.indexOf(x, y + 1);
1315
- y = $ < 0 ? e.length : $ + 1;
1532
+ const x = (m, v) => pe(e, m, v), h = (m, v) => Ze(e, m, v);
1533
+ function l(m) {
1534
+ let v = m + 1, w = 1;
1535
+ for (; v < e.length; ) {
1536
+ const g = e[v];
1537
+ if (g === '"' || g === "'") {
1538
+ const $ = e.indexOf(g, v + 1);
1539
+ v = $ < 0 ? e.length : $ + 1;
1316
1540
  continue;
1317
1541
  }
1318
- if (x === "/" && e[y + 1] === "*") {
1319
- const $ = e.indexOf("*/", y + 2);
1320
- y = $ < 0 ? e.length : $ + 2;
1542
+ if (g === "/" && e[v + 1] === "*") {
1543
+ const $ = e.indexOf("*/", v + 2);
1544
+ v = $ < 0 ? e.length : $ + 2;
1321
1545
  continue;
1322
1546
  }
1323
- if (x === "{") k++;
1324
- else if (x === "}" && --k === 0) return y + 1;
1325
- y++;
1547
+ if (g === "{") w++;
1548
+ else if (g === "}" && --w === 0) return v + 1;
1549
+ v++;
1326
1550
  }
1327
1551
  return e.length;
1328
1552
  }
1329
- function a(m) {
1330
- let y = m;
1331
- for (; y < e.length && Ae.test(e[y]); ) y++;
1332
- return y;
1333
- }
1334
- function f(m) {
1335
- const y = e[m], k = y === "(" ? ")" : "]";
1336
- let x = m + 1, $ = 1;
1337
- for (; x < e.length; ) {
1338
- const O = e[x];
1339
- if (O === '"' || O === "'") {
1340
- const E = e.indexOf(O, x + 1);
1341
- x = E < 0 ? e.length : E + 1;
1553
+ function c(m) {
1554
+ let v = m;
1555
+ for (; v < e.length && Ce.test(e[v]); ) v++;
1556
+ return v;
1557
+ }
1558
+ function u(m) {
1559
+ const v = e[m], w = v === "(" ? ")" : "]";
1560
+ let g = m + 1, $ = 1;
1561
+ for (; g < e.length; ) {
1562
+ const T = e[g];
1563
+ if (T === '"' || T === "'") {
1564
+ const O = e.indexOf(T, g + 1);
1565
+ g = O < 0 ? e.length : O + 1;
1342
1566
  continue;
1343
1567
  }
1344
- if (O === y) $++;
1345
- else if (O === k && --$ === 0) return x + 1;
1346
- x++;
1568
+ if (T === v) $++;
1569
+ else if (T === w && --$ === 0) return g + 1;
1570
+ g++;
1347
1571
  }
1348
1572
  return e.length;
1349
1573
  }
1350
- function l(m, y) {
1351
- const k = [];
1352
- let x = m;
1353
- for (; x < y; ) {
1354
- const $ = e[x];
1355
- if (B($) || $ === ">" || $ === "+" || $ === "~" || $ === ",") break;
1574
+ function p(m, v) {
1575
+ const w = [];
1576
+ let g = m;
1577
+ for (; g < v; ) {
1578
+ const $ = e[g];
1579
+ if (V($) || $ === ">" || $ === "+" || $ === "~" || $ === ",") break;
1356
1580
  if ($ === "*")
1357
- k.push({ kind: "universal" }), x++;
1581
+ w.push({ kind: "universal" }), g++;
1358
1582
  else if ($ === "." || $ === "#") {
1359
- const O = a(x + 1);
1360
- k.push(
1361
- $ === "." ? { kind: "class", name: e.slice(x + 1, O) } : { kind: "name", name: e.slice(x + 1, O) }
1362
- ), x = O;
1583
+ const T = c(g + 1);
1584
+ w.push(
1585
+ $ === "." ? { kind: "class", name: e.slice(g + 1, T) } : { kind: "name", name: e.slice(g + 1, T) }
1586
+ ), g = T;
1363
1587
  } else if ($ === "[") {
1364
- const O = Math.min(f(x), y);
1365
- k.push({ kind: "unknown", text: e.slice(x, O) }), x = O;
1588
+ const T = Math.min(u(g), v);
1589
+ w.push({ kind: "unknown", text: e.slice(g, T) }), g = T;
1366
1590
  } else if ($ === ":")
1367
- if (e[x + 1] === ":") {
1368
- const O = a(x + 2);
1369
- k.push({ kind: "unknown", text: e.slice(x, O) }), x = O;
1591
+ if (e[g + 1] === ":") {
1592
+ const T = c(g + 2);
1593
+ w.push({ kind: "unknown", text: e.slice(g, T) }), g = T;
1370
1594
  } else {
1371
- const O = a(x + 1);
1372
- if (e[O] === "(") {
1373
- const E = Math.min(f(O), y);
1374
- k.push({ kind: "unknown", text: e.slice(x, E) }), x = E;
1595
+ const T = c(g + 1);
1596
+ if (e[T] === "(") {
1597
+ const O = Math.min(u(T), v);
1598
+ w.push({ kind: "unknown", text: e.slice(g, O) }), g = O;
1375
1599
  } else
1376
- k.push({ kind: "pseudo", name: e.slice(x + 1, O) }), x = O;
1600
+ w.push({ kind: "pseudo", name: e.slice(g + 1, T) }), g = T;
1377
1601
  }
1378
- else if (Ae.test($)) {
1379
- const O = a(x);
1380
- k.push({ kind: "type", name: e.slice(x, O) }), x = O;
1602
+ else if (Ce.test($)) {
1603
+ const T = c(g);
1604
+ w.push({ kind: "type", name: e.slice(g, T) }), g = T;
1381
1605
  } else
1382
- k.push({ kind: "unknown", text: $ }), x++;
1606
+ w.push({ kind: "unknown", text: $ }), g++;
1383
1607
  }
1384
- return { simple: k, next: x };
1385
- }
1386
- function h(m, y) {
1387
- const k = d(m, y), x = [];
1388
- let $ = "descendant", O = null, E = k.start;
1389
- for (; E < k.end; ) {
1390
- const C = e[E];
1391
- if (B(C)) {
1392
- E++;
1608
+ return { simple: w, next: g };
1609
+ }
1610
+ function i(m, v) {
1611
+ const w = h(m, v), g = [];
1612
+ let $ = "descendant", T = null, O = w.start;
1613
+ for (; O < w.end; ) {
1614
+ const R = e[O];
1615
+ if (V(R)) {
1616
+ O++;
1393
1617
  continue;
1394
1618
  }
1395
- if (C === ">") {
1396
- $ = "child", E++;
1619
+ if (R === ">") {
1620
+ $ = "child", O++;
1397
1621
  continue;
1398
1622
  }
1399
- if (C === "+" || C === "~") {
1400
- O = C, E++;
1623
+ if (R === "+" || R === "~") {
1624
+ T = R, O++;
1401
1625
  continue;
1402
1626
  }
1403
- const { simple: L, next: w } = l(E, k.end);
1404
- if (w === E) {
1405
- E++;
1627
+ const { simple: z, next: W } = p(O, w.end);
1628
+ if (W === O) {
1629
+ O++;
1406
1630
  continue;
1407
1631
  }
1408
- O !== null && (L.unshift({ kind: "unknown", text: O }), O = null), x.push({ combinator: $, simple: L }), $ = "descendant", E = w;
1632
+ T !== null && (z.unshift({ kind: "unknown", text: T }), T = null), g.push({ combinator: $, simple: z }), $ = "descendant", O = W;
1409
1633
  }
1410
- return { parts: x, span: k };
1634
+ return { parts: g, span: w };
1411
1635
  }
1412
- function g(m, y) {
1413
- const k = [];
1414
- let x = m;
1636
+ function y(m, v) {
1637
+ const w = [];
1638
+ let g = m;
1415
1639
  for (; ; ) {
1416
- const $ = Math.min(v(x, ","), y);
1417
- if (k.push(h(x, $)), $ >= y) break;
1418
- x = $ + 1;
1640
+ const $ = Math.min(x(g, ","), v);
1641
+ if (w.push(i(g, $)), $ >= v) break;
1642
+ g = $ + 1;
1419
1643
  }
1420
- return k;
1644
+ return w;
1421
1645
  }
1422
- function p() {
1423
- const m = r, y = a(r + 1), k = e.slice(r + 1, y), x = v(y, "{;");
1424
- if (x < e.length && e[x] === "{") {
1425
- const O = o(x);
1426
- return r = O, { kind: "unknown", span: { start: m, end: O } };
1646
+ function k() {
1647
+ const m = o, v = c(o + 1), w = e.slice(o + 1, v), g = x(v, "{;");
1648
+ if (g < e.length && e[g] === "{") {
1649
+ const T = l(g);
1650
+ return o = T, { kind: "unknown", span: { start: m, end: T } };
1427
1651
  }
1428
- const $ = x < e.length ? x + 1 : e.length;
1429
- if (r = $, k === "import") {
1430
- const O = e.slice(y, $), E = /["']([^"']*)["']/.exec(O);
1431
- return E === null ? (u("@import without a quoted path", m, $), { kind: "unknown", span: { start: m, end: $ } }) : { kind: "import", url: E[1], span: { start: m, end: $ } };
1652
+ const $ = g < e.length ? g + 1 : e.length;
1653
+ if (o = $, w === "import") {
1654
+ const T = e.slice(v, $), O = /["']([^"']*)["']/.exec(T);
1655
+ return O === null ? (d("@import without a quoted path", m, $), { kind: "unknown", span: { start: m, end: $ } }) : { kind: "import", url: O[1], span: { start: m, end: $ } };
1432
1656
  }
1433
1657
  return { kind: "unknown", span: { start: m, end: $ } };
1434
1658
  }
1435
- function b() {
1436
- const m = r, y = v(m, "{");
1437
- if (y >= e.length)
1438
- return u("rule without a block", m, e.length), r = e.length, { kind: "unknown", span: { start: m, end: e.length } };
1439
- const k = d(m, y), x = o(y);
1440
- (x > e.length || e[x - 1] !== "}") && u("unterminated rule block", m, x);
1659
+ function f() {
1660
+ const m = o, v = x(m, "{");
1661
+ if (v >= e.length)
1662
+ return d("rule without a block", m, e.length), o = e.length, { kind: "unknown", span: { start: m, end: e.length } };
1663
+ const w = h(m, v), g = l(v);
1664
+ (g > e.length || e[g - 1] !== "}") && d("unterminated rule block", m, g);
1441
1665
  const $ = {
1442
- selectors: g(k.start, k.end),
1443
- declarations: Ge(e, y + 1, x - 1, u),
1444
- span: { start: k.start, end: x },
1445
- selectorSpan: k,
1666
+ selectors: y(w.start, w.end),
1667
+ declarations: Ke(e, v + 1, g - 1, d),
1668
+ span: { start: w.start, end: g },
1669
+ selectorSpan: w,
1446
1670
  selectorDirty: !1,
1447
1671
  declarationsDirty: !1
1448
1672
  };
1449
- return r = x, { kind: "rule", rule: $ };
1673
+ return o = g, { kind: "rule", rule: $ };
1450
1674
  }
1451
- for (; c(), !(r >= e.length); )
1452
- i.push(e[r] === "@" ? p() : b());
1453
- return { sheet: { source: e, origin: n, items: i }, warnings: s };
1675
+ for (; a(), !(o >= e.length); )
1676
+ r.push(e[o] === "@" ? k() : f());
1677
+ return { sheet: { source: e, origin: n, items: r }, warnings: s };
1454
1678
  }
1455
- function Zt(e, n, t) {
1679
+ function fn(e, n, t) {
1456
1680
  switch (e.kind) {
1457
1681
  case "universal":
1458
1682
  return !0;
@@ -1468,61 +1692,61 @@ function Zt(e, n, t) {
1468
1692
  return !1;
1469
1693
  }
1470
1694
  }
1471
- function Qt(e, n, t) {
1472
- return e.simple.every((s) => Zt(s, n, t));
1695
+ function pn(e, n, t) {
1696
+ return e.simple.every((s) => fn(s, n, t));
1473
1697
  }
1474
- function ue(e, n, t, s) {
1475
- if (!Qt(e[n], t, s)) return !1;
1698
+ function he(e, n, t, s) {
1699
+ if (!pn(e[n], t, s)) return !1;
1476
1700
  if (n === 0) return !0;
1477
- const i = s.parentOf(t);
1701
+ const r = s.parentOf(t);
1478
1702
  if (e[n].combinator === "child")
1479
- return i !== null && ue(e, n - 1, i, s);
1480
- for (let r = i; r !== null; r = s.parentOf(r))
1481
- if (ue(e, n - 1, r, s)) return !0;
1703
+ return r !== null && he(e, n - 1, r, s);
1704
+ for (let o = r; o !== null; o = s.parentOf(o))
1705
+ if (he(e, n - 1, o, s)) return !0;
1482
1706
  return !1;
1483
1707
  }
1484
- function Je(e, n, t) {
1485
- return e.parts.length === 0 ? !1 : ue(e.parts, e.parts.length - 1, n, t);
1708
+ function Qe(e, n, t) {
1709
+ return e.parts.length === 0 ? !1 : he(e.parts, e.parts.length - 1, n, t);
1486
1710
  }
1487
- function en(e) {
1711
+ function hn(e) {
1488
1712
  const n = [];
1489
1713
  for (const t of e.parts)
1490
1714
  for (const s of t.simple)
1491
1715
  s.kind === "pseudo" && s.name !== "root" && !n.includes(s.name) && n.push(s.name);
1492
1716
  return n;
1493
1717
  }
1494
- function tn(e) {
1718
+ function mn(e) {
1495
1719
  const n = [];
1496
1720
  for (const t of e)
1497
1721
  for (const s of t.parts)
1498
- for (const i of s.simple) {
1499
- if (i.kind !== "name" && i.kind !== "class" || !i.name.startsWith("unity-")) continue;
1500
- const r = i.kind === "name" ? `#${i.name}` : `.${i.name}`;
1501
- n.includes(r) || n.push(r);
1722
+ for (const r of s.simple) {
1723
+ if (r.kind !== "name" && r.kind !== "class" || !r.name.startsWith("unity-")) continue;
1724
+ const o = r.kind === "name" ? `#${r.name}` : `.${r.name}`;
1725
+ n.includes(o) || n.push(o);
1502
1726
  }
1503
1727
  return n;
1504
1728
  }
1505
- function Xe(e) {
1729
+ function et(e) {
1506
1730
  for (const n of e)
1507
1731
  for (const t of n.parts)
1508
1732
  for (const s of t.simple)
1509
1733
  if (s.kind === "unknown") return s.text;
1510
1734
  return null;
1511
1735
  }
1512
- function nn(e) {
1736
+ function gn(e) {
1513
1737
  const n = /* @__PURE__ */ new Map([[e, null]]), t = [e];
1514
1738
  for (; t.length > 0; ) {
1515
1739
  const s = t.pop();
1516
- for (const i of s.children)
1517
- n.set(i, s), t.push(i);
1740
+ for (const r of s.children)
1741
+ n.set(r, s), t.push(r);
1518
1742
  }
1519
1743
  return n;
1520
1744
  }
1521
- function sn(e) {
1745
+ function yn(e) {
1522
1746
  let n = 0, t = 0, s = 0;
1523
- for (const i of e.parts)
1524
- for (const r of i.simple)
1525
- switch (r.kind) {
1747
+ for (const r of e.parts)
1748
+ for (const o of r.simple)
1749
+ switch (o.kind) {
1526
1750
  case "name":
1527
1751
  n++;
1528
1752
  break;
@@ -1536,62 +1760,64 @@ function sn(e) {
1536
1760
  }
1537
1761
  return [n, t, s];
1538
1762
  }
1539
- function Ye(e, n) {
1763
+ function tt(e, n) {
1540
1764
  return e[0] - n[0] || e[1] - n[1] || e[2] - n[2];
1541
1765
  }
1542
- const rn = [Number.MAX_SAFE_INTEGER, 0, 0], on = ge(Ve, null, -1).sheet.items.flatMap(
1766
+ const bn = [Number.MAX_SAFE_INTEGER, 0, 0], vn = ve(Je, null, -1).sheet.items.flatMap(
1543
1767
  (e, n) => e.kind === "rule" ? [{ rule: e.rule, sheet: -1, item: n, builtin: !0 }] : []
1544
1768
  );
1545
- function ln(e) {
1546
- return Ve.slice(e.selectorSpan.start, e.selectorSpan.end).trim();
1547
- }
1548
- function an(e, n, t, s) {
1549
- const i = (t == null ? void 0 : t.activeStates) ?? /* @__PURE__ */ new Set(), r = Object.entries((t == null ? void 0 : t.states) ?? {}), u = [];
1550
- for (const [o, a] of r) {
1551
- const f = ge(`${o} {}`, null, -1).sheet.items.find((h) => h.kind === "rule"), l = f === void 0 ? o : Xe(f.rule.selectors);
1552
- if (f === void 0 || l !== null) {
1769
+ function wn(e) {
1770
+ return Je.slice(e.selectorSpan.start, e.selectorSpan.end).trim();
1771
+ }
1772
+ function xn(e, n, t, s) {
1773
+ const r = (t == null ? void 0 : t.activeStates) ?? /* @__PURE__ */ new Set(), o = Object.entries((t == null ? void 0 : t.states) ?? {}), d = [];
1774
+ for (const [l, c] of o) {
1775
+ const u = ve(`${l} {}`, null, -1).sheet.items.find((i) => i.kind === "rule"), p = u === void 0 ? l : et(u.rule.selectors);
1776
+ if (u === void 0 || p !== null) {
1553
1777
  s.push({
1554
1778
  kind: "unsupported-selector",
1555
- message: `states key "${o}" is not a usable USS selector; it is ignored`
1779
+ message: `states key "${l}" is not a usable USS selector; it is ignored`,
1780
+ reason: "not-uss",
1781
+ subject: { kind: "states-key", key: l }
1556
1782
  });
1557
1783
  continue;
1558
1784
  }
1559
- u.push({ selectors: f.rule.selectors, states: a });
1560
- }
1561
- const c = /* @__PURE__ */ new Map(), v = (o) => o.attributes.some((a) => a.name === "enabled" && a.value === "false"), d = (o, a) => {
1562
- const f = a || v(o), l = new Set(i);
1563
- f && l.add("disabled");
1564
- for (const h of u)
1565
- if (h.selectors.some((g) => Je(g, { kind: "element", node: o }, n)))
1566
- for (const g of h.states) l.add(g);
1567
- c.set(o, l);
1568
- for (const h of o.children) d(h, f);
1785
+ d.push({ selectors: u.rule.selectors, states: c });
1786
+ }
1787
+ const a = /* @__PURE__ */ new Map(), x = (l) => l.attributes.some((c) => c.name === "enabled" && c.value === "false"), h = (l, c) => {
1788
+ const u = c || x(l), p = new Set(r);
1789
+ u && p.add("disabled");
1790
+ for (const i of d)
1791
+ if (i.selectors.some((y) => Qe(y, { kind: "element", node: l }, n)))
1792
+ for (const y of i.states) p.add(y);
1793
+ a.set(l, p);
1794
+ for (const i of l.children) h(i, u);
1569
1795
  };
1570
- return d(e.root, !1), c;
1796
+ return h(e.root, !1), a;
1571
1797
  }
1572
- function cn(e) {
1798
+ function kn(e) {
1573
1799
  const n = [], t = /* @__PURE__ */ new Map();
1574
- e.sheets.forEach((u, c) => {
1575
- u.origin !== null && !t.has(u.origin) && t.set(u.origin, c);
1576
- }), n.push(...on);
1577
- const s = /* @__PURE__ */ new Map(), i = (u, c) => {
1578
- const v = s.get(c) ?? /* @__PURE__ */ new Set();
1579
- if (v.has(u)) return;
1580
- v.add(u), s.set(c, v);
1581
- const d = e.sheets[u];
1582
- d !== void 0 && d.items.forEach((o, a) => {
1583
- if (o.kind === "rule")
1584
- n.push({ rule: o.rule, sheet: u, item: a, scope: c });
1585
- else if (o.kind === "import") {
1586
- const f = o.resolvedSheet ?? t.get(o.url);
1587
- f !== void 0 && i(f, c);
1800
+ e.sheets.forEach((d, a) => {
1801
+ d.origin !== null && !t.has(d.origin) && t.set(d.origin, a);
1802
+ }), n.push(...vn);
1803
+ const s = /* @__PURE__ */ new Map(), r = (d, a) => {
1804
+ const x = s.get(a) ?? /* @__PURE__ */ new Set();
1805
+ if (x.has(d)) return;
1806
+ x.add(d), s.set(a, x);
1807
+ const h = e.sheets[d];
1808
+ h !== void 0 && h.items.forEach((l, c) => {
1809
+ if (l.kind === "rule")
1810
+ n.push({ rule: l.rule, sheet: d, item: c, scope: a });
1811
+ else if (l.kind === "import") {
1812
+ const u = l.resolvedSheet ?? t.get(l.url);
1813
+ u !== void 0 && r(u, a);
1588
1814
  }
1589
1815
  });
1590
- }, r = e.styleRoots ?? (e.sheets.length === 0 ? [] : [{ sheet: 0, scope: e.root.id }]);
1591
- for (const u of r) i(u.sheet, u.scope);
1816
+ }, o = e.styleRoots ?? (e.sheets.length === 0 ? [] : [{ sheet: 0, scope: e.root.id }]);
1817
+ for (const d of o) r(d.sheet, d.scope);
1592
1818
  return n;
1593
1819
  }
1594
- function un(e, n, t) {
1820
+ function Sn(e, n, t) {
1595
1821
  let s = e;
1596
1822
  for (; s !== null; ) {
1597
1823
  if (s.kind === "element" && s.node.id === n) return !0;
@@ -1599,25 +1825,30 @@ function un(e, n, t) {
1599
1825
  }
1600
1826
  return !1;
1601
1827
  }
1602
- function dn(e) {
1828
+ function $n(e) {
1603
1829
  return e.selectors.some(
1604
1830
  (n) => n.parts.some((t) => t.simple.some((s) => s.kind === "pseudo" && s.name === "root"))
1605
1831
  );
1606
1832
  }
1607
- function de(e, n) {
1833
+ function ee(e, n) {
1834
+ var s;
1835
+ const t = n.rule.selectorSpan;
1836
+ return ((s = e.sheets[n.sheet]) == null ? void 0 : s.source.slice(t.start, t.end)) ?? "";
1837
+ }
1838
+ function H(e, n) {
1608
1839
  var s;
1609
1840
  const t = (s = e.sheets[n]) == null ? void 0 : s.origin;
1610
1841
  return typeof t == "string" ? { sourceDocument: t } : {};
1611
1842
  }
1612
- function Ke(e, n) {
1613
- const t = nn(e.root), s = [], i = /* @__PURE__ */ new Set(), r = (l) => {
1614
- var g;
1615
- const h = (g = l.attributes.find((p) => p.name === "class")) == null ? void 0 : g.value;
1616
- return h === void 0 ? [] : h.split(/\s+/).filter((p) => p.length > 0);
1617
- }, u = (l, h) => {
1618
- var g;
1619
- return (g = l.attributes.find((p) => p.name === h)) == null ? void 0 : g.value;
1620
- }, c = {
1843
+ function nt(e, n) {
1844
+ const t = gn(e.root), s = [], r = /* @__PURE__ */ new Set(), o = (i) => {
1845
+ var k;
1846
+ const y = (k = i.attributes.find((f) => f.name === "class")) == null ? void 0 : k.value;
1847
+ return y === void 0 ? [] : y.split(/\s+/).filter((f) => f.length > 0);
1848
+ }, d = (i, y) => {
1849
+ var k;
1850
+ return (k = i.attributes.find((f) => f.name === y)) == null ? void 0 : k.value;
1851
+ }, a = {
1621
1852
  /**
1622
1853
  * The rule the measurement forced.
1623
1854
  *
@@ -1628,146 +1859,220 @@ function Ke(e, n) {
1628
1859
  * owner. That is the hierarchy the dumps show, so descendant selectors like
1629
1860
  * `.panel #unity-content-viewport` behave as they do in Unity.
1630
1861
  */
1631
- parentOf: (l) => {
1632
- if (l.kind === "element") {
1633
- const p = t.get(l.node) ?? null;
1634
- return p === null ? null : { kind: "element", node: p };
1862
+ parentOf: (i) => {
1863
+ if (i.kind === "element") {
1864
+ const f = t.get(i.node) ?? null;
1865
+ return f === null ? null : { kind: "element", node: f };
1635
1866
  }
1636
- if (l.depth === 0) return { kind: "element", node: l.owner };
1637
- const g = H(l.owner).spec.parts[l.depth - 1];
1638
- return { kind: "part", owner: l.owner, name: g.name, depth: l.depth - 1 };
1867
+ if (i.depth === 0) return { kind: "element", node: i.owner };
1868
+ const k = Y(i.owner).spec.parts[i.depth - 1];
1869
+ return { kind: "part", owner: i.owner, name: k.name, depth: i.depth - 1 };
1639
1870
  },
1640
- isRoot: (l) => l.kind === "element" && l.node === e.root,
1871
+ isRoot: (i) => i.kind === "element" && i.node === e.root,
1641
1872
  // Unity's parts are VisualElements, so a `VisualElement` rule reaches them.
1642
1873
  // Not measured — `part-type-selector` is the case that will settle it.
1643
- typeNameOf: (l) => l.kind === "element" ? l.node.name.local : "VisualElement",
1644
- idOf: (l) => l.kind === "element" ? u(l.node, "name") : l.name,
1874
+ typeNameOf: (i) => i.kind === "element" ? i.node.name.local : "VisualElement",
1875
+ idOf: (i) => i.kind === "element" ? d(i.node, "name") : i.name,
1645
1876
  // Implicit classes are as real as written ones for matching: in Unity the
1646
1877
  // element genuinely carries them, which is why `.unity-button` in author USS
1647
1878
  // hits a plain `<ui:Button />`. Parts carry classes too in Unity, but which
1648
1879
  // ones is unmeasured, so none are claimed here.
1649
- classesOf: (l) => l.kind === "element" ? [...r(l.node), ...$t(l.node)] : []
1650
- }, v = { ...c, statesOf: () => i }, d = an(e, v, n, s), o = {
1651
- ...c,
1880
+ classesOf: (i) => i.kind === "element" ? [...o(i.node), ...pt(i.node)] : []
1881
+ }, x = { ...a, statesOf: () => r }, h = xn(e, x, n, s), l = {
1882
+ ...a,
1652
1883
  // A part inherits its owner's states: `SetEnabled(false)` disables the whole
1653
1884
  // subtree, and a part is inside it.
1654
- statesOf: (l) => d.get(l.kind === "element" ? l.node : l.owner) ?? i
1655
- }, a = [];
1656
- let f = !1;
1657
- for (const l of cn(e)) {
1658
- if (l.builtin === !0) {
1659
- a.push(l);
1885
+ statesOf: (i) => h.get(i.kind === "element" ? i.node : i.owner) ?? r
1886
+ }, c = [];
1887
+ let u = !1;
1888
+ for (const i of kn(e)) {
1889
+ if (i.builtin === !0) {
1890
+ c.push(i);
1660
1891
  continue;
1661
1892
  }
1662
- const h = Xe(l.rule.selectors);
1663
- if (h !== null) {
1893
+ const y = et(i.rule.selectors);
1894
+ if (y !== null) {
1664
1895
  s.push({
1665
1896
  kind: "unsupported-selector",
1666
- message: `"${h}" is not supported in USS; the whole rule is ignored`,
1667
- at: { in: "uss", sheet: l.sheet, span: l.rule.selectorSpan },
1668
- ...de(e, l.sheet)
1897
+ message: `"${y}": the whole rule is ignored`,
1898
+ at: { in: "uss", sheet: i.sheet, span: i.rule.selectorSpan },
1899
+ reason: "not-uss",
1900
+ subject: { kind: "selector", selector: ee(e, i), fragment: y },
1901
+ ...H(e, i.sheet)
1669
1902
  });
1670
1903
  continue;
1671
1904
  }
1672
- !f && dn(l.rule) && (f = !0, s.push({
1905
+ !u && $n(i.rule) && (u = !0, s.push({
1673
1906
  kind: "version-dependent",
1674
- message: ":root in USS names the element the stylesheet was applied to, not the document root as in CSS. Template stylesheets therefore match their generated TemplateContainer.",
1675
- at: { in: "uss", sheet: l.sheet, span: l.rule.selectorSpan },
1676
- ...de(e, l.sheet)
1677
- })), a.push(l);
1907
+ // Not a version difference: USS :root means something else than CSS
1908
+ // :root, and this preview does what Unity does. Kept as a warning so
1909
+ // an author porting CSS is told; the kind stays for compatibility.
1910
+ message: ":root matched the element this stylesheet is attached to — the document root, or the TemplateContainer of a template",
1911
+ at: { in: "uss", sheet: i.sheet, span: i.rule.selectorSpan },
1912
+ reason: "matches-unity",
1913
+ subject: { kind: "selector", selector: ee(e, i), fragment: ":root" },
1914
+ ...H(e, i.sheet)
1915
+ })), c.push(i);
1916
+ }
1917
+ const p = /* @__PURE__ */ new Set();
1918
+ for (const i of c) {
1919
+ if (i.builtin === !0) continue;
1920
+ const y = `${i.sheet}:${i.item}`;
1921
+ if (p.has(y)) continue;
1922
+ p.add(y);
1923
+ const k = /* @__PURE__ */ new Set();
1924
+ for (const f of i.rule.selectors)
1925
+ for (const m of f.parts)
1926
+ for (const v of m.simple)
1927
+ v.kind !== "pseudo" || v.name === "root" || Pt.includes(v.name) || k.add(v.name);
1928
+ for (const f of k)
1929
+ s.push({
1930
+ kind: "unsupported-selector",
1931
+ message: `":${f}": never matches; Unity sets no such state`,
1932
+ at: { in: "uss", sheet: i.sheet, span: i.rule.selectorSpan },
1933
+ ...H(e, i.sheet),
1934
+ reason: "not-uss",
1935
+ subject: { kind: "selector", selector: ee(e, i), fragment: `:${f}` }
1936
+ });
1937
+ for (const f of i.rule.declarations) {
1938
+ const m = Xe(f.property, f.value);
1939
+ m !== null && s.push({
1940
+ kind: "unsupported-property",
1941
+ ...m,
1942
+ at: { in: "uss", sheet: i.sheet, span: f.span },
1943
+ ...H(e, i.sheet)
1944
+ });
1945
+ }
1678
1946
  }
1679
- return { ctx: o, usable: a, warnings: s };
1947
+ return e.sheets.forEach((i, y) => {
1948
+ var k;
1949
+ for (const f of i.items) {
1950
+ if (f.kind !== "unknown") continue;
1951
+ const m = (k = /^@([A-Za-z][\w-]*)/.exec(i.source.slice(f.span.start, f.span.end))) == null ? void 0 : k[1];
1952
+ m === void 0 || m === "import" || s.push({
1953
+ kind: "unsupported-selector",
1954
+ message: `@${m}: block ignored`,
1955
+ at: { in: "uss", sheet: y, span: f.span },
1956
+ ...H(e, y),
1957
+ reason: "not-uss",
1958
+ subject: { kind: "at-rule", name: m }
1959
+ });
1960
+ }
1961
+ }), { ctx: l, usable: c, warnings: s };
1680
1962
  }
1681
- function fn(e, n) {
1682
- const t = n.attributes.find((i) => i.name === "style");
1963
+ function we(e, n) {
1964
+ const t = n.attributes.find((r) => r.name === "style");
1683
1965
  if (t === void 0) return [];
1684
- const s = Kt(t);
1685
- return s === null ? [] : Ge(e.source, s, s + t.value.length);
1686
- }
1687
- function Ze(e, n, t, s) {
1688
- const i = [];
1689
- let r = 0;
1690
- const u = (c, v, d, o, a) => {
1691
- i.push({ property: c, value: v, origin: d, rank: o, specificity: a, order: r++, winner: !1 });
1966
+ const s = dn(t);
1967
+ return s === null ? [] : Ke(e.source, s, s + t.value.length);
1968
+ }
1969
+ function Tn(e) {
1970
+ let n = null;
1971
+ const t = (s, r) => {
1972
+ var o;
1973
+ typeof s.sourceDocument != "string" && r.set(((o = s.derived) == null ? void 0 : o.instance) ?? s.id, s);
1974
+ for (const d of s.children) t(d, r);
1975
+ return r;
1976
+ };
1977
+ return (s) => {
1978
+ var r;
1979
+ if (s.kind === "rule") {
1980
+ const o = (r = e.sheets[s.sheet]) == null ? void 0 : r.items[s.item], d = (o == null ? void 0 : o.kind) === "rule" ? o.rule.declarations[s.declIndex] : void 0;
1981
+ return d === void 0 ? {} : { at: { in: "uss", sheet: s.sheet, span: d.span }, ...H(e, s.sheet) };
1982
+ }
1983
+ if (s.kind === "inline") {
1984
+ if (typeof s.sourceDocument == "string") return { sourceDocument: s.sourceDocument };
1985
+ n ?? (n = t(e.root, /* @__PURE__ */ new Map()));
1986
+ const o = n.get(s.node), d = o === void 0 ? void 0 : we(e, o)[s.declIndex];
1987
+ return d === void 0 ? {} : { at: { in: "uxml", span: d.span } };
1988
+ }
1989
+ return {};
1990
+ };
1991
+ }
1992
+ function st(e, n, t, s) {
1993
+ const r = [];
1994
+ let o = 0;
1995
+ const d = (a, x, h, l, c) => {
1996
+ r.push({ property: a, value: x, origin: h, rank: l, specificity: c, order: o++, winner: !1 });
1692
1997
  };
1693
1998
  if (n.kind === "part") {
1694
- const c = H(n.owner).spec.parts[n.depth];
1695
- for (const [v, d] of Object.entries((c == null ? void 0 : c.style) ?? {}))
1696
- for (const [o, a] of ie(v, d))
1697
- u(
1698
- o,
1699
- a,
1999
+ const a = Y(n.owner).spec.parts[n.depth];
2000
+ for (const [x, h] of Object.entries((a == null ? void 0 : a.style) ?? {}))
2001
+ for (const [l, c] of le(x, h))
2002
+ d(
2003
+ l,
2004
+ c,
1700
2005
  {
1701
2006
  kind: "builtin-theme",
1702
2007
  selector: `#${n.name}`,
1703
- property: o,
1704
- unityVersion: Z
2008
+ property: l,
2009
+ unityVersion: te
1705
2010
  },
1706
2011
  0,
1707
2012
  [0, 0, 0]
1708
2013
  );
1709
2014
  }
1710
- for (const c of t.usable) {
1711
- if (c.scope !== void 0 && !un(n, c.scope, t.ctx)) continue;
1712
- const v = c.scope === void 0 ? t.ctx : {
2015
+ for (const a of t.usable) {
2016
+ if (a.scope !== void 0 && !Sn(n, a.scope, t.ctx)) continue;
2017
+ const x = a.scope === void 0 ? t.ctx : {
1713
2018
  ...t.ctx,
1714
2019
  // Unity USS :root names the element this particular stylesheet is
1715
2020
  // attached to. Template sheets are attached to each generated
1716
2021
  // TemplateContainer, not to the entry document root.
1717
- isRoot: (a) => a.kind === "element" && a.node.id === c.scope
2022
+ isRoot: (c) => c.kind === "element" && c.node.id === a.scope
1718
2023
  };
1719
- let d = null, o = [];
1720
- for (const a of c.rule.selectors) {
1721
- if (!Je(a, n, v)) continue;
1722
- const f = sn(a);
1723
- (d === null || Ye(f, d) > 0) && (d = f, o = en(a));
2024
+ let h = null, l = [];
2025
+ for (const c of a.rule.selectors) {
2026
+ if (!Qe(c, n, x)) continue;
2027
+ const u = yn(c);
2028
+ (h === null || tt(u, h) > 0) && (h = u, l = hn(c));
1724
2029
  }
1725
- d !== null && (s == null || s.add(c), c.rule.declarations.forEach((a, f) => {
1726
- var l, h, g;
1727
- for (const [p, b] of ie(a.property, a.value)) {
1728
- const m = c.builtin === !0 ? {
2030
+ h !== null && (s == null || s.add(a), a.rule.declarations.forEach((c, u) => {
2031
+ var p, i, y;
2032
+ for (const [k, f] of le(c.property, c.value)) {
2033
+ const m = a.builtin === !0 ? {
1729
2034
  kind: "builtin-theme",
1730
- selector: ln(c.rule),
1731
- property: p,
1732
- unityVersion: Z
2035
+ selector: wn(a.rule),
2036
+ property: k,
2037
+ unityVersion: te
1733
2038
  } : {
1734
2039
  kind: "rule",
1735
- sheet: c.sheet,
1736
- item: c.item,
1737
- declIndex: f,
1738
- ...((l = e.sheets[c.sheet]) == null ? void 0 : l.origin) === null || ((h = e.sheets[c.sheet]) == null ? void 0 : h.origin) === void 0 ? {} : { sourceDocument: e.sheets[c.sheet].origin },
1739
- ...((g = e.sheets[c.sheet]) == null ? void 0 : g.sourceDocumentFrom) === void 0 ? {} : { sourceDocumentFrom: e.sheets[c.sheet].sourceDocumentFrom },
2040
+ sheet: a.sheet,
2041
+ item: a.item,
2042
+ declIndex: u,
2043
+ ...((p = e.sheets[a.sheet]) == null ? void 0 : p.origin) === null || ((i = e.sheets[a.sheet]) == null ? void 0 : i.origin) === void 0 ? {} : { sourceDocument: e.sheets[a.sheet].origin },
2044
+ ...((y = e.sheets[a.sheet]) == null ? void 0 : y.sourceDocumentFrom) === void 0 ? {} : { sourceDocumentFrom: e.sheets[a.sheet].sourceDocumentFrom },
1740
2045
  // Omitted rather than set to [] when unconditional, so the
1741
2046
  // common case stays the shape it has always been.
1742
- ...o.length > 0 ? { states: o } : {}
2047
+ ...l.length > 0 ? { states: l } : {}
1743
2048
  };
1744
- u(p, b, m, c.builtin === !0 ? 0 : 1, d);
2049
+ d(k, f, m, a.builtin === !0 ? 0 : 1, h);
1745
2050
  }
1746
2051
  }));
1747
2052
  }
1748
2053
  if (n.kind === "element") {
1749
- const c = n.node;
1750
- fn(e, c).forEach((v, d) => {
1751
- var o;
1752
- for (const [a, f] of ie(v.property, v.value))
1753
- u(
1754
- a,
1755
- f,
2054
+ const a = n.node;
2055
+ we(e, a).forEach((x, h) => {
2056
+ var l;
2057
+ for (const [c, u] of le(x.property, x.value))
2058
+ d(
2059
+ c,
2060
+ u,
1756
2061
  {
1757
2062
  kind: "inline",
1758
- node: ((o = c.derived) == null ? void 0 : o.instance) ?? c.sourceNode ?? c.id,
1759
- declIndex: d,
1760
- ...typeof c.sourceDocument == "string" ? { sourceDocument: c.sourceDocument } : {},
1761
- ...c.sourceDocumentFrom === void 0 ? {} : { sourceDocumentFrom: c.sourceDocumentFrom }
2063
+ node: ((l = a.derived) == null ? void 0 : l.instance) ?? a.sourceNode ?? a.id,
2064
+ declIndex: h,
2065
+ ...typeof a.sourceDocument == "string" ? { sourceDocument: a.sourceDocument } : {},
2066
+ ...a.sourceDocumentFrom === void 0 ? {} : { sourceDocumentFrom: a.sourceDocumentFrom }
1762
2067
  },
1763
2068
  1,
1764
- rn
2069
+ bn
1765
2070
  );
1766
2071
  });
1767
2072
  }
1768
- return i;
2073
+ return r;
1769
2074
  }
1770
- function Qe(e) {
2075
+ function ot(e) {
1771
2076
  const n = /* @__PURE__ */ new Map();
1772
2077
  for (const t of e) {
1773
2078
  const s = n.get(t.property);
@@ -1779,100 +2084,122 @@ function Qe(e) {
1779
2084
  t.rank > s.rank && n.set(t.property, t);
1780
2085
  continue;
1781
2086
  }
1782
- const i = Ye(t.specificity, s.specificity);
1783
- (i > 0 || i === 0 && t.order > s.order) && n.set(t.property, t);
2087
+ const r = tt(t.specificity, s.specificity);
2088
+ (r > 0 || r === 0 && t.order > s.order) && n.set(t.property, t);
1784
2089
  }
1785
2090
  for (const t of n.values()) t.winner = !0;
1786
2091
  return n;
1787
2092
  }
1788
- const pn = /var\(\s*(--[^,)\s]+)\s*(?:,([^)]*))?\)/;
1789
- function fe(e, n, t = /* @__PURE__ */ new Set()) {
1790
- var i;
2093
+ const In = /var\(\s*(--[^,)\s]+)\s*(?:,([^)]*))?\)/;
2094
+ function me(e, n, t = /* @__PURE__ */ new Set()) {
2095
+ var r;
1791
2096
  let s = e;
1792
- for (let r = 0; r < 32; r++) {
1793
- const u = pn.exec(s);
1794
- if (u === null) return s;
1795
- const c = u[1], v = (i = u[2]) == null ? void 0 : i.trim();
1796
- if (t.has(c)) return null;
1797
- const d = /* @__PURE__ */ new Set([...t, c]), o = n.get(c), a = o !== void 0 ? fe(o, n, d) : v !== void 0 && v.length > 0 ? fe(v, n, d) : null;
1798
- if (a === null) return null;
1799
- s = s.slice(0, u.index) + a + s.slice(u.index + u[0].length);
2097
+ for (let o = 0; o < 32; o++) {
2098
+ const d = In.exec(s);
2099
+ if (d === null) return s;
2100
+ const a = d[1], x = (r = d[2]) == null ? void 0 : r.trim();
2101
+ if (t.has(a)) return null;
2102
+ const h = /* @__PURE__ */ new Set([...t, a]), l = n.get(a), c = l !== void 0 ? me(l, n, h) : x !== void 0 && x.length > 0 ? me(x, n, h) : null;
2103
+ if (c === null) return null;
2104
+ s = s.slice(0, d.index) + c + s.slice(d.index + d[0].length);
1800
2105
  }
1801
2106
  return null;
1802
2107
  }
1803
- function hn(e, n) {
1804
- const t = Ke(e, n), s = [...t.warnings], i = /* @__PURE__ */ new Map();
1805
- let r = !1;
1806
- const u = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Set(), v = (o, a, f) => {
1807
- const l = Ze(e, o, t, c);
1808
- !r && l.some((m) => m.origin.kind === "builtin-theme") && (r = !0);
1809
- const h = Qe(l), g = /* @__PURE__ */ new Map();
1810
- for (const [m, y] of a)
1811
- m.startsWith("--") && g.set(m, y.value);
1812
- for (const [m, y] of h)
1813
- m.startsWith("--") && g.set(m, y.value);
1814
- const p = /* @__PURE__ */ new Map();
1815
- for (const [m, y] of a) p.set(m, y);
1816
- for (const [m, y] of h) {
1817
- const k = fe(y.value, g);
1818
- if (k === null) {
2108
+ function En(e, n) {
2109
+ const t = nt(e, n), s = [...t.warnings], r = /* @__PURE__ */ new Map();
2110
+ let o = !1;
2111
+ const d = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set(), x = (u, p, i) => {
2112
+ const y = st(e, u, t, a);
2113
+ !o && y.some((w) => w.origin.kind === "builtin-theme") && (o = !0);
2114
+ const k = ot(y), f = /* @__PURE__ */ new Map();
2115
+ for (const [w, g] of p)
2116
+ w.startsWith("--") && f.set(w, g.value);
2117
+ for (const [w, g] of k)
2118
+ w.startsWith("--") && f.set(w, g.value);
2119
+ const m = /* @__PURE__ */ new Map();
2120
+ for (const [w, g] of p) m.set(w, g);
2121
+ for (const [w, g] of k) {
2122
+ const $ = me(g.value, f);
2123
+ if ($ === null) {
1819
2124
  s.push({
1820
2125
  kind: "unsupported-property",
1821
- message: `${m}: var() reference could not be resolved; declaration dropped`,
1822
- node: f
2126
+ message: `${w}: var() reference could not be resolved; declaration dropped`,
2127
+ node: i,
2128
+ reason: "invalid-value",
2129
+ subject: { kind: "property", property: w, value: g.value }
1823
2130
  });
1824
2131
  continue;
1825
2132
  }
1826
- p.set(m, { value: k, origin: y.origin });
2133
+ m.set(w, { value: $, origin: g.origin });
1827
2134
  }
1828
- const b = /* @__PURE__ */ new Map();
1829
- for (const [m, y] of p)
1830
- Dt(m) && b.set(m, {
1831
- value: y.value,
1832
- origin: { kind: "inherited", from: f, origin: y.origin }
2135
+ const v = /* @__PURE__ */ new Map();
2136
+ for (const [w, g] of m)
2137
+ Bt(w) && v.set(w, {
2138
+ value: g.value,
2139
+ origin: { kind: "inherited", from: i, origin: g.origin }
1833
2140
  });
1834
- return { computed: p, forChildren: b };
1835
- }, d = (o, a) => {
1836
- const f = v({ kind: "element", node: o }, a, o.id);
1837
- i.set(o.id, f.computed);
1838
- let l = f.forChildren;
1839
- const h = H(o).spec.parts;
1840
- if (h.length > 0) {
1841
- const g = /* @__PURE__ */ new Map();
1842
- h.forEach((p, b) => {
1843
- const m = v(
1844
- { kind: "part", owner: o, name: p.name, depth: b },
1845
- l,
1846
- o.id
2141
+ return { computed: m, forChildren: v };
2142
+ }, h = /* @__PURE__ */ new Set(), l = (u) => {
2143
+ var y;
2144
+ const p = ((y = u.derived) == null ? void 0 : y.instance) ?? u.sourceNode ?? u.id, i = typeof u.sourceDocument == "string" ? u.sourceDocument : null;
2145
+ we(e, u).forEach((k, f) => {
2146
+ const m = Xe(k.property, k.value);
2147
+ if (m === null) return;
2148
+ const v = `${u.sourceDocument ?? ""}#${p}#${f}`;
2149
+ h.has(v) || (h.add(v), s.push({
2150
+ kind: "unsupported-property",
2151
+ ...m,
2152
+ node: u.id,
2153
+ // A span is only meaningful in the entry document's own text; a
2154
+ // template's declaration names its file instead.
2155
+ ...i !== null ? { sourceDocument: i } : { at: { in: "uxml", span: k.span } }
2156
+ }));
2157
+ });
2158
+ }, c = (u, p) => {
2159
+ l(u);
2160
+ const i = x({ kind: "element", node: u }, p, u.id);
2161
+ r.set(u.id, i.computed);
2162
+ let y = i.forChildren;
2163
+ const k = Y(u).spec.parts;
2164
+ if (k.length > 0) {
2165
+ const f = /* @__PURE__ */ new Map();
2166
+ k.forEach((m, v) => {
2167
+ const w = x(
2168
+ { kind: "part", owner: u, name: m.name, depth: v },
2169
+ y,
2170
+ u.id
1847
2171
  );
1848
- g.set(p.name, m.computed), l = m.forChildren;
1849
- }), u.set(o.id, g);
2172
+ f.set(m.name, w.computed), y = w.forChildren;
2173
+ }), d.set(u.id, f);
1850
2174
  }
1851
- for (const g of o.children) d(g, l);
2175
+ for (const f of u.children) c(f, y);
1852
2176
  };
1853
- d(e.root, /* @__PURE__ */ new Map()), r && s.push({
2177
+ c(e.root, /* @__PURE__ */ new Map()), o && s.push({
1854
2178
  kind: "version-dependent",
1855
- message: `Unity's control defaults were applied, as measured on ${Z} (Unity ships these as a theme stylesheet). Other versions may use different values; see src/controls/theme.ts.`
2179
+ message: `Built-in control defaults applied, as measured on Unity ${te}`,
2180
+ reason: "version-dependent"
1856
2181
  });
1857
- for (const o of t.usable) {
1858
- if (o.builtin === !0 || c.has(o)) continue;
1859
- const a = tn(o.rule.selectors);
1860
- a.length !== 0 && s.push({
2182
+ for (const u of t.usable) {
2183
+ if (u.builtin === !0 || a.has(u)) continue;
2184
+ const p = mn(u.rule.selectors);
2185
+ p.length !== 0 && s.push({
1861
2186
  kind: "unsupported-selector",
1862
- message: `${a.join(", ")} matched nothing. Those names belong to the elements a control builds for itself, and only controls with a renderer of their own have them — ${Tt().join(", ")}. Anything else is drawn as a plain box and has no parts to style.`,
1863
- at: { in: "uss", sheet: o.sheet, span: o.rule.selectorSpan },
1864
- ...de(e, o.sheet)
2187
+ message: `${p.join(", ")} matched nothing; only ${ht().join(", ")} are drawn with the parts these names refer to`,
2188
+ at: { in: "uss", sheet: u.sheet, span: u.rule.selectorSpan },
2189
+ reason: "not-rendered",
2190
+ subject: { kind: "selector", selector: ee(e, u), fragment: p.join(", ") },
2191
+ ...H(e, u.sheet)
1865
2192
  });
1866
2193
  }
1867
- return { styles: i, partStyles: u, warnings: s };
2194
+ return { styles: r, partStyles: d, warnings: s };
1868
2195
  }
1869
- function Sn(e, n, t, s) {
1870
- const i = Ke(e, s), r = Ze(e, { kind: "element", node: n }, i).filter(
1871
- (u) => u.property === t
2196
+ function Ln(e, n, t, s) {
2197
+ const r = nt(e, s), o = st(e, { kind: "element", node: n }, r).filter(
2198
+ (d) => d.property === t
1872
2199
  );
1873
- return Qe(r), r;
2200
+ return ot(o), o;
1874
2201
  }
1875
- const $n = [
2202
+ const Un = [
1876
2203
  {
1877
2204
  id: "text-metrics",
1878
2205
  kind: "unreproducible",
@@ -1892,226 +2219,245 @@ const $n = [
1892
2219
  detail: "The yoga-layout version this package depends on resolves a main-axis percentage against an indefinite parent differently from the Yoga vendored inside Unity 6000.0.40f1. Not configurable: no available setting reproduces Unity's answer without breaking cases that currently match. Fully deterministic and pinned to a case in docs/accuracy.md — this always reproduces the same way, it just cannot be fixed from inside this repository."
1893
2220
  }
1894
2221
  ];
1895
- function mn(e, n) {
1896
- const t = (d) => e.slice(d.start, d.end);
1897
- function s(d) {
1898
- return d.spans.closeTag !== null ? d.spans.closeTag.end : Math.max(d.spans.openTag.end, d.spans.inner.end);
1899
- }
1900
- function i(d) {
1901
- return d.includes('"') ? d.includes("'") ? `"${d.replace(/"/g, "&quot;")}"` : `'${d}'` : `"${d}"`;
1902
- }
1903
- function r(d) {
1904
- const o = d.attributes.map((f) => ` ${f.name}=${i(f.value)}`).join(""), a = Ce(d.name);
1905
- return d.spans.closeTag === null ? `<${a}${o} />` : `<${a}${o}>`;
1906
- }
1907
- function u(d) {
1908
- var l, h;
1909
- const o = t(d.spans.inner), a = ((l = /^[ \t]*\r?\n[ \t]*/.exec(o)) == null ? void 0 : l[0]) ?? "", f = ((h = /\r?\n[ \t]*$/.exec(o)) == null ? void 0 : h[0]) ?? "";
1910
- return { between: a, before: a, after: f };
1911
- }
1912
- function c(d) {
1913
- const { inner: o } = d.spans;
1914
- if (d.children.length === 0) return t(o);
1915
- if (d.childrenDirty) {
1916
- const { between: l, before: h, after: g } = u(d);
1917
- return h + d.children.map(v).join(l) + g;
2222
+ function On(e, n) {
2223
+ const t = (h) => e.slice(h.start, h.end);
2224
+ function s(h) {
2225
+ return h.spans.closeTag !== null ? h.spans.closeTag.end : Math.max(h.spans.openTag.end, h.spans.inner.end);
2226
+ }
2227
+ function r(h) {
2228
+ return h.includes('"') ? h.includes("'") ? `"${h.replace(/"/g, "&quot;")}"` : `'${h}'` : `"${h}"`;
2229
+ }
2230
+ function o(h) {
2231
+ const l = h.attributes.map((u) => ` ${u.name}=${r(u.value)}`).join(""), c = Le(h.name);
2232
+ return h.spans.closeTag === null ? `<${c}${l} />` : `<${c}${l}>`;
2233
+ }
2234
+ function d(h) {
2235
+ var p, i;
2236
+ const l = t(h.spans.inner), c = ((p = /^[ \t]*\r?\n[ \t]*/.exec(l)) == null ? void 0 : p[0]) ?? "", u = ((i = /\r?\n[ \t]*$/.exec(l)) == null ? void 0 : i[0]) ?? "";
2237
+ return { between: c, before: c, after: u };
2238
+ }
2239
+ function a(h) {
2240
+ const { inner: l } = h.spans;
2241
+ if (h.children.length === 0) return t(l);
2242
+ if (h.childrenDirty) {
2243
+ const { between: p, before: i, after: y } = d(h);
2244
+ return i + h.children.map(x).join(p) + y;
1918
2245
  }
1919
- let a = "", f = o.start;
1920
- for (const l of d.children)
1921
- a += e.slice(f, l.spans.openTag.start), a += v(l), f = s(l);
1922
- return a + e.slice(f, o.end);
1923
- }
1924
- function v(d) {
1925
- const o = d.tagDirty ? r(d) : t(d.spans.openTag), a = d.spans.closeTag === null ? "" : t(d.spans.closeTag);
1926
- return o + c(d) + a;
1927
- }
1928
- return e.slice(0, n.spans.openTag.start) + v(n) + e.slice(s(n));
1929
- }
1930
- function gn(e) {
1931
- const n = e.source, t = (o) => n.slice(o.start, o.end);
1932
- function s(o) {
1933
- return o.parts.map((a, f) => {
1934
- const l = f === 0 ? "" : a.combinator === "child" ? " > " : " ", h = a.simple.map((g) => {
1935
- switch (g.kind) {
2246
+ let c = "", u = l.start;
2247
+ for (const p of h.children)
2248
+ c += e.slice(u, p.spans.openTag.start), c += x(p), u = s(p);
2249
+ return c + e.slice(u, l.end);
2250
+ }
2251
+ function x(h) {
2252
+ const l = h.tagDirty ? o(h) : t(h.spans.openTag), c = h.spans.closeTag === null ? "" : t(h.spans.closeTag);
2253
+ return l + a(h) + c;
2254
+ }
2255
+ return e.slice(0, n.spans.openTag.start) + x(n) + e.slice(s(n));
2256
+ }
2257
+ function Dn(e) {
2258
+ const n = e.source, t = (l) => n.slice(l.start, l.end);
2259
+ function s(l) {
2260
+ return l.parts.map((c, u) => {
2261
+ const p = u === 0 ? "" : c.combinator === "child" ? " > " : " ", i = c.simple.map((y) => {
2262
+ switch (y.kind) {
1936
2263
  case "universal":
1937
2264
  return "*";
1938
2265
  case "type":
1939
- return g.name;
2266
+ return y.name;
1940
2267
  case "class":
1941
- return `.${g.name}`;
2268
+ return `.${y.name}`;
1942
2269
  case "name":
1943
- return `#${g.name}`;
2270
+ return `#${y.name}`;
1944
2271
  case "pseudo":
1945
- return `:${g.name}`;
2272
+ return `:${y.name}`;
1946
2273
  case "unknown":
1947
- return g.text;
2274
+ return y.text;
1948
2275
  }
1949
2276
  }).join("");
1950
- return l + h;
2277
+ return p + i;
1951
2278
  }).join("");
1952
2279
  }
1953
- function i(o) {
1954
- var p, b;
1955
- const a = o.declarations[0];
1956
- if (a === void 0) return { between: "", before: "", after: "" };
1957
- const f = n.lastIndexOf(`
1958
- `, a.span.start), l = f < 0 ? "" : n.slice(f, a.span.start), h = n.slice(o.selectorSpan.end, o.span.end), g = ((b = (p = /\r?\n[ \t]*\}$/.exec(h)) == null ? void 0 : p[0]) == null ? void 0 : b.replace(/\}$/, "")) ?? "";
1959
- return { between: `;${l}`, before: l, after: `;${g}` };
1960
- }
1961
- function r(o) {
1962
- const a = o.selectorDirty ? o.selectors.map(s).join(", ") : t(o.selectorSpan);
1963
- if (o.declarations.length === 0)
1964
- return a + n.slice(o.selectorSpan.end, o.span.end);
1965
- const f = n.slice(o.selectorSpan.end, o.declarations[0].span.start);
1966
- if (o.declarationsDirty) {
1967
- const { between: g, before: p, after: b } = i(o), m = f.slice(0, f.indexOf("{") + 1), y = o.declarations.map(u).join(g);
1968
- return `${a}${m}${p}${y}${b}}`;
2280
+ function r(l) {
2281
+ var k, f;
2282
+ const c = l.declarations[0];
2283
+ if (c === void 0) return { between: "", before: "", after: "" };
2284
+ const u = n.lastIndexOf(`
2285
+ `, c.span.start), p = u < 0 ? "" : n.slice(u, c.span.start), i = n.slice(l.selectorSpan.end, l.span.end), y = ((f = (k = /\r?\n[ \t]*\}$/.exec(i)) == null ? void 0 : k[0]) == null ? void 0 : f.replace(/\}$/, "")) ?? "";
2286
+ return { between: `;${p}`, before: p, after: `;${y}` };
2287
+ }
2288
+ function o(l) {
2289
+ const c = l.selectorDirty ? l.selectors.map(s).join(", ") : t(l.selectorSpan);
2290
+ if (l.declarations.length === 0)
2291
+ return c + n.slice(l.selectorSpan.end, l.span.end);
2292
+ const u = n.slice(l.selectorSpan.end, l.declarations[0].span.start);
2293
+ if (l.declarationsDirty) {
2294
+ const { between: y, before: k, after: f } = r(l), m = u.slice(0, u.indexOf("{") + 1), v = l.declarations.map(d).join(y);
2295
+ return `${c}${m}${k}${v}${f}}`;
1969
2296
  }
1970
- let l = a, h = o.selectorSpan.end;
1971
- for (const g of o.declarations)
1972
- l += n.slice(h, g.span.start), l += u(g), h = g.span.end;
1973
- return l + n.slice(h, o.span.end);
2297
+ let p = c, i = l.selectorSpan.end;
2298
+ for (const y of l.declarations)
2299
+ p += n.slice(i, y.span.start), p += d(y), i = y.span.end;
2300
+ return p + n.slice(i, l.span.end);
1974
2301
  }
1975
- function u(o) {
1976
- return o.dirty ? `${o.property}: ${o.value}` : t(o.span);
2302
+ function d(l) {
2303
+ return l.dirty ? `${l.property}: ${l.value}` : t(l.span);
1977
2304
  }
1978
- function c(o) {
1979
- return o.kind === "rule" ? r(o.rule) : t(o.span);
2305
+ function a(l) {
2306
+ return l.kind === "rule" ? o(l.rule) : t(l.span);
1980
2307
  }
1981
- let v = "", d = 0;
1982
- for (const o of e.items) {
1983
- const a = o.kind === "rule" ? o.rule.span : o.span;
1984
- v += n.slice(d, a.start), v += c(o), d = a.end;
2308
+ let x = "", h = 0;
2309
+ for (const l of e.items) {
2310
+ const c = l.kind === "rule" ? l.rule.span : l.span;
2311
+ x += n.slice(h, c.start), x += a(l), h = c.end;
1985
2312
  }
1986
- return v + n.slice(d);
2313
+ return x + n.slice(h);
1987
2314
  }
1988
- ot(
1989
- (e, n) => n === void 0 ? Ie(e) : Ie(e, void 0, { resolveImport: n })
2315
+ gt(
2316
+ (e, n) => n === void 0 ? Ne(e) : Ne(e, void 0, { resolveImport: n })
1990
2317
  );
1991
- function et(e, n = []) {
2318
+ function rt(e, n = []) {
1992
2319
  var t;
1993
2320
  for (const s of e.children) {
1994
2321
  if (s.name.local === "Style") {
1995
- const i = (t = s.attributes.find((r) => r.name === "src")) == null ? void 0 : t.value;
1996
- i !== void 0 && i.length > 0 && n.push({ url: J(i), scope: e.id });
2322
+ const r = (t = s.attributes.find((o) => o.name === "src")) == null ? void 0 : t.value;
2323
+ r !== void 0 && r.length > 0 && n.push({ url: X(r), scope: e.id });
1997
2324
  }
1998
- et(s, n);
2325
+ rt(s, n);
1999
2326
  }
2000
2327
  return n;
2001
2328
  }
2002
- function wn(e) {
2329
+ function Mn(e) {
2003
2330
  return e.startsWith("project://") || e.startsWith("/");
2004
2331
  }
2005
- function Ie(e, n, t) {
2006
- var d, o;
2007
- const s = Re(e), i = [...s.warnings], r = [], u = [], c = [];
2008
- for (const { url: a, scope: f } of et(s.root)) {
2009
- const l = ((d = t == null ? void 0 : t.resolveImport) == null ? void 0 : d.call(t, a, null)) ?? null;
2010
- if (l === null) {
2011
- i.push({
2332
+ function Ne(e, n, t) {
2333
+ var h, l;
2334
+ const s = ze(e), r = [...s.warnings], o = [], d = [], a = [];
2335
+ for (const { url: c, scope: u } of rt(s.root)) {
2336
+ const p = ((h = t == null ? void 0 : t.resolveImport) == null ? void 0 : h.call(t, c, null)) ?? null;
2337
+ if (p === null) {
2338
+ r.push({
2012
2339
  kind: "import-unresolved",
2013
- message: (t == null ? void 0 : t.resolveImport) === void 0 ? `<Style src="${a}"> was not loaded: pass resolveImport to read it, or pass the stylesheet text directly. Until then this document renders unstyled.` : `<Style src="${a}"> could not be resolved`,
2014
- node: s.root.id
2340
+ message: (t == null ? void 0 : t.resolveImport) === void 0 ? `<Style src="${c}"> was not loaded: pass resolveImport to read it, or pass the stylesheet text directly. Until then this document renders unstyled.` : `<Style src="${c}"> could not be resolved`,
2341
+ node: s.root.id,
2342
+ subject: { kind: "import", url: c, from: null }
2015
2343
  });
2016
2344
  continue;
2017
2345
  }
2018
- c.push({ text: l, origin: a, scope: f });
2019
- }
2020
- if (n !== void 0 || c.length > 0) {
2021
- const a = /* @__PURE__ */ new Map(), f = [];
2022
- let l = 0;
2023
- for (const h of c) {
2024
- const g = l++;
2025
- f.push({ text: h.text, origin: h.origin, sheet: g }), u.push({ sheet: g, scope: h.scope });
2346
+ a.push({ text: p, origin: c, scope: u });
2347
+ }
2348
+ if (n !== void 0 || a.length > 0) {
2349
+ const c = /* @__PURE__ */ new Map(), u = [];
2350
+ let p = 0;
2351
+ for (const i of a) {
2352
+ const y = p++;
2353
+ u.push({ text: i.text, origin: i.origin, sheet: y }), d.push({ sheet: y, scope: i.scope });
2026
2354
  }
2027
2355
  if (n !== void 0) {
2028
- const h = l++;
2029
- f.push({ text: n, origin: null, sheet: h }), u.push({ sheet: h, scope: s.root.id });
2356
+ const i = p++;
2357
+ u.push({ text: n, origin: null, sheet: i }), d.push({ sheet: i, scope: s.root.id });
2030
2358
  }
2031
- for (; f.length > 0; ) {
2032
- const h = f.shift(), g = h.sheet, p = ge(h.text, h.origin, g);
2033
- r.push(p.sheet), i.push(...p.warnings);
2034
- for (const b of p.sheet.items) {
2035
- if (b.kind !== "import") continue;
2036
- const m = wn(b.url) ? b.url : JSON.stringify([b.url, h.origin]);
2037
- if (a.has(m)) {
2038
- const x = a.get(m);
2039
- x != null && (b.resolvedSheet = x);
2359
+ for (; u.length > 0; ) {
2360
+ const i = u.shift(), y = i.sheet, k = ve(i.text, i.origin, y);
2361
+ o.push(k.sheet), r.push(...k.warnings);
2362
+ for (const f of k.sheet.items) {
2363
+ if (f.kind !== "import") continue;
2364
+ const m = Mn(f.url) ? f.url : JSON.stringify([f.url, i.origin]);
2365
+ if (c.has(m)) {
2366
+ const g = c.get(m);
2367
+ g != null && (f.resolvedSheet = g);
2040
2368
  continue;
2041
2369
  }
2042
- a.set(m, null);
2043
- const y = ((o = t == null ? void 0 : t.resolveImport) == null ? void 0 : o.call(t, b.url, h.origin)) ?? null;
2044
- if (y === null) {
2045
- i.push({
2370
+ c.set(m, null);
2371
+ const v = ((l = t == null ? void 0 : t.resolveImport) == null ? void 0 : l.call(t, f.url, i.origin)) ?? null;
2372
+ if (v === null) {
2373
+ r.push({
2046
2374
  kind: "import-unresolved",
2047
- message: (t == null ? void 0 : t.resolveImport) === void 0 ? `@import "${b.url}" was not loaded: pass resolveImport to read it` : `@import "${b.url}" could not be resolved`,
2048
- at: { in: "uss", sheet: g, span: b.span }
2375
+ message: (t == null ? void 0 : t.resolveImport) === void 0 ? `@import "${f.url}" was not loaded: pass resolveImport to read it` : `@import "${f.url}" could not be resolved`,
2376
+ at: { in: "uss", sheet: y, span: f.span },
2377
+ subject: { kind: "import", url: f.url, from: i.origin }
2049
2378
  });
2050
2379
  continue;
2051
2380
  }
2052
- const k = l++;
2053
- a.set(m, k), b.resolvedSheet = k, f.push({ text: y, origin: b.url, sheet: k });
2381
+ const w = p++;
2382
+ c.set(m, w), f.resolvedSheet = w, u.push({ text: v, origin: f.url, sheet: w });
2054
2383
  }
2055
2384
  }
2056
2385
  }
2057
- const v = { source: e, root: s.root, sheets: r, styleRoots: u, warnings: i };
2058
- return lt(v, t == null ? void 0 : t.resolveImport), v;
2386
+ const x = { source: e, root: s.root, sheets: o, styleRoots: d, warnings: r };
2387
+ return yt(x, t == null ? void 0 : t.resolveImport), x;
2059
2388
  }
2060
- function Tn(e) {
2389
+ function _n(e) {
2061
2390
  const n = e.sheets[0];
2062
2391
  return {
2063
- uxml: mn(e.source, e.root),
2392
+ uxml: On(e.source, e.root),
2064
2393
  // Only the sheet passed to `parse` round-trips. `@import`ed sheets (Phase 3)
2065
2394
  // are separate files and are not this function's to write.
2066
- uss: n === void 0 ? "" : gn(n)
2395
+ uss: n === void 0 ? "" : Dn(n)
2067
2396
  };
2068
2397
  }
2069
- function On(e, n, t) {
2070
- const s = n.ownerDocument, i = (t == null ? void 0 : t.size) ?? {
2398
+ function Rn(e) {
2399
+ const n = /* @__PURE__ */ new Set();
2400
+ return e.filter((t) => {
2401
+ if (t.at === void 0) return !0;
2402
+ const s = JSON.stringify([t.kind, t.message, t.sourceDocument ?? null, t.at]);
2403
+ return n.has(s) ? !1 : (n.add(s), !0);
2404
+ });
2405
+ }
2406
+ function Wn(e, n, t) {
2407
+ const s = n.ownerDocument, r = (t == null ? void 0 : t.size) ?? {
2071
2408
  width: n.clientWidth,
2072
2409
  height: n.clientHeight
2073
- }, r = bt(e), u = r.document, c = hn(u, {
2410
+ }, o = Dt(e), d = o.document, a = En(d, {
2074
2411
  ...(t == null ? void 0 : t.activeStates) === void 0 ? {} : { activeStates: t.activeStates },
2075
2412
  ...(t == null ? void 0 : t.states) === void 0 ? {} : { states: t.states }
2076
- }), v = (t == null ? void 0 : t.measureText) ?? jt(s), d = zt(u.root, c.styles, c.partStyles, {
2077
- size: i,
2078
- measureText: v
2413
+ }), x = (t == null ? void 0 : t.measureText) ?? en(s), h = Tn(d), l = Kt(d.root, a.styles, a.partStyles, {
2414
+ size: r,
2415
+ measureText: x,
2416
+ locate: h
2079
2417
  });
2080
- let o;
2418
+ let c;
2081
2419
  try {
2082
- o = Yt(u.root, d.boxes, d.parts, c.styles, n, {
2420
+ c = un(d.root, l.boxes, l.parts, a.styles, n, {
2083
2421
  document: s,
2084
- resolveAsset: t == null ? void 0 : t.resolveAsset
2422
+ resolveAsset: t == null ? void 0 : t.resolveAsset,
2423
+ locate: h
2085
2424
  });
2086
- } catch (f) {
2087
- throw d.dispose(), f;
2425
+ } catch (p) {
2426
+ throw l.dispose(), p;
2088
2427
  }
2089
- let a = !1;
2428
+ let u = !1;
2090
2429
  return {
2091
- warnings: [...r.warnings, ...c.warnings, ...d.warnings, ...o.warnings],
2092
- elements: o.elements,
2093
- boxes: d.boxes,
2430
+ warnings: Rn([
2431
+ ...o.warnings,
2432
+ ...a.warnings,
2433
+ ...l.warnings,
2434
+ ...c.warnings
2435
+ ]),
2436
+ elements: c.elements,
2437
+ boxes: l.boxes,
2094
2438
  dispose() {
2095
- a || (a = !0, d.dispose(), n.replaceChildren());
2439
+ u || (u = !0, l.dispose(), n.replaceChildren());
2096
2440
  }
2097
2441
  };
2098
2442
  }
2099
2443
  export {
2100
- $n as KNOWN_DIVERGENCES,
2101
- Gt as NODE_ATTRIBUTE,
2102
- Jt as PART_ATTRIBUTE,
2103
- Xt as PART_OWNER_ATTRIBUTE,
2104
- bn as collectDependencies,
2105
- jt as createDefaultMeasureText,
2106
- bt as expandTemplates,
2107
- Sn as explainProperty,
2108
- Dt as isInherited,
2109
- xn as isLayoutEngineReady,
2110
- kn as liveNodeCount,
2111
- yn as loadLayoutEngine,
2112
- Ie as parse,
2113
- On as render,
2114
- hn as resolveStyles,
2115
- Tn as serialize,
2116
- Tt as supportedControlNames
2444
+ Un as KNOWN_DIVERGENCES,
2445
+ an as NODE_ATTRIBUTE,
2446
+ ln as PART_ATTRIBUTE,
2447
+ cn as PART_OWNER_ATTRIBUTE,
2448
+ Ie as TEMPLATE_DEPTH_LIMIT,
2449
+ Pt as USS_STATES,
2450
+ Cn as collectDependencies,
2451
+ en as createDefaultMeasureText,
2452
+ Dt as expandTemplates,
2453
+ Ln as explainProperty,
2454
+ Bt as isInherited,
2455
+ jn as isLayoutEngineReady,
2456
+ zn as liveNodeCount,
2457
+ Nn as loadLayoutEngine,
2458
+ Ne as parse,
2459
+ Wn as render,
2460
+ En as resolveStyles,
2461
+ _n as serialize,
2462
+ ht as supportedControlNames
2117
2463
  };