@brucesantos/design-space 0.3.0 → 0.5.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,9 +1,24 @@
1
- import { ComponentPreview, Fixture, Flow, Module, Persona, ProductDefinition, Rule, Scenario, ScenarioStatus } from '../types/index.js';
1
+ import { ComponentPreview, ComponentPreviewFixture, Fixture, Flow, Module, Persona, ProductDefinition, Rule, Scenario, ScenarioStatus, ScenarioView } from '../types/index.js';
2
2
  import { ValidationIssue } from './validate.js';
3
3
  export type ModuleNode = {
4
4
  module: Module;
5
5
  scenarios: Scenario[];
6
6
  };
7
+ export type ScenarioQueryOptions = {
8
+ /** Coleção consultada. Padrão: trabalho ativo. */
9
+ view?: ScenarioView;
10
+ /** Inclui o catálogo completo. Reservado a diagnóstico e compatibilidade. */
11
+ includePorted?: boolean;
12
+ /** @deprecated Deep links agora inferem `view: "ported"`. */
13
+ activeScenario?: string;
14
+ };
15
+ export type ComponentFixtureResolution = {
16
+ fixture: ComponentPreviewFixture | undefined;
17
+ /** Id que veio da URL, inclusive quando não existe. */
18
+ requestedId: string | undefined;
19
+ /** `true` quando a URL pediu um id inexistente e o motor usou o fallback. */
20
+ didFallback: boolean;
21
+ };
7
22
  export type Registry = {
8
23
  product: ProductDefinition;
9
24
  /** Árvore de navegação: módulos com seus cenários, na ordem declarada. */
@@ -13,6 +28,8 @@ export type Registry = {
13
28
  issues: ValidationIssue[];
14
29
  scenario: (id: string | undefined) => Scenario | undefined;
15
30
  component: (id: string | undefined) => ComponentPreview | undefined;
31
+ componentFixture: (componentId: string | undefined, fixtureId: string | undefined) => ComponentPreviewFixture | undefined;
32
+ resolveComponentFixture: (componentId: string | undefined, requestedId: string | undefined) => ComponentFixtureResolution;
16
33
  persona: (id: string | undefined) => Persona | undefined;
17
34
  fixture: (id: string | undefined) => Fixture | undefined;
18
35
  rule: (id: string | undefined) => Rule | undefined;
@@ -23,14 +40,19 @@ export type Registry = {
23
40
  /** Permissões efetivas: as do cenário, ou as da persona quando ausentes. */
24
41
  permissionsOf: (scenario: Scenario | undefined) => string[];
25
42
  /** Cenários que abrem a mesma rota. Serve para o seletor de situação. */
26
- scenariosForRoute: (route: string) => Scenario[];
43
+ scenariosForRoute: (route: string, options?: ScenarioQueryOptions) => Scenario[];
44
+ /** Cenários da visão pedida; trabalho ativo é o padrão. */
45
+ activeScenarios: (options?: ScenarioQueryOptions) => Scenario[];
46
+ /** Árvore filtrada para navegação, preservando `tree` como catálogo completo. */
47
+ treeFor: (options?: ScenarioQueryOptions) => ModuleNode[];
48
+ orphansFor: (options?: ScenarioQueryOptions) => Scenario[];
27
49
  /**
28
50
  * Busca por vocabulário de negócio. Um PO precisa achar "aprovação bloqueada"
29
51
  * sem saber o id nem o nome do arquivo (§15.1 "Compreensão de negócio").
30
52
  */
31
- search: (query: string) => Scenario[];
53
+ search: (query: string, options?: ScenarioQueryOptions) => Scenario[];
32
54
  byStatus: (status: ScenarioStatus) => Scenario[];
33
55
  /** Contagem por status, para o cabeçalho de cobertura. */
34
- coverage: () => Record<ScenarioStatus, number>;
56
+ coverage: (options?: ScenarioQueryOptions) => Record<ScenarioStatus, number>;
35
57
  };
36
58
  export declare function createRegistry(product: ProductDefinition): Registry;
@@ -1,9 +1,11 @@
1
- import { Registry } from '../registry/index.js';
2
- import { ControlsState } from '../types/index.js';
1
+ import { ComponentFixtureResolution, Registry } from '../registry/index.js';
2
+ import { ComponentPreview, ControlsState } from '../types/index.js';
3
3
  export type ControlsProps = {
4
4
  registry: Registry;
5
5
  controls: ControlsState;
6
6
  scenarioActive: boolean;
7
+ component?: ComponentPreview;
8
+ componentFixture?: ComponentFixtureResolution;
7
9
  onChange: (patch: Partial<ControlsState>) => void;
8
10
  };
9
- export declare function Controls({ registry, controls, scenarioActive, onChange }: ControlsProps): import("react").JSX.Element;
11
+ export declare function Controls({ registry, controls, scenarioActive, component, componentFixture, onChange, }: ControlsProps): import("react").JSX.Element;
@@ -1,6 +1,11 @@
1
1
  import { Registry } from '../registry/index.js';
2
+ import { ScenarioView } from '../types/index.js';
2
3
  export type HomeProps = {
3
4
  registry: Registry;
4
5
  onOpenScenario: (scenarioId: string) => void;
6
+ view?: ScenarioView;
7
+ onViewChange?: (view: ScenarioView) => void;
8
+ /** @deprecated Use `view="ported"`. */
9
+ showPorted?: boolean;
5
10
  };
6
- export declare function Home({ registry, onOpenScenario }: HomeProps): import("react").JSX.Element;
11
+ export declare function Home({ registry, onOpenScenario, view: requestedView, onViewChange, showPorted, }: HomeProps): import("react").JSX.Element;
@@ -1,12 +1,13 @@
1
- import { Registry } from '../registry/index.js';
1
+ import { ComponentFixtureResolution, Registry } from '../registry/index.js';
2
2
  import { AccessibleNode } from '../a11y/accessible-tree.js';
3
3
  import { ComponentPreview, ControlsState, Scenario } from '../types/index.js';
4
4
  export type InspectorProps = {
5
5
  registry: Registry;
6
6
  scenario: Scenario | undefined;
7
7
  component?: ComponentPreview;
8
+ componentFixture?: ComponentFixtureResolution;
8
9
  controls: ControlsState;
9
10
  focusedNode: AccessibleNode | undefined;
10
11
  tabStopCount: number;
11
12
  };
12
- export declare function Inspector({ registry, scenario, component, controls, focusedNode, tabStopCount, }: InspectorProps): import("react").JSX.Element;
13
+ export declare function Inspector({ registry, scenario, component, componentFixture, controls, focusedNode, tabStopCount, }: InspectorProps): import("react").JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import { Registry } from '../registry/index.js';
2
- import { ControlsState, Scenario } from '../types/index.js';
2
+ import { ControlsState, Scenario, ScenarioView } from '../types/index.js';
3
3
  export type SidebarProps = {
4
4
  registry: Registry;
5
5
  activeScenario: Scenario | undefined;
@@ -7,7 +7,8 @@ export type SidebarProps = {
7
7
  controls: ControlsState;
8
8
  onOpenScenario: (scenarioId: string) => void;
9
9
  onOpenComponent: (componentId: string) => void;
10
+ onViewChange: (view: ScenarioView) => void;
10
11
  };
11
- export declare function Sidebar({ registry, activeScenario, activeComponent, controls, onOpenScenario, onOpenComponent, }: SidebarProps): import("react").JSX.Element;
12
+ export declare function Sidebar({ registry, activeScenario, activeComponent, controls, onOpenScenario, onOpenComponent, onViewChange, }: SidebarProps): import("react").JSX.Element;
12
13
  export declare function isSearchShortcut(event: Pick<KeyboardEvent, "key" | "metaKey" | "ctrlKey" | "altKey" | "shiftKey">): boolean;
13
14
  export declare function nextItemId(ids: string[], currentId: string | undefined, offset: number): string | undefined;
@@ -1,14 +1,15 @@
1
1
  import { DeployContext } from '../deploy/index.js';
2
- import { ChromeTheme, ProductDefinition, Scenario } from '../types/index.js';
2
+ import { ChromeTheme, ProductDefinition, Scenario, ScenarioView } from '../types/index.js';
3
3
  export type TopbarProps = {
4
4
  product: ProductDefinition;
5
5
  scenario: Scenario | undefined;
6
6
  deploy: DeployContext;
7
7
  inspectorOpen: boolean;
8
8
  chromeTheme: ChromeTheme;
9
+ view: ScenarioView;
9
10
  onToggleInspector: () => void;
10
11
  onToggleChromeTheme: () => void;
11
12
  };
12
- export declare function Topbar({ product, scenario, deploy, inspectorOpen, chromeTheme, onToggleInspector, onToggleChromeTheme, }: TopbarProps): import("react").JSX.Element;
13
+ export declare function Topbar({ product, scenario, deploy, inspectorOpen, chromeTheme, view, onToggleInspector, onToggleChromeTheme, }: TopbarProps): import("react").JSX.Element;
13
14
  export declare function buildCleanReviewUrl(href: string): string;
14
- export declare function buildHomeUrl(origin: string, chromeTheme: ChromeTheme): string;
15
+ export declare function buildHomeUrl(origin: string, chromeTheme: ChromeTheme, view?: ScenarioView): string;
@@ -34,6 +34,18 @@ export type Labels = {
34
34
  matchCount: (total: number) => string;
35
35
  noComponentMatch: (query: string) => string;
36
36
  componentMatchCount: (total: number) => string;
37
+ activeWork: string;
38
+ portedReferences: (total: number) => string;
39
+ viewPorted: (total: number) => string;
40
+ backToActive: string;
41
+ currentView: (view: string) => string;
42
+ noActiveWork: string;
43
+ noPortedReferences: string;
44
+ /** @deprecated Mantido para overrides escritos para 0.4.0. */
45
+ showPorted: string;
46
+ /** @deprecated Deep links portados agora abrem a visão correspondente. */
47
+ activePorted: string;
48
+ /** @deprecated Grupos vazios não são mais renderizados. */
37
49
  emptyModule: string;
38
50
  emptyComponents: string;
39
51
  withoutModule: string;
@@ -46,6 +58,7 @@ export type Labels = {
46
58
  region: string;
47
59
  persona: string;
48
60
  fixture: string;
61
+ componentFixture: string;
49
62
  network: string;
50
63
  viewport: string;
51
64
  customWidth: string;
@@ -70,6 +83,9 @@ export type Labels = {
70
83
  noScenario: string;
71
84
  componentReference: string;
72
85
  componentGroup: string;
86
+ componentFixture: string;
87
+ componentFixtureDescription: string;
88
+ componentFixtureFallback: (requested: string, fallback: string) => string;
73
89
  situation: string;
74
90
  reproduction: string;
75
91
  id: string;
@@ -120,6 +136,8 @@ export type Labels = {
120
136
  withoutModuleHint: string;
121
137
  emptyModule: string;
122
138
  keyboardBadge: string;
139
+ noActiveWork: string;
140
+ noPortedReferences: string;
123
141
  };
124
142
  shell: {
125
143
  restoreChrome: string;
package/dist/testing.js CHANGED
@@ -1,11 +1,11 @@
1
- import { v as n, j as o, i, s as t } from "./contrast-87-ijttm.js";
2
- import { b as v, d as P, c as g, f as E } from "./contrast-87-ijttm.js";
3
- function a(e = "http://localhost:5173") {
1
+ import { v as n, k as o, j as a, s as t } from "./contrast-BseNi5QD.js";
2
+ import { b as v, d as P, c as g, h as k } from "./contrast-BseNi5QD.js";
3
+ function i(e = "http://localhost:5173") {
4
4
  const r = typeof process < "u" ? process.env : {};
5
5
  return (r.PREVIEW_URL || r.BASE_URL || e).replace(/\/$/, "");
6
6
  }
7
7
  function u(e, r = {}) {
8
- return t(e, { origin: r.origin ?? a(), overrides: r.overrides });
8
+ return t(e, { origin: r.origin ?? i(), overrides: r.overrides });
9
9
  }
10
10
  function d(e, r = {}) {
11
11
  const s = new URL(t(e, { origin: "http://design-space.invalid", overrides: r }));
@@ -21,21 +21,21 @@ function p(e) {
21
21
  const r = n(e);
22
22
  if (o(r))
23
23
  throw new Error(`Contrato de cenário inválido:
24
- ${i(r)}`);
24
+ ${a(r)}`);
25
25
  }
26
26
  export {
27
27
  v as assertContrastPairs,
28
28
  p as assertValidProduct,
29
29
  P as checkContrastPair,
30
30
  g as checkContrastPairs,
31
- E as contrastRatio,
32
- i as formatIssues,
31
+ k as contrastRatio,
32
+ a as formatIssues,
33
33
  o as hasErrors,
34
34
  f as keyboardScenarios,
35
35
  d as pathFor,
36
36
  t as scenarioUrl,
37
37
  l as scenariosUnderTest,
38
- a as testOrigin,
38
+ i as testOrigin,
39
39
  u as urlFor,
40
40
  n as validateProduct
41
41
  };
@@ -173,7 +173,31 @@ export type ScreenProps = {
173
173
  * O motor só organiza e renderiza a referência. Implementação, aparência e
174
174
  * conteúdo continuam no repositório do produto.
175
175
  */
176
- export type ComponentPreview = {
176
+ export type ComponentPreviewFixture<T = unknown> = {
177
+ /** Identificador estável, com escopo apenas dentro deste componente. */
178
+ id: string;
179
+ /** Rótulo legível para o seletor de dados do componente. */
180
+ label: string;
181
+ description?: string;
182
+ /** Valor sintético determinístico, ou factory pura que o produz. */
183
+ data: T | (() => T);
184
+ };
185
+ /** Controles e dados que o motor entrega a um preview isolado. */
186
+ export type ComponentPreviewProps<T = unknown> = {
187
+ fixture?: ComponentPreviewFixture<T>;
188
+ data: T | undefined;
189
+ viewport: ViewportSetting;
190
+ /** `default` quando o produto não declara modos de tema. */
191
+ themeMode: string;
192
+ /** `default` quando o produto não declara idiomas. */
193
+ locale: string;
194
+ a11y: {
195
+ keyboardMode: boolean;
196
+ reducedMotion: boolean;
197
+ textScale: number;
198
+ };
199
+ };
200
+ export type ComponentPreview<T = unknown> = {
177
201
  /** Identificador estável usado no deep link: `button.primary`. */
178
202
  id: string;
179
203
  /** Nome legível no vocabulário do produto. */
@@ -182,7 +206,11 @@ export type ComponentPreview = {
182
206
  group?: string;
183
207
  description?: string;
184
208
  /** Composição visual fornecida e mantida pelo produto. */
185
- preview: ComponentType;
209
+ preview: ComponentType<ComponentPreviewProps<T>>;
210
+ /** Dados sintéticos exclusivos deste componente; não usam o catálogo de cenários. */
211
+ fixtures?: ComponentPreviewFixture<T>[];
212
+ /** Id da fixture selecionada quando o deep link não informa outra. */
213
+ defaultFixture?: string;
186
214
  };
187
215
  /**
188
216
  * A UI do produto nunca depende diretamente de um backend. A camada de
@@ -257,7 +285,8 @@ export type ProductDefinition = {
257
285
  rules?: Rule[];
258
286
  routes: RouteDefinition[];
259
287
  /** Catálogo visual opcional, implementado integralmente pelo produto. */
260
- components?: ComponentPreview[];
288
+ /** Cada item pode ter seu próprio tipo de dados; o registry os trata como opacos. */
289
+ components?: ComponentPreview<any>[];
261
290
  theme?: ProductTheme;
262
291
  /**
263
292
  * Adapters de dados disponíveis. `fixtures` é o padrão (D-05); qualquer
@@ -364,8 +393,14 @@ export type ViewportSetting = {
364
393
  };
365
394
  /** Aparência do chrome do Design Space. Não altera o tema da UI do produto. */
366
395
  export type ChromeTheme = "dark" | "light";
396
+ /** Coleção de cenários exibida na navegação, home, busca e contagens. */
397
+ export type ScenarioView = "active" | "ported";
367
398
  export type ControlsState = {
368
399
  scenario: string | undefined;
400
+ /** Visão atual. `active` é o padrão e `ported` é a biblioteca de referências. */
401
+ view?: ScenarioView;
402
+ /** @deprecated Compatibilidade programática com 0.4.0. Use `view: "ported"`. */
403
+ showPorted?: boolean;
369
404
  /** Referência visual ativa. Opcional para preservar objetos do contrato anterior. */
370
405
  component?: string;
371
406
  persona: string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brucesantos/design-space",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "Motor neutro do Bananas Design Space: registry de cenários, shell, deep links, controles de persona/viewport/rede, inspetor de regras e ferramentas de acessibilidade. Não contém UI de cliente.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,268 +0,0 @@
1
- const w = [
2
- "ported",
3
- "proposed",
4
- "in-review",
5
- "approved",
6
- "in-implementation",
7
- "implemented",
8
- "superseded"
9
- ], A = [
10
- "success",
11
- "loading",
12
- "empty",
13
- "error",
14
- "slow"
15
- ], $ = /^[a-z0-9]+([.\-][a-z0-9]+)*$/;
16
- function m(e) {
17
- return typeof e == "string" && e.trim().length > 0;
18
- }
19
- function k(e, o) {
20
- const t = [], r = m(e?.id) ? `scenario:${e.id}` : `scenario[${o ?? "?"}]`, n = (c) => t.push({ level: "error", where: r, message: c }), s = (c) => t.push({ level: "warning", where: r, message: c });
21
- m(e?.id) ? $.test(e.id) ? e.id.includes(".") || s("`id` sem prefixo de módulo dificulta a navegação e a busca do agente.") : n(
22
- "`id` deve ser minúsculo em kebab-case, com o módulo como prefixo: `requests.approve-blocked`."
23
- ) : n("`id` é obrigatório."), m(e?.title) || n("`title` é obrigatório e deve usar o vocabulário do negócio."), m(e?.route) ? e.route.startsWith("/") || n("`route` deve começar com `/`.") : n("`route` é obrigatório."), m(e?.persona) || n("`persona` é obrigatório."), m(e?.fixture) || n("`fixture` é obrigatório. O padrão do ambiente é dado sintético (D-05)."), w.includes(e?.status) || n(`\`status\` deve ser um de: ${w.join(", ")}.`), e?.network && !A.includes(e.network) && n(`\`network\` deve ser um de: ${A.join(", ")}.`);
24
- const i = e?.a11y;
25
- return !i || typeof i != "object" ? n(
26
- "`a11y` é obrigatório. Acessibilidade é campo do contrato, não auditoria de fim de projeto (D-15)."
27
- ) : (["full", "partial", "not-applicable"].includes(i.keyboard) || n("`a11y.keyboard` deve ser `full`, `partial` ou `not-applicable`."), ["AA", "AAA"].includes(i.contrast) || n("`a11y.contrast` deve ser `AA` ou `AAA`. O padrão interno é WCAG 2.2 AA."), i.announces !== void 0 && !Array.isArray(i.announces) && n("`a11y.announces` deve ser uma lista de chaves de evento de domínio.")), e?.status === "approved" && i?.keyboard === "partial" && s(
28
- 'Cenário aprovado com `a11y.keyboard: "partial"`. Confirme que esta jornada não é crítica.'
29
- ), e?.status === "approved" && !e.approvedAt && s(
30
- "Cenário aprovado sem `approvedAt`. A aprovação deve ser registrada por URL de commit (§10.2), senão muda de conteúdo debaixo de quem aprovou."
31
- ), e?.expected?.length || s(
32
- "Sem `expected`, o cenário não vira caso verificável no handoff — é tela bonita sem critério (risco: prototype theater)."
33
- ), t;
34
- }
35
- function D(e) {
36
- const o = [], t = (d, a, l) => o.push({ level: d, where: a, message: l }), r = new Set(e.personas?.map((d) => d.id) ?? []), n = new Set(e.fixtures?.map((d) => d.id) ?? []), s = new Set(e.rules?.map((d) => d.id) ?? []), i = new Set(e.modules?.map((d) => d.id) ?? []), c = /* @__PURE__ */ new Set();
37
- m(e.id) || t("error", "product", "`id` é obrigatório."), m(e.name) || t("error", "product", "`name` é obrigatório."), e.routes?.length || t("error", "product", "`routes` está vazio: nenhum cenário conseguirá renderizar.");
38
- const u = /* @__PURE__ */ new Set();
39
- for (const [d, a] of (e.components ?? []).entries()) {
40
- const l = `component:${a?.id ?? d}`;
41
- m(a?.id) ? $.test(a.id) ? u.has(a.id) ? t("error", l, `\`id\` duplicado: ${a.id}.`) : u.add(a.id) : t("error", l, "`id` deve ser minúsculo em kebab-case ou usar pontos para agrupamento.") : t("error", l, "`id` é obrigatório."), m(a?.name) || t("error", l, "`name` é obrigatório."), typeof a?.preview != "function" && t("error", l, "`preview` é obrigatório.");
42
- }
43
- for (const [d, a] of (e.scenarios ?? []).entries()) {
44
- o.push(...k(a, d));
45
- const l = `scenario:${a?.id ?? d}`;
46
- if (a?.id) {
47
- c.has(a.id) && t("error", l, `\`id\` duplicado: ${a.id}.`), c.add(a.id);
48
- const p = a.id.split(".")[0];
49
- p && i.size > 0 && !i.has(p) && t(
50
- "warning",
51
- l,
52
- `Prefixo \`${p}\` não corresponde a nenhum módulo registrado. O cenário não vai aparecer na navegação.`
53
- );
54
- }
55
- a?.persona && !r.has(a.persona) && t("error", l, `Persona não registrada: \`${a.persona}\`.`), a?.fixture && !n.has(a.fixture) && t("error", l, `Fixture não registrada: \`${a.fixture}\`.`);
56
- for (const p of a?.rules ?? [])
57
- s.has(p) || t("error", l, `Regra não registrada: \`${p}\`.`);
58
- a?.route && !N(a.route, e) && t(
59
- "error",
60
- l,
61
- `Rota \`${a.route}\` não casa com nenhuma rota declarada. O deep link abriria a tela de rota inexistente.`
62
- );
63
- }
64
- for (const d of e.modules ?? [])
65
- for (const a of d.flows ?? []) {
66
- const l = `flow:${d.id}/${a.id}`;
67
- a.steps?.length || t("warning", l, "Jornada sem passos.");
68
- for (const p of a.steps ?? []) {
69
- c.has(p.scenario) || t("error", l, `Passo aponta para cenário inexistente: \`${p.scenario}\`.`);
70
- for (const [y, b] of Object.entries(p.branches ?? {}))
71
- c.has(b) || t(
72
- "error",
73
- l,
74
- `Ramificação "${y}" aponta para cenário inexistente: \`${b}\`.`
75
- );
76
- }
77
- }
78
- const f = e.dataSources?.default;
79
- return f && f !== "fixtures" && (new Set(e.dataSources?.adapters?.map((a) => a.id) ?? []).has(f) || t("error", "product", `\`dataSources.default\` aponta para adapter inexistente: \`${f}\`.`), t(
80
- "warning",
81
- "product",
82
- "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."
83
- )), o;
84
- }
85
- function N(e, o) {
86
- const t = e.split("?")[0] ?? e;
87
- return (o.routes ?? []).some((r) => P(r.path, t));
88
- }
89
- function P(e, o) {
90
- const t = e.split("/").filter(Boolean), r = o.split("/").filter(Boolean);
91
- for (const [n, s] of t.entries()) {
92
- if (s === "*") return !0;
93
- const i = r[n];
94
- if (i === void 0) return !1;
95
- if (!s.startsWith(":") && s !== i)
96
- return !1;
97
- }
98
- return t.length === r.length;
99
- }
100
- function M(e) {
101
- return e.some((o) => o.level === "error");
102
- }
103
- function z(e) {
104
- return e.length === 0 ? "Nenhum problema encontrado." : e.map((o) => `${o.level === "error" ? "✖" : "▲"} ${o.where}
105
- ${o.message}`).join(`
106
- `);
107
- }
108
- const h = {
109
- scenario: "scenario",
110
- component: "component",
111
- persona: "persona",
112
- fixture: "fixture",
113
- network: "network",
114
- viewport: "viewport",
115
- customWidth: "w",
116
- themeMode: "theme",
117
- locale: "locale",
118
- dataSource: "source",
119
- chromeTheme: "appearance",
120
- chrome: "chrome",
121
- keyboardMode: "kb",
122
- reducedMotion: "motion",
123
- textScale: "scale",
124
- inspector: "panel"
125
- };
126
- function C(e) {
127
- return typeof e == "boolean" ? e ? "1" : "0" : String(e);
128
- }
129
- function R(e, o = {}) {
130
- for (const [t, r] of Object.entries(o)) {
131
- if (r == null) continue;
132
- const n = h[t];
133
- n && e.set(n, C(r));
134
- }
135
- }
136
- function S(e = {}) {
137
- const o = e.branchUrl || void 0, t = e.deploymentUrl || void 0, r = e.commit || void 0, n = e.env || "development", s = o && `https://${o}` || t && `https://${t}` || (typeof window < "u" ? window.location.origin : "http://localhost:5173");
138
- return {
139
- env: n,
140
- origin: s.replace(/\/$/, ""),
141
- branchUrl: o,
142
- deploymentUrl: t,
143
- branch: e.branch || void 0,
144
- commit: r,
145
- shortCommit: r?.slice(0, 7),
146
- isDeployed: n === "preview" || n === "production"
147
- };
148
- }
149
- function I(e, o = {}) {
150
- const t = o.origin ?? S().origin, r = new URL(e.route, t);
151
- return r.searchParams.set(h.scenario, e.id), r.searchParams.set(h.persona, e.persona), r.searchParams.set(h.fixture, e.fixture), e.network && e.network !== "success" && r.searchParams.set(h.network, e.network), R(r.searchParams, o.overrides), r.toString();
152
- }
153
- function L(e, o) {
154
- const t = o.commit ?? S().commit;
155
- if (!t) return;
156
- const r = o.template.replaceAll("{shortCommit}", t.slice(0, 7)).replaceAll("{commit}", t);
157
- return I(e, { origin: r });
158
- }
159
- const x = {
160
- AA: { normal: 4.5, large: 3 },
161
- AAA: { normal: 7, large: 4.5 }
162
- }, O = {
163
- white: "#ffffff",
164
- black: "#000000",
165
- transparent: "#00000000"
166
- };
167
- function v(e) {
168
- const o = e.trim().toLowerCase(), t = O[o];
169
- if (t) return v(t);
170
- if (o.startsWith("#")) {
171
- const n = o.slice(1), s = (i) => Number.parseInt(i.repeat(2), 16);
172
- if (n.length === 3 || n.length === 4) {
173
- const [i, c, u, f] = [...n];
174
- return !i || !c || !u ? void 0 : { r: s(i), g: s(c), b: s(u), a: f ? s(f) / 255 : 1 };
175
- }
176
- if (n.length === 6 || n.length === 8) {
177
- const i = (u) => Number.parseInt(n.slice(u, u + 2), 16), c = [i(0), i(2), i(4)];
178
- return c.some(Number.isNaN) ? void 0 : {
179
- r: c[0],
180
- g: c[1],
181
- b: c[2],
182
- a: n.length === 8 ? i(6) / 255 : 1
183
- };
184
- }
185
- return;
186
- }
187
- const r = o.match(/^rgba?\(([^)]+)\)$/);
188
- if (r?.[1]) {
189
- const n = r[1].split(/[\s,/]+/).filter(Boolean), [s, i, c, u] = n.map(Number);
190
- return [s, i, c].some((f) => f === void 0 || Number.isNaN(f)) ? void 0 : { r: s, g: i, b: c, a: u === void 0 || Number.isNaN(u) ? 1 : u };
191
- }
192
- }
193
- function T(e, o) {
194
- if (e.a >= 1) return e;
195
- const t = (r, n) => r * e.a + n * (1 - e.a);
196
- return {
197
- r: t(e.r, o.r),
198
- g: t(e.g, o.g),
199
- b: t(e.b, o.b),
200
- a: 1
201
- };
202
- }
203
- function g({ r: e, g: o, b: t }) {
204
- const r = (n) => {
205
- const s = n / 255;
206
- return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
207
- };
208
- return 0.2126 * r(e) + 0.7152 * r(o) + 0.0722 * r(t);
209
- }
210
- function j(e, o) {
211
- const t = v(o), r = v(e);
212
- if (!t || !r) return;
213
- const n = T(r, t), s = Math.max(g(n), g(t)), i = Math.min(g(n), g(t));
214
- return (s + 0.05) / (i + 0.05);
215
- }
216
- function E(e) {
217
- const o = e.target ?? "AA", t = e.largeText ? x[o].large : x[o].normal, r = j(e.foreground, e.background);
218
- return {
219
- pair: e,
220
- target: o,
221
- ratio: r,
222
- required: t,
223
- passes: r === void 0 ? void 0 : r >= t,
224
- label: r === void 0 ? "não medido" : `${r.toFixed(2)}:1`
225
- };
226
- }
227
- function U(e = []) {
228
- return e.map(E);
229
- }
230
- function W(e) {
231
- const o = U(e).filter((r) => r.passes !== !0);
232
- if (o.length === 0) return;
233
- const t = o.map(
234
- (r) => ` ✖ ${r.pair.name}: ${r.label} (mínimo ${r.required}:1 para ${r.target}${r.pair.largeText ? ", texto grande" : ""})`
235
- ).join(`
236
- `);
237
- throw new Error(`Pares de contraste fora do alvo:
238
- ${t}`);
239
- }
240
- function q(e, o) {
241
- if (typeof window > "u") return;
242
- const t = o ?? document.documentElement;
243
- return window.getComputedStyle(t).getPropertyValue(e).trim() || void 0;
244
- }
245
- export {
246
- x as C,
247
- A as N,
248
- h as P,
249
- w as S,
250
- R as a,
251
- W as b,
252
- U as c,
253
- E as d,
254
- L as e,
255
- j as f,
256
- S as g,
257
- T as h,
258
- z as i,
259
- M as j,
260
- g as k,
261
- C as l,
262
- k as m,
263
- v as p,
264
- q as r,
265
- I as s,
266
- D as v
267
- };
268
- //# sourceMappingURL=contrast-87-ijttm.js.map