okengine 0.3.5 → 0.4.3

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 (144) hide show
  1. package/AGENTS.md +6 -0
  2. package/manifest.v1.schema.json +43 -1
  3. package/package.json +27 -12
  4. package/site/content/docs/ai/skills.mdx +11 -7
  5. package/site/content/docs/console/vault.mdx +4 -0
  6. package/site/content/docs/elements/ai.mdx +2 -0
  7. package/site/content/docs/elements/channel.mdx +7 -4
  8. package/site/content/docs/elements/clock.mdx +2 -4
  9. package/site/content/docs/elements/flow.mdx +19 -10
  10. package/site/content/docs/elements/gate.mdx +18 -11
  11. package/site/content/docs/elements/signal.mdx +9 -12
  12. package/site/content/docs/elements/store.mdx +69 -8
  13. package/site/content/docs/elements/vault.mdx +11 -12
  14. package/site/content/docs/get-started/basic-usage.mdx +76 -41
  15. package/site/content/docs/get-started/installation.mdx +95 -43
  16. package/site/content/docs/get-started/introduction.mdx +128 -75
  17. package/site/content/docs/get-started/meta.json +1 -1
  18. package/site/content/docs/get-started/why.mdx +141 -0
  19. package/site/content/docs/plugins/ip-allowlist.mdx +1 -2
  20. package/site/content/docs/plugins/security-headers.mdx +1 -1
  21. package/site/content/docs/reference/configuration.mdx +2 -2
  22. package/site/content/docs/reference/environment-variables.mdx +10 -0
  23. package/site/content/docs/reference/fx.mdx +56 -3
  24. package/site/content/docs/reference/plugins.mdx +18 -18
  25. package/src/cli/competitor-mention-removal.test.ts +117 -0
  26. package/src/cli/dev.ts +20 -0
  27. package/src/cli/meilisearch-local.test.ts +69 -0
  28. package/src/cli/meilisearch-local.ts +188 -0
  29. package/src/compiler/extract.test.ts +63 -0
  30. package/src/compiler/extract.ts +36 -15
  31. package/src/compiler/fixtures/skyport/src/flows/payments/index.ts +5 -1
  32. package/src/console/server/channels.ts +2 -0
  33. package/src/console/server/clock.ts +3 -0
  34. package/src/console/server/flows.ts +13 -0
  35. package/src/console/server/gates.ts +2 -0
  36. package/src/console/server/plugins.ts +20 -1
  37. package/src/console/server/signals.ts +5 -0
  38. package/src/console/server/store.test.ts +17 -0
  39. package/src/console/server/store.ts +35 -1
  40. package/src/console/ui/channels/types.ts +1 -0
  41. package/src/console/ui/clock/types.ts +1 -0
  42. package/src/console/ui/display.test.ts +14 -0
  43. package/src/console/ui/display.ts +9 -0
  44. package/src/console/ui/dist/assets/index-CjxwRGVv.js +10 -0
  45. package/src/console/ui/dist/assets/panel-access-BGv45snf.js +64 -0
  46. package/src/console/ui/dist/assets/{panel-ai-D_m6WQI8.js → panel-ai-B2S7LEii.js} +1 -1
  47. package/src/console/ui/dist/assets/{panel-architecture-CKnXFyUx.js → panel-architecture-D7UJh91v.js} +1 -1
  48. package/src/console/ui/dist/assets/panel-channels-9T3ybqRu.js +1 -0
  49. package/src/console/ui/dist/assets/panel-clock-Cb1UXGRQ.js +1 -0
  50. package/src/console/ui/dist/assets/{panel-diff-cdonmH8c.js → panel-diff-DmYbKWmN.js} +1 -1
  51. package/src/console/ui/dist/assets/panel-flows-PiHwT55z.js +48 -0
  52. package/src/console/ui/dist/assets/panel-gates-BQGYXvjT.js +1 -0
  53. package/src/console/ui/dist/assets/panel-overview-BBnRO18l.js +1 -0
  54. package/src/console/ui/dist/assets/panel-plugins-D0PsmVw2.js +1 -0
  55. package/src/console/ui/dist/assets/panel-runs-CWuRDe0r.js +1 -0
  56. package/src/console/ui/dist/assets/panel-signals-Bbg4ewpP.js +1 -0
  57. package/src/console/ui/dist/assets/panel-store-CPCbsDRa.js +1 -0
  58. package/src/console/ui/dist/assets/panel-traces-DVAzuA_S.js +1 -0
  59. package/src/console/ui/dist/assets/panel-vault-D1_MvOmo.js +1 -0
  60. package/src/console/ui/dist/assets/{rolldown-runtime-CNC7AqOf.js → rolldown-runtime-B0Z9INg1.js} +1 -1
  61. package/src/console/ui/dist/index.html +2 -2
  62. package/src/console/ui/gates/types.ts +1 -0
  63. package/src/console/ui/plugins/fixture.ts +7 -0
  64. package/src/console/ui/plugins/types.ts +3 -0
  65. package/src/console/ui/shell/client.ts +3 -0
  66. package/src/console/ui/shell/panels/channels/ChannelsPanel.tsx +7 -2
  67. package/src/console/ui/shell/panels/clock/ClockPanel.tsx +9 -2
  68. package/src/console/ui/shell/panels/gates/GatesPanel.tsx +12 -5
  69. package/src/console/ui/shell/panels/plugins/PluginsPanel.tsx +18 -4
  70. package/src/console/ui/shell/panels/signals/SignalsPanel.tsx +13 -2
  71. package/src/console/ui/shell/panels/store/StorePanel.tsx +11 -4
  72. package/src/console/ui/shell/panels/vault/VaultPanel.tsx +9 -3
  73. package/src/console/ui/signals/types.ts +1 -0
  74. package/src/console/ui/store/fixture.ts +5 -0
  75. package/src/console/ui/store/types.ts +2 -0
  76. package/src/docker/compose.ts +5 -0
  77. package/src/docker/docker.test.ts +41 -0
  78. package/src/docker/recipes/index.ts +10 -2
  79. package/src/docker/recipes/meilisearch.ts +31 -0
  80. package/src/drivers/conformance.test.ts +26 -0
  81. package/src/drivers/conformance.ts +40 -3
  82. package/src/drivers/drizzle-dialect.test.ts +4 -0
  83. package/src/drivers/drizzle-dialect.ts +8 -4
  84. package/src/drivers/index.ts +18 -2
  85. package/src/drivers/libsql.ts +179 -0
  86. package/src/drivers/meilisearch.integration.test.ts +77 -0
  87. package/src/drivers/meilisearch.test.ts +181 -0
  88. package/src/drivers/meilisearch.ts +208 -0
  89. package/src/drivers/memory.ts +4 -4
  90. package/src/drivers/pglite.ts +79 -0
  91. package/src/drivers/pgvector.ts +60 -25
  92. package/src/drivers/types.ts +106 -16
  93. package/src/drivers/vault-driver-removal.test.ts +6 -0
  94. package/src/drivers/vault-types.ts +4 -4
  95. package/src/elements/ai/runtime.ts +6 -0
  96. package/src/elements/ai.test.ts +22 -0
  97. package/src/elements/channel/declare.ts +5 -0
  98. package/src/elements/clock/declare.ts +5 -0
  99. package/src/elements/clock/durable.ts +7 -1
  100. package/src/elements/gate/declare.ts +28 -5
  101. package/src/elements/gate.ts +1 -0
  102. package/src/elements/signal/declare.ts +5 -0
  103. package/src/elements/store/declare.ts +10 -2
  104. package/src/elements/store/index-boot.test.ts +299 -0
  105. package/src/elements/store/runtime.ts +110 -17
  106. package/src/elements/store/schema-decl.ts +7 -0
  107. package/src/elements/store.ts +2 -0
  108. package/src/elements/vault.test.ts +27 -4
  109. package/src/elements/vault.ts +1 -1
  110. package/src/index.ts +4 -0
  111. package/src/kernel/abort-scope.ts +116 -0
  112. package/src/kernel/app.ts +12 -2
  113. package/src/kernel/boot-bind/store.test.ts +68 -1
  114. package/src/kernel/boot-bind/store.ts +92 -2
  115. package/src/kernel/concurrency.test.ts +294 -0
  116. package/src/kernel/concurrency.ts +220 -0
  117. package/src/kernel/flow.ts +9 -0
  118. package/src/kernel/fx.test.ts +23 -2
  119. package/src/kernel/fx.ts +80 -4
  120. package/src/kernel/index.ts +23 -0
  121. package/src/kernel/journal.ts +9 -0
  122. package/src/kernel/plugin/capabilities.test.ts +18 -0
  123. package/src/kernel/plugin.ts +11 -3
  124. package/src/kernel/redacted.ts +74 -0
  125. package/src/kernel/registry.ts +29 -6
  126. package/src/kernel/router.ts +3 -3
  127. package/src/manifest/types.ts +21 -0
  128. package/src/release/measure.ts +4 -0
  129. package/src/test/provisions.integration.test.ts +1 -1
  130. package/site/content/docs/get-started/comparison.mdx +0 -65
  131. package/src/console/ui/dist/assets/index-BWo8R7NR.js +0 -10
  132. package/src/console/ui/dist/assets/panel-access-C0J2D-a2.js +0 -64
  133. package/src/console/ui/dist/assets/panel-channels-BOmQ-onL.js +0 -1
  134. package/src/console/ui/dist/assets/panel-clock-giAq0Ccv.js +0 -1
  135. package/src/console/ui/dist/assets/panel-flows-DlCU5zjA.js +0 -45
  136. package/src/console/ui/dist/assets/panel-gates-XclZxWD5.js +0 -1
  137. package/src/console/ui/dist/assets/panel-overview-BznEOTnb.js +0 -1
  138. package/src/console/ui/dist/assets/panel-plugins-CcGM1g64.js +0 -1
  139. package/src/console/ui/dist/assets/panel-runs-CGWNHLR4.js +0 -1
  140. package/src/console/ui/dist/assets/panel-signals-CNywkdak.js +0 -1
  141. package/src/console/ui/dist/assets/panel-store-KmTbFHMH.js +0 -1
  142. package/src/console/ui/dist/assets/panel-traces-DBLx2ilD.js +0 -1
  143. package/src/console/ui/dist/assets/panel-vault-CEnFc0dk.js +0 -1
  144. package/src/drivers/vault-infisical.ts +0 -57
@@ -1 +1 @@
1
- import{a as e,r as t}from"./rolldown-runtime-CNC7AqOf.js";import{C as n,Q as r,_ as i,b as a,d as o,nt as s,o as c,tt as l,u,v as d,w as f,x as p,y as m}from"./panel-access-C0J2D-a2.js";var h=[`data`,`messaging`,`time`,`external`],g={data:`Data`,messaging:`Messaging`,time:`Time`,external:`External`},_={data:!0,messaging:!0,time:!0,external:!0},v=p([i(),d(`true`),d(`false`)]).transform(e=>e===!0||e===`true`),ee=m({focus:a().optional(),depth:p([d(1),d(2),d(`1`),d(`2`)]).transform(e=>Number(e)===2?2:1).default(1),data:v.optional(),messaging:v.optional(),time:v.optional(),external:v.optional()});function te(e){let t=ee.safeParse(e);return t.success?t.data:{depth:1}}function ne(e){let t={};e.focus&&(t.focus=e.focus),e.depth===2&&(t.depth=`2`);for(let n of h)e[n]===!1&&(t[n]=`false`);return t}function y(e){return{data:e.data??_.data,messaging:e.messaging??_.messaging,time:e.time??_.time,external:e.external??_.external}}function b(e,t){return{...e,focus:t}}function re(e){let{focus:t,...n}=e;return{...n,depth:e.depth}}function ie(e,t){return{...e,depth:t}}function x(e,t,n){return{...e,[t]:n}}function S(e){return e.startsWith(`sql:`)||e.startsWith(`kv:`)||e.startsWith(`files:`)||e.startsWith(`index:`)?`data`:e.startsWith(`signal:`)?`messaging`:e.startsWith(`channel:`)||e.startsWith(`ai:`)?`external`:null}function ae(e){return e.kind===`signal`?`messaging`:e.kind===`cron`||e.kind===`every`?`time`:null}function C(e){return e.startsWith(`channel:`)||e.startsWith(`ai:`)}function w(e){let t=e.indexOf(`:`);return t===-1?e:e.slice(t+1)}function oe(e){let t=new Set;for(let n of e.flows)for(let e of n.effectRefs)C(e)&&t.add(e);return t.size}function se(e){let t=new Set;for(let n of e.flows)for(let e of n.effectRefs)C(e)&&t.add(e);return[...t].sort()}function ce(e,t){switch(e){case`emit`:return t.startsWith(`signal:`)?t:`signal:${t}`;case`send`:return t.startsWith(`channel:`)?t:`channel:${t}`;case`ask`:return t.startsWith(`ai:`)?t:`ai:${t}`;case`secret`:return t.startsWith(`secret:`)?t:`secret:${t}`;case`call`:return t.startsWith(`flow:`)?t:`flow:${t}`;default:return t}}function T(e,t){return`${e}\0${t}`}function le(e){let t=new Map;for(let n of e){for(let e of n.effects){let r=ce(e.kind,e.resource),i=T(n.flow,r);t.set(i,(t.get(i)??0)+1)}n.parentId}return t}function E(e,t,n){return e.get(T(t,n))??0}function ue(e,t){if(e<=0)return 1;if(t<=1)return 2;let n=e/t;return Math.max(1,Math.min(8,Math.ceil(n*8)))}function D(e){let t=[],n=pe(e);for(let r of e.flows){for(let n of r.causeIds){let i=e.causeById.get(n);if(!i)continue;let a=ae(i);a&&t.push({from:`cause:${i.id}`,to:`flow:${r.id}`,flowId:r.id,layer:a,fromUnit:r.unit,toUnit:r.unit})}for(let i of r.effectRefs){if(i.startsWith(`flow:`)){let e=i.slice(5),n=O(e);t.push({from:`flow:${r.id}`,to:`flow:${e}`,flowId:r.id,ref:i,layer:`call`,fromUnit:r.unit,toUnit:n});continue}let a=S(i);if(!a)continue;let o=C(i)?`external`:de(i,e);if(t.push({from:`flow:${r.id}`,to:i,flowId:r.id,ref:i,layer:a,fromUnit:r.unit,toUnit:o}),a===`messaging`&&i.startsWith(`signal:`)){let a=i.slice(7);for(let o of n.get(a)??[]){let n=e.flowById.get(o);!n||n.id===r.id||t.push({from:`flow:${r.id}`,to:`flow:${n.id}`,flowId:r.id,ref:i,layer:`messaging`,fromUnit:r.unit,toUnit:n.unit})}}}}return t}function de(e,t){let n=t.effectByRef.get(e);if(!n||n.flowIds.length===0)return`shared`;let r=n.flowIds.filter(n=>{let r=t.flowById.get(n);return r?fe(r,e):!1})[0]??n.flowIds[0];return r?O(r):`shared`}function fe(e,t){let n=e.raw.effects;if(!n)return!1;if(t.startsWith(`signal:`)){let e=t.slice(7);return(n.emits??[]).includes(e)}return!!(n.writes??[]).includes(t)}function pe(e){let t=new Map;for(let n of e.flows){let e=n.raw.trigger?.signal;if(!e)continue;let r=t.get(e)??[];r.push(n.id),t.set(e,r)}return t}function O(e){let t=e.indexOf(`.`);return t===-1?e:e.slice(0,t)}function k(e){let t=[];return t.push(...A(e)),t.push(...j(e)),t.push(...M(e)),t.push(...N(e)),t}function A(e){let t=new Map,n=e=>{let n=t.get(e);return n||(n=new Set,t.set(e,n)),n};for(let t of D(e)){if(!t.from.startsWith(`flow:`)||!t.to.startsWith(`flow:`))continue;let e=t.from.slice(5),r=t.to.slice(5);n(e).add(r)}let r=[],i=new Set,a=[],o=new Set,s=e=>{i.add(e),a.push(e),o.add(e);for(let n of t.get(e)??[])if(!i.has(n))s(n);else if(o.has(n)){let e=a.indexOf(n);e!==-1&&r.push([...a.slice(e),n])}a.pop(),o.delete(e)};for(let t of e.flows.map(e=>e.id))i.has(t)||s(t);let c=new Set,l=[];for(let e of r){let t=P(e.slice(0,-1)),n=t.join(`→`);c.has(n)||(c.add(n),l.push({kind:`cycle`,severity:`critical`,title:`Cycle`,detail:`Causal cycle: ${t.join(` → `)}`,nodeIds:t.map(e=>`flow:${e}`)}))}return l}function j(e){if(e.effects.length===0)return[];let t=[...e.effects].filter(e=>e.touchCount>0).sort((e,t)=>t.touchCount-e.touchCount||e.ref.localeCompare(t.ref)),n=t[0];if(!n||n.touchCount<2)return[];let r=t[1]?.touchCount??0;return n.touchCount===r&&t.filter(e=>e.touchCount===n.touchCount).length>1?t.filter(e=>e.touchCount===n.touchCount).map(e=>({kind:`god-node`,severity:`warning`,title:`God node`,detail:`${e.ref} is touched by ${e.touchCount} flows — the most in the system`,nodeIds:[e.ref]})):[{kind:`god-node`,severity:`warning`,title:`God node`,detail:`${n.ref} is touched by ${n.touchCount} flows — the most in the system`,nodeIds:[n.ref]}]}function M(e){let t=[],n=new Set;for(let t of e.effects)t.ref.startsWith(`signal:`)&&n.add(t.ref.slice(7));for(let t of e.flows){for(let e of t.raw.effects?.emits??[])n.add(e);let e=t.raw.trigger?.signal;e&&n.add(e)}for(let r of[...n].sort()){let n=`signal:${r}`,i=e.flows.filter(e=>(e.raw.effects?.emits??[]).includes(r)),a=e.flows.filter(e=>e.raw.trigger?.signal===r);if(i.length===0&&a.length===0){t.push({kind:`orphan-signal`,severity:`warning`,title:`Orphan signal`,detail:`${r} is declared but has no producers and no consumers`,nodeIds:[n]});continue}if(i.length===0){t.push({kind:`orphan-signal`,severity:`warning`,title:`Orphan signal`,detail:`${r} has consumers but no producer`,nodeIds:[n,...a.map(e=>`flow:${e.id}`)]});continue}a.length===0&&t.push({kind:`orphan-signal`,severity:`warning`,title:`Orphan signal`,detail:`${r} is emitted but has no consumers`,nodeIds:[n,...i.map(e=>`flow:${e.id}`)]})}return t}function N(e){let t=[];for(let n of e.effects){if(n.touchCount<2||n.ref.startsWith(`secret:`)||n.ref.startsWith(`channel:`)||n.ref.startsWith(`ai:`))continue;let r=n.flowIds.filter(t=>{let r=e.flowById.get(t);if(!r?.raw.effects)return!1;if(n.ref.startsWith(`signal:`)){let e=n.ref.slice(7);return(r.raw.effects.emits??[]).includes(e)}return(r.raw.effects.writes??[]).includes(n.ref)});if(r.length!==1)continue;let i=r[0];t.push({kind:`spof`,severity:`critical`,title:`Single point of failure`,detail:`${n.ref} is touched by ${n.touchCount} flows but written/emitted by only ${i}`,nodeIds:[n.ref,`flow:${i}`]})}return t}function P(e){if(e.length===0)return[];let t=[...e],n=t.join(`\0`);for(let r=1;r<e.length;r++){let i=[...e.slice(r),...e.slice(0,r)],a=i.join(`\0`);a<n&&(t=i,n=a)}return t}function F(e,t={}){let n=t.focus??null,r=t.depth===2?2:1,i=t.layers??_,a=le(t.runs??[]),o=D(e),s=k(e),c=oe(e);return n?L({graph:e,declared:o,traffic:a,focus:n,depth:r,layers:i,findings:s,crossings:c}):I({graph:e,declared:o,traffic:a,layers:i,findings:s,crossings:c})}function I(e){let{graph:t,declared:n,traffic:r,layers:i,findings:a,crossings:o}=e,s=[...new Set(t.flows.map(e=>e.unit))].sort().map(e=>({id:`unit:${e}`,kind:`unit`,label:e,unit:e,insideBoundary:!0,flowCount:t.flows.filter(t=>t.unit===e).length}));for(let e of se(t))s.push({id:e,kind:`external`,label:w(e),layer:`external`,insideBoundary:!1});let c=new Map;for(let e of n){if(!V(e.layer,i))continue;let t=`unit:${e.fromUnit}`,n=null;if(e.toUnit===`external`||C(e.to))n=e.ref??e.to;else if(e.fromUnit!==e.toUnit)n=`unit:${e.toUnit}`;else continue;if(t===n)continue;let a=`${t}\0${n}\0${e.layer}`,o=e.ref?E(r,e.flowId,e.ref):0,s=c.get(a);s?s.traversals+=o:c.set(a,{from:t,to:n,layer:e.layer,traversals:o,declared:!0})}let l=H(c,!0);return{nodes:U(s),edges:l,boundaryCrossingCount:o,findings:a,focus:null,depth:1,layers:i}}function L(e){let{graph:t,declared:n,traffic:r,focus:i,depth:a,layers:o,findings:s,crossings:c}=e,l=z(t,n,i,a),u=[];for(let e of l){let r=B(t,n,i,e,a);if(e.startsWith(`unit:`)){let n=e.slice(5);u.push({id:e,kind:`unit`,label:n,unit:n,insideBoundary:!0,flowCount:t.flows.filter(e=>e.unit===n).length,focused:e===i,depth:r});continue}if(e.startsWith(`flow:`)){let n=e.slice(5),a=t.flowById.get(n);u.push({id:e,kind:`flow`,label:n,unit:a?.unit??O(n),insideBoundary:!0,focused:e===i,depth:r});continue}if(e.startsWith(`cause:`)){let n=e.slice(6),a=t.causeById.get(n),s=a?.kind===`cron`||a?.kind===`every`?`time`:a?.kind===`signal`?`messaging`:void 0;if(!s||!o[s])continue;u.push({id:e,kind:`resource`,label:a?.label??n,layer:s,insideBoundary:!0,focused:e===i,depth:r});continue}u.push({id:e,kind:C(e)?`external`:`resource`,label:w(e),layer:C(e)?`external`:e.startsWith(`signal:`)?`messaging`:`data`,insideBoundary:!C(e),focused:e===i,depth:r})}u.some(e=>e.id===i)||u.push(...R(t,i));let d=new Map,f=new Set(u.map(e=>e.id));for(let e of n){if(!V(e.layer,o))continue;let t=e.from,n=e.to;if(!f.has(t)||!f.has(n))continue;let i=`${t}\0${n}\0${e.layer}`,a=e.ref?E(r,e.flowId,e.ref):0,s=d.get(i);s?s.traversals+=a:d.set(i,{from:t,to:n,layer:e.layer,traversals:a,declared:!0})}return{nodes:U(u),edges:H(d,!1),boundaryCrossingCount:c,findings:s,focus:i,depth:a,layers:o}}function R(e,t){if(t.startsWith(`unit:`)){let n=t.slice(5);return[{id:t,kind:`unit`,label:n,unit:n,insideBoundary:!0,flowCount:e.flows.filter(e=>e.unit===n).length,focused:!0,depth:0}]}if(t.startsWith(`flow:`)){let n=t.slice(5);return[{id:t,kind:`flow`,label:n,unit:e.flowById.get(n)?.unit??O(n),insideBoundary:!0,focused:!0,depth:0}]}return[{id:t,kind:C(t)?`external`:`resource`,label:w(t),layer:C(t)?`external`:t.startsWith(`signal:`)?`messaging`:`data`,insideBoundary:!C(t),focused:!0,depth:0}]}function z(e,t,n,r){let i=new Set([n]);if(n.startsWith(`unit:`)){let t=n.slice(5);for(let n of e.flows)n.unit===t&&i.add(`flow:${n.id}`)}let a=new Set(i);for(let e=0;e<r;e++){let e=new Set;for(let n of t){let t=n.from,r=n.to;a.has(t)&&e.add(r),a.has(r)&&e.add(t);for(let n of[t,r]){if(!n.startsWith(`flow:`))continue;let t=`unit:${O(n.slice(5))}`;a.has(n)&&e.add(t),a.has(t)&&e.add(n)}}for(let t of e)i.add(t);a=e}return i}function B(e,t,n,r,i){if(n===r)return 0;let a=new Set([n]),o=new Set([n]);for(let n=1;n<=i;n++){let i=new Set;for(let e of t){let t=e.from,s=e.to;for(let[e,c]of[[t,s],[s,t]])if(o.has(e)){if(c===r)return n;a.has(c)||(a.add(c),i.add(c))}}for(let t of o){if(t.startsWith(`flow:`)){let e=`unit:${O(t.slice(5))}`;if(e===r)return n;a.has(e)||(a.add(e),i.add(e))}if(t.startsWith(`unit:`)){let o=t.slice(5);for(let t of e.flows){if(t.unit!==o)continue;let e=`flow:${t.id}`;if(e===r)return n;a.has(e)||(a.add(e),i.add(e))}}}o=i}return i}function V(e,t){return e===`call`||t[e]}function H(e,t){let n=Math.max(0,...[...e.values()].map(e=>e.traversals));return[...e.values()].map(e=>({id:`${e.from}->${e.to}:${e.layer}`,from:e.from,to:e.to,layer:e.layer,declared:e.declared,traversals:e.traversals,dashed:e.declared&&e.traversals===0,thickness:ue(e.traversals,n),aggregated:t})).sort((e,t)=>e.id.localeCompare(t.id))}function U(e){let t=new Map;for(let n of e)t.has(n.id)||t.set(n.id,n);return[...t.values()].sort((e,t)=>e.id.localeCompare(t.id))}function W(e){let t={...e.dimensions??{}};return t.flow===void 0&&(t.flow=e.flow),t.unit===void 0&&(t.unit=e.unit??null),t.trigger===void 0&&(t.trigger=e.trigger),t.plane===void 0&&(t.plane=e.plane),t.tenant===void 0&&(t.tenant=e.tenant??null),t.principal===void 0&&(t.principal=e.principal??null),t.cache===void 0&&(t.cache=e.cache??`none`),t.duration_ms===void 0&&(t.duration_ms=e.durationMs),t.error_code===void 0&&e.error&&(t.error_code=e.error),{id:e.id,parentId:e.parentId??null,flow:e.flow,unit:e.unit??null,trigger:e.trigger,plane:e.plane,tenant:e.tenant??null,principal:e.principal??null,gates:e.gates??[],cache:e.cache??`none`,replica:e.replica??null,replicaLagMs:e.replicaLagMs??null,cost:e.cost??null,promptVersion:e.promptVersion??null,buildVersion:e.buildVersion??null,startedAt:e.startedAt,endedAt:e.endedAt,durationMs:e.durationMs,error:e.error??null,effects:e.effects??[],logs:e.logs??[],dimensions:t}}function me(e){return{id:e.id,...e.parentId?{parentId:e.parentId}:{},flow:e.flow,...e.unit?{unit:e.unit}:{},trigger:e.trigger,plane:e.plane,tenant:e.tenant,principal:e.principal,gates:e.gates,cache:e.cache,...e.replica?{replica:e.replica}:{},...e.replicaLagMs==null?{}:{replicaLagMs:e.replicaLagMs},...e.cost==null?{}:{cost:e.cost},...e.promptVersion==null?{}:{promptVersion:e.promptVersion},...e.buildVersion?{buildVersion:e.buildVersion}:{},error:e.error?{code:e.error}:null,effects:e.effects,logs:e.logs,durationMs:e.durationMs,startedAt:e.startedAt,endedAt:e.endedAt,dimensions:{...e.dimensions}}}var G=e(s(),1),K={x:32,y:40,width:440,height:300};function he(e){let t=e.filter(e=>e.insideBoundary),n=e.filter(e=>!e.insideBoundary),r=new Map,i=Math.max(1,Math.ceil(Math.sqrt(t.length))),a=K.width/(i+1),o=Math.max(1,Math.ceil(t.length/i)),s=K.height/(o+1);return t.forEach((e,t)=>{let n=t%i,o=Math.floor(t/i);r.set(e.id,{id:e.id,x:K.x+a*(n+1),y:K.y+s*(o+1)})}),n.forEach((e,t)=>{r.set(e.id,{id:e.id,x:K.x+K.width+96,y:K.y+48+t*56})}),r}var q={read:`none`,write:`reversible`,emit:`deferred`,send:`irreversible`,ask:`irreversible`,secret:`capability`,call:`portal`};function ge(e){return q[e]}Object.entries(q).map(([e,t])=>({kind:e,reversibility:t}));function _e(e,t={}){if(!e)return[];let n=t.touchCounts,r=t.emitFanOut,i=[],a=(e,a,o)=>{for(let s of o??[])i.push({tier:e,kind:a,ref:s,reversibility:ge(a),touchCount:n?.get(s)??1,fanOut:a===`emit`?r?.get(s)??0:void 0,transitive:t.transitive})};return a(`reads`,`read`,e.reads),a(`writes`,`write`,e.writes),a(`emits`,`emit`,e.emits),a(`external`,`send`,e.sends),a(`external`,`ask`,e.asks),a(`capabilities`,`secret`,e.secrets),i}function J(e){return e?(e.sends?.length??0)>0||(e.asks?.length??0)>0?`external`:(e.secrets?.length??0)>0?`capabilities`:(e.emits?.length??0)>0?`emits`:(e.writes?.length??0)>0?`writes`:(e.reads?.length??0)>0?`reads`:`none`:`none`}function Y(e){return ve(J(e))}function ve(e){return e===`external`}var ye=[`reads`,`writes`,`emits`,`external`,`capabilities`],be={reads:`Reads`,writes:`Writes`,emits:`Emits`,external:`External`,capabilities:`Capabilities`};function xe(e){let t=e.indexOf(`.`);return t===-1?e:e.slice(0,t)}function Se(e){let t=e.indexOf(`.`);return t===-1?e:e.slice(t+1)}function Ce(e,t,n){let r=[];if(e?.http){let n=`http:${e.http.method}:${e.http.path}`;r.push({id:n,kind:`http`,label:`${e.http.method} ${e.http.path}`,flowIds:[t]})}if(e?.signal&&r.push({id:`signal:${e.signal}`,kind:`signal`,label:e.signal,flowIds:[t]}),e?.cron&&r.push({id:`cron:${e.cron}`,kind:`cron`,label:e.cron,flowIds:[t]}),e?.every&&r.push({id:`every:${e.every}`,kind:`every`,label:`every ${e.every}`,flowIds:[t]}),e?.cdc){let n=e.cdc.column?`.${e.cdc.column}`:``,i=`cdc:${e.cdc.table}${n}`;r.push({id:i,kind:`cdc`,label:`cdc ${e.cdc.table}${n}`,flowIds:[t]})}if(r.length===0)for(let e of n)r.push({id:`caller:${e}`,kind:`caller`,label:e,flowIds:[t]});return r}function X(e){if(!e)return[];let t=[];for(let n of e.reads??[])t.push(n);for(let n of e.writes??[])t.push(n);for(let n of e.emits??[])t.push(`signal:${n}`);for(let n of e.sends??[])t.push(`channel:${n}`);for(let n of e.asks??[])t.push(`ai:${n}`);for(let n of e.secrets??[])t.push(`secret:${n}`);for(let n of e.calls??[])t.push(`flow:${n}`);return t}function Z(e){return!e||typeof e==`string`?null:e}function we(e){return e.errors?Array.isArray(e.errors)?[...e.errors]:Object.keys(e.errors):[]}function Q(e){let t=e?.flows??{},n=Object.keys(t).sort(),r=new Map;for(let e of n){let n=t[e]?.effects?.calls??[];for(let t of n){let n=r.get(t)??[];n.push(e),r.set(t,n)}}let i=new Map;for(let e of n){let n=t[e]?.trigger?.signal;if(!n)continue;let r=i.get(n)??[];r.push(e),i.set(n,r)}let a=new Map,o=new Map,s=[];for(let e of n){let n=t[e];if(!n)continue;let c=r.get(e)??[],l=Ce(n.trigger,e,c);for(let t of l){let n=a.get(t.id);n?a.set(t.id,{...n,flowIds:[...new Set([...n.flowIds,e])]}):a.set(t.id,t)}let u=new Map,d=new Map;for(let e of n.effects?.emits??[])d.set(e,i.get(e)?.length??0);let f=_e(n.effects,{touchCounts:u,emitFanOut:d}),p=X(n.effects);for(let t of f){let n=t.kind===`emit`?`signal:${t.ref}`:t.kind===`send`?`channel:${t.ref}`:t.kind===`ask`?`ai:${t.ref}`:t.kind===`secret`?`secret:${t.ref}`:t.kind===`call`?`flow:${t.ref}`:t.ref,r=o.get(n);r?(r.flowIds.push(e),r.fanOut=Math.max(r.fanOut,t.fanOut??0)):o.set(n,{tier:t.tier,flowIds:[e],fanOut:t.fanOut??0})}s.push({id:e,unit:xe(e),action:Se(e),plane:n.plane??`user`,causeIds:l.map(e=>e.id),effectRefs:p,effects:f,peakTier:J(n.effects),external:Y(n.effects),flags:{durable:n.durable===!0,live:n.live===!0,cached:n.cache!==void 0&&n.cache!==!1,costsMoney:(n.cost?.estimatePerCall??0)>0,readsSecret:(n.effects?.secrets?.length??0)>0,touchesPii:n.pii!==void 0||n.allowPii===!0,external:Y(n.effects)},inSchema:Z(n.in),outSchema:Z(n.out),errorNames:we(n),source:n.source,deprecated:!!n.deprecated,raw:n})}if(e?.stores){for(let t of Object.values(e.stores))if(t.facet===`sql`&&t.tables)for(let e of Object.keys(t.tables)){let t=`sql:${e}`;o.has(t)||o.set(t,{tier:`reads`,flowIds:[],fanOut:0})}}if(e?.signals)for(let t of Object.keys(e.signals)){let e=`signal:${t}`;o.has(e)||o.set(e,{tier:`emits`,flowIds:[],fanOut:0})}if(e?.channels)for(let t of Object.keys(e.channels)){let e=`channel:${t}`;o.has(e)||o.set(e,{tier:`external`,flowIds:[],fanOut:0})}if(e?.vault)for(let t of Object.keys(e.vault)){let e=`secret:${t}`;o.has(e)||o.set(e,{tier:`capabilities`,flowIds:[],fanOut:0})}let c=[...a.values()].sort((e,t)=>e.label.localeCompare(t.label)),l=[...o.entries()].map(([e,t])=>({ref:e,tier:t.tier,flowIds:[...new Set(t.flowIds)].sort(),touchCount:new Set(t.flowIds).size,fanOut:t.fanOut})).sort((e,t)=>t.touchCount-e.touchCount||e.ref.localeCompare(t.ref));return{causes:c,flows:s,effects:l,causeById:new Map(c.map(e=>[e.id,e])),flowById:new Map(s.map(e=>[e.id,e])),effectByRef:new Map(l.map(e=>[e.ref,e]))}}function Te(e,t){let n=null;if(t.sel===`cause`&&t.cause){let r=e.causeById.get(t.cause);n=new Set(r?.flowIds??[])}else if(t.sel===`effect`&&t.effect){let r=e.effectByRef.get(t.effect);n=new Set(r?.flowIds??[])}else t.sel===`flow`&&t.flow&&(n=new Set([t.flow]));return e.flows.map(e=>{let r=n===null||n.has(e.id),i=Oe(e,t.q),a=!t.unit||e.unit===t.unit,o=r&&i&&a;return{...e,match:o,related:r}})}function Ee(e,t){let n=null;if(t.sel===`flow`&&t.flow){let r=e.flowById.get(t.flow);n=new Set(r?.causeIds??[])}else if(t.sel===`effect`&&t.effect){let r=e.effectByRef.get(t.effect),i=new Set;for(let t of r?.flowIds??[]){let n=e.flowById.get(t);for(let e of n?.causeIds??[])i.add(e)}n=i}return e.causes.map(e=>{let r=n===null||n.has(e.id),i=!t.q||e.label.toLowerCase().includes(t.q.toLowerCase())||e.id.toLowerCase().includes(t.q.toLowerCase());return{...e,match:r&&i,related:r}})}function De(e,t,n={}){let r=null;if(t.sel===`flow`&&t.flow){let n=e.flowById.get(t.flow);r=new Set(n?.effectRefs??[])}else if(t.sel===`cause`&&t.cause){let n=e.causeById.get(t.cause),i=new Set;for(let t of n?.flowIds??[]){let n=e.flowById.get(t);for(let e of n?.effectRefs??[])i.add(e)}r=i}let i=n.ubiquitousThreshold??8;return e.effects.map(e=>{let a=r===null||r.has(e.ref),o=!t.q||e.ref.toLowerCase().includes(t.q.toLowerCase()),s=!n.hideUbiquitous||e.touchCount<i||r!==null;return{...e,match:a&&o&&s,related:a}})}function Oe(e,t){if(!t?.trim())return!0;let n=t.toLowerCase();return e.id.toLowerCase().includes(n)||e.unit.toLowerCase().includes(n)||e.action.toLowerCase().includes(n)}var $=l();function ke(){let e=f({from:`/architecture`}),t=n({from:`/architecture`}),i=e=>{t({search:ne(e),replace:!0})},a=r({queryKey:[`console.manifest.get`],queryFn:async()=>{let e=await o.manifestGet();if(e.error)throw Error(e.error.code);return e.data.manifest}}),s=r({queryKey:[`console.runs.list`],queryFn:async()=>{let e=await o.runsList();if(e.error)throw Error(e.error.code);return e.data.runs.map(W)},refetchInterval:1e4}),l=(0,G.useMemo)(()=>Q(a.data),[a.data]),d=y(e),p=(0,G.useMemo)(()=>F(l,{focus:e.focus??null,depth:e.depth,layers:y(e),runs:s.data??[]}),[l,e.focus,e.depth,e.data,e.messaging,e.time,e.external,s.data]),m=(0,G.useMemo)(()=>he(p.nodes),[p.nodes]);return(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 flex-wrap items-end gap-4 border-b border-[var(--oke-line)] px-6 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`p`,{className:`text-xs uppercase tracking-[0.2em] text-[var(--oke-muted)]`,children:`Architecture`}),(0,$.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`System shape`}),(0,$.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Clustered by unit · typed layers · traffic from Runs`})]}),(0,$.jsxs)(`p`,{className:`ml-auto font-mono text-sm`,role:`status`,"aria-live":`polite`,children:[(0,$.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:`Boundary crossings`}),` `,(0,$.jsx)(`span`,{className:`text-lg font-semibold tabular-nums`,children:p.boundaryCrossingCount})]})]}),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-0 lg:flex-row`,children:[(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-4 border-b border-[var(--oke-line)] px-6 py-3`,children:[(0,$.jsxs)(`fieldset`,{className:`flex flex-wrap items-center gap-3`,children:[(0,$.jsx)(`legend`,{className:`sr-only`,children:`Element layers`}),(0,$.jsx)(`span`,{className:`text-xs uppercase tracking-[0.15em] text-[var(--oke-muted)]`,children:`Layers`}),h.map(t=>(0,$.jsxs)(`label`,{className:`inline-flex min-h-8 cursor-pointer items-center gap-2 text-sm`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:d[t],onChange:n=>i(x(e,t,n.target.checked)),"aria-label":`${g[t]} layer`}),g[t]]},t))]}),e.focus?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,$.jsxs)(`fieldset`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`legend`,{className:`sr-only`,children:`Focus depth`}),(0,$.jsx)(`span`,{className:`text-xs text-[var(--oke-muted)]`,children:`Depth`}),[1,2].map(t=>(0,$.jsxs)(`label`,{className:`inline-flex min-h-8 cursor-pointer items-center gap-1.5 text-sm`,children:[(0,$.jsx)(`input`,{type:`radio`,name:`arch-depth`,checked:e.depth===t,onChange:()=>i(ie(e,t))}),t]},t))]}),(0,$.jsx)(c,{type:`button`,variant:`ghost`,onClick:()=>i(re(e)),children:`Clear focus`})]}):(0,$.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Select a unit to focus at depth 1–2`})]}),(0,$.jsxs)(`section`,{"aria-label":`System diagram`,className:`min-h-0 flex-1 overflow-auto px-4 py-4`,children:[(0,$.jsx)(`div`,{"aria-hidden":`true`,className:`mb-4 overflow-x-auto`,children:(0,$.jsxs)(`svg`,{className:`h-auto w-full max-w-5xl text-[var(--oke-fg)]`,viewBox:`0 0 640 380`,children:[(0,$.jsx)(`rect`,{x:K.x,y:K.y,width:K.width,height:K.height,fill:`color-mix(in oklab, var(--oke-fg) 3%, transparent)`,stroke:`var(--oke-muted)`,strokeDasharray:`8 5`,strokeWidth:1.5,rx:4}),(0,$.jsxs)(`text`,{x:K.x+12,y:K.y+18,className:`fill-[var(--oke-muted)]`,fontSize:11,fontFamily:`var(--oke-mono)`,children:[`System boundary · `,p.boundaryCrossingCount,` crossings`]}),p.edges.map(e=>{let t=m.get(e.from),n=m.get(e.to);return!t||!n?null:(0,$.jsx)(`line`,{x1:t.x,y1:t.y,x2:n.x,y2:n.y,stroke:e.layer===`external`?`var(--oke-external)`:`var(--oke-muted)`,strokeWidth:e.thickness,strokeDasharray:e.dashed?`6 4`:void 0,opacity:e.dashed?.55:.9},e.id)}),p.nodes.map(e=>{let t=m.get(e.id);if(!t)return null;let n=e.kind===`unit`?28:22;return(0,$.jsxs)(`g`,{children:[(0,$.jsx)(`circle`,{cx:t.x,cy:t.y,r:n,fill:e.focused?`var(--oke-accent)`:e.insideBoundary?`var(--oke-bg)`:`color-mix(in oklab, var(--oke-external) 25%, var(--oke-bg))`,stroke:e.insideBoundary?`var(--oke-fg)`:`var(--oke-external)`,strokeWidth:e.focused?2.5:1.25}),(0,$.jsx)(`text`,{x:t.x,y:t.y+4,textAnchor:`middle`,fontSize:10,fontFamily:`var(--oke-mono)`,className:`fill-[var(--oke-fg)]`,children:Ae(e.label,12)})]},e.id)})]})}),(0,$.jsx)(`ul`,{"aria-label":`Nodes`,className:`flex flex-wrap gap-2 border-t border-[var(--oke-line)] pt-4`,children:p.nodes.map(t=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":t.focused===!0,className:u(`inline-flex min-h-8 items-center gap-2 border px-3 text-sm`,t.focused?`border-[var(--oke-accent)] text-[var(--oke-fg)]`:`border-[var(--oke-line)] text-[var(--oke-muted)]`),onClick:()=>i(b(e,t.id)),children:[(0,$.jsx)(`span`,{children:t.label}),t.kind===`unit`&&t.flowCount!==void 0?(0,$.jsx)(`span`,{className:`font-mono text-xs`,children:t.flowCount}):null,t.insideBoundary?null:(0,$.jsx)(`span`,{className:`text-xs text-[var(--oke-external)]`,children:`external`})]})},t.id))}),(0,$.jsx)(`ul`,{className:`sr-only`,"aria-label":`Edges`,children:p.edges.map(e=>(0,$.jsxs)(`li`,{children:[e.from,` → `,e.to,e.dashed?` (declared, never traversed)`:` · ${e.traversals} traversals`,` · ${e.layer}`]},e.id))})]})]}),(0,$.jsxs)(`aside`,{"aria-label":`Findings`,className:`w-full shrink-0 overflow-auto border-t border-[var(--oke-line)] lg:w-80 lg:border-l lg:border-t-0`,children:[(0,$.jsxs)(`div`,{className:`px-5 py-4`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-medium`,children:`Findings`}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-[var(--oke-muted)]`,children:`Pathologies from the graph as data`})]}),p.findings.length===0?(0,$.jsx)(`p`,{className:`px-5 pb-4 text-sm text-[var(--oke-muted)]`,children:`No pathologies detected.`}):(0,$.jsx)(`ul`,{className:`divide-y divide-[var(--oke-line)] border-t border-[var(--oke-line)]`,children:p.findings.map((t,n)=>(0,$.jsxs)(`li`,{className:`px-5 py-3`,children:[(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,$.jsx)(`span`,{className:u(`inline-block size-1.5 rounded-full`,t.severity===`critical`?`bg-[var(--oke-danger)]`:`bg-[var(--oke-external)]`),"aria-hidden":!0}),t.title]}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-[var(--oke-muted)]`,children:t.detail}),t.nodeIds[0]?(0,$.jsx)(`button`,{type:`button`,className:`mt-2 min-h-8 text-sm text-[var(--oke-accent)] underline-offset-2 hover:underline`,onClick:()=>i(b(e,t.nodeIds[0])),children:`Focus`}):null]},`${t.kind}-${n}`))})]})]})]})}function Ae(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}var je=t({default:()=>ke});export{De as a,W as c,te as d,Ee as i,me as l,Q as n,be as o,Te as r,ye as s,je as t,A as u};
1
+ import{a as e,r as t}from"./rolldown-runtime-B0Z9INg1.js";import{C as n,Q as r,_ as i,b as a,d as o,nt as s,o as c,tt as l,u,v as d,w as f,x as p,y as m}from"./panel-access-BGv45snf.js";var h=[`data`,`messaging`,`time`,`external`],g={data:`Data`,messaging:`Messaging`,time:`Time`,external:`External`},_={data:!0,messaging:!0,time:!0,external:!0},v=p([i(),d(`true`),d(`false`)]).transform(e=>e===!0||e===`true`),ee=m({focus:a().optional(),depth:p([d(1),d(2),d(`1`),d(`2`)]).transform(e=>Number(e)===2?2:1).default(1),data:v.optional(),messaging:v.optional(),time:v.optional(),external:v.optional()});function te(e){let t=ee.safeParse(e);return t.success?t.data:{depth:1}}function ne(e){let t={};e.focus&&(t.focus=e.focus),e.depth===2&&(t.depth=`2`);for(let n of h)e[n]===!1&&(t[n]=`false`);return t}function y(e){return{data:e.data??_.data,messaging:e.messaging??_.messaging,time:e.time??_.time,external:e.external??_.external}}function b(e,t){return{...e,focus:t}}function re(e){let{focus:t,...n}=e;return{...n,depth:e.depth}}function ie(e,t){return{...e,depth:t}}function x(e,t,n){return{...e,[t]:n}}function S(e){return e.startsWith(`sql:`)||e.startsWith(`kv:`)||e.startsWith(`files:`)||e.startsWith(`index:`)?`data`:e.startsWith(`signal:`)?`messaging`:e.startsWith(`channel:`)||e.startsWith(`ai:`)?`external`:null}function ae(e){return e.kind===`signal`?`messaging`:e.kind===`cron`||e.kind===`every`?`time`:null}function C(e){return e.startsWith(`channel:`)||e.startsWith(`ai:`)}function w(e){let t=e.indexOf(`:`);return t===-1?e:e.slice(t+1)}function oe(e){let t=new Set;for(let n of e.flows)for(let e of n.effectRefs)C(e)&&t.add(e);return t.size}function se(e){let t=new Set;for(let n of e.flows)for(let e of n.effectRefs)C(e)&&t.add(e);return[...t].sort()}function ce(e,t){switch(e){case`emit`:return t.startsWith(`signal:`)?t:`signal:${t}`;case`send`:return t.startsWith(`channel:`)?t:`channel:${t}`;case`ask`:return t.startsWith(`ai:`)?t:`ai:${t}`;case`secret`:return t.startsWith(`secret:`)?t:`secret:${t}`;case`call`:return t.startsWith(`flow:`)?t:`flow:${t}`;default:return t}}function T(e,t){return`${e}\0${t}`}function le(e){let t=new Map;for(let n of e){for(let e of n.effects){let r=ce(e.kind,e.resource),i=T(n.flow,r);t.set(i,(t.get(i)??0)+1)}n.parentId}return t}function E(e,t,n){return e.get(T(t,n))??0}function ue(e,t){if(e<=0)return 1;if(t<=1)return 2;let n=e/t;return Math.max(1,Math.min(8,Math.ceil(n*8)))}function D(e){let t=[],n=pe(e);for(let r of e.flows){for(let n of r.causeIds){let i=e.causeById.get(n);if(!i)continue;let a=ae(i);a&&t.push({from:`cause:${i.id}`,to:`flow:${r.id}`,flowId:r.id,layer:a,fromUnit:r.unit,toUnit:r.unit})}for(let i of r.effectRefs){if(i.startsWith(`flow:`)){let e=i.slice(5),n=O(e);t.push({from:`flow:${r.id}`,to:`flow:${e}`,flowId:r.id,ref:i,layer:`call`,fromUnit:r.unit,toUnit:n});continue}let a=S(i);if(!a)continue;let o=C(i)?`external`:de(i,e);if(t.push({from:`flow:${r.id}`,to:i,flowId:r.id,ref:i,layer:a,fromUnit:r.unit,toUnit:o}),a===`messaging`&&i.startsWith(`signal:`)){let a=i.slice(7);for(let o of n.get(a)??[]){let n=e.flowById.get(o);!n||n.id===r.id||t.push({from:`flow:${r.id}`,to:`flow:${n.id}`,flowId:r.id,ref:i,layer:`messaging`,fromUnit:r.unit,toUnit:n.unit})}}}}return t}function de(e,t){let n=t.effectByRef.get(e);if(!n||n.flowIds.length===0)return`shared`;let r=n.flowIds.filter(n=>{let r=t.flowById.get(n);return r?fe(r,e):!1})[0]??n.flowIds[0];return r?O(r):`shared`}function fe(e,t){let n=e.raw.effects;if(!n)return!1;if(t.startsWith(`signal:`)){let e=t.slice(7);return(n.emits??[]).includes(e)}return!!(n.writes??[]).includes(t)}function pe(e){let t=new Map;for(let n of e.flows){let e=n.raw.trigger?.signal;if(!e)continue;let r=t.get(e)??[];r.push(n.id),t.set(e,r)}return t}function O(e){let t=e.indexOf(`.`);return t===-1?e:e.slice(0,t)}function k(e){let t=[];return t.push(...A(e)),t.push(...j(e)),t.push(...M(e)),t.push(...N(e)),t}function A(e){let t=new Map,n=e=>{let n=t.get(e);return n||(n=new Set,t.set(e,n)),n};for(let t of D(e)){if(!t.from.startsWith(`flow:`)||!t.to.startsWith(`flow:`))continue;let e=t.from.slice(5),r=t.to.slice(5);n(e).add(r)}let r=[],i=new Set,a=[],o=new Set,s=e=>{i.add(e),a.push(e),o.add(e);for(let n of t.get(e)??[])if(!i.has(n))s(n);else if(o.has(n)){let e=a.indexOf(n);e!==-1&&r.push([...a.slice(e),n])}a.pop(),o.delete(e)};for(let t of e.flows.map(e=>e.id))i.has(t)||s(t);let c=new Set,l=[];for(let e of r){let t=P(e.slice(0,-1)),n=t.join(`→`);c.has(n)||(c.add(n),l.push({kind:`cycle`,severity:`critical`,title:`Cycle`,detail:`Causal cycle: ${t.join(` → `)}`,nodeIds:t.map(e=>`flow:${e}`)}))}return l}function j(e){if(e.effects.length===0)return[];let t=[...e.effects].filter(e=>e.touchCount>0).sort((e,t)=>t.touchCount-e.touchCount||e.ref.localeCompare(t.ref)),n=t[0];if(!n||n.touchCount<2)return[];let r=t[1]?.touchCount??0;return n.touchCount===r&&t.filter(e=>e.touchCount===n.touchCount).length>1?t.filter(e=>e.touchCount===n.touchCount).map(e=>({kind:`god-node`,severity:`warning`,title:`God node`,detail:`${e.ref} is touched by ${e.touchCount} flows — the most in the system`,nodeIds:[e.ref]})):[{kind:`god-node`,severity:`warning`,title:`God node`,detail:`${n.ref} is touched by ${n.touchCount} flows — the most in the system`,nodeIds:[n.ref]}]}function M(e){let t=[],n=new Set;for(let t of e.effects)t.ref.startsWith(`signal:`)&&n.add(t.ref.slice(7));for(let t of e.flows){for(let e of t.raw.effects?.emits??[])n.add(e);let e=t.raw.trigger?.signal;e&&n.add(e)}for(let r of[...n].sort()){let n=`signal:${r}`,i=e.flows.filter(e=>(e.raw.effects?.emits??[]).includes(r)),a=e.flows.filter(e=>e.raw.trigger?.signal===r);if(i.length===0&&a.length===0){t.push({kind:`orphan-signal`,severity:`warning`,title:`Orphan signal`,detail:`${r} is declared but has no producers and no consumers`,nodeIds:[n]});continue}if(i.length===0){t.push({kind:`orphan-signal`,severity:`warning`,title:`Orphan signal`,detail:`${r} has consumers but no producer`,nodeIds:[n,...a.map(e=>`flow:${e.id}`)]});continue}a.length===0&&t.push({kind:`orphan-signal`,severity:`warning`,title:`Orphan signal`,detail:`${r} is emitted but has no consumers`,nodeIds:[n,...i.map(e=>`flow:${e.id}`)]})}return t}function N(e){let t=[];for(let n of e.effects){if(n.touchCount<2||n.ref.startsWith(`secret:`)||n.ref.startsWith(`channel:`)||n.ref.startsWith(`ai:`))continue;let r=n.flowIds.filter(t=>{let r=e.flowById.get(t);if(!r?.raw.effects)return!1;if(n.ref.startsWith(`signal:`)){let e=n.ref.slice(7);return(r.raw.effects.emits??[]).includes(e)}return(r.raw.effects.writes??[]).includes(n.ref)});if(r.length!==1)continue;let i=r[0];t.push({kind:`spof`,severity:`critical`,title:`Single point of failure`,detail:`${n.ref} is touched by ${n.touchCount} flows but written/emitted by only ${i}`,nodeIds:[n.ref,`flow:${i}`]})}return t}function P(e){if(e.length===0)return[];let t=[...e],n=t.join(`\0`);for(let r=1;r<e.length;r++){let i=[...e.slice(r),...e.slice(0,r)],a=i.join(`\0`);a<n&&(t=i,n=a)}return t}function F(e,t={}){let n=t.focus??null,r=t.depth===2?2:1,i=t.layers??_,a=le(t.runs??[]),o=D(e),s=k(e),c=oe(e);return n?L({graph:e,declared:o,traffic:a,focus:n,depth:r,layers:i,findings:s,crossings:c}):I({graph:e,declared:o,traffic:a,layers:i,findings:s,crossings:c})}function I(e){let{graph:t,declared:n,traffic:r,layers:i,findings:a,crossings:o}=e,s=[...new Set(t.flows.map(e=>e.unit))].sort().map(e=>({id:`unit:${e}`,kind:`unit`,label:e,unit:e,insideBoundary:!0,flowCount:t.flows.filter(t=>t.unit===e).length}));for(let e of se(t))s.push({id:e,kind:`external`,label:w(e),layer:`external`,insideBoundary:!1});let c=new Map;for(let e of n){if(!V(e.layer,i))continue;let t=`unit:${e.fromUnit}`,n=null;if(e.toUnit===`external`||C(e.to))n=e.ref??e.to;else if(e.fromUnit!==e.toUnit)n=`unit:${e.toUnit}`;else continue;if(t===n)continue;let a=`${t}\0${n}\0${e.layer}`,o=e.ref?E(r,e.flowId,e.ref):0,s=c.get(a);s?s.traversals+=o:c.set(a,{from:t,to:n,layer:e.layer,traversals:o,declared:!0})}let l=H(c,!0);return{nodes:U(s),edges:l,boundaryCrossingCount:o,findings:a,focus:null,depth:1,layers:i}}function L(e){let{graph:t,declared:n,traffic:r,focus:i,depth:a,layers:o,findings:s,crossings:c}=e,l=z(t,n,i,a),u=[];for(let e of l){let r=B(t,n,i,e,a);if(e.startsWith(`unit:`)){let n=e.slice(5);u.push({id:e,kind:`unit`,label:n,unit:n,insideBoundary:!0,flowCount:t.flows.filter(e=>e.unit===n).length,focused:e===i,depth:r});continue}if(e.startsWith(`flow:`)){let n=e.slice(5),a=t.flowById.get(n);u.push({id:e,kind:`flow`,label:n,unit:a?.unit??O(n),insideBoundary:!0,focused:e===i,depth:r});continue}if(e.startsWith(`cause:`)){let n=e.slice(6),a=t.causeById.get(n),s=a?.kind===`cron`||a?.kind===`every`?`time`:a?.kind===`signal`?`messaging`:void 0;if(!s||!o[s])continue;u.push({id:e,kind:`resource`,label:a?.label??n,layer:s,insideBoundary:!0,focused:e===i,depth:r});continue}u.push({id:e,kind:C(e)?`external`:`resource`,label:w(e),layer:C(e)?`external`:e.startsWith(`signal:`)?`messaging`:`data`,insideBoundary:!C(e),focused:e===i,depth:r})}u.some(e=>e.id===i)||u.push(...R(t,i));let d=new Map,f=new Set(u.map(e=>e.id));for(let e of n){if(!V(e.layer,o))continue;let t=e.from,n=e.to;if(!f.has(t)||!f.has(n))continue;let i=`${t}\0${n}\0${e.layer}`,a=e.ref?E(r,e.flowId,e.ref):0,s=d.get(i);s?s.traversals+=a:d.set(i,{from:t,to:n,layer:e.layer,traversals:a,declared:!0})}return{nodes:U(u),edges:H(d,!1),boundaryCrossingCount:c,findings:s,focus:i,depth:a,layers:o}}function R(e,t){if(t.startsWith(`unit:`)){let n=t.slice(5);return[{id:t,kind:`unit`,label:n,unit:n,insideBoundary:!0,flowCount:e.flows.filter(e=>e.unit===n).length,focused:!0,depth:0}]}if(t.startsWith(`flow:`)){let n=t.slice(5);return[{id:t,kind:`flow`,label:n,unit:e.flowById.get(n)?.unit??O(n),insideBoundary:!0,focused:!0,depth:0}]}return[{id:t,kind:C(t)?`external`:`resource`,label:w(t),layer:C(t)?`external`:t.startsWith(`signal:`)?`messaging`:`data`,insideBoundary:!C(t),focused:!0,depth:0}]}function z(e,t,n,r){let i=new Set([n]);if(n.startsWith(`unit:`)){let t=n.slice(5);for(let n of e.flows)n.unit===t&&i.add(`flow:${n.id}`)}let a=new Set(i);for(let e=0;e<r;e++){let e=new Set;for(let n of t){let t=n.from,r=n.to;a.has(t)&&e.add(r),a.has(r)&&e.add(t);for(let n of[t,r]){if(!n.startsWith(`flow:`))continue;let t=`unit:${O(n.slice(5))}`;a.has(n)&&e.add(t),a.has(t)&&e.add(n)}}for(let t of e)i.add(t);a=e}return i}function B(e,t,n,r,i){if(n===r)return 0;let a=new Set([n]),o=new Set([n]);for(let n=1;n<=i;n++){let i=new Set;for(let e of t){let t=e.from,s=e.to;for(let[e,c]of[[t,s],[s,t]])if(o.has(e)){if(c===r)return n;a.has(c)||(a.add(c),i.add(c))}}for(let t of o){if(t.startsWith(`flow:`)){let e=`unit:${O(t.slice(5))}`;if(e===r)return n;a.has(e)||(a.add(e),i.add(e))}if(t.startsWith(`unit:`)){let o=t.slice(5);for(let t of e.flows){if(t.unit!==o)continue;let e=`flow:${t.id}`;if(e===r)return n;a.has(e)||(a.add(e),i.add(e))}}}o=i}return i}function V(e,t){return e===`call`||t[e]}function H(e,t){let n=Math.max(0,...[...e.values()].map(e=>e.traversals));return[...e.values()].map(e=>({id:`${e.from}->${e.to}:${e.layer}`,from:e.from,to:e.to,layer:e.layer,declared:e.declared,traversals:e.traversals,dashed:e.declared&&e.traversals===0,thickness:ue(e.traversals,n),aggregated:t})).sort((e,t)=>e.id.localeCompare(t.id))}function U(e){let t=new Map;for(let n of e)t.has(n.id)||t.set(n.id,n);return[...t.values()].sort((e,t)=>e.id.localeCompare(t.id))}function W(e){let t={...e.dimensions??{}};return t.flow===void 0&&(t.flow=e.flow),t.unit===void 0&&(t.unit=e.unit??null),t.trigger===void 0&&(t.trigger=e.trigger),t.plane===void 0&&(t.plane=e.plane),t.tenant===void 0&&(t.tenant=e.tenant??null),t.principal===void 0&&(t.principal=e.principal??null),t.cache===void 0&&(t.cache=e.cache??`none`),t.duration_ms===void 0&&(t.duration_ms=e.durationMs),t.error_code===void 0&&e.error&&(t.error_code=e.error),{id:e.id,parentId:e.parentId??null,flow:e.flow,unit:e.unit??null,trigger:e.trigger,plane:e.plane,tenant:e.tenant??null,principal:e.principal??null,gates:e.gates??[],cache:e.cache??`none`,replica:e.replica??null,replicaLagMs:e.replicaLagMs??null,cost:e.cost??null,promptVersion:e.promptVersion??null,buildVersion:e.buildVersion??null,startedAt:e.startedAt,endedAt:e.endedAt,durationMs:e.durationMs,error:e.error??null,effects:e.effects??[],logs:e.logs??[],dimensions:t}}function me(e){return{id:e.id,...e.parentId?{parentId:e.parentId}:{},flow:e.flow,...e.unit?{unit:e.unit}:{},trigger:e.trigger,plane:e.plane,tenant:e.tenant,principal:e.principal,gates:e.gates,cache:e.cache,...e.replica?{replica:e.replica}:{},...e.replicaLagMs==null?{}:{replicaLagMs:e.replicaLagMs},...e.cost==null?{}:{cost:e.cost},...e.promptVersion==null?{}:{promptVersion:e.promptVersion},...e.buildVersion?{buildVersion:e.buildVersion}:{},error:e.error?{code:e.error}:null,effects:e.effects,logs:e.logs,durationMs:e.durationMs,startedAt:e.startedAt,endedAt:e.endedAt,dimensions:{...e.dimensions}}}var G=e(s(),1),K={x:32,y:40,width:440,height:300};function he(e){let t=e.filter(e=>e.insideBoundary),n=e.filter(e=>!e.insideBoundary),r=new Map,i=Math.max(1,Math.ceil(Math.sqrt(t.length))),a=K.width/(i+1),o=Math.max(1,Math.ceil(t.length/i)),s=K.height/(o+1);return t.forEach((e,t)=>{let n=t%i,o=Math.floor(t/i);r.set(e.id,{id:e.id,x:K.x+a*(n+1),y:K.y+s*(o+1)})}),n.forEach((e,t)=>{r.set(e.id,{id:e.id,x:K.x+K.width+96,y:K.y+48+t*56})}),r}var q={read:`none`,write:`reversible`,emit:`deferred`,send:`irreversible`,ask:`irreversible`,secret:`capability`,call:`portal`};function ge(e){return q[e]}Object.entries(q).map(([e,t])=>({kind:e,reversibility:t}));function _e(e,t={}){if(!e)return[];let n=t.touchCounts,r=t.emitFanOut,i=[],a=(e,a,o)=>{for(let s of o??[])i.push({tier:e,kind:a,ref:s,reversibility:ge(a),touchCount:n?.get(s)??1,fanOut:a===`emit`?r?.get(s)??0:void 0,transitive:t.transitive})};return a(`reads`,`read`,e.reads),a(`writes`,`write`,e.writes),a(`emits`,`emit`,e.emits),a(`external`,`send`,e.sends),a(`external`,`ask`,e.asks),a(`capabilities`,`secret`,e.secrets),i}function J(e){return e?(e.sends?.length??0)>0||(e.asks?.length??0)>0?`external`:(e.secrets?.length??0)>0?`capabilities`:(e.emits?.length??0)>0?`emits`:(e.writes?.length??0)>0?`writes`:(e.reads?.length??0)>0?`reads`:`none`:`none`}function Y(e){return ve(J(e))}function ve(e){return e===`external`}var ye=[`reads`,`writes`,`emits`,`external`,`capabilities`],be={reads:`Reads`,writes:`Writes`,emits:`Emits`,external:`External`,capabilities:`Capabilities`};function xe(e){let t=e.indexOf(`.`);return t===-1?e:e.slice(0,t)}function Se(e){let t=e.indexOf(`.`);return t===-1?e:e.slice(t+1)}function Ce(e,t,n){let r=[];if(e?.http){let n=`http:${e.http.method}:${e.http.path}`;r.push({id:n,kind:`http`,label:`${e.http.method} ${e.http.path}`,flowIds:[t]})}if(e?.signal&&r.push({id:`signal:${e.signal}`,kind:`signal`,label:e.signal,flowIds:[t]}),e?.cron&&r.push({id:`cron:${e.cron}`,kind:`cron`,label:e.cron,flowIds:[t]}),e?.every&&r.push({id:`every:${e.every}`,kind:`every`,label:`every ${e.every}`,flowIds:[t]}),e?.cdc){let n=e.cdc.column?`.${e.cdc.column}`:``,i=`cdc:${e.cdc.table}${n}`;r.push({id:i,kind:`cdc`,label:`cdc ${e.cdc.table}${n}`,flowIds:[t]})}if(r.length===0)for(let e of n)r.push({id:`caller:${e}`,kind:`caller`,label:e,flowIds:[t]});return r}function X(e){if(!e)return[];let t=[];for(let n of e.reads??[])t.push(n);for(let n of e.writes??[])t.push(n);for(let n of e.emits??[])t.push(`signal:${n}`);for(let n of e.sends??[])t.push(`channel:${n}`);for(let n of e.asks??[])t.push(`ai:${n}`);for(let n of e.secrets??[])t.push(`secret:${n}`);for(let n of e.calls??[])t.push(`flow:${n}`);return t}function Z(e){return!e||typeof e==`string`?null:e}function we(e){return e.errors?Array.isArray(e.errors)?[...e.errors]:Object.keys(e.errors):[]}function Q(e){let t=e?.flows??{},n=Object.keys(t).sort(),r=new Map;for(let e of n){let n=t[e]?.effects?.calls??[];for(let t of n){let n=r.get(t)??[];n.push(e),r.set(t,n)}}let i=new Map;for(let e of n){let n=t[e]?.trigger?.signal;if(!n)continue;let r=i.get(n)??[];r.push(e),i.set(n,r)}let a=new Map,o=new Map,s=[];for(let e of n){let n=t[e];if(!n)continue;let c=r.get(e)??[],l=Ce(n.trigger,e,c);for(let t of l){let n=a.get(t.id);n?a.set(t.id,{...n,flowIds:[...new Set([...n.flowIds,e])]}):a.set(t.id,t)}let u=new Map,d=new Map;for(let e of n.effects?.emits??[])d.set(e,i.get(e)?.length??0);let f=_e(n.effects,{touchCounts:u,emitFanOut:d}),p=X(n.effects);for(let t of f){let n=t.kind===`emit`?`signal:${t.ref}`:t.kind===`send`?`channel:${t.ref}`:t.kind===`ask`?`ai:${t.ref}`:t.kind===`secret`?`secret:${t.ref}`:t.kind===`call`?`flow:${t.ref}`:t.ref,r=o.get(n);r?(r.flowIds.push(e),r.fanOut=Math.max(r.fanOut,t.fanOut??0)):o.set(n,{tier:t.tier,flowIds:[e],fanOut:t.fanOut??0})}s.push({id:e,unit:xe(e),action:Se(e),plane:n.plane??`user`,causeIds:l.map(e=>e.id),effectRefs:p,effects:f,peakTier:J(n.effects),external:Y(n.effects),flags:{durable:n.durable===!0,live:n.live===!0,cached:n.cache!==void 0&&n.cache!==!1,costsMoney:(n.cost?.estimatePerCall??0)>0,readsSecret:(n.effects?.secrets?.length??0)>0,touchesPii:n.pii!==void 0||n.allowPii===!0,external:Y(n.effects)},inSchema:Z(n.in),outSchema:Z(n.out),errorNames:we(n),source:n.source,deprecated:!!n.deprecated,raw:n})}if(e?.stores){for(let t of Object.values(e.stores))if(t.facet===`sql`&&t.tables)for(let e of Object.keys(t.tables)){let t=`sql:${e}`;o.has(t)||o.set(t,{tier:`reads`,flowIds:[],fanOut:0})}}if(e?.signals)for(let t of Object.keys(e.signals)){let e=`signal:${t}`;o.has(e)||o.set(e,{tier:`emits`,flowIds:[],fanOut:0})}if(e?.channels)for(let t of Object.keys(e.channels)){let e=`channel:${t}`;o.has(e)||o.set(e,{tier:`external`,flowIds:[],fanOut:0})}if(e?.vault)for(let t of Object.keys(e.vault)){let e=`secret:${t}`;o.has(e)||o.set(e,{tier:`capabilities`,flowIds:[],fanOut:0})}let c=[...a.values()].sort((e,t)=>e.label.localeCompare(t.label)),l=[...o.entries()].map(([e,t])=>({ref:e,tier:t.tier,flowIds:[...new Set(t.flowIds)].sort(),touchCount:new Set(t.flowIds).size,fanOut:t.fanOut})).sort((e,t)=>t.touchCount-e.touchCount||e.ref.localeCompare(t.ref));return{causes:c,flows:s,effects:l,causeById:new Map(c.map(e=>[e.id,e])),flowById:new Map(s.map(e=>[e.id,e])),effectByRef:new Map(l.map(e=>[e.ref,e]))}}function Te(e,t){let n=null;if(t.sel===`cause`&&t.cause){let r=e.causeById.get(t.cause);n=new Set(r?.flowIds??[])}else if(t.sel===`effect`&&t.effect){let r=e.effectByRef.get(t.effect);n=new Set(r?.flowIds??[])}else t.sel===`flow`&&t.flow&&(n=new Set([t.flow]));return e.flows.map(e=>{let r=n===null||n.has(e.id),i=Oe(e,t.q),a=!t.unit||e.unit===t.unit,o=r&&i&&a;return{...e,match:o,related:r}})}function Ee(e,t){let n=null;if(t.sel===`flow`&&t.flow){let r=e.flowById.get(t.flow);n=new Set(r?.causeIds??[])}else if(t.sel===`effect`&&t.effect){let r=e.effectByRef.get(t.effect),i=new Set;for(let t of r?.flowIds??[]){let n=e.flowById.get(t);for(let e of n?.causeIds??[])i.add(e)}n=i}return e.causes.map(e=>{let r=n===null||n.has(e.id),i=!t.q||e.label.toLowerCase().includes(t.q.toLowerCase())||e.id.toLowerCase().includes(t.q.toLowerCase());return{...e,match:r&&i,related:r}})}function De(e,t,n={}){let r=null;if(t.sel===`flow`&&t.flow){let n=e.flowById.get(t.flow);r=new Set(n?.effectRefs??[])}else if(t.sel===`cause`&&t.cause){let n=e.causeById.get(t.cause),i=new Set;for(let t of n?.flowIds??[]){let n=e.flowById.get(t);for(let e of n?.effectRefs??[])i.add(e)}r=i}let i=n.ubiquitousThreshold??8;return e.effects.map(e=>{let a=r===null||r.has(e.ref),o=!t.q||e.ref.toLowerCase().includes(t.q.toLowerCase()),s=!n.hideUbiquitous||e.touchCount<i||r!==null;return{...e,match:a&&o&&s,related:a}})}function Oe(e,t){if(!t?.trim())return!0;let n=t.toLowerCase();return e.id.toLowerCase().includes(n)||e.unit.toLowerCase().includes(n)||e.action.toLowerCase().includes(n)}var $=l();function ke(){let e=f({from:`/architecture`}),t=n({from:`/architecture`}),i=e=>{t({search:ne(e),replace:!0})},a=r({queryKey:[`console.manifest.get`],queryFn:async()=>{let e=await o.manifestGet();if(e.error)throw Error(e.error.code);return e.data.manifest}}),s=r({queryKey:[`console.runs.list`],queryFn:async()=>{let e=await o.runsList();if(e.error)throw Error(e.error.code);return e.data.runs.map(W)},refetchInterval:1e4}),l=(0,G.useMemo)(()=>Q(a.data),[a.data]),d=y(e),p=(0,G.useMemo)(()=>F(l,{focus:e.focus??null,depth:e.depth,layers:y(e),runs:s.data??[]}),[l,e.focus,e.depth,e.data,e.messaging,e.time,e.external,s.data]),m=(0,G.useMemo)(()=>he(p.nodes),[p.nodes]);return(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 flex-wrap items-end gap-4 border-b border-[var(--oke-line)] px-6 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`p`,{className:`text-xs uppercase tracking-[0.2em] text-[var(--oke-muted)]`,children:`Architecture`}),(0,$.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`System shape`}),(0,$.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Clustered by unit · typed layers · traffic from Runs`})]}),(0,$.jsxs)(`p`,{className:`ml-auto font-mono text-sm`,role:`status`,"aria-live":`polite`,children:[(0,$.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:`Boundary crossings`}),` `,(0,$.jsx)(`span`,{className:`text-lg font-semibold tabular-nums`,children:p.boundaryCrossingCount})]})]}),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-0 lg:flex-row`,children:[(0,$.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-4 border-b border-[var(--oke-line)] px-6 py-3`,children:[(0,$.jsxs)(`fieldset`,{className:`flex flex-wrap items-center gap-3`,children:[(0,$.jsx)(`legend`,{className:`sr-only`,children:`Element layers`}),(0,$.jsx)(`span`,{className:`text-xs uppercase tracking-[0.15em] text-[var(--oke-muted)]`,children:`Layers`}),h.map(t=>(0,$.jsxs)(`label`,{className:`inline-flex min-h-8 cursor-pointer items-center gap-2 text-sm`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:d[t],onChange:n=>i(x(e,t,n.target.checked)),"aria-label":`${g[t]} layer`}),g[t]]},t))]}),e.focus?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,$.jsxs)(`fieldset`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`legend`,{className:`sr-only`,children:`Focus depth`}),(0,$.jsx)(`span`,{className:`text-xs text-[var(--oke-muted)]`,children:`Depth`}),[1,2].map(t=>(0,$.jsxs)(`label`,{className:`inline-flex min-h-8 cursor-pointer items-center gap-1.5 text-sm`,children:[(0,$.jsx)(`input`,{type:`radio`,name:`arch-depth`,checked:e.depth===t,onChange:()=>i(ie(e,t))}),t]},t))]}),(0,$.jsx)(c,{type:`button`,variant:`ghost`,onClick:()=>i(re(e)),children:`Clear focus`})]}):(0,$.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Select a unit to focus at depth 1–2`})]}),(0,$.jsxs)(`section`,{"aria-label":`System diagram`,className:`min-h-0 flex-1 overflow-auto px-4 py-4`,children:[(0,$.jsx)(`div`,{"aria-hidden":`true`,className:`mb-4 overflow-x-auto`,children:(0,$.jsxs)(`svg`,{className:`h-auto w-full max-w-5xl text-[var(--oke-fg)]`,viewBox:`0 0 640 380`,children:[(0,$.jsx)(`rect`,{x:K.x,y:K.y,width:K.width,height:K.height,fill:`color-mix(in oklab, var(--oke-fg) 3%, transparent)`,stroke:`var(--oke-muted)`,strokeDasharray:`8 5`,strokeWidth:1.5,rx:4}),(0,$.jsxs)(`text`,{x:K.x+12,y:K.y+18,className:`fill-[var(--oke-muted)]`,fontSize:11,fontFamily:`var(--oke-mono)`,children:[`System boundary · `,p.boundaryCrossingCount,` crossings`]}),p.edges.map(e=>{let t=m.get(e.from),n=m.get(e.to);return!t||!n?null:(0,$.jsx)(`line`,{x1:t.x,y1:t.y,x2:n.x,y2:n.y,stroke:e.layer===`external`?`var(--oke-external)`:`var(--oke-muted)`,strokeWidth:e.thickness,strokeDasharray:e.dashed?`6 4`:void 0,opacity:e.dashed?.55:.9},e.id)}),p.nodes.map(e=>{let t=m.get(e.id);if(!t)return null;let n=e.kind===`unit`?28:22;return(0,$.jsxs)(`g`,{children:[(0,$.jsx)(`circle`,{cx:t.x,cy:t.y,r:n,fill:e.focused?`var(--oke-accent)`:e.insideBoundary?`var(--oke-bg)`:`color-mix(in oklab, var(--oke-external) 25%, var(--oke-bg))`,stroke:e.insideBoundary?`var(--oke-fg)`:`var(--oke-external)`,strokeWidth:e.focused?2.5:1.25}),(0,$.jsx)(`text`,{x:t.x,y:t.y+4,textAnchor:`middle`,fontSize:10,fontFamily:`var(--oke-mono)`,className:`fill-[var(--oke-fg)]`,children:Ae(e.label,12)})]},e.id)})]})}),(0,$.jsx)(`ul`,{"aria-label":`Nodes`,className:`flex flex-wrap gap-2 border-t border-[var(--oke-line)] pt-4`,children:p.nodes.map(t=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":t.focused===!0,className:u(`inline-flex min-h-8 items-center gap-2 border px-3 text-sm`,t.focused?`border-[var(--oke-accent)] text-[var(--oke-fg)]`:`border-[var(--oke-line)] text-[var(--oke-muted)]`),onClick:()=>i(b(e,t.id)),children:[(0,$.jsx)(`span`,{children:t.label}),t.kind===`unit`&&t.flowCount!==void 0?(0,$.jsx)(`span`,{className:`font-mono text-xs`,children:t.flowCount}):null,t.insideBoundary?null:(0,$.jsx)(`span`,{className:`text-xs text-[var(--oke-external)]`,children:`external`})]})},t.id))}),(0,$.jsx)(`ul`,{className:`sr-only`,"aria-label":`Edges`,children:p.edges.map(e=>(0,$.jsxs)(`li`,{children:[e.from,` → `,e.to,e.dashed?` (declared, never traversed)`:` · ${e.traversals} traversals`,` · ${e.layer}`]},e.id))})]})]}),(0,$.jsxs)(`aside`,{"aria-label":`Findings`,className:`w-full shrink-0 overflow-auto border-t border-[var(--oke-line)] lg:w-80 lg:border-l lg:border-t-0`,children:[(0,$.jsxs)(`div`,{className:`px-5 py-4`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-medium`,children:`Findings`}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-[var(--oke-muted)]`,children:`Pathologies from the graph as data`})]}),p.findings.length===0?(0,$.jsx)(`p`,{className:`px-5 pb-4 text-sm text-[var(--oke-muted)]`,children:`No pathologies detected.`}):(0,$.jsx)(`ul`,{className:`divide-y divide-[var(--oke-line)] border-t border-[var(--oke-line)]`,children:p.findings.map((t,n)=>(0,$.jsxs)(`li`,{className:`px-5 py-3`,children:[(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,$.jsx)(`span`,{className:u(`inline-block size-1.5 rounded-full`,t.severity===`critical`?`bg-[var(--oke-danger)]`:`bg-[var(--oke-external)]`),"aria-hidden":!0}),t.title]}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-[var(--oke-muted)]`,children:t.detail}),t.nodeIds[0]?(0,$.jsx)(`button`,{type:`button`,className:`mt-2 min-h-8 text-sm text-[var(--oke-accent)] underline-offset-2 hover:underline`,onClick:()=>i(b(e,t.nodeIds[0])),children:`Focus`}):null]},`${t.kind}-${n}`))})]})]})]})}function Ae(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}var je=t({default:()=>ke});export{De as a,W as c,te as d,Ee as i,me as l,Q as n,be as o,Te as r,ye as s,je as t,A as u};
@@ -0,0 +1 @@
1
+ import{a as e,r as t}from"./rolldown-runtime-B0Z9INg1.js";import{C as n,Q as r,Z as i,a,b as o,d as s,et as c,g as l,nt as u,o as d,r as f,tt as p,u as m,w as h,y as g}from"./panel-access-BGv45snf.js";var _=g({q:o().optional(),template:o().optional(),locale:o().optional(),view:l([`inbox`,`outcomes`,`receipts`,`suppression`,`preview`]).optional()});function v(e){let t=_.safeParse(e);return t.success?t.data:{}}function y(e){let t={};return e.q&&(t.q=e.q),e.template&&(t.template=e.template),e.locale&&(t.locale=e.locale),e.view&&(t.view=e.view),t}function b(e,t){return{...e,template:t}}var x={"suppressed/opted-out":`Suppressed · opted out`,"suppressed/prior-bounce":`Suppressed · prior hard bounce`,"blocked/invalid-address":`Blocked · invalid address`,"soft-bounce":`Soft bounce`,"hard-bounce":`Hard bounce`,"provider-error":`Provider error`,"delivered-then-complained":`Delivered then complained`},S={correct:`correct`,retry:`retry`,suppress:`suppress`,review:`review`};function C(e){return[...e].sort((e,t)=>t.weight===e.weight?t.count-e.count:t.weight-e.weight)}function w(e){return e.weight>=10&&e.count>0}function T(e){return e.filter(e=>e.state===`delivered-then-complained`&&w(e)).map(e=>({state:`delivered-then-complained`,count:e.count,verdict:e.verdict,weight:e.weight}))}function E(e){return e.totalCount===0?`No sends in the last week`:e.chainExample?`${e.chainExample} · ${e.summary}`:e.summary}function D(e){return e.length===0?`default`:e.join(` → `)}function O(e={production:!0}){return e.production?{kind:`typed`,phrase:`SEND`,requireReason:!0}:{kind:`undo`,windowMs:f}}function k(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>e.name.toLowerCase().includes(n)||e.medium.toLowerCase().includes(n)||e.locales.some(e=>e.toLowerCase().includes(n))):e}var A=e(u(),1);function j(e,t){return t&&t.length>0?t:e}var M=p();function N(){let e=h({from:`/channels`}),t=n({from:`/channels`}),o=c(),[l,u]=(0,A.useState)(``),[f,p]=(0,A.useState)(``),[g,_]=(0,A.useState)(`test@example.com`),[v,T]=(0,A.useState)(e.locale??``),[N,P]=(0,A.useState)(null),F=e=>{t({search:y(e),replace:!0})},I=r({queryKey:[`console.channel.list`],queryFn:async()=>{let e=await s.channelsList();if(e.error)throw Error(e.error.code);return e.data},refetchInterval:1e4}),L=I.data,R=(0,A.useMemo)(()=>k(L?.templates??[],e.q??``),[L?.templates,e.q]),z=R.find(t=>t.name===e.template)??L?.templates.find(t=>t.name===e.template),B=C(L?.outcomes??[]),V=O({production:L?.production??!0}),H=r({queryKey:[`console.channel.preview`,z?.name,v||e.locale],enabled:!!z,queryFn:async()=>{if(!z)return null;let t=await s.channelPreview({template:z.name,locale:v||e.locale||z.locales[0]});if(t.error)throw Error(t.error.code);return t.data}}),U=r({queryKey:[`console.channel.verifyAuth`,z?.from],enabled:!!z?.from,queryFn:async()=>{if(!z?.from)return null;let e=await s.channelVerifyAuth({from:z.from});if(e.error)throw Error(e.error.code);return e.data}});(0,A.useEffect)(()=>{u(``),p(``),P(null),z?.locales[0]&&!v&&T(z.locales[0])},[z?.name]);let W=i({mutationFn:async()=>{if(!z)throw Error(`No template selected`);if(V.kind===`typed`){let e=a({typed:l,reason:f,phrase:V.phrase});if(e)throw Error(e.typed??e.reason??`Confirm required`)}let e=await s.channelSendTest({template:z.name,to:g,locale:v||z.locales[0],confirmation:V.kind===`typed`?V.phrase:void 0,reason:V.kind===`typed`?f:void 0});if(e.error)throw Error(e.error.code);return e.data},onSuccess:e=>{P(e.ok?`Sent · ${e.messageId}${e.chain?` · ${e.chain}`:``}`:`Failed · ${e.status}`),o.invalidateQueries({queryKey:[`console.channel.list`]}),u(``),p(``)},onError:e=>{P(e instanceof Error?e.message:String(e))}});return(0,M.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,M.jsxs)(`header`,{className:`shrink-0 border-b border-[var(--oke-line)] px-4 py-3`,children:[(0,M.jsx)(`h1`,{className:`text-lg text-[var(--oke-fg)]`,children:`Channels`}),(0,M.jsx)(`p`,{className:`mt-1 text-sm text-[var(--oke-muted)]`,children:L?.face===`inbox`?`Dev inbox — all media land here instead of sending`:`Deliverability — seven states of did not arrive`}),(0,M.jsxs)(`label`,{className:`mt-3 block text-sm text-[var(--oke-muted)]`,children:[`Filter templates`,(0,M.jsx)(`input`,{"aria-label":`Filter templates`,className:`mt-1 block w-full max-w-md border border-[var(--oke-line)] bg-transparent px-2 py-1 text-[var(--oke-fg)]`,value:e.q??``,onChange:t=>F({...e,q:t.target.value})})]})]}),(0,M.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[(0,M.jsxs)(`section`,{"aria-label":`Templates`,className:`w-64 shrink-0 overflow-y-auto border-r border-[var(--oke-line)] p-3`,children:[(0,M.jsx)(`h2`,{className:`mb-2 text-xs tracking-wide text-[var(--oke-muted)]`,children:`Templates`}),I.isLoading?(0,M.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Loading…`}):(0,M.jsx)(`ul`,{className:`space-y-1`,children:R.map(t=>(0,M.jsx)(`li`,{children:(0,M.jsxs)(`button`,{type:`button`,"aria-pressed":t.name===e.template,className:m(`flex min-h-8 w-full items-center justify-between px-2 text-left text-sm`,t.name===e.template?`bg-[var(--oke-line)] text-[var(--oke-fg)]`:`text-[var(--oke-muted)]`),onClick:()=>F(b(e,t.name)),children:[(0,M.jsx)(`span`,{children:j(t.name,t.description)}),(0,M.jsx)(`span`,{className:`font-mono text-xs`,children:t.medium})]})},t.name))})]}),(0,M.jsxs)(`main`,{id:`channels-main`,className:`min-w-0 flex-1 overflow-y-auto p-4`,children:[L?.face===`inbox`?(0,M.jsxs)(`section`,{"aria-label":`Inbox`,className:`mb-8`,children:[(0,M.jsx)(`h2`,{className:`text-base text-[var(--oke-fg)]`,children:`Inbox`}),(0,M.jsxs)(`ul`,{className:`mt-3 space-y-2`,children:[(L.inbox??[]).map(e=>(0,M.jsxs)(`li`,{className:`border-b border-[var(--oke-line)] pb-2 text-sm`,children:[(0,M.jsxs)(`div`,{className:`flex gap-2 text-[var(--oke-muted)]`,children:[(0,M.jsx)(`span`,{children:e.medium}),(0,M.jsx)(`span`,{children:e.toMasked}),e.template?(0,M.jsx)(`span`,{children:e.template}):null]}),(0,M.jsx)(`p`,{className:`mt-1 text-[var(--oke-fg)]`,children:e.subject??e.text??`(empty)`})]},e.id)),(L.inbox??[]).length===0?(0,M.jsx)(`li`,{className:`text-sm text-[var(--oke-muted)]`,children:`No messages yet`}):null]})]}):null,(0,M.jsxs)(`section`,{"aria-label":`Did not arrive`,className:`mb-8`,children:[(0,M.jsx)(`h2`,{className:`text-base text-[var(--oke-fg)]`,children:`Did not arrive`}),(0,M.jsxs)(`table`,{className:`mt-3 w-full text-left text-sm`,children:[(0,M.jsx)(`caption`,{className:`sr-only`,children:`Seven-state taxonomy with verdicts`}),(0,M.jsx)(`thead`,{children:(0,M.jsxs)(`tr`,{className:`text-[var(--oke-muted)]`,children:[(0,M.jsx)(`th`,{scope:`col`,className:`py-1 font-normal`,children:`State`}),(0,M.jsx)(`th`,{scope:`col`,className:`py-1 font-normal`,children:`Count`}),(0,M.jsx)(`th`,{scope:`col`,className:`py-1 font-normal`,children:`Verdict`})]})}),(0,M.jsx)(`tbody`,{children:B.map(e=>(0,M.jsxs)(`tr`,{className:m(`border-t border-[var(--oke-line)]`,w(e)&&`text-[var(--oke-fg)]`),children:[(0,M.jsx)(`th`,{scope:`row`,className:`py-2 font-normal`,children:x[e.state]}),(0,M.jsx)(`td`,{className:`py-2`,children:e.count}),(0,M.jsx)(`td`,{className:`py-2`,children:S[e.verdict]})]},e.state))})]})]}),(0,M.jsxs)(`section`,{"aria-label":`Fallback chains`,className:`mb-8`,children:[(0,M.jsx)(`h2`,{className:`text-base text-[var(--oke-fg)]`,children:`Fallback`}),(0,M.jsx)(`p`,{className:`mt-2 text-sm text-[var(--oke-muted)]`,role:`status`,children:L?E(L.fallback):`—`})]}),z?(0,M.jsxs)(`section`,{"aria-label":`Template detail`,className:`mb-8`,children:[(0,M.jsx)(`h2`,{className:`text-base text-[var(--oke-fg)]`,children:j(z.name,z.description)}),(0,M.jsxs)(`p`,{className:`mt-1 text-sm text-[var(--oke-muted)]`,children:[z.description?(0,M.jsx)(`span`,{className:`font-mono`,children:z.name}):null,z.description?` · `:``,`From `,z.from??`unset`,` · Locales `,z.locales.join(`, `)||`none`]}),z.from?(0,M.jsxs)(`section`,{"aria-label":`Email authentication`,className:`mt-4`,children:[(0,M.jsx)(`h3`,{className:`text-sm text-[var(--oke-fg)]`,children:`SPF / DKIM / DMARC`}),U.data?(0,M.jsxs)(`ul`,{className:`mt-2 space-y-1 text-sm text-[var(--oke-muted)]`,children:[(0,M.jsxs)(`li`,{children:[`SPF: `,U.data.spf]}),(0,M.jsxs)(`li`,{children:[`DKIM: `,U.data.dkim]}),(0,M.jsxs)(`li`,{children:[`DMARC: `,U.data.dmarc]}),(0,M.jsx)(`li`,{className:`font-mono text-xs`,children:U.data.domain})]}):(0,M.jsx)(`p`,{className:`mt-2 text-sm text-[var(--oke-muted)]`,children:`Checking…`})]}):null,(0,M.jsxs)(`section`,{"aria-label":`Locale preview`,className:`mt-4`,children:[(0,M.jsx)(`h3`,{className:`text-sm text-[var(--oke-fg)]`,children:`Preview`}),(0,M.jsxs)(`label`,{className:`mt-2 block text-sm text-[var(--oke-muted)]`,children:[`Locale`,(0,M.jsx)(`select`,{"aria-label":`Preview locale`,className:`mt-1 block border border-[var(--oke-line)] bg-transparent px-2 py-1`,value:v||z.locales[0]||`en`,onChange:e=>T(e.target.value),children:(z.locales.length>0?z.locales:[`en`]).map(e=>(0,M.jsx)(`option`,{value:e,children:e},e))})]}),H.data?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`p`,{className:`mt-2 text-xs text-[var(--oke-muted)]`,children:[`Locale chain: `,D(H.data.localeChain)]}),(0,M.jsxs)(`div`,{className:`mt-2 max-w-prose border border-[var(--oke-line)] p-3 text-sm text-[var(--oke-fg)]`,dir:H.data.dir,lang:H.data.locale,children:[H.data.subject?(0,M.jsx)(`p`,{className:`mb-2 font-medium`,children:H.data.subject}):null,(0,M.jsx)(`p`,{children:H.data.text??H.data.html})]})]}):null]}),(0,M.jsxs)(`section`,{"aria-label":`Send test`,className:`mt-6`,children:[(0,M.jsx)(`h3`,{className:`text-sm text-[var(--oke-fg)]`,children:`Send test`}),(0,M.jsx)(`p`,{className:`mt-1 text-sm text-[var(--oke-muted)]`,role:`status`,children:`Real send to a designated recipient — not a dry run`}),(0,M.jsxs)(`label`,{className:`mt-3 block text-sm text-[var(--oke-muted)]`,children:[`Recipient`,(0,M.jsx)(`input`,{"aria-label":`Test recipient`,className:`mt-1 block w-full max-w-md border border-[var(--oke-line)] bg-transparent px-2 py-1 text-[var(--oke-fg)]`,value:g,onChange:e=>_(e.target.value)})]}),V.kind===`typed`?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`label`,{className:`mt-3 block text-sm text-[var(--oke-muted)]`,children:[`Type `,V.phrase,` to confirm`,(0,M.jsx)(`input`,{"aria-label":`Type ${V.phrase} to confirm`,className:`mt-1 block w-full max-w-md border border-[var(--oke-line)] bg-transparent px-2 py-1 text-[var(--oke-fg)]`,value:l,onChange:e=>u(e.target.value),autoComplete:`off`})]}),(0,M.jsxs)(`label`,{className:`mt-3 block text-sm text-[var(--oke-muted)]`,children:[`Reason`,(0,M.jsx)(`input`,{"aria-label":`Reason for send test`,className:`mt-1 block w-full max-w-md border border-[var(--oke-line)] bg-transparent px-2 py-1 text-[var(--oke-fg)]`,value:f,onChange:e=>p(e.target.value)})]})]}):null,(0,M.jsx)(`div`,{className:`mt-3`,children:(0,M.jsx)(d,{type:`button`,onClick:()=>W.mutate(),disabled:W.isPending||!g.trim(),children:`Send test`})}),N?(0,M.jsx)(`p`,{className:`mt-2 text-sm text-[var(--oke-muted)]`,role:`status`,children:N}):null]})]}):(0,M.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Select a template to preview and send a test.`}),(0,M.jsxs)(`section`,{"aria-label":`Suppression list`,className:`mb-8`,children:[(0,M.jsx)(`h2`,{className:`text-base text-[var(--oke-fg)]`,children:`Suppression`}),(0,M.jsxs)(`ul`,{className:`mt-3 space-y-1 text-sm text-[var(--oke-muted)]`,children:[(L?.suppression??[]).map(e=>(0,M.jsxs)(`li`,{children:[e.subjectMasked,` · `,e.reason,` · `,e.medium]},`${e.subjectMasked}-${e.reason}-${e.at}`)),(L?.suppression??[]).length===0?(0,M.jsx)(`li`,{children:`Empty`}):null]})]}),(0,M.jsxs)(`section`,{"aria-label":`Recent receipts`,children:[(0,M.jsx)(`h2`,{className:`text-base text-[var(--oke-fg)]`,children:`Receipts`}),(0,M.jsxs)(`ul`,{className:`mt-3 space-y-2 text-sm`,children:[(L?.receipts??[]).map(e=>(0,M.jsxs)(`li`,{className:`border-b border-[var(--oke-line)] pb-2 text-[var(--oke-muted)]`,children:[(0,M.jsx)(`span`,{className:`text-[var(--oke-fg)]`,children:e.template}),` → `,e.toMasked,` · `,e.status,e.chain?` · ${e.chain}`:``,e.localeChain.length>0?(0,M.jsxs)(`span`,{className:`block text-xs`,children:[`Locale: `,D(e.localeChain)]}):null]},e.id)),(L?.receipts??[]).length===0?(0,M.jsx)(`li`,{children:`No receipts yet`}):null]})]})]})]})]})}var P=t({default:()=>N});export{v as i,j as n,T as r,P as t};
@@ -0,0 +1 @@
1
+ import{a as e,r as t}from"./rolldown-runtime-B0Z9INg1.js";import{C as n,Q as r,Z as i,a,b as o,c as s,d as c,et as l,g as u,nt as d,o as f,r as p,tt as m,u as h,w as g,y as _}from"./panel-access-BGv45snf.js";import{n as v}from"./panel-channels-9T3ybqRu.js";var y=_({q:o().optional(),cron:o().optional(),wake:o().optional(),action:u([`run`,`edit`]).optional()});function b(e){let t=y.safeParse(e);return t.success?t.data:{}}function x(e){let t={};return e.q&&(t.q=e.q),e.cron&&(t.cron=e.cron),e.wake&&(t.wake=e.wake),e.action&&(t.action=e.action),t}function S(e,t){return{...e,cron:t,wake:void 0,action:void 0}}function C(e,t){return{...e,wake:t,cron:void 0,action:void 0}}function ee(e,t){let n=t+864e5;return e.filter(e=>e.at>=t&&e.at<n).slice().sort((e,t)=>e.at-t.at||e.name.localeCompare(t.name))}function te(e,t){let n=e-t;if(n<0)return`past`;if(n<6e4)return`in ${Math.round(n/1e3)}s`;if(n<36e5)return`in ${Math.round(n/6e4)}m`;if(n<864e5){let e=Math.floor(n/36e5),t=Math.round(n%36e5/6e4);return t>0?`in ${e}h ${t}m`:`in ${e}h`}return new Date(e).toISOString()}function w(e,t){return e===0?`Nothing waiting`:`${e} sleeping — ${t.slice(0,4).map(e=>`${e.count} ${e.label}`).join(`, `)}`}function T(e){if(e<=0)return`due`;if(e<1e3)return`${e}ms`;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);if(r<48){let e=n%60;return e>0?`${r}h ${e}m`:`${r}h`}return`${Math.floor(r/24)}d`}function E(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>e.label.toLowerCase().includes(n)||e.flow.toLowerCase().includes(n)||e.runId.toLowerCase().includes(n)||(e.step?.toLowerCase().includes(n)??!1)):e}function D(e){return{drift:e.driftMs==null?`drift unknown`:`drift ${k(e.driftMs)}`,overdue:e.overdue?`overdue`:`on time`,missedWithPolicy:`${e.missedRuns} missed · catch-up ${e.catchUp}`,lease:e.leaderInstanceId?`lease ${e.leaderInstanceId}`:`no lease`}}function O(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>e.name.toLowerCase().includes(n)||(e.effectiveCron?.toLowerCase().includes(n)??!1)||(e.effectiveEvery?.toLowerCase().includes(n)??!1)||e.flowIds.some(e=>e.toLowerCase().includes(n))):e}function k(e){let t=e>=0?`+`:`-`,n=Math.abs(e);return n<1e3?`${t}${n}ms`:n<6e4?`${t}${Math.round(n/1e3)}s`:`${t}${Math.round(n/6e4)}m`}function A(e){return e.filter(e=>e.health.overdue).map(e=>({name:e.name,driftMs:e.health.driftMs,missedRuns:e.health.missedRuns,...e.nextRunAt===void 0?{}:{nextRunAt:e.nextRunAt},flowIds:e.flowIds})).sort((e,t)=>t.missedRuns-e.missedRuns||e.name.localeCompare(t.name))}function j(e,t={production:!0}){return t.production&&e.external?{kind:`typed`,phrase:`RUN`,requireReason:!0}:{kind:`undo`,windowMs:p}}var M=e(d(),1),N=m();function P(){let e=g({from:`/clock`}),t=n({from:`/clock`}),o=l(),[u,d]=(0,M.useState)(``),[p,m]=(0,M.useState)(``),[_,y]=(0,M.useState)(``),[b,k]=(0,M.useState)(``),[A,P]=(0,M.useState)(null),F=e=>{t({search:x(e),replace:!0})},I=r({queryKey:[`console.clock.list`],queryFn:async()=>{let e=await c.clockList();if(e.error)throw Error(e.error.code);return e.data},refetchInterval:5e3}),L=I.data,R=L?.now??Date.now(),z=e.q??``,B=(0,M.useMemo)(()=>O(L?.crons??[],z),[L?.crons,z]),V=(0,M.useMemo)(()=>E(L?.waitingOn??[],z),[L?.waitingOn,z]),H=(0,M.useMemo)(()=>ee(L?.timeline??[],R),[L?.timeline,R]),U=L?.waitingOnCounts??[],W=w(V.length,U),G=B.find(t=>t.name===e.cron),K=V.find(t=>t.runId===e.wake),q=G?j(G,{production:!0}):null,J=G?D(G.health):null;(0,M.useEffect)(()=>{d(``),m(``),P(null),G&&(y(G.effectiveCron??``),k(G.effectiveEvery??``))},[G?.name,e.action,K?.runId]);let Y=()=>o.invalidateQueries({queryKey:[`console.clock.list`]}),X=i({mutationFn:async()=>{if(!G||!q)throw Error(`no cron`);if(q.kind===`typed`){let e=a({typed:u,reason:p,phrase:q.phrase});if(e)throw Error(e.typed??e.reason??`confirm`)}let e=await c.clockRunNow({name:G.name,confirmation:q.kind===`typed`?u:void 0,reason:q.kind===`typed`?p:void 0});if(e.error)throw Error(e.error.code);return e.data},onSuccess:async e=>{P(e?.ran?`Ran now`:`Did not acquire lease`),d(``),m(``),await Y()},onError:e=>{P(e instanceof Error?e.message:`Run failed`)}}),Z=i({mutationFn:async()=>{if(!G)throw Error(`no cron`);let e=await c.clockPause({name:G.name});if(e.error)throw Error(e.error.code);return e.data},onSuccess:async()=>{P(`Paused`),await Y()}}),Q=i({mutationFn:async()=>{if(!G?.overridable)throw Error(`not overridable`);let e=await c.clockEditSchedule({name:G.name,cron:_||void 0,every:b||void 0});if(e.error)throw Error(e.error.code);return e.data},onSuccess:async()=>{P(`Schedule updated`),F({...e,action:void 0}),await Y()},onError:e=>{P(e instanceof Error?e.message:`Edit failed`)}}),$=i({mutationFn:async()=>{if(!K)throw Error(`no wake`);let e=await c.clockWakeEarly({runId:K.runId});if(e.error)throw Error(e.error.code);return e.data},onSuccess:async()=>{P(`Woke early`),F({...e,wake:void 0}),await Y()}});return(0,N.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,N.jsxs)(`header`,{className:`shrink-0 border-b border-[var(--oke-line)] px-4 py-3`,children:[(0,N.jsx)(`h1`,{className:`text-lg font-medium`,children:`Clock`}),(0,N.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Forward timeline, waiting-on, cron health`}),(0,N.jsxs)(`label`,{className:`mt-2 block max-w-sm text-sm`,children:[(0,N.jsx)(`span`,{className:`sr-only`,children:`Filter clock`}),(0,N.jsx)(s,{"aria-label":`Filter clock`,placeholder:`Filter…`,value:z,onChange:t=>F({...e,q:t.currentTarget.value||void 0})})]})]}),(0,N.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-1 gap-0 overflow-hidden lg:grid-cols-[1fr_1fr_1.2fr]`,children:[(0,N.jsxs)(`section`,{"aria-label":`Forward timeline`,className:`min-h-0 overflow-y-auto border-b border-[var(--oke-line)] p-4 lg:border-b-0 lg:border-r`,children:[(0,N.jsx)(`h2`,{className:`mb-2 text-sm font-medium`,children:`Next 24 hours`}),I.isLoading?(0,N.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Loading…`}):H.length===0?(0,N.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Nothing in the next 24h`}):(0,N.jsx)(`ol`,{className:`space-y-1`,children:H.map(e=>(0,N.jsxs)(`li`,{className:`flex min-h-8 items-baseline gap-2 text-sm`,children:[(0,N.jsx)(`span`,{className:`w-24 shrink-0 text-[var(--oke-muted)]`,children:te(e.at,R)}),(0,N.jsxs)(`span`,{children:[e.kind===`cron`?`cron`:`wake`,` · `,e.name]})]},`${e.kind}-${e.name}-${e.at}`))})]}),(0,N.jsxs)(`section`,{"aria-label":`Waiting on`,className:`min-h-0 overflow-y-auto border-b border-[var(--oke-line)] p-4 lg:border-b-0 lg:border-r`,children:[(0,N.jsx)(`h2`,{className:`mb-1 text-sm font-medium`,children:`Waiting on`}),(0,N.jsx)(`p`,{className:`mb-2 text-sm text-[var(--oke-muted)]`,role:`status`,children:W}),(0,N.jsx)(`ul`,{className:`space-y-1`,children:V.map(t=>{let n=U.find(e=>e.label===(t.label||`(unlabelled)`))?.count??1;return(0,N.jsx)(`li`,{children:(0,N.jsxs)(`button`,{type:`button`,"aria-pressed":t.runId===e.wake,className:h(`flex min-h-8 w-full flex-col items-start px-2 py-1 text-left text-sm`,t.runId===e.wake?`bg-[var(--oke-line)]`:`hover:bg-[var(--oke-line)]/40`),onClick:()=>F(C(e,t.runId)),children:[(0,N.jsx)(`span`,{children:t.label||t.flow}),(0,N.jsxs)(`span`,{className:`text-[var(--oke-muted)]`,children:[`wake-in `,T(t.wakeInMs),t.step?` · step ${t.step}`:``,` · ${n} run${n===1?``:`s`}`]})]})},t.runId)})})]}),(0,N.jsxs)(`section`,{"aria-label":`Cron schedules`,className:`min-h-0 overflow-y-auto p-4`,children:[(0,N.jsx)(`h2`,{className:`mb-2 text-sm font-medium`,children:`Schedules`}),(0,N.jsx)(`ul`,{className:`mb-4 space-y-1`,children:B.map(t=>{let n=D(t.health);return(0,N.jsx)(`li`,{children:(0,N.jsxs)(`button`,{type:`button`,"aria-pressed":t.name===e.cron,className:h(`flex min-h-8 w-full flex-col items-start px-2 py-1 text-left text-sm`,t.name===e.cron?`bg-[var(--oke-line)]`:`hover:bg-[var(--oke-line)]/40`),onClick:()=>F(S(e,t.name)),children:[(0,N.jsxs)(`span`,{className:`flex items-center gap-1`,children:[v(t.name,t.description),t.external?(0,N.jsx)(`span`,{"aria-label":`external effect`,children:`↗`}):null,t.health.overdue?(0,N.jsx)(`span`,{role:`status`,className:`text-[var(--oke-danger)]`,children:`overdue`}):null,t.dstAmbiguity?(0,N.jsxs)(`span`,{role:`status`,children:[`DST `,t.dstAmbiguity.kind]}):null]}),(0,N.jsxs)(`span`,{className:`text-[var(--oke-muted)]`,children:[n.drift,` · `,n.missedWithPolicy,` · `,n.lease]})]})},t.name)})}),G&&J?(0,N.jsxs)(`section`,{"aria-label":`Cron detail`,"aria-live":`polite`,className:`space-y-3 border-t border-[var(--oke-line)] pt-3`,children:[(0,N.jsx)(`h3`,{className:`text-base font-medium`,children:v(G.name,G.description)}),(0,N.jsxs)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:[G.description?(0,N.jsx)(`span`,{className:`font-mono`,children:G.name}):null,G.description?` · `:``,G.effectiveCron??G.effectiveEvery,` · `,G.timezone,G.status===`active`?``:` · ${G.status}`]}),(0,N.jsxs)(`dl`,{className:`grid grid-cols-2 gap-2 text-sm`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`dt`,{className:`text-[var(--oke-muted)]`,children:`Drift`}),(0,N.jsx)(`dd`,{children:J.drift})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`dt`,{className:`text-[var(--oke-muted)]`,children:`Overdue`}),(0,N.jsx)(`dd`,{children:J.overdue})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`dt`,{className:`text-[var(--oke-muted)]`,children:`Missed + catch-up`}),(0,N.jsx)(`dd`,{children:J.missedWithPolicy})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`dt`,{className:`text-[var(--oke-muted)]`,children:`Lease`}),(0,N.jsx)(`dd`,{children:J.lease})]})]}),G.dstAmbiguity?(0,N.jsx)(`p`,{role:`alert`,className:`text-sm`,children:G.dstAmbiguity.reason}):null,(0,N.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,N.jsx)(f,{type:`button`,variant:G.external?`external`:`primary`,disabled:X.isPending,onClick:()=>{if(q?.kind===`typed`&&e.action!==`run`){F({...e,action:`run`});return}X.mutate()},children:`Run now`}),(0,N.jsx)(f,{type:`button`,variant:`ghost`,disabled:Z.isPending||G.status===`paused`,onClick:()=>Z.mutate(),children:`Pause`}),G.overridable?(0,N.jsx)(f,{type:`button`,variant:`ghost`,onClick:()=>F({...e,action:e.action===`edit`?void 0:`edit`}),children:`Edit schedule`}):null]}),e.action===`run`&&q?.kind===`typed`?(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsxs)(`p`,{className:`text-sm`,children:[`This cron has an external effect. Type `,(0,N.jsx)(`strong`,{children:`RUN`}),` and a reason.`]}),(0,N.jsxs)(`label`,{className:`block text-sm`,children:[`Type RUN to confirm`,(0,N.jsx)(s,{"aria-label":`Type RUN to confirm`,value:u,onChange:e=>d(e.currentTarget.value)})]}),(0,N.jsxs)(`label`,{className:`block text-sm`,children:[`Reason`,(0,N.jsx)(s,{"aria-label":`Reason`,value:p,onChange:e=>m(e.currentTarget.value)})]}),(0,N.jsx)(f,{type:`button`,variant:`external`,disabled:X.isPending,onClick:()=>X.mutate(),children:`Confirm run now`})]}):null,e.action===`edit`&&G.overridable?(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsxs)(`label`,{className:`block text-sm`,children:[`Cron expression`,(0,N.jsx)(s,{"aria-label":`Cron expression`,value:_,onChange:e=>y(e.currentTarget.value)})]}),(0,N.jsxs)(`label`,{className:`block text-sm`,children:[`Every interval`,(0,N.jsx)(s,{"aria-label":`Every interval`,value:b,onChange:e=>k(e.currentTarget.value)})]}),(0,N.jsx)(f,{type:`button`,disabled:Q.isPending,onClick:()=>Q.mutate(),children:`Save schedule`})]}):null]}):null,K?(0,N.jsxs)(`section`,{"aria-label":`Wake detail`,"aria-live":`polite`,className:`mt-4 space-y-2 border-t border-[var(--oke-line)] pt-3`,children:[(0,N.jsx)(`h3`,{className:`text-base font-medium`,children:K.label||K.flow}),(0,N.jsxs)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:[K.flow,` · wake in `,T(K.wakeInMs),K.step?` · step ${K.step}`:``]}),(0,N.jsx)(f,{type:`button`,disabled:$.isPending,onClick:()=>$.mutate(),children:`Wake early`})]}):null,A?(0,N.jsx)(`p`,{className:`mt-3 text-sm`,role:`status`,children:A}):null]})]})]})}var F=t({default:()=>P});export{A as n,b as r,F as t};
@@ -1 +1 @@
1
- import{a as e,r as t}from"./rolldown-runtime-CNC7AqOf.js";import{C as n,D as r,E as i,Q as a,b as o,d as s,g as c,k as l,nt as u,tt as d,u as f,y as p}from"./panel-access-C0J2D-a2.js";function m(e){let t=l({warn:e?.router===void 0}),n=e?.router||t;return r(n.stores.__store,i(e,n))}var h=p({q:o().optional(),path:o().optional(),category:c([`contract-breaking`,`permission-widening`,`effect-widening`,`no-impact`]).optional()});function g(e){let t=h.safeParse(e);return t.success?t.data:{}}function _(e){let t={};return e.q&&(t.q=e.q),e.path&&(t.path=e.path),e.category&&(t.category=e.category),t}var v=[`contract-breaking`,`permission-widening`,`effect-widening`,`no-impact`],y={"contract-breaking":`Contract breaking`,"permission-widening":`Permission widening`,"effect-widening":`Effect widening`,"no-impact":`No impact`};function b(e,t,n){let r=t.trim().toLowerCase();return e.filter(e=>n&&e.category!==n?!1:!r||e.path.toLowerCase().includes(r)||e.summary.toLowerCase().includes(r)||(e.blastLine?.toLowerCase().includes(r)??!1)||(e.flowName?.toLowerCase().includes(r)??!1)||(e.weeklyBillLine?.toLowerCase().includes(r)??!1))}function x(e){let t=new Map;for(let e of v)t.set(e,[]);for(let n of e)t.get(n.category)?.push(n);return v.flatMap(e=>{let n=t.get(e)??[];return n.length===0?[]:[{category:e,label:y[e],items:n}]})}function S(e){return e===`blocked`?`CI gate: blocked — undeclared break`:e===`acknowledged`?`CI gate: allowed — breaking: true`:null}function C(e){let t=`/diff`;if(!e.hasBaseline)return{hasBaseline:!1,severity:null,changeCount:0,blockedCount:0,acknowledgedCount:0,line:`No prior deploy baseline — Manifest Diff has nothing to compare yet`,href:t};let n=e.changes.length;if(n===0)return{hasBaseline:!0,severity:null,changeCount:0,blockedCount:0,acknowledgedCount:0,line:`Last deploy changed nothing in the Manifest`,href:t};let r=e.severity==null?`changes`:y[e.severity],i=e.changes[0],a=e.blockedCount>0?` · ${e.blockedCount} blocked by CI`:e.acknowledgedCount>0?` · ${e.acknowledgedCount} acknowledged break${e.acknowledgedCount===1?``:`s`}`:``;return{hasBaseline:!0,severity:e.severity,changeCount:n,blockedCount:e.blockedCount,acknowledgedCount:e.acknowledgedCount,line:`${n} Manifest change${n===1?``:`s`} (${r}): ${i.summary}${a}`,href:t}}var w=e(u(),1),T=d();function E(){let e=m({select:e=>e.location.pathname}),t=m({select:e=>e.location.search}),r=(0,w.useMemo)(()=>g(t),[t]),i=n(),o=t=>{i({to:e===`/diff`?`/diff`:`/manifest-diff`,search:_(t),replace:!0})},c=a({queryKey:[`console.diff.list`],queryFn:async()=>{let e=await s.diffList();if(e.error)throw Error(e.error.code);return e.data},refetchInterval:1e4}),l=c.data,u=(0,w.useMemo)(()=>b(l?.changes??[],r.q??``,r.category),[l?.changes,r.q,r.category]),d=(0,w.useMemo)(()=>x(u),[u]),p=r.path;return(0,T.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,T.jsxs)(`header`,{className:`shrink-0 border-b border-[var(--oke-line)] px-4 py-3`,children:[(0,T.jsx)(`h1`,{className:`text-base font-medium text-[var(--oke-fg)]`,children:`Manifest Diff`}),(0,T.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Blast radius of a deploy — contract, permission, effect, and no-impact. Read-only compare of current Manifest vs baseline.`}),(0,T.jsxs)(`label`,{className:`mt-2 flex max-w-sm flex-col gap-1 text-sm`,children:[(0,T.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:`Filter`}),(0,T.jsx)(`input`,{"aria-label":`Filter changes`,className:`min-h-8 border border-[var(--oke-line)] bg-transparent px-2`,value:r.q??``,onChange:e=>o({...r,q:e.target.value||void 0})})]}),(0,T.jsxs)(`div`,{role:`group`,"aria-label":`Blast-radius category`,className:`mt-2 flex flex-wrap gap-1`,children:[(0,T.jsx)(D,{label:`All`,pressed:r.category===void 0,onClick:()=>o({...r,category:void 0})}),v.map(e=>(0,T.jsx)(D,{label:y[e],pressed:r.category===e,onClick:()=>o({...r,category:r.category===e?void 0:e})},e))]})]}),l?.hasBaseline?(0,T.jsxs)(`section`,{"aria-label":`CI gate summary`,role:`status`,className:`shrink-0 border-b border-[var(--oke-line)] px-4 py-2 text-sm`,children:[(0,T.jsx)(`h2`,{className:`sr-only`,children:`CI gate`}),(0,T.jsxs)(`p`,{className:`text-[var(--oke-fg)]`,children:[(0,T.jsxs)(`span`,{className:(l.blockedCount??0)>0?`text-[var(--oke-fg)]`:`text-[var(--oke-muted)]`,children:[l.blockedCount,` undeclared break`,l.blockedCount===1?``:`s`,` blocked`]}),(0,T.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:` · `}),(0,T.jsxs)(`span`,{className:`text-[var(--oke-muted)]`,children:[l.acknowledgedCount,` acknowledged with`,` `,(0,T.jsx)(`code`,{className:`font-mono text-xs`,children:`breaking: true`})]})]})]}):null,(0,T.jsxs)(`main`,{id:`diff-main`,className:`min-h-0 flex-1 overflow-y-auto p-4`,children:[c.isLoading?(0,T.jsx)(`p`,{className:`text-[var(--oke-muted)]`,children:`Loading…`}):null,c.isError?(0,T.jsx)(`p`,{role:`alert`,children:`Failed to load Manifest Diff`}):null,l&&!l.hasBaseline?(0,T.jsx)(`p`,{className:`text-[var(--oke-muted)]`,role:`status`,children:`No baseline Manifest to compare. Deploy once, or feed a previous Manifest, to see blast radius.`}):null,l?.hasBaseline&&d.length===0?(0,T.jsx)(`p`,{className:`text-[var(--oke-muted)]`,role:`status`,children:`No behavioural changes between baseline and current Manifest.`}):null,d.map(e=>(0,T.jsxs)(`section`,{"aria-label":e.label,className:`mb-8`,children:[(0,T.jsxs)(`h2`,{className:`mb-3 text-xs uppercase tracking-wide text-[var(--oke-muted)]`,children:[e.label,(0,T.jsxs)(`span`,{className:`ml-2 font-mono normal-case`,children:[`(`,e.items.length,`)`]})]}),(0,T.jsx)(`ul`,{className:`space-y-3`,children:e.items.map(e=>{let t=S(e.ciGate),n=e.path===p;return(0,T.jsx)(`li`,{children:(0,T.jsxs)(`article`,{"aria-current":n?`true`:void 0,className:f(`border border-[var(--oke-line)] px-3 py-3`,n&&`bg-[var(--oke-line)]`),children:[(0,T.jsxs)(`button`,{type:`button`,className:`min-h-8 w-full text-left`,"aria-pressed":n,onClick:()=>o({...r,path:r.path===e.path?void 0:e.path}),children:[(0,T.jsx)(`h3`,{className:`font-mono text-sm text-[var(--oke-fg)]`,children:e.path}),(0,T.jsx)(`p`,{className:`mt-1 text-sm text-[var(--oke-muted)]`,children:e.summary})]}),e.blastLine?(0,T.jsx)(`p`,{role:`status`,className:`mt-2 text-sm text-[var(--oke-fg)]`,children:e.blastLine}):e.runCountLastWeek>0&&e.flowName?(0,T.jsxs)(`p`,{className:`mt-2 text-sm text-[var(--oke-muted)]`,children:[`Ran `,e.runCountLastWeek.toLocaleString(`en-US`),` times last week`]}):null,e.weeklyBillLine?(0,T.jsxs)(`p`,{className:`mt-1 text-sm font-medium text-[var(--oke-fg)]`,children:[`Weekly bill: `,e.weeklyBillLine]}):null,t?(0,T.jsx)(`p`,{role:`status`,"data-ci-gate":e.ciGate??void 0,className:f(`mt-2 text-sm`,e.ciGate===`blocked`?`text-[var(--oke-fg)]`:`text-[var(--oke-muted)]`),children:t}):null]})},e.path)})})]},e.category))]})]})}function D(e){return(0,T.jsx)(`button`,{type:`button`,"aria-pressed":e.pressed,className:f(`min-h-8 px-2 text-xs`,e.pressed?`bg-[var(--oke-line)] text-[var(--oke-fg)]`:`text-[var(--oke-muted)]`),onClick:e.onClick,children:e.label})}var O=t({default:()=>E});export{m as i,C as n,g as r,O as t};
1
+ import{a as e,r as t}from"./rolldown-runtime-B0Z9INg1.js";import{C as n,D as r,E as i,Q as a,b as o,d as s,g as c,k as l,nt as u,tt as d,u as f,y as p}from"./panel-access-BGv45snf.js";function m(e){let t=l({warn:e?.router===void 0}),n=e?.router||t;return r(n.stores.__store,i(e,n))}var h=p({q:o().optional(),path:o().optional(),category:c([`contract-breaking`,`permission-widening`,`effect-widening`,`no-impact`]).optional()});function g(e){let t=h.safeParse(e);return t.success?t.data:{}}function _(e){let t={};return e.q&&(t.q=e.q),e.path&&(t.path=e.path),e.category&&(t.category=e.category),t}var v=[`contract-breaking`,`permission-widening`,`effect-widening`,`no-impact`],y={"contract-breaking":`Contract breaking`,"permission-widening":`Permission widening`,"effect-widening":`Effect widening`,"no-impact":`No impact`};function b(e,t,n){let r=t.trim().toLowerCase();return e.filter(e=>n&&e.category!==n?!1:!r||e.path.toLowerCase().includes(r)||e.summary.toLowerCase().includes(r)||(e.blastLine?.toLowerCase().includes(r)??!1)||(e.flowName?.toLowerCase().includes(r)??!1)||(e.weeklyBillLine?.toLowerCase().includes(r)??!1))}function x(e){let t=new Map;for(let e of v)t.set(e,[]);for(let n of e)t.get(n.category)?.push(n);return v.flatMap(e=>{let n=t.get(e)??[];return n.length===0?[]:[{category:e,label:y[e],items:n}]})}function S(e){return e===`blocked`?`CI gate: blocked — undeclared break`:e===`acknowledged`?`CI gate: allowed — breaking: true`:null}function C(e){let t=`/diff`;if(!e.hasBaseline)return{hasBaseline:!1,severity:null,changeCount:0,blockedCount:0,acknowledgedCount:0,line:`No prior deploy baseline — Manifest Diff has nothing to compare yet`,href:t};let n=e.changes.length;if(n===0)return{hasBaseline:!0,severity:null,changeCount:0,blockedCount:0,acknowledgedCount:0,line:`Last deploy changed nothing in the Manifest`,href:t};let r=e.severity==null?`changes`:y[e.severity],i=e.changes[0],a=e.blockedCount>0?` · ${e.blockedCount} blocked by CI`:e.acknowledgedCount>0?` · ${e.acknowledgedCount} acknowledged break${e.acknowledgedCount===1?``:`s`}`:``;return{hasBaseline:!0,severity:e.severity,changeCount:n,blockedCount:e.blockedCount,acknowledgedCount:e.acknowledgedCount,line:`${n} Manifest change${n===1?``:`s`} (${r}): ${i.summary}${a}`,href:t}}var w=e(u(),1),T=d();function E(){let e=m({select:e=>e.location.pathname}),t=m({select:e=>e.location.search}),r=(0,w.useMemo)(()=>g(t),[t]),i=n(),o=t=>{i({to:e===`/diff`?`/diff`:`/manifest-diff`,search:_(t),replace:!0})},c=a({queryKey:[`console.diff.list`],queryFn:async()=>{let e=await s.diffList();if(e.error)throw Error(e.error.code);return e.data},refetchInterval:1e4}),l=c.data,u=(0,w.useMemo)(()=>b(l?.changes??[],r.q??``,r.category),[l?.changes,r.q,r.category]),d=(0,w.useMemo)(()=>x(u),[u]),p=r.path;return(0,T.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,T.jsxs)(`header`,{className:`shrink-0 border-b border-[var(--oke-line)] px-4 py-3`,children:[(0,T.jsx)(`h1`,{className:`text-base font-medium text-[var(--oke-fg)]`,children:`Manifest Diff`}),(0,T.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Blast radius of a deploy — contract, permission, effect, and no-impact. Read-only compare of current Manifest vs baseline.`}),(0,T.jsxs)(`label`,{className:`mt-2 flex max-w-sm flex-col gap-1 text-sm`,children:[(0,T.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:`Filter`}),(0,T.jsx)(`input`,{"aria-label":`Filter changes`,className:`min-h-8 border border-[var(--oke-line)] bg-transparent px-2`,value:r.q??``,onChange:e=>o({...r,q:e.target.value||void 0})})]}),(0,T.jsxs)(`div`,{role:`group`,"aria-label":`Blast-radius category`,className:`mt-2 flex flex-wrap gap-1`,children:[(0,T.jsx)(D,{label:`All`,pressed:r.category===void 0,onClick:()=>o({...r,category:void 0})}),v.map(e=>(0,T.jsx)(D,{label:y[e],pressed:r.category===e,onClick:()=>o({...r,category:r.category===e?void 0:e})},e))]})]}),l?.hasBaseline?(0,T.jsxs)(`section`,{"aria-label":`CI gate summary`,role:`status`,className:`shrink-0 border-b border-[var(--oke-line)] px-4 py-2 text-sm`,children:[(0,T.jsx)(`h2`,{className:`sr-only`,children:`CI gate`}),(0,T.jsxs)(`p`,{className:`text-[var(--oke-fg)]`,children:[(0,T.jsxs)(`span`,{className:(l.blockedCount??0)>0?`text-[var(--oke-fg)]`:`text-[var(--oke-muted)]`,children:[l.blockedCount,` undeclared break`,l.blockedCount===1?``:`s`,` blocked`]}),(0,T.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:` · `}),(0,T.jsxs)(`span`,{className:`text-[var(--oke-muted)]`,children:[l.acknowledgedCount,` acknowledged with`,` `,(0,T.jsx)(`code`,{className:`font-mono text-xs`,children:`breaking: true`})]})]})]}):null,(0,T.jsxs)(`main`,{id:`diff-main`,className:`min-h-0 flex-1 overflow-y-auto p-4`,children:[c.isLoading?(0,T.jsx)(`p`,{className:`text-[var(--oke-muted)]`,children:`Loading…`}):null,c.isError?(0,T.jsx)(`p`,{role:`alert`,children:`Failed to load Manifest Diff`}):null,l&&!l.hasBaseline?(0,T.jsx)(`p`,{className:`text-[var(--oke-muted)]`,role:`status`,children:`No baseline Manifest to compare. Deploy once, or feed a previous Manifest, to see blast radius.`}):null,l?.hasBaseline&&d.length===0?(0,T.jsx)(`p`,{className:`text-[var(--oke-muted)]`,role:`status`,children:`No behavioural changes between baseline and current Manifest.`}):null,d.map(e=>(0,T.jsxs)(`section`,{"aria-label":e.label,className:`mb-8`,children:[(0,T.jsxs)(`h2`,{className:`mb-3 text-xs uppercase tracking-wide text-[var(--oke-muted)]`,children:[e.label,(0,T.jsxs)(`span`,{className:`ml-2 font-mono normal-case`,children:[`(`,e.items.length,`)`]})]}),(0,T.jsx)(`ul`,{className:`space-y-3`,children:e.items.map(e=>{let t=S(e.ciGate),n=e.path===p;return(0,T.jsx)(`li`,{children:(0,T.jsxs)(`article`,{"aria-current":n?`true`:void 0,className:f(`border border-[var(--oke-line)] px-3 py-3`,n&&`bg-[var(--oke-line)]`),children:[(0,T.jsxs)(`button`,{type:`button`,className:`min-h-8 w-full text-left`,"aria-pressed":n,onClick:()=>o({...r,path:r.path===e.path?void 0:e.path}),children:[(0,T.jsx)(`h3`,{className:`font-mono text-sm text-[var(--oke-fg)]`,children:e.path}),(0,T.jsx)(`p`,{className:`mt-1 text-sm text-[var(--oke-muted)]`,children:e.summary})]}),e.blastLine?(0,T.jsx)(`p`,{role:`status`,className:`mt-2 text-sm text-[var(--oke-fg)]`,children:e.blastLine}):e.runCountLastWeek>0&&e.flowName?(0,T.jsxs)(`p`,{className:`mt-2 text-sm text-[var(--oke-muted)]`,children:[`Ran `,e.runCountLastWeek.toLocaleString(`en-US`),` times last week`]}):null,e.weeklyBillLine?(0,T.jsxs)(`p`,{className:`mt-1 text-sm font-medium text-[var(--oke-fg)]`,children:[`Weekly bill: `,e.weeklyBillLine]}):null,t?(0,T.jsx)(`p`,{role:`status`,"data-ci-gate":e.ciGate??void 0,className:f(`mt-2 text-sm`,e.ciGate===`blocked`?`text-[var(--oke-fg)]`:`text-[var(--oke-muted)]`),children:t}):null]})},e.path)})})]},e.category))]})]})}function D(e){return(0,T.jsx)(`button`,{type:`button`,"aria-pressed":e.pressed,className:f(`min-h-8 px-2 text-xs`,e.pressed?`bg-[var(--oke-line)] text-[var(--oke-fg)]`:`text-[var(--oke-muted)]`),onClick:e.onClick,children:e.label})}var O=t({default:()=>E});export{m as i,C as n,g as r,O as t};