@pygmalionjs/pygmalion 0.2.33 → 0.2.34

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