@brucesantos/design-space 0.11.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,78 +1,78 @@
1
- const C = [
1
+ const j = [
2
2
  "success",
3
3
  "loading",
4
4
  "empty",
5
5
  "error",
6
6
  "slow"
7
7
  ];
8
- function j(e, r) {
9
- const o = e.split("/").filter(Boolean), t = M(r).split("/").filter(Boolean), a = {};
8
+ function I(e, t) {
9
+ const o = e.split("/").filter(Boolean), r = M(t).split("/").filter(Boolean), a = {};
10
10
  for (const [s, c] of o.entries()) {
11
11
  if (c === "*")
12
- return a["*"] = t.slice(s).join("/"), a;
13
- const m = t[s];
14
- if (m === void 0) return null;
12
+ return a["*"] = r.slice(s).join("/"), a;
13
+ const h = r[s];
14
+ if (h === void 0) return null;
15
15
  if (c.startsWith(":")) {
16
- a[c.slice(1)] = m;
16
+ a[c.slice(1)] = h;
17
17
  continue;
18
18
  }
19
- if (c !== m) return null;
19
+ if (c !== h) return null;
20
20
  }
21
- return o.length !== t.length ? null : a;
21
+ return o.length !== r.length ? null : a;
22
22
  }
23
- function P(e, r) {
24
- const o = [...e].sort((t, a) => I(a.path) - I(t.path));
25
- for (const t of o) {
26
- const a = j(t.path, r);
27
- if (a) return { definition: t, params: a };
23
+ function P(e, t) {
24
+ const o = [...e].sort((r, a) => C(a.path) - C(r.path));
25
+ for (const r of o) {
26
+ const a = I(r.path, t);
27
+ if (a) return { definition: r, params: a };
28
28
  }
29
29
  }
30
- function F(e, r = {}) {
30
+ function E(e, t = {}) {
31
31
  const o = (a) => {
32
- const s = r[a];
32
+ const s = t[a];
33
33
  return typeof s == "string" && s.length > 0 ? s : void 0;
34
- }, t = [];
34
+ }, r = [];
35
35
  for (const a of e.split("/").filter(Boolean)) {
36
36
  if (a === "*") {
37
37
  const c = o("*");
38
- c && t.push(...c.split("/").filter(Boolean).map(encodeURIComponent));
38
+ c && r.push(...c.split("/").filter(Boolean).map(encodeURIComponent));
39
39
  continue;
40
40
  }
41
41
  const s = a.startsWith(":") ? o(a.slice(1)) : void 0;
42
- t.push(s === void 0 ? a : encodeURIComponent(s));
42
+ r.push(s === void 0 ? a : encodeURIComponent(s));
43
43
  }
44
- return `/${t.join("/")}`;
44
+ return `/${r.join("/")}`;
45
45
  }
46
- function I(e) {
47
- const r = e.split("/").filter(Boolean);
48
- let o = r.length;
49
- for (const t of r)
50
- t === "*" ? o -= 2 : t.startsWith(":") ? o += 1 : o += 4;
46
+ function C(e) {
47
+ const t = e.split("/").filter(Boolean);
48
+ let o = t.length;
49
+ for (const r of t)
50
+ r === "*" ? o -= 2 : r.startsWith(":") ? o += 1 : o += 4;
51
51
  return o;
52
52
  }
53
53
  function M(e) {
54
- const r = e.split("?")[0] ?? e;
54
+ const t = e.split("?")[0] ?? e;
55
55
  try {
56
- return decodeURI(r);
56
+ return decodeURI(t);
57
57
  } catch {
58
- return r;
58
+ return t;
59
59
  }
60
60
  }
61
61
  const R = /^[a-z0-9]+([.\-][a-z0-9]+)*$/, z = /^[A-Za-z0-9][A-Za-z0-9_.-]*$/;
62
62
  function u(e) {
63
63
  return typeof e == "string" && e.trim().length > 0;
64
64
  }
65
- function q(e, r) {
66
- const o = [], t = u(e?.id) ? `scenario:${e.id}` : `scenario[${r ?? "?"}]`, a = (c) => o.push({ level: "error", where: t, message: c }), s = (c) => o.push({ level: "warning", where: t, message: c });
65
+ function q(e, t) {
66
+ const o = [], r = u(e?.id) ? `scenario:${e.id}` : `scenario[${t ?? "?"}]`, a = (c) => o.push({ level: "error", where: r, message: c }), s = (c) => o.push({ level: "warning", where: r, message: c });
67
67
  return u(e?.id) ? R.test(e.id) || a(
68
68
  "`id` deve ser minúsculo, em kebab-case, com pontos opcionais: `requests.approve-blocked` ou `approve-blocked`."
69
- ) : a("`id` é obrigatório."), u(e?.title) || a("`title` é obrigatório e deve usar o vocabulário do negócio."), u(e?.route) ? e.route.startsWith("/") || a("`route` deve começar com `/`.") : a("`route` é obrigatório."), e?.persona !== void 0 && !u(e.persona) && a("`persona`, quando informada, deve ser o id de uma persona registrada."), u(e?.fixture) || a("`fixture` é obrigatório. O padrão do ambiente é dado sintético (D-05)."), e?.components !== void 0 && !Array.isArray(e.components) && a("`components`, quando informado, deve ser uma lista de ids de componente."), e?.network && !C.includes(e.network) && a(`\`network\` deve ser um de: ${C.join(", ")}.`), e?.expected?.length || s(
69
+ ) : a("`id` é obrigatório."), u(e?.title) || a("`title` é obrigatório e deve usar o vocabulário do negócio."), u(e?.route) ? e.route.startsWith("/") || a("`route` deve começar com `/`.") : a("`route` é obrigatório."), e?.persona !== void 0 && !u(e.persona) && a("`persona`, quando informada, deve ser o id de uma persona registrada."), u(e?.fixture) || a("`fixture` é obrigatório. O padrão do ambiente é dado sintético (D-05)."), e?.components !== void 0 && !Array.isArray(e.components) && a("`components`, quando informado, deve ser uma lista de ids de componente."), e?.network && !j.includes(e.network) && a(`\`network\` deve ser um de: ${j.join(", ")}.`), e?.expected?.length || s(
70
70
  "Sem `expected`, o cenário não vira caso verificável no handoff — é tela bonita sem critério (risco: prototype theater)."
71
71
  ), o;
72
72
  }
73
73
  function Q(e) {
74
- const r = [], o = (l, n, i) => r.push({ level: l, where: n, message: i }), t = new Set(e.personas?.map((l) => l.id) ?? []), a = new Set(e.fixtures?.map((l) => l.id) ?? []), s = new Set(e.rules?.map((l) => l.id) ?? []), c = /* @__PURE__ */ new Set();
75
- u(e.id) || o("error", "product", "`id` é obrigatório."), u(e.name) || o("error", "product", "`name` é obrigatório."), !e.routes?.length && e.scenarios?.length && o("error", "product", "`routes` está vazio: nenhum cenário conseguirá renderizar."), e.defaultPersona !== void 0 && !t.has(e.defaultPersona) && o(
74
+ const t = [], o = (l, n, i) => t.push({ level: l, where: n, message: i }), r = new Set(e.personas?.map((l) => l.id) ?? []), a = new Set(e.fixtures?.map((l) => l.id) ?? []), s = new Set(e.rules?.map((l) => l.id) ?? []), c = /* @__PURE__ */ new Set();
75
+ u(e.id) || o("error", "product", "`id` é obrigatório."), u(e.name) || o("error", "product", "`name` é obrigatório."), !e.routes?.length && e.scenarios?.length && o("error", "product", "`routes` está vazio: nenhum cenário conseguirá renderizar."), e.defaultPersona !== void 0 && !r.has(e.defaultPersona) && o(
76
76
  "error",
77
77
  "product",
78
78
  `\`defaultPersona\` aponta para persona não registrada: \`${e.defaultPersona}\`.`
@@ -81,27 +81,31 @@ function Q(e) {
81
81
  "product",
82
82
  "`modules` foi removido na 0.8.0 e é ignorado: cada rota é uma tela, e os cenários da rota são as variações dela."
83
83
  );
84
- const m = /* @__PURE__ */ new Set();
84
+ const h = /* @__PURE__ */ new Set();
85
85
  for (const [l, n] of (e.routes ?? []).entries()) {
86
86
  const i = `route:${n?.path ?? l}`;
87
87
  if (!u(n?.path)) {
88
88
  o("error", i, "`path` é obrigatório.");
89
89
  continue;
90
90
  }
91
- n.path.startsWith("/") || o("error", i, "`path` deve começar com `/`."), m.has(n.path) && o("error", i, `\`path\` duplicado: ${n.path}. Cada rota é uma tela.`), m.add(n.path), typeof n.screen != "function" && typeof n.screen != "object" && o("error", i, "`screen` é obrigatório."), n.name !== void 0 && !u(n.name) && o("warning", i, "`name` vazio: a tela aparece com o título do primeiro cenário."), n.group !== void 0 && !u(n.group) && o("warning", i, "`group` vazio: a tela aparece fora de qualquer fluxo."), n.expected !== void 0 && !Array.isArray(n.expected) && o("error", i, "`expected`, quando informado, deve ser uma lista de frases."), n.components !== void 0 && !Array.isArray(n.components) && o("error", i, "`components`, quando informado, deve ser uma lista de ids de componente."), n.controls !== void 0 && (Array.isArray(n.controls) ? _(n.controls, i, o) : o("error", i, "`controls`, quando informado, deve ser uma lista de grupos de controles."));
91
+ n.path.startsWith("/") || o("error", i, "`path` deve começar com `/`."), h.has(n.path) && o("error", i, `\`path\` duplicado: ${n.path}. Cada rota é uma tela.`), h.add(n.path), typeof n.screen != "function" && typeof n.screen != "object" && o("error", i, "`screen` é obrigatório."), n.name !== void 0 && !u(n.name) && o("warning", i, "`name` vazio: a tela aparece com o título do primeiro cenário."), n.group !== void 0 && !u(n.group) && o("warning", i, "`group` vazio: a tela aparece fora de qualquer fluxo."), n.expected !== void 0 && !Array.isArray(n.expected) && o("error", i, "`expected`, quando informado, deve ser uma lista de frases."), n.components !== void 0 && !Array.isArray(n.components) && o("error", i, "`components`, quando informado, deve ser uma lista de ids de componente."), n.controls !== void 0 && (Array.isArray(n.controls) ? L(n.controls, i, o) : o("error", i, "`controls`, quando informado, deve ser uma lista de grupos de controles."));
92
92
  }
93
93
  const f = /* @__PURE__ */ new Set();
94
94
  for (const [l, n] of (e.components ?? []).entries()) {
95
95
  const i = `component:${n?.id ?? l}`;
96
- u(n?.id) ? R.test(n.id) ? f.has(n.id) ? o("error", i, `\`id\` duplicado: ${n.id}.`) : f.add(n.id) : o("error", i, "`id` deve ser minúsculo em kebab-case ou usar pontos para agrupamento.") : o("error", i, "`id` é obrigatório."), u(n?.name) || o("error", i, "`name` é obrigatório."), typeof n?.preview != "function" && typeof n?.preview != "object" && o("error", i, "`preview` é obrigatório."), n?.source !== void 0 && typeof n.source != "string" && o("error", i, "`source`, quando informado, é texto livre.");
96
+ u(n?.id) ? R.test(n.id) ? f.has(n.id) ? o("error", i, `\`id\` duplicado: ${n.id}.`) : f.add(n.id) : o("error", i, "`id` deve ser minúsculo em kebab-case ou usar pontos para agrupamento.") : o("error", i, "`id` é obrigatório."), u(n?.name) || o("error", i, "`name` é obrigatório."), typeof n?.preview != "function" && typeof n?.preview != "object" && o("error", i, "`preview` é obrigatório."), n?.source !== void 0 && typeof n.source != "string" && o("error", i, "`source`, quando informado, é texto livre."), n?.implementation !== void 0 && (Array.isArray(n.implementation) ? n.implementation : [n.implementation]).some((g) => typeof g != "function" && (typeof g != "object" || g === null)) && o(
97
+ "error",
98
+ i,
99
+ "`implementation`, quando informado, é o componente React real (ou uma lista deles), não o nome."
100
+ );
97
101
  const p = /* @__PURE__ */ new Set();
98
- for (const [b, v] of (n?.fixtures ?? []).entries()) {
99
- const h = `${i}/fixture:${v?.id ?? b}`;
100
- u(v?.id) ? R.test(v.id) ? p.has(v.id) ? o("error", h, `Id de fixture do componente duplicado: \`${v.id}\`.`) : p.add(v.id) : o(
102
+ for (const [b, g] of (n?.fixtures ?? []).entries()) {
103
+ const v = `${i}/fixture:${g?.id ?? b}`;
104
+ u(g?.id) ? R.test(g.id) ? p.has(g.id) ? o("error", v, `Id de fixture do componente duplicado: \`${g.id}\`.`) : p.add(g.id) : o(
101
105
  "error",
102
- h,
103
- `Id de fixture do componente inválido: \`${v.id}\`. Use minúsculas em kebab-case.`
104
- ) : o("error", h, "`id` da fixture do componente é obrigatório."), u(v?.label) || o("error", h, "`label` da fixture do componente é obrigatório."), (!v || !("data" in v)) && o("error", h, "`data` da fixture do componente é obrigatório.");
106
+ v,
107
+ `Id de fixture do componente inválido: \`${g.id}\`. Use minúsculas em kebab-case.`
108
+ ) : o("error", v, "`id` da fixture do componente é obrigatório."), u(g?.label) || o("error", v, "`label` da fixture do componente é obrigatório."), (!g || !("data" in g)) && o("error", v, "`data` da fixture do componente é obrigatório.");
105
109
  }
106
110
  n?.defaultFixture && !p.has(n.defaultFixture) && o(
107
111
  "error",
@@ -112,7 +116,7 @@ function Q(e) {
112
116
  for (const l of e.routes ?? []) {
113
117
  if (!u(l?.path)) continue;
114
118
  const n = `route:${l.path}`;
115
- B(e, l, n, o);
119
+ W(e, l, n, o);
116
120
  for (const i of Array.isArray(l.components) ? l.components : [])
117
121
  f.has(i) || o(
118
122
  "warning",
@@ -127,9 +131,9 @@ function Q(e) {
127
131
  );
128
132
  }
129
133
  for (const [l, n] of (e.scenarios ?? []).entries()) {
130
- r.push(...q(n, l));
134
+ t.push(...q(n, l));
131
135
  const i = `scenario:${n?.id ?? l}`;
132
- n?.id && (c.has(n.id) && o("error", i, `\`id\` duplicado: ${n.id}.`), c.add(n.id)), n?.persona && !t.has(n.persona) && o("error", i, `Persona não registrada: \`${n.persona}\`.`), n?.fixture && !a.has(n.fixture) && o("error", i, `Fixture não registrada: \`${n.fixture}\`.`);
136
+ n?.id && (c.has(n.id) && o("error", i, `\`id\` duplicado: ${n.id}.`), c.add(n.id)), n?.persona && !r.has(n.persona) && o("error", i, `Persona não registrada: \`${n.persona}\`.`), n?.fixture && !a.has(n.fixture) && o("error", i, `Fixture não registrada: \`${n.fixture}\`.`);
133
137
  for (const p of n?.rules ?? [])
134
138
  s.has(p) || o("error", i, `Regra não registrada: \`${p}\`.`);
135
139
  for (const p of Array.isArray(n?.components) ? n.components : [])
@@ -142,27 +146,27 @@ function Q(e) {
142
146
  if (!n.controls || typeof n.controls != "object" || Array.isArray(n.controls))
143
147
  o("error", i, "`controls`, quando informado, é um objeto de id do controle → valor.");
144
148
  else if (n.route) {
145
- const p = P(e.routes ?? [], n.route.split("?")[0] ?? n.route), b = Array.isArray(p?.definition.controls) ? p.definition.controls : [], v = new Map(
146
- b.flatMap((h) => Array.isArray(h?.controls) ? h.controls : []).map((h) => [
147
- h?.id,
148
- h
149
+ const p = P(e.routes ?? [], n.route.split("?")[0] ?? n.route), b = Array.isArray(p?.definition.controls) ? p.definition.controls : [], g = new Map(
150
+ b.flatMap((v) => Array.isArray(v?.controls) ? v.controls : []).map((v) => [
151
+ v?.id,
152
+ v
149
153
  ])
150
154
  );
151
- for (const [h, U] of Object.entries(n.controls)) {
152
- const x = v.get(h);
153
- x ? (x.options ?? []).some((A) => A?.value === U) || o(
155
+ for (const [v, O] of Object.entries(n.controls)) {
156
+ const A = g.get(v);
157
+ A ? (A.options ?? []).some((x) => x?.value === O) || o(
154
158
  "error",
155
159
  i,
156
- `Valor \`${U}\` não é opção do controle \`${h}\`. Opções: ${(x.options ?? []).map((A) => `\`${A?.value}\``).join(", ")}.`
160
+ `Valor \`${O}\` não é opção do controle \`${v}\`. Opções: ${(A.options ?? []).map((x) => `\`${x?.value}\``).join(", ")}.`
157
161
  ) : o(
158
162
  "error",
159
163
  i,
160
- `Controle \`${h}\` não existe na tela \`${p?.definition.path ?? n.route}\`.`
164
+ `Controle \`${v}\` não existe na tela \`${p?.definition.path ?? n.route}\`.`
161
165
  );
162
166
  }
163
167
  }
164
168
  }
165
- n?.route && !L(n.route, e) && o(
169
+ n?.route && !_(n.route, e) && o(
166
170
  "error",
167
171
  i,
168
172
  `Rota \`${n.route}\` não casa com nenhuma rota declarada. O deep link abriria a tela de rota inexistente.`
@@ -173,18 +177,18 @@ function Q(e) {
173
177
  "warning",
174
178
  "product",
175
179
  "A fonte padrão não é `fixtures`. O padrão do ambiente é dado sintético e determinístico (D-05); API real entra como adapter opcional, com justificativa."
176
- )), r;
180
+ )), t;
177
181
  }
178
- function _(e, r, o) {
179
- const t = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
182
+ function L(e, t, o) {
183
+ const r = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
180
184
  for (const [s, c] of e.entries()) {
181
- const m = `${r}/group:${c?.id ?? s}`;
182
- if (u(c?.id) ? t.has(c.id) ? o("error", m, `\`id\` de grupo duplicado na tela: \`${c.id}\`.`) : t.add(c.id) : o("error", m, "`id` do grupo de controles é obrigatório."), u(c?.title) || o("error", m, "`title` do grupo é obrigatório."), !Array.isArray(c?.controls)) {
183
- o("error", m, "`controls` do grupo deve ser uma lista.");
185
+ const h = `${t}/group:${c?.id ?? s}`;
186
+ if (u(c?.id) ? r.has(c.id) ? o("error", h, `\`id\` de grupo duplicado na tela: \`${c.id}\`.`) : r.add(c.id) : o("error", h, "`id` do grupo de controles é obrigatório."), u(c?.title) || o("error", h, "`title` do grupo é obrigatório."), !Array.isArray(c?.controls)) {
187
+ o("error", h, "`controls` do grupo deve ser uma lista.");
184
188
  continue;
185
189
  }
186
190
  for (const [f, d] of c.controls.entries()) {
187
- const l = `${m}/control:${d?.id ?? f}`;
191
+ const l = `${h}/control:${d?.id ?? f}`;
188
192
  u(d?.id) ? z.test(d.id) ? a.has(d.id) ? o("error", l, `\`id\` de controle duplicado na tela: \`${d.id}\`.`) : a.add(d.id) : o(
189
193
  "error",
190
194
  l,
@@ -206,105 +210,105 @@ function _(e, r, o) {
206
210
  }
207
211
  }
208
212
  }
209
- function B(e, r, o, t) {
210
- const a = r.path.split("/").filter((f) => f.startsWith(":") || f === "*").map((f) => f === "*" ? "*" : f.slice(1)), s = r.params;
213
+ function W(e, t, o, r) {
214
+ const a = t.path.split("/").filter((f) => f.startsWith(":") || f === "*").map((f) => f === "*" ? "*" : f.slice(1)), s = t.params;
211
215
  if (s !== void 0 && (!s || typeof s != "object" || Array.isArray(s))) {
212
- t("error", o, "`params`, quando informado, é um objeto de nome do parâmetro → valor de exemplo.");
216
+ r("error", o, "`params`, quando informado, é um objeto de nome do parâmetro → valor de exemplo.");
213
217
  return;
214
218
  }
215
219
  const c = s ?? {};
216
220
  for (const [f, d] of Object.entries(c))
217
- a.includes(f) ? u(d) || t("warning", o, `\`params.${f}\` vazio: a tela abre com \`:${f}\` literal.`) : t("warning", o, `\`params.${f}\` não é parâmetro de \`${r.path}\` e é ignorado.`);
218
- const m = a.filter((f) => f !== "*" && !u(c[f]));
219
- if (m.length > 0) {
221
+ a.includes(f) ? u(d) || r("warning", o, `\`params.${f}\` vazio: a tela abre com \`:${f}\` literal.`) : r("warning", o, `\`params.${f}\` não é parâmetro de \`${t.path}\` e é ignorado.`);
222
+ const h = a.filter((f) => f !== "*" && !u(c[f]));
223
+ if (h.length > 0) {
220
224
  (e.scenarios ?? []).some(
221
- (d) => u(d?.route) && P(e.routes ?? [], d.route.split("?")[0] ?? d.route)?.definition.path === r.path
222
- ) || t(
225
+ (d) => u(d?.route) && P(e.routes ?? [], d.route.split("?")[0] ?? d.route)?.definition.path === t.path
226
+ ) || r(
223
227
  "warning",
224
228
  o,
225
- `Sem exemplo para ${m.map((d) => `\`:${d}\``).join(", ")} e sem cenário na rota: a tela abre no caminho literal \`${r.path}\`. Declare \`params: { ${m.map((d) => `${d}: "…"`).join(", ")} }\`.`
229
+ `Sem exemplo para ${h.map((d) => `\`:${d}\``).join(", ")} e sem cenário na rota: a tela abre no caminho literal \`${t.path}\`. Declare \`params: { ${h.map((d) => `${d}: "…"`).join(", ")} }\`.`
226
230
  );
227
231
  return;
228
232
  }
229
233
  if (a.length > 0) {
230
- const f = F(r.path, c), d = P(e.routes ?? [], f);
231
- d && d.definition.path !== r.path && t(
234
+ const f = E(t.path, c), d = P(e.routes ?? [], f);
235
+ d && d.definition.path !== t.path && r(
232
236
  "warning",
233
237
  o,
234
238
  `Os exemplos de \`params\` montam \`${f}\`, que abre a rota \`${d.definition.path}\`, não esta.`
235
239
  );
236
240
  }
237
241
  }
238
- function L(e, r) {
242
+ function _(e, t) {
239
243
  const o = e.split("?")[0] ?? e;
240
- return (r.routes ?? []).some((t) => N(t.path, o));
244
+ return (t.routes ?? []).some((r) => B(r.path, o));
241
245
  }
242
- function N(e, r) {
243
- const o = e.split("/").filter(Boolean), t = r.split("/").filter(Boolean);
246
+ function B(e, t) {
247
+ const o = e.split("/").filter(Boolean), r = t.split("/").filter(Boolean);
244
248
  for (const [a, s] of o.entries()) {
245
249
  if (s === "*") return !0;
246
- const c = t[a];
250
+ const c = r[a];
247
251
  if (c === void 0) return !1;
248
252
  if (!s.startsWith(":") && s !== c)
249
253
  return !1;
250
254
  }
251
- return o.length === t.length;
255
+ return o.length === r.length;
252
256
  }
253
257
  function X(e) {
254
- return e.some((r) => r.level === "error");
258
+ return e.some((t) => t.level === "error");
255
259
  }
256
260
  function Y(e) {
257
- return e.length === 0 ? "Nenhum problema encontrado." : e.map((r) => `${r.level === "error" ? "✖" : "▲"} ${r.where}
258
- ${r.message}`).join(`
261
+ return e.length === 0 ? "Nenhum problema encontrado." : e.map((t) => `${t.level === "error" ? "✖" : "▲"} ${t.where}
262
+ ${t.message}`).join(`
259
263
  `);
260
264
  }
261
- const $ = {
265
+ const w = {
262
266
  enabled: "handoff",
263
267
  scenario: "allowScenario",
264
268
  route: "allowRoute",
265
269
  component: "allowComponent"
266
270
  };
267
- function J(e) {
268
- if (e.get($.enabled) === "1")
271
+ function ee(e) {
272
+ if (e.get(w.enabled) === "1")
269
273
  return k({
270
- scenarios: e.getAll($.scenario),
271
- routes: e.getAll($.route),
272
- components: e.getAll($.component)
274
+ scenarios: e.getAll(w.scenario),
275
+ routes: e.getAll(w.route),
276
+ components: e.getAll(w.component)
273
277
  });
274
278
  }
275
- function W(e, r) {
276
- for (const t of Object.values($)) e.delete(t);
277
- if (!r) return;
278
- e.set($.enabled, "1");
279
- const o = k(r);
280
- for (const t of o.scenarios ?? []) e.append($.scenario, t);
281
- for (const t of o.routes ?? []) e.append($.route, t);
282
- for (const t of o.components ?? []) e.append($.component, t);
279
+ function N(e, t) {
280
+ for (const r of Object.values(w)) e.delete(r);
281
+ if (!t) return;
282
+ e.set(w.enabled, "1");
283
+ const o = k(t);
284
+ for (const r of o.scenarios ?? []) e.append(w.scenario, r);
285
+ for (const r of o.routes ?? []) e.append(w.route, r);
286
+ for (const r of o.components ?? []) e.append(w.component, r);
283
287
  }
284
288
  function k(e) {
285
- const r = S(e.scenarios), o = S(e.routes), t = S(e.components);
289
+ const t = S(e.scenarios), o = S(e.routes), r = S(e.components);
286
290
  return {
287
- ...r.length ? { scenarios: r } : {},
291
+ ...t.length ? { scenarios: t } : {},
288
292
  ...o.length ? { routes: o } : {},
289
- ...t.length ? { components: t } : {}
293
+ ...r.length ? { components: r } : {}
290
294
  };
291
295
  }
292
- function D(e, r) {
293
- return !e || !!(r && e.scenarios?.includes(r));
296
+ function D(e, t) {
297
+ return !e || !!(t && e.scenarios?.includes(t));
294
298
  }
295
- function ee(e, r) {
296
- return !e || !!(r && e.components?.includes(r));
299
+ function oe(e, t) {
300
+ return !e || !!(t && e.components?.includes(t));
297
301
  }
298
- function oe(e, r, o = []) {
299
- return !e || r === "/" ? !0 : [
302
+ function te(e, t, o = []) {
303
+ return !e || t === "/" ? !0 : [
300
304
  ...e.routes ?? [],
301
305
  ...o.filter((a) => D(e, a.id)).map((a) => a.route)
302
- ].some((a) => j(a, r) !== null);
306
+ ].some((a) => I(a, t) !== null);
303
307
  }
304
308
  function S(e) {
305
- return [...new Set((e ?? []).map((r) => r.trim()).filter(Boolean))].sort();
309
+ return [...new Set((e ?? []).map((t) => t.trim()).filter(Boolean))].sort();
306
310
  }
307
- const g = {
311
+ const m = {
308
312
  scenario: "scenario",
309
313
  component: "component",
310
314
  persona: "persona",
@@ -322,178 +326,190 @@ const g = {
322
326
  zoom: "zoom",
323
327
  rotated: "rotate",
324
328
  highlight: "highlight"
325
- }, w = "c.", H = /* @__PURE__ */ new Set([
326
- ...Object.values(g),
327
- ...Object.values($)
329
+ }, y = "c.", H = /* @__PURE__ */ new Set([
330
+ ...Object.values(m),
331
+ ...Object.values(w)
328
332
  ]);
329
333
  function re(e) {
330
- return e.startsWith(w) || H.has(e);
334
+ return e.startsWith(y) || H.has(e);
331
335
  }
332
- function te(e) {
333
- const r = typeof e == "string" ? new URLSearchParams(e) : e, o = {};
334
- for (const [t, a] of r) {
335
- if (!t.startsWith(w)) continue;
336
- const s = t.slice(w.length);
336
+ function ne(e) {
337
+ const t = typeof e == "string" ? new URLSearchParams(e) : e, o = {};
338
+ for (const [r, a] of t) {
339
+ if (!r.startsWith(y)) continue;
340
+ const s = r.slice(y.length);
337
341
  s && (o[s] = a);
338
342
  }
339
343
  return o;
340
344
  }
341
- function ne(e) {
342
- for (const r of [...e.keys()])
343
- r.startsWith(w) && e.delete(r);
345
+ function ae(e) {
346
+ for (const t of [...e.keys()])
347
+ t.startsWith(y) && e.delete(t);
344
348
  }
345
349
  function G(e) {
346
350
  return typeof e == "boolean" ? e ? "1" : "0" : String(e);
347
351
  }
348
- function T(e, r = {}) {
349
- for (const [o, t] of Object.entries(r)) {
350
- if (t == null) continue;
352
+ function F(e, t = {}) {
353
+ for (const [o, r] of Object.entries(t)) {
354
+ if (r == null) continue;
351
355
  if (o === "handoff") {
352
- W(e, t);
356
+ N(e, r);
353
357
  continue;
354
358
  }
355
359
  if (o === "screenControls") {
356
- for (const [s, c] of Object.entries(t))
357
- e.set(`${w}${s}`, c);
360
+ for (const [s, c] of Object.entries(r))
361
+ e.set(`${y}${s}`, c);
358
362
  continue;
359
363
  }
360
- const a = g[o];
361
- a && e.set(a, G(t));
364
+ const a = m[o];
365
+ a && e.set(a, G(r));
362
366
  }
363
367
  }
364
- const y = "ds-frame", K = "data-ds-frame", ae = "data-ds-component", E = [
365
- g.chromeTheme,
366
- g.chrome,
367
- g.inspector,
368
- g.panelTab,
369
- g.zoom,
370
- g.rotated
368
+ const $ = "ds-frame", K = "data-ds-frame", ie = "data-ds-component", T = [
369
+ m.chromeTheme,
370
+ m.chrome,
371
+ m.inspector,
372
+ m.panelTab,
373
+ m.zoom,
374
+ m.rotated
371
375
  ];
372
- function ie(e, r) {
373
- const o = new URLSearchParams(r);
374
- for (const t of E) o.delete(t);
375
- return o.delete(y), o.set(y, "1"), `${e || "/"}?${o.toString()}`;
376
- }
377
- function se(e) {
378
- const r = new URL(e, "http://design-space.invalid");
379
- r.searchParams.delete(y);
380
- const o = r.searchParams.toString();
381
- return { path: r.pathname || "/", search: o ? `?${o}` : "" };
376
+ function V(e, t) {
377
+ const o = new URLSearchParams(t);
378
+ for (const r of T) o.delete(r);
379
+ return o.delete($), o.set($, "1"), `${e || "/"}?${o.toString()}`;
380
+ }
381
+ function se(e, t, o) {
382
+ let { path: r, search: a } = o;
383
+ if (e)
384
+ try {
385
+ const c = new URL(e);
386
+ c.origin === t && ({ pathname: r, search: a } = c);
387
+ } catch {
388
+ }
389
+ const s = new URLSearchParams(a);
390
+ return s.delete(m.viewport), s.delete(m.customWidth), V(r, `?${s.toString()}`);
382
391
  }
383
392
  function ce(e) {
384
- const r = new URL(e, "http://design-space.invalid");
385
- return `${r.pathname}|${r.searchParams.get(g.component) ?? ""}`;
386
- }
387
- function le(e, r) {
388
- const o = new URLSearchParams(e), t = new URLSearchParams(r);
389
- o.delete(y);
390
- for (const s of E) {
393
+ const t = new URL(e, "http://design-space.invalid");
394
+ t.searchParams.delete($);
395
+ const o = t.searchParams.toString();
396
+ return { path: t.pathname || "/", search: o ? `?${o}` : "" };
397
+ }
398
+ function le(e) {
399
+ const t = new URL(e, "http://design-space.invalid");
400
+ return `${t.pathname}|${t.searchParams.get(m.component) ?? ""}`;
401
+ }
402
+ function de(e, t) {
403
+ const o = new URLSearchParams(e), r = new URLSearchParams(t);
404
+ o.delete($);
405
+ for (const s of T) {
391
406
  o.delete(s);
392
- const c = t.get(s);
407
+ const c = r.get(s);
393
408
  c !== null && o.set(s, c);
394
409
  }
395
410
  const a = o.toString();
396
411
  return a ? `?${a}` : "";
397
412
  }
398
- function V(e) {
413
+ function Z(e) {
399
414
  if (!e || typeof e != "object") return !1;
400
- const r = e;
401
- if (r.ds !== 1 || typeof r.type != "string") return !1;
402
- switch (r.type) {
415
+ const t = e;
416
+ if (t.ds !== 1 || typeof t.type != "string") return !1;
417
+ switch (t.type) {
403
418
  case "ready":
404
419
  case "location":
405
- return typeof r.url == "string";
420
+ return typeof t.url == "string";
406
421
  case "navigate":
407
- return typeof r.url == "string";
422
+ return typeof t.url == "string";
408
423
  case "shortcut":
409
- return ["C", "K", "F"].includes(r.key);
424
+ return ["C", "K", "F"].includes(t.key);
410
425
  default:
411
426
  return !1;
412
427
  }
413
428
  }
414
- function de(e, r) {
415
- if (e.origin === r.origin && !(!r.source || e.source !== r.source))
416
- return V(e.data) ? e.data : void 0;
429
+ function fe(e, t) {
430
+ if (e.origin === t.origin && !(!t.source || e.source !== t.source))
431
+ return Z(e.data) ? e.data : void 0;
417
432
  }
418
- function fe(e, r, o) {
433
+ function ue(e, t, o) {
419
434
  try {
420
- e?.postMessage(r, o);
435
+ e?.postMessage(t, o);
421
436
  } catch {
422
437
  }
423
438
  }
424
- function ue(e = typeof window > "u" ? void 0 : window) {
439
+ function pe(e = typeof window > "u" ? void 0 : window) {
425
440
  if (!e) return !1;
426
- if (new URLSearchParams(e.location.search).get(y) === "1") return !0;
441
+ if (new URLSearchParams(e.location.search).get($) === "1") return !0;
427
442
  try {
428
443
  return !!e.frameElement?.hasAttribute(K);
429
444
  } catch {
430
445
  return !1;
431
446
  }
432
447
  }
433
- function O(e = {}) {
434
- const r = e.branchUrl || void 0, o = e.deploymentUrl || void 0, t = e.commit || void 0, a = e.env || "development", s = r && `https://${r}` || o && `https://${o}` || (typeof window < "u" ? window.location.origin : "http://localhost:5173");
448
+ function U(e = {}) {
449
+ const t = e.branchUrl || void 0, o = e.deploymentUrl || void 0, r = e.commit || void 0, a = e.env || "development", s = t && `https://${t}` || o && `https://${o}` || (typeof window < "u" ? window.location.origin : "http://localhost:5173");
435
450
  return {
436
451
  env: a,
437
452
  origin: s.replace(/\/$/, ""),
438
- branchUrl: r,
453
+ branchUrl: t,
439
454
  deploymentUrl: o,
440
455
  branch: e.branch || void 0,
441
- commit: t,
442
- shortCommit: t?.slice(0, 7),
456
+ commit: r,
457
+ shortCommit: r?.slice(0, 7),
443
458
  isDeployed: a === "preview" || a === "production"
444
459
  };
445
460
  }
446
- function Z(e, r = {}) {
447
- const o = r.origin ?? O().origin, t = new URL(e.route, o);
448
- return t.searchParams.set(g.scenario, e.id), e.persona && t.searchParams.set(g.persona, e.persona), t.searchParams.set(g.fixture, e.fixture), e.network && e.network !== "success" && t.searchParams.set(g.network, e.network), T(t.searchParams, r.overrides), t.toString();
461
+ function J(e, t = {}) {
462
+ const o = t.origin ?? U().origin, r = new URL(e.route, o);
463
+ return r.searchParams.set(m.scenario, e.id), e.persona && r.searchParams.set(m.persona, e.persona), r.searchParams.set(m.fixture, e.fixture), e.network && e.network !== "success" && r.searchParams.set(m.network, e.network), F(r.searchParams, t.overrides), r.toString();
449
464
  }
450
- function pe(e, r = {}) {
451
- const o = r.origin ?? O().origin, t = new URL("/", o), a = r.fixture ?? e.fixtures?.find((s) => s.id === e.defaultFixture)?.id ?? e.fixtures?.[0]?.id;
452
- return t.searchParams.set(g.component, e.id), a && t.searchParams.set(g.fixture, a), T(t.searchParams, r.overrides), t.toString();
465
+ function me(e, t = {}) {
466
+ const o = t.origin ?? U().origin, r = new URL("/", o), a = t.fixture ?? e.fixtures?.find((s) => s.id === e.defaultFixture)?.id ?? e.fixtures?.[0]?.id;
467
+ return r.searchParams.set(m.component, e.id), a && r.searchParams.set(m.fixture, a), F(r.searchParams, t.overrides), r.toString();
453
468
  }
454
- function me(e, r) {
455
- const o = r.commit ?? O().commit;
469
+ function he(e, t) {
470
+ const o = t.commit ?? U().commit;
456
471
  if (!o) return;
457
- const t = r.template.replaceAll("{shortCommit}", o.slice(0, 7)).replaceAll("{commit}", o);
458
- return Z(e, { origin: t });
472
+ const r = t.template.replaceAll("{shortCommit}", o.slice(0, 7)).replaceAll("{commit}", o);
473
+ return J(e, { origin: r });
459
474
  }
460
475
  export {
461
- Y as A,
462
- X as B,
463
- w as C,
464
- j as D,
465
- k as E,
466
- y as F,
467
- G,
468
- $ as H,
469
- q as I,
470
- C as N,
471
- g as P,
472
- ee as a,
473
- oe as b,
474
- te as c,
475
- W as d,
476
- fe as e,
477
- se as f,
478
- de as g,
476
+ me as A,
477
+ Y as B,
478
+ y as C,
479
+ X as D,
480
+ I as E,
481
+ $ as F,
482
+ k as G,
483
+ w as H,
484
+ G as I,
485
+ q as J,
486
+ j as N,
487
+ m as P,
488
+ oe as a,
489
+ te as b,
490
+ ne as c,
491
+ N as d,
492
+ ue as e,
493
+ ce as f,
494
+ fe as g,
479
495
  D as h,
480
496
  re as i,
481
- ne as j,
482
- Z as k,
483
- T as l,
484
- E as m,
485
- ce as n,
497
+ ae as j,
498
+ J as k,
499
+ F as l,
500
+ T as m,
501
+ le as n,
486
502
  K as o,
487
- J as p,
488
- ae as q,
503
+ ee as p,
504
+ ie as q,
489
505
  P as r,
490
- F as s,
491
- ie as t,
492
- ue as u,
506
+ E as s,
507
+ V as t,
508
+ pe as u,
493
509
  Q as v,
494
- O as w,
495
- le as x,
496
- me as y,
497
- pe as z
510
+ U as w,
511
+ de as x,
512
+ se as y,
513
+ he as z
498
514
  };
499
- //# sourceMappingURL=index-Dv-W-bL0.js.map
515
+ //# sourceMappingURL=index-CLox5DuH.js.map