@pygmalionjs/pygmalion 0.2.19 → 0.2.21

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.
@@ -1,7 +1,7 @@
1
- import { jsxs as R, jsx as b } from "react/jsx-runtime";
2
- import { b as Q, m as Ke, v as qe, c as Ge, i as Je, g as Le, e as K, d as Ve, a as We, f as Qe, h as Xe, j as Ye, k as Ze, l as et, n as tt, o as nt, p as rt, q as ot, r as it, t as st, u as ie, S as at, A as ct, w as xe, x as lt, y as dt, z as ft, B as ut, C as pt, D as ht, E as mt, G as Pe } from "./App-CiSnd2mV.js";
3
- import { H as kn, I as Dn, J as zn, K as _n, L as Fn, M as jn, O as Bn, P as Un, Q as Hn, R as Kn, T as qn, U as Gn, V as Jn, W as Ln, X as Vn, Y as Wn, Z as Qn } from "./App-CiSnd2mV.js";
4
- import { createElement as Ee, useMemo as le, useState as ee, useRef as Ne, useCallback as W, useEffect as te } from "react";
1
+ import { jsxs as N, jsx as w } from "react/jsx-runtime";
2
+ import { b as Q, m as Ge, v as Ve, c as qe, i as Je, g as Le, e as K, d as We, a as Qe, f as Xe, h as Ye, j as Ze, k as et, l as tt, n as nt, o as rt, p as ot, q as it, r as st, t as at, u as ct, w as ie, S as lt, A as dt, x as xe, y as ft, z as ut, B as pt, C as ht, D as mt, E as gt, G as yt, H as Pe } from "./App-B_6qmxhS.js";
3
+ import { I as zn, J as _n, K as Fn, L as jn, M as Bn, O as Un, P as Hn, Q as Kn, R as Gn, T as Vn, U as qn, V as Jn, W as Ln, X as Wn, Y as Qn, Z as Xn, _ as Yn, $ as Zn } from "./App-B_6qmxhS.js";
4
+ import { createElement as Ee, useMemo as de, useState as te, useRef as Ne, useCallback as W, useEffect as ne } from "react";
5
5
  function we(e, t = /* @__PURE__ */ new Set()) {
6
6
  if (e == null || typeof e == "string" || typeof e == "boolean" || typeof e == "number" && Number.isFinite(e))
7
7
  return e;
@@ -11,14 +11,14 @@ function we(e, t = /* @__PURE__ */ new Set()) {
11
11
  if (t.has(e))
12
12
  throw new Error("A storyboard recipe cannot contain circular references.");
13
13
  t.add(e);
14
- const r = {};
14
+ const o = {};
15
15
  for (const n of Object.keys(e).sort()) {
16
- const o = e[n];
17
- o !== void 0 && (r[n] = we(o, t));
16
+ const r = e[n];
17
+ r !== void 0 && (o[n] = we(r, t));
18
18
  }
19
- return t.delete(e), r;
19
+ return t.delete(e), o;
20
20
  }
21
- function gt(e) {
21
+ function wt(e) {
22
22
  return JSON.stringify(
23
23
  we({
24
24
  version: 1,
@@ -40,17 +40,17 @@ function gt(e) {
40
40
  );
41
41
  }
42
42
  function z(e) {
43
- return [...new Set([...e].map((t) => t == null ? void 0 : t.trim()).filter(Boolean))].sort((t, r) => t.localeCompare(r));
43
+ return [...new Set([...e].map((t) => t == null ? void 0 : t.trim()).filter(Boolean))].sort((t, o) => t.localeCompare(o));
44
44
  }
45
- function yt(e, t) {
45
+ function bt(e, t) {
46
46
  var n;
47
47
  return ((n = e.id) == null ? void 0 : n.trim()) || `edge:${t + 1}`;
48
48
  }
49
- function wt(e) {
50
- const t = [...e.screens].sort((n, o) => n.id.localeCompare(o.id)), r = t[0].id;
49
+ function St(e) {
50
+ const t = [...e.screens].sort((n, r) => n.id.localeCompare(r.id)), o = t[0].id;
51
51
  return {
52
- id: `story:${r}`,
53
- canonicalScreenId: r,
52
+ id: `story:${o}`,
53
+ canonicalScreenId: o,
54
54
  screenIds: t.map((n) => n.id),
55
55
  names: z(t.map((n) => n.name)),
56
56
  recipeKey: e.recipeKey,
@@ -75,210 +75,210 @@ function Re(e) {
75
75
  e.scenarioId
76
76
  ].join(":");
77
77
  }
78
- function bt(e) {
78
+ function vt(e) {
79
79
  var re, oe;
80
- const t = [], r = [], n = /* @__PURE__ */ new Map();
80
+ const t = [], o = [], n = /* @__PURE__ */ new Map();
81
81
  for (const c of e.screens) {
82
- const d = c.id.trim();
83
- if (!d || n.has(d)) {
82
+ const f = c.id.trim();
83
+ if (!f || n.has(f)) {
84
84
  t.push({
85
85
  code: "duplicate-screen-id",
86
86
  severity: "error",
87
- message: d ? `Multiple storyboard screens use the id "${d}".` : "A storyboard screen has an empty id.",
88
- screenId: d || void 0
87
+ message: f ? `Multiple storyboard screens use the id "${f}".` : "A storyboard screen has an empty id.",
88
+ screenId: f || void 0
89
89
  });
90
90
  continue;
91
91
  }
92
- const l = d === c.id ? c : { ...c, id: d };
93
- n.set(d, l), r.push(l);
92
+ const d = f === c.id ? c : { ...c, id: f };
93
+ n.set(f, d), o.push(d);
94
94
  }
95
- const o = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set();
96
- for (const c of r) {
97
- let d;
95
+ const r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set();
96
+ for (const c of o) {
97
+ let f;
98
98
  try {
99
- if (d = (e.recipeKey ?? gt)(c), !d.trim()) throw new Error("Recipe keys cannot be empty.");
99
+ if (f = (e.recipeKey ?? wt)(c), !f.trim()) throw new Error("Recipe keys cannot be empty.");
100
100
  } catch (u) {
101
101
  i.add(c.id), t.push({
102
102
  code: "invalid-recipe",
103
103
  severity: "error",
104
104
  message: u instanceof Error ? u.message : "Storyboard recipe identity could not be created.",
105
105
  screenId: c.id
106
- }), d = `invalid:${c.id}`;
106
+ }), f = `invalid:${c.id}`;
107
107
  }
108
- const l = o.get(d);
109
- l ? l.screens.push(c) : o.set(d, { recipeKey: d, screens: [c] });
108
+ const d = r.get(f);
109
+ d ? d.screens.push(c) : r.set(f, { recipeKey: f, screens: [c] });
110
110
  }
111
- const s = [...o.values()].map(wt).sort((c, d) => c.id.localeCompare(d.id)), a = {};
111
+ const s = [...r.values()].map(St).sort((c, f) => c.id.localeCompare(f.id)), a = {};
112
112
  for (const c of s)
113
- for (const d of c.screenIds) a[d] = c.id;
114
- const f = new Map(s.map((c) => [c.id, c])), m = /* @__PURE__ */ new Map();
113
+ for (const f of c.screenIds) a[f] = c.id;
114
+ const l = new Map(s.map((c) => [c.id, c])), g = /* @__PURE__ */ new Map();
115
115
  for (const c of e.assets ?? []) {
116
- const d = m.get(c.pageId);
117
- d ? d.push(c) : m.set(c.pageId, [c]);
116
+ const f = g.get(c.pageId);
117
+ f ? f.push(c) : g.set(c.pageId, [c]);
118
118
  }
119
119
  const p = s.map((c) => {
120
- const d = c.screenIds.flatMap(
121
- (l) => m.get(l) ?? []
120
+ const f = c.screenIds.flatMap(
121
+ (d) => g.get(d) ?? []
122
122
  );
123
123
  return {
124
124
  ...c,
125
125
  scenarioIds: z([
126
126
  ...c.scenarioIds,
127
- ...d.map((l) => l.scenarioId)
127
+ ...f.map((d) => d.scenarioId)
128
128
  ]),
129
129
  sourceKeys: z([
130
130
  ...c.sourceKeys,
131
- ...d.map((l) => l.sourcePath)
131
+ ...f.map((d) => d.sourcePath)
132
132
  ])
133
133
  };
134
- }), y = /* @__PURE__ */ new Map();
134
+ }), b = /* @__PURE__ */ new Map();
135
135
  for (const c of p)
136
- for (const d of c.routes) {
137
- const l = y.get(d);
138
- l ? l.push(c.id) : y.set(d, [c.id]);
136
+ for (const f of c.routes) {
137
+ const d = b.get(f);
138
+ d ? d.push(c.id) : b.set(f, [c.id]);
139
139
  }
140
- const g = (c, d, l) => {
141
- const u = c.trim(), x = a[u] ?? (f.has(u) ? u : null);
142
- if (x) return x;
143
- const I = z(y.get(u) ?? []);
140
+ const m = (c, f, d) => {
141
+ const u = c.trim(), P = a[u] ?? (l.has(u) ? u : null);
142
+ if (P) return P;
143
+ const I = z(b.get(u) ?? []);
144
144
  return I.length === 1 ? I[0] : I.length > 1 ? (t.push({
145
- code: l === "source" ? "ambiguous-edge-source" : "ambiguous-edge-target",
145
+ code: d === "source" ? "ambiguous-edge-source" : "ambiguous-edge-target",
146
146
  severity: "error",
147
- message: `Storyboard edge "${d}" references an ambiguous ${l} route.`,
148
- edgeId: d,
147
+ message: `Storyboard edge "${f}" references an ambiguous ${d} route.`,
148
+ edgeId: f,
149
149
  screenId: u || void 0
150
150
  }), null) : (t.push({
151
- code: l === "source" ? "unknown-edge-source" : "unknown-edge-target",
151
+ code: d === "source" ? "unknown-edge-source" : "unknown-edge-target",
152
152
  severity: "error",
153
- message: `Storyboard edge "${d}" references an unknown ${l}.`,
154
- edgeId: d,
153
+ message: `Storyboard edge "${f}" references an unknown ${d}.`,
154
+ edgeId: f,
155
155
  screenId: u || void 0
156
156
  }), null);
157
- }, v = [], w = /* @__PURE__ */ new Map(), N = [
157
+ }, v = [], y = /* @__PURE__ */ new Map(), R = [
158
158
  ["explicit", e.explicitEdges ?? []],
159
159
  ["inferred", e.inferredEdges ?? []]
160
160
  ];
161
161
  let h = 0;
162
- for (const [c, d] of N)
163
- for (const l of d) {
164
- const u = yt(l, h);
162
+ for (const [c, f] of R)
163
+ for (const d of f) {
164
+ const u = bt(d, h);
165
165
  h += 1;
166
- const x = g(l.from, u, "source"), I = g(l.to, u, "target");
167
- if (!x || !I || x === I) continue;
168
- const M = `${x}\0${I}`, C = w.get(M);
166
+ const P = m(d.from, u, "source"), I = m(d.to, u, "target");
167
+ if (!P || !I || P === I) continue;
168
+ const M = `${P}\0${I}`, C = y.get(M);
169
169
  if (C) {
170
170
  if (!C.sourceEdgeIds.includes(u)) {
171
- const q = {
171
+ const V = {
172
172
  ...C,
173
173
  sourceEdgeIds: z([
174
174
  ...C.sourceEdgeIds,
175
175
  u
176
176
  ])
177
177
  };
178
- w.set(M, q);
178
+ y.set(M, V);
179
179
  const H = v.indexOf(C);
180
- H >= 0 && (v[H] = q);
180
+ H >= 0 && (v[H] = V);
181
181
  }
182
182
  continue;
183
183
  }
184
184
  const L = {
185
185
  id: u,
186
- from: x,
186
+ from: P,
187
187
  to: I,
188
- kind: ((re = l.kind) == null ? void 0 : re.trim()) || void 0,
189
- label: ((oe = l.label) == null ? void 0 : oe.trim()) || void 0,
188
+ kind: ((re = d.kind) == null ? void 0 : re.trim()) || void 0,
189
+ label: ((oe = d.label) == null ? void 0 : oe.trim()) || void 0,
190
190
  origin: c,
191
191
  sourceEdgeIds: [u]
192
192
  };
193
- w.set(M, L), v.push(L);
193
+ y.set(M, L), v.push(L);
194
194
  }
195
195
  v.sort(
196
- (c, d) => `${c.from}:${c.to}:${c.id}`.localeCompare(`${d.from}:${d.to}:${d.id}`)
196
+ (c, f) => `${c.from}:${c.to}:${c.id}`.localeCompare(`${f.from}:${f.to}:${f.id}`)
197
197
  );
198
198
  const O = /* @__PURE__ */ new Map(), A = /* @__PURE__ */ new Map();
199
199
  for (const c of v) {
200
- const d = A.get(c.from);
201
- d ? d.push(c) : A.set(c.from, [c]);
202
- const l = O.get(c.to);
203
- l ? l.push(c) : O.set(c.to, [c]);
200
+ const f = A.get(c.from);
201
+ f ? f.push(c) : A.set(c.from, [c]);
202
+ const d = O.get(c.to);
203
+ d ? d.push(c) : O.set(c.to, [c]);
204
204
  }
205
- const $ = [];
205
+ const D = [];
206
206
  for (const c of e.startScreenIds ?? []) {
207
- const d = c.trim(), l = a[d] ?? (f.has(d) ? d : null);
208
- if (!l) {
207
+ const f = c.trim(), d = a[f] ?? (l.has(f) ? f : null);
208
+ if (!d) {
209
209
  t.push({
210
210
  code: "unknown-start-screen",
211
211
  severity: "error",
212
- message: `Storyboard start references an unknown screen "${d}".`,
213
- screenId: d || void 0
212
+ message: `Storyboard start references an unknown screen "${f}".`,
213
+ screenId: f || void 0
214
214
  });
215
215
  continue;
216
216
  }
217
- $.push(l);
217
+ D.push(d);
218
218
  }
219
- const T = new Set($);
220
- let k = z($);
219
+ const $ = new Set(D);
220
+ let k = z(D);
221
221
  k.length || (k = p.filter((c) => {
222
- var d;
223
- return (((d = O.get(c.id)) == null ? void 0 : d.length) ?? 0) === 0;
224
- }).map((c) => c.id).sort((c, d) => c.localeCompare(d))), !k.length && p.length && (k = [p[0].id]);
225
- const S = /* @__PURE__ */ new Set(), P = [...k];
226
- for (; P.length; ) {
227
- const c = P.shift();
222
+ var f;
223
+ return (((f = O.get(c.id)) == null ? void 0 : f.length) ?? 0) === 0;
224
+ }).map((c) => c.id).sort((c, f) => c.localeCompare(f))), !k.length && p.length && (k = [p[0].id]);
225
+ const S = /* @__PURE__ */ new Set(), x = [...k];
226
+ for (; x.length; ) {
227
+ const c = x.shift();
228
228
  if (!S.has(c)) {
229
229
  S.add(c);
230
- for (const d of A.get(c) ?? []) P.push(d.to);
230
+ for (const f of A.get(c) ?? []) x.push(f.to);
231
231
  }
232
232
  }
233
- const D = p.filter((c) => {
234
- var l, u;
235
- const d = (((l = O.get(c.id)) == null ? void 0 : l.length) ?? 0) === 0 && (((u = A.get(c.id)) == null ? void 0 : u.length) ?? 0) === 0 && !T.has(c.id);
236
- return !S.has(c.id) || d && p.length > 1;
233
+ const T = p.filter((c) => {
234
+ var d, u;
235
+ const f = (((d = O.get(c.id)) == null ? void 0 : d.length) ?? 0) === 0 && (((u = A.get(c.id)) == null ? void 0 : u.length) ?? 0) === 0 && !$.has(c.id);
236
+ return !S.has(c.id) || f && p.length > 1;
237
237
  });
238
- for (const c of D)
239
- for (const d of c.screenIds)
238
+ for (const c of T)
239
+ for (const f of c.screenIds)
240
240
  t.push({
241
241
  code: "disconnected-screen",
242
242
  severity: "warning",
243
- message: `Storyboard screen "${d}" is not connected to a graph branch.`,
244
- screenId: d,
243
+ message: `Storyboard screen "${f}" is not connected to a graph branch.`,
244
+ screenId: f,
245
245
  nodeId: c.id
246
246
  });
247
247
  const j = /* @__PURE__ */ new Map();
248
248
  for (const c of p)
249
- for (const d of c.sourceKeys) {
250
- const l = j.get(d) ?? {
249
+ for (const f of c.sourceKeys) {
250
+ const d = j.get(f) ?? {
251
251
  nodeIds: /* @__PURE__ */ new Set(),
252
252
  screenIds: /* @__PURE__ */ new Set()
253
253
  };
254
- l.nodeIds.add(c.id);
255
- for (const u of c.screenIds) l.screenIds.add(u);
256
- j.set(d, l);
254
+ d.nodeIds.add(c.id);
255
+ for (const u of c.screenIds) d.screenIds.add(u);
256
+ j.set(f, d);
257
257
  }
258
- const Y = [...j.entries()].map(([c, d]) => ({
258
+ const X = [...j.entries()].map(([c, f]) => ({
259
259
  sourceKey: c,
260
- nodeIds: [...d.nodeIds].sort((l, u) => l.localeCompare(u)),
261
- screenIds: [...d.screenIds].sort((l, u) => l.localeCompare(u)),
262
- shared: d.nodeIds.size > 1
263
- })).sort((c, d) => c.sourceKey.localeCompare(d.sourceKey)), J = p.map((c) => {
264
- const d = [...A.get(c.id) ?? []].sort(
265
- (l, u) => l.id.localeCompare(u.id)
260
+ nodeIds: [...f.nodeIds].sort((d, u) => d.localeCompare(u)),
261
+ screenIds: [...f.screenIds].sort((d, u) => d.localeCompare(u)),
262
+ shared: f.nodeIds.size > 1
263
+ })).sort((c, f) => c.sourceKey.localeCompare(f.sourceKey)), Y = p.map((c) => {
264
+ const f = [...A.get(c.id) ?? []].sort(
265
+ (d, u) => d.id.localeCompare(u.id)
266
266
  );
267
267
  return {
268
268
  nodeId: c.id,
269
- edgeIds: d.map((l) => l.id),
270
- targetNodeIds: z(d.map((l) => l.to))
269
+ edgeIds: f.map((d) => d.id),
270
+ targetNodeIds: z(f.map((d) => d.to))
271
271
  };
272
- }).filter((c) => c.targetNodeIds.length > 1).sort((c, d) => c.nodeId.localeCompare(d.nodeId)), V = new Set(
272
+ }).filter((c) => c.targetNodeIds.length > 1).sort((c, f) => c.nodeId.localeCompare(f.nodeId)), G = new Set(
273
273
  p.flatMap((c) => c.scenarioIds)
274
- ), E = new Set(
274
+ ), Z = new Set(
275
275
  (e.nonVisualScenarioIds ?? []).map((c) => c.trim())
276
- ), B = z(
276
+ ), E = z(
277
277
  (e.scenarios ?? []).map((c) => c.id)
278
- ), _ = B.filter(
279
- (c) => !V.has(c) && !E.has(c)
278
+ ), B = E.filter(
279
+ (c) => !G.has(c) && !Z.has(c)
280
280
  );
281
- for (const c of _)
281
+ for (const c of B)
282
282
  t.push({
283
283
  code: "missing-code-scenario",
284
284
  severity: "warning",
@@ -286,122 +286,122 @@ function bt(e) {
286
286
  scenarioId: c
287
287
  });
288
288
  t.sort(
289
- (c, d) => Re(c).localeCompare(Re(d))
289
+ (c, f) => Re(c).localeCompare(Re(f))
290
290
  );
291
- const ne = z(
292
- D.flatMap((c) => c.screenIds)
293
- ), se = {
294
- screens: r.length,
291
+ const _ = z(
292
+ T.flatMap((c) => c.screenIds)
293
+ ), ae = {
294
+ screens: o.length,
295
295
  canonicalNodes: p.length,
296
- mergedScreens: Math.max(0, r.length - p.length),
296
+ mergedScreens: Math.max(0, o.length - p.length),
297
297
  edges: v.length,
298
- connectedNodes: p.length - D.length,
299
- disconnectedScreens: ne,
300
- codeScenarios: B.length,
301
- representedScenarios: B.filter(
302
- (c) => V.has(c)
298
+ connectedNodes: p.length - T.length,
299
+ disconnectedScreens: _,
300
+ codeScenarios: E.length,
301
+ representedScenarios: E.filter(
302
+ (c) => G.has(c)
303
303
  ).length,
304
- missingScenarios: _,
305
- complete: ne.length === 0 && _.length === 0 && !t.some((c) => c.severity === "error") && i.size === 0
304
+ missingScenarios: B,
305
+ complete: _.length === 0 && B.length === 0 && !t.some((c) => c.severity === "error") && i.size === 0
306
306
  };
307
307
  return {
308
308
  version: 1,
309
309
  nodes: p,
310
310
  edges: v,
311
311
  aliases: Object.fromEntries(
312
- Object.entries(a).sort(([c], [d]) => c.localeCompare(d))
312
+ Object.entries(a).sort(([c], [f]) => c.localeCompare(f))
313
313
  ),
314
- sourceGroups: Y,
314
+ sourceGroups: X,
315
315
  startNodeIds: k,
316
- branches: J,
316
+ branches: Y,
317
317
  warnings: t,
318
- coverage: se
318
+ coverage: ae
319
319
  };
320
320
  }
321
- function St(e) {
321
+ function It(e) {
322
322
  return e ? JSON.parse(JSON.stringify(e)) : void 0;
323
323
  }
324
- function de(e) {
325
- if (Array.isArray(e)) return e.map(de);
324
+ function fe(e) {
325
+ if (Array.isArray(e)) return e.map(fe);
326
326
  if (e && typeof e == "object") {
327
- const t = Object.entries(e).filter(([, r]) => r !== void 0).sort(([r], [n]) => r.localeCompare(n)).map(([r, n]) => [r, de(n)]).filter(([, r]) => r !== void 0);
327
+ const t = Object.entries(e).filter(([, o]) => o !== void 0).sort(([o], [n]) => o.localeCompare(n)).map(([o, n]) => [o, fe(n)]).filter(([, o]) => o !== void 0);
328
328
  return t.length ? Object.fromEntries(t) : void 0;
329
329
  }
330
330
  return e;
331
331
  }
332
332
  function Ce(e) {
333
- return JSON.stringify(de(e ?? null));
333
+ return JSON.stringify(fe(e ?? null));
334
334
  }
335
- function vt(e) {
335
+ function xt(e) {
336
336
  return !!(e && typeof e == "object" && !Array.isArray(e));
337
337
  }
338
338
  function U(e) {
339
339
  const t = e == null ? void 0 : e.trim();
340
340
  if (!t) return null;
341
- let r = t;
341
+ let o = t;
342
342
  try {
343
- /^[a-z][a-z\d+.-]*:\/\//i.test(t) && (r = new URL(t).pathname);
343
+ /^[a-z][a-z\d+.-]*:\/\//i.test(t) && (o = new URL(t).pathname);
344
344
  } catch {
345
345
  return null;
346
346
  }
347
- return r = r.split(/[?#]/, 1)[0].replace(/\/{2,}/g, "/"), r.startsWith("/") || (r = `/${r}`), r.length > 1 && (r = r.replace(/\/+$/, "")), r || "/";
347
+ return o = o.split(/[?#]/, 1)[0].replace(/\/{2,}/g, "/"), o.startsWith("/") || (o = `/${o}`), o.length > 1 && (o = o.replace(/\/+$/, "")), o || "/";
348
348
  }
349
- function De(e) {
349
+ function ke(e) {
350
350
  return `source-route:${encodeURIComponent(e)}`;
351
351
  }
352
352
  function Ie(e, t) {
353
- const r = e.split("/").filter(Boolean), n = t.split("/").filter(Boolean);
354
- let o = 0;
355
- for (let i = 0; i < r.length; i += 1) {
356
- const s = r[i];
353
+ const o = e.split("/").filter(Boolean), n = t.split("/").filter(Boolean);
354
+ let r = 0;
355
+ for (let i = 0; i < o.length; i += 1) {
356
+ const s = o[i];
357
357
  if (s === "*" || s.startsWith("*")) return !0;
358
- const a = n[o];
358
+ const a = n[r];
359
359
  if (!(s.endsWith("?") && a == null)) {
360
360
  if (a == null || !s.startsWith(":") && s !== a) return !1;
361
- o += 1;
361
+ r += 1;
362
362
  }
363
363
  }
364
- return o === n.length;
364
+ return r === n.length;
365
365
  }
366
366
  function Ae(e, t) {
367
- const r = U(e);
368
- if (!r) return [];
369
- const n = t.get(r);
370
- return n && !/[:*]/.test(r) ? [n] : [
367
+ const o = U(e);
368
+ if (!o) return [];
369
+ const n = t.get(o);
370
+ return n && !/[:*]/.test(o) ? [n] : [
371
371
  ...new Set(
372
- [...t.entries()].filter(([o]) => Ie(r, o)).map(([, o]) => o)
372
+ [...t.entries()].filter(([r]) => Ie(o, r)).map(([, r]) => r)
373
373
  )
374
- ].sort((o, i) => o.localeCompare(i));
374
+ ].sort((r, i) => r.localeCompare(i));
375
375
  }
376
- function It(e) {
377
- var r;
376
+ function Pt(e) {
377
+ var o;
378
378
  const t = /* @__PURE__ */ new Map();
379
379
  for (const n of e ?? []) {
380
- const o = U(n.path);
381
- !o || t.has(o) || t.set(o, {
382
- id: De(o),
383
- name: o,
380
+ const r = U(n.path);
381
+ !r || t.has(r) || t.set(r, {
382
+ id: ke(r),
383
+ name: r,
384
384
  section: "Source routes",
385
- codeName: ((r = n.id) == null ? void 0 : r.trim()) || void 0
385
+ codeName: ((o = n.id) == null ? void 0 : o.trim()) || void 0
386
386
  });
387
387
  }
388
- return [...t.values()].sort((n, o) => n.id.localeCompare(o.id));
388
+ return [...t.values()].sort((n, r) => n.id.localeCompare(r.id));
389
389
  }
390
- function xt(e, t, r) {
391
- return (e ?? []).flatMap((n, o) => {
392
- var p, y, g;
393
- const i = (p = n.from) == null ? void 0 : p.trim(), s = (y = n.to) == null ? void 0 : y.trim();
390
+ function Et(e, t, o) {
391
+ return (e ?? []).flatMap((n, r) => {
392
+ var p, b, m;
393
+ const i = (p = n.from) == null ? void 0 : p.trim(), s = (b = n.to) == null ? void 0 : b.trim();
394
394
  if (!i || !s || n.unresolvedTarget) return [];
395
- const a = r.has(i) ? [i] : Ae(i, t), f = r.has(s) ? [s] : Ae(s, t);
396
- if (!a.length || !f.length) return [];
397
- const m = ((g = n.id) == null ? void 0 : g.trim()) || `discovery-edge:${o + 1}`;
395
+ const a = o.has(i) ? [i] : Ae(i, t), l = o.has(s) ? [s] : Ae(s, t);
396
+ if (!a.length || !l.length) return [];
397
+ const g = ((m = n.id) == null ? void 0 : m.trim()) || `discovery-edge:${r + 1}`;
398
398
  return a.flatMap(
399
- (v, w) => f.map((N, h) => {
399
+ (v, y) => l.map((R, h) => {
400
400
  var O, A;
401
401
  return {
402
- id: a.length === 1 && f.length === 1 ? m : `${m}:${w + 1}:${h + 1}`,
402
+ id: a.length === 1 && l.length === 1 ? g : `${g}:${y + 1}:${h + 1}`,
403
403
  from: v,
404
- to: N,
404
+ to: R,
405
405
  kind: ((O = n.kind) == null ? void 0 : O.trim()) || void 0,
406
406
  label: ((A = n.label) == null ? void 0 : A.trim()) || void 0
407
407
  };
@@ -409,34 +409,34 @@ function xt(e, t, r) {
409
409
  );
410
410
  });
411
411
  }
412
- function Pt(e, t, r) {
412
+ function Nt(e, t, o) {
413
413
  const n = U(e.route);
414
414
  if (!n) return [];
415
- const o = t.filter(
415
+ const r = t.filter(
416
416
  (a) => {
417
- const f = U(a.route);
418
- return f ? Ie(f, n) : !1;
417
+ const l = U(a.route);
418
+ return l ? Ie(l, n) : !1;
419
419
  }
420
420
  );
421
- if (!o.length) return [];
421
+ if (!r.length) return [];
422
422
  const i = Ce(
423
- Ke(r, e.environment)
424
- ), s = o.filter(
423
+ Ge(o, e.environment)
424
+ ), s = r.filter(
425
425
  (a) => Ce(a.environment) === i
426
426
  );
427
427
  return [
428
428
  ...new Set(
429
429
  s.map((a) => {
430
- var f;
431
- return (f = a.scenarioId) == null ? void 0 : f.trim();
430
+ var l;
431
+ return (l = a.scenarioId) == null ? void 0 : l.trim();
432
432
  }).filter((a) => !!a)
433
433
  )
434
- ].sort((a, f) => a.localeCompare(f));
434
+ ].sort((a, l) => a.localeCompare(l));
435
435
  }
436
- function Et(e, t) {
437
- const r = e.some((i) => i.importKind != null), n = t.candidates ?? [], o = _e(t);
436
+ function Rt(e, t) {
437
+ const o = e.some((i) => i.importKind != null), n = t.candidates ?? [], r = _e(t);
438
438
  return e.filter(
439
- (i) => r ? i.importKind === "screens" : !!i.route
439
+ (i) => o ? i.importKind === "screens" : !!i.route
440
440
  ).map((i) => ({
441
441
  id: i.id,
442
442
  name: i.name,
@@ -455,7 +455,7 @@ function Et(e, t) {
455
455
  scenario: i.scenario,
456
456
  state: i.state,
457
457
  scenarioId: i.scenarioId,
458
- scenarioIds: Pt(i, n, o),
458
+ scenarioIds: Nt(i, n, r),
459
459
  interactions: i.interactions,
460
460
  environment: i.environment,
461
461
  preset: i.preset,
@@ -464,32 +464,32 @@ function Et(e, t) {
464
464
  }));
465
465
  }
466
466
  function me(e, t) {
467
- var a, f, m, p;
468
- const r = (((a = e.interactions) == null ? void 0 : a.length) ?? 0) - (((f = t.interactions) == null ? void 0 : f.length) ?? 0);
469
- if (r !== 0) return r;
470
- const n = (m = e.scenarioIds) != null && m.includes("environment:baseline") ? 0 : 1, o = (p = t.scenarioIds) != null && p.includes("environment:baseline") ? 0 : 1;
471
- if (n !== o) return n - o;
467
+ var a, l, g, p;
468
+ const o = (((a = e.interactions) == null ? void 0 : a.length) ?? 0) - (((l = t.interactions) == null ? void 0 : l.length) ?? 0);
469
+ if (o !== 0) return o;
470
+ const n = (g = e.scenarioIds) != null && g.includes("environment:baseline") ? 0 : 1, r = (p = t.scenarioIds) != null && p.includes("environment:baseline") ? 0 : 1;
471
+ if (n !== r) return n - r;
472
472
  const i = !e.environment && !e.preset ? 0 : 1, s = !t.environment && !t.preset ? 0 : 1;
473
473
  return i !== s ? i - s : e.id.localeCompare(t.id);
474
474
  }
475
- function Nt(e) {
475
+ function Ct(e) {
476
476
  const t = /* @__PURE__ */ new Map();
477
- for (const r of e) {
478
- const n = U(r.route);
477
+ for (const o of e) {
478
+ const n = U(o.route);
479
479
  if (!n) continue;
480
- const o = t.get(n);
481
- o ? o.push(r) : t.set(n, [r]);
480
+ const r = t.get(n);
481
+ r ? r.push(o) : t.set(n, [o]);
482
482
  }
483
483
  return new Map(
484
- [...t.entries()].map(([r, n]) => {
485
- const o = [...n].sort(me);
486
- return [r, o[0].id];
484
+ [...t.entries()].map(([o, n]) => {
485
+ const r = [...n].sort(me);
486
+ return [o, r[0].id];
487
487
  })
488
488
  );
489
489
  }
490
- function Rt(e) {
490
+ function At(e) {
491
491
  return e.action === "wait" ? null : JSON.stringify(
492
- de({
492
+ fe({
493
493
  action: e.action,
494
494
  selector: e.selector,
495
495
  text: e.text,
@@ -504,23 +504,23 @@ function Rt(e) {
504
504
  );
505
505
  }
506
506
  function ze(e) {
507
- return (e.interactions ?? []).map(Rt).filter((t) => t != null);
507
+ return (e.interactions ?? []).map(At).filter((t) => t != null);
508
508
  }
509
- function Ct(e, t) {
510
- return e.length < t.length && e.every((r, n) => r === t[n]);
509
+ function Ot(e, t) {
510
+ return e.length < t.length && e.every((o, n) => o === t[n]);
511
511
  }
512
- function At(e, t) {
513
- const r = /* @__PURE__ */ new Map();
512
+ function $t(e, t) {
513
+ const o = /* @__PURE__ */ new Map();
514
514
  for (const n of e) {
515
- const o = U(n.route);
516
- if (!o) continue;
517
- const i = `${o}\0${ze(n).join("")}`, s = r.get(i);
518
- s ? s.push(n) : r.set(i, [n]);
515
+ const r = U(n.route);
516
+ if (!r) continue;
517
+ const i = `${r}\0${ze(n).join("")}`, s = o.get(i);
518
+ s ? s.push(n) : o.set(i, [n]);
519
519
  }
520
- return [...r.values()].flatMap((n) => {
520
+ return [...o.values()].flatMap((n) => {
521
521
  if (n.length < 2) return [];
522
- const o = U(n[0].route), i = t.get(o), s = n.find((a) => a.id === i) ?? [...n].sort(me)[0];
523
- return n.filter((a) => a.id !== s.id).sort((a, f) => a.id.localeCompare(f.id)).map((a) => ({
522
+ const r = U(n[0].route), i = t.get(r), s = n.find((a) => a.id === i) ?? [...n].sort(me)[0];
523
+ return n.filter((a) => a.id !== s.id).sort((a, l) => a.id.localeCompare(l.id)).map((a) => ({
524
524
  id: `discovery-variant:${encodeURIComponent(s.id)}:${encodeURIComponent(a.id)}`,
525
525
  from: s.id,
526
526
  to: a.id,
@@ -528,81 +528,81 @@ function At(e, t) {
528
528
  }));
529
529
  });
530
530
  }
531
- function Ot(e, t) {
532
- const r = /* @__PURE__ */ new Map();
531
+ function Mt(e, t) {
532
+ const o = /* @__PURE__ */ new Map();
533
533
  for (const n of e) {
534
- const o = U(n.route);
535
- if (!o) continue;
536
- const i = r.get(o);
537
- i ? i.push(n) : r.set(o, [n]);
534
+ const r = U(n.route);
535
+ if (!r) continue;
536
+ const i = o.get(r);
537
+ i ? i.push(n) : o.set(r, [n]);
538
538
  }
539
- return [...r.entries()].flatMap(([n, o]) => {
539
+ return [...o.entries()].flatMap(([n, r]) => {
540
540
  const i = new Map(
541
- o.map((f) => [f.id, ze(f)])
542
- ), s = t.get(n), a = o.find(
543
- (f) => f.id === s
541
+ r.map((l) => [l.id, ze(l)])
542
+ ), s = t.get(n), a = r.find(
543
+ (l) => l.id === s
544
544
  );
545
- return o.flatMap((f) => {
546
- const m = i.get(f.id);
547
- if (!m.length) return [];
548
- const y = o.filter(
549
- (g) => Ct(
550
- i.get(g.id),
551
- m
545
+ return r.flatMap((l) => {
546
+ const g = i.get(l.id);
547
+ if (!g.length) return [];
548
+ const b = r.filter(
549
+ (m) => Ot(
550
+ i.get(m.id),
551
+ g
552
552
  )
553
- ).sort((g, v) => {
554
- const w = i.get(v.id).length - i.get(g.id).length;
555
- if (w !== 0) return w;
556
- const N = g.flow && g.flow === f.flow ? 0 : 1, h = v.flow && v.flow === f.flow ? 0 : 1;
557
- if (N !== h) return N - h;
558
- const O = g.section && g.section === f.section ? 0 : 1, A = v.section && v.section === f.section ? 0 : 1;
553
+ ).sort((m, v) => {
554
+ const y = i.get(v.id).length - i.get(m.id).length;
555
+ if (y !== 0) return y;
556
+ const R = m.flow && m.flow === l.flow ? 0 : 1, h = v.flow && v.flow === l.flow ? 0 : 1;
557
+ if (R !== h) return R - h;
558
+ const O = m.section && m.section === l.section ? 0 : 1, A = v.section && v.section === l.section ? 0 : 1;
559
559
  if (O !== A) return O - A;
560
- const $ = g.id === s ? 0 : 1, T = v.id === s ? 0 : 1;
561
- return $ !== T ? $ - T : me(g, v);
560
+ const D = m.id === s ? 0 : 1, $ = v.id === s ? 0 : 1;
561
+ return D !== $ ? D - $ : me(m, v);
562
562
  })[0];
563
- return y ? [
563
+ return b ? [
564
564
  {
565
- id: `discovery-recipe:${encodeURIComponent(y.id)}:${encodeURIComponent(f.id)}`,
566
- from: y.id,
567
- to: f.id,
565
+ id: `discovery-recipe:${encodeURIComponent(b.id)}:${encodeURIComponent(l.id)}`,
566
+ from: b.id,
567
+ to: l.id,
568
568
  kind: "recipe-step"
569
569
  }
570
- ] : a && a.id !== f.id && i.get(a.id).join("") !== m.join("") ? [
570
+ ] : a && a.id !== l.id && i.get(a.id).join("") !== g.join("") ? [
571
571
  {
572
- id: `discovery-route-case:${encodeURIComponent(a.id)}:${encodeURIComponent(f.id)}`,
572
+ id: `discovery-route-case:${encodeURIComponent(a.id)}:${encodeURIComponent(l.id)}`,
573
573
  from: a.id,
574
- to: f.id,
574
+ to: l.id,
575
575
  kind: "route-case"
576
576
  }
577
577
  ] : [];
578
578
  });
579
579
  });
580
580
  }
581
- function $t(e) {
582
- var r;
581
+ function Tt(e) {
582
+ var o;
583
583
  const t = /* @__PURE__ */ new Map();
584
584
  for (const n of e) {
585
- const o = (r = n.flow) == null ? void 0 : r.trim();
586
- if (!o) continue;
587
- const i = t.get(o);
588
- i ? i.push(n) : t.set(o, [n]);
585
+ const r = (o = n.flow) == null ? void 0 : o.trim();
586
+ if (!r) continue;
587
+ const i = t.get(r);
588
+ i ? i.push(n) : t.set(r, [n]);
589
589
  }
590
590
  return [...t.values()].flatMap((n) => {
591
- const o = n[0], i = /* @__PURE__ */ new Map();
591
+ const r = n[0], i = /* @__PURE__ */ new Map();
592
592
  for (const s of n) {
593
593
  const a = U(s.route);
594
594
  if (!a) continue;
595
- const f = i.get(a);
596
- f ? f.push(s) : i.set(a, [s]);
595
+ const l = i.get(a);
596
+ l ? l.push(s) : i.set(a, [s]);
597
597
  }
598
598
  return i.size < 2 ? [] : [...i.values()].flatMap((s) => {
599
599
  const a = [...s].sort(
600
600
  me
601
601
  )[0];
602
- return a.id === o.id ? [] : [
602
+ return a.id === r.id ? [] : [
603
603
  {
604
- id: `discovery-flow-route:${encodeURIComponent(o.id)}:${encodeURIComponent(a.id)}`,
605
- from: o.id,
604
+ id: `discovery-flow-route:${encodeURIComponent(r.id)}:${encodeURIComponent(a.id)}`,
605
+ from: r.id,
606
606
  to: a.id,
607
607
  kind: "flow-route"
608
608
  }
@@ -610,137 +610,137 @@ function $t(e) {
610
610
  });
611
611
  });
612
612
  }
613
- function Mt(e, t, r) {
613
+ function Dt(e, t, o) {
614
614
  const n = new Set(
615
- (t.routes ?? []).map((o) => U(o.path)).filter((o) => !!o)
615
+ (t.routes ?? []).map((r) => U(r.path)).filter((r) => !!r)
616
616
  );
617
- return e.map((o) => {
618
- const i = U(o.route);
619
- if (!i || r.get(i) !== o.id)
620
- return o;
617
+ return e.map((r) => {
618
+ const i = U(r.route);
619
+ if (!i || o.get(i) !== r.id)
620
+ return r;
621
621
  const s = [...n].filter(
622
622
  (a) => Ie(a, i)
623
623
  );
624
624
  return s.length ? {
625
- ...o,
625
+ ...r,
626
626
  scenarioIds: [
627
627
  .../* @__PURE__ */ new Set([
628
- ...o.scenarioIds ?? [],
629
- ...s.map(De)
628
+ ...r.scenarioIds ?? [],
629
+ ...s.map(ke)
630
630
  ])
631
- ].sort((a, f) => a.localeCompare(f))
632
- } : o;
631
+ ].sort((a, l) => a.localeCompare(l))
632
+ } : r;
633
633
  });
634
634
  }
635
- function Tt(e, t) {
636
- var m, p, y, g, v;
637
- const r = new Set(e.map((w) => w.id)), n = new Map(
638
- e.map((w, N) => [w.id, N])
639
- ), o = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
640
- for (const w of r)
641
- o.set(w, /* @__PURE__ */ new Set()), i.set(w, /* @__PURE__ */ new Set()), s.set(w, /* @__PURE__ */ new Set());
642
- for (const w of t)
643
- !r.has(w.from) || !r.has(w.to) || ((m = o.get(w.to)) == null || m.add(w.from), (p = i.get(w.from)) == null || p.add(w.to), (y = s.get(w.from)) == null || y.add(w.to), (g = s.get(w.to)) == null || g.add(w.from));
644
- const a = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Set();
645
- for (const w of r) {
646
- if (f.has(w)) continue;
647
- const N = [], h = [w];
635
+ function kt(e, t) {
636
+ var g, p, b, m, v;
637
+ const o = new Set(e.map((y) => y.id)), n = new Map(
638
+ e.map((y, R) => [y.id, R])
639
+ ), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
640
+ for (const y of o)
641
+ r.set(y, /* @__PURE__ */ new Set()), i.set(y, /* @__PURE__ */ new Set()), s.set(y, /* @__PURE__ */ new Set());
642
+ for (const y of t)
643
+ !o.has(y.from) || !o.has(y.to) || ((g = r.get(y.to)) == null || g.add(y.from), (p = i.get(y.from)) == null || p.add(y.to), (b = s.get(y.from)) == null || b.add(y.to), (m = s.get(y.to)) == null || m.add(y.from));
644
+ const a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set();
645
+ for (const y of o) {
646
+ if (l.has(y)) continue;
647
+ const R = [], h = [y];
648
648
  for (; h.length; ) {
649
649
  const S = h.shift();
650
- if (!f.has(S)) {
651
- f.add(S), N.push(S);
652
- for (const P of s.get(S) ?? [])
653
- f.has(P) || h.push(P);
650
+ if (!l.has(S)) {
651
+ l.add(S), R.push(S);
652
+ for (const x of s.get(S) ?? [])
653
+ l.has(x) || h.push(x);
654
654
  }
655
655
  }
656
- if (N.length === 1 && (((v = s.get(N[0])) == null ? void 0 : v.size) ?? 0) === 0)
656
+ if (R.length === 1 && (((v = s.get(R[0])) == null ? void 0 : v.size) ?? 0) === 0)
657
657
  continue;
658
- const O = N.filter((S) => {
659
- var P;
660
- return (((P = o.get(S)) == null ? void 0 : P.size) ?? 0) === 0;
658
+ const O = R.filter((S) => {
659
+ var x;
660
+ return (((x = r.get(S)) == null ? void 0 : x.size) ?? 0) === 0;
661
661
  }).sort(
662
- (S, P) => (n.get(S) ?? Number.MAX_SAFE_INTEGER) - (n.get(P) ?? Number.MAX_SAFE_INTEGER) || S.localeCompare(P)
663
- ), A = [...N].sort(
664
- (S, P) => (n.get(S) ?? Number.MAX_SAFE_INTEGER) - (n.get(P) ?? Number.MAX_SAFE_INTEGER) || S.localeCompare(P)
662
+ (S, x) => (n.get(S) ?? Number.MAX_SAFE_INTEGER) - (n.get(x) ?? Number.MAX_SAFE_INTEGER) || S.localeCompare(x)
663
+ ), A = [...R].sort(
664
+ (S, x) => (n.get(S) ?? Number.MAX_SAFE_INTEGER) - (n.get(x) ?? Number.MAX_SAFE_INTEGER) || S.localeCompare(x)
665
665
  )[0];
666
666
  if (!A) continue;
667
- const $ = [A], T = /* @__PURE__ */ new Set(), k = (S) => {
668
- const P = [S];
669
- for (; P.length; ) {
670
- const D = P.shift();
671
- if (!T.has(D)) {
672
- T.add(D);
673
- for (const j of i.get(D) ?? [])
674
- T.has(j) || P.push(j);
667
+ const D = [A], $ = /* @__PURE__ */ new Set(), k = (S) => {
668
+ const x = [S];
669
+ for (; x.length; ) {
670
+ const T = x.shift();
671
+ if (!$.has(T)) {
672
+ $.add(T);
673
+ for (const j of i.get(T) ?? [])
674
+ $.has(j) || x.push(j);
675
675
  }
676
676
  }
677
677
  };
678
678
  k(A);
679
679
  for (const S of O)
680
- T.has(S) || ($.push(S), k(S));
681
- for (const S of $)
680
+ $.has(S) || (D.push(S), k(S));
681
+ for (const S of D)
682
682
  a.add(S);
683
683
  }
684
684
  return [...a].sort(
685
- (w, N) => (n.get(w) ?? Number.MAX_SAFE_INTEGER) - (n.get(N) ?? Number.MAX_SAFE_INTEGER) || w.localeCompare(N)
685
+ (y, R) => (n.get(y) ?? Number.MAX_SAFE_INTEGER) - (n.get(R) ?? Number.MAX_SAFE_INTEGER) || y.localeCompare(R)
686
686
  );
687
687
  }
688
688
  function _e(e) {
689
- var t, r;
690
- return St(
691
- (r = (t = e.scenarios) == null ? void 0 : t.find(
689
+ var t, o;
690
+ return It(
691
+ (o = (t = e.scenarios) == null ? void 0 : t.find(
692
692
  (n) => n.id === "environment:baseline"
693
- )) == null ? void 0 : r.environment
693
+ )) == null ? void 0 : o.environment
694
694
  );
695
695
  }
696
- function kt(e) {
697
- const t = Et(
696
+ function zt(e) {
697
+ const t = Rt(
698
698
  e.pages,
699
699
  e.manifest
700
- ), r = Nt(t), n = Mt(
700
+ ), o = Ct(t), n = Dt(
701
701
  t,
702
702
  e.manifest,
703
- r
703
+ o
704
704
  ), i = [
705
- ...xt(
705
+ ...Et(
706
706
  e.manifest.edges,
707
- r,
707
+ o,
708
708
  new Set(n.map((s) => s.id))
709
709
  ),
710
- ...At(n, r),
711
- ...Ot(n, r),
712
- ...$t(n)
710
+ ...$t(n, o),
711
+ ...Mt(n, o),
712
+ ...Tt(n)
713
713
  ];
714
- return bt({
714
+ return vt({
715
715
  screens: n,
716
716
  assets: e.assets,
717
- scenarios: It(e.manifest.routes),
717
+ scenarios: Pt(e.manifest.routes),
718
718
  inferredEdges: i,
719
- startScreenIds: Tt(n, i)
719
+ startScreenIds: kt(n, i)
720
720
  });
721
721
  }
722
722
  async function Fe(e) {
723
- const r = await (e.fetcher ?? ((o, i) => fetch(o, i)))(e.endpoint, {
723
+ const o = await (e.fetcher ?? ((r, i) => fetch(r, i)))(e.endpoint, {
724
724
  headers: { accept: "application/json" },
725
725
  cache: "no-store",
726
726
  signal: e.signal
727
727
  });
728
- if (!r.ok)
729
- throw new Error(`Storyboard discovery failed (${r.status})`);
730
- const n = await r.json();
731
- if (!vt(n))
728
+ if (!o.ok)
729
+ throw new Error(`Storyboard discovery failed (${o.status})`);
730
+ const n = await o.json();
731
+ if (!xt(n))
732
732
  throw new Error("Storyboard discovery returned an invalid manifest.");
733
733
  return {
734
734
  manifest: n,
735
735
  baselineEnvironment: _e(n),
736
- graph: kt({
736
+ graph: zt({
737
737
  manifest: n,
738
738
  pages: e.pages,
739
739
  assets: e.assets
740
740
  })
741
741
  };
742
742
  }
743
- async function yn(e) {
743
+ async function bn(e) {
744
744
  Q(null);
745
745
  try {
746
746
  const t = await Fe(e);
@@ -749,18 +749,18 @@ async function yn(e) {
749
749
  throw Q(null), t;
750
750
  }
751
751
  }
752
- const Dt = "pygmalion-preview", zt = "unknown", _t = 512, Ft = 2048, jt = 8 * 1024 * 1024, Bt = 128 * 1024 * 1024, Ut = /* @__PURE__ */ new Set([
752
+ const _t = "pygmalion-preview", Ft = "unknown", jt = 512, Bt = 2048, Ut = 8 * 1024 * 1024, Ht = 128 * 1024 * 1024, Kt = /* @__PURE__ */ new Set([
753
753
  "__proto__",
754
754
  "constructor",
755
755
  "prototype"
756
756
  ]);
757
- function X(e, t) {
758
- const r = e.trim();
759
- if (!r && t != null) return t;
760
- if (ce(r)) return r;
757
+ function J(e, t) {
758
+ const o = e.trim();
759
+ if (!o && t != null) return t;
760
+ if (le(o)) return o;
761
761
  throw new TypeError("Preview identity must be a non-empty bounded string.");
762
762
  }
763
- function Ht(e) {
763
+ function Gt(e) {
764
764
  const t = e ?? 1;
765
765
  if (!Number.isSafeInteger(t) || t < 1)
766
766
  throw new TypeError(
@@ -777,51 +777,60 @@ function be(e, t = /* @__PURE__ */ new Set()) {
777
777
  "Preview recipe identity cannot contain circular values."
778
778
  );
779
779
  if (t.add(e), Array.isArray(e)) {
780
- const n = e.map((o) => be(o, t));
780
+ const n = e.map((r) => be(r, t));
781
781
  return t.delete(e), n;
782
782
  }
783
- const r = {};
783
+ const o = {};
784
784
  for (const n of Object.keys(e).sort()) {
785
- const o = e[n];
786
- o !== void 0 && (r[n] = be(o, t));
785
+ const r = e[n];
786
+ r !== void 0 && (o[n] = be(r, t));
787
787
  }
788
- return t.delete(e), r;
788
+ return t.delete(e), o;
789
789
  }
790
- function Kt(e) {
791
- let t = 2166136261, r = 2654435769;
790
+ function Vt(e) {
791
+ let t = 2166136261, o = 2654435769;
792
792
  for (let n = 0; n < e.length; n += 1) {
793
- const o = e.charCodeAt(n);
794
- t = Math.imul(t ^ o, 16777619), r = Math.imul(r ^ o + n, 2246822507);
793
+ const r = e.charCodeAt(n);
794
+ t = Math.imul(t ^ r, 16777619), o = Math.imul(o ^ r + n, 2246822507);
795
795
  }
796
- return `${(t >>> 0).toString(16).padStart(8, "0")}${(r >>> 0).toString(16).padStart(8, "0")}`;
796
+ return `${(t >>> 0).toString(16).padStart(8, "0")}${(o >>> 0).toString(16).padStart(8, "0")}`;
797
797
  }
798
- function qt(e) {
798
+ function je(e) {
799
799
  if (!Array.isArray(e))
800
800
  throw new TypeError("Preview recipes must be an array.");
801
- const t = /* @__PURE__ */ new Set(), r = e.map(({ id: n, recipe: o }) => {
802
- const i = X(n);
801
+ const t = /* @__PURE__ */ new Set(), o = e.map(({ id: n, recipe: r }) => {
802
+ const i = J(n);
803
803
  if (t.has(i))
804
804
  throw new TypeError(`Duplicate preview recipe identity: ${i}`);
805
805
  return t.add(i), {
806
806
  id: i,
807
- recipe: be(o)
807
+ recipe: be(r)
808
808
  };
809
809
  });
810
- return Kt(JSON.stringify(r));
810
+ return Vt(JSON.stringify(o));
811
811
  }
812
- function wn({
812
+ function Sn(e, t = {}) {
813
+ const o = qt(e), n = t.dependencyDigest;
814
+ return je([
815
+ {
816
+ id: J(e.id ?? "", "frame"),
817
+ recipe: n == null ? o : { recipe: o, dependencyDigest: J(n) }
818
+ }
819
+ ]);
820
+ }
821
+ function vn({
813
822
  sourceRevision: e,
814
823
  recipes: t,
815
- recipeVersion: r,
816
- scope: n = Dt
824
+ recipeVersion: o,
825
+ scope: n = _t
817
826
  }) {
818
- const o = X(n), i = X(
827
+ const r = J(n), i = J(
819
828
  e,
820
- zt
821
- ), s = Ht(r), a = qt(t);
822
- return `${o}:${encodeURIComponent(i)}:recipe-v${s}:${a}`;
829
+ Ft
830
+ ), s = Gt(o), a = je(t);
831
+ return `${r}:${encodeURIComponent(i)}:recipe-v${s}:${a}`;
823
832
  }
824
- function bn(e) {
833
+ function qt(e) {
825
834
  return {
826
835
  route: e.route,
827
836
  path: e.path,
@@ -848,25 +857,27 @@ function bn(e) {
848
857
  assertions: e.assertions
849
858
  };
850
859
  }
851
- function Gt({
860
+ function Jt({
852
861
  endpoint: e,
853
862
  fetcher: t,
854
- captureBaseUrl: r
863
+ captureBaseUrl: o
855
864
  }) {
856
865
  const n = e.trim();
857
866
  if (!n)
858
867
  throw new TypeError(
859
868
  "Preview artifact endpoint must be a non-empty string."
860
869
  );
861
- const o = t ?? ((i, s) => fetch(i, s));
870
+ const r = t ?? ((i, s) => fetch(i, s));
862
871
  return async (i) => {
863
872
  const s = new URLSearchParams({
864
873
  namespace: i.namespace,
865
874
  sourceRevision: i.sourceRevision
866
- }), a = i.captureBaseUrl ?? r;
875
+ });
876
+ i.frames && s.set("frames", JSON.stringify(i.frames));
877
+ const a = i.captureBaseUrl ?? o;
867
878
  a && s.set("captureBaseUrl", a);
868
- const f = n.includes("?") ? "&" : "?", m = await o(
869
- `${n}${f}${s}`,
879
+ const l = n.includes("?") ? "&" : "?", g = await r(
880
+ `${n}${l}${s}`,
870
881
  {
871
882
  method: "GET",
872
883
  headers: { accept: "application/json" },
@@ -874,38 +885,40 @@ function Gt({
874
885
  signal: i.signal
875
886
  }
876
887
  );
877
- return m.ok ? m.json().catch(() => null) : null;
888
+ if (!g.ok) return null;
889
+ const p = await g.json().catch(() => null);
890
+ return se(p) && p.artifact !== void 0 ? p.artifact : p;
878
891
  };
879
892
  }
880
- function fe(e) {
893
+ function se(e) {
881
894
  if (!e || typeof e != "object" || Array.isArray(e)) return !1;
882
895
  const t = Object.getPrototypeOf(e);
883
896
  return t === Object.prototype || t === null;
884
897
  }
885
- function je(e) {
898
+ function Be(e) {
886
899
  return new TextEncoder().encode(e).byteLength;
887
900
  }
888
- function ce(e) {
889
- return typeof e == "string" && e.length > 0 && e.length <= _t && e === e.trim() && !Ut.has(e);
901
+ function le(e) {
902
+ return typeof e == "string" && e.length > 0 && e.length <= jt && e === e.trim() && !Kt.has(e);
890
903
  }
891
- function Jt(e) {
904
+ function Lt(e) {
892
905
  const t = /(?:expression\s*\(|-moz-binding\s*:|(?:^|[;{])\s*behavior\s*:)/i;
893
- for (const r of e.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style\s*>/gi))
894
- if (t.test(r[1] ?? "")) return !0;
895
- for (const r of e.matchAll(
906
+ for (const o of e.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style\s*>/gi))
907
+ if (t.test(o[1] ?? "")) return !0;
908
+ for (const o of e.matchAll(
896
909
  /\sstyle\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/gi
897
910
  ))
898
- if (t.test(r[1] ?? r[2] ?? r[3] ?? "")) return !0;
911
+ if (t.test(o[1] ?? o[2] ?? o[3] ?? "")) return !0;
899
912
  return !1;
900
913
  }
901
- function Lt(e) {
902
- return typeof e != "string" || e.length === 0 || je(e) > jt ? !1 : !(/<\s*(?:script|iframe|object|embed|applet|portal)\b/i.test(e) || /<\s*meta\b[^>]*http-equiv\s*=\s*["']?\s*refresh\b/i.test(e) || /\s(?:on[a-z][\w:-]*|srcdoc)\s*=/i.test(e) || /\s(?:href|src|action|formaction|xlink:href)\s*=\s*(?:"\s*|'?\s*)(?:javascript|vbscript|data\s*:\s*text\/html)\s*:/i.test(
914
+ function Wt(e) {
915
+ return typeof e != "string" || e.length === 0 || Be(e) > Ut ? !1 : !(/<\s*(?:script|iframe|object|embed|applet|portal)\b/i.test(e) || /<\s*meta\b[^>]*http-equiv\s*=\s*["']?\s*refresh\b/i.test(e) || /\s(?:on[a-z][\w:-]*|srcdoc)\s*=/i.test(e) || /\s(?:href|src|action|formaction|xlink:href)\s*=\s*(?:"\s*|'?\s*)(?:javascript|vbscript|data\s*:\s*text\/html)\s*:/i.test(
903
916
  e
904
- ) || Jt(e));
917
+ ) || Lt(e));
905
918
  }
906
- function Vt(e) {
919
+ function Qt(e) {
907
920
  const t = [];
908
- if (!fe(e) || e.version !== 1)
921
+ if (!se(e) || e.version !== 1)
909
922
  return {
910
923
  valid: !1,
911
924
  artifact: null,
@@ -913,16 +926,16 @@ function Vt(e) {
913
926
  "Preview artifact must be a version 1, version 2, or version 3 bundle."
914
927
  ]
915
928
  };
916
- if (ce(e.namespace) || t.push("Preview artifact namespace is invalid."), e.sourceRevision != null && !ce(e.sourceRevision) && t.push("Preview artifact source revision is invalid."), !fe(e.snapshots))
929
+ if (le(e.namespace) || t.push("Preview artifact namespace is invalid."), e.sourceRevision != null && !le(e.sourceRevision) && t.push("Preview artifact source revision is invalid."), !se(e.snapshots))
917
930
  t.push("Preview artifact snapshots must be a record.");
918
931
  else {
919
- const r = Object.entries(e.snapshots);
920
- r.length > Ft && t.push("Preview artifact has too many frames.");
921
- for (const [n, o] of r)
922
- (!ce(n) || !Lt(o)) && t.push(`Preview artifact frame "${n}" is invalid.`);
932
+ const o = Object.entries(e.snapshots);
933
+ o.length > Bt && t.push("Preview artifact has too many frames.");
934
+ for (const [n, r] of o)
935
+ (!le(n) || !Wt(r)) && t.push(`Preview artifact frame "${n}" is invalid.`);
923
936
  }
924
937
  try {
925
- je(JSON.stringify(e)) > Bt && t.push("Preview artifact exceeds the bundle byte limit.");
938
+ Be(JSON.stringify(e)) > Ht && t.push("Preview artifact exceeds the bundle byte limit.");
926
939
  } catch {
927
940
  t.push("Preview artifact is not serializable.");
928
941
  }
@@ -932,35 +945,35 @@ function Vt(e) {
932
945
  errors: t
933
946
  };
934
947
  }
935
- function Wt(e, t) {
936
- const r = fe(e) && e.version === 3 ? (() => {
937
- const n = qe(e);
948
+ function Xt(e, t) {
949
+ const o = se(e) && e.version === 3 ? (() => {
950
+ const n = Ve(e);
938
951
  return {
939
952
  valid: n.valid,
940
953
  artifact: n.valid ? e : null,
941
954
  errors: n.errors
942
955
  };
943
- })() : fe(e) && e.version === 2 ? (() => {
944
- const n = Ge(e);
956
+ })() : se(e) && e.version === 2 ? (() => {
957
+ const n = qe(e);
945
958
  return {
946
959
  valid: n.valid,
947
960
  artifact: n.valid ? e : null,
948
961
  errors: n.errors
949
962
  };
950
- })() : Vt(e);
951
- return !r.valid || !r.artifact ? {
963
+ })() : Qt(e);
964
+ return !o.valid || !o.artifact ? {
952
965
  valid: !1,
953
966
  artifact: null,
954
967
  reason: "invalid-bundle",
955
- errors: r.errors
956
- } : t && r.artifact.namespace !== X(t.namespace) ? {
968
+ errors: o.errors
969
+ } : t && o.artifact.namespace !== J(t.namespace) ? {
957
970
  valid: !1,
958
971
  artifact: null,
959
972
  reason: "namespace-mismatch",
960
973
  errors: [
961
974
  "Preview artifact namespace does not match the runtime namespace."
962
975
  ]
963
- } : t && r.artifact.sourceRevision !== X(t.sourceRevision) ? {
976
+ } : t && o.artifact.sourceRevision !== J(t.sourceRevision) ? {
964
977
  valid: !1,
965
978
  artifact: null,
966
979
  reason: "revision-mismatch",
@@ -969,30 +982,30 @@ function Wt(e, t) {
969
982
  ]
970
983
  } : {
971
984
  valid: !0,
972
- artifact: r.artifact,
985
+ artifact: o.artifact,
973
986
  errors: []
974
987
  };
975
988
  }
976
- async function Qt({
989
+ async function Yt({
977
990
  namespace: e,
978
991
  sourceRevision: t,
979
- transport: r,
992
+ transport: o,
980
993
  signal: n
981
994
  }) {
982
- const o = {
983
- namespace: X(e),
984
- sourceRevision: X(t)
995
+ const r = {
996
+ namespace: J(e),
997
+ sourceRevision: J(t)
985
998
  };
986
999
  let i;
987
1000
  try {
988
- i = await r({ ...o, signal: n });
1001
+ i = await o({ ...r, signal: n });
989
1002
  } catch (a) {
990
1003
  if (n != null && n.aborted) throw a;
991
1004
  return { status: "unavailable", artifact: null, error: a };
992
1005
  }
993
1006
  if (i == null)
994
1007
  return { status: "unavailable", artifact: null };
995
- const s = Wt(i, o);
1008
+ const s = Xt(i, r);
996
1009
  return s.valid ? { status: "accepted", artifact: s.artifact } : {
997
1010
  status: "rejected",
998
1011
  artifact: null,
@@ -1000,20 +1013,20 @@ async function Qt({
1000
1013
  errors: s.errors
1001
1014
  };
1002
1015
  }
1003
- const ue = "var(--pygmalion-catalog-surface, #ffffff)", pe = "var(--pygmalion-catalog-canvas, #f5f5f5)", Se = "var(--pygmalion-catalog-border, #e5e7eb)", he = "var(--pygmalion-catalog-text, #202124)", F = "var(--pygmalion-catalog-muted, #6b7280)", Xt = "var(--pygmalion-catalog-header, #11182f)", Yt = "var(--pygmalion-catalog-accent, #7c6cf2)";
1004
- function Sn({
1016
+ const ue = "var(--pygmalion-catalog-surface, #ffffff)", pe = "var(--pygmalion-catalog-canvas, #f5f5f5)", Se = "var(--pygmalion-catalog-border, #e5e7eb)", he = "var(--pygmalion-catalog-text, #202124)", F = "var(--pygmalion-catalog-muted, #6b7280)", Zt = "var(--pygmalion-catalog-header, #11182f)", en = "var(--pygmalion-catalog-accent, #7c6cf2)";
1017
+ function In({
1005
1018
  title: e,
1006
1019
  eyebrow: t,
1007
- description: r,
1020
+ description: o,
1008
1021
  version: n,
1009
- meta: o,
1022
+ meta: r,
1010
1023
  children: i,
1011
- headerBackground: s = Xt,
1024
+ headerBackground: s = Zt,
1012
1025
  headerColor: a = "#ffffff",
1013
- bodyBackground: f = ue,
1014
- bodyGap: m = 40
1026
+ bodyBackground: l = ue,
1027
+ bodyGap: g = 40
1015
1028
  }) {
1016
- return /* @__PURE__ */ R(
1029
+ return /* @__PURE__ */ N(
1017
1030
  "section",
1018
1031
  {
1019
1032
  "data-pygmalion-catalog-document": "",
@@ -1026,11 +1039,11 @@ function Sn({
1026
1039
  flexDirection: "column",
1027
1040
  overflow: "visible",
1028
1041
  color: he,
1029
- background: f,
1042
+ background: l,
1030
1043
  fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif"
1031
1044
  },
1032
1045
  children: [
1033
- /* @__PURE__ */ R(
1046
+ /* @__PURE__ */ N(
1034
1047
  "header",
1035
1048
  {
1036
1049
  style: {
@@ -1044,8 +1057,8 @@ function Sn({
1044
1057
  background: s
1045
1058
  },
1046
1059
  children: [
1047
- /* @__PURE__ */ R("div", { style: { display: "flex", flexDirection: "column", gap: 10 }, children: [
1048
- t ? /* @__PURE__ */ b(
1060
+ /* @__PURE__ */ N("div", { style: { display: "flex", flexDirection: "column", gap: 10 }, children: [
1061
+ t ? /* @__PURE__ */ w(
1049
1062
  "div",
1050
1063
  {
1051
1064
  style: {
@@ -1058,7 +1071,7 @@ function Sn({
1058
1071
  children: t
1059
1072
  }
1060
1073
  ) : null,
1061
- /* @__PURE__ */ b(
1074
+ /* @__PURE__ */ w(
1062
1075
  "h1",
1063
1076
  {
1064
1077
  style: {
@@ -1072,7 +1085,7 @@ function Sn({
1072
1085
  children: e
1073
1086
  }
1074
1087
  ),
1075
- r ? /* @__PURE__ */ b(
1088
+ o ? /* @__PURE__ */ w(
1076
1089
  "div",
1077
1090
  {
1078
1091
  style: {
@@ -1081,11 +1094,11 @@ function Sn({
1081
1094
  fontSize: 13,
1082
1095
  lineHeight: 1.55
1083
1096
  },
1084
- children: r
1097
+ children: o
1085
1098
  }
1086
1099
  ) : null
1087
1100
  ] }),
1088
- n || o ? /* @__PURE__ */ R(
1101
+ n || r ? /* @__PURE__ */ N(
1089
1102
  "div",
1090
1103
  {
1091
1104
  style: {
@@ -1097,15 +1110,15 @@ function Sn({
1097
1110
  whiteSpace: "nowrap"
1098
1111
  },
1099
1112
  children: [
1100
- n ? /* @__PURE__ */ b("span", { children: n }) : null,
1101
- o ? /* @__PURE__ */ b("span", { children: o }) : null
1113
+ n ? /* @__PURE__ */ w("span", { children: n }) : null,
1114
+ r ? /* @__PURE__ */ w("span", { children: r }) : null
1102
1115
  ]
1103
1116
  }
1104
1117
  ) : null
1105
1118
  ]
1106
1119
  }
1107
1120
  ),
1108
- /* @__PURE__ */ b(
1121
+ /* @__PURE__ */ w(
1109
1122
  "div",
1110
1123
  {
1111
1124
  "data-pygmalion-catalog-document-body": "",
@@ -1114,9 +1127,9 @@ function Sn({
1114
1127
  display: "inline-flex",
1115
1128
  flexDirection: "column",
1116
1129
  alignItems: "flex-start",
1117
- gap: m,
1130
+ gap: g,
1118
1131
  padding: 48,
1119
- background: f
1132
+ background: l
1120
1133
  },
1121
1134
  children: i
1122
1135
  }
@@ -1125,14 +1138,14 @@ function Sn({
1125
1138
  }
1126
1139
  );
1127
1140
  }
1128
- function vn({
1141
+ function xn({
1129
1142
  title: e,
1130
1143
  count: t,
1131
- description: r,
1144
+ description: o,
1132
1145
  children: n,
1133
- tone: o = "tinted"
1146
+ tone: r = "tinted"
1134
1147
  }) {
1135
- return /* @__PURE__ */ R(
1148
+ return /* @__PURE__ */ N(
1136
1149
  "section",
1137
1150
  {
1138
1151
  "data-pygmalion-catalog-section": "",
@@ -1143,12 +1156,12 @@ function vn({
1143
1156
  flexDirection: "column",
1144
1157
  alignItems: "flex-start",
1145
1158
  gap: 18,
1146
- padding: o === "tinted" ? 24 : 0,
1147
- background: o === "tinted" ? pe : "transparent"
1159
+ padding: r === "tinted" ? 24 : 0,
1160
+ background: r === "tinted" ? pe : "transparent"
1148
1161
  },
1149
1162
  children: [
1150
- /* @__PURE__ */ R("header", { style: { display: "flex", alignItems: "baseline", gap: 8 }, children: [
1151
- /* @__PURE__ */ b(
1163
+ /* @__PURE__ */ N("header", { style: { display: "flex", alignItems: "baseline", gap: 8 }, children: [
1164
+ /* @__PURE__ */ w(
1152
1165
  "h2",
1153
1166
  {
1154
1167
  style: {
@@ -1160,25 +1173,25 @@ function vn({
1160
1173
  children: e
1161
1174
  }
1162
1175
  ),
1163
- typeof t == "number" ? /* @__PURE__ */ b("span", { style: { color: F, fontSize: 11 }, children: t }) : null
1176
+ typeof t == "number" ? /* @__PURE__ */ w("span", { style: { color: F, fontSize: 11 }, children: t }) : null
1164
1177
  ] }),
1165
- r ? /* @__PURE__ */ b("div", { style: { marginTop: -10, color: F, fontSize: 11 }, children: r }) : null,
1178
+ o ? /* @__PURE__ */ w("div", { style: { marginTop: -10, color: F, fontSize: 11 }, children: o }) : null,
1166
1179
  n
1167
1180
  ]
1168
1181
  }
1169
1182
  );
1170
1183
  }
1171
- function In({
1184
+ function Pn({
1172
1185
  rows: e,
1173
1186
  columns: t,
1174
- cornerLabel: r,
1187
+ cornerLabel: o,
1175
1188
  renderCell: n,
1176
- renderRowLabel: o = (f) => f,
1177
- renderColumnLabel: i = (f) => f,
1189
+ renderRowLabel: r = (l) => l,
1190
+ renderColumnLabel: i = (l) => l,
1178
1191
  boundary: s = !0,
1179
1192
  cellStyle: a
1180
1193
  }) {
1181
- return /* @__PURE__ */ b(
1194
+ return /* @__PURE__ */ w(
1182
1195
  "div",
1183
1196
  {
1184
1197
  "data-pygmalion-catalog-matrix": "",
@@ -1187,10 +1200,10 @@ function In({
1187
1200
  display: "inline-block",
1188
1201
  width: "max-content",
1189
1202
  padding: s ? 16 : 0,
1190
- border: s ? `1px dashed ${Yt}` : void 0,
1203
+ border: s ? `1px dashed ${en}` : void 0,
1191
1204
  borderRadius: s ? 4 : void 0
1192
1205
  },
1193
- children: /* @__PURE__ */ R(
1206
+ children: /* @__PURE__ */ N(
1194
1207
  "table",
1195
1208
  {
1196
1209
  style: {
@@ -1199,8 +1212,8 @@ function In({
1199
1212
  borderSpacing: 0
1200
1213
  },
1201
1214
  children: [
1202
- /* @__PURE__ */ b("thead", { children: /* @__PURE__ */ R("tr", { children: [
1203
- /* @__PURE__ */ b(
1215
+ /* @__PURE__ */ w("thead", { children: /* @__PURE__ */ N("tr", { children: [
1216
+ /* @__PURE__ */ w(
1204
1217
  "th",
1205
1218
  {
1206
1219
  style: {
@@ -1211,10 +1224,10 @@ function In({
1211
1224
  textAlign: "left",
1212
1225
  whiteSpace: "nowrap"
1213
1226
  },
1214
- children: r
1227
+ children: o
1215
1228
  }
1216
1229
  ),
1217
- t.map((f) => /* @__PURE__ */ b(
1230
+ t.map((l) => /* @__PURE__ */ w(
1218
1231
  "th",
1219
1232
  {
1220
1233
  style: {
@@ -1225,13 +1238,13 @@ function In({
1225
1238
  textAlign: "center",
1226
1239
  whiteSpace: "nowrap"
1227
1240
  },
1228
- children: i(f)
1241
+ children: i(l)
1229
1242
  },
1230
- f
1243
+ l
1231
1244
  ))
1232
1245
  ] }) }),
1233
- /* @__PURE__ */ b("tbody", { children: e.map((f) => /* @__PURE__ */ R("tr", { children: [
1234
- /* @__PURE__ */ b(
1246
+ /* @__PURE__ */ w("tbody", { children: e.map((l) => /* @__PURE__ */ N("tr", { children: [
1247
+ /* @__PURE__ */ w(
1235
1248
  "th",
1236
1249
  {
1237
1250
  style: {
@@ -1242,10 +1255,10 @@ function In({
1242
1255
  textAlign: "left",
1243
1256
  whiteSpace: "nowrap"
1244
1257
  },
1245
- children: o(f)
1258
+ children: r(l)
1246
1259
  }
1247
1260
  ),
1248
- t.map((m) => /* @__PURE__ */ b(
1261
+ t.map((g) => /* @__PURE__ */ w(
1249
1262
  "td",
1250
1263
  {
1251
1264
  style: {
@@ -1254,25 +1267,25 @@ function In({
1254
1267
  verticalAlign: "middle",
1255
1268
  ...a
1256
1269
  },
1257
- children: n(f, m)
1270
+ children: n(l, g)
1258
1271
  },
1259
- m
1272
+ g
1260
1273
  ))
1261
- ] }, f)) })
1274
+ ] }, l)) })
1262
1275
  ]
1263
1276
  }
1264
1277
  )
1265
1278
  }
1266
1279
  );
1267
1280
  }
1268
- function Zt(e) {
1281
+ function tn(e) {
1269
1282
  return e.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").replace(/[^\p{L}\p{N}]+/gu, "-").replace(/^-+|-+$/g, "").toLowerCase() || "page";
1270
1283
  }
1271
- function Be(e, t, r = "PygmalionCatalog") {
1272
- const n = (o) => Zt(o).replace(/-/g, "_");
1273
- return `${r}_${n(e)}_${n(t)}`;
1284
+ function Ue(e, t, o = "PygmalionCatalog") {
1285
+ const n = (r) => tn(r).replace(/-/g, "_");
1286
+ return `${o}_${n(e)}_${n(t)}`;
1274
1287
  }
1275
- function Ue(e, t) {
1288
+ function He(e, t) {
1276
1289
  return {
1277
1290
  id: e.id,
1278
1291
  name: e.name,
@@ -1283,25 +1296,25 @@ function Ue(e, t) {
1283
1296
  description: e.description
1284
1297
  };
1285
1298
  }
1286
- function He(e) {
1299
+ function Ke(e) {
1287
1300
  const t = /* @__PURE__ */ new Set();
1288
- for (const r of e) {
1289
- if (t.has(r.id))
1290
- throw new Error(`Duplicate design catalog item id: ${r.id}`);
1291
- t.add(r.id);
1301
+ for (const o of e) {
1302
+ if (t.has(o.id))
1303
+ throw new Error(`Duplicate design catalog item id: ${o.id}`);
1304
+ t.add(o.id);
1292
1305
  }
1293
1306
  }
1294
- function en(e, t, r) {
1295
- return typeof e == "function" ? e(t, r) : e;
1307
+ function nn(e, t, o) {
1308
+ return typeof e == "function" ? e(t, o) : e;
1296
1309
  }
1297
- function tn({
1310
+ function rn({
1298
1311
  page: e,
1299
1312
  items: t,
1300
- renderPreview: r,
1313
+ renderPreview: o,
1301
1314
  secondaryLabel: n,
1302
- minimumColumnWidth: o
1315
+ minimumColumnWidth: r
1303
1316
  }) {
1304
- return /* @__PURE__ */ R(
1317
+ return /* @__PURE__ */ N(
1305
1318
  "section",
1306
1319
  {
1307
1320
  "data-pygmalion-catalog-page": e.id,
@@ -1316,14 +1329,14 @@ function tn({
1316
1329
  fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif"
1317
1330
  },
1318
1331
  children: [
1319
- /* @__PURE__ */ R("header", { style: { marginBottom: 24 }, children: [
1320
- /* @__PURE__ */ b("h1", { style: { margin: 0, fontSize: 24, lineHeight: 1.35 }, children: e.name }),
1321
- /* @__PURE__ */ R("p", { style: { margin: "6px 0 0", color: F, fontSize: 13 }, children: [
1332
+ /* @__PURE__ */ N("header", { style: { marginBottom: 24 }, children: [
1333
+ /* @__PURE__ */ w("h1", { style: { margin: 0, fontSize: 24, lineHeight: 1.35 }, children: e.name }),
1334
+ /* @__PURE__ */ N("p", { style: { margin: "6px 0 0", color: F, fontSize: 13 }, children: [
1322
1335
  t.length,
1323
1336
  " assets"
1324
1337
  ] })
1325
1338
  ] }),
1326
- /* @__PURE__ */ b(
1339
+ /* @__PURE__ */ w(
1327
1340
  "div",
1328
1341
  {
1329
1342
  style: {
@@ -1331,20 +1344,20 @@ function tn({
1331
1344
  gridTemplateColumns: "repeat(6, max-content)",
1332
1345
  gap: 16
1333
1346
  },
1334
- children: t.map((i) => /* @__PURE__ */ R(
1347
+ children: t.map((i) => /* @__PURE__ */ N(
1335
1348
  "article",
1336
1349
  {
1337
1350
  "data-pygmalion-catalog-item": i.id,
1338
1351
  style: {
1339
- minWidth: o,
1340
- width: o,
1352
+ minWidth: r,
1353
+ width: r,
1341
1354
  padding: 16,
1342
1355
  border: `1px solid ${Se}`,
1343
1356
  borderRadius: 12,
1344
1357
  background: ue
1345
1358
  },
1346
1359
  children: [
1347
- /* @__PURE__ */ b(
1360
+ /* @__PURE__ */ w(
1348
1361
  "div",
1349
1362
  {
1350
1363
  style: {
@@ -1354,10 +1367,10 @@ function tn({
1354
1367
  justifyContent: "center",
1355
1368
  overflow: "hidden"
1356
1369
  },
1357
- children: r(i)
1370
+ children: o(i)
1358
1371
  }
1359
1372
  ),
1360
- /* @__PURE__ */ b(
1373
+ /* @__PURE__ */ w(
1361
1374
  "div",
1362
1375
  {
1363
1376
  style: {
@@ -1372,7 +1385,7 @@ function tn({
1372
1385
  children: i.name
1373
1386
  }
1374
1387
  ),
1375
- n ? /* @__PURE__ */ b("div", { style: { marginTop: 4, color: F, fontSize: 11, lineHeight: 1.45 }, children: n(i) }) : i.codeName ? /* @__PURE__ */ b(
1388
+ n ? /* @__PURE__ */ w("div", { style: { marginTop: 4, color: F, fontSize: 11, lineHeight: 1.45 }, children: n(i) }) : i.codeName ? /* @__PURE__ */ w(
1376
1389
  "div",
1377
1390
  {
1378
1391
  style: {
@@ -1398,86 +1411,86 @@ function tn({
1398
1411
  }
1399
1412
  );
1400
1413
  }
1401
- function xn(e) {
1402
- He(e.items);
1414
+ function En(e) {
1415
+ Ke(e.items);
1403
1416
  const t = /* @__PURE__ */ new Map();
1404
- for (const o of e.items) {
1405
- const i = e.pageFor(o), s = t.get(i.id);
1417
+ for (const r of e.items) {
1418
+ const i = e.pageFor(r), s = t.get(i.id);
1406
1419
  if (s) {
1407
1420
  if (s.page.name !== i.name || s.page.section !== i.section)
1408
1421
  throw new Error(`Conflicting design catalog page descriptor: ${i.id}`);
1409
- s.items.push(o);
1422
+ s.items.push(r);
1410
1423
  continue;
1411
1424
  }
1412
1425
  t.set(i.id, {
1413
1426
  page: i,
1414
- items: [o],
1415
- registryName: Be(
1427
+ items: [r],
1428
+ registryName: Ue(
1416
1429
  e.kind,
1417
1430
  i.id,
1418
1431
  e.registryPrefix
1419
1432
  )
1420
1433
  });
1421
1434
  }
1422
- const r = {}, n = [];
1423
- for (const o of t.values()) {
1424
- const i = () => /* @__PURE__ */ b(
1425
- tn,
1435
+ const o = {}, n = [];
1436
+ for (const r of t.values()) {
1437
+ const i = () => /* @__PURE__ */ w(
1438
+ rn,
1426
1439
  {
1427
- page: o.page,
1428
- items: o.items,
1440
+ page: r.page,
1441
+ items: r.items,
1429
1442
  renderPreview: e.renderPreview,
1430
1443
  secondaryLabel: e.secondaryLabel,
1431
1444
  minimumColumnWidth: e.minimumColumnWidth ?? 152
1432
1445
  }
1433
1446
  );
1434
- r[o.registryName] = {
1447
+ o[r.registryName] = {
1435
1448
  component: i,
1436
1449
  children: "none"
1437
1450
  };
1438
- const s = en(e.frame, o.page, o.items);
1451
+ const s = nn(e.frame, r.page, r.items);
1439
1452
  n.push({
1440
- ...o.page,
1441
- componentName: o.registryName,
1453
+ ...r.page,
1454
+ componentName: r.registryName,
1442
1455
  width: (s == null ? void 0 : s.width) ?? 1,
1443
1456
  height: (s == null ? void 0 : s.height) ?? 1,
1444
1457
  frameSizeMode: s ? "fixed" : "content"
1445
1458
  });
1446
1459
  }
1447
1460
  return {
1448
- registry: r,
1461
+ registry: o,
1449
1462
  collection: {
1450
1463
  expectedCount: e.expectedCount ?? e.items.length,
1451
- assets: e.items.map((o) => Ue(o, e.pageFor(o).id)),
1464
+ assets: e.items.map((r) => He(r, e.pageFor(r).id)),
1452
1465
  pages: n
1453
1466
  }
1454
1467
  };
1455
1468
  }
1456
- function nn(e, t = 60) {
1457
- const r = Object.entries((e == null ? void 0 : e.props) ?? {}).filter(([, a]) => a.length > 0).sort(([a, f], [m, p]) => p.length - f.length || a.localeCompare(m)), n = r[0], o = r[1], i = Math.max(1, (n == null ? void 0 : n[1].length) ?? 1), s = o == null ? void 0 : o[1].slice(0, Math.max(1, Math.floor(t / i)));
1469
+ function on(e, t = 60) {
1470
+ const o = Object.entries((e == null ? void 0 : e.props) ?? {}).filter(([, a]) => a.length > 0).sort(([a, l], [g, p]) => p.length - l.length || a.localeCompare(g)), n = o[0], r = o[1], i = Math.max(1, (n == null ? void 0 : n[1].length) ?? 1), s = r == null ? void 0 : r[1].slice(0, Math.max(1, Math.floor(t / i)));
1458
1471
  return {
1459
1472
  row: n,
1460
- column: o ? [o[0], s ?? []] : void 0,
1461
- fixed: r.slice(2).map(([a, f]) => [a, f[0]]),
1462
- additional: r.slice(2)
1473
+ column: r ? [r[0], s ?? []] : void 0,
1474
+ fixed: o.slice(2).map(([a, l]) => [a, l[0]]),
1475
+ additional: o.slice(2)
1463
1476
  };
1464
1477
  }
1465
- function rn(e, t, r, n) {
1478
+ function sn(e, t, o, n) {
1466
1479
  return {
1467
1480
  ...e.defaultProps,
1468
1481
  ...Object.fromEntries(t.fixed),
1469
- ...t.row && r ? { [t.row[0]]: r } : {},
1482
+ ...t.row && o ? { [t.row[0]]: o } : {},
1470
1483
  ...t.column && n ? { [t.column[0]]: n } : {}
1471
1484
  };
1472
1485
  }
1473
- function on({
1486
+ function an({
1474
1487
  item: e,
1475
1488
  entry: t,
1476
- maxVariantCells: r
1489
+ maxVariantCells: o
1477
1490
  }) {
1478
- var a, f;
1491
+ var a, l;
1479
1492
  if (!t)
1480
- return /* @__PURE__ */ R(
1493
+ return /* @__PURE__ */ N(
1481
1494
  "section",
1482
1495
  {
1483
1496
  "data-pygmalion-catalog-component": e.id,
@@ -1491,13 +1504,13 @@ function on({
1491
1504
  background: pe
1492
1505
  },
1493
1506
  children: [
1494
- /* @__PURE__ */ b("strong", { children: e.name }),
1495
- /* @__PURE__ */ b("p", { style: { color: F }, children: "The component is not registered." })
1507
+ /* @__PURE__ */ w("strong", { children: e.name }),
1508
+ /* @__PURE__ */ w("p", { style: { color: F }, children: "The component is not registered." })
1496
1509
  ]
1497
1510
  }
1498
1511
  );
1499
- const n = nn(t, r), o = ((a = n.row) == null ? void 0 : a[1]) ?? [void 0], i = ((f = n.column) == null ? void 0 : f[1]) ?? [void 0], s = t.component;
1500
- return /* @__PURE__ */ R(
1512
+ const n = on(t, o), r = ((a = n.row) == null ? void 0 : a[1]) ?? [void 0], i = ((l = n.column) == null ? void 0 : l[1]) ?? [void 0], s = t.component;
1513
+ return /* @__PURE__ */ N(
1501
1514
  "section",
1502
1515
  {
1503
1516
  "data-pygmalion-catalog-component": e.id,
@@ -1512,11 +1525,11 @@ function on({
1512
1525
  fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif"
1513
1526
  },
1514
1527
  children: [
1515
- /* @__PURE__ */ R("header", { style: { marginBottom: 24 }, children: [
1516
- /* @__PURE__ */ b("h1", { style: { margin: 0, fontSize: 24 }, children: e.name }),
1517
- e.sourcePath ? /* @__PURE__ */ b("p", { style: { margin: "6px 0 0", color: F, fontSize: 12 }, children: e.sourcePath }) : null
1528
+ /* @__PURE__ */ N("header", { style: { marginBottom: 24 }, children: [
1529
+ /* @__PURE__ */ w("h1", { style: { margin: 0, fontSize: 24 }, children: e.name }),
1530
+ e.sourcePath ? /* @__PURE__ */ w("p", { style: { margin: "6px 0 0", color: F, fontSize: 12 }, children: e.sourcePath }) : null
1518
1531
  ] }),
1519
- /* @__PURE__ */ b(
1532
+ /* @__PURE__ */ w(
1520
1533
  "div",
1521
1534
  {
1522
1535
  style: {
@@ -1524,13 +1537,13 @@ function on({
1524
1537
  gridTemplateColumns: `repeat(${i.length}, max-content)`,
1525
1538
  gap: 12
1526
1539
  },
1527
- children: o.flatMap(
1528
- (m) => i.map((p) => {
1529
- const y = rn(t, n, m, p), g = [
1530
- n.row && m ? `${n.row[0]}=${m}` : "",
1540
+ children: r.flatMap(
1541
+ (g) => i.map((p) => {
1542
+ const b = sn(t, n, g, p), m = [
1543
+ n.row && g ? `${n.row[0]}=${g}` : "",
1531
1544
  n.column && p ? `${n.column[0]}=${p}` : ""
1532
1545
  ].filter(Boolean).join(" · ");
1533
- return /* @__PURE__ */ R(
1546
+ return /* @__PURE__ */ N(
1534
1547
  "article",
1535
1548
  {
1536
1549
  style: {
@@ -1541,23 +1554,23 @@ function on({
1541
1554
  background: ue
1542
1555
  },
1543
1556
  children: [
1544
- g ? /* @__PURE__ */ b("div", { style: { marginBottom: 12, color: F, fontSize: 11 }, children: g }) : null,
1545
- /* @__PURE__ */ b("div", { style: { display: "flex", minHeight: 44, alignItems: "center" }, children: Ee(
1557
+ m ? /* @__PURE__ */ w("div", { style: { marginBottom: 12, color: F, fontSize: 11 }, children: m }) : null,
1558
+ /* @__PURE__ */ w("div", { style: { display: "flex", minHeight: 44, alignItems: "center" }, children: Ee(
1546
1559
  s,
1547
- y,
1560
+ b,
1548
1561
  t.children === "text" ? t.defaultChildren ?? e.name : void 0
1549
1562
  ) })
1550
1563
  ]
1551
1564
  },
1552
- `${m ?? "default"}:${p ?? "default"}`
1565
+ `${g ?? "default"}:${p ?? "default"}`
1553
1566
  );
1554
1567
  })
1555
1568
  )
1556
1569
  }
1557
1570
  ),
1558
- n.additional.map(([m, p]) => /* @__PURE__ */ R("section", { style: { marginTop: 20 }, children: [
1559
- /* @__PURE__ */ b("h2", { style: { margin: "0 0 10px", color: F, fontSize: 12 }, children: m }),
1560
- /* @__PURE__ */ b("div", { style: { display: "flex", flexWrap: "wrap", gap: 12 }, children: p.map((y) => /* @__PURE__ */ R(
1571
+ n.additional.map(([g, p]) => /* @__PURE__ */ N("section", { style: { marginTop: 20 }, children: [
1572
+ /* @__PURE__ */ w("h2", { style: { margin: "0 0 10px", color: F, fontSize: 12 }, children: g }),
1573
+ /* @__PURE__ */ w("div", { style: { display: "flex", flexWrap: "wrap", gap: 12 }, children: p.map((b) => /* @__PURE__ */ N(
1561
1574
  "article",
1562
1575
  {
1563
1576
  style: {
@@ -1567,38 +1580,38 @@ function on({
1567
1580
  background: ue
1568
1581
  },
1569
1582
  children: [
1570
- /* @__PURE__ */ b("div", { style: { marginBottom: 12, color: F, fontSize: 11 }, children: y }),
1583
+ /* @__PURE__ */ w("div", { style: { marginBottom: 12, color: F, fontSize: 11 }, children: b }),
1571
1584
  Ee(
1572
1585
  s,
1573
- { ...t.defaultProps, [m]: y },
1586
+ { ...t.defaultProps, [g]: b },
1574
1587
  t.children === "text" ? t.defaultChildren ?? e.name : void 0
1575
1588
  )
1576
1589
  ]
1577
1590
  },
1578
- y
1591
+ b
1579
1592
  )) })
1580
- ] }, m))
1593
+ ] }, g))
1581
1594
  ]
1582
1595
  }
1583
1596
  );
1584
1597
  }
1585
- function Pn(e) {
1586
- He(e.items);
1587
- const t = {}, r = [], n = [], o = e.maxVariantCells ?? 60;
1598
+ function Nn(e) {
1599
+ Ke(e.items);
1600
+ const t = {}, o = [], n = [], r = e.maxVariantCells ?? 60;
1588
1601
  for (const i of e.items) {
1589
- const s = Be(
1602
+ const s = Ue(
1590
1603
  e.kind,
1591
1604
  i.id,
1592
1605
  e.registryPrefix
1593
- ), a = e.registry[i.name], f = () => /* @__PURE__ */ b(
1594
- on,
1606
+ ), a = e.registry[i.name], l = () => /* @__PURE__ */ w(
1607
+ an,
1595
1608
  {
1596
1609
  item: i,
1597
1610
  entry: a,
1598
- maxVariantCells: o
1611
+ maxVariantCells: r
1599
1612
  }
1600
1613
  );
1601
- t[s] = { component: f, children: "none" }, r.push({
1614
+ t[s] = { component: l, children: "none" }, o.push({
1602
1615
  id: i.id,
1603
1616
  name: i.name,
1604
1617
  section: i.section,
@@ -1608,24 +1621,24 @@ function Pn(e) {
1608
1621
  width: 1,
1609
1622
  height: 1,
1610
1623
  frameSizeMode: "content"
1611
- }), n.push(Ue(i, i.id));
1624
+ }), n.push(He(i, i.id));
1612
1625
  }
1613
1626
  return {
1614
1627
  registry: t,
1615
1628
  collection: {
1616
1629
  expectedCount: e.expectedCount ?? e.items.length,
1617
1630
  assets: n,
1618
- pages: r
1631
+ pages: o
1619
1632
  }
1620
1633
  };
1621
1634
  }
1622
- const Oe = /^[a-f0-9]{64}$/, sn = /^\/__pygmalion-qa\/artifacts\/[A-Za-z0-9_-]{8,120}\.png$/, an = /^p\d+$/;
1635
+ const Oe = /^[a-f0-9]{64}$/, cn = /^\/__pygmalion-qa\/artifacts\/[A-Za-z0-9_-]{8,120}\.png$/, ln = /^p\d+$/;
1623
1636
  function ve(e) {
1624
- return typeof e == "string" && sn.test(e) ? e : void 0;
1637
+ return typeof e == "string" && cn.test(e) ? e : void 0;
1625
1638
  }
1626
1639
  function $e(e, t) {
1627
- const r = new URL(e, t);
1628
- return r.search = "", r.hash = "", r.pathname.endsWith("/") || (r.pathname = `${r.pathname}/`), r.href;
1640
+ const o = new URL(e, t);
1641
+ return o.search = "", o.hash = "", o.pathname.endsWith("/") || (o.pathname = `${o.pathname}/`), o.href;
1629
1642
  }
1630
1643
  function ge(e) {
1631
1644
  if (!e || typeof e != "object" || Array.isArray(e)) return null;
@@ -1641,80 +1654,80 @@ function Me(e) {
1641
1654
  const t = e;
1642
1655
  return !Number.isSafeInteger(t.width) || !Number.isSafeInteger(t.height) || Number(t.width) < 1 || Number(t.height) < 1 || Number(t.width) > 65536 || Number(t.height) > 65536 ? null : { width: Number(t.width), height: Number(t.height) };
1643
1656
  }
1644
- function cn(e) {
1657
+ function dn(e) {
1645
1658
  if (!e || typeof e != "object" || Array.isArray(e)) return null;
1646
- const t = e, r = Me(t.before), n = Me(t.after);
1647
- if (!r || !n || !Number.isSafeInteger(t.changedPixels) || !Number.isSafeInteger(t.totalPixels) || Number(t.changedPixels) < 0 || Number(t.totalPixels) < 1 || Number(t.changedPixels) > Number(t.totalPixels) || typeof t.threshold != "number" || !Number.isFinite(t.threshold) || t.threshold < 0 || t.threshold > 1)
1659
+ const t = e, o = Me(t.before), n = Me(t.after);
1660
+ if (!o || !n || !Number.isSafeInteger(t.changedPixels) || !Number.isSafeInteger(t.totalPixels) || Number(t.changedPixels) < 0 || Number(t.totalPixels) < 1 || Number(t.changedPixels) > Number(t.totalPixels) || typeof t.threshold != "number" || !Number.isFinite(t.threshold) || t.threshold < 0 || t.threshold > 1)
1648
1661
  return null;
1649
- const o = t.heatmapUrl == null ? null : ve(t.heatmapUrl) ?? null;
1662
+ const r = t.heatmapUrl == null ? null : ve(t.heatmapUrl) ?? null;
1650
1663
  return {
1651
- before: r,
1664
+ before: o,
1652
1665
  after: n,
1653
- dimensionsMatch: r.width === n.width && r.height === n.height,
1666
+ dimensionsMatch: o.width === n.width && o.height === n.height,
1654
1667
  changedPixels: Number(t.changedPixels),
1655
1668
  totalPixels: Number(t.totalPixels),
1656
1669
  diffRatio: Number(t.changedPixels) / Number(t.totalPixels),
1657
1670
  threshold: t.threshold,
1658
- heatmapUrl: o
1671
+ heatmapUrl: r
1659
1672
  };
1660
1673
  }
1661
- function ln(e, t) {
1674
+ function fn(e, t) {
1662
1675
  if (!e || typeof e != "object" || Array.isArray(e)) return null;
1663
- const r = e;
1664
- if (typeof r.id != "string" || !r.id) return null;
1665
- const n = ge(r), o = ge(r.before) ?? n;
1666
- if (!o) return null;
1667
- const i = ge(r.after);
1676
+ const o = e;
1677
+ if (typeof o.id != "string" || !o.id) return null;
1678
+ const n = ge(o), r = ge(o.before) ?? n;
1679
+ if (!r) return null;
1680
+ const i = ge(o.after);
1668
1681
  if (t === "changed" && !i) return null;
1669
- const s = i ? cn(r.pixelDiff) : null;
1682
+ const s = i ? dn(o.pixelDiff) : null;
1670
1683
  return {
1671
- id: r.id,
1672
- before: o,
1684
+ id: o.id,
1685
+ before: r,
1673
1686
  ...i ? { after: i } : {},
1674
1687
  ...i ? {
1675
- domChanged: o.domStructureHash !== i.domStructureHash,
1676
- screenshotChanged: o.screenshotHash !== i.screenshotHash
1688
+ domChanged: r.domStructureHash !== i.domStructureHash,
1689
+ screenshotChanged: r.screenshotHash !== i.screenshotHash
1677
1690
  } : {},
1678
1691
  ...s ? { pixelDiff: s } : {}
1679
1692
  };
1680
1693
  }
1681
- function dn(e, t = []) {
1682
- const r = new Set(t), n = r.size > 0, o = /* @__PURE__ */ new Set(), i = [
1694
+ function un(e, t = []) {
1695
+ const o = new Set(t), n = o.size > 0, r = /* @__PURE__ */ new Set(), i = [
1683
1696
  ...e.styles.map((s) => s.affectedFrames ?? []),
1684
1697
  ...e.texts.map((s) => s.affectedFrames ?? []),
1685
1698
  ...e.operations.map((s) => s.affectedFrames ?? [])
1686
1699
  ];
1687
1700
  for (const s of i)
1688
1701
  for (const a of s) {
1689
- if (n && an.test(a.id) && !r.has(a.id))
1702
+ if (n && ln.test(a.id) && !o.has(a.id))
1690
1703
  throw new Error(
1691
1704
  `"Impact Screen"${a.name}"This internal editor ID (${a.id}) is used. A canonical screen ID is required.`
1692
1705
  );
1693
- !a.id || n && !r.has(a.id) || o.add(a.id);
1706
+ !a.id || n && !o.has(a.id) || r.add(a.id);
1694
1707
  }
1695
- return [...o].sort();
1708
+ return [...r].sort();
1696
1709
  }
1697
- async function Te(e, t, r) {
1710
+ async function Te(e, t, o) {
1698
1711
  const n = await e(`${t.replace(/\/$/, "")}/capture`, {
1699
1712
  method: "POST",
1700
1713
  headers: { "content-type": "application/json" },
1701
- body: JSON.stringify(r)
1702
- }), o = await n.json();
1703
- if (!n.ok || o.ok === !1)
1714
+ body: JSON.stringify(o)
1715
+ }), r = await n.json();
1716
+ if (!n.ok || r.ok === !1)
1704
1717
  throw new Error(
1705
- typeof o.error == "string" ? o.error : `Pygmalion visual QA capture failed (${n.status})`
1718
+ typeof r.error == "string" ? r.error : `Pygmalion visual QA capture failed (${n.status})`
1706
1719
  );
1707
- if (typeof o.baselineId != "string" || !o.baselineId)
1720
+ if (typeof r.baselineId != "string" || !r.baselineId)
1708
1721
  throw new Error("Pygmalion visual QA response has no baselineId");
1709
- const i = Array.isArray(o.frames) ? o.frames.map((p) => ln(p, r.phase)).filter((p) => p != null) : [], s = Array.isArray(o.failures) ? o.failures.map((p) => {
1722
+ const i = Array.isArray(r.frames) ? r.frames.map((p) => fn(p, o.phase)).filter((p) => p != null) : [], s = Array.isArray(r.failures) ? r.failures.map((p) => {
1710
1723
  if (!p || typeof p != "object" || Array.isArray(p)) return null;
1711
- const y = p;
1712
- return typeof y.id == "string" && typeof y.error == "string" ? { id: y.id, error: y.error } : null;
1713
- }).filter((p) => p != null) : [], a = new Set(r.frameIds), m = new Set(i.map((p) => p.id)).size === i.length && i.every((p) => a.has(p.id)) && s.every((p) => a.has(p.id));
1724
+ const b = p;
1725
+ return typeof b.id == "string" && typeof b.error == "string" ? { id: b.id, error: b.error } : null;
1726
+ }).filter((p) => p != null) : [], a = new Set(o.frameIds), g = new Set(i.map((p) => p.id)).size === i.length && i.every((p) => a.has(p.id)) && s.every((p) => a.has(p.id));
1714
1727
  return {
1715
- phase: r.phase,
1716
- baselineId: o.baselineId,
1717
- complete: o.complete !== !1 && m && s.length === 0 && i.length === r.frameIds.length,
1728
+ phase: o.phase,
1729
+ baselineId: r.baselineId,
1730
+ complete: r.complete !== !1 && g && s.length === 0 && i.length === o.frameIds.length,
1718
1731
  frames: i,
1719
1732
  failures: s
1720
1733
  };
@@ -1723,46 +1736,46 @@ const ye = {
1723
1736
  mirror: "/__pygmalion-dev-control",
1724
1737
  sessions: "/__pygmalion-design-session",
1725
1738
  inspect: "/__pygmalion-inspect"
1726
- }, fn = "pygmalion.designSessionId", un = "/__pygmalion-qa", ae = /* @__PURE__ */ new Map();
1727
- function ke() {
1739
+ }, pn = "pygmalion.designSessionId", hn = "/__pygmalion-qa", ce = /* @__PURE__ */ new Map();
1740
+ function De() {
1728
1741
  var e;
1729
1742
  return typeof window < "u" && ((e = window.crypto) != null && e.randomUUID) ? window.crypto.randomUUID() : `pygmalion-${Date.now()}-${Math.random().toString(36).slice(2)}`;
1730
1743
  }
1731
- function pn(e, t) {
1744
+ function mn(e, t) {
1732
1745
  if (e) return e;
1733
- const r = ae.get(t);
1734
- if (r) return r;
1746
+ const o = ce.get(t);
1747
+ if (o) return o;
1735
1748
  try {
1736
1749
  const n = window.localStorage.getItem(t);
1737
1750
  if (n)
1738
- return ae.set(t, n), n;
1739
- const o = ke();
1740
- return window.localStorage.setItem(t, o), ae.set(t, o), o;
1751
+ return ce.set(t, n), n;
1752
+ const r = De();
1753
+ return window.localStorage.setItem(t, r), ce.set(t, r), r;
1741
1754
  } catch {
1742
- const n = ke();
1743
- return ae.set(t, n), n;
1755
+ const n = De();
1756
+ return ce.set(t, n), n;
1744
1757
  }
1745
1758
  }
1746
- async function G(e) {
1759
+ async function q(e) {
1747
1760
  const t = await e.json();
1748
1761
  if (!e.ok) throw new Error(t.error ?? `Pygmalion request failed (${e.status})`);
1749
1762
  return t;
1750
1763
  }
1751
- function En(e = {}) {
1752
- var se, re, oe, c, d;
1764
+ function Rn(e = {}) {
1765
+ var ae, re, oe, c, f;
1753
1766
  const {
1754
1767
  sessionId: t,
1755
- sessionStorageKey: r = fn,
1768
+ sessionStorageKey: o = pn,
1756
1769
  autoStart: n = !0,
1757
- fetcher: o = fetch,
1770
+ fetcher: r = fetch,
1758
1771
  formatApplyMessage: i
1759
- } = e, s = ((se = e.endpoints) == null ? void 0 : se.mirror) ?? ye.mirror, a = ((re = e.endpoints) == null ? void 0 : re.sessions) ?? ye.sessions, f = ((oe = e.endpoints) == null ? void 0 : oe.inspect) ?? ye.inspect, m = e.visualQa != null, p = ((c = e.visualQa) == null ? void 0 : c.endpoint) ?? un, y = JSON.stringify(((d = e.visualQa) == null ? void 0 : d.eligibleFrameIds) ?? []), g = le(
1760
- () => JSON.parse(y),
1761
- [y]
1762
- ), v = le(
1763
- () => pn(t, r),
1764
- [t, r]
1765
- ), [w, N] = ee({
1772
+ } = e, s = ((ae = e.endpoints) == null ? void 0 : ae.mirror) ?? ye.mirror, a = ((re = e.endpoints) == null ? void 0 : re.sessions) ?? ye.sessions, l = ((oe = e.endpoints) == null ? void 0 : oe.inspect) ?? ye.inspect, g = e.visualQa != null, p = ((c = e.visualQa) == null ? void 0 : c.endpoint) ?? hn, b = JSON.stringify(((f = e.visualQa) == null ? void 0 : f.eligibleFrameIds) ?? []), m = de(
1773
+ () => JSON.parse(b),
1774
+ [b]
1775
+ ), v = de(
1776
+ () => mn(t, o),
1777
+ [t, o]
1778
+ ), [y, R] = te({
1766
1779
  state: "idle",
1767
1780
  commit: null,
1768
1781
  shortCommit: null,
@@ -1772,100 +1785,100 @@ function En(e = {}) {
1772
1785
  warning: null,
1773
1786
  error: null,
1774
1787
  appOrigin: null
1775
- }), [h, O] = ee(null), [A, $] = ee(null), [T, k] = ee({
1788
+ }), [h, O] = te(null), [A, D] = te(null), [$, k] = te({
1776
1789
  refs: [],
1777
1790
  defaultRef: null,
1778
1791
  worktreeRef: null
1779
- }), S = Ne(null), P = Ne(null), D = W(
1780
- async (l = !0, u) => {
1792
+ }), S = Ne(null), x = Ne(null), T = W(
1793
+ async (d = !0, u) => {
1781
1794
  if (u != null && S.current && await S.current.catch(() => {
1782
1795
  }), S.current) return S.current;
1783
- const x = (async () => {
1784
- N((I) => ({ ...I, state: "syncing", error: null }));
1796
+ const P = (async () => {
1797
+ R((I) => ({ ...I, state: "syncing", error: null }));
1785
1798
  try {
1786
1799
  const I = u != null;
1787
- let M = await o(`${s}/${l || I ? "refresh" : "status"}`, {
1788
- method: l || I ? "POST" : "GET",
1800
+ let M = await r(`${s}/${d || I ? "refresh" : "status"}`, {
1801
+ method: d || I ? "POST" : "GET",
1789
1802
  ...I ? {
1790
1803
  headers: { "content-type": "application/json" },
1791
1804
  body: JSON.stringify({ ref: u })
1792
1805
  } : {}
1793
- }), C = await G(M);
1806
+ }), C = await q(M);
1794
1807
  const L = Date.now();
1795
- for (; !l && C.state === "syncing" && Date.now() - L < 12e4; )
1796
- await new Promise((Z) => window.setTimeout(Z, 500)), M = await o(`${s}/status`), C = await G(M);
1808
+ for (; !d && C.state === "syncing" && Date.now() - L < 12e4; )
1809
+ await new Promise((ee) => window.setTimeout(ee, 500)), M = await r(`${s}/status`), C = await q(M);
1797
1810
  if (C.state !== "ready" || !C.appOrigin || !C.commit)
1798
1811
  throw new Error(C.error ?? "Pygmalion could not prepare the source preview");
1799
- const q = await G(
1800
- await o(`${a}/open`, {
1812
+ const V = await q(
1813
+ await r(`${a}/open`, {
1801
1814
  method: "POST",
1802
1815
  headers: { "content-type": "application/json" },
1803
1816
  body: JSON.stringify({ sessionId: v, baseDevSha: C.commit })
1804
1817
  })
1805
1818
  );
1806
- if (!q.ok || !q.session)
1807
- throw new Error(q.error ?? "Pygmalion could not open the design session");
1808
- let H = q.session;
1819
+ if (!V.ok || !V.session)
1820
+ throw new Error(V.error ?? "Pygmalion could not open the design session");
1821
+ let H = V.session;
1809
1822
  if (H.branchName) {
1810
- const Z = await G(
1811
- await o(`${a}/check`, {
1823
+ const ee = await q(
1824
+ await r(`${a}/check`, {
1812
1825
  method: "POST",
1813
1826
  headers: { "content-type": "application/json" },
1814
1827
  body: JSON.stringify({ sessionId: H.id })
1815
1828
  })
1816
1829
  );
1817
- if (!Z.ok || !Z.session)
1818
- throw new Error(Z.error ?? "Pygmalion could not check the design session");
1819
- H = Z.session;
1830
+ if (!ee.ok || !ee.session)
1831
+ throw new Error(ee.error ?? "Pygmalion could not check the design session");
1832
+ H = ee.session;
1820
1833
  }
1821
- N(C), O(H), $(H.appOrigin ?? C.appOrigin);
1834
+ R(C), O(H), D(H.appOrigin ?? C.appOrigin);
1822
1835
  } catch (I) {
1823
- N((M) => ({
1836
+ R((M) => ({
1824
1837
  ...M,
1825
1838
  state: "error",
1826
1839
  error: I instanceof Error ? I.message : String(I)
1827
1840
  }));
1828
1841
  }
1829
1842
  })();
1830
- S.current = x;
1843
+ S.current = P;
1831
1844
  try {
1832
- await x;
1845
+ await P;
1833
1846
  } finally {
1834
- S.current === x && (S.current = null);
1847
+ S.current === P && (S.current = null);
1835
1848
  }
1836
1849
  },
1837
- [o, s, a, v]
1850
+ [r, s, a, v]
1838
1851
  ), j = W(async () => {
1839
1852
  try {
1840
- const l = await G(
1841
- await o(`${s}/refs`)
1853
+ const d = await q(
1854
+ await r(`${s}/refs`)
1842
1855
  ), u = {
1843
- refs: l.refs ?? [],
1844
- defaultRef: l.defaultRef ?? null,
1845
- worktreeRef: l.worktreeRef ?? null
1856
+ refs: d.refs ?? [],
1857
+ defaultRef: d.defaultRef ?? null,
1858
+ worktreeRef: d.worktreeRef ?? null
1846
1859
  };
1847
1860
  return k(u), u;
1848
1861
  } catch {
1849
- return T;
1862
+ return $;
1850
1863
  }
1851
- }, [o, s, T]), Y = W(
1852
- async (l, u) => {
1864
+ }, [r, s, $]), X = W(
1865
+ async (d, u) => {
1853
1866
  if (h != null && h.branchName && !(u != null && u.discardEdits))
1854
1867
  throw new Error(
1855
1868
  "This design session has unapplied edits against the current source. Apply or revert them, or pass discardEdits to switch anyway."
1856
1869
  );
1857
- await D(!0, l);
1870
+ await T(!0, d);
1858
1871
  },
1859
- [D, h == null ? void 0 : h.branchName]
1860
- ), J = W(
1861
- async (l) => {
1872
+ [T, h == null ? void 0 : h.branchName]
1873
+ ), Y = W(
1874
+ async (d) => {
1862
1875
  var C;
1863
1876
  if (!h) throw new Error("Pygmalion design session is not ready");
1864
- const u = P.current;
1865
- if (u && (u.sessionId !== h.id || u.baseDevSha !== h.baseDevSha || u.revision !== h.revision || u.fingerprint !== JSON.stringify(l)))
1877
+ const u = x.current;
1878
+ if (u && (u.sessionId !== h.id || u.baseDevSha !== h.baseDevSha || u.revision !== h.revision || u.fingerprint !== JSON.stringify(d)))
1866
1879
  throw new Error("The code diff you checked is out of date. Please check the diff for the current changes again.");
1867
- const x = await G(
1868
- await o(`${a}/apply-visual`, {
1880
+ const P = await q(
1881
+ await r(`${a}/apply-visual`, {
1869
1882
  method: "POST",
1870
1883
  headers: { "content-type": "application/json" },
1871
1884
  body: JSON.stringify({
@@ -1873,82 +1886,82 @@ function En(e = {}) {
1873
1886
  baseDevSha: h.baseDevSha,
1874
1887
  expectedRevision: h.revision,
1875
1888
  ...u ? { previewRevision: u.revision } : {},
1876
- changes: l
1889
+ changes: d
1877
1890
  })
1878
1891
  })
1879
1892
  );
1880
- if (!x.ok || !x.session)
1881
- throw new Error(x.error ?? "Pygmalion could not apply the visual changes");
1882
- O(x.session), x.session.appOrigin && $(x.session.appOrigin);
1883
- const I = x.applied ?? l.styles.length + l.texts.length + l.operations.length;
1893
+ if (!P.ok || !P.session)
1894
+ throw new Error(P.error ?? "Pygmalion could not apply the visual changes");
1895
+ O(P.session), P.session.appOrigin && D(P.session.appOrigin);
1896
+ const I = P.applied ?? d.styles.length + d.texts.length + d.operations.length;
1884
1897
  let M;
1885
- if (u != null && u.qaBaselineId && ((C = u.qaFrameIds) != null && C.length) && x.session.appOrigin)
1898
+ if (u != null && u.qaBaselineId && ((C = u.qaFrameIds) != null && C.length) && P.session.appOrigin)
1886
1899
  try {
1887
- M = await Te(o, p, {
1900
+ M = await Te(r, p, {
1888
1901
  phase: "changed",
1889
1902
  baselineId: u.qaBaselineId,
1890
- basePath: $e(x.session.appOrigin, window.location.origin),
1903
+ basePath: $e(P.session.appOrigin, window.location.origin),
1891
1904
  frameIds: u.qaFrameIds
1892
1905
  });
1893
1906
  } catch (L) {
1894
- const q = L instanceof Error ? L.message : String(L);
1907
+ const V = L instanceof Error ? L.message : String(L);
1895
1908
  M = {
1896
1909
  phase: "changed",
1897
1910
  baselineId: u.qaBaselineId,
1898
1911
  complete: !1,
1899
1912
  frames: [],
1900
- failures: u.qaFrameIds.map((H) => ({ id: H, error: q }))
1913
+ failures: u.qaFrameIds.map((H) => ({ id: H, error: V }))
1901
1914
  };
1902
1915
  }
1903
- return P.current = null, {
1916
+ return x.current = null, {
1904
1917
  applied: I,
1905
- branch: x.session.branchName ?? void 0,
1906
- integration: x.session.integration.state,
1907
- message: i == null ? void 0 : i(x.session, I),
1918
+ branch: P.session.branchName ?? void 0,
1919
+ integration: P.session.integration.state,
1920
+ message: i == null ? void 0 : i(P.session, I),
1908
1921
  ...M ? { qa: M } : {}
1909
1922
  };
1910
1923
  },
1911
- [o, i, p, h, a]
1912
- ), V = W(
1913
- async (l) => {
1924
+ [r, i, p, h, a]
1925
+ ), G = W(
1926
+ async (d) => {
1914
1927
  var C;
1915
1928
  if (!h) throw new Error("Pygmalion design session is not ready");
1916
- P.current = null;
1917
- const u = await G(
1918
- await o(`${a}/preview-visual`, {
1929
+ x.current = null;
1930
+ const u = await q(
1931
+ await r(`${a}/preview-visual`, {
1919
1932
  method: "POST",
1920
1933
  headers: { "content-type": "application/json" },
1921
1934
  body: JSON.stringify({
1922
1935
  sessionId: h.id,
1923
1936
  baseDevSha: h.baseDevSha,
1924
1937
  expectedRevision: h.revision,
1925
- changes: l
1938
+ changes: d
1926
1939
  })
1927
1940
  })
1928
1941
  );
1929
1942
  if (!u.ok || !Number.isSafeInteger(u.revision))
1930
1943
  throw new Error(u.error ?? "Pygmalion could not preview the visual changes");
1931
- const x = m ? dn(l, g) : [];
1944
+ const P = g ? un(d, m) : [];
1932
1945
  let I;
1933
- const M = h.appOrigin ?? w.appOrigin;
1934
- if (x.length > 0) {
1946
+ const M = h.appOrigin ?? y.appOrigin;
1947
+ if (P.length > 0) {
1935
1948
  if (!M)
1936
1949
  throw new Error("Impact screen QA baseline preview not ready");
1937
- if (I = await Te(o, p, {
1950
+ if (I = await Te(r, p, {
1938
1951
  phase: "baseline",
1939
1952
  basePath: $e(M, window.location.origin),
1940
- frameIds: x
1953
+ frameIds: P
1941
1954
  }), !I.complete)
1942
1955
  throw new Error(
1943
- ((C = I.failures[0]) == null ? void 0 : C.error) ?? `Failed to capture ${x.length - I.frames.length} affected frames`
1956
+ ((C = I.failures[0]) == null ? void 0 : C.error) ?? `Failed to capture ${P.length - I.frames.length} affected frames`
1944
1957
  );
1945
1958
  }
1946
- return P.current = {
1959
+ return x.current = {
1947
1960
  sessionId: h.id,
1948
1961
  baseDevSha: h.baseDevSha,
1949
1962
  revision: u.revision,
1950
- fingerprint: JSON.stringify(l),
1951
- ...I ? { qaBaselineId: I.baselineId, qaFrameIds: x } : {}
1963
+ fingerprint: JSON.stringify(d),
1964
+ ...I ? { qaBaselineId: I.baselineId, qaFrameIds: P } : {}
1952
1965
  }, {
1953
1966
  revision: u.revision,
1954
1967
  files: Array.isArray(u.files) ? u.files : [],
@@ -1957,34 +1970,34 @@ function En(e = {}) {
1957
1970
  };
1958
1971
  },
1959
1972
  [
1960
- o,
1961
- w.appOrigin,
1962
- g,
1973
+ r,
1974
+ y.appOrigin,
1975
+ m,
1963
1976
  p,
1964
1977
  h,
1965
1978
  a,
1966
- m
1979
+ g
1967
1980
  ]
1968
- ), E = W(
1969
- async (l) => {
1970
- if (l.length === 0) return { files: [] };
1971
- const u = await G(
1972
- await o(`${f}/impact`, {
1981
+ ), Z = W(
1982
+ async (d) => {
1983
+ if (d.length === 0) return { files: [] };
1984
+ const u = await q(
1985
+ await r(`${l}/impact`, {
1973
1986
  method: "POST",
1974
1987
  headers: { "content-type": "application/json" },
1975
- body: JSON.stringify({ componentFiles: l })
1988
+ body: JSON.stringify({ componentFiles: d })
1976
1989
  })
1977
1990
  );
1978
1991
  if (u.error || u.ok === !1)
1979
1992
  throw new Error(u.error ?? "Pygmalion could not calculate source impact");
1980
1993
  return { files: Array.isArray(u.files) ? u.files : [] };
1981
1994
  },
1982
- [o, f]
1983
- ), B = W(async () => {
1995
+ [r, l]
1996
+ ), E = W(async () => {
1984
1997
  if (!(h != null && h.canRevert) || !h.headSha)
1985
1998
  throw new Error("There are no reversible changes applied");
1986
- const l = await G(
1987
- await o(`${a}/revert-visual`, {
1999
+ const d = await q(
2000
+ await r(`${a}/revert-visual`, {
1988
2001
  method: "POST",
1989
2002
  headers: { "content-type": "application/json" },
1990
2003
  body: JSON.stringify({
@@ -1995,77 +2008,77 @@ function En(e = {}) {
1995
2008
  })
1996
2009
  })
1997
2010
  );
1998
- if (!l.ok || l.reverted !== !0 || !l.operation || l.operation.kind !== "visual-revert" || !l.session)
1999
- throw new Error(l.error ?? "Pygmalion could not revert the last visual change");
2000
- return P.current = null, O(l.session), l.session.appOrigin && $(l.session.appOrigin), {
2011
+ if (!d.ok || d.reverted !== !0 || !d.operation || d.operation.kind !== "visual-revert" || !d.session)
2012
+ throw new Error(d.error ?? "Pygmalion could not revert the last visual change");
2013
+ return x.current = null, O(d.session), d.session.appOrigin && D(d.session.appOrigin), {
2001
2014
  reverted: !0,
2002
- operation: l.operation,
2003
- session: l.session
2015
+ operation: d.operation,
2016
+ session: d.session
2004
2017
  };
2005
- }, [o, h, a]);
2006
- te(() => {
2007
- n && D(!1);
2008
- }, [n, D]), te(() => {
2018
+ }, [r, h, a]);
2019
+ ne(() => {
2020
+ n && T(!1);
2021
+ }, [n, T]), ne(() => {
2009
2022
  n && j();
2010
2023
  }, [n]);
2011
- const _ = (h == null ? void 0 : h.appOrigin) ?? w.appOrigin ?? A, ne = (h == null ? void 0 : h.headSha) ?? (h == null ? void 0 : h.baseDevSha) ?? w.commit ?? "pending";
2024
+ const B = (h == null ? void 0 : h.appOrigin) ?? y.appOrigin ?? A, _ = (h == null ? void 0 : h.headSha) ?? (h == null ? void 0 : h.baseDevSha) ?? y.commit ?? "pending";
2012
2025
  return {
2013
- mirror: w,
2026
+ mirror: y,
2014
2027
  session: h,
2015
2028
  ready: A != null,
2016
- appOrigin: _,
2017
- previewRevision: `${ne}:${(h == null ? void 0 : h.revision) ?? 0}`,
2018
- previewSourceRevision: ne,
2019
- refresh: D,
2020
- switchSource: Y,
2021
- sourceRefs: T,
2029
+ appOrigin: B,
2030
+ previewRevision: `${_}:${(h == null ? void 0 : h.revision) ?? 0}`,
2031
+ previewSourceRevision: _,
2032
+ refresh: T,
2033
+ switchSource: X,
2034
+ sourceRefs: $,
2022
2035
  loadSourceRefs: j,
2023
- previewVisual: V,
2024
- inspectImpact: E,
2025
- applyVisual: J,
2026
- revertLastVisual: B
2036
+ previewVisual: G,
2037
+ inspectImpact: Z,
2038
+ applyVisual: Y,
2039
+ revertLastVisual: E
2027
2040
  };
2028
2041
  }
2029
- function Nn({
2042
+ function Cn({
2030
2043
  value: e,
2031
2044
  refs: t,
2032
- onChange: r,
2045
+ onChange: o,
2033
2046
  busy: n = !1,
2034
- defaultRef: o = null,
2047
+ defaultRef: r = null,
2035
2048
  worktreeRef: i = null,
2036
2049
  label: s = "Source revision",
2037
2050
  children: a,
2038
- className: f
2051
+ className: l
2039
2052
  }) {
2040
- const m = le(
2053
+ const g = de(
2041
2054
  () => ({
2042
- local: t.filter((g) => g.kind === "local"),
2043
- remote: t.filter((g) => g.kind === "remote")
2055
+ local: t.filter((m) => m.kind === "local"),
2056
+ remote: t.filter((m) => m.kind === "remote")
2044
2057
  }),
2045
2058
  [t]
2046
- ), p = le(() => {
2047
- const g = new Set(t.map((v) => v.name));
2048
- return o && g.add(o), i && g.add(i), g;
2049
- }, [o, t, i]), y = e ?? o ?? "";
2050
- return /* @__PURE__ */ R(
2059
+ ), p = de(() => {
2060
+ const m = new Set(t.map((v) => v.name));
2061
+ return r && m.add(r), i && m.add(i), m;
2062
+ }, [r, t, i]), b = e ?? r ?? "";
2063
+ return /* @__PURE__ */ N(
2051
2064
  "span",
2052
2065
  {
2053
- className: f,
2066
+ className: l,
2054
2067
  "data-pygmalion-source-ref": "",
2055
2068
  "data-busy": n ? "" : void 0,
2056
2069
  style: { position: "relative", display: "inline-flex", alignItems: "center" },
2057
2070
  children: [
2058
- a ?? /* @__PURE__ */ b("span", { "data-pygmalion-source-ref-value": "", children: y || s }),
2059
- /* @__PURE__ */ R(
2071
+ a ?? /* @__PURE__ */ w("span", { "data-pygmalion-source-ref-value": "", children: b || s }),
2072
+ /* @__PURE__ */ N(
2060
2073
  "select",
2061
2074
  {
2062
- value: y,
2075
+ value: b,
2063
2076
  disabled: n,
2064
2077
  "aria-label": s,
2065
2078
  "data-pygmalion-source-ref-select": "",
2066
- onChange: (g) => {
2067
- const v = g.target.value;
2068
- v && v !== y && r(v);
2079
+ onChange: (m) => {
2080
+ const v = m.target.value;
2081
+ v && v !== b && o(v);
2069
2082
  },
2070
2083
  style: {
2071
2084
  position: "absolute",
@@ -2081,21 +2094,21 @@ function Nn({
2081
2094
  margin: 0
2082
2095
  },
2083
2096
  children: [
2084
- y && !p.has(y) ? /* @__PURE__ */ b("option", { value: y, children: y }) : null,
2085
- i ? /* @__PURE__ */ R("option", { value: i, children: [
2097
+ b && !p.has(b) ? /* @__PURE__ */ w("option", { value: b, children: b }) : null,
2098
+ i ? /* @__PURE__ */ N("option", { value: i, children: [
2086
2099
  i,
2087
2100
  " · uncommitted work"
2088
2101
  ] }) : null,
2089
- m.local.length > 0 ? /* @__PURE__ */ b("optgroup", { label: "local", children: m.local.map((g) => /* @__PURE__ */ R("option", { value: g.name, children: [
2090
- g.name,
2102
+ g.local.length > 0 ? /* @__PURE__ */ w("optgroup", { label: "local", children: g.local.map((m) => /* @__PURE__ */ N("option", { value: m.name, children: [
2103
+ m.name,
2091
2104
  " · ",
2092
- g.commit
2093
- ] }, g.fullName)) }) : null,
2094
- m.remote.length > 0 ? /* @__PURE__ */ b("optgroup", { label: "remote", children: m.remote.map((g) => /* @__PURE__ */ R("option", { value: g.name, children: [
2095
- g.name,
2105
+ m.commit
2106
+ ] }, m.fullName)) }) : null,
2107
+ g.remote.length > 0 ? /* @__PURE__ */ w("optgroup", { label: "remote", children: g.remote.map((m) => /* @__PURE__ */ N("option", { value: m.name, children: [
2108
+ m.name,
2096
2109
  " · ",
2097
- g.commit
2098
- ] }, g.fullName)) }) : null
2110
+ m.commit
2111
+ ] }, m.fullName)) }) : null
2099
2112
  ]
2100
2113
  }
2101
2114
  )
@@ -2103,56 +2116,57 @@ function Nn({
2103
2116
  }
2104
2117
  );
2105
2118
  }
2106
- const Rn = {
2119
+ const An = {
2107
2120
  editor: K,
2108
2121
  getObserverTree: Le,
2109
2122
  isObservableProp: Je
2110
2123
  };
2111
- function Cn(e) {
2124
+ function On(e) {
2112
2125
  K.navigateToPageByName(e);
2113
2126
  }
2114
- function An() {
2127
+ function $n() {
2115
2128
  K.openPreview();
2116
2129
  }
2117
- function On() {
2130
+ function Mn() {
2118
2131
  const e = xe.entries.length > 0;
2119
2132
  return e && xe.discardPending(), K.resetCurrentEdits() || e;
2120
2133
  }
2121
- function $n({
2134
+ function Tn({
2122
2135
  registry: e,
2123
2136
  tokens: t,
2124
- initialPages: r,
2125
- designImport: n,
2126
- onTokensChange: o,
2127
- appOrigin: i,
2128
- previewRevision: s,
2129
- previewCacheNamespace: a,
2130
- previewArtifacts: f,
2131
- previewArtifactEndpoint: m,
2132
- previewConcurrency: p,
2133
- previewOpen: y,
2134
- onPreviewOpenChange: g,
2135
- flowCanvas: v,
2136
- onApply: w,
2137
- onDesignChange: N,
2138
- onInspectApply: h,
2139
- onInspectPreview: O,
2140
- onInspectImpact: A,
2137
+ initialPages: o,
2138
+ viewportPresets: n,
2139
+ designImport: r,
2140
+ onTokensChange: i,
2141
+ appOrigin: s,
2142
+ previewRevision: a,
2143
+ previewCacheNamespace: l,
2144
+ previewArtifacts: g,
2145
+ previewArtifactEndpoint: p,
2146
+ previewConcurrency: b,
2147
+ previewOpen: m,
2148
+ onPreviewOpenChange: v,
2149
+ flowCanvas: y,
2150
+ onApply: R,
2151
+ onDesignChange: h,
2152
+ onInspectApply: O,
2153
+ onInspectPreview: A,
2154
+ onInspectImpact: D,
2141
2155
  storyboardDiscovery: $ = !0,
2142
- storyboardDiscoveryEndpoint: T = at
2156
+ storyboardDiscoveryEndpoint: k = lt
2143
2157
  }) {
2144
- const [k, S] = ee(!$), [P, D] = ee();
2145
- n && (n.assertComplete(), Ve(n));
2146
- const j = e ?? (n == null ? void 0 : n.getRegistry()), Y = t ?? (n == null ? void 0 : n.getTokens()), J = r ?? (n == null ? void 0 : n.getInitialPages());
2147
- j && We(j), Y && Qe(Y), lt(o ?? null), i != null && Xe(i), s != null && Ye(s), Ze(a);
2148
- const V = P ?? f;
2149
- return V && J && k && et(V, {
2150
- namespace: a ?? "",
2151
- previewRevision: ft(),
2152
- appOrigin: dt(),
2153
- baselineEnvironment: tt(),
2154
- allowStaleIdentity: P == null && !!m,
2155
- pages: J.flatMap(
2158
+ const [S, x] = te(!$), [T, j] = te();
2159
+ r && (r.assertComplete(), We(r));
2160
+ const X = e ?? (r == null ? void 0 : r.getRegistry()), Y = t ?? (r == null ? void 0 : r.getTokens()), G = o ?? (r == null ? void 0 : r.getInitialPages());
2161
+ X && Qe(X), Y && Xe(Y), n && Ye(n), ft(i ?? null), s != null && Ze(s), a != null && et(a), tt(l);
2162
+ const Z = T ?? g;
2163
+ return Z && G && S && nt(Z, {
2164
+ namespace: l ?? "",
2165
+ previewRevision: pt(),
2166
+ appOrigin: ut(),
2167
+ baselineEnvironment: rt(),
2168
+ allowStaleIdentity: T == null && !!p,
2169
+ pages: G.flatMap(
2156
2170
  (E) => E.route && E.importPageId ? [
2157
2171
  {
2158
2172
  canonicalId: E.importPageId,
@@ -2166,66 +2180,66 @@ function $n({
2166
2180
  }
2167
2181
  ] : []
2168
2182
  )
2169
- }), p != null && nt(p), ut(g ?? null), v != null && rt(v), pt(w ?? null), ht(h ?? null), ot(O ?? null), mt(A ?? null), J && K.initPagesFromComponents(J), te(() => {
2170
- Pe(N ?? null);
2171
- const E = it(K);
2183
+ }), b != null && ot(b), ht(v ?? null), y != null && it(y), mt(R ?? null), gt(O ?? null), st(A ?? null), yt(D ?? null), G && K.initPagesFromComponents(G), ne(() => {
2184
+ Pe(h ?? null);
2185
+ const E = at(K);
2172
2186
  return () => {
2173
2187
  E(), Pe(null);
2174
2188
  };
2175
- }, [N]), te(() => {
2176
- if (D(void 0), !k || !m || !(a != null && a.trim()) || !(s != null && s.trim()))
2189
+ }, [h]), ne(() => {
2190
+ if (j(void 0), !S || !p || !(l != null && l.trim()) || !(a != null && a.trim()))
2177
2191
  return;
2178
2192
  const E = new AbortController();
2179
- return Qt({
2180
- namespace: a,
2181
- sourceRevision: st(s),
2182
- transport: Gt({
2183
- endpoint: m,
2184
- captureBaseUrl: i
2193
+ return Yt({
2194
+ namespace: l,
2195
+ sourceRevision: ct(a),
2196
+ transport: Jt({
2197
+ endpoint: p,
2198
+ captureBaseUrl: s
2185
2199
  }),
2186
2200
  signal: E.signal
2187
2201
  }).then((B) => {
2188
- !E.signal.aborted && B.status === "accepted" && D(B.artifact);
2202
+ !E.signal.aborted && B.status === "accepted" && j(B.artifact);
2189
2203
  }), () => E.abort();
2190
2204
  }, [
2191
- m,
2205
+ p,
2206
+ l,
2192
2207
  a,
2193
2208
  s,
2194
- i,
2195
- k
2196
- ]), te(() => {
2209
+ S
2210
+ ]), ne(() => {
2197
2211
  let E = !0;
2198
2212
  if (!$)
2199
- return ie(void 0), S(!0), () => {
2213
+ return ie(void 0), x(!0), () => {
2200
2214
  E = !1;
2201
2215
  };
2202
2216
  const B = new AbortController();
2203
- return S(!1), ie(void 0), Q(null), Fe({
2204
- endpoint: T,
2217
+ return x(!1), ie(void 0), Q(null), Fe({
2218
+ endpoint: k,
2205
2219
  signal: B.signal,
2206
2220
  pages: K.pages.map((_) => ({
2207
2221
  ..._,
2208
2222
  id: _.importPageId ?? _.id,
2209
2223
  importKind: _.importKind
2210
2224
  })),
2211
- assets: (n == null ? void 0 : n.getAssets("screens")) ?? []
2225
+ assets: (r == null ? void 0 : r.getAssets("screens")) ?? []
2212
2226
  }).then((_) => {
2213
2227
  E && (ie(_.baselineEnvironment), Q(_.graph));
2214
2228
  }).catch(() => {
2215
2229
  E && (ie(void 0), Q(null));
2216
2230
  }).finally(() => {
2217
- E && S(!0);
2231
+ E && x(!0);
2218
2232
  }), () => {
2219
2233
  E = !1, B.abort(), ie(void 0), Q(null);
2220
2234
  };
2221
2235
  }, [
2222
- n,
2223
2236
  r,
2237
+ o,
2224
2238
  $,
2225
- T
2226
- ]), te(() => {
2227
- y == null || y === K.previewOpen || (y ? K.openPreview({ notifyHost: !1 }) : K.closePreview({ notifyHost: !1 }));
2228
- }, [y]), k ? /* @__PURE__ */ b(ct, {}) : /* @__PURE__ */ b(
2239
+ k
2240
+ ]), ne(() => {
2241
+ m == null || m === K.previewOpen || (m ? K.openPreview({ notifyHost: !1 }) : K.closePreview({ notifyHost: !1 }));
2242
+ }, [m]), S ? /* @__PURE__ */ w(dt, {}) : /* @__PURE__ */ w(
2229
2243
  "div",
2230
2244
  {
2231
2245
  "data-pygmalion-storyboard-loading": "",
@@ -2244,60 +2258,63 @@ function $n({
2244
2258
  );
2245
2259
  }
2246
2260
  export {
2247
- kn as DESIGN_IMPORT_KINDS,
2248
- Sn as PygmalionCatalogDocument,
2249
- In as PygmalionCatalogMatrix,
2250
- vn as PygmalionCatalogSection,
2251
- $n as PygmalionEditor,
2252
- at as STORYBOARD_ENVIRONMENT_CONTROL,
2253
- Dn as STORYBOARD_ENVIRONMENT_QUERY,
2254
- Nn as SourceRefControl,
2255
- Rn as __debug,
2256
- zn as applyTokenOverride,
2257
- Qt as bootstrapPreviewArtifact,
2258
- _n as clearPygmalionPreviewCache,
2259
- Pn as createDesignComponentCatalog,
2260
- nn as createDesignComponentVariantMatrix,
2261
- xn as createDesignGalleryCatalog,
2262
- Fn as createDesignImportController,
2263
- jn as createDesignScreenCollection,
2264
- Gt as createPreviewArtifactHttpTransport,
2265
- wn as createPreviewCacheNamespace,
2266
- qt as createPreviewRecipeFingerprint,
2267
- bn as createStoryboardCaptureRecipeIdentity,
2268
- bt as createStoryboardGraph,
2269
- kt as createStoryboardGraphFromDiscovery,
2270
- Bn as createStoryboardGraphViewModel,
2271
- Un as createStoryboardRouteUrl,
2272
- Zt as designCatalogKey,
2273
- Be as designCatalogRegistryName,
2274
- Hn as expandDesignScreenCasesViewports,
2275
- Kn as expandDesignScreenCollectionViewports,
2261
+ zn as DESIGN_IMPORT_KINDS,
2262
+ In as PygmalionCatalogDocument,
2263
+ Pn as PygmalionCatalogMatrix,
2264
+ xn as PygmalionCatalogSection,
2265
+ Tn as PygmalionEditor,
2266
+ lt as STORYBOARD_ENVIRONMENT_CONTROL,
2267
+ _n as STORYBOARD_ENVIRONMENT_QUERY,
2268
+ Cn as SourceRefControl,
2269
+ An as __debug,
2270
+ Fn as applyTokenOverride,
2271
+ Yt as bootstrapPreviewArtifact,
2272
+ jn as clearPygmalionPreviewCache,
2273
+ Nn as createDesignComponentCatalog,
2274
+ on as createDesignComponentVariantMatrix,
2275
+ En as createDesignGalleryCatalog,
2276
+ Bn as createDesignImportController,
2277
+ Un as createDesignScreenCollection,
2278
+ Jt as createPreviewArtifactHttpTransport,
2279
+ vn as createPreviewCacheNamespace,
2280
+ Sn as createPreviewFrameFingerprint,
2281
+ je as createPreviewRecipeFingerprint,
2282
+ qt as createStoryboardCaptureRecipeIdentity,
2283
+ vt as createStoryboardGraph,
2284
+ zt as createStoryboardGraphFromDiscovery,
2285
+ Hn as createStoryboardGraphViewModel,
2286
+ Kn as createStoryboardRouteUrl,
2287
+ tn as designCatalogKey,
2288
+ Ue as designCatalogRegistryName,
2289
+ Gn as expandDesignScreenCasesViewports,
2290
+ Vn as expandDesignScreenCollectionViewports,
2276
2291
  qn as getRecommendedPygmalionPreviewConcurrency,
2277
- tt as getStoryboardBaselineEnvironment,
2292
+ rt as getStoryboardBaselineEnvironment,
2278
2293
  _e as getStoryboardDiscoveryBaselineEnvironment,
2279
- Gn as getStoryboardGraph,
2294
+ Jn as getStoryboardGraph,
2295
+ Ln as getViewportPresets,
2280
2296
  Fe as loadStoryboardDiscovery,
2281
- Jn as mergeScreenPresets,
2282
- Ke as mergeStoryboardEnvironment,
2283
- yn as publishStoryboardDiscovery,
2284
- Cn as pygmalionNavigate,
2285
- An as pygmalionOpenPreview,
2286
- On as pygmalionResetCurrentEdits,
2287
- Ln as reconstructRoutePreviewArtifactScreenshotV3,
2288
- Vn as reconstructRoutePreviewArtifactSnapshotV3,
2289
- Wn as resetTokenOverrides,
2290
- Et as resolveStoryboardScreenCases,
2291
- We as setComponentRegistry,
2292
- Xe as setPygmalionAppOrigin,
2293
- nt as setPygmalionPreviewConcurrency,
2294
- Ye as setPygmalionPreviewRevision,
2297
+ Wn as mergeScreenPresets,
2298
+ Ge as mergeStoryboardEnvironment,
2299
+ bn as publishStoryboardDiscovery,
2300
+ On as pygmalionNavigate,
2301
+ $n as pygmalionOpenPreview,
2302
+ Mn as pygmalionResetCurrentEdits,
2303
+ Qn as reconstructRoutePreviewArtifactScreenshotV3,
2304
+ Xn as reconstructRoutePreviewArtifactSnapshotV3,
2305
+ Yn as resetTokenOverrides,
2306
+ Rt as resolveStoryboardScreenCases,
2307
+ Qe as setComponentRegistry,
2308
+ Ze as setPygmalionAppOrigin,
2309
+ ot as setPygmalionPreviewConcurrency,
2310
+ et as setPygmalionPreviewRevision,
2295
2311
  ie as setStoryboardBaselineEnvironment,
2296
2312
  Q as setStoryboardGraph,
2297
- Qe as setTokens,
2298
- gt as storyboardScreenRecipeKey,
2299
- Qn as subscribeStoryboardGraph,
2300
- En as usePygmalionProject,
2301
- Wt as validatePreviewArtifactBundle,
2302
- qe as validateRoutePreviewArtifactV3Browser
2313
+ Xe as setTokens,
2314
+ Ye as setViewportPresets,
2315
+ wt as storyboardScreenRecipeKey,
2316
+ Zn as subscribeStoryboardGraph,
2317
+ Rn as usePygmalionProject,
2318
+ Xt as validatePreviewArtifactBundle,
2319
+ Ve as validateRoutePreviewArtifactV3Browser
2303
2320
  };