@zaip-ai/cli 1.3.1 → 1.3.2

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.
Files changed (30) hide show
  1. package/README.md +3 -2
  2. package/dist/services/runtime-template.test.js +8 -8
  3. package/package.json +1 -1
  4. package/templates/.agents/dashboard/.zaip-managed.json +16 -16
  5. package/templates/.agents/dashboard/apps/frontend/dist/assets/{DashboardHelpDialog-BgVgrfhQ.js → DashboardHelpDialog-BXy6nti1.js} +28 -0
  6. package/templates/.agents/dashboard/apps/frontend/dist/assets/{TraceabilityWorkspace-DLn-Mz2M.js → TraceabilityWorkspace-CTH2wDs5.js} +1 -1
  7. package/templates/.agents/dashboard/apps/frontend/dist/assets/{index-CZQlsLV9.js → index-CuMcoUni.js} +2 -2
  8. package/templates/.agents/dashboard/apps/frontend/dist/index.html +1 -1
  9. package/templates/.agents/dashboard/packages/local-runtime/dist/server.cjs +84 -84
  10. package/templates/.agents/dashboard/packages/local-runtime/dist/sqlite-read-model.cjs +64 -64
  11. package/templates/.agents/dashboard/packages/local-runtime/server.mjs +87 -87
  12. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-operations-work-list.test.ts +70 -0
  13. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-operations-work-list.ts +74 -7
  14. package/templates/.agents/requirements/autonomous-assurance.md +1 -1
  15. package/templates/.agents/requirements/comparative-audit.md +1 -1
  16. package/templates/.agents/requirements/context-engine.md +1 -1
  17. package/templates/.agents/requirements/cost-observability.md +1 -1
  18. package/templates/.agents/requirements/dashboard-launch.md +1 -1
  19. package/templates/.agents/requirements/data-export.md +1 -1
  20. package/templates/.agents/requirements/design-system.md +1 -1
  21. package/templates/.agents/requirements/execution-engine.md +1 -1
  22. package/templates/.agents/requirements/kanban-dashboard.md +1 -1
  23. package/templates/.agents/requirements/model-orchestration.md +1 -1
  24. package/templates/.agents/requirements/public-distribution.md +1 -1
  25. package/templates/.agents/requirements/software-architecture.md +1 -1
  26. package/templates/.agents/requirements/strategic-improvements.md +1 -1
  27. package/templates/.agents/requirements/work-lifecycle.md +1 -1
  28. package/templates/.agents/requirements/zaip-strategic-95.md +1 -1
  29. package/templates/.agents/zaip-aios/guides/26-qualidade-e-release.md +15 -0
  30. package/templates/template-manifest.json +32 -32
package/README.md CHANGED
@@ -84,5 +84,6 @@ skills never claim runtime validators that are not distributed.
84
84
 
85
85
  ## Contributing and license
86
86
 
87
- Run `corepack pnpm verify` from `public-cli` before submitting a change. Candidate `1.3.1` is
88
- `UNLICENSED`; publication does not grant an open-source license.
87
+ Run `corepack pnpm verify` from `public-cli` before submitting a change. This package is
88
+ `UNLICENSED`; publication does not grant an open-source license. Consult npm for the
89
+ published version and the repository release evidence for its qualification status.
@@ -20,7 +20,7 @@ describe("public lifecycle runtime template", { timeout: 90_000 }, () => {
20
20
  expect(() => validateTemplatePath(".agents/runtime/bin/zaip.mjs")).not.toThrow();
21
21
  });
22
22
  it("installs the checksum-verified runtime used by generated guidance", async () => {
23
- const template = await loadTemplate(templateDirectory, "1.3.1");
23
+ const template = await loadTemplate(templateDirectory, "1.3.2");
24
24
  const runtime = template.files.find((file) => file.path === ".agents/runtime/bin/zaip.mjs");
25
25
  expect(runtime?.binary).toBe(true);
26
26
  expect(runtime?.content).toEqual(await readFile(resolve(templateDirectory, ".agents/runtime/bin/zaip.mjs")));
@@ -44,11 +44,11 @@ describe("public lifecycle runtime template", { timeout: 90_000 }, () => {
44
44
  runtimeFilesSha256: digestRuntimeFiles([]),
45
45
  files: [{ path, sha256: sha256(expected), sourcePath }],
46
46
  }), "utf8");
47
- await expect(loadTemplate(root, "1.3.1")).resolves.toMatchObject({
47
+ await expect(loadTemplate(root, "1.3.2")).resolves.toMatchObject({
48
48
  files: [expect.objectContaining({ path, content: expected })],
49
49
  });
50
50
  await writeFile(packedPath, "tampered\n", "utf8");
51
- await expect(loadTemplate(root, "1.3.1")).rejects.toThrow(`Template integrity check failed for ${path}`);
51
+ await expect(loadTemplate(root, "1.3.2")).rejects.toThrow(`Template integrity check failed for ${path}`);
52
52
  });
53
53
  it.each([
54
54
  "after-stage",
@@ -84,7 +84,7 @@ describe("public lifecycle runtime template", { timeout: 90_000 }, () => {
84
84
  it("executes capture and activation commands in a clean installed workspace", async () => {
85
85
  const root = await mkdtemp(join(tmpdir(), "zaip-public-runtime-"));
86
86
  roots.push(root);
87
- await installAgentsTemplate({ cwd: root, templateDirectory, cliVersion: "1.3.1" });
87
+ await installAgentsTemplate({ cwd: root, templateDirectory, cliVersion: "1.3.2" });
88
88
  const runtime = resolve(root, ".agents/runtime/bin/zaip.mjs");
89
89
  await expect(readFile(resolve(root, ".local/.gitignore"), "utf8")).resolves.toBe("*\n!.gitignore\n");
90
90
  await expect(readFile(resolve(root, ".agents/local/.gitignore"))).rejects.toMatchObject({
@@ -99,7 +99,7 @@ describe("public lifecycle runtime template", { timeout: 90_000 }, () => {
99
99
  it("installs canonical agent aliases and converges managed host shims", async () => {
100
100
  const root = await mkdtemp(join(tmpdir(), "zaip-public-agent-compat-"));
101
101
  roots.push(root);
102
- await installAgentsTemplate({ cwd: root, templateDirectory, cliVersion: "1.3.1" });
102
+ await installAgentsTemplate({ cwd: root, templateDirectory, cliVersion: "1.3.2" });
103
103
  const runtime = resolve(root, ".agents/runtime/bin/zaip.mjs");
104
104
  const catalog = await readFile(resolve(root, ".agents/config/agents/catalog.yaml"), "utf8");
105
105
  expect(catalog).toContain("value: agent-task-finalizer");
@@ -115,7 +115,7 @@ describe("public lifecycle runtime template", { timeout: 90_000 }, () => {
115
115
  it("reports a missing runtime and restores it transactionally", async () => {
116
116
  const root = await mkdtemp(join(tmpdir(), "zaip-public-runtime-missing-"));
117
117
  roots.push(root);
118
- await installAgentsTemplate({ cwd: root, templateDirectory, cliVersion: "1.3.1" });
118
+ await installAgentsTemplate({ cwd: root, templateDirectory, cliVersion: "1.3.2" });
119
119
  const runtime = resolve(root, ".agents/runtime/bin/zaip.mjs");
120
120
  await rm(runtime);
121
121
  await expect(doctorProject(root)).resolves.toMatchObject({
@@ -130,7 +130,7 @@ describe("public lifecycle runtime template", { timeout: 90_000 }, () => {
130
130
  const repaired = await installAgentsTemplate({
131
131
  cwd: root,
132
132
  templateDirectory,
133
- cliVersion: "1.3.1",
133
+ cliVersion: "1.3.2",
134
134
  });
135
135
  expect(repaired.applied).toBe(true);
136
136
  expect(repaired.created).toContain(".agents/runtime/bin/zaip.mjs");
@@ -139,7 +139,7 @@ describe("public lifecycle runtime template", { timeout: 90_000 }, () => {
139
139
  it("converges attributed work when a public runtime Run finishes", async () => {
140
140
  const root = await mkdtemp(join(tmpdir(), "zaip-public-runtime-closure-"));
141
141
  roots.push(root);
142
- await installAgentsTemplate({ cwd: root, templateDirectory, cliVersion: "1.3.1" });
142
+ await installAgentsTemplate({ cwd: root, templateDirectory, cliVersion: "1.3.2" });
143
143
  const runtime = resolve(root, ".agents/runtime/bin/zaip.mjs");
144
144
  const ids = {
145
145
  task: "TASK-2026-07-17-21-03-PUBLIC-CLOSURE-A7K2",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zaip-ai/cli",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "CLI oficial para instalar e configurar o ZAIP-AIOS em qualquer repositório",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -23,8 +23,8 @@
23
23
  "sha256": "8cc193dc078b845250b86e2eb5b406bf3a521c2582099f8a60e7b111b417d7e4"
24
24
  },
25
25
  {
26
- "path": "apps/frontend/dist/assets/DashboardHelpDialog-BgVgrfhQ.js",
27
- "sha256": "48205945e669e00aaccc5ec45d2640441bdec36fde52f9ea11451458a11eb287"
26
+ "path": "apps/frontend/dist/assets/DashboardHelpDialog-BXy6nti1.js",
27
+ "sha256": "d9c312a6e562000475fc29059da59af99470fffca73df1fb44be5b2deaf56298"
28
28
  },
29
29
  {
30
30
  "path": "apps/frontend/dist/assets/DashboardHelpDialog-Je5nK-Et.css",
@@ -39,8 +39,8 @@
39
39
  "sha256": "2d1180a1ac0828c6e68a4e1d5e090e92aa32a9f999b86d7153d0262c83d62a9f"
40
40
  },
41
41
  {
42
- "path": "apps/frontend/dist/assets/index-CZQlsLV9.js",
43
- "sha256": "a33f0056e241da5e0909506cc56c3b3f580cd1bac4e46fb03abbcb2be8527c1a"
42
+ "path": "apps/frontend/dist/assets/index-CuMcoUni.js",
43
+ "sha256": "d3c72b2f609e92cc8ea86e26f022099e7814dd4be1f7be97a7a140ef259cc822"
44
44
  },
45
45
  {
46
46
  "path": "apps/frontend/dist/assets/logo_novo_azul-BBx5pA2B.png",
@@ -75,8 +75,8 @@
75
75
  "sha256": "3134c9eb5bbbdb1e48e1001fe6c4b7fd32840db04d9782587f2c4f6eacc21a64"
76
76
  },
77
77
  {
78
- "path": "apps/frontend/dist/assets/TraceabilityWorkspace-DLn-Mz2M.js",
79
- "sha256": "7be561858ed9f8538b996c83875f24c49974bfe9899f0c619c2082164f983ff1"
78
+ "path": "apps/frontend/dist/assets/TraceabilityWorkspace-CTH2wDs5.js",
79
+ "sha256": "bc0e4e8ef20625ebb5869ac1f88ee7e15c8f49c8fca49ba2b70aa66ccac188ff"
80
80
  },
81
81
  {
82
82
  "path": "apps/frontend/dist/assets/TraceabilityWorkspace-DvvavDLY.css",
@@ -88,7 +88,7 @@
88
88
  },
89
89
  {
90
90
  "path": "apps/frontend/dist/index.html",
91
- "sha256": "932b520a5d494e351b83972f309154a6aeea0e5e26e6aa49a8e5aaa638c5d1e3"
91
+ "sha256": "d54d70e2ac30944a918b108d90c6311076da7a2415cdb4bb46c7436456a4ce07"
92
92
  },
93
93
  {
94
94
  "path": "apps/frontend/dist/logo_novo_azul.png",
@@ -1460,27 +1460,27 @@
1460
1460
  },
1461
1461
  {
1462
1462
  "path": "packages/local-runtime/dist/server.cjs",
1463
- "sha256": "45692c4e7317fa77cc6928a09f8da99d3176a65aaae78fcee987571452b69348"
1463
+ "sha256": "afa0ffec725ba10a8175525805d84077019dc916a9dfcf3b98b87b7d9db18b20"
1464
1464
  },
1465
1465
  {
1466
1466
  "path": "packages/local-runtime/dist/server.cjs.map",
1467
- "sha256": "4d1d69882353e37fb1ed515b86c7b412e8f5ce3d5cc83dd1054e1ca73cf7894d"
1467
+ "sha256": "72aa68ad1b838614e84a63b639c3402e5a7c43cf6c1afe5e09de02e9389f4b6f"
1468
1468
  },
1469
1469
  {
1470
1470
  "path": "packages/local-runtime/dist/server.js",
1471
- "sha256": "240676f45050bfa27f41a578ab892c2c4d810deb4406cea433c4c8e259b92beb"
1471
+ "sha256": "1572db115912d9738dcb82b7083fffedede0eaa4b63334ed73c974e3dd7fdb80"
1472
1472
  },
1473
1473
  {
1474
1474
  "path": "packages/local-runtime/dist/server.js.map",
1475
- "sha256": "ef55289e82a9c6bbe7275d52b71a5fefdb142fdc556116b0d5779c018cbe51e3"
1475
+ "sha256": "003343344a1e54e430f7b735b947b6013ece44db829b408b56992307e207084f"
1476
1476
  },
1477
1477
  {
1478
1478
  "path": "packages/local-runtime/dist/sqlite-read-model.cjs",
1479
- "sha256": "9b3047e610d5bc8f60b4aac6f6d204b7aa2a2989e83e0d86810906e3f57d160f"
1479
+ "sha256": "c1f5982265d2267d039e0515b0010fd15fc5681233eb529e71fffa95156015aa"
1480
1480
  },
1481
1481
  {
1482
1482
  "path": "packages/local-runtime/dist/sqlite-read-model.cjs.map",
1483
- "sha256": "9f5c641dabff48240180a2b971844207c40dc002c099112b7dcf82d993dbb5a1"
1483
+ "sha256": "8d0d6f5e049f0afd4ff0ae3f164f4acc977121873ce37589c213d46ae4e22ea8"
1484
1484
  },
1485
1485
  {
1486
1486
  "path": "packages/local-runtime/package.json",
@@ -1516,7 +1516,7 @@
1516
1516
  },
1517
1517
  {
1518
1518
  "path": "packages/local-runtime/server.mjs",
1519
- "sha256": "240676f45050bfa27f41a578ab892c2c4d810deb4406cea433c4c8e259b92beb"
1519
+ "sha256": "1572db115912d9738dcb82b7083fffedede0eaa4b63334ed73c974e3dd7fdb80"
1520
1520
  },
1521
1521
  {
1522
1522
  "path": "packages/local-runtime/src/agent-adapter-sync.ts",
@@ -1732,11 +1732,11 @@
1732
1732
  },
1733
1733
  {
1734
1734
  "path": "packages/local-runtime/src/sqlite-operations-work-list.test.ts",
1735
- "sha256": "7b38ebb344a9254af8508e0e6495e09916c3faa441b65f03916f01d673349005"
1735
+ "sha256": "dedafac62284c63d7afffc1936bd2d7db4c37963d3e5f247a68ff6284e89308e"
1736
1736
  },
1737
1737
  {
1738
1738
  "path": "packages/local-runtime/src/sqlite-operations-work-list.ts",
1739
- "sha256": "7dd1b49d4e97e084fd301a625a4417ab45008b4daa810e2da5fef0b6cd55a6d7"
1739
+ "sha256": "c390ecebfc2838427ea5a02cb491e1eb020a3683d9c32bbaeffb21f12d7a1207"
1740
1740
  },
1741
1741
  {
1742
1742
  "path": "packages/local-runtime/src/sqlite-read-model-cache.test-support.ts",
@@ -1362,6 +1362,21 @@ sincronize/audite novamente o template público. Execute gates geradores em
1362
1362
  checkout/worktree isolado para preservar trabalho concorrente. Gates locais,
1363
1363
  artefato exato, CI terminal e produção continuam sendo provas distintas.
1364
1364
 
1365
+ ### Falhas de desempenho no dashboard
1366
+
1367
+ Reproduza a rota, período, filtro, offset e tamanho da página que falharam.
1368
+ Separe a primeira consulta sem resultado em cache da navegação já aquecida;
1369
+ uma página rápida em cache não comprova o custo de exportar páginas distintas.
1370
+ Correlacione o clique com a requisição, a espera pelo servidor, o retorno e o
1371
+ fechamento do arquivo. Registre a concorrência do teste e do ambiente.
1372
+
1373
+ Timeout não autoriza aumentar limites nem remover a matriz de performance.
1374
+ Primeiro diferencie requisição ausente, cancelada, bloqueada e consulta lenta.
1375
+ Uma correção de consulta deve preservar filtros, ordenação, total, IDs únicos,
1376
+ offsets contíguos e exportação até \`has_more=false\`. Reexecute o cenário que
1377
+ falhou e o gate correspondente no candidato corrigido. Se o pacote anterior
1378
+ já estiver publicado, distribua a correção em nova versão imutável.
1379
+
1365
1380
  ## Histórico e nova qualificação em 30/08/2026
1366
1381
 
1367
1382
  Snapshot bloqueado em 2026-08-30 para o candidato
@@ -1399,6 +1414,17 @@ não no histórico distribuído ao consumidor.
1399
1414
 
1400
1415
  \`test-results\`, \`playwright-report\`, \`coverage\`, \`.turbo\` e \`node_modules\` nunca pertencem ao pacote portável nem ao manifesto gerenciado. A embalagem e o clean-room aplicam a mesma política de exclusão.
1401
1416
 
1417
+ Antes de substituir \`public-cli/artifacts\` ou executar \`npm pack\`, o guard de
1418
+ release compara o inventário público efetivo do Dashboard com os arquivos
1419
+ rastreados pelo Git. Somente os dois outputs declarados do build SQLite,
1420
+ \`packages/local-runtime/dist/server.cjs\` e
1421
+ \`packages/local-runtime/dist/sqlite-read-model.cjs\`, podem ser gerados sem
1422
+ rastreamento. Outros arquivos não rastreados, inclusive diagnósticos ignorados
1423
+ pelo Git, impedem a embalagem. Uma consulta Git indisponível também bloqueia.
1424
+ O guard não remove, move, ignora ou adiciona arquivos ao Git; a limpeza deve
1425
+ ser resolvida pelo responsável autorizado, preservando os artefatos anteriores.
1426
+ Use o checkout limpo do candidato exato e não publique TGZs de diagnóstico.
1427
+
1402
1428
  ## Evidência e aprovação
1403
1429
 
1404
1430
  Testes passando comprovam validação técnica. Maturidade formal máxima exige ainda:
@@ -2216,6 +2242,8 @@ Antes de integrar uma mudança relevante ou preparar um release, \`pnpm verify\`
2216
2242
 
2217
2243
  Use a versão de pnpm fixada em \`packageManager\` (\`corepack pnpm\` quando disponível). Para uma alteração delimitada, selecione os checks pertinentes ao risco e ao diff; a lista acima não exige repetir todos os testes a cada edição documental. Qualificação de release usa os gates completos do [guia 26](.agents/zaip-aios/guides/26-qualidade-e-release.md) no candidato exato. Não confunda \`validate:github:prepared\`, execução local, push e CI terminal verde.
2218
2244
 
2245
+ Os dois pacotes públicos compartilham a mesma versão; consulte os links npm acima para identificar o \`latest\` publicado. A versão em um checkout não comprova publicação: a qualificação deve registrar a revisão exata, o resultado terminal do CI, a integridade dos TGZs e uma instalação nova do registro. O framework mantém seu cohort \`1.3.0\`, separado da versão pública. Publicação manual com token autorizado não equivale a atestado OIDC. Resultados e ressalvas ficam nas evidências da Change de release, preservando as tentativas anteriores.
2246
+
2219
2247
  A arquitetura detalhada está resumida na seção [Arquitetura das aplicações](#arquitetura-das-aplicações) deste README.
2220
2248
 
2221
2249
 
@@ -1 +1 @@
1
- import{S as e,b as t}from"./cost-monitor-DKwP1stV.js";import{n}from"./traceability-7f1j5wx3.js";import{t as r}from"./index-CZQlsLV9.js";var i=e(),a=t();function o(e,t){let n=t.trim().toLocaleLowerCase();return n===``?[...e]:e.filter(e=>`${e.title} ${e.id}`.toLocaleLowerCase().includes(n))}function s(e,t,n){return n?[...e]:o(e,t)}function c(e){return`traceability-task-option-${e}`}function l({locale:e,loadingTaskId:t,hasMoreTasks:o,isLoadingTasks:l,onLoadMoreTasks:u,onSelectTask:d,onOpenChange:f,onOpenPrd:p,onOpenSpec:m,selectedTaskId:h,tasks:g,trace:_}){let v=[...g].sort((e,t)=>Date.parse(t.created_at)-Date.parse(e.created_at)),y=v.find(e=>e.id===h),[b,x]=(0,i.useState)(()=>y?.title??h),[S,C]=(0,i.useState)(!1),[w,T]=(0,i.useState)(!1),[E,D]=(0,i.useState)(0),[O,k]=(0,i.useState)(12),A=(0,i.useMemo)(()=>s(v,b,w),[b,w,v]),j=A.slice(0,O),M=j.length<A.length,N=`traceability-task-search`,P=`traceability-task-results`,F=e===`pt-BR`?`Task selecionada`:`Selected task`,I=e===`pt-BR`?`Buscar task por nome ou ID`:`Search task by name or ID`,L=S?A[E]?.id:void 0;(0,i.useEffect)(()=>{x(y?.title??h),D(0)},[y?.title,h]);let R=e=>{x(e.title),C(!1),T(!1),d(e.id)},z=(e=!0)=>{C(!0),T(!0),e&&(D(0),k(12))};return(0,a.jsxs)(`section`,{className:`traceability-workspace`,children:[(0,a.jsxs)(`header`,{children:[(0,a.jsxs)(`div`,{children:[(0,a.jsx)(`label`,{htmlFor:N,children:F}),(0,a.jsx)(`input`,{"aria-activedescendant":L===void 0?void 0:c(L),"aria-autocomplete":`list`,"aria-controls":P,"aria-expanded":S,"aria-label":I,id:N,onChange:e=>{x(e.target.value),D(0),T(!1),k(12),C(!0)},onClick:()=>z(),onFocus:()=>z(),onKeyDown:e=>{if(e.key===`ArrowDown`)e.preventDefault(),z(!1),D(e=>Math.min(e+1,Math.max(0,v.length-1)));else if(e.key===`ArrowUp`)e.preventDefault(),z(!1),D(e=>Math.max(0,e-1));else if(e.key===`Enter`&&S){let t=A[E];t!==void 0&&(e.preventDefault(),R(t))}else e.key===`Escape`&&C(!1)},role:`combobox`,type:`search`,value:b}),S?(0,a.jsx)(`div`,{"aria-label":I,className:`traceability-task-results`,id:P,onScroll:e=>{let{clientHeight:t,scrollHeight:n,scrollTop:i}=e.currentTarget;i+t<n-32||(o&&u(),j.length<A.length&&k(e=>r(e,A.length,12)))},role:`listbox`,children:A.length>0?j.map((e,t)=>(0,a.jsx)(`div`,{role:`presentation`,children:(0,a.jsx)(`button`,{"aria-selected":e.id===h,className:t===E?`is-active`:void 0,id:c(e.id),onClick:()=>R(e),role:`option`,type:`button`,children:(0,a.jsx)(`strong`,{children:e.title})})},e.id)):(0,a.jsx)(`div`,{className:`traceability-task-no-results`,role:`status`,children:e===`pt-BR`?`Nenhuma task encontrada.`:`No tasks found.`})}):null,S&&A.length>0?(0,a.jsx)(`p`,{"aria-live":`polite`,className:`traceability-task-pagination-status`,role:`status`,children:l?e===`pt-BR`?`Carregando mais tasks…`:`Loading more tasks…`:M||o?e===`pt-BR`?`${j.length} de ${A.length} tasks exibidas. Role para carregar mais.`:`${j.length} of ${A.length} tasks shown. Scroll to load more.`:e===`pt-BR`?`${A.length} tasks exibidas. Fim da lista.`:`${A.length} tasks shown. End of list.`}):null]}),(0,a.jsx)(`small`,{children:e===`pt-BR`?`Selecione pelo nome para visualizar o ciclo completo sem precisar do ID.`:`Select by name to inspect the complete lifecycle without knowing the ID.`})]}),t?(0,a.jsx)(`div`,{"aria-live":`polite`,className:`traceability-workspace-loading`,children:e===`pt-BR`?`Carregando as 6 etapas…`:`Loading all 6 stages…`}):_?(0,a.jsx)(n,{embedded:!0,locale:e,onClose:()=>void 0,onOpenChange:f,onOpenPrd:p,onOpenSpec:m,trace:_}):(0,a.jsx)(`p`,{children:e===`pt-BR`?`Nenhuma task disponível.`:`No task available.`})]})}export{l as TraceabilityWorkspace};
1
+ import{S as e,b as t}from"./cost-monitor-DKwP1stV.js";import{n}from"./traceability-7f1j5wx3.js";import{t as r}from"./index-CuMcoUni.js";var i=e(),a=t();function o(e,t){let n=t.trim().toLocaleLowerCase();return n===``?[...e]:e.filter(e=>`${e.title} ${e.id}`.toLocaleLowerCase().includes(n))}function s(e,t,n){return n?[...e]:o(e,t)}function c(e){return`traceability-task-option-${e}`}function l({locale:e,loadingTaskId:t,hasMoreTasks:o,isLoadingTasks:l,onLoadMoreTasks:u,onSelectTask:d,onOpenChange:f,onOpenPrd:p,onOpenSpec:m,selectedTaskId:h,tasks:g,trace:_}){let v=[...g].sort((e,t)=>Date.parse(t.created_at)-Date.parse(e.created_at)),y=v.find(e=>e.id===h),[b,x]=(0,i.useState)(()=>y?.title??h),[S,C]=(0,i.useState)(!1),[w,T]=(0,i.useState)(!1),[E,D]=(0,i.useState)(0),[O,k]=(0,i.useState)(12),A=(0,i.useMemo)(()=>s(v,b,w),[b,w,v]),j=A.slice(0,O),M=j.length<A.length,N=`traceability-task-search`,P=`traceability-task-results`,F=e===`pt-BR`?`Task selecionada`:`Selected task`,I=e===`pt-BR`?`Buscar task por nome ou ID`:`Search task by name or ID`,L=S?A[E]?.id:void 0;(0,i.useEffect)(()=>{x(y?.title??h),D(0)},[y?.title,h]);let R=e=>{x(e.title),C(!1),T(!1),d(e.id)},z=(e=!0)=>{C(!0),T(!0),e&&(D(0),k(12))};return(0,a.jsxs)(`section`,{className:`traceability-workspace`,children:[(0,a.jsxs)(`header`,{children:[(0,a.jsxs)(`div`,{children:[(0,a.jsx)(`label`,{htmlFor:N,children:F}),(0,a.jsx)(`input`,{"aria-activedescendant":L===void 0?void 0:c(L),"aria-autocomplete":`list`,"aria-controls":P,"aria-expanded":S,"aria-label":I,id:N,onChange:e=>{x(e.target.value),D(0),T(!1),k(12),C(!0)},onClick:()=>z(),onFocus:()=>z(),onKeyDown:e=>{if(e.key===`ArrowDown`)e.preventDefault(),z(!1),D(e=>Math.min(e+1,Math.max(0,v.length-1)));else if(e.key===`ArrowUp`)e.preventDefault(),z(!1),D(e=>Math.max(0,e-1));else if(e.key===`Enter`&&S){let t=A[E];t!==void 0&&(e.preventDefault(),R(t))}else e.key===`Escape`&&C(!1)},role:`combobox`,type:`search`,value:b}),S?(0,a.jsx)(`div`,{"aria-label":I,className:`traceability-task-results`,id:P,onScroll:e=>{let{clientHeight:t,scrollHeight:n,scrollTop:i}=e.currentTarget;i+t<n-32||(o&&u(),j.length<A.length&&k(e=>r(e,A.length,12)))},role:`listbox`,children:A.length>0?j.map((e,t)=>(0,a.jsx)(`div`,{role:`presentation`,children:(0,a.jsx)(`button`,{"aria-selected":e.id===h,className:t===E?`is-active`:void 0,id:c(e.id),onClick:()=>R(e),role:`option`,type:`button`,children:(0,a.jsx)(`strong`,{children:e.title})})},e.id)):(0,a.jsx)(`div`,{className:`traceability-task-no-results`,role:`status`,children:e===`pt-BR`?`Nenhuma task encontrada.`:`No tasks found.`})}):null,S&&A.length>0?(0,a.jsx)(`p`,{"aria-live":`polite`,className:`traceability-task-pagination-status`,role:`status`,children:l?e===`pt-BR`?`Carregando mais tasks…`:`Loading more tasks…`:M||o?e===`pt-BR`?`${j.length} de ${A.length} tasks exibidas. Role para carregar mais.`:`${j.length} of ${A.length} tasks shown. Scroll to load more.`:e===`pt-BR`?`${A.length} tasks exibidas. Fim da lista.`:`${A.length} tasks shown. End of list.`}):null]}),(0,a.jsx)(`small`,{children:e===`pt-BR`?`Selecione pelo nome para visualizar o ciclo completo sem precisar do ID.`:`Select by name to inspect the complete lifecycle without knowing the ID.`})]}),t?(0,a.jsx)(`div`,{"aria-live":`polite`,className:`traceability-workspace-loading`,children:e===`pt-BR`?`Carregando as 6 etapas…`:`Loading all 6 stages…`}):_?(0,a.jsx)(n,{embedded:!0,locale:e,onClose:()=>void 0,onOpenChange:f,onOpenPrd:p,onOpenSpec:m,trace:_}):(0,a.jsx)(`p`,{children:e===`pt-BR`?`Nenhuma task disponível.`:`No task available.`})]})}export{l as TraceabilityWorkspace};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DashboardHelpDialog-BgVgrfhQ.js","assets/cost-monitor-DKwP1stV.js","assets/rolldown-runtime-D9-fqq9M.js","assets/cost-monitor-PoJA2PI1.css","assets/dashboard-localization-CLJ0lT9v.js","assets/DashboardHelpDialog-Je5nK-Et.css","assets/PricingSettingsDialog-vSvvOHQp.js","assets/ProjectSettingsPage-zH758vfs.js","assets/ProjectSettingsPage-BomxqCBU.css","assets/CostCalculationGuidePage-ovxurkIk.js","assets/TraceabilityWorkspace-DLn-Mz2M.js","assets/traceability-7f1j5wx3.js","assets/icons-vendor-B_lDDHn1.js","assets/traceability-DFY7ZDlu.css","assets/TraceabilityWorkspace-DvvavDLY.css"])))=>i.map(i=>d[i]);
2
- import{S as e,a as t,b as n,g as r,h as i,i as a,n as o,r as s,t as c}from"./cost-monitor-DKwP1stV.js";import{t as l}from"./react-vendor-B3TJrD4O.js";import{n as u,t as d}from"./traceability-7f1j5wx3.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var f=e(),p=l(),m=n();function h({locale:e}){let t=e===`pt-BR`?[`Definição`,`Planejamento`,`Pronto para Executar`,`Execução`,`Verificação`]:[`Definition`,`Planning`,`Ready to Execute`,`Execution`,`Verification`];return(0,m.jsxs)(`main`,{"aria-busy":`true`,"aria-live":`polite`,"aria-label":e===`pt-BR`?`Preparando dashboard`:`Preparing dashboard`,className:`app-skeleton`,role:`status`,children:[(0,m.jsxs)(`header`,{className:`app-skeleton-header`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`span`,{className:`app-skeleton-line app-skeleton-line-short`}),(0,m.jsx)(`h1`,{children:`Dashboard Zaip AIOS`})]}),(0,m.jsxs)(`div`,{className:`app-skeleton-actions`,children:[(0,m.jsx)(`span`,{}),(0,m.jsx)(`span`,{}),(0,m.jsx)(`span`,{})]})]}),(0,m.jsx)(`section`,{className:`app-skeleton-kpis`,"aria-hidden":`true`,children:Array.from({length:4},(e,t)=>`skeleton-kpi-${t}`).map(e=>(0,m.jsxs)(`article`,{children:[(0,m.jsx)(`span`,{className:`app-skeleton-line app-skeleton-line-short`}),(0,m.jsx)(`span`,{className:`app-skeleton-value`}),(0,m.jsx)(`span`,{className:`app-skeleton-line`})]},e))}),(0,m.jsxs)(`section`,{className:`app-skeleton-panels`,"aria-hidden":`true`,children:[(0,m.jsxs)(`article`,{children:[(0,m.jsx)(`span`,{className:`app-skeleton-line app-skeleton-line-medium`}),(0,m.jsx)(`div`,{className:`app-skeleton-chart`})]}),(0,m.jsxs)(`article`,{children:[(0,m.jsx)(`span`,{className:`app-skeleton-line app-skeleton-line-medium`}),(0,m.jsx)(`div`,{className:`app-skeleton-chart app-skeleton-chart-small`})]})]}),(0,m.jsx)(`section`,{className:`app-skeleton-board`,"aria-hidden":`true`,children:t.map((e,t)=>(0,m.jsxs)(`article`,{children:[(0,m.jsx)(`h2`,{children:e}),Array.from({length:t%2==0?2:1},(t,n)=>`${e}-${n}`).map(e=>(0,m.jsxs)(`div`,{className:`app-skeleton-card`,children:[(0,m.jsx)(`span`,{className:`app-skeleton-line`}),(0,m.jsx)(`span`,{className:`app-skeleton-line app-skeleton-line-medium`}),(0,m.jsx)(`span`,{className:`app-skeleton-pill`})]},e))]},e))})]})}function g(e,t){let n=t===`pt-BR`;return e===`costs`?n?{title:`Carregando Monitor de Custos…`,detail:`Isso costuma levar poucos segundos.`}:{title:`Loading Cost Monitor…`,detail:`This usually takes a few seconds.`}:e===`traceability`?n?{title:`Carregando Rastreabilidade…`,detail:`Estamos preparando as 6 etapas da task.`}:{title:`Loading Traceability…`,detail:`Preparing the task's 6 stages.`}:n?{title:`Atualizando dados do dashboard…`,detail:`Você pode continuar navegando.`}:{title:`Refreshing dashboard data…`,detail:`You can keep navigating.`}}function _({area:e,locale:t}){let n=g(e,t);return(0,m.jsxs)(`section`,{"aria-busy":`true`,"aria-live":`polite`,className:`app-loading-panel`,role:`status`,children:[(0,m.jsx)(`i`,{}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`strong`,{children:n.title}),(0,m.jsx)(`span`,{children:n.detail})]})]})}function v({area:e,locale:t}){let n=g(e,t);return(0,m.jsxs)(`section`,{"aria-live":`polite`,className:`app-refresh-status`,role:`status`,children:[(0,m.jsx)(`i`,{}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`strong`,{children:n.title}),(0,m.jsx)(`span`,{children:n.detail})]})]})}function y({locale:e,onRetry:t}){return(0,m.jsxs)(`section`,{"aria-live":`polite`,className:`app-loading-panel app-loading-panel-error`,role:`status`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`strong`,{children:e===`pt-BR`?`Não foi possível carregar os custos`:`Couldn't load costs`}),(0,m.jsx)(`span`,{children:e===`pt-BR`?`A tela continua disponível. Tente novamente quando quiser.`:`The dashboard remains available. Try again whenever you want.`})]}),(0,m.jsx)(`button`,{onClick:t,type:`button`,children:e===`pt-BR`?`Tentar novamente`:`Try again`})]})}function b(e,t){return e===t}function x(e,t,n,r){return b(e,t)&&n.from===r.from&&n.to===r.to}function S(e){return e instanceof DOMException&&e.name===`AbortError`}function ee(e,t){return e===t}function te(e,t,n){return b(e,t)&&!n.aborted}function ne(e,t){let n=e=>[...new Map(e.map(e=>[e.id,e])).values()];return{...e,prds:n([...e.prds,...t.flatMap(e=>e.prds)]),specs:n([...e.specs,...t.flatMap(e=>e.specs)]),tasks:n([...e.tasks,...t.flatMap(e=>e.tasks)]),changes:n([...e.changes,...t.flatMap(e=>e.changes)])}}function C(){let e=(0,f.useRef)(null);return(0,f.useEffect)(()=>{e.current?.focus()},[]),(0,m.jsx)(`div`,{"aria-busy":`true`,"aria-live":`polite`,className:`period-transition-overlay`,onKeyDownCapture:e=>e.preventDefault(),ref:e,role:`status`,tabIndex:-1,children:(0,m.jsxs)(`div`,{className:`period-transition-overlay__content`,children:[(0,m.jsx)(`i`,{"aria-hidden":`true`,className:`period-transition-overlay__spinner`}),(0,m.jsx)(`span`,{className:`period-transition-overlay__label`,children:`Carregando...`})]})})}function re({pending:e,children:t}){return(0,m.jsx)(`div`,{"aria-hidden":e||void 0,inert:e,children:t})}function ie({children:e,error:t,globalLoadingPending:n,locale:r,onRefresh:i,operations:a,snapshotNotice:o,setupRoute:s}){return s===null?t&&a===null?(0,m.jsxs)(`main`,{className:`app-state`,children:[(0,m.jsx)(`p`,{children:`Dashboard local indisponível`}),(0,m.jsx)(`h1`,{children:`Não foi possível ler o workspace V2.`}),(0,m.jsx)(`pre`,{children:t}),(0,m.jsx)(`button`,{onClick:i,type:`button`,children:`Tentar novamente`})]}):a===null?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(h,{locale:r}),o,n?(0,m.jsx)(C,{}):null]}):e:s}var w=`modulepreload`,T=function(e){return`/`+e},ae={},E=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=T(t,n),t=s(t),t in ae)return;ae[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:w,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},oe=(0,f.lazy)(async()=>({default:(await E(async()=>{let{DashboardHelpDialog:e}=await import(`./DashboardHelpDialog-BgVgrfhQ.js`);return{DashboardHelpDialog:e}},__vite__mapDeps([0,1,2,3,4,5]))).DashboardHelpDialog}));function se({costLocale:e,documentDetail:n,helpOpen:i,loadingArea:a,operations:s,reconciliationResult:c,refreshDialog:l,showTrace:p,trace:h,traceLink:g,traceLoadingTaskId:_,closeDocument:y,onCloseHelp:b,onCloseTrace:x,onDismissReconciliation:S,onOpenDocument:ee,onOpenTrace:te,onOpenTraceChange:ne,onOpenTraceMacro:C,onRefreshCancel:re,onRefreshFromDialog:ie,setTraceLink:w}){return(0,m.jsxs)(m.Fragment,{children:[p?null:_?(0,m.jsx)(d,{locale:e,taskId:_}):h?(0,m.jsx)(u,{locale:e,onClose:x,onOpenChange:ne,onOpenPrd:e=>C(`PRD`,e),onOpenSpec:e=>C(`SPEC`,e),trace:h}):null,g?.kind===`change`?(0,m.jsx)(r,{details:{kind:`change`,row:g.row},locale:e,onClose:()=>w(null)}):null,g?.kind===`macro`?(0,m.jsx)(t,{label:g.label,locale:e,onClose:()=>w(null),onOpenDocument:ee,onOpenTrace:e=>{w(null),te(e)},row:g.row,runs:s.runs,specs:s.specs,tasks:s.tasks}):null,n?(0,m.jsx)(o,{detail:n.detail,error:n.error,label:n.label,locale:e,loading:!n.detail&&!n.error,onClose:y,onRetry:()=>ee(n.kind,n.preview.id),preview:n.preview}):null,i?(0,m.jsx)(f.Suspense,{fallback:null,children:(0,m.jsx)(oe,{locale:e,onClose:b})}):null,l===`choose`?(0,m.jsx)(`div`,{className:`app-refresh-dialog-backdrop`,children:(0,m.jsxs)(`section`,{"aria-label":`Atualizar dashboard`,"aria-modal":`true`,className:`app-refresh-dialog`,role:`dialog`,children:[(0,m.jsx)(`h2`,{children:e===`pt-BR`?`Atualizar dashboard`:`Refresh dashboard`}),(0,m.jsx)(`p`,{children:e===`pt-BR`?`Escolha uma atualização rápida ou reconcilie os itens que ainda estão em aberto.`:`Choose a quick refresh or reconcile work items that are still open.`}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`button`,{onClick:()=>ie(!1),type:`button`,children:e===`pt-BR`?`Apenas atualizar dados`:`Refresh data only`}),(0,m.jsx)(`button`,{onClick:()=>ie(!0),type:`button`,children:e===`pt-BR`?`Reconciliar itens abertos`:`Reconcile open work`})]}),(0,m.jsx)(`button`,{className:`app-refresh-cancel`,onClick:re,type:`button`,children:e===`pt-BR`?`Cancelar`:`Cancel`})]})}):null,l===`refreshing`||l===`reconciling`?(0,m.jsxs)(`section`,{"aria-live":`polite`,className:`app-refresh-status`,role:`status`,children:[(0,m.jsx)(`i`,{}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`strong`,{children:l===`reconciling`?e===`pt-BR`?`Reconciliando itens em aberto…`:`Reconciling open work…`:e===`pt-BR`?`Atualizando dados…`:`Refreshing data…`}),(0,m.jsx)(`span`,{children:e===`pt-BR`?`Você pode continuar usando o dashboard.`:`You can keep using the dashboard.`})]})]}):null,c!==null&&l===null?(0,m.jsxs)(`section`,{"aria-live":`polite`,className:`app-reconciliation-result`,role:`status`,children:[(0,m.jsx)(`strong`,{children:e===`pt-BR`?`Resultado da reconciliação manual`:`Manual reconciliation result`}),(0,m.jsx)(`span`,{children:e===`pt-BR`?`${c.reconciled_ids.length} item(ns) reconciliado(s).`:`${c.reconciled_ids.length} item(s) reconciled.`}),c.reconciled_ids.length>0?(0,m.jsx)(`p`,{children:c.reconciled_ids.join(`, `)}):null,c.blocked.length>0?(0,m.jsxs)(`p`,{children:[e===`pt-BR`?`Bloqueados: `:`Blocked: `,c.blocked.map(e=>`${e.id}${e.reason===null?``:` (${e.reason})`}`).join(`; `)]}):null,c.not_reconciled.length>0?(0,m.jsxs)(`p`,{children:[e===`pt-BR`?`Não reconciliados: `:`Not reconciled: `,c.not_reconciled.map(e=>`${e.id}${e.reason===null?``:` (${e.reason})`}`).join(`; `)]}):null,(0,m.jsx)(`button`,{onClick:S,type:`button`,children:e===`pt-BR`?`Fechar`:`Dismiss`})]}):null,a!==null&&a!==`operations`&&l===null?(0,m.jsx)(v,{area:a,locale:e}):null]})}var ce=(0,f.lazy)(async()=>({default:(await E(async()=>{let{PricingSettingsPage:e}=await import(`./PricingSettingsDialog-vSvvOHQp.js`);return{PricingSettingsPage:e}},__vite__mapDeps([6,1,2,3,4]))).PricingSettingsPage})),le=(0,f.lazy)(async()=>({default:(await E(async()=>{let{ProjectSettingsPage:e}=await import(`./ProjectSettingsPage-zH758vfs.js`);return{ProjectSettingsPage:e}},__vite__mapDeps([7,1,2,3,8]))).ProjectSettingsPage})),ue=(0,f.lazy)(async()=>({default:(await E(async()=>{let{CostCalculationGuidePage:e}=await import(`./CostCalculationGuidePage-ovxurkIk.js`);return{CostCalculationGuidePage:e}},__vite__mapDeps([9,1,2,3]))).CostCalculationGuidePage})),de=`/setup-pricing`,fe=`/setup-project`,pe=`/cost-calculation-guide`;function me(e){let{api:t,costLocale:n,fxRate:r,navigate:i,pathname:a,pricing:o,refresh:s,setFxRate:c,setPricing:l}=e;return a===`/setup-pricing`?o===null?(0,m.jsxs)(`main`,{className:`app-state`,children:[(0,m.jsx)(`p`,{children:n===`pt-BR`?`Configuração do projeto`:`Project settings`}),(0,m.jsx)(`h1`,{children:n===`pt-BR`?`Carregando catálogo de preços…`:`Loading pricing catalog…`}),(0,m.jsx)(`button`,{onClick:()=>i(`/`),type:`button`,children:n===`pt-BR`?`Voltar ao dashboard`:`Back to dashboard`})]}):(0,m.jsx)(f.Suspense,{fallback:null,children:(0,m.jsx)(ce,{catalog:o,fxRate:r,locale:n,onClose:()=>i(`/`),onSave:async e=>{l(await t.savePricing(e)),await s()},onSaveFxRate:async e=>{c(await t.saveFxRate(e)),await s()}})}):a===`/cost-calculation-guide`&&o!==null?(0,m.jsx)(f.Suspense,{fallback:null,children:(0,m.jsx)(ue,{catalog:o,fxRate:r,locale:n,onClose:()=>i(`/`)})}):a===`/setup-project`?(0,m.jsx)(f.Suspense,{fallback:null,children:(0,m.jsx)(le,{api:t,locale:n,onClose:()=>i(`/`)})}):null}var he=`/zaip-cost-monitor`,D=`zaip-dashboard-session-token`,ge=`zaip-dashboard-locale`,O=`zaip-dashboard-currency`;function _e(){return window.localStorage.getItem(`zaip-dashboard-locale`)===`en-US`?`en-US`:`pt-BR`}function ve(e){return e.replace(/\/+$/,``)===he?`cost-monitor`:null}function ye(){let e=new URL(window.location.href),t=e.searchParams.get(`token`)??window.localStorage.getItem(`zaip-dashboard-session-token`)??window.sessionStorage.getItem(`zaip-dashboard-session-token`)??``;return t&&(window.localStorage.setItem(D,t),window.sessionStorage.setItem(D,t)),e.searchParams.has(`token`)&&(e.searchParams.delete(`token`),window.history.replaceState(null,``,`${e.pathname}${e.search}${e.hash}`)),t}var be=(0,f.lazy)(async()=>({default:(await E(async()=>{let{TraceabilityWorkspace:e}=await import(`./TraceabilityWorkspace-DLn-Mz2M.js`);return{TraceabilityWorkspace:e}},__vite__mapDeps([10,1,2,3,11,12,13,14]))).TraceabilityWorkspace}));function xe({costs:e,costLocale:t,currency:n,dashboardView:r,failedArea:i,lastUpdatedAt:a,loadCostDetail:o,loadCostReadModelPage:s,loadCostRunPage:l,loadCostGroupPage:u,loadingArea:d,onActiveDataChange:p,onCurrencyChange:h,onLoadingChange:g,onLocaleChange:v,onOpenTrace:b,onLoadMoreTraceTasks:x,onRefresh:S,onRetry:ee,onSelectTraceTask:te,onOpenTraceChange:ne,onOpenTraceMacro:C,operations:re,selectedTraceTaskId:ie,trace:w,traceLoadingTaskId:T,traceTasksHasMore:ae,traceTasksLoading:E,traceTasks:oe}){return r===`cost-monitor`?e===null?()=>i===`costs`?(0,m.jsx)(y,{locale:t,onRetry:ee}):(0,m.jsx)(_,{area:`costs`,locale:t}):r=>(0,m.jsx)(f.Suspense,{fallback:(0,m.jsx)(_,{area:`costs`,locale:t}),children:(0,m.jsx)(c,{currency:n,data:e,embedded:!0,globalFilters:r,lastUpdatedAt:a,locale:t,loading:d===`costs`,loadDetail:o,loadReadModelPage:s,loadRunPage:l,loadGroupPage:u,onActiveDataChange:p,onCurrencyChange:h,onLoadingChange:g,onLocaleChange:v,onOpenTrace:b,onRefresh:S,operations:re})}):r===`traceability`?()=>(0,m.jsx)(f.Suspense,{fallback:(0,m.jsx)(_,{area:`operations`,locale:t}),children:(0,m.jsx)(be,{loadingTaskId:T,locale:t,onOpenChange:ne,onOpenPrd:e=>C(`PRD`,e),onOpenSpec:e=>C(`SPEC`,e),onLoadMoreTasks:x,onSelectTask:te,selectedTaskId:ie,tasks:oe.length>0?oe:re.tasks,hasMoreTasks:ae,isLoadingTasks:E,trace:w})}):r===null?(0,m.jsx)(`span`,{"aria-hidden":`true`,hidden:!0}):void 0}var k={"pt-BR":{label:`Áreas do dashboard`,operations:`Operação`,operationsHint:`Trabalho em andamento e priorização`,costs:`Monitor de Custos`,costsHint:`Tempo, tokens e custo`,traceability:`Rastreabilidade`,traceabilityHint:`Ciclo completo em 6 etapas`},"en-US":{label:`Dashboard areas`,operations:`Operations`,operationsHint:`Lifecycle and work in progress`,costs:`Cost Monitor`,costsHint:`Time, tokens, and cost`,traceability:`Traceability`,traceabilityHint:`Complete 6-stage lifecycle`}};function Se({activeView:e,locale:t,onChange:n}){let r=k[t],i=e=>{n(e),window.requestAnimationFrame(()=>{document.querySelector(`.dashboard-global-controls`)?.scrollIntoView({behavior:`smooth`,block:`start`})})};return(0,m.jsxs)(`nav`,{"aria-label":r.label,className:`dashboard-capability-nav`,children:[(0,m.jsxs)(`button`,{"aria-current":e===`cost-monitor`?`page`:void 0,className:e===`cost-monitor`?`is-active`:void 0,onClick:()=>i(`cost-monitor`),type:`button`,children:[(0,m.jsx)(Ce,{}),(0,m.jsxs)(`span`,{children:[(0,m.jsx)(`strong`,{children:r.costs}),(0,m.jsx)(`small`,{children:r.costsHint})]})]}),(0,m.jsxs)(`button`,{"aria-current":e===`operations`?`page`:void 0,className:e===`operations`?`is-active`:void 0,onClick:()=>i(`operations`),type:`button`,children:[(0,m.jsx)(A,{}),(0,m.jsxs)(`span`,{children:[(0,m.jsx)(`strong`,{children:r.operations}),(0,m.jsx)(`small`,{children:r.operationsHint})]})]}),(0,m.jsxs)(`button`,{"aria-current":e===`traceability`?`page`:void 0,className:e===`traceability`?`is-active`:void 0,onClick:()=>i(`traceability`),type:`button`,children:[(0,m.jsx)(j,{}),(0,m.jsxs)(`span`,{children:[(0,m.jsx)(`strong`,{children:r.traceability}),(0,m.jsx)(`small`,{children:r.traceabilityHint})]})]})]})}function A(){return(0,m.jsxs)(`svg`,{"aria-hidden":`true`,className:`lucide lucide-square-kanban`,viewBox:`0 0 24 24`,children:[(0,m.jsx)(`rect`,{height:`18`,rx:`2`,width:`18`,x:`3`,y:`3`}),(0,m.jsx)(`path`,{d:`M8 7v7`}),(0,m.jsx)(`path`,{d:`M12 7v4`}),(0,m.jsx)(`path`,{d:`M16 7v9`})]})}function Ce(){return(0,m.jsxs)(`svg`,{"aria-hidden":`true`,className:`lucide lucide-circle-dollar-sign`,viewBox:`0 0 24 24`,children:[(0,m.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,m.jsx)(`path`,{d:`M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8`}),(0,m.jsx)(`path`,{d:`M12 18V6`})]})}function j(){return(0,m.jsxs)(`svg`,{"aria-hidden":`true`,className:`lucide lucide-route`,viewBox:`0 0 24 24`,children:[(0,m.jsx)(`circle`,{cx:`6`,cy:`19`,r:`3`}),(0,m.jsx)(`path`,{d:`M9 19h6.5a3.5 3.5 0 0 0 0-7h-7a3.5 3.5 0 0 1 0-7H18`}),(0,m.jsx)(`circle`,{cx:`18`,cy:`5`,r:`3`})]})}function we({currency:e,locale:t,onCurrencyChange:n,onHelpOpen:r,onNavigate:i,pricingSetupPath:a,projectSetupPath:o,costCalculationGuidePath:s}){return(0,m.jsxs)(`div`,{className:`dashboard-global-settings`,children:[(0,m.jsxs)(`label`,{children:[(0,m.jsx)(`span`,{children:t===`pt-BR`?`Moeda`:`Currency`}),(0,m.jsxs)(`select`,{"aria-label":t===`pt-BR`?`Moeda`:`Currency`,onChange:e=>n(e.target.value),value:e,children:[(0,m.jsx)(`option`,{value:`BRL`,children:`BRL · Real brasileiro`}),(0,m.jsx)(`option`,{value:`USD`,children:`USD · US Dollar`})]})]}),(0,m.jsx)(`button`,{className:`dashboard-help-open`,onClick:r,type:`button`,children:t===`pt-BR`?`Central de Ajuda`:`Open help and guides`}),(0,m.jsx)(`button`,{className:`dashboard-help-open`,onClick:()=>i(a),type:`button`,children:t===`pt-BR`?`Configurar preços e câmbio`:`Configure pricing and FX`}),(0,m.jsx)(`button`,{className:`dashboard-help-open`,onClick:()=>i(o),type:`button`,children:t===`pt-BR`?`Configurar projeto`:`Configure project`})]})}var Te=class{token;constructor(e){this.token=e}ready(){return this.get(`/api/v2/ready`)}operations(e,t=`detail`,n,r=!1){let a=`${i.operations}?scope=${t}${r?`&fresh=1`:``}`;return this.get(F(a,e),n)}sqliteViewPage(e,t,n={},r){let i=new URLSearchParams({view:e,offset:String(n.offset??0)});return n.limit!==void 0&&i.set(`limit`,String(n.limit)),n.query&&i.set(`query`,n.query),n.status&&i.set(`status`,n.status),n.risk&&i.set(`risk`,n.risk),n.provider&&i.set(`provider`,n.provider),n.model&&i.set(`model`,n.model),n.agent&&i.set(`agent`,n.agent),n.phase&&i.set(`phase`,n.phase),n.origin&&i.set(`origin`,n.origin),n.workType&&i.set(`workType`,n.workType),n.priority&&i.set(`priority`,n.priority),n.kind&&i.set(`kind`,n.kind),this.get(F(`/api/v2/sqlite-views?${i.toString()}`,t),r)}operationsBoard(e,t,n=0,r,a,o=4){let s=new URLSearchParams({scope:`board`,stage:t,offset:String(n),limit:String(o)});return r?.query&&s.set(`query`,r.query),r?.status&&s.set(`status`,r.status),r?.risk&&s.set(`risk`,r.risk),r?.origin&&s.set(`origin`,r.origin),r?.kind&&s.set(`kind`,r.kind),this.get(F(`${i.operations}?${s.toString()}`,e),a)}operationsClassification(e,t,n,r=0,a,o=50){let s=new URLSearchParams({scope:`classification`,kind:t,classification:n,offset:String(r),limit:String(o)});return this.get(F(`${i.operations}?${s.toString()}`,e),a)}operationsEntityPage(e,t,n=0,r,a){let o=M(t,n,r);return this.get(F(`${i.operations}/runs?${o}`,e),a)}operationsLifecyclePage(e,t,n=0,r,a){let o=M(t,n,r);return this.get(F(`${i.operations}/entities?${o}`,e),a)}operationsReadModelPage(e,t,n=0,r=50,a=``,o){let s=new URLSearchParams({kind:t,offset:String(n),limit:String(r)});return a&&s.set(`query`,a),this.get(F(`${i.operations}/read-models?${s.toString()}`,e),o)}costMonitor(e=`BRL`,t,n=`detail`,r,a,o=!1){let s=new URLSearchParams({currency:e,scope:n});o&&s.set(`fresh`,`1`);for(let[e,t]of Object.entries(a??{}))t&&s.set(e,t);return this.get(F(`${i.costMonitor}?${s.toString()}`,t),r)}costMonitorRuns(e=`BRL`,t,n,r=100,a,o){let s=new URLSearchParams({currency:e,scope:`runs`,offset:String(n),limit:String(r)});for(let[e,t]of Object.entries(o??{}))t&&s.set(e,t);return this.get(F(`${i.costMonitor}?${s.toString()}`,t),a)}snapshot(e=`BRL`,t){return this.get(F(`${i.snapshot}?currency=${e}`,t))}reconcileOpenWork(e=`BRL`,t){return this.post(F(`${i.reconcileOpenWork}?currency=${e}`,t),Ee)}refreshProjection(e=`BRL`,t){return this.post(F(`${i.refreshProjection}?currency=${e}`,t),Ee)}task(e){return this.get(i.task(e))}prd(e){return this.get(i.prd(e))}spec(e){return this.get(i.spec(e))}taskTrace(e,t){return this.get(i.taskTrace(e),t)}pricing(){return this.get(`/api/v2/pricing`)}async savePricing(e){let t=await fetch(`/api/v2/pricing`,{method:`PUT`,headers:{"content-type":`application/json`,"x-zaip-session":this.token},body:JSON.stringify(e)});if(!t.ok)throw Error(`Pricing update failed with HTTP ${t.status}`);return await t.json()}fxRate(){return this.get(`/api/v2/fx-rate`)}agentCatalog(){return this.get(i.agentCatalog)}agentPortraitUrl(e){return`/api/v2/agent-catalog-assets/${encodeURIComponent(e)}?token=${encodeURIComponent(this.token)}`}projectSettings(){return this.get(i.projectSettings)}projectOverview(){return this.get(`${i.projectSettings}/overview`)}async saveWorkPriority(e){let t=await fetch(i.workPriority,{method:`PUT`,headers:{"content-type":`application/json`,"x-zaip-session":this.token},body:JSON.stringify({item_ids:e})});if(!t.ok)throw Error(`Work priority update failed with HTTP ${t.status}`);return await t.json()}async saveProjectSettings(e){let t=await fetch(i.projectSettings,{method:`PUT`,headers:{"content-type":`application/json`,"x-zaip-session":this.token},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error??`Project settings update failed with HTTP ${t.status}`)}return await t.json()}async saveAgentCatalog(e){let t=e.map(({nickname_candidates:e,...t})=>t),n=await fetch(i.agentCatalog,{method:`PUT`,headers:{"content-type":`application/json`,"x-zaip-session":this.token},body:JSON.stringify({agents:t})});if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error??`Agent catalog update failed with HTTP ${n.status}`)}return await n.json()}async saveFxRate(e){let t=await fetch(`/api/v2/fx-rate`,{method:`PUT`,headers:{"content-type":`application/json`,"x-zaip-session":this.token},body:JSON.stringify({rate:e})});if(!t.ok)throw Error(`FX update failed with HTTP ${t.status}`);return await t.json()}async get(e,t){let n=await P(e,{cache:`no-cache`,headers:{"x-zaip-session":this.token}},N,t);if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error??`Dashboard API failed with HTTP ${n.status}`)}return await n.json()}async post(e,t=N){let n=await P(e,{method:`POST`,headers:{"x-zaip-session":this.token}},t);if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error??`Dashboard API failed with HTTP ${n.status}`)}return await n.json()}};function M(e,t,n){let r=new URLSearchParams({kind:e,offset:String(t),limit:`100`});return n?.query&&r.set(`query`,n.query),n?.status&&r.set(`status`,n.status),n?.risk&&r.set(`risk`,n.risk),r.toString()}var N=6e4,Ee=18e4;async function P(e,t,n=N,r){let i=new AbortController,a=()=>i.abort();r?.addEventListener(`abort`,a,{once:!0}),r?.aborted&&i.abort();let o=window.setTimeout(()=>i.abort(),n);try{return await fetch(e,{...t,signal:i.signal})}catch(e){throw e instanceof DOMException&&e.name===`AbortError`?Error(`A leitura demorou mais de ${Math.ceil(n/1e3)} segundos. Tente novamente.`):e}finally{window.clearTimeout(o),r?.removeEventListener(`abort`,a)}}function F(e,t){if(t===void 0)return e;let n=new URL(e,`http://dashboard.local`);return t.from!==null&&n.searchParams.set(`from`,t.from),t.to!==null&&n.searchParams.set(`to`,t.to),`${n.pathname}${n.search}`}var De={preset:`this-month`,range:a(`this-month`)};function I(e){return e.preset===`all`?{from:null,to:null}:{from:e.range.start,to:e.range.end}}var Oe=1500;function ke({snapshotUpdating:e,initialDataPending:t,dismissed:n,delayElapsed:r}){return e&&t&&!n&&r}function Ae({cursor:e,page:t,tasks:n}){let r=new Map(n.map(e=>[e.id,e]));for(let e of t.tasks)r.set(e.id,e);let i=e.offset+t.tasks.length;return{tasks:[...r.values()],cursor:t.tasks.length===0||i>=t.total?{offset:0,stageIndex:e.stageIndex+1}:{...e,offset:i}}}function je(e,t,n){return Math.min(t,e+n)}function L(e){return typeof e==`number`?e:null}function Me(e){return typeof e==`number`?{known_sum:e,unknown:0,complete:!0,coverage_ratio:1}:{known_sum:0,unknown:1,complete:!1,coverage_ratio:0}}function R(e){return Object.hasOwn(e,`total_duration`)?L(e.total_duration):L(e.cost_monitor_total_duration)}function Ne(e,t,n){let{filters:r,query:i}=e;return{offset:t,limit:n,...i===void 0||i===``?{}:{query:i},...r.provider?{provider:r.provider}:{},...r.model?{model:r.model}:{},...r.agent?{agent:r.agent}:{},...r.phase?{phase:r.phase}:{},...r.status?{status:r.status}:{},...r.origin?{origin:r.origin}:{},...r.workType?{workType:r.workType}:{},...r.priority?{priority:r.priority}:{},...r.risk?{risk:r.risk}:{}}}function z(e){let t=R(e),n=Number(e.duration_unknown??+(t===null)),r=L(e.duration_known)??t??0;return{key:String(e.key??e.period_key??`total`),label:String(e.label??e.key??e.period_key??``),latest_started_at:typeof e.latest_started_at==`string`?e.latest_started_at:``,persona:typeof e.persona==`string`?e.persona:null,job:typeof e.job==`string`?e.job:null,run_count:Number(e.total_run_count??e.invocation_count??0),task_count:L(e.task_count),prd_count:Number(e.prd_count??0),spec_count:Number(e.spec_count??0),evidence_count:Number(e.evidence_count??0),test_count:Number(e.validation_count??0),event_count:Number(e.source_event_count??0),total_tokens:L(e.total_tokens),estimated_usd:L(e.total_cost_usd),estimated_brl:L(e.total_cost_brl),duration_ms:t,duration:{known_sum:r,unknown:n,complete:n===0,coverage_ratio:+(n===0)},coverage:{events:0,tokens:0,usd:0,brl:0}}}async function Pe(e,t){let{from:n,limit:r,offset:i,signal:a,to:o,view:s}=t,c=n===void 0||o===void 0?void 0:{from:n,to:o};if(s===`daily`){let n=await e.sqliteViewPage(`cost_monitor_daily`,c,Ne(t,i,r),a);return{offset:n.offset,limit:n.limit,total_count:n.total_count,has_more:n.has_more,rows:n.rows.map(z),...n.totals===void 0?{}:{totals:z(n.totals)}}}let l={monthly:`cost_monitor_monthly`,annual:`cost_monitor_annual`,agents:`cost_monitor_zaip_agents`,models:`cost_monitor_models`,providers:`cost_monitor_providers`}[s],u=await e.sqliteViewPage(l,c,Ne(t,i,r),a);return{offset:u.offset,limit:u.limit,total_count:u.total_count,has_more:u.has_more,rows:u.rows.map(z),...u.totals===void 0?{}:{totals:z(u.totals)}}}async function Fe(e,t){let{filters:n,from:r,limit:i=10,offset:a,signal:o,to:s}=t,c=await e.sqliteViewPage(`cost_monitor_agent_invocations`,r===void 0||s===void 0?void 0:{from:r,to:s},{offset:a,limit:i,...n?.query?{query:n.query}:{},...n?.provider?{provider:n.provider}:{},...n?.model?{model:n.model}:{},...n?.agent?{agent:n.agent}:{},...n?.phase?{phase:n.phase}:{},...n?.status?{status:n.status}:{}},o);return{page_only:!0,runs:c.rows.map(Ie),run_page:{offset:c.offset,limit:c.limit,total:c.total_count,has_more:c.has_more}}}function Ie(e){let t=(e,t)=>typeof e==`string`?e:t,n=e=>typeof e==`number`?e:null,r=t(e.agent_invocation_id,`unavailable`),i=typeof e.task_id==`string`?e.task_id:null,a=typeof e.spec_id==`string`?e.spec_id:null,o=typeof e.prd_id==`string`?e.prd_id:null,s=t(e.phase,`execution`),c=e.duration_provenance===`observed`||e.duration_provenance===`reconciled`||e.duration_provenance===`estimated`||e.duration_provenance===`legacy_inferred`?e.duration_provenance:`unavailable`,l=Object.hasOwn(e,`calculated_cost_usd`)?n(e.calculated_cost_usd):n(e.cost_usd),u=n(e.current_fx_rate)??n(e.fx_rate),d=n(e.recorded_cost_usd)??n(e.recorded_usd),f=Object.hasOwn(e,`recorded_fx_rate`)?n(e.recorded_fx_rate):n(e.fx_rate),p=n(e.recorded_brl)??(!Object.hasOwn(e,`recorded_brl`)&&d!==null?n(e.cost_brl):null),m=l!==null&&u!==null?Math.round(l*u*1e6)/1e6:null;return{run_id:r,execution_id:typeof e.execution_id==`string`?e.execution_id:null,conversation_id:t(e.run_id,r),task_id:i,task_title:t(e.task_title,i??`Tarefa avulsa`),task_status:t(e.task_status,`unavailable`),priority:t(e.priority,`unavailable`),risk:t(e.risk,`unavailable`),spec_id:a,prd_id:o,change_id:typeof e.change_id==`string`?e.change_id:null,parent_run_id:typeof e.parent_agent_invocation_id==`string`?e.parent_agent_invocation_id:null,run_role:e.invocation_kind===`subagent`?`subagent`:`orchestrator`,run_kind:e.run_kind===`subrun`?`subrun`:`run`,run_purpose:`execution`,requires_finalizer:!1,client:t(e.client,`unavailable`),agent:t(e.zaip_agent,`unavailable`),agent_name:t(e.zaip_agent,`unavailable`),provider:typeof e.provider==`string`?e.provider:null,model:t(e.model,`unavailable`),requested_model:t(e.requested_model,`unavailable`),reasoning_effort:typeof e.reasoning_effort==`string`?e.reasoning_effort:null,effective_reasoning_effort:typeof e.effective_reasoning_effort==`string`?e.effective_reasoning_effort:null,service_tier:typeof e.service_tier==`string`?e.service_tier:null,call_count:n(e.llm_call_count),status:t(e.status,`completed`),phase:s,origin:o===null?a===null?i===null?`conversation`:`task`:`spec`:`prd`,work_type:e.work_type===`rework`?`rework`:`new`,started_at:t(e.occurred_at,``),finished_at:typeof e.finished_at==`string`?e.finished_at:null,duration_ms:n(e.duration_ms),duration_provenance:c,estimation_basis:typeof e.estimation_basis==`string`?e.estimation_basis:null,source_started_at:typeof e.source_started_at==`string`?e.source_started_at:null,source_finished_at:typeof e.source_finished_at==`string`?e.source_finished_at:null,capture_lag_ms:n(e.capture_lag_ms),event_count:n(e.source_event_count),input_tokens:n(e.input_tokens),cached_input_tokens:n(e.cached_input_tokens),output_tokens:n(e.output_tokens),reasoning_tokens:n(e.reasoning_tokens),total_tokens:n(e.total_tokens),uncached_input_tokens:n(e.uncached_input_tokens),visible_output_tokens:n(e.visible_output_tokens),input_rate_usd_per_million:n(e.input_rate_usd_per_million),cached_input_rate_usd_per_million:n(e.cached_input_rate_usd_per_million),output_rate_usd_per_million:n(e.output_rate_usd_per_million),reasoning_rate_usd_per_million:n(e.reasoning_rate_usd_per_million),context_input_multiplier:n(e.context_input_multiplier),context_output_multiplier:n(e.context_output_multiplier),speed_cost_multiplier:n(e.speed_cost_multiplier),standard_cost_usd:n(e.standard_cost_usd),speed_uplift_usd:n(e.speed_uplift_usd),input_cost_usd:n(e.input_cost_usd),cached_input_cost_usd:n(e.cached_input_cost_usd),output_cost_usd:n(e.output_cost_usd),reasoning_cost_usd:n(e.reasoning_cost_usd),fx_rate:u,estimated_usd:l,estimated_brl:m,recorded_usd:d,recorded_brl:p,recorded_fx_rate:f,coverage:{events:0,tokens:0,usd:0,brl:0},artifact_path:`.agents/records/runs/${r}`}}function Le(e,t){let n=t.totals,r=e=>Me(n?.[e]);return{data_source:`lifecycle_daily_read_models`,snapshot_id:null,source_latest_at:null,kind:e,offset:t.offset,limit:t.limit,total:t.total_count,has_more:t.has_more,next_cursor:null,subtotal:{entity_count:typeof n?.entity_count==`number`?n.entity_count:t.total_count,run_count:r(`invocation_count`),metrics:{duration:r(`total_duration`),total_tokens:r(`total_tokens`),cost_brl:r(`total_cost_brl`),cost_usd:r(`total_cost_usd`)}},rows:t.rows.map(t=>({id:String(t.task_id??t.spec_id??t.prd_id??t.execution_id??t.conversation_id??t.id??`unavailable`),title:String(t.title??t.task_id??t.spec_id??t.prd_id??t.execution_id??t.conversation_id??`Unavailable`),kind:e===`tasks`?`task`:e===`specs`?`spec`:e===`prds`?`prd`:e===`executions`?`execution`:`conversation`,status:typeof t.status==`string`?t.status:null,risk:typeof t.risk==`string`?t.risk:null,occurred_at:typeof t.occurred_at==`string`?t.occurred_at:typeof t.started_at==`string`?t.started_at:typeof t.last_day==`string`?`${t.last_day}T12:00:00.000Z`:``,parent_id:null,run_count:Number(t.invocation_count??0),cost_currency:`BRL`,metrics:{duration:Me(t.total_duration),total_tokens:Me(t.total_tokens),cost:Me(t.total_cost_brl)}}))}}function Re(e){return{loadCostDetail:(0,f.useCallback)(async()=>{throw Error(`SQLite Cost Monitor loads the selected paginated view; full detail is disabled.`)},[]),loadCostReadModelPage:(0,f.useCallback)(async({filters:t,from:n,kind:r,limit:i,offset:a,query:o,signal:s,to:c})=>{let l={tasks:`cost_monitor_tasks`,specs:`cost_monitor_specs`,prds:`cost_monitor_prds`,executions:`cost_monitor_executions`,conversations:`cost_monitor_conversations`}[r];return Le(r,await e.sqliteViewPage(l,n===void 0||c===void 0?void 0:{from:n,to:c},{offset:a,limit:i,...o===void 0||o===``?{}:{query:o},...t.provider?{provider:t.provider}:{},...t.model?{model:t.model}:{},...t.agent?{agent:t.agent}:{},...t.phase?{phase:t.phase}:{},...t.status?{status:t.status}:{},...t.origin?{origin:t.origin}:{},...t.workType?{workType:t.workType}:{},...t.priority?{priority:t.priority}:{},...t.risk?{risk:t.risk}:{}},s))},[e]),loadCostRunPage:(0,f.useCallback)(t=>Fe(e,t),[e]),loadCostGroupPage:(0,f.useCallback)(t=>Pe(e,t),[e])}}function ze(e,t){return!1}function Be(e,t=window,n=0){let r=!1,i=!1,a=new AbortController,o=t.setTimeout(()=>{r||i||(i=!0,e(a.signal))},n);return()=>{r||(r=!0,a.abort(),t.clearTimeout(o))}}function Ve({inFlight:e,lastRefreshAt:t,now:n,visibilityState:r}){return r===`visible`&&!e&&n-t>=5e3}function He({api:e,costLocale:t,currency:n,dashboardView:r,loadOperationsDetails:i,operations:a,operationsDetailAbortRef:o,operationsDetailCancelRef:s,operationsPageAbortRef:c,pathname:l,pricing:u,refresh:d,refreshVersion:p,setError:m,setFxRate:h,setPathname:g,setPricing:_}){let v=(0,f.useRef)(!1),y=(0,f.useRef)(0);(0,f.useEffect)(()=>(d(),()=>{s.current?.(),s.current=null,o.current?.abort(),o.current=null,c.current?.abort(),c.current=null,++p.current}),[o,s,c,d,p]),(0,f.useEffect)(()=>{let e=()=>{let e=Date.now();Ve({inFlight:v.current,lastRefreshAt:y.current,now:e,visibilityState:document.visibilityState})&&(y.current=e,v.current=!0,d(!1,!1,!0).finally(()=>{v.current=!1}))};return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,e)}},[d]),(0,f.useEffect)(()=>{if(!ze(r,a?.summary.overview_metrics?.partial===!0))return;let e=Be(async e=>{await i(e)});return s.current=e,()=>{s.current===e&&(s.current=null),e()}},[r,i,a?.summary.overview_metrics?.partial,s]),(0,f.useEffect)(()=>window.localStorage.setItem(ge,t),[t]),(0,f.useEffect)(()=>window.localStorage.setItem(O,n),[n]),(0,f.useEffect)(()=>{[`/`,`/setup-pricing`,`/setup-project`].includes(window.location.pathname)||(window.history.replaceState(null,``,`/${window.location.search}${window.location.hash}`),g(`/`))},[g]),(0,f.useEffect)(()=>{let e=()=>g(window.location.pathname);return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[g]),(0,f.useEffect)(()=>{l!==`/setup-pricing`||u!==null||Promise.all([e.pricing(),e.fxRate()]).then(([e,t])=>{_(e),h(t)}).catch(e=>m(String(e)))},[e,l,u,m,h,_])}var B={events:0,tokens:{input:null,cached_input:null,output:null,reasoning:null,total:null},cost:{usd:null,brl:null},coverage:{events:0,tokens:0,usd:0,brl:0}};function Ue(e,t,n){let r=e=>e===`intake`||e===`orchestration`||e===`execution`||e===`review`||e===`audit`||e===`finalization`?e:`execution`,i=n.rows.map(e=>({id:e.id,artifact_path:`.agents/records/runs/${e.id}`,status:e.status===`running`||e.status===`failed`||e.status===`cancelled`?e.status:`completed`,phase:e.phase??`execution`,entrypoint:e.conversation_id===null?`task`:`conversation`,work_type:`new`,run_role:e.run_kind===`subrun`?`subagent`:`orchestrator`,run_kind:e.run_kind??`run`,run_purpose:r(e.run_purpose),requires_finalizer:!1,parent_run_id:e.parent_run_id,client:e.client??`unknown`,agent:e.agent??`unknown`,agent_name:e.agent??`unknown`,agent_persona:e.agent_persona??null,agent_job:e.agent_job??null,provider:e.provider??null,model:e.model??`unknown`,reasoning_effort:e.reasoning_effort??null,effective_model:e.model??null,effective_reasoning_effort:e.reasoning_effort??null,effective_config_mixed:e.pricing_mixed??!1,service_tier:e.service_tier??null,call_count:e.llm_call_count??null,terminal_call_count:null,failed_call_count:null,cancelled_call_count:null,conversation_id:e.conversation_id??e.id,execution_id:e.execution_id,task_id:e.task_id,spec_id:null,prd_id:null,change_id:null,started_at:e.started_at,finished_at:e.finished_at,duration_ms:e.duration_ms,source_duration_ms:e.source_duration_ms===void 0?e.duration_ms:e.source_duration_ms,duration_provenance:e.duration_provenance===`observed`||e.duration_provenance===`reconciled`||e.duration_provenance===`legacy_inferred`||e.duration_provenance===`estimated`?e.duration_provenance:`unavailable`,llm_call_count:e.llm_call_count??null,input_tokens:e.input_tokens??null,cached_input_tokens:e.cached_input_tokens??null,uncached_input_tokens:e.uncached_input_tokens??null,output_tokens:e.output_tokens??null,reasoning_tokens:e.reasoning_tokens??null,visible_output_tokens:e.visible_output_tokens??null,input_rate_usd_per_million:e.input_rate_usd_per_million??null,cached_input_rate_usd_per_million:e.cached_input_rate_usd_per_million??null,output_rate_usd_per_million:e.output_rate_usd_per_million??null,reasoning_rate_usd_per_million:e.reasoning_rate_usd_per_million??null,context_input_multiplier:e.context_input_multiplier??null,context_output_multiplier:e.context_output_multiplier??null,speed_cost_multiplier:e.speed_cost_multiplier??null,pricing_scenario:e.pricing_scenario??null,standard_cost_usd:e.standard_cost_usd??null,speed_uplift_usd:e.speed_uplift_usd??null,input_cost_usd:e.input_cost_usd??null,cached_input_cost_usd:e.cached_input_cost_usd??null,output_cost_usd:e.output_cost_usd??null,reasoning_cost_usd:e.reasoning_cost_usd??null,calculated_cost_usd:e.calculated_cost_usd??null,recorded_cost_usd:e.recorded_cost_usd??null,cost_variance_usd:e.cost_variance_usd??null,cost_usd:e.cost_usd??null,cost_brl:e.currency===`BRL`?e.cost:null,fx_rate:e.fx_rate??null,pricing_segment_count:e.pricing_segment_count??null,pricing_mixed:e.pricing_mixed??!1,pricing_model:e.pricing_model??null,pricing_source:e.pricing_source??null,...e.lifecycle_elapsed_ms===void 0?{}:{lifecycle_elapsed_ms:e.lifecycle_elapsed_ms},usage:{conversation:B,planning:B,execution:{...B,events:e.llm_call_count??0,tokens:{input:e.input_tokens??null,cached_input:e.cached_input_tokens??null,output:e.output_tokens??null,reasoning:e.reasoning_tokens??null,total:e.total_tokens},cost:{usd:e.cost_usd??null,brl:e.currency===`BRL`?e.cost:null}},total:{...B,events:e.llm_call_count??0,tokens:{input:e.input_tokens??null,cached_input:e.cached_input_tokens??null,output:e.output_tokens??null,reasoning:e.reasoning_tokens??null,total:e.total_tokens},cost:{usd:e.cost_usd??null,brl:e.currency===`BRL`?e.cost:null}},new_work:B,rework:B}}));return{...e,runs:i,executions:t===`executions`||t===`conversations`?n.rows.map((e,n)=>{let r=i[n],a=r.execution_id??r.conversation_id,o=e.status??`unavailable`;return{id:a,kind:t===`conversations`?`interaction`:`delivery`,created_at:r.started_at,status:o,work_status:o,origin:t===`conversations`?{type:`interaction`,conversation_id:r.conversation_id}:{type:`task`,task_id:r.task_id??`unavailable`},dag:{nodes:[],topological_order:[]},result:null,artifact_path:`.agents/records/executions/${a}`,agent_call_count:0,orchestrator_run_count:0,subagent_run_count:0,finalizer_run_count:0,finalized_task_count:0,llm_call_count:0,llm_call_count_complete:!1,task_count:0,spec_count:0,prd_count:0,duration_ms:r.source_duration_ms??null,...e.lifecycle_elapsed_ms===void 0?{}:{lifecycle_elapsed_ms:e.lifecycle_elapsed_ms},total_tokens:r.usage.total.tokens.total,cost_brl:r.usage.total.cost.brl}}):e.executions}}function We(e){if(typeof e!=`string`)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function Ge({api:e,entityFiltersRef:t,operationsPageAbortRef:n,operationsPageRequestVersionRef:r,operationsPeriod:i,operationsPeriodRef:a,refreshVersion:o,setEntityPage:s,setEntityPageKind:c,setOperations:l}){return{loadOperationsEntityPage:(0,f.useCallback)(async(u,d=0,f=t.current)=>{n.current?.abort();let p=new AbortController;n.current=p;let m=++r.current,h=o.current,g=I(i),_=()=>te(m,r.current,p.signal)&&x(h,o.current,g,I(a.current));c(u),s({offset:d,total:null,loading:!0,error:null});try{let t={runs:`operations_agent_invocations`,executions:`operations_executions`,conversations:`operations_conversations`}[u],n=await e.sqliteViewPage(t,g,{offset:d,limit:100,...f.query?{query:f.query}:{},...f.status?{status:f.status}:{},...f.risk?{risk:f.risk}:{}},p.signal),r={kind:u,offset:n.offset,limit:n.limit,total:n.total_count,aggregation:`canonical_entity`,rows:n.rows.map(e=>({id:String(e.agent_invocation_id??e.execution_id??e.conversation_id??e.id),started_at:String(e.occurred_at??e.started_at??`1970-01-01T00:00:00.000Z`),finished_at:typeof e.finished_at==`string`?e.finished_at:null,task_id:typeof e.task_id==`string`?e.task_id:null,execution_id:typeof e.execution_id==`string`?e.execution_id:null,conversation_id:typeof e.conversation_id==`string`?e.conversation_id:null,parent_run_id:typeof e.parent_agent_invocation_id==`string`?e.parent_agent_invocation_id:null,run_kind:e.invocation_kind===`delegated`||e.invocation_kind===`subagent`?`subrun`:e.invocation_kind===`orchestrator`?`run`:null,run_purpose:typeof e.purpose==`string`?e.purpose:null,phase:typeof e.phase==`string`?e.phase:null,status:typeof e.status==`string`?e.status:null,agent:typeof e.zaip_agent==`string`?e.zaip_agent:null,agent_persona:typeof e.zaip_agent_persona==`string`?e.zaip_agent_persona:null,agent_job:typeof e.zaip_agent_job==`string`?e.zaip_agent_job:null,client:typeof e.client==`string`?e.client:null,provider:typeof e.provider==`string`?e.provider:null,model:typeof e.model==`string`?e.model:null,reasoning_effort:typeof e.reasoning_effort==`string`?e.reasoning_effort:null,service_tier:typeof e.service_tier==`string`?e.service_tier:null,duration_ms:typeof e.duration_ms==`number`?e.duration_ms:typeof e.total_duration==`number`?e.total_duration:null,source_duration_ms:typeof e.source_duration_ms==`number`?e.source_duration_ms:null,duration_provenance:typeof e.duration_provenance==`string`?e.duration_provenance:null,llm_call_count:typeof e.llm_call_count==`number`?e.llm_call_count:null,input_tokens:typeof e.input_tokens==`number`?e.input_tokens:null,cached_input_tokens:typeof e.cached_input_tokens==`number`?e.cached_input_tokens:null,uncached_input_tokens:typeof e.uncached_input_tokens==`number`?e.uncached_input_tokens:null,output_tokens:typeof e.output_tokens==`number`?e.output_tokens:null,reasoning_tokens:typeof e.reasoning_tokens==`number`?e.reasoning_tokens:null,visible_output_tokens:typeof e.visible_output_tokens==`number`?e.visible_output_tokens:null,total_tokens:typeof e.total_tokens==`number`?e.total_tokens:null,input_rate_usd_per_million:typeof e.input_rate_usd_per_million==`number`?e.input_rate_usd_per_million:null,cached_input_rate_usd_per_million:typeof e.cached_input_rate_usd_per_million==`number`?e.cached_input_rate_usd_per_million:null,output_rate_usd_per_million:typeof e.output_rate_usd_per_million==`number`?e.output_rate_usd_per_million:null,reasoning_rate_usd_per_million:typeof e.reasoning_rate_usd_per_million==`number`?e.reasoning_rate_usd_per_million:null,context_input_multiplier:typeof e.context_input_multiplier==`number`?e.context_input_multiplier:null,context_output_multiplier:typeof e.context_output_multiplier==`number`?e.context_output_multiplier:null,speed_cost_multiplier:typeof e.speed_cost_multiplier==`number`?e.speed_cost_multiplier:null,pricing_scenario:typeof e.pricing_scenario==`string`?e.pricing_scenario:null,standard_cost_usd:typeof e.standard_cost_usd==`number`?e.standard_cost_usd:null,speed_uplift_usd:typeof e.speed_uplift_usd==`number`?e.speed_uplift_usd:null,input_cost_usd:typeof e.input_cost_usd==`number`?e.input_cost_usd:null,cached_input_cost_usd:typeof e.cached_input_cost_usd==`number`?e.cached_input_cost_usd:null,output_cost_usd:typeof e.output_cost_usd==`number`?e.output_cost_usd:null,reasoning_cost_usd:typeof e.reasoning_cost_usd==`number`?e.reasoning_cost_usd:null,calculated_cost_usd:typeof e.calculated_cost_usd==`number`?e.calculated_cost_usd:null,recorded_cost_usd:typeof e.recorded_cost_usd==`number`?e.recorded_cost_usd:null,cost_variance_usd:typeof e.cost_variance_usd==`number`?e.cost_variance_usd:null,cost_usd:typeof e.cost_usd==`number`?e.cost_usd:null,fx_rate:typeof e.fx_rate==`number`?e.fx_rate:null,pricing_segment_count:typeof e.pricing_segment_count==`number`?e.pricing_segment_count:null,pricing_mixed:e.pricing_mixed===1||e.pricing_mixed===!0,pricing_model:typeof e.audit_pricing_model==`string`?e.audit_pricing_model:typeof e.pricing_model==`string`?e.pricing_model:null,pricing_source:typeof e.audit_pricing_source==`string`?e.audit_pricing_source:typeof e.pricing_source==`string`?e.pricing_source:null,cost:typeof e.total_cost_brl==`number`?e.total_cost_brl:typeof e.cost_brl==`number`?e.cost_brl:null,currency:`BRL`}))};if(!_())return;l(e=>e===null?e:Ue(e,u,r)),s({offset:r.offset,total:r.total,loading:!1,error:null,aggregation:r.aggregation})}catch(e){if(!_()||S(e))return;s({offset:d,total:null,loading:!1,error:e instanceof Error?e.message:String(e)})}finally{n.current===p&&(n.current=null)}},[e,t,n,r,i,a,o,s,c,l]),loadOperationsLifecyclePage:(0,f.useCallback)(async(u,d=0,f=t.current)=>{n.current?.abort();let p=new AbortController;n.current=p;let m=++r.current,h=o.current,g=I(i),_=()=>te(m,r.current,p.signal)&&x(h,o.current,g,I(a.current));c(u),s({offset:d,total:null,loading:!0,error:null});try{let t=await e.sqliteViewPage(u===`changes`?`operations_changes`:`operations_decisions`,g,{offset:d,limit:100,...f.query?{query:f.query}:{},...f.status?{status:f.status}:{},...f.risk?{risk:f.risk}:{}},p.signal),n=u===`changes`?t.rows.map(e=>{let t=String(e.source_type),n=String(e.source_id);return{id:String(e.id),title:typeof e.title==`string`?e.title:String(e.id),created_at:typeof e.occurred_at==`string`?e.occurred_at:null,status:typeof e.status==`string`?e.status:`unclassified`,risk:typeof e.risk==`string`?e.risk:`unclassified`,source:t===`spec`?{type:`spec`,spec_id:n}:t===`prd`?{type:`prd`,prd_id:n,spec_id:null}:{type:`task`,task_id:n},requirement_ids:We(e.requirement_ids_json),acceptance_ids:We(e.acceptance_ids_json),task_ids:We(e.task_ids_json),result:typeof e.result==`string`?e.result:null,artifact_path:typeof e.source_path==`string`?e.source_path:String(e.id)}}):t.rows.map(e=>({id:String(e.id),title:typeof e.title==`string`?e.title:String(e.id),origin:e.origin===`human`?`human`:`agent`,scope_type:e.scope_type===`execution`?`execution`:`change`,scope_id:String(e.scope_id),artifact_path:typeof e.source_path==`string`?e.source_path:String(e.id),created_at:typeof e.occurred_at==`string`?e.occurred_at:`1970-01-01T00:00:00.000Z`})),r={kind:u,offset:t.offset,limit:t.limit,total:t.total_count,rows:n};if(!_())return;l(e=>e===null?e:{...e,...u===`changes`?{changes:r.rows}:{decisions:r.rows}}),s({offset:r.offset,total:r.total,loading:!1,error:null})}catch(e){if(!_()||S(e))return;s({offset:d,total:null,loading:!1,error:e instanceof Error?e.message:String(e)})}finally{n.current===p&&(n.current=null)}},[e,t,n,r,i,a,o,s,c,l])}}function Ke({api:e,operations:t,setError:n,setFailedArea:r,setLoadingArea:i}){let[a,o]=(0,f.useState)(null),[s,c]=(0,f.useState)([]),[l,u]=(0,f.useState)(null),[d,p]=(0,f.useState)(null),m=(0,f.useRef)(0),h=(0,f.useRef)(0),g=(0,f.useRef)(null),[_,v]=(0,f.useState)(null),[y,b]=(0,f.useState)(``);async function x(a){let c=++h.current;g.current?.abort();let l=new AbortController;g.current=l,n(null),r(null),o(null),v(a),i(`traceability`),await new Promise(e=>window.requestAnimationFrame(()=>e()));try{let n=await e.taskTrace(a,l.signal);if(h.current!==c)return!1;let r=s.find(e=>e.id===a)??t?.tasks.find(e=>e.id===a);return o({...n,task_title:r?.title||n.task_title||a,task_risk:r?.risk||n.task_risk||null,task_created_at:r?.created_at||n.task_created_at||null,task_progress:r?.progress??n.task_progress??0}),!0}catch(e){return l.signal.aborted||h.current!==c?!1:(n(e instanceof Error?e.message:String(e)),r(`traceability`),!1)}finally{h.current===c&&(g.current===l&&(g.current=null),v(null),i(e=>e===`traceability`?null:e))}}function S(e){let n=t?.changes.find(t=>t.id===e);n!==void 0&&(o(null),p({kind:`change`,row:n}))}function ee(e,n){let r=(e===`PRD`?t?.prds:t?.specs)?.find(e=>e.id===n);r!==void 0&&(o(null),p({kind:`macro`,label:e,row:r}))}async function te(n,r){let i=(n===`prd`?t?.prds:t?.specs)?.find(e=>e.id===r);if(!i)return;let a=++m.current,o=n===`prd`?`PRD`:`SPEC`;u({kind:n,label:o,preview:i});try{let t=n===`prd`?await e.prd(r):await e.spec(r);if(m.current!==a)return;u({kind:n,label:o,preview:i,detail:t})}catch(e){if(m.current!==a)return;u({kind:n,label:o,preview:i,error:e instanceof Error?e.message:String(e)})}}function ne(){m.current+=1,u(null)}return{closeDocument:ne,documentDetail:l,openDocument:te,openTrace:x,openTraceChange:S,openTraceMacro:ee,selectedTraceTaskId:y,setSelectedTraceTaskId:b,setTrace:o,setTraceLink:p,setTraceLoadingTaskId:v,setTraceTasks:c,trace:a,traceLink:d,traceLoadingTaskId:_,traceTasks:s}}function qe(e,t){return JSON.stringify([e.query,e.status,e.risk,e.origin??``,e.kind??``,t.from??``,t.to??``])}function Je(e,t,n){return e===`explicit`||t!==n}function Ye(e,t){return{...e,kind:e.kind??t.kind??``}}var V={offset:0,limit:10,total:null,hasMore:!1,typeFilter:`all`,rows:[],loading:!1,error:null};function Xe({api:e,operationsPeriod:t,operationsPeriodRef:n}){let[r,i]=(0,f.useState)(V),a=(0,f.useRef)({query:``,status:``,risk:``}),o=(0,f.useRef)(null),s=(0,f.useRef)(0),c=(0,f.useRef)(null),l=(0,f.useCallback)(async(r,l=0,u=`explicit`)=>{let d=I(t),f=Ye(r,a.current),p=qe(f,d);if(!Je(u,p,c.current))return;o.current?.abort();let m=new AbortController;o.current=m;let h=++s.current;a.current=f,c.current=p;let g=f.kind||`all`;i(e=>({...e,offset:l,typeFilter:g,loading:!0,error:null}));try{let t=await e.sqliteViewPage(`operations_work_list`,d,{offset:l,limit:10,...f.query?{query:f.query}:{},...f.status?{status:f.status}:{},...f.risk?{risk:f.risk}:{},...f.origin?{origin:f.origin}:{},...g===`all`?{}:{kind:g}},m.signal);if(m.signal.aborted||h!==s.current||d.from!==I(n.current).from||d.to!==I(n.current).to)return;i({offset:t.offset,limit:t.limit,total:t.total_count,hasMore:t.has_more,typeFilter:g,rows:t.rows,loading:!1,error:null})}catch(e){if(m.signal.aborted||h!==s.current)return;c.current===p&&(c.current=null),i(t=>({...t,offset:l,typeFilter:g,loading:!1,error:e instanceof Error?e.message:String(e)}))}finally{o.current===m&&(o.current=null)}},[e,t,n]),u=(0,f.useCallback)(()=>{o.current?.abort(),o.current=null,++s.current,c.current=null,i(V)},[]);return{workListPage:r,workListFiltersRef:a,loadWorkListFilters:(0,f.useCallback)(e=>l(e,0,`filter-hydration`),[l]),loadWorkListPage:l,resetWorkListPage:u}}async function*H(e,t){let n=e;for(;;){if(n.rows.length===0)return;yield n.rows;let e=n.offset+n.rows.length;if(!n.has_more||e>=n.total_count)return;n=await t(e)}}function Ze({api:e,operationsPeriod:t}){return(0,f.useCallback)((n,r)=>{let i=I(t);if(n===`work-kanban`)return;let a={"work-list":`operations_work_list`,changes:`operations_changes`,decisions:`operations_decisions`,executions:`operations_executions`,runs:`operations_agent_invocations`,conversations:`operations_conversations`,daily:`operations_daily`,monthly:`operations_monthly`,yearly:`operations_annual`}[n];if(a===void 0)return;let o=e=>({offset:e,limit:100,...r.query?{query:r.query}:{},...r.status?{status:r.status}:{},...r.risk?{risk:r.risk}:{},...r.origin?{origin:r.origin}:{},...a===`operations_work_list`&&r.kind?{kind:r.kind}:{}});return{prepare:async()=>{let t=await e.sqliteViewPage(a,i,o(0));return{totalRows:t.total_count,pages:()=>H(t,t=>e.sqliteViewPage(a,i,o(t)))}}}},[e,t])}var Qe=(e,t)=>`${e}:${t}`,$e=(e,t)=>`${e}:${t}`,et=[`definition`,`planning`,`ready`,`executing`,`verifying`,`completed`,`blocked`,`cancelled`,`failed`],tt=[`completed`,`executing`,`ready`,`blocked`,`verifying`,`failed`,`cancelled`,`planning`,`definition`];function U(){let[e,t]=(0,f.useState)(!1),[n,r]=(0,f.useState)(!1),[i,a]=(0,f.useState)(!1),o=(0,f.useMemo)(ye,[]),c=(0,f.useMemo)(()=>new Te(o),[o]),{loadCostDetail:l,loadCostReadModelPage:u,loadCostRunPage:d,loadCostGroupPage:p}=Re(c),[h,g]=(0,f.useState)(()=>ve(window.location.pathname)),_=(0,f.useRef)(h);_.current=h;let[v,y]=(0,f.useState)(null),[te,w]=(0,f.useState)({offset:0,total:null,loading:!1,error:null}),[T,ae]=(0,f.useState)(`runs`),E=(0,f.useRef)({query:``,status:``,risk:``}),[oe,ce]=(0,f.useState)({}),[le,ue]=(0,f.useState)({}),[he,D]=(0,f.useState)({}),[ge,O]=(0,f.useState)({}),[be,k]=(0,f.useState)({}),[A,Ce]=(0,f.useState)(null),[j,M]=(0,f.useState)(null),[N,Ee]=(0,f.useState)(_e),[P,F]=(0,f.useState)(()=>window.localStorage.getItem(`zaip-dashboard-currency`)===`USD`?`USD`:`BRL`),je=(0,f.useCallback)(e=>{Ee(e),F(e===`en-US`?`USD`:`BRL`)},[]),[L,Me]=(0,f.useState)(()=>De),R=(0,f.useRef)(L);R.current=L;let[Ne,z]=(0,f.useState)(!1),[Pe,Fe]=(0,f.useState)(null),[Ie,Le]=(0,f.useState)(null),[ze,Be]=(0,f.useState)(window.location.pathname),[Ve,B]=(0,f.useState)(!0),[,Ue]=(0,f.useState)(!1),[,We]=(0,f.useState)(!1),[qe,Je]=(0,f.useState)(!1),[Ye,V]=(0,f.useState)(`operations`),[H,U]=(0,f.useState)(null),[nt,rt]=(0,f.useState)(null);(0,f.useEffect)(()=>{c.ready().then(e=>t(e.snapshot_state===`updating`)).catch(()=>{})},[c]);let[it,W]=(0,f.useState)(null),[at,ot]=(0,f.useState)(null),[st,ct]=(0,f.useState)(null),[lt,ut]=(0,f.useState)({title:`Dashboard Zaip AIOS`,repositoryName:``}),{closeDocument:dt,documentDetail:ft,openDocument:pt,openTrace:G,openTraceChange:mt,openTraceMacro:ht,selectedTraceTaskId:gt,setSelectedTraceTaskId:_t,setTrace:vt,setTraceLink:yt,setTraceLoadingTaskId:bt,setTraceTasks:xt,trace:St,traceLink:Ct,traceLoadingTaskId:wt,traceTasks:Tt}=Ke({api:c,operations:v,setError:W,setFailedArea:U,setLoadingArea:V}),K=(0,f.useRef)(Tt),q=(0,f.useRef)({offset:0,stageIndex:0}),Et=(0,f.useRef)(!1),[Dt,Ot]=(0,f.useState)(!1),[kt,At]=(0,f.useState)(!1),J=(0,f.useRef)(0);(0,f.useEffect)(()=>{K.current=Tt},[Tt]);let jt=(0,f.useRef)(0),Mt=(0,f.useRef)(!1),Y=(0,f.useRef)(0),Nt=(0,f.useRef)(0),Pt=(0,f.useRef)(null),Ft=(0,f.useRef)(!1),It=(0,f.useRef)(!1),Lt=(0,f.useRef)(null),X=(0,f.useRef)(null),Rt=(0,f.useRef)(null),zt=(0,f.useRef)(0),Bt=(0,f.useRef)({}),Z=(0,f.useRef)(new Set),Q=(0,f.useRef)(new Map),Vt=(0,f.useRef)(new Set),Ht=(0,f.useRef)(new Set),Ut=(0,f.useRef)({query:``,status:``,risk:``,origin:``,kind:``}),Wt=(0,f.useRef)(`||||`),$=(0,f.useRef)(0),Gt=(0,f.useRef)(void 0),{workListPage:Kt,workListFiltersRef:qt,loadWorkListFilters:Jt,loadWorkListPage:Yt,resetWorkListPage:Xt}=Xe({api:c,operationsPeriod:L,operationsPeriodRef:R}),Zt=(0,f.useRef)(!1),Qt=(0,f.useCallback)(async(e=!0,t=!1,n=!1)=>{Lt.current?.(),Lt.current=null,X.current?.abort(),X.current=null,$.current+=1;for(let e of Q.current.values())e.abort();Q.current.clear(),Z.current.clear(),Ht.current.clear(),Bt.current={},ce({}),ue({}),D({}),O({}),k({});let r=++J.current,i=jt.current,a=_.current,o=I(L),s=()=>b(r,J.current)&&x(r,J.current,o,I(R.current));e&&(B(!0),V(`operations`)),W(null),U(null);try{if(t||n){let e,n=null;if(t){let t=await c.reconcileOpenWork(P,o);n=t.reconciliation,e=t}else e=await c.refreshProjection(P,o);if(!s())return;n!==null&&ot(n),y(e.operations),Gt.current=e.operations.summary.overview_metrics,It.current=!0,Ce(e.costs),Ft.current=!0,M(null),e.dashboard&&ut({title:e.dashboard.title,repositoryName:e.dashboard.repository_name}),ct(e.projection.source_latest_at)}else{let[e,t]=await Promise.all([c.operations(o,`quick`,void 0,Zt.current),P===`USD`?c.costMonitor(P,o,`summary`):Promise.resolve(null)]);if(!s())return;Zt.current=!1,y(e),Gt.current=e.summary.overview_metrics,It.current=!1,t!==null&&(Ce(t),Ft.current=!1,M(null)),ct(e.summary.source_latest_at)}}catch(e){if(!s())return;W(e instanceof Error?e.message:String(e)),U(a===`cost-monitor`?`costs`:`operations`)}finally{s()&&ee(i,jt.current)&&Je(!1),e&&s()&&(B(!1),V(e=>e===`operations`?null:e))}},[c,P,L]),$t=(0,f.useCallback)(async e=>{if(It.current||Mt.current||e?.aborted)return null;X.current?.abort();let t=e===void 0?new AbortController:null,n=e??t?.signal;if(n===void 0)return null;t!==null&&(X.current=t),Mt.current=!0,Y.current+=1,V(`costs`),U(null);try{let e=++J.current,t=I(L),r=()=>b(e,J.current)&&x(e,J.current,t,I(R.current)),i=await c.operations(t,`detail`,n);return r()?(y(i),It.current=!0,i):null}catch(e){return n.aborted||S(e)?null:(W(e instanceof Error?e.message:String(e)),U(`operations`),null)}finally{t!==null&&X.current===t&&(X.current=null),Mt.current=!1,Y.current=Math.max(0,Y.current-1),Y.current===0&&V(e=>e===`costs`?null:e)}},[c,L]),{loadOperationsEntityPage:en,loadOperationsLifecyclePage:tn}=Ge({api:c,entityFiltersRef:E,operationsPageAbortRef:Rt,operationsPageRequestVersionRef:zt,operationsPeriod:L,operationsPeriodRef:R,refreshVersion:J,setEntityPage:w,setEntityPageKind:ae,setOperations:y}),nn=(0,f.useCallback)((e,t)=>{E.current=t,e===`changes`||e===`decisions`?tn(e,0,t):en(e,0,t)},[en,tn]),rn=(0,f.useCallback)(async e=>{if(v===null||Z.current.has(e))return;Z.current.add(e),Q.current.get(e)?.abort();let t=new AbortController;Q.current.set(e,t);let n=$.current,r=I(L);D(t=>({...t,[e]:{loading:!0,error:null}}));let i=Bt.current[e]??0;try{let a=await c.operationsBoard(r,e,i,Ut.current,t.signal,10);if(t.signal.aborted||n!==$.current||r.from!==I(R.current).from||r.to!==I(R.current).to)return;y(e=>e===null?e:{...ne(e,[a]),summary:e.summary}),ce(t=>({...t,[e]:a.total})),ue(t=>({...t,[e]:a.totals_by_kind}));let o=i+a.prds.length+a.specs.length+a.tasks.length;Bt.current={...Bt.current,[e]:o}}catch(r){if(t.signal.aborted||n!==$.current||S(r))return;D(t=>({...t,[e]:{loading:!1,error:r instanceof Error?r.message:String(r)}}))}finally{n===$.current&&(Z.current.delete(e),Q.current.get(e)===t&&Q.current.delete(e),D(t=>t[e]?.error===null?{...t,[e]:{loading:!1,error:null}}:t))}},[c,v,L]),an=(0,f.useCallback)(e=>{let t={...e,kind:e.kind??Ut.current.kind??``},n=`${t.query}|${t.status}|${t.risk}|${t.origin??``}|${t.kind}`;if(n!==Wt.current){Wt.current=n,Ut.current=t,$.current+=1;for(let e of Q.current.values())e.abort();Q.current.clear(),Z.current.clear(),Ht.current.clear(),Bt.current={},ce({}),ue({}),D({}),O({}),k({}),y(e=>e===null?e:{...e,prds:[],specs:[],tasks:[],changes:[],summary:n===`||||`&&Gt.current!==void 0?{...e.summary,overview_metrics:Gt.current}:e.summary})}},[]),on=(0,f.useCallback)(async(e,t,n)=>{let r=Qe(e,t);if(Vt.current.has(r))return;Vt.current.add(r);let i=$.current,a=I(L);O(e=>({...e,[r]:{items:n===0?[]:e[r]?.items??[],total:e[r]?.total??0,loading:!0,error:null}}));try{let o=await c.operationsBoard(a,e,n,{kind:t===`task`?`all-tasks`:t});if(i!==$.current||a.from!==I(R.current).from||a.to!==I(R.current).to)return;let s=t===`task`?o.tasks:t===`spec`?o.specs:o.prds;O(e=>({...e,[r]:{items:n===0?s:[...e[r]?.items??[],...s],total:o.total,loading:!1,error:null}}))}catch(e){if(i!==$.current||S(e))return;O(t=>({...t,[r]:{items:t[r]?.items??[],total:t[r]?.total??0,loading:!1,error:e instanceof Error?e.message:String(e)}}))}finally{Vt.current.delete(r)}},[c,L]),sn=(0,f.useCallback)(async(e,t,n)=>{let r=$e(e,t);if(Vt.current.has(r))return;Vt.current.add(r);let i=$.current,a=I(L);k(e=>({...e,[r]:{items:n===0?[]:e[r]?.items??[],total:e[r]?.total??0,loading:!0,error:null}}));try{let o=await c.operationsClassification(a,e,t,n);if(i!==$.current||a.from!==I(R.current).from||a.to!==I(R.current).to)return;let s=e===`task`?o.tasks:e===`spec`?o.specs:o.prds;k(e=>({...e,[r]:{items:n===0?s:[...e[r]?.items??[],...s],total:o.total,loading:!1,error:null}}))}catch(e){if(i!==$.current||S(e))return;k(t=>({...t,[r]:{items:t[r]?.items??[],total:t[r]?.total??0,loading:!1,error:e instanceof Error?e.message:String(e)}}))}finally{Vt.current.delete(r)}},[c,L]),cn=(0,f.useCallback)(e=>{let t={...Ut.current,...e},n=I(L);return{prepare:async()=>{let e=await Promise.all(et.map(e=>c.operationsBoard(n,e,0,t))),r=e=>[...e.prds.map(({kind:e,...t})=>({kind:`prd`,...t})),...e.specs.map(({kind:e,...t})=>({kind:`spec`,...t})),...e.tasks.map(e=>({kind:`task`,...e}))];return{totalRows:e.reduce((e,t)=>e+t.total,0),pages:async function*(){for(let i of e){let e=i,a=0;for(;;){let i=r(e);if(i.length===0||(a+=i.length,yield i,a>=e.total))break;e=await c.operationsBoard(n,e.stage,a,t)}}}}}}},[c,L]),ln=Ze({api:c,operationsPeriod:L});(0,f.useEffect)(()=>{if(h!==`operations`||v===null)return;let e=!1,t=async()=>{if(e)return;let t=et.filter(e=>!Ht.current.has(e)&&!Z.current.has(e));for(let n=0;n<t.length&&!e;n+=3){let e=t.slice(n,n+3);for(let t of e)Ht.current.add(t);await Promise.all(e.map(e=>rn(e)))}},n=typeof window.requestIdleCallback==`function`?{kind:`idle`,id:window.requestIdleCallback(()=>void t())}:{kind:`timeout`,id:window.setTimeout(()=>void t(),0)};return()=>{e=!0,n.kind===`idle`?window.cancelIdleCallback(n.id):window.clearTimeout(n.id)}},[h,rn,v]);let un=async e=>{e&&ot(null),rt(e?`reconciling`:`refreshing`),await Qt(!1,e,!e),rt(null)};He({api:c,costLocale:N,currency:P,dashboardView:h,loadOperationsDetails:$t,operations:v,operationsDetailAbortRef:X,operationsDetailCancelRef:Lt,operationsPageAbortRef:Rt,pathname:ze,pricing:Pe,refresh:Qt,refreshVersion:J,setError:W,setFxRate:Le,setPathname:Be,setPricing:Fe});let dn=e=>{window.history.pushState(null,``,e),Be(e),window.scrollTo({left:0,top:0})},fn=(0,f.useCallback)(async()=>{Pt.current?.abort();let e=new AbortController;Pt.current=e;let t=++Nt.current,n=I(L);Y.current+=1,V(`costs`),U(null);try{let r=await c.costMonitor(P,n,`summary`,e.signal);if(e.signal.aborted||t!==Nt.current)return;Ce(r),Ft.current=!0,M(null)}catch(n){if(e.signal.aborted||t!==Nt.current)return;W(n instanceof Error?n.message:String(n)),U(`costs`)}finally{Y.current=Math.max(0,Y.current-1),Y.current===0&&V(e=>e===`costs`?null:e),Pt.current===e&&(Pt.current=null)}},[c,P,L]);(0,f.useEffect)(()=>{P!==`USD`||A?.currency===P||fn()},[A?.currency,P,fn]);let pn=(0,f.useCallback)(async(e=!1,t=!1)=>{if(Et.current||(t&&(q.current={offset:0,stageIndex:0},K.current=[],xt([]),Ot(!0)),q.current.stageIndex>=tt.length))return K.current;Et.current=!0,At(!0);try{do{let t=q.current,n=tt[t.stageIndex];if(n===void 0)break;let r=await c.operationsBoard({from:null,to:null},n,t.offset,{kind:`all-tasks`},void 0,10),i=Ae({cursor:t,page:r,tasks:K.current});if(K.current=i.tasks,xt(K.current),q.current=i.cursor,r.tasks.length>0&&!e)break}while(q.current.stageIndex<tt.length);return Ot(q.current.stageIndex<tt.length),K.current}finally{Et.current=!1,At(!1)}},[c,xt]),mn=async e=>{if(g(e),window.scrollTo({left:0,top:0}),e===`cost-monitor`?A?.currency!==P&&fn():Pt.current?.abort(),e===`traceability`){let e=Tt;if(e.length===0){let t=$.current;if(e=await pn(!1,!0),t!==$.current)return;xt(e)}let t=e.toSorted((e,t)=>Date.parse(t.finished_at??t.updated_at)-Date.parse(e.finished_at??e.updated_at)),n=t.find(e=>e.status===`completed`)??t[0];n&&(_t(n.id),G(n.id));return}vt(null),bt(null)},hn=(0,m.jsx)(Se,{activeView:h,locale:N,onChange:e=>void mn(e)}),gn=(0,f.useMemo)(()=>new Map((j??A)?.runs.map(e=>[e.run_id,P===`USD`?e.estimated_usd:e.estimated_brl])??[]),[A,P,j]),_n=(0,f.useMemo)(()=>{let e=j??A;return e?.currency===P?P===`USD`?e.overview.estimated_usd:e.overview.estimated_brl:null},[A,P,j]),vn=(0,f.useMemo)(()=>{let e=j??A;if(e?.currency===P)return{day:e.groups.daily,month:e.groups.monthly,year:e.groups.annual}},[A,P,j]),yn=()=>{W(null),H===`costs`?Qt():H===`traceability`&&gt?G(gt):H===`operations`&&v!==null?$t():Qt()},bn=me({api:c,costLocale:N,fxRate:Ie,navigate:dn,pathname:ze,pricing:Pe,refresh:Qt,setFxRate:Le,setPricing:Fe}),xn=qe||P===`USD`&&A?.currency!==P,Sn=v===null&&Ve;(0,f.useEffect)(()=>{if(!e||!Sn||n){a(!1);return}let t=window.setTimeout(()=>a(!0),Oe);return()=>window.clearTimeout(t)},[Sn,n,e]);let Cn=ke({snapshotUpdating:e,initialDataPending:Sn,dismissed:n,delayElapsed:i})?(0,m.jsxs)(`div`,{"aria-live":`polite`,className:`app-notice app-snapshot-status`,role:`status`,children:[(0,m.jsx)(`span`,{children:`Exibindo o último snapshot local validado. Os dados canônicos estão sendo atualizados em segundo plano e estarão atuais na próxima abertura.`}),(0,m.jsx)(`button`,{"aria-label":N===`pt-BR`?`Fechar aviso de atualização do snapshot`:`Dismiss snapshot update notice`,onClick:()=>r(!0),type:`button`,children:`×`})]}):null,wn=v;return(0,m.jsxs)(ie,{error:it,globalLoadingPending:xn,locale:N,onRefresh:()=>void Qt(),operations:v,snapshotNotice:Cn,setupRoute:bn,children:[(0,m.jsxs)(re,{pending:xn,children:[it?(0,m.jsxs)(`div`,{"aria-live":`assertive`,className:`app-warning app-error`,role:`alert`,children:[(0,m.jsx)(`span`,{children:it}),H?(0,m.jsx)(`button`,{onClick:yn,type:`button`,children:N===`pt-BR`?`Tentar novamente`:`Try again`}):null,(0,m.jsx)(`button`,{"aria-label":N===`pt-BR`?`Fechar erro`:`Dismiss error`,onClick:()=>W(null),type:`button`,children:`×`})]}):null,(0,m.jsx)(s,{alternateContent:xe({costs:A,costLocale:N,currency:P,dashboardView:h,failedArea:H,lastUpdatedAt:st,loadCostDetail:l,loadCostReadModelPage:u,loadCostRunPage:d,loadCostGroupPage:p,loadingArea:Ye,onActiveDataChange:M,onCurrencyChange:F,onLoadingChange:We,onLocaleChange:je,onLoadMoreTraceTasks:pn,onOpenTrace:e=>void G(e),onRefresh:()=>rt(`choose`),onRetry:yn,onSelectTraceTask:e=>{_t(e),G(e)},onOpenTraceChange:mt,onOpenTraceMacro:ht,operations:wn,selectedTraceTaskId:gt,trace:St,traceLoadingTaskId:wt,traceTasksHasMore:Dt,traceTasksLoading:kt,traceTasks:Tt}),capabilityNavigation:hn,boardTotals:oe,boardKindTotals:le,boardExportSource:cn,detailExportSource:ln,boardStates:he,data:wn,datePreset:L.preset,dateRange:L.range,entityPage:te,dashboardTitle:lt.title,repositoryName:lt.repositoryName,loading:Ve,locale:N,currency:P,factualCostTotal:_n,factualCostPeriods:vn,onLoadingChange:Ue,resolveRunCost:A===null?void 0:e=>gn.get(e)??null,onLocaleChange:je,onDetailDataRequest:e=>{let t=e===`conversations`?`conversations`:e===`executions`?`executions`:e===`runs`?`runs`:null;t===null?e===`changes`||e===`decisions`?tn(e):$t():en(t)},onLoadMacroMetrics:()=>void $t(),onEntityPageChange:e=>{T===`changes`||T===`decisions`?tn(T,e):en(T,e)},onEntityFiltersChange:nn,onBoardFiltersChange:an,onWorkListFiltersChange:Jt,onWorkListPageChange:e=>void Yt(qt.current,e),onBoardTypeChange:e=>an({...Ut.current,kind:e===`all`?``:e}),onWorkListTypeChange:e=>void Yt({...qt.current,kind:e===`all`?``:e}),onLoadMoreBoard:e=>void rn(e),workListPage:Kt,statusPage:(e,t)=>ge[Qe(e,t)],onLoadStatusPage:(e,t,n)=>void on(e,t,n),classificationPage:(e,t)=>be[$e(e,t)],onLoadClassificationPage:(e,t,n)=>void sn(e,t,n),onOpenDocument:(e,t)=>void pt(e,t),onOpenTask:G,onPriorityChange:async e=>{try{await c.saveWorkPriority(e)}catch(e){throw W(e instanceof Error?e.message:String(e)),e}},onDateChange:(e,t)=>{It.current=!1,Lt.current?.(),Lt.current=null,X.current?.abort(),X.current=null,Rt.current?.abort(),Rt.current=null,Xt(),++zt.current,$.current+=1;for(let e of Q.current.values())e.abort();Q.current.clear(),Z.current.clear(),Ht.current.clear(),Bt.current={},ce({}),ue({}),D({}),O({}),k({}),++J.current,w({offset:0,total:null,loading:!1,error:null}),Ft.current=!1,Ce(null),M(null),B(!0),jt.current+=1,Je(!0),V(`operations`),Me({preset:e,range:t})},onRefresh:()=>rt(`choose`),settings:(0,m.jsx)(we,{costCalculationGuidePath:pe,currency:P,locale:N,onCurrencyChange:F,onHelpOpen:()=>z(!0),onNavigate:dn,pricingSetupPath:de,projectSetupPath:fe})}),(0,m.jsx)(se,{closeDocument:dt,costLocale:N,documentDetail:ft,helpOpen:Ne,loadingArea:h===`cost-monitor`&&A===null?null:Ye,operations:wn,reconciliationResult:at,refreshDialog:nt,showTrace:h===`traceability`,trace:St,traceLink:Ct,traceLoadingTaskId:wt,onCloseHelp:()=>z(!1),onCloseTrace:()=>vt(null),onDismissReconciliation:()=>ot(null),onOpenDocument:(e,t)=>void pt(e,t),onOpenTrace:e=>void G(e),onOpenTraceChange:mt,onOpenTraceMacro:ht,onRefreshCancel:()=>rt(null),onRefreshFromDialog:e=>void un(e),setTraceLink:e=>yt(e)})]}),xn?(0,m.jsx)(C,{}):null]})}var nt=document.getElementById(`root`);if(!nt)throw Error(`Elemento #root não encontrado`);(0,p.createRoot)(nt).render((0,m.jsx)(f.StrictMode,{children:(0,m.jsx)(U,{})}));export{je as t};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DashboardHelpDialog-BXy6nti1.js","assets/cost-monitor-DKwP1stV.js","assets/rolldown-runtime-D9-fqq9M.js","assets/cost-monitor-PoJA2PI1.css","assets/dashboard-localization-CLJ0lT9v.js","assets/DashboardHelpDialog-Je5nK-Et.css","assets/PricingSettingsDialog-vSvvOHQp.js","assets/ProjectSettingsPage-zH758vfs.js","assets/ProjectSettingsPage-BomxqCBU.css","assets/CostCalculationGuidePage-ovxurkIk.js","assets/TraceabilityWorkspace-CTH2wDs5.js","assets/traceability-7f1j5wx3.js","assets/icons-vendor-B_lDDHn1.js","assets/traceability-DFY7ZDlu.css","assets/TraceabilityWorkspace-DvvavDLY.css"])))=>i.map(i=>d[i]);
2
+ import{S as e,a as t,b as n,g as r,h as i,i as a,n as o,r as s,t as c}from"./cost-monitor-DKwP1stV.js";import{t as l}from"./react-vendor-B3TJrD4O.js";import{n as u,t as d}from"./traceability-7f1j5wx3.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var f=e(),p=l(),m=n();function h({locale:e}){let t=e===`pt-BR`?[`Definição`,`Planejamento`,`Pronto para Executar`,`Execução`,`Verificação`]:[`Definition`,`Planning`,`Ready to Execute`,`Execution`,`Verification`];return(0,m.jsxs)(`main`,{"aria-busy":`true`,"aria-live":`polite`,"aria-label":e===`pt-BR`?`Preparando dashboard`:`Preparing dashboard`,className:`app-skeleton`,role:`status`,children:[(0,m.jsxs)(`header`,{className:`app-skeleton-header`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`span`,{className:`app-skeleton-line app-skeleton-line-short`}),(0,m.jsx)(`h1`,{children:`Dashboard Zaip AIOS`})]}),(0,m.jsxs)(`div`,{className:`app-skeleton-actions`,children:[(0,m.jsx)(`span`,{}),(0,m.jsx)(`span`,{}),(0,m.jsx)(`span`,{})]})]}),(0,m.jsx)(`section`,{className:`app-skeleton-kpis`,"aria-hidden":`true`,children:Array.from({length:4},(e,t)=>`skeleton-kpi-${t}`).map(e=>(0,m.jsxs)(`article`,{children:[(0,m.jsx)(`span`,{className:`app-skeleton-line app-skeleton-line-short`}),(0,m.jsx)(`span`,{className:`app-skeleton-value`}),(0,m.jsx)(`span`,{className:`app-skeleton-line`})]},e))}),(0,m.jsxs)(`section`,{className:`app-skeleton-panels`,"aria-hidden":`true`,children:[(0,m.jsxs)(`article`,{children:[(0,m.jsx)(`span`,{className:`app-skeleton-line app-skeleton-line-medium`}),(0,m.jsx)(`div`,{className:`app-skeleton-chart`})]}),(0,m.jsxs)(`article`,{children:[(0,m.jsx)(`span`,{className:`app-skeleton-line app-skeleton-line-medium`}),(0,m.jsx)(`div`,{className:`app-skeleton-chart app-skeleton-chart-small`})]})]}),(0,m.jsx)(`section`,{className:`app-skeleton-board`,"aria-hidden":`true`,children:t.map((e,t)=>(0,m.jsxs)(`article`,{children:[(0,m.jsx)(`h2`,{children:e}),Array.from({length:t%2==0?2:1},(t,n)=>`${e}-${n}`).map(e=>(0,m.jsxs)(`div`,{className:`app-skeleton-card`,children:[(0,m.jsx)(`span`,{className:`app-skeleton-line`}),(0,m.jsx)(`span`,{className:`app-skeleton-line app-skeleton-line-medium`}),(0,m.jsx)(`span`,{className:`app-skeleton-pill`})]},e))]},e))})]})}function g(e,t){let n=t===`pt-BR`;return e===`costs`?n?{title:`Carregando Monitor de Custos…`,detail:`Isso costuma levar poucos segundos.`}:{title:`Loading Cost Monitor…`,detail:`This usually takes a few seconds.`}:e===`traceability`?n?{title:`Carregando Rastreabilidade…`,detail:`Estamos preparando as 6 etapas da task.`}:{title:`Loading Traceability…`,detail:`Preparing the task's 6 stages.`}:n?{title:`Atualizando dados do dashboard…`,detail:`Você pode continuar navegando.`}:{title:`Refreshing dashboard data…`,detail:`You can keep navigating.`}}function _({area:e,locale:t}){let n=g(e,t);return(0,m.jsxs)(`section`,{"aria-busy":`true`,"aria-live":`polite`,className:`app-loading-panel`,role:`status`,children:[(0,m.jsx)(`i`,{}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`strong`,{children:n.title}),(0,m.jsx)(`span`,{children:n.detail})]})]})}function v({area:e,locale:t}){let n=g(e,t);return(0,m.jsxs)(`section`,{"aria-live":`polite`,className:`app-refresh-status`,role:`status`,children:[(0,m.jsx)(`i`,{}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`strong`,{children:n.title}),(0,m.jsx)(`span`,{children:n.detail})]})]})}function y({locale:e,onRetry:t}){return(0,m.jsxs)(`section`,{"aria-live":`polite`,className:`app-loading-panel app-loading-panel-error`,role:`status`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`strong`,{children:e===`pt-BR`?`Não foi possível carregar os custos`:`Couldn't load costs`}),(0,m.jsx)(`span`,{children:e===`pt-BR`?`A tela continua disponível. Tente novamente quando quiser.`:`The dashboard remains available. Try again whenever you want.`})]}),(0,m.jsx)(`button`,{onClick:t,type:`button`,children:e===`pt-BR`?`Tentar novamente`:`Try again`})]})}function b(e,t){return e===t}function x(e,t,n,r){return b(e,t)&&n.from===r.from&&n.to===r.to}function S(e){return e instanceof DOMException&&e.name===`AbortError`}function ee(e,t){return e===t}function te(e,t,n){return b(e,t)&&!n.aborted}function ne(e,t){let n=e=>[...new Map(e.map(e=>[e.id,e])).values()];return{...e,prds:n([...e.prds,...t.flatMap(e=>e.prds)]),specs:n([...e.specs,...t.flatMap(e=>e.specs)]),tasks:n([...e.tasks,...t.flatMap(e=>e.tasks)]),changes:n([...e.changes,...t.flatMap(e=>e.changes)])}}function C(){let e=(0,f.useRef)(null);return(0,f.useEffect)(()=>{e.current?.focus()},[]),(0,m.jsx)(`div`,{"aria-busy":`true`,"aria-live":`polite`,className:`period-transition-overlay`,onKeyDownCapture:e=>e.preventDefault(),ref:e,role:`status`,tabIndex:-1,children:(0,m.jsxs)(`div`,{className:`period-transition-overlay__content`,children:[(0,m.jsx)(`i`,{"aria-hidden":`true`,className:`period-transition-overlay__spinner`}),(0,m.jsx)(`span`,{className:`period-transition-overlay__label`,children:`Carregando...`})]})})}function re({pending:e,children:t}){return(0,m.jsx)(`div`,{"aria-hidden":e||void 0,inert:e,children:t})}function ie({children:e,error:t,globalLoadingPending:n,locale:r,onRefresh:i,operations:a,snapshotNotice:o,setupRoute:s}){return s===null?t&&a===null?(0,m.jsxs)(`main`,{className:`app-state`,children:[(0,m.jsx)(`p`,{children:`Dashboard local indisponível`}),(0,m.jsx)(`h1`,{children:`Não foi possível ler o workspace V2.`}),(0,m.jsx)(`pre`,{children:t}),(0,m.jsx)(`button`,{onClick:i,type:`button`,children:`Tentar novamente`})]}):a===null?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(h,{locale:r}),o,n?(0,m.jsx)(C,{}):null]}):e:s}var w=`modulepreload`,T=function(e){return`/`+e},ae={},E=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=T(t,n),t=s(t),t in ae)return;ae[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:w,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},oe=(0,f.lazy)(async()=>({default:(await E(async()=>{let{DashboardHelpDialog:e}=await import(`./DashboardHelpDialog-BXy6nti1.js`);return{DashboardHelpDialog:e}},__vite__mapDeps([0,1,2,3,4,5]))).DashboardHelpDialog}));function se({costLocale:e,documentDetail:n,helpOpen:i,loadingArea:a,operations:s,reconciliationResult:c,refreshDialog:l,showTrace:p,trace:h,traceLink:g,traceLoadingTaskId:_,closeDocument:y,onCloseHelp:b,onCloseTrace:x,onDismissReconciliation:S,onOpenDocument:ee,onOpenTrace:te,onOpenTraceChange:ne,onOpenTraceMacro:C,onRefreshCancel:re,onRefreshFromDialog:ie,setTraceLink:w}){return(0,m.jsxs)(m.Fragment,{children:[p?null:_?(0,m.jsx)(d,{locale:e,taskId:_}):h?(0,m.jsx)(u,{locale:e,onClose:x,onOpenChange:ne,onOpenPrd:e=>C(`PRD`,e),onOpenSpec:e=>C(`SPEC`,e),trace:h}):null,g?.kind===`change`?(0,m.jsx)(r,{details:{kind:`change`,row:g.row},locale:e,onClose:()=>w(null)}):null,g?.kind===`macro`?(0,m.jsx)(t,{label:g.label,locale:e,onClose:()=>w(null),onOpenDocument:ee,onOpenTrace:e=>{w(null),te(e)},row:g.row,runs:s.runs,specs:s.specs,tasks:s.tasks}):null,n?(0,m.jsx)(o,{detail:n.detail,error:n.error,label:n.label,locale:e,loading:!n.detail&&!n.error,onClose:y,onRetry:()=>ee(n.kind,n.preview.id),preview:n.preview}):null,i?(0,m.jsx)(f.Suspense,{fallback:null,children:(0,m.jsx)(oe,{locale:e,onClose:b})}):null,l===`choose`?(0,m.jsx)(`div`,{className:`app-refresh-dialog-backdrop`,children:(0,m.jsxs)(`section`,{"aria-label":`Atualizar dashboard`,"aria-modal":`true`,className:`app-refresh-dialog`,role:`dialog`,children:[(0,m.jsx)(`h2`,{children:e===`pt-BR`?`Atualizar dashboard`:`Refresh dashboard`}),(0,m.jsx)(`p`,{children:e===`pt-BR`?`Escolha uma atualização rápida ou reconcilie os itens que ainda estão em aberto.`:`Choose a quick refresh or reconcile work items that are still open.`}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`button`,{onClick:()=>ie(!1),type:`button`,children:e===`pt-BR`?`Apenas atualizar dados`:`Refresh data only`}),(0,m.jsx)(`button`,{onClick:()=>ie(!0),type:`button`,children:e===`pt-BR`?`Reconciliar itens abertos`:`Reconcile open work`})]}),(0,m.jsx)(`button`,{className:`app-refresh-cancel`,onClick:re,type:`button`,children:e===`pt-BR`?`Cancelar`:`Cancel`})]})}):null,l===`refreshing`||l===`reconciling`?(0,m.jsxs)(`section`,{"aria-live":`polite`,className:`app-refresh-status`,role:`status`,children:[(0,m.jsx)(`i`,{}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`strong`,{children:l===`reconciling`?e===`pt-BR`?`Reconciliando itens em aberto…`:`Reconciling open work…`:e===`pt-BR`?`Atualizando dados…`:`Refreshing data…`}),(0,m.jsx)(`span`,{children:e===`pt-BR`?`Você pode continuar usando o dashboard.`:`You can keep using the dashboard.`})]})]}):null,c!==null&&l===null?(0,m.jsxs)(`section`,{"aria-live":`polite`,className:`app-reconciliation-result`,role:`status`,children:[(0,m.jsx)(`strong`,{children:e===`pt-BR`?`Resultado da reconciliação manual`:`Manual reconciliation result`}),(0,m.jsx)(`span`,{children:e===`pt-BR`?`${c.reconciled_ids.length} item(ns) reconciliado(s).`:`${c.reconciled_ids.length} item(s) reconciled.`}),c.reconciled_ids.length>0?(0,m.jsx)(`p`,{children:c.reconciled_ids.join(`, `)}):null,c.blocked.length>0?(0,m.jsxs)(`p`,{children:[e===`pt-BR`?`Bloqueados: `:`Blocked: `,c.blocked.map(e=>`${e.id}${e.reason===null?``:` (${e.reason})`}`).join(`; `)]}):null,c.not_reconciled.length>0?(0,m.jsxs)(`p`,{children:[e===`pt-BR`?`Não reconciliados: `:`Not reconciled: `,c.not_reconciled.map(e=>`${e.id}${e.reason===null?``:` (${e.reason})`}`).join(`; `)]}):null,(0,m.jsx)(`button`,{onClick:S,type:`button`,children:e===`pt-BR`?`Fechar`:`Dismiss`})]}):null,a!==null&&a!==`operations`&&l===null?(0,m.jsx)(v,{area:a,locale:e}):null]})}var ce=(0,f.lazy)(async()=>({default:(await E(async()=>{let{PricingSettingsPage:e}=await import(`./PricingSettingsDialog-vSvvOHQp.js`);return{PricingSettingsPage:e}},__vite__mapDeps([6,1,2,3,4]))).PricingSettingsPage})),le=(0,f.lazy)(async()=>({default:(await E(async()=>{let{ProjectSettingsPage:e}=await import(`./ProjectSettingsPage-zH758vfs.js`);return{ProjectSettingsPage:e}},__vite__mapDeps([7,1,2,3,8]))).ProjectSettingsPage})),ue=(0,f.lazy)(async()=>({default:(await E(async()=>{let{CostCalculationGuidePage:e}=await import(`./CostCalculationGuidePage-ovxurkIk.js`);return{CostCalculationGuidePage:e}},__vite__mapDeps([9,1,2,3]))).CostCalculationGuidePage})),de=`/setup-pricing`,fe=`/setup-project`,pe=`/cost-calculation-guide`;function me(e){let{api:t,costLocale:n,fxRate:r,navigate:i,pathname:a,pricing:o,refresh:s,setFxRate:c,setPricing:l}=e;return a===`/setup-pricing`?o===null?(0,m.jsxs)(`main`,{className:`app-state`,children:[(0,m.jsx)(`p`,{children:n===`pt-BR`?`Configuração do projeto`:`Project settings`}),(0,m.jsx)(`h1`,{children:n===`pt-BR`?`Carregando catálogo de preços…`:`Loading pricing catalog…`}),(0,m.jsx)(`button`,{onClick:()=>i(`/`),type:`button`,children:n===`pt-BR`?`Voltar ao dashboard`:`Back to dashboard`})]}):(0,m.jsx)(f.Suspense,{fallback:null,children:(0,m.jsx)(ce,{catalog:o,fxRate:r,locale:n,onClose:()=>i(`/`),onSave:async e=>{l(await t.savePricing(e)),await s()},onSaveFxRate:async e=>{c(await t.saveFxRate(e)),await s()}})}):a===`/cost-calculation-guide`&&o!==null?(0,m.jsx)(f.Suspense,{fallback:null,children:(0,m.jsx)(ue,{catalog:o,fxRate:r,locale:n,onClose:()=>i(`/`)})}):a===`/setup-project`?(0,m.jsx)(f.Suspense,{fallback:null,children:(0,m.jsx)(le,{api:t,locale:n,onClose:()=>i(`/`)})}):null}var he=`/zaip-cost-monitor`,D=`zaip-dashboard-session-token`,ge=`zaip-dashboard-locale`,O=`zaip-dashboard-currency`;function _e(){return window.localStorage.getItem(`zaip-dashboard-locale`)===`en-US`?`en-US`:`pt-BR`}function ve(e){return e.replace(/\/+$/,``)===he?`cost-monitor`:null}function ye(){let e=new URL(window.location.href),t=e.searchParams.get(`token`)??window.localStorage.getItem(`zaip-dashboard-session-token`)??window.sessionStorage.getItem(`zaip-dashboard-session-token`)??``;return t&&(window.localStorage.setItem(D,t),window.sessionStorage.setItem(D,t)),e.searchParams.has(`token`)&&(e.searchParams.delete(`token`),window.history.replaceState(null,``,`${e.pathname}${e.search}${e.hash}`)),t}var be=(0,f.lazy)(async()=>({default:(await E(async()=>{let{TraceabilityWorkspace:e}=await import(`./TraceabilityWorkspace-CTH2wDs5.js`);return{TraceabilityWorkspace:e}},__vite__mapDeps([10,1,2,3,11,12,13,14]))).TraceabilityWorkspace}));function xe({costs:e,costLocale:t,currency:n,dashboardView:r,failedArea:i,lastUpdatedAt:a,loadCostDetail:o,loadCostReadModelPage:s,loadCostRunPage:l,loadCostGroupPage:u,loadingArea:d,onActiveDataChange:p,onCurrencyChange:h,onLoadingChange:g,onLocaleChange:v,onOpenTrace:b,onLoadMoreTraceTasks:x,onRefresh:S,onRetry:ee,onSelectTraceTask:te,onOpenTraceChange:ne,onOpenTraceMacro:C,operations:re,selectedTraceTaskId:ie,trace:w,traceLoadingTaskId:T,traceTasksHasMore:ae,traceTasksLoading:E,traceTasks:oe}){return r===`cost-monitor`?e===null?()=>i===`costs`?(0,m.jsx)(y,{locale:t,onRetry:ee}):(0,m.jsx)(_,{area:`costs`,locale:t}):r=>(0,m.jsx)(f.Suspense,{fallback:(0,m.jsx)(_,{area:`costs`,locale:t}),children:(0,m.jsx)(c,{currency:n,data:e,embedded:!0,globalFilters:r,lastUpdatedAt:a,locale:t,loading:d===`costs`,loadDetail:o,loadReadModelPage:s,loadRunPage:l,loadGroupPage:u,onActiveDataChange:p,onCurrencyChange:h,onLoadingChange:g,onLocaleChange:v,onOpenTrace:b,onRefresh:S,operations:re})}):r===`traceability`?()=>(0,m.jsx)(f.Suspense,{fallback:(0,m.jsx)(_,{area:`operations`,locale:t}),children:(0,m.jsx)(be,{loadingTaskId:T,locale:t,onOpenChange:ne,onOpenPrd:e=>C(`PRD`,e),onOpenSpec:e=>C(`SPEC`,e),onLoadMoreTasks:x,onSelectTask:te,selectedTaskId:ie,tasks:oe.length>0?oe:re.tasks,hasMoreTasks:ae,isLoadingTasks:E,trace:w})}):r===null?(0,m.jsx)(`span`,{"aria-hidden":`true`,hidden:!0}):void 0}var k={"pt-BR":{label:`Áreas do dashboard`,operations:`Operação`,operationsHint:`Trabalho em andamento e priorização`,costs:`Monitor de Custos`,costsHint:`Tempo, tokens e custo`,traceability:`Rastreabilidade`,traceabilityHint:`Ciclo completo em 6 etapas`},"en-US":{label:`Dashboard areas`,operations:`Operations`,operationsHint:`Lifecycle and work in progress`,costs:`Cost Monitor`,costsHint:`Time, tokens, and cost`,traceability:`Traceability`,traceabilityHint:`Complete 6-stage lifecycle`}};function Se({activeView:e,locale:t,onChange:n}){let r=k[t],i=e=>{n(e),window.requestAnimationFrame(()=>{document.querySelector(`.dashboard-global-controls`)?.scrollIntoView({behavior:`smooth`,block:`start`})})};return(0,m.jsxs)(`nav`,{"aria-label":r.label,className:`dashboard-capability-nav`,children:[(0,m.jsxs)(`button`,{"aria-current":e===`cost-monitor`?`page`:void 0,className:e===`cost-monitor`?`is-active`:void 0,onClick:()=>i(`cost-monitor`),type:`button`,children:[(0,m.jsx)(Ce,{}),(0,m.jsxs)(`span`,{children:[(0,m.jsx)(`strong`,{children:r.costs}),(0,m.jsx)(`small`,{children:r.costsHint})]})]}),(0,m.jsxs)(`button`,{"aria-current":e===`operations`?`page`:void 0,className:e===`operations`?`is-active`:void 0,onClick:()=>i(`operations`),type:`button`,children:[(0,m.jsx)(A,{}),(0,m.jsxs)(`span`,{children:[(0,m.jsx)(`strong`,{children:r.operations}),(0,m.jsx)(`small`,{children:r.operationsHint})]})]}),(0,m.jsxs)(`button`,{"aria-current":e===`traceability`?`page`:void 0,className:e===`traceability`?`is-active`:void 0,onClick:()=>i(`traceability`),type:`button`,children:[(0,m.jsx)(j,{}),(0,m.jsxs)(`span`,{children:[(0,m.jsx)(`strong`,{children:r.traceability}),(0,m.jsx)(`small`,{children:r.traceabilityHint})]})]})]})}function A(){return(0,m.jsxs)(`svg`,{"aria-hidden":`true`,className:`lucide lucide-square-kanban`,viewBox:`0 0 24 24`,children:[(0,m.jsx)(`rect`,{height:`18`,rx:`2`,width:`18`,x:`3`,y:`3`}),(0,m.jsx)(`path`,{d:`M8 7v7`}),(0,m.jsx)(`path`,{d:`M12 7v4`}),(0,m.jsx)(`path`,{d:`M16 7v9`})]})}function Ce(){return(0,m.jsxs)(`svg`,{"aria-hidden":`true`,className:`lucide lucide-circle-dollar-sign`,viewBox:`0 0 24 24`,children:[(0,m.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,m.jsx)(`path`,{d:`M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8`}),(0,m.jsx)(`path`,{d:`M12 18V6`})]})}function j(){return(0,m.jsxs)(`svg`,{"aria-hidden":`true`,className:`lucide lucide-route`,viewBox:`0 0 24 24`,children:[(0,m.jsx)(`circle`,{cx:`6`,cy:`19`,r:`3`}),(0,m.jsx)(`path`,{d:`M9 19h6.5a3.5 3.5 0 0 0 0-7h-7a3.5 3.5 0 0 1 0-7H18`}),(0,m.jsx)(`circle`,{cx:`18`,cy:`5`,r:`3`})]})}function we({currency:e,locale:t,onCurrencyChange:n,onHelpOpen:r,onNavigate:i,pricingSetupPath:a,projectSetupPath:o,costCalculationGuidePath:s}){return(0,m.jsxs)(`div`,{className:`dashboard-global-settings`,children:[(0,m.jsxs)(`label`,{children:[(0,m.jsx)(`span`,{children:t===`pt-BR`?`Moeda`:`Currency`}),(0,m.jsxs)(`select`,{"aria-label":t===`pt-BR`?`Moeda`:`Currency`,onChange:e=>n(e.target.value),value:e,children:[(0,m.jsx)(`option`,{value:`BRL`,children:`BRL · Real brasileiro`}),(0,m.jsx)(`option`,{value:`USD`,children:`USD · US Dollar`})]})]}),(0,m.jsx)(`button`,{className:`dashboard-help-open`,onClick:r,type:`button`,children:t===`pt-BR`?`Central de Ajuda`:`Open help and guides`}),(0,m.jsx)(`button`,{className:`dashboard-help-open`,onClick:()=>i(a),type:`button`,children:t===`pt-BR`?`Configurar preços e câmbio`:`Configure pricing and FX`}),(0,m.jsx)(`button`,{className:`dashboard-help-open`,onClick:()=>i(o),type:`button`,children:t===`pt-BR`?`Configurar projeto`:`Configure project`})]})}var Te=class{token;constructor(e){this.token=e}ready(){return this.get(`/api/v2/ready`)}operations(e,t=`detail`,n,r=!1){let a=`${i.operations}?scope=${t}${r?`&fresh=1`:``}`;return this.get(F(a,e),n)}sqliteViewPage(e,t,n={},r){let i=new URLSearchParams({view:e,offset:String(n.offset??0)});return n.limit!==void 0&&i.set(`limit`,String(n.limit)),n.query&&i.set(`query`,n.query),n.status&&i.set(`status`,n.status),n.risk&&i.set(`risk`,n.risk),n.provider&&i.set(`provider`,n.provider),n.model&&i.set(`model`,n.model),n.agent&&i.set(`agent`,n.agent),n.phase&&i.set(`phase`,n.phase),n.origin&&i.set(`origin`,n.origin),n.workType&&i.set(`workType`,n.workType),n.priority&&i.set(`priority`,n.priority),n.kind&&i.set(`kind`,n.kind),this.get(F(`/api/v2/sqlite-views?${i.toString()}`,t),r)}operationsBoard(e,t,n=0,r,a,o=4){let s=new URLSearchParams({scope:`board`,stage:t,offset:String(n),limit:String(o)});return r?.query&&s.set(`query`,r.query),r?.status&&s.set(`status`,r.status),r?.risk&&s.set(`risk`,r.risk),r?.origin&&s.set(`origin`,r.origin),r?.kind&&s.set(`kind`,r.kind),this.get(F(`${i.operations}?${s.toString()}`,e),a)}operationsClassification(e,t,n,r=0,a,o=50){let s=new URLSearchParams({scope:`classification`,kind:t,classification:n,offset:String(r),limit:String(o)});return this.get(F(`${i.operations}?${s.toString()}`,e),a)}operationsEntityPage(e,t,n=0,r,a){let o=M(t,n,r);return this.get(F(`${i.operations}/runs?${o}`,e),a)}operationsLifecyclePage(e,t,n=0,r,a){let o=M(t,n,r);return this.get(F(`${i.operations}/entities?${o}`,e),a)}operationsReadModelPage(e,t,n=0,r=50,a=``,o){let s=new URLSearchParams({kind:t,offset:String(n),limit:String(r)});return a&&s.set(`query`,a),this.get(F(`${i.operations}/read-models?${s.toString()}`,e),o)}costMonitor(e=`BRL`,t,n=`detail`,r,a,o=!1){let s=new URLSearchParams({currency:e,scope:n});o&&s.set(`fresh`,`1`);for(let[e,t]of Object.entries(a??{}))t&&s.set(e,t);return this.get(F(`${i.costMonitor}?${s.toString()}`,t),r)}costMonitorRuns(e=`BRL`,t,n,r=100,a,o){let s=new URLSearchParams({currency:e,scope:`runs`,offset:String(n),limit:String(r)});for(let[e,t]of Object.entries(o??{}))t&&s.set(e,t);return this.get(F(`${i.costMonitor}?${s.toString()}`,t),a)}snapshot(e=`BRL`,t){return this.get(F(`${i.snapshot}?currency=${e}`,t))}reconcileOpenWork(e=`BRL`,t){return this.post(F(`${i.reconcileOpenWork}?currency=${e}`,t),Ee)}refreshProjection(e=`BRL`,t){return this.post(F(`${i.refreshProjection}?currency=${e}`,t),Ee)}task(e){return this.get(i.task(e))}prd(e){return this.get(i.prd(e))}spec(e){return this.get(i.spec(e))}taskTrace(e,t){return this.get(i.taskTrace(e),t)}pricing(){return this.get(`/api/v2/pricing`)}async savePricing(e){let t=await fetch(`/api/v2/pricing`,{method:`PUT`,headers:{"content-type":`application/json`,"x-zaip-session":this.token},body:JSON.stringify(e)});if(!t.ok)throw Error(`Pricing update failed with HTTP ${t.status}`);return await t.json()}fxRate(){return this.get(`/api/v2/fx-rate`)}agentCatalog(){return this.get(i.agentCatalog)}agentPortraitUrl(e){return`/api/v2/agent-catalog-assets/${encodeURIComponent(e)}?token=${encodeURIComponent(this.token)}`}projectSettings(){return this.get(i.projectSettings)}projectOverview(){return this.get(`${i.projectSettings}/overview`)}async saveWorkPriority(e){let t=await fetch(i.workPriority,{method:`PUT`,headers:{"content-type":`application/json`,"x-zaip-session":this.token},body:JSON.stringify({item_ids:e})});if(!t.ok)throw Error(`Work priority update failed with HTTP ${t.status}`);return await t.json()}async saveProjectSettings(e){let t=await fetch(i.projectSettings,{method:`PUT`,headers:{"content-type":`application/json`,"x-zaip-session":this.token},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error??`Project settings update failed with HTTP ${t.status}`)}return await t.json()}async saveAgentCatalog(e){let t=e.map(({nickname_candidates:e,...t})=>t),n=await fetch(i.agentCatalog,{method:`PUT`,headers:{"content-type":`application/json`,"x-zaip-session":this.token},body:JSON.stringify({agents:t})});if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error??`Agent catalog update failed with HTTP ${n.status}`)}return await n.json()}async saveFxRate(e){let t=await fetch(`/api/v2/fx-rate`,{method:`PUT`,headers:{"content-type":`application/json`,"x-zaip-session":this.token},body:JSON.stringify({rate:e})});if(!t.ok)throw Error(`FX update failed with HTTP ${t.status}`);return await t.json()}async get(e,t){let n=await P(e,{cache:`no-cache`,headers:{"x-zaip-session":this.token}},N,t);if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error??`Dashboard API failed with HTTP ${n.status}`)}return await n.json()}async post(e,t=N){let n=await P(e,{method:`POST`,headers:{"x-zaip-session":this.token}},t);if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error??`Dashboard API failed with HTTP ${n.status}`)}return await n.json()}};function M(e,t,n){let r=new URLSearchParams({kind:e,offset:String(t),limit:`100`});return n?.query&&r.set(`query`,n.query),n?.status&&r.set(`status`,n.status),n?.risk&&r.set(`risk`,n.risk),r.toString()}var N=6e4,Ee=18e4;async function P(e,t,n=N,r){let i=new AbortController,a=()=>i.abort();r?.addEventListener(`abort`,a,{once:!0}),r?.aborted&&i.abort();let o=window.setTimeout(()=>i.abort(),n);try{return await fetch(e,{...t,signal:i.signal})}catch(e){throw e instanceof DOMException&&e.name===`AbortError`?Error(`A leitura demorou mais de ${Math.ceil(n/1e3)} segundos. Tente novamente.`):e}finally{window.clearTimeout(o),r?.removeEventListener(`abort`,a)}}function F(e,t){if(t===void 0)return e;let n=new URL(e,`http://dashboard.local`);return t.from!==null&&n.searchParams.set(`from`,t.from),t.to!==null&&n.searchParams.set(`to`,t.to),`${n.pathname}${n.search}`}var De={preset:`this-month`,range:a(`this-month`)};function I(e){return e.preset===`all`?{from:null,to:null}:{from:e.range.start,to:e.range.end}}var Oe=1500;function ke({snapshotUpdating:e,initialDataPending:t,dismissed:n,delayElapsed:r}){return e&&t&&!n&&r}function Ae({cursor:e,page:t,tasks:n}){let r=new Map(n.map(e=>[e.id,e]));for(let e of t.tasks)r.set(e.id,e);let i=e.offset+t.tasks.length;return{tasks:[...r.values()],cursor:t.tasks.length===0||i>=t.total?{offset:0,stageIndex:e.stageIndex+1}:{...e,offset:i}}}function je(e,t,n){return Math.min(t,e+n)}function L(e){return typeof e==`number`?e:null}function Me(e){return typeof e==`number`?{known_sum:e,unknown:0,complete:!0,coverage_ratio:1}:{known_sum:0,unknown:1,complete:!1,coverage_ratio:0}}function R(e){return Object.hasOwn(e,`total_duration`)?L(e.total_duration):L(e.cost_monitor_total_duration)}function Ne(e,t,n){let{filters:r,query:i}=e;return{offset:t,limit:n,...i===void 0||i===``?{}:{query:i},...r.provider?{provider:r.provider}:{},...r.model?{model:r.model}:{},...r.agent?{agent:r.agent}:{},...r.phase?{phase:r.phase}:{},...r.status?{status:r.status}:{},...r.origin?{origin:r.origin}:{},...r.workType?{workType:r.workType}:{},...r.priority?{priority:r.priority}:{},...r.risk?{risk:r.risk}:{}}}function z(e){let t=R(e),n=Number(e.duration_unknown??+(t===null)),r=L(e.duration_known)??t??0;return{key:String(e.key??e.period_key??`total`),label:String(e.label??e.key??e.period_key??``),latest_started_at:typeof e.latest_started_at==`string`?e.latest_started_at:``,persona:typeof e.persona==`string`?e.persona:null,job:typeof e.job==`string`?e.job:null,run_count:Number(e.total_run_count??e.invocation_count??0),task_count:L(e.task_count),prd_count:Number(e.prd_count??0),spec_count:Number(e.spec_count??0),evidence_count:Number(e.evidence_count??0),test_count:Number(e.validation_count??0),event_count:Number(e.source_event_count??0),total_tokens:L(e.total_tokens),estimated_usd:L(e.total_cost_usd),estimated_brl:L(e.total_cost_brl),duration_ms:t,duration:{known_sum:r,unknown:n,complete:n===0,coverage_ratio:+(n===0)},coverage:{events:0,tokens:0,usd:0,brl:0}}}async function Pe(e,t){let{from:n,limit:r,offset:i,signal:a,to:o,view:s}=t,c=n===void 0||o===void 0?void 0:{from:n,to:o};if(s===`daily`){let n=await e.sqliteViewPage(`cost_monitor_daily`,c,Ne(t,i,r),a);return{offset:n.offset,limit:n.limit,total_count:n.total_count,has_more:n.has_more,rows:n.rows.map(z),...n.totals===void 0?{}:{totals:z(n.totals)}}}let l={monthly:`cost_monitor_monthly`,annual:`cost_monitor_annual`,agents:`cost_monitor_zaip_agents`,models:`cost_monitor_models`,providers:`cost_monitor_providers`}[s],u=await e.sqliteViewPage(l,c,Ne(t,i,r),a);return{offset:u.offset,limit:u.limit,total_count:u.total_count,has_more:u.has_more,rows:u.rows.map(z),...u.totals===void 0?{}:{totals:z(u.totals)}}}async function Fe(e,t){let{filters:n,from:r,limit:i=10,offset:a,signal:o,to:s}=t,c=await e.sqliteViewPage(`cost_monitor_agent_invocations`,r===void 0||s===void 0?void 0:{from:r,to:s},{offset:a,limit:i,...n?.query?{query:n.query}:{},...n?.provider?{provider:n.provider}:{},...n?.model?{model:n.model}:{},...n?.agent?{agent:n.agent}:{},...n?.phase?{phase:n.phase}:{},...n?.status?{status:n.status}:{}},o);return{page_only:!0,runs:c.rows.map(Ie),run_page:{offset:c.offset,limit:c.limit,total:c.total_count,has_more:c.has_more}}}function Ie(e){let t=(e,t)=>typeof e==`string`?e:t,n=e=>typeof e==`number`?e:null,r=t(e.agent_invocation_id,`unavailable`),i=typeof e.task_id==`string`?e.task_id:null,a=typeof e.spec_id==`string`?e.spec_id:null,o=typeof e.prd_id==`string`?e.prd_id:null,s=t(e.phase,`execution`),c=e.duration_provenance===`observed`||e.duration_provenance===`reconciled`||e.duration_provenance===`estimated`||e.duration_provenance===`legacy_inferred`?e.duration_provenance:`unavailable`,l=Object.hasOwn(e,`calculated_cost_usd`)?n(e.calculated_cost_usd):n(e.cost_usd),u=n(e.current_fx_rate)??n(e.fx_rate),d=n(e.recorded_cost_usd)??n(e.recorded_usd),f=Object.hasOwn(e,`recorded_fx_rate`)?n(e.recorded_fx_rate):n(e.fx_rate),p=n(e.recorded_brl)??(!Object.hasOwn(e,`recorded_brl`)&&d!==null?n(e.cost_brl):null),m=l!==null&&u!==null?Math.round(l*u*1e6)/1e6:null;return{run_id:r,execution_id:typeof e.execution_id==`string`?e.execution_id:null,conversation_id:t(e.run_id,r),task_id:i,task_title:t(e.task_title,i??`Tarefa avulsa`),task_status:t(e.task_status,`unavailable`),priority:t(e.priority,`unavailable`),risk:t(e.risk,`unavailable`),spec_id:a,prd_id:o,change_id:typeof e.change_id==`string`?e.change_id:null,parent_run_id:typeof e.parent_agent_invocation_id==`string`?e.parent_agent_invocation_id:null,run_role:e.invocation_kind===`subagent`?`subagent`:`orchestrator`,run_kind:e.run_kind===`subrun`?`subrun`:`run`,run_purpose:`execution`,requires_finalizer:!1,client:t(e.client,`unavailable`),agent:t(e.zaip_agent,`unavailable`),agent_name:t(e.zaip_agent,`unavailable`),provider:typeof e.provider==`string`?e.provider:null,model:t(e.model,`unavailable`),requested_model:t(e.requested_model,`unavailable`),reasoning_effort:typeof e.reasoning_effort==`string`?e.reasoning_effort:null,effective_reasoning_effort:typeof e.effective_reasoning_effort==`string`?e.effective_reasoning_effort:null,service_tier:typeof e.service_tier==`string`?e.service_tier:null,call_count:n(e.llm_call_count),status:t(e.status,`completed`),phase:s,origin:o===null?a===null?i===null?`conversation`:`task`:`spec`:`prd`,work_type:e.work_type===`rework`?`rework`:`new`,started_at:t(e.occurred_at,``),finished_at:typeof e.finished_at==`string`?e.finished_at:null,duration_ms:n(e.duration_ms),duration_provenance:c,estimation_basis:typeof e.estimation_basis==`string`?e.estimation_basis:null,source_started_at:typeof e.source_started_at==`string`?e.source_started_at:null,source_finished_at:typeof e.source_finished_at==`string`?e.source_finished_at:null,capture_lag_ms:n(e.capture_lag_ms),event_count:n(e.source_event_count),input_tokens:n(e.input_tokens),cached_input_tokens:n(e.cached_input_tokens),output_tokens:n(e.output_tokens),reasoning_tokens:n(e.reasoning_tokens),total_tokens:n(e.total_tokens),uncached_input_tokens:n(e.uncached_input_tokens),visible_output_tokens:n(e.visible_output_tokens),input_rate_usd_per_million:n(e.input_rate_usd_per_million),cached_input_rate_usd_per_million:n(e.cached_input_rate_usd_per_million),output_rate_usd_per_million:n(e.output_rate_usd_per_million),reasoning_rate_usd_per_million:n(e.reasoning_rate_usd_per_million),context_input_multiplier:n(e.context_input_multiplier),context_output_multiplier:n(e.context_output_multiplier),speed_cost_multiplier:n(e.speed_cost_multiplier),standard_cost_usd:n(e.standard_cost_usd),speed_uplift_usd:n(e.speed_uplift_usd),input_cost_usd:n(e.input_cost_usd),cached_input_cost_usd:n(e.cached_input_cost_usd),output_cost_usd:n(e.output_cost_usd),reasoning_cost_usd:n(e.reasoning_cost_usd),fx_rate:u,estimated_usd:l,estimated_brl:m,recorded_usd:d,recorded_brl:p,recorded_fx_rate:f,coverage:{events:0,tokens:0,usd:0,brl:0},artifact_path:`.agents/records/runs/${r}`}}function Le(e,t){let n=t.totals,r=e=>Me(n?.[e]);return{data_source:`lifecycle_daily_read_models`,snapshot_id:null,source_latest_at:null,kind:e,offset:t.offset,limit:t.limit,total:t.total_count,has_more:t.has_more,next_cursor:null,subtotal:{entity_count:typeof n?.entity_count==`number`?n.entity_count:t.total_count,run_count:r(`invocation_count`),metrics:{duration:r(`total_duration`),total_tokens:r(`total_tokens`),cost_brl:r(`total_cost_brl`),cost_usd:r(`total_cost_usd`)}},rows:t.rows.map(t=>({id:String(t.task_id??t.spec_id??t.prd_id??t.execution_id??t.conversation_id??t.id??`unavailable`),title:String(t.title??t.task_id??t.spec_id??t.prd_id??t.execution_id??t.conversation_id??`Unavailable`),kind:e===`tasks`?`task`:e===`specs`?`spec`:e===`prds`?`prd`:e===`executions`?`execution`:`conversation`,status:typeof t.status==`string`?t.status:null,risk:typeof t.risk==`string`?t.risk:null,occurred_at:typeof t.occurred_at==`string`?t.occurred_at:typeof t.started_at==`string`?t.started_at:typeof t.last_day==`string`?`${t.last_day}T12:00:00.000Z`:``,parent_id:null,run_count:Number(t.invocation_count??0),cost_currency:`BRL`,metrics:{duration:Me(t.total_duration),total_tokens:Me(t.total_tokens),cost:Me(t.total_cost_brl)}}))}}function Re(e){return{loadCostDetail:(0,f.useCallback)(async()=>{throw Error(`SQLite Cost Monitor loads the selected paginated view; full detail is disabled.`)},[]),loadCostReadModelPage:(0,f.useCallback)(async({filters:t,from:n,kind:r,limit:i,offset:a,query:o,signal:s,to:c})=>{let l={tasks:`cost_monitor_tasks`,specs:`cost_monitor_specs`,prds:`cost_monitor_prds`,executions:`cost_monitor_executions`,conversations:`cost_monitor_conversations`}[r];return Le(r,await e.sqliteViewPage(l,n===void 0||c===void 0?void 0:{from:n,to:c},{offset:a,limit:i,...o===void 0||o===``?{}:{query:o},...t.provider?{provider:t.provider}:{},...t.model?{model:t.model}:{},...t.agent?{agent:t.agent}:{},...t.phase?{phase:t.phase}:{},...t.status?{status:t.status}:{},...t.origin?{origin:t.origin}:{},...t.workType?{workType:t.workType}:{},...t.priority?{priority:t.priority}:{},...t.risk?{risk:t.risk}:{}},s))},[e]),loadCostRunPage:(0,f.useCallback)(t=>Fe(e,t),[e]),loadCostGroupPage:(0,f.useCallback)(t=>Pe(e,t),[e])}}function ze(e,t){return!1}function Be(e,t=window,n=0){let r=!1,i=!1,a=new AbortController,o=t.setTimeout(()=>{r||i||(i=!0,e(a.signal))},n);return()=>{r||(r=!0,a.abort(),t.clearTimeout(o))}}function Ve({inFlight:e,lastRefreshAt:t,now:n,visibilityState:r}){return r===`visible`&&!e&&n-t>=5e3}function He({api:e,costLocale:t,currency:n,dashboardView:r,loadOperationsDetails:i,operations:a,operationsDetailAbortRef:o,operationsDetailCancelRef:s,operationsPageAbortRef:c,pathname:l,pricing:u,refresh:d,refreshVersion:p,setError:m,setFxRate:h,setPathname:g,setPricing:_}){let v=(0,f.useRef)(!1),y=(0,f.useRef)(0);(0,f.useEffect)(()=>(d(),()=>{s.current?.(),s.current=null,o.current?.abort(),o.current=null,c.current?.abort(),c.current=null,++p.current}),[o,s,c,d,p]),(0,f.useEffect)(()=>{let e=()=>{let e=Date.now();Ve({inFlight:v.current,lastRefreshAt:y.current,now:e,visibilityState:document.visibilityState})&&(y.current=e,v.current=!0,d(!1,!1,!0).finally(()=>{v.current=!1}))};return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,e)}},[d]),(0,f.useEffect)(()=>{if(!ze(r,a?.summary.overview_metrics?.partial===!0))return;let e=Be(async e=>{await i(e)});return s.current=e,()=>{s.current===e&&(s.current=null),e()}},[r,i,a?.summary.overview_metrics?.partial,s]),(0,f.useEffect)(()=>window.localStorage.setItem(ge,t),[t]),(0,f.useEffect)(()=>window.localStorage.setItem(O,n),[n]),(0,f.useEffect)(()=>{[`/`,`/setup-pricing`,`/setup-project`].includes(window.location.pathname)||(window.history.replaceState(null,``,`/${window.location.search}${window.location.hash}`),g(`/`))},[g]),(0,f.useEffect)(()=>{let e=()=>g(window.location.pathname);return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[g]),(0,f.useEffect)(()=>{l!==`/setup-pricing`||u!==null||Promise.all([e.pricing(),e.fxRate()]).then(([e,t])=>{_(e),h(t)}).catch(e=>m(String(e)))},[e,l,u,m,h,_])}var B={events:0,tokens:{input:null,cached_input:null,output:null,reasoning:null,total:null},cost:{usd:null,brl:null},coverage:{events:0,tokens:0,usd:0,brl:0}};function Ue(e,t,n){let r=e=>e===`intake`||e===`orchestration`||e===`execution`||e===`review`||e===`audit`||e===`finalization`?e:`execution`,i=n.rows.map(e=>({id:e.id,artifact_path:`.agents/records/runs/${e.id}`,status:e.status===`running`||e.status===`failed`||e.status===`cancelled`?e.status:`completed`,phase:e.phase??`execution`,entrypoint:e.conversation_id===null?`task`:`conversation`,work_type:`new`,run_role:e.run_kind===`subrun`?`subagent`:`orchestrator`,run_kind:e.run_kind??`run`,run_purpose:r(e.run_purpose),requires_finalizer:!1,parent_run_id:e.parent_run_id,client:e.client??`unknown`,agent:e.agent??`unknown`,agent_name:e.agent??`unknown`,agent_persona:e.agent_persona??null,agent_job:e.agent_job??null,provider:e.provider??null,model:e.model??`unknown`,reasoning_effort:e.reasoning_effort??null,effective_model:e.model??null,effective_reasoning_effort:e.reasoning_effort??null,effective_config_mixed:e.pricing_mixed??!1,service_tier:e.service_tier??null,call_count:e.llm_call_count??null,terminal_call_count:null,failed_call_count:null,cancelled_call_count:null,conversation_id:e.conversation_id??e.id,execution_id:e.execution_id,task_id:e.task_id,spec_id:null,prd_id:null,change_id:null,started_at:e.started_at,finished_at:e.finished_at,duration_ms:e.duration_ms,source_duration_ms:e.source_duration_ms===void 0?e.duration_ms:e.source_duration_ms,duration_provenance:e.duration_provenance===`observed`||e.duration_provenance===`reconciled`||e.duration_provenance===`legacy_inferred`||e.duration_provenance===`estimated`?e.duration_provenance:`unavailable`,llm_call_count:e.llm_call_count??null,input_tokens:e.input_tokens??null,cached_input_tokens:e.cached_input_tokens??null,uncached_input_tokens:e.uncached_input_tokens??null,output_tokens:e.output_tokens??null,reasoning_tokens:e.reasoning_tokens??null,visible_output_tokens:e.visible_output_tokens??null,input_rate_usd_per_million:e.input_rate_usd_per_million??null,cached_input_rate_usd_per_million:e.cached_input_rate_usd_per_million??null,output_rate_usd_per_million:e.output_rate_usd_per_million??null,reasoning_rate_usd_per_million:e.reasoning_rate_usd_per_million??null,context_input_multiplier:e.context_input_multiplier??null,context_output_multiplier:e.context_output_multiplier??null,speed_cost_multiplier:e.speed_cost_multiplier??null,pricing_scenario:e.pricing_scenario??null,standard_cost_usd:e.standard_cost_usd??null,speed_uplift_usd:e.speed_uplift_usd??null,input_cost_usd:e.input_cost_usd??null,cached_input_cost_usd:e.cached_input_cost_usd??null,output_cost_usd:e.output_cost_usd??null,reasoning_cost_usd:e.reasoning_cost_usd??null,calculated_cost_usd:e.calculated_cost_usd??null,recorded_cost_usd:e.recorded_cost_usd??null,cost_variance_usd:e.cost_variance_usd??null,cost_usd:e.cost_usd??null,cost_brl:e.currency===`BRL`?e.cost:null,fx_rate:e.fx_rate??null,pricing_segment_count:e.pricing_segment_count??null,pricing_mixed:e.pricing_mixed??!1,pricing_model:e.pricing_model??null,pricing_source:e.pricing_source??null,...e.lifecycle_elapsed_ms===void 0?{}:{lifecycle_elapsed_ms:e.lifecycle_elapsed_ms},usage:{conversation:B,planning:B,execution:{...B,events:e.llm_call_count??0,tokens:{input:e.input_tokens??null,cached_input:e.cached_input_tokens??null,output:e.output_tokens??null,reasoning:e.reasoning_tokens??null,total:e.total_tokens},cost:{usd:e.cost_usd??null,brl:e.currency===`BRL`?e.cost:null}},total:{...B,events:e.llm_call_count??0,tokens:{input:e.input_tokens??null,cached_input:e.cached_input_tokens??null,output:e.output_tokens??null,reasoning:e.reasoning_tokens??null,total:e.total_tokens},cost:{usd:e.cost_usd??null,brl:e.currency===`BRL`?e.cost:null}},new_work:B,rework:B}}));return{...e,runs:i,executions:t===`executions`||t===`conversations`?n.rows.map((e,n)=>{let r=i[n],a=r.execution_id??r.conversation_id,o=e.status??`unavailable`;return{id:a,kind:t===`conversations`?`interaction`:`delivery`,created_at:r.started_at,status:o,work_status:o,origin:t===`conversations`?{type:`interaction`,conversation_id:r.conversation_id}:{type:`task`,task_id:r.task_id??`unavailable`},dag:{nodes:[],topological_order:[]},result:null,artifact_path:`.agents/records/executions/${a}`,agent_call_count:0,orchestrator_run_count:0,subagent_run_count:0,finalizer_run_count:0,finalized_task_count:0,llm_call_count:0,llm_call_count_complete:!1,task_count:0,spec_count:0,prd_count:0,duration_ms:r.source_duration_ms??null,...e.lifecycle_elapsed_ms===void 0?{}:{lifecycle_elapsed_ms:e.lifecycle_elapsed_ms},total_tokens:r.usage.total.tokens.total,cost_brl:r.usage.total.cost.brl}}):e.executions}}function We(e){if(typeof e!=`string`)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function Ge({api:e,entityFiltersRef:t,operationsPageAbortRef:n,operationsPageRequestVersionRef:r,operationsPeriod:i,operationsPeriodRef:a,refreshVersion:o,setEntityPage:s,setEntityPageKind:c,setOperations:l}){return{loadOperationsEntityPage:(0,f.useCallback)(async(u,d=0,f=t.current)=>{n.current?.abort();let p=new AbortController;n.current=p;let m=++r.current,h=o.current,g=I(i),_=()=>te(m,r.current,p.signal)&&x(h,o.current,g,I(a.current));c(u),s({offset:d,total:null,loading:!0,error:null});try{let t={runs:`operations_agent_invocations`,executions:`operations_executions`,conversations:`operations_conversations`}[u],n=await e.sqliteViewPage(t,g,{offset:d,limit:100,...f.query?{query:f.query}:{},...f.status?{status:f.status}:{},...f.risk?{risk:f.risk}:{}},p.signal),r={kind:u,offset:n.offset,limit:n.limit,total:n.total_count,aggregation:`canonical_entity`,rows:n.rows.map(e=>({id:String(e.agent_invocation_id??e.execution_id??e.conversation_id??e.id),started_at:String(e.occurred_at??e.started_at??`1970-01-01T00:00:00.000Z`),finished_at:typeof e.finished_at==`string`?e.finished_at:null,task_id:typeof e.task_id==`string`?e.task_id:null,execution_id:typeof e.execution_id==`string`?e.execution_id:null,conversation_id:typeof e.conversation_id==`string`?e.conversation_id:null,parent_run_id:typeof e.parent_agent_invocation_id==`string`?e.parent_agent_invocation_id:null,run_kind:e.invocation_kind===`delegated`||e.invocation_kind===`subagent`?`subrun`:e.invocation_kind===`orchestrator`?`run`:null,run_purpose:typeof e.purpose==`string`?e.purpose:null,phase:typeof e.phase==`string`?e.phase:null,status:typeof e.status==`string`?e.status:null,agent:typeof e.zaip_agent==`string`?e.zaip_agent:null,agent_persona:typeof e.zaip_agent_persona==`string`?e.zaip_agent_persona:null,agent_job:typeof e.zaip_agent_job==`string`?e.zaip_agent_job:null,client:typeof e.client==`string`?e.client:null,provider:typeof e.provider==`string`?e.provider:null,model:typeof e.model==`string`?e.model:null,reasoning_effort:typeof e.reasoning_effort==`string`?e.reasoning_effort:null,service_tier:typeof e.service_tier==`string`?e.service_tier:null,duration_ms:typeof e.duration_ms==`number`?e.duration_ms:typeof e.total_duration==`number`?e.total_duration:null,source_duration_ms:typeof e.source_duration_ms==`number`?e.source_duration_ms:null,duration_provenance:typeof e.duration_provenance==`string`?e.duration_provenance:null,llm_call_count:typeof e.llm_call_count==`number`?e.llm_call_count:null,input_tokens:typeof e.input_tokens==`number`?e.input_tokens:null,cached_input_tokens:typeof e.cached_input_tokens==`number`?e.cached_input_tokens:null,uncached_input_tokens:typeof e.uncached_input_tokens==`number`?e.uncached_input_tokens:null,output_tokens:typeof e.output_tokens==`number`?e.output_tokens:null,reasoning_tokens:typeof e.reasoning_tokens==`number`?e.reasoning_tokens:null,visible_output_tokens:typeof e.visible_output_tokens==`number`?e.visible_output_tokens:null,total_tokens:typeof e.total_tokens==`number`?e.total_tokens:null,input_rate_usd_per_million:typeof e.input_rate_usd_per_million==`number`?e.input_rate_usd_per_million:null,cached_input_rate_usd_per_million:typeof e.cached_input_rate_usd_per_million==`number`?e.cached_input_rate_usd_per_million:null,output_rate_usd_per_million:typeof e.output_rate_usd_per_million==`number`?e.output_rate_usd_per_million:null,reasoning_rate_usd_per_million:typeof e.reasoning_rate_usd_per_million==`number`?e.reasoning_rate_usd_per_million:null,context_input_multiplier:typeof e.context_input_multiplier==`number`?e.context_input_multiplier:null,context_output_multiplier:typeof e.context_output_multiplier==`number`?e.context_output_multiplier:null,speed_cost_multiplier:typeof e.speed_cost_multiplier==`number`?e.speed_cost_multiplier:null,pricing_scenario:typeof e.pricing_scenario==`string`?e.pricing_scenario:null,standard_cost_usd:typeof e.standard_cost_usd==`number`?e.standard_cost_usd:null,speed_uplift_usd:typeof e.speed_uplift_usd==`number`?e.speed_uplift_usd:null,input_cost_usd:typeof e.input_cost_usd==`number`?e.input_cost_usd:null,cached_input_cost_usd:typeof e.cached_input_cost_usd==`number`?e.cached_input_cost_usd:null,output_cost_usd:typeof e.output_cost_usd==`number`?e.output_cost_usd:null,reasoning_cost_usd:typeof e.reasoning_cost_usd==`number`?e.reasoning_cost_usd:null,calculated_cost_usd:typeof e.calculated_cost_usd==`number`?e.calculated_cost_usd:null,recorded_cost_usd:typeof e.recorded_cost_usd==`number`?e.recorded_cost_usd:null,cost_variance_usd:typeof e.cost_variance_usd==`number`?e.cost_variance_usd:null,cost_usd:typeof e.cost_usd==`number`?e.cost_usd:null,fx_rate:typeof e.fx_rate==`number`?e.fx_rate:null,pricing_segment_count:typeof e.pricing_segment_count==`number`?e.pricing_segment_count:null,pricing_mixed:e.pricing_mixed===1||e.pricing_mixed===!0,pricing_model:typeof e.audit_pricing_model==`string`?e.audit_pricing_model:typeof e.pricing_model==`string`?e.pricing_model:null,pricing_source:typeof e.audit_pricing_source==`string`?e.audit_pricing_source:typeof e.pricing_source==`string`?e.pricing_source:null,cost:typeof e.total_cost_brl==`number`?e.total_cost_brl:typeof e.cost_brl==`number`?e.cost_brl:null,currency:`BRL`}))};if(!_())return;l(e=>e===null?e:Ue(e,u,r)),s({offset:r.offset,total:r.total,loading:!1,error:null,aggregation:r.aggregation})}catch(e){if(!_()||S(e))return;s({offset:d,total:null,loading:!1,error:e instanceof Error?e.message:String(e)})}finally{n.current===p&&(n.current=null)}},[e,t,n,r,i,a,o,s,c,l]),loadOperationsLifecyclePage:(0,f.useCallback)(async(u,d=0,f=t.current)=>{n.current?.abort();let p=new AbortController;n.current=p;let m=++r.current,h=o.current,g=I(i),_=()=>te(m,r.current,p.signal)&&x(h,o.current,g,I(a.current));c(u),s({offset:d,total:null,loading:!0,error:null});try{let t=await e.sqliteViewPage(u===`changes`?`operations_changes`:`operations_decisions`,g,{offset:d,limit:100,...f.query?{query:f.query}:{},...f.status?{status:f.status}:{},...f.risk?{risk:f.risk}:{}},p.signal),n=u===`changes`?t.rows.map(e=>{let t=String(e.source_type),n=String(e.source_id);return{id:String(e.id),title:typeof e.title==`string`?e.title:String(e.id),created_at:typeof e.occurred_at==`string`?e.occurred_at:null,status:typeof e.status==`string`?e.status:`unclassified`,risk:typeof e.risk==`string`?e.risk:`unclassified`,source:t===`spec`?{type:`spec`,spec_id:n}:t===`prd`?{type:`prd`,prd_id:n,spec_id:null}:{type:`task`,task_id:n},requirement_ids:We(e.requirement_ids_json),acceptance_ids:We(e.acceptance_ids_json),task_ids:We(e.task_ids_json),result:typeof e.result==`string`?e.result:null,artifact_path:typeof e.source_path==`string`?e.source_path:String(e.id)}}):t.rows.map(e=>({id:String(e.id),title:typeof e.title==`string`?e.title:String(e.id),origin:e.origin===`human`?`human`:`agent`,scope_type:e.scope_type===`execution`?`execution`:`change`,scope_id:String(e.scope_id),artifact_path:typeof e.source_path==`string`?e.source_path:String(e.id),created_at:typeof e.occurred_at==`string`?e.occurred_at:`1970-01-01T00:00:00.000Z`})),r={kind:u,offset:t.offset,limit:t.limit,total:t.total_count,rows:n};if(!_())return;l(e=>e===null?e:{...e,...u===`changes`?{changes:r.rows}:{decisions:r.rows}}),s({offset:r.offset,total:r.total,loading:!1,error:null})}catch(e){if(!_()||S(e))return;s({offset:d,total:null,loading:!1,error:e instanceof Error?e.message:String(e)})}finally{n.current===p&&(n.current=null)}},[e,t,n,r,i,a,o,s,c,l])}}function Ke({api:e,operations:t,setError:n,setFailedArea:r,setLoadingArea:i}){let[a,o]=(0,f.useState)(null),[s,c]=(0,f.useState)([]),[l,u]=(0,f.useState)(null),[d,p]=(0,f.useState)(null),m=(0,f.useRef)(0),h=(0,f.useRef)(0),g=(0,f.useRef)(null),[_,v]=(0,f.useState)(null),[y,b]=(0,f.useState)(``);async function x(a){let c=++h.current;g.current?.abort();let l=new AbortController;g.current=l,n(null),r(null),o(null),v(a),i(`traceability`),await new Promise(e=>window.requestAnimationFrame(()=>e()));try{let n=await e.taskTrace(a,l.signal);if(h.current!==c)return!1;let r=s.find(e=>e.id===a)??t?.tasks.find(e=>e.id===a);return o({...n,task_title:r?.title||n.task_title||a,task_risk:r?.risk||n.task_risk||null,task_created_at:r?.created_at||n.task_created_at||null,task_progress:r?.progress??n.task_progress??0}),!0}catch(e){return l.signal.aborted||h.current!==c?!1:(n(e instanceof Error?e.message:String(e)),r(`traceability`),!1)}finally{h.current===c&&(g.current===l&&(g.current=null),v(null),i(e=>e===`traceability`?null:e))}}function S(e){let n=t?.changes.find(t=>t.id===e);n!==void 0&&(o(null),p({kind:`change`,row:n}))}function ee(e,n){let r=(e===`PRD`?t?.prds:t?.specs)?.find(e=>e.id===n);r!==void 0&&(o(null),p({kind:`macro`,label:e,row:r}))}async function te(n,r){let i=(n===`prd`?t?.prds:t?.specs)?.find(e=>e.id===r);if(!i)return;let a=++m.current,o=n===`prd`?`PRD`:`SPEC`;u({kind:n,label:o,preview:i});try{let t=n===`prd`?await e.prd(r):await e.spec(r);if(m.current!==a)return;u({kind:n,label:o,preview:i,detail:t})}catch(e){if(m.current!==a)return;u({kind:n,label:o,preview:i,error:e instanceof Error?e.message:String(e)})}}function ne(){m.current+=1,u(null)}return{closeDocument:ne,documentDetail:l,openDocument:te,openTrace:x,openTraceChange:S,openTraceMacro:ee,selectedTraceTaskId:y,setSelectedTraceTaskId:b,setTrace:o,setTraceLink:p,setTraceLoadingTaskId:v,setTraceTasks:c,trace:a,traceLink:d,traceLoadingTaskId:_,traceTasks:s}}function qe(e,t){return JSON.stringify([e.query,e.status,e.risk,e.origin??``,e.kind??``,t.from??``,t.to??``])}function Je(e,t,n){return e===`explicit`||t!==n}function Ye(e,t){return{...e,kind:e.kind??t.kind??``}}var V={offset:0,limit:10,total:null,hasMore:!1,typeFilter:`all`,rows:[],loading:!1,error:null};function Xe({api:e,operationsPeriod:t,operationsPeriodRef:n}){let[r,i]=(0,f.useState)(V),a=(0,f.useRef)({query:``,status:``,risk:``}),o=(0,f.useRef)(null),s=(0,f.useRef)(0),c=(0,f.useRef)(null),l=(0,f.useCallback)(async(r,l=0,u=`explicit`)=>{let d=I(t),f=Ye(r,a.current),p=qe(f,d);if(!Je(u,p,c.current))return;o.current?.abort();let m=new AbortController;o.current=m;let h=++s.current;a.current=f,c.current=p;let g=f.kind||`all`;i(e=>({...e,offset:l,typeFilter:g,loading:!0,error:null}));try{let t=await e.sqliteViewPage(`operations_work_list`,d,{offset:l,limit:10,...f.query?{query:f.query}:{},...f.status?{status:f.status}:{},...f.risk?{risk:f.risk}:{},...f.origin?{origin:f.origin}:{},...g===`all`?{}:{kind:g}},m.signal);if(m.signal.aborted||h!==s.current||d.from!==I(n.current).from||d.to!==I(n.current).to)return;i({offset:t.offset,limit:t.limit,total:t.total_count,hasMore:t.has_more,typeFilter:g,rows:t.rows,loading:!1,error:null})}catch(e){if(m.signal.aborted||h!==s.current)return;c.current===p&&(c.current=null),i(t=>({...t,offset:l,typeFilter:g,loading:!1,error:e instanceof Error?e.message:String(e)}))}finally{o.current===m&&(o.current=null)}},[e,t,n]),u=(0,f.useCallback)(()=>{o.current?.abort(),o.current=null,++s.current,c.current=null,i(V)},[]);return{workListPage:r,workListFiltersRef:a,loadWorkListFilters:(0,f.useCallback)(e=>l(e,0,`filter-hydration`),[l]),loadWorkListPage:l,resetWorkListPage:u}}async function*H(e,t){let n=e;for(;;){if(n.rows.length===0)return;yield n.rows;let e=n.offset+n.rows.length;if(!n.has_more||e>=n.total_count)return;n=await t(e)}}function Ze({api:e,operationsPeriod:t}){return(0,f.useCallback)((n,r)=>{let i=I(t);if(n===`work-kanban`)return;let a={"work-list":`operations_work_list`,changes:`operations_changes`,decisions:`operations_decisions`,executions:`operations_executions`,runs:`operations_agent_invocations`,conversations:`operations_conversations`,daily:`operations_daily`,monthly:`operations_monthly`,yearly:`operations_annual`}[n];if(a===void 0)return;let o=e=>({offset:e,limit:100,...r.query?{query:r.query}:{},...r.status?{status:r.status}:{},...r.risk?{risk:r.risk}:{},...r.origin?{origin:r.origin}:{},...a===`operations_work_list`&&r.kind?{kind:r.kind}:{}});return{prepare:async()=>{let t=await e.sqliteViewPage(a,i,o(0));return{totalRows:t.total_count,pages:()=>H(t,t=>e.sqliteViewPage(a,i,o(t)))}}}},[e,t])}var Qe=(e,t)=>`${e}:${t}`,$e=(e,t)=>`${e}:${t}`,et=[`definition`,`planning`,`ready`,`executing`,`verifying`,`completed`,`blocked`,`cancelled`,`failed`],tt=[`completed`,`executing`,`ready`,`blocked`,`verifying`,`failed`,`cancelled`,`planning`,`definition`];function U(){let[e,t]=(0,f.useState)(!1),[n,r]=(0,f.useState)(!1),[i,a]=(0,f.useState)(!1),o=(0,f.useMemo)(ye,[]),c=(0,f.useMemo)(()=>new Te(o),[o]),{loadCostDetail:l,loadCostReadModelPage:u,loadCostRunPage:d,loadCostGroupPage:p}=Re(c),[h,g]=(0,f.useState)(()=>ve(window.location.pathname)),_=(0,f.useRef)(h);_.current=h;let[v,y]=(0,f.useState)(null),[te,w]=(0,f.useState)({offset:0,total:null,loading:!1,error:null}),[T,ae]=(0,f.useState)(`runs`),E=(0,f.useRef)({query:``,status:``,risk:``}),[oe,ce]=(0,f.useState)({}),[le,ue]=(0,f.useState)({}),[he,D]=(0,f.useState)({}),[ge,O]=(0,f.useState)({}),[be,k]=(0,f.useState)({}),[A,Ce]=(0,f.useState)(null),[j,M]=(0,f.useState)(null),[N,Ee]=(0,f.useState)(_e),[P,F]=(0,f.useState)(()=>window.localStorage.getItem(`zaip-dashboard-currency`)===`USD`?`USD`:`BRL`),je=(0,f.useCallback)(e=>{Ee(e),F(e===`en-US`?`USD`:`BRL`)},[]),[L,Me]=(0,f.useState)(()=>De),R=(0,f.useRef)(L);R.current=L;let[Ne,z]=(0,f.useState)(!1),[Pe,Fe]=(0,f.useState)(null),[Ie,Le]=(0,f.useState)(null),[ze,Be]=(0,f.useState)(window.location.pathname),[Ve,B]=(0,f.useState)(!0),[,Ue]=(0,f.useState)(!1),[,We]=(0,f.useState)(!1),[qe,Je]=(0,f.useState)(!1),[Ye,V]=(0,f.useState)(`operations`),[H,U]=(0,f.useState)(null),[nt,rt]=(0,f.useState)(null);(0,f.useEffect)(()=>{c.ready().then(e=>t(e.snapshot_state===`updating`)).catch(()=>{})},[c]);let[it,W]=(0,f.useState)(null),[at,ot]=(0,f.useState)(null),[st,ct]=(0,f.useState)(null),[lt,ut]=(0,f.useState)({title:`Dashboard Zaip AIOS`,repositoryName:``}),{closeDocument:dt,documentDetail:ft,openDocument:pt,openTrace:G,openTraceChange:mt,openTraceMacro:ht,selectedTraceTaskId:gt,setSelectedTraceTaskId:_t,setTrace:vt,setTraceLink:yt,setTraceLoadingTaskId:bt,setTraceTasks:xt,trace:St,traceLink:Ct,traceLoadingTaskId:wt,traceTasks:Tt}=Ke({api:c,operations:v,setError:W,setFailedArea:U,setLoadingArea:V}),K=(0,f.useRef)(Tt),q=(0,f.useRef)({offset:0,stageIndex:0}),Et=(0,f.useRef)(!1),[Dt,Ot]=(0,f.useState)(!1),[kt,At]=(0,f.useState)(!1),J=(0,f.useRef)(0);(0,f.useEffect)(()=>{K.current=Tt},[Tt]);let jt=(0,f.useRef)(0),Mt=(0,f.useRef)(!1),Y=(0,f.useRef)(0),Nt=(0,f.useRef)(0),Pt=(0,f.useRef)(null),Ft=(0,f.useRef)(!1),It=(0,f.useRef)(!1),Lt=(0,f.useRef)(null),X=(0,f.useRef)(null),Rt=(0,f.useRef)(null),zt=(0,f.useRef)(0),Bt=(0,f.useRef)({}),Z=(0,f.useRef)(new Set),Q=(0,f.useRef)(new Map),Vt=(0,f.useRef)(new Set),Ht=(0,f.useRef)(new Set),Ut=(0,f.useRef)({query:``,status:``,risk:``,origin:``,kind:``}),Wt=(0,f.useRef)(`||||`),$=(0,f.useRef)(0),Gt=(0,f.useRef)(void 0),{workListPage:Kt,workListFiltersRef:qt,loadWorkListFilters:Jt,loadWorkListPage:Yt,resetWorkListPage:Xt}=Xe({api:c,operationsPeriod:L,operationsPeriodRef:R}),Zt=(0,f.useRef)(!1),Qt=(0,f.useCallback)(async(e=!0,t=!1,n=!1)=>{Lt.current?.(),Lt.current=null,X.current?.abort(),X.current=null,$.current+=1;for(let e of Q.current.values())e.abort();Q.current.clear(),Z.current.clear(),Ht.current.clear(),Bt.current={},ce({}),ue({}),D({}),O({}),k({});let r=++J.current,i=jt.current,a=_.current,o=I(L),s=()=>b(r,J.current)&&x(r,J.current,o,I(R.current));e&&(B(!0),V(`operations`)),W(null),U(null);try{if(t||n){let e,n=null;if(t){let t=await c.reconcileOpenWork(P,o);n=t.reconciliation,e=t}else e=await c.refreshProjection(P,o);if(!s())return;n!==null&&ot(n),y(e.operations),Gt.current=e.operations.summary.overview_metrics,It.current=!0,Ce(e.costs),Ft.current=!0,M(null),e.dashboard&&ut({title:e.dashboard.title,repositoryName:e.dashboard.repository_name}),ct(e.projection.source_latest_at)}else{let[e,t]=await Promise.all([c.operations(o,`quick`,void 0,Zt.current),P===`USD`?c.costMonitor(P,o,`summary`):Promise.resolve(null)]);if(!s())return;Zt.current=!1,y(e),Gt.current=e.summary.overview_metrics,It.current=!1,t!==null&&(Ce(t),Ft.current=!1,M(null)),ct(e.summary.source_latest_at)}}catch(e){if(!s())return;W(e instanceof Error?e.message:String(e)),U(a===`cost-monitor`?`costs`:`operations`)}finally{s()&&ee(i,jt.current)&&Je(!1),e&&s()&&(B(!1),V(e=>e===`operations`?null:e))}},[c,P,L]),$t=(0,f.useCallback)(async e=>{if(It.current||Mt.current||e?.aborted)return null;X.current?.abort();let t=e===void 0?new AbortController:null,n=e??t?.signal;if(n===void 0)return null;t!==null&&(X.current=t),Mt.current=!0,Y.current+=1,V(`costs`),U(null);try{let e=++J.current,t=I(L),r=()=>b(e,J.current)&&x(e,J.current,t,I(R.current)),i=await c.operations(t,`detail`,n);return r()?(y(i),It.current=!0,i):null}catch(e){return n.aborted||S(e)?null:(W(e instanceof Error?e.message:String(e)),U(`operations`),null)}finally{t!==null&&X.current===t&&(X.current=null),Mt.current=!1,Y.current=Math.max(0,Y.current-1),Y.current===0&&V(e=>e===`costs`?null:e)}},[c,L]),{loadOperationsEntityPage:en,loadOperationsLifecyclePage:tn}=Ge({api:c,entityFiltersRef:E,operationsPageAbortRef:Rt,operationsPageRequestVersionRef:zt,operationsPeriod:L,operationsPeriodRef:R,refreshVersion:J,setEntityPage:w,setEntityPageKind:ae,setOperations:y}),nn=(0,f.useCallback)((e,t)=>{E.current=t,e===`changes`||e===`decisions`?tn(e,0,t):en(e,0,t)},[en,tn]),rn=(0,f.useCallback)(async e=>{if(v===null||Z.current.has(e))return;Z.current.add(e),Q.current.get(e)?.abort();let t=new AbortController;Q.current.set(e,t);let n=$.current,r=I(L);D(t=>({...t,[e]:{loading:!0,error:null}}));let i=Bt.current[e]??0;try{let a=await c.operationsBoard(r,e,i,Ut.current,t.signal,10);if(t.signal.aborted||n!==$.current||r.from!==I(R.current).from||r.to!==I(R.current).to)return;y(e=>e===null?e:{...ne(e,[a]),summary:e.summary}),ce(t=>({...t,[e]:a.total})),ue(t=>({...t,[e]:a.totals_by_kind}));let o=i+a.prds.length+a.specs.length+a.tasks.length;Bt.current={...Bt.current,[e]:o}}catch(r){if(t.signal.aborted||n!==$.current||S(r))return;D(t=>({...t,[e]:{loading:!1,error:r instanceof Error?r.message:String(r)}}))}finally{n===$.current&&(Z.current.delete(e),Q.current.get(e)===t&&Q.current.delete(e),D(t=>t[e]?.error===null?{...t,[e]:{loading:!1,error:null}}:t))}},[c,v,L]),an=(0,f.useCallback)(e=>{let t={...e,kind:e.kind??Ut.current.kind??``},n=`${t.query}|${t.status}|${t.risk}|${t.origin??``}|${t.kind}`;if(n!==Wt.current){Wt.current=n,Ut.current=t,$.current+=1;for(let e of Q.current.values())e.abort();Q.current.clear(),Z.current.clear(),Ht.current.clear(),Bt.current={},ce({}),ue({}),D({}),O({}),k({}),y(e=>e===null?e:{...e,prds:[],specs:[],tasks:[],changes:[],summary:n===`||||`&&Gt.current!==void 0?{...e.summary,overview_metrics:Gt.current}:e.summary})}},[]),on=(0,f.useCallback)(async(e,t,n)=>{let r=Qe(e,t);if(Vt.current.has(r))return;Vt.current.add(r);let i=$.current,a=I(L);O(e=>({...e,[r]:{items:n===0?[]:e[r]?.items??[],total:e[r]?.total??0,loading:!0,error:null}}));try{let o=await c.operationsBoard(a,e,n,{kind:t===`task`?`all-tasks`:t});if(i!==$.current||a.from!==I(R.current).from||a.to!==I(R.current).to)return;let s=t===`task`?o.tasks:t===`spec`?o.specs:o.prds;O(e=>({...e,[r]:{items:n===0?s:[...e[r]?.items??[],...s],total:o.total,loading:!1,error:null}}))}catch(e){if(i!==$.current||S(e))return;O(t=>({...t,[r]:{items:t[r]?.items??[],total:t[r]?.total??0,loading:!1,error:e instanceof Error?e.message:String(e)}}))}finally{Vt.current.delete(r)}},[c,L]),sn=(0,f.useCallback)(async(e,t,n)=>{let r=$e(e,t);if(Vt.current.has(r))return;Vt.current.add(r);let i=$.current,a=I(L);k(e=>({...e,[r]:{items:n===0?[]:e[r]?.items??[],total:e[r]?.total??0,loading:!0,error:null}}));try{let o=await c.operationsClassification(a,e,t,n);if(i!==$.current||a.from!==I(R.current).from||a.to!==I(R.current).to)return;let s=e===`task`?o.tasks:e===`spec`?o.specs:o.prds;k(e=>({...e,[r]:{items:n===0?s:[...e[r]?.items??[],...s],total:o.total,loading:!1,error:null}}))}catch(e){if(i!==$.current||S(e))return;k(t=>({...t,[r]:{items:t[r]?.items??[],total:t[r]?.total??0,loading:!1,error:e instanceof Error?e.message:String(e)}}))}finally{Vt.current.delete(r)}},[c,L]),cn=(0,f.useCallback)(e=>{let t={...Ut.current,...e},n=I(L);return{prepare:async()=>{let e=await Promise.all(et.map(e=>c.operationsBoard(n,e,0,t))),r=e=>[...e.prds.map(({kind:e,...t})=>({kind:`prd`,...t})),...e.specs.map(({kind:e,...t})=>({kind:`spec`,...t})),...e.tasks.map(e=>({kind:`task`,...e}))];return{totalRows:e.reduce((e,t)=>e+t.total,0),pages:async function*(){for(let i of e){let e=i,a=0;for(;;){let i=r(e);if(i.length===0||(a+=i.length,yield i,a>=e.total))break;e=await c.operationsBoard(n,e.stage,a,t)}}}}}}},[c,L]),ln=Ze({api:c,operationsPeriod:L});(0,f.useEffect)(()=>{if(h!==`operations`||v===null)return;let e=!1,t=async()=>{if(e)return;let t=et.filter(e=>!Ht.current.has(e)&&!Z.current.has(e));for(let n=0;n<t.length&&!e;n+=3){let e=t.slice(n,n+3);for(let t of e)Ht.current.add(t);await Promise.all(e.map(e=>rn(e)))}},n=typeof window.requestIdleCallback==`function`?{kind:`idle`,id:window.requestIdleCallback(()=>void t())}:{kind:`timeout`,id:window.setTimeout(()=>void t(),0)};return()=>{e=!0,n.kind===`idle`?window.cancelIdleCallback(n.id):window.clearTimeout(n.id)}},[h,rn,v]);let un=async e=>{e&&ot(null),rt(e?`reconciling`:`refreshing`),await Qt(!1,e,!e),rt(null)};He({api:c,costLocale:N,currency:P,dashboardView:h,loadOperationsDetails:$t,operations:v,operationsDetailAbortRef:X,operationsDetailCancelRef:Lt,operationsPageAbortRef:Rt,pathname:ze,pricing:Pe,refresh:Qt,refreshVersion:J,setError:W,setFxRate:Le,setPathname:Be,setPricing:Fe});let dn=e=>{window.history.pushState(null,``,e),Be(e),window.scrollTo({left:0,top:0})},fn=(0,f.useCallback)(async()=>{Pt.current?.abort();let e=new AbortController;Pt.current=e;let t=++Nt.current,n=I(L);Y.current+=1,V(`costs`),U(null);try{let r=await c.costMonitor(P,n,`summary`,e.signal);if(e.signal.aborted||t!==Nt.current)return;Ce(r),Ft.current=!0,M(null)}catch(n){if(e.signal.aborted||t!==Nt.current)return;W(n instanceof Error?n.message:String(n)),U(`costs`)}finally{Y.current=Math.max(0,Y.current-1),Y.current===0&&V(e=>e===`costs`?null:e),Pt.current===e&&(Pt.current=null)}},[c,P,L]);(0,f.useEffect)(()=>{P!==`USD`||A?.currency===P||fn()},[A?.currency,P,fn]);let pn=(0,f.useCallback)(async(e=!1,t=!1)=>{if(Et.current||(t&&(q.current={offset:0,stageIndex:0},K.current=[],xt([]),Ot(!0)),q.current.stageIndex>=tt.length))return K.current;Et.current=!0,At(!0);try{do{let t=q.current,n=tt[t.stageIndex];if(n===void 0)break;let r=await c.operationsBoard({from:null,to:null},n,t.offset,{kind:`all-tasks`},void 0,10),i=Ae({cursor:t,page:r,tasks:K.current});if(K.current=i.tasks,xt(K.current),q.current=i.cursor,r.tasks.length>0&&!e)break}while(q.current.stageIndex<tt.length);return Ot(q.current.stageIndex<tt.length),K.current}finally{Et.current=!1,At(!1)}},[c,xt]),mn=async e=>{if(g(e),window.scrollTo({left:0,top:0}),e===`cost-monitor`?A?.currency!==P&&fn():Pt.current?.abort(),e===`traceability`){let e=Tt;if(e.length===0){let t=$.current;if(e=await pn(!1,!0),t!==$.current)return;xt(e)}let t=e.toSorted((e,t)=>Date.parse(t.finished_at??t.updated_at)-Date.parse(e.finished_at??e.updated_at)),n=t.find(e=>e.status===`completed`)??t[0];n&&(_t(n.id),G(n.id));return}vt(null),bt(null)},hn=(0,m.jsx)(Se,{activeView:h,locale:N,onChange:e=>void mn(e)}),gn=(0,f.useMemo)(()=>new Map((j??A)?.runs.map(e=>[e.run_id,P===`USD`?e.estimated_usd:e.estimated_brl])??[]),[A,P,j]),_n=(0,f.useMemo)(()=>{let e=j??A;return e?.currency===P?P===`USD`?e.overview.estimated_usd:e.overview.estimated_brl:null},[A,P,j]),vn=(0,f.useMemo)(()=>{let e=j??A;if(e?.currency===P)return{day:e.groups.daily,month:e.groups.monthly,year:e.groups.annual}},[A,P,j]),yn=()=>{W(null),H===`costs`?Qt():H===`traceability`&&gt?G(gt):H===`operations`&&v!==null?$t():Qt()},bn=me({api:c,costLocale:N,fxRate:Ie,navigate:dn,pathname:ze,pricing:Pe,refresh:Qt,setFxRate:Le,setPricing:Fe}),xn=qe||P===`USD`&&A?.currency!==P,Sn=v===null&&Ve;(0,f.useEffect)(()=>{if(!e||!Sn||n){a(!1);return}let t=window.setTimeout(()=>a(!0),Oe);return()=>window.clearTimeout(t)},[Sn,n,e]);let Cn=ke({snapshotUpdating:e,initialDataPending:Sn,dismissed:n,delayElapsed:i})?(0,m.jsxs)(`div`,{"aria-live":`polite`,className:`app-notice app-snapshot-status`,role:`status`,children:[(0,m.jsx)(`span`,{children:`Exibindo o último snapshot local validado. Os dados canônicos estão sendo atualizados em segundo plano e estarão atuais na próxima abertura.`}),(0,m.jsx)(`button`,{"aria-label":N===`pt-BR`?`Fechar aviso de atualização do snapshot`:`Dismiss snapshot update notice`,onClick:()=>r(!0),type:`button`,children:`×`})]}):null,wn=v;return(0,m.jsxs)(ie,{error:it,globalLoadingPending:xn,locale:N,onRefresh:()=>void Qt(),operations:v,snapshotNotice:Cn,setupRoute:bn,children:[(0,m.jsxs)(re,{pending:xn,children:[it?(0,m.jsxs)(`div`,{"aria-live":`assertive`,className:`app-warning app-error`,role:`alert`,children:[(0,m.jsx)(`span`,{children:it}),H?(0,m.jsx)(`button`,{onClick:yn,type:`button`,children:N===`pt-BR`?`Tentar novamente`:`Try again`}):null,(0,m.jsx)(`button`,{"aria-label":N===`pt-BR`?`Fechar erro`:`Dismiss error`,onClick:()=>W(null),type:`button`,children:`×`})]}):null,(0,m.jsx)(s,{alternateContent:xe({costs:A,costLocale:N,currency:P,dashboardView:h,failedArea:H,lastUpdatedAt:st,loadCostDetail:l,loadCostReadModelPage:u,loadCostRunPage:d,loadCostGroupPage:p,loadingArea:Ye,onActiveDataChange:M,onCurrencyChange:F,onLoadingChange:We,onLocaleChange:je,onLoadMoreTraceTasks:pn,onOpenTrace:e=>void G(e),onRefresh:()=>rt(`choose`),onRetry:yn,onSelectTraceTask:e=>{_t(e),G(e)},onOpenTraceChange:mt,onOpenTraceMacro:ht,operations:wn,selectedTraceTaskId:gt,trace:St,traceLoadingTaskId:wt,traceTasksHasMore:Dt,traceTasksLoading:kt,traceTasks:Tt}),capabilityNavigation:hn,boardTotals:oe,boardKindTotals:le,boardExportSource:cn,detailExportSource:ln,boardStates:he,data:wn,datePreset:L.preset,dateRange:L.range,entityPage:te,dashboardTitle:lt.title,repositoryName:lt.repositoryName,loading:Ve,locale:N,currency:P,factualCostTotal:_n,factualCostPeriods:vn,onLoadingChange:Ue,resolveRunCost:A===null?void 0:e=>gn.get(e)??null,onLocaleChange:je,onDetailDataRequest:e=>{let t=e===`conversations`?`conversations`:e===`executions`?`executions`:e===`runs`?`runs`:null;t===null?e===`changes`||e===`decisions`?tn(e):$t():en(t)},onLoadMacroMetrics:()=>void $t(),onEntityPageChange:e=>{T===`changes`||T===`decisions`?tn(T,e):en(T,e)},onEntityFiltersChange:nn,onBoardFiltersChange:an,onWorkListFiltersChange:Jt,onWorkListPageChange:e=>void Yt(qt.current,e),onBoardTypeChange:e=>an({...Ut.current,kind:e===`all`?``:e}),onWorkListTypeChange:e=>void Yt({...qt.current,kind:e===`all`?``:e}),onLoadMoreBoard:e=>void rn(e),workListPage:Kt,statusPage:(e,t)=>ge[Qe(e,t)],onLoadStatusPage:(e,t,n)=>void on(e,t,n),classificationPage:(e,t)=>be[$e(e,t)],onLoadClassificationPage:(e,t,n)=>void sn(e,t,n),onOpenDocument:(e,t)=>void pt(e,t),onOpenTask:G,onPriorityChange:async e=>{try{await c.saveWorkPriority(e)}catch(e){throw W(e instanceof Error?e.message:String(e)),e}},onDateChange:(e,t)=>{It.current=!1,Lt.current?.(),Lt.current=null,X.current?.abort(),X.current=null,Rt.current?.abort(),Rt.current=null,Xt(),++zt.current,$.current+=1;for(let e of Q.current.values())e.abort();Q.current.clear(),Z.current.clear(),Ht.current.clear(),Bt.current={},ce({}),ue({}),D({}),O({}),k({}),++J.current,w({offset:0,total:null,loading:!1,error:null}),Ft.current=!1,Ce(null),M(null),B(!0),jt.current+=1,Je(!0),V(`operations`),Me({preset:e,range:t})},onRefresh:()=>rt(`choose`),settings:(0,m.jsx)(we,{costCalculationGuidePath:pe,currency:P,locale:N,onCurrencyChange:F,onHelpOpen:()=>z(!0),onNavigate:dn,pricingSetupPath:de,projectSetupPath:fe})}),(0,m.jsx)(se,{closeDocument:dt,costLocale:N,documentDetail:ft,helpOpen:Ne,loadingArea:h===`cost-monitor`&&A===null?null:Ye,operations:wn,reconciliationResult:at,refreshDialog:nt,showTrace:h===`traceability`,trace:St,traceLink:Ct,traceLoadingTaskId:wt,onCloseHelp:()=>z(!1),onCloseTrace:()=>vt(null),onDismissReconciliation:()=>ot(null),onOpenDocument:(e,t)=>void pt(e,t),onOpenTrace:e=>void G(e),onOpenTraceChange:mt,onOpenTraceMacro:ht,onRefreshCancel:()=>rt(null),onRefreshFromDialog:e=>void un(e),setTraceLink:e=>yt(e)})]}),xn?(0,m.jsx)(C,{}):null]})}var nt=document.getElementById(`root`);if(!nt)throw Error(`Elemento #root não encontrado`);(0,p.createRoot)(nt).render((0,m.jsx)(f.StrictMode,{children:(0,m.jsx)(U,{})}));export{je as t};
@@ -6,7 +6,7 @@
6
6
  <meta name="color-scheme" content="dark light" />
7
7
  <link rel="icon" type="image/png" href="/icon_zaip.png" />
8
8
  <title>ZAIP-AIOS</title>
9
- <script type="module" crossorigin src="/assets/index-CZQlsLV9.js"></script>
9
+ <script type="module" crossorigin src="/assets/index-CuMcoUni.js"></script>
10
10
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-D9-fqq9M.js">
11
11
  <link rel="modulepreload" crossorigin href="/assets/cost-monitor-DKwP1stV.js">
12
12
  <link rel="modulepreload" crossorigin href="/assets/react-vendor-B3TJrD4O.js">