@kopai/app 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # @kopai/app
2
2
 
3
+ [![npm](https://img.shields.io/npm/v/@kopai/app?label=latest)](https://www.npmjs.com/package/@kopai/app)
4
+
3
5
  Local OpenTelemetry backend with an http/json Otel collector, Otel data storage and API to query the data.
4
6
 
5
7
  ## Quick Start
package/dist/cli.cjs CHANGED
@@ -10,6 +10,11 @@ const version = pkg.version;
10
10
 
11
11
  //#endregion
12
12
  //#region src/cli.ts
13
+ const originalEmit = process.emit;
14
+ process.emit = function(event, ...args) {
15
+ if (event === "warning" && args[0]?.name === "ExperimentalWarning" && args[0]?.message?.includes("SQLite")) return false;
16
+ return originalEmit.apply(this, [event, ...args]);
17
+ };
13
18
  const { values, positionals } = (0, node_util.parseArgs)({
14
19
  allowPositionals: true,
15
20
  options: {
@@ -53,7 +58,7 @@ if (values.help || command === "help" || !command) {
53
58
  showHelp();
54
59
  process.exit(0);
55
60
  }
56
- if (command === "start") Promise.resolve().then(() => require("./server-DTDkwqCT.cjs"));
61
+ if (command === "start") Promise.resolve().then(() => require("./server-C0Z3uYgw.cjs"));
57
62
  else {
58
63
  console.error(`Unknown command: ${command}`);
59
64
  showHelp();
package/dist/cli.mjs CHANGED
@@ -8,6 +8,11 @@ const version = pkg.version;
8
8
 
9
9
  //#endregion
10
10
  //#region src/cli.ts
11
+ const originalEmit = process.emit;
12
+ process.emit = function(event, ...args) {
13
+ if (event === "warning" && args[0]?.name === "ExperimentalWarning" && args[0]?.message?.includes("SQLite")) return false;
14
+ return originalEmit.apply(this, [event, ...args]);
15
+ };
11
16
  const { values, positionals } = parseArgs({
12
17
  allowPositionals: true,
13
18
  options: {
@@ -51,7 +56,7 @@ if (values.help || command === "help" || !command) {
51
56
  showHelp();
52
57
  process.exit(0);
53
58
  }
54
- if (command === "start") import("./server-YFpVoJ3q.mjs");
59
+ if (command === "start") import("./server-DOf6Bn7W.mjs");
55
60
  else {
56
61
  console.error(`Unknown command: ${command}`);
57
62
  showHelp();
package/dist/cli.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.mjs","names":[],"sources":["../src/version.ts","../src/cli.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\n\nconst require = createRequire(import.meta.url);\nconst pkg = require(\"../package.json\");\n\nexport const version: string = pkg.version;\n","#!/usr/bin/env node\nimport { parseArgs } from \"node:util\";\nimport { version } from \"./version.js\";\n\nconst { values, positionals } = parseArgs({\n allowPositionals: true,\n options: {\n help: { type: \"boolean\", short: \"h\" },\n version: { type: \"boolean\", short: \"v\" },\n },\n});\n\nconst command = positionals[0];\n\nfunction showHelp() {\n console.log(`\n|--k> kopai\nv${version} - OpenTelemetry collector and API server\n\nUsage: npx @kopai/app <command>\n\nCommands:\n start Start the server\n help Show this help message\n\nOptions:\n -h, --help Show this help message\n -v, --version Show version\n\nEnvironment:\n SQLITE_DB_FILE_PATH Path to SQLite database (default: :memory:)\n PORT API server port (default: 8000)\n HOST Host to bind (default: localhost)\n`);\n}\n\nif (values.version) {\n console.log(version);\n process.exit(0);\n}\n\nif (values.help || command === \"help\" || !command) {\n showHelp();\n process.exit(0);\n}\n\nif (command === \"start\") {\n import(\"./server.js\");\n} else {\n console.error(`Unknown command: ${command}`);\n showHelp();\n process.exit(1);\n}\n"],"mappings":";;;;;AAGA,MAAM,MADU,cAAc,OAAO,KAAK,IAAI,CAC1B,kBAAkB;AAEtC,MAAa,UAAkB,IAAI;;;;ACDnC,MAAM,EAAE,QAAQ,gBAAgB,UAAU;CACxC,kBAAkB;CAClB,SAAS;EACP,MAAM;GAAE,MAAM;GAAW,OAAO;GAAK;EACrC,SAAS;GAAE,MAAM;GAAW,OAAO;GAAK;EACzC;CACF,CAAC;AAEF,MAAM,UAAU,YAAY;AAE5B,SAAS,WAAW;AAClB,SAAQ,IAAI;;GAEX,QAAQ;;;;;;;;;;;;;;;;EAgBT;;AAGF,IAAI,OAAO,SAAS;AAClB,SAAQ,IAAI,QAAQ;AACpB,SAAQ,KAAK,EAAE;;AAGjB,IAAI,OAAO,QAAQ,YAAY,UAAU,CAAC,SAAS;AACjD,WAAU;AACV,SAAQ,KAAK,EAAE;;AAGjB,IAAI,YAAY,QACd,QAAO;KACF;AACL,SAAQ,MAAM,oBAAoB,UAAU;AAC5C,WAAU;AACV,SAAQ,KAAK,EAAE"}
1
+ {"version":3,"file":"cli.mjs","names":[],"sources":["../src/version.ts","../src/cli.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\n\nconst require = createRequire(import.meta.url);\nconst pkg = require(\"../package.json\");\n\nexport const version: string = pkg.version;\n","#!/usr/bin/env node\nconst originalEmit = process.emit;\n// @ts-expect-error - monkey-patch to suppress ExperimentalWarning for SQLite\nprocess.emit = function (event, ...args) {\n if (\n event === \"warning\" &&\n args[0]?.name === \"ExperimentalWarning\" &&\n args[0]?.message?.includes(\"SQLite\")\n )\n return false;\n return originalEmit.apply(this, [event, ...args]);\n};\n\nimport { parseArgs } from \"node:util\";\nimport { version } from \"./version.js\";\n\nconst { values, positionals } = parseArgs({\n allowPositionals: true,\n options: {\n help: { type: \"boolean\", short: \"h\" },\n version: { type: \"boolean\", short: \"v\" },\n },\n});\n\nconst command = positionals[0];\n\nfunction showHelp() {\n console.log(`\n|--k> kopai\nv${version} - OpenTelemetry collector and API server\n\nUsage: npx @kopai/app <command>\n\nCommands:\n start Start the server\n help Show this help message\n\nOptions:\n -h, --help Show this help message\n -v, --version Show version\n\nEnvironment:\n SQLITE_DB_FILE_PATH Path to SQLite database (default: :memory:)\n PORT API server port (default: 8000)\n HOST Host to bind (default: localhost)\n`);\n}\n\nif (values.version) {\n console.log(version);\n process.exit(0);\n}\n\nif (values.help || command === \"help\" || !command) {\n showHelp();\n process.exit(0);\n}\n\nif (command === \"start\") {\n import(\"./server.js\");\n} else {\n console.error(`Unknown command: ${command}`);\n showHelp();\n process.exit(1);\n}\n"],"mappings":";;;;;AAGA,MAAM,MADU,cAAc,OAAO,KAAK,IAAI,CAC1B,kBAAkB;AAEtC,MAAa,UAAkB,IAAI;;;;ACJnC,MAAM,eAAe,QAAQ;AAE7B,QAAQ,OAAO,SAAU,OAAO,GAAG,MAAM;AACvC,KACE,UAAU,aACV,KAAK,IAAI,SAAS,yBAClB,KAAK,IAAI,SAAS,SAAS,SAAS,CAEpC,QAAO;AACT,QAAO,aAAa,MAAM,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC;;AAMnD,MAAM,EAAE,QAAQ,gBAAgB,UAAU;CACxC,kBAAkB;CAClB,SAAS;EACP,MAAM;GAAE,MAAM;GAAW,OAAO;GAAK;EACrC,SAAS;GAAE,MAAM;GAAW,OAAO;GAAK;EACzC;CACF,CAAC;AAEF,MAAM,UAAU,YAAY;AAE5B,SAAS,WAAW;AAClB,SAAQ,IAAI;;GAEX,QAAQ;;;;;;;;;;;;;;;;EAgBT;;AAGF,IAAI,OAAO,SAAS;AAClB,SAAQ,IAAI,QAAQ;AACpB,SAAQ,KAAK,EAAE;;AAGjB,IAAI,OAAO,QAAQ,YAAY,UAAU,CAAC,SAAS;AACjD,WAAU;AACV,SAAQ,KAAK,EAAE;;AAGjB,IAAI,YAAY,QACd,QAAO;KACF;AACL,SAAQ,MAAM,oBAAoB,UAAU;AAC5C,WAAU;AACV,SAAQ,KAAK,EAAE"}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "index.html": {
3
- "file": "assets/index-oJZ3KchX.js",
3
+ "file": "assets/index-5oZTtMlU.js",
4
4
  "name": "index",
5
5
  "src": "index.html",
6
6
  "isEntry": true,
@@ -93,4 +93,4 @@ ${Mr(t.durationMs)}
93
93
  Status: ${l?"ERROR":"OK"}`,children:h.jsx("div",{className:"absolute inset-0",children:h.jsx("div",{className:"absolute top-1/2 -translate-y-1/2 h-2 rounded-sm cursor-pointer hover:opacity-80 transition-opacity",style:{left:`${u}%`,width:`max(2px, ${c}%)`,backgroundColor:i}})})})})}function vw(t){const r=t.attributes,o=r["http.method"],l=r["http.url"]||r["http.target"],i=r["http.status_code"];if(!o&&!l)return null;const u=[];return o&&u.push(String(o)),l&&u.push(String(l)),i&&u.push(`[${i}]`),u.join(" ")}const bw=D.memo(function({span:r,level:o,isCollapsed:l,isSelected:i,isParentOfHovered:u=!1,relativeStart:c,relativeDuration:m,onClick:v,onToggleCollapse:g,onMouseEnter:_,onMouseLeave:b}){const x=r.children.length>0,$=r.status==="ERROR",O=vw(r);return h.jsxs("div",{className:`flex h-8 border-b border-border hover:bg-muted cursor-pointer ${i?"bg-blue-100 dark:bg-blue-900/30 hover:bg-blue-100 dark:hover:bg-blue-900/30":""}`,onClick:v,onMouseEnter:_,onMouseLeave:b,role:"treeitem","aria-expanded":x?!l:void 0,"aria-selected":i,"aria-label":`${r.name}, ${r.serviceName}, ${Mr(r.durationMs)}${$?", error":""}`,"aria-level":o+1,children:[h.jsxs("div",{className:"flex items-center min-w-0 flex-shrink-0 w-96 px-2 relative z-10",children:[Array.from({length:o}).map((T,q)=>h.jsx("div",{className:`w-4 h-full border-l flex-shrink-0 ${u?"border-blue-500 border-l-2":"border-border"}`},q)),x?h.jsx("button",{className:"w-4 h-4 flex items-center justify-center flex-shrink-0 text-muted-foreground hover:text-foreground",onClick:T=>{T.stopPropagation(),g()},"aria-label":l?"Expand":"Collapse",children:l?h.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}):h.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})}):h.jsx("div",{className:"w-4 flex-shrink-0"}),$&&h.jsx("svg",{className:"w-4 h-4 text-red-500 flex-shrink-0 mr-1",fill:"currentColor",viewBox:"0 0 20 20",children:h.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})}),h.jsx("span",{className:"text-xs text-muted-foreground flex-shrink-0 mr-2",children:r.serviceName}),h.jsx("span",{className:"text-sm font-medium truncate flex-1 min-w-0 text-foreground",children:r.name}),x&&h.jsxs("span",{className:"text-xs text-muted-foreground flex-shrink-0 ml-1",children:["(",r.children.length,")"]}),O&&h.jsx("span",{className:"text-xs text-muted-foreground truncate ml-2 flex-shrink-0 max-w-xs",children:O}),h.jsx("span",{className:"text-xs text-muted-foreground flex-shrink-0 ml-2",children:Mr(r.durationMs)})]}),h.jsx("div",{className:"flex-1 min-w-0 px-2",children:h.jsx(gw,{span:r,relativeStart:c,relativeDuration:m})})]})});function Xa(t){return t==null?"null":typeof t=="string"?t:typeof t=="boolean"||typeof t=="number"?String(t):Array.isArray(t)||typeof t=="object"?JSON.stringify(t,null,2):String(t)}function qz(t){return typeof t=="object"&&t!==null&&(Array.isArray(t)||Object.keys(t).length>0)}const yw=new Set(["http.method","http.url","http.status_code","http.target","http.host","http.scheme","http.route","http.user_agent","http.request_content_length","http.response_content_length"]);function _w({span:t}){const{httpAttributes:r,otherAttributes:o,resourceAttributes:l}=D.useMemo(()=>{const i=[],u=[],c=[];return t.attributes&&Object.entries(t.attributes).forEach(([m,v])=>{yw.has(m)?i.push([m,v]):u.push([m,v])}),t.resourceAttributes&&Object.entries(t.resourceAttributes).forEach(([m,v])=>{c.push([m,v])}),i.sort(([m],[v])=>m.localeCompare(v)),u.sort(([m],[v])=>m.localeCompare(v)),c.sort(([m],[v])=>m.localeCompare(v)),{httpAttributes:i,otherAttributes:u,resourceAttributes:c}},[t]);return r.length>0||o.length>0||l.length>0?h.jsxs("div",{className:"space-y-6",children:[r.length>0&&h.jsxs("section",{children:[h.jsxs("h3",{className:"text-sm font-semibold text-foreground mb-3 flex items-center",children:[h.jsx("span",{className:"w-2 h-2 bg-blue-500 rounded-full mr-2"}),"HTTP Attributes"]}),h.jsx("div",{className:"space-y-2",children:r.map(([i,u])=>h.jsx(Df,{attrKey:i,value:u,highlighted:!0},i))})]}),o.length>0&&h.jsxs("section",{children:[h.jsx("h3",{className:"text-sm font-semibold text-foreground mb-3",children:"Span Attributes"}),h.jsx("div",{className:"space-y-2",children:o.map(([i,u])=>h.jsx(Df,{attrKey:i,value:u},i))})]}),l.length>0&&h.jsxs("section",{children:[h.jsx("h3",{className:"text-sm font-semibold text-foreground mb-3",children:"Resource Attributes"}),h.jsx("div",{className:"space-y-2",children:l.map(([i,u])=>h.jsx(Df,{attrKey:i,value:u},i))})]})]}):h.jsx("div",{className:"text-sm text-muted-foreground text-center py-8",children:"No attributes available"})}function Df({attrKey:t,value:r,highlighted:o}){const l=qz(r),i=Xa(r);return h.jsxs("div",{className:`grid grid-cols-[minmax(150px,1fr)_2fr] gap-4 p-2 rounded text-sm ${o?"bg-blue-50 dark:bg-blue-950 border-l-2 border-blue-500":"bg-muted"}`,children:[h.jsx("div",{className:`font-mono font-medium break-words ${o?"text-blue-700 dark:text-blue-300":"text-foreground"}`,title:t,children:t}),h.jsx("div",{className:"break-words",children:l?h.jsx("pre",{className:"text-xs text-foreground bg-background p-2 rounded border border-border overflow-x-auto",children:i}):h.jsx("span",{className:"text-foreground",children:i})})]})}function xw(t,r){const o=t-r;return`${o<0?"-":"+"}${Mr(Math.abs(o))}`}function Sw({span:t}){const[r,o]=D.useState(new Set),l=i=>{o(u=>{const c=new Set(u);return c.has(i)?c.delete(i):c.add(i),c})};return!t.events||t.events.length===0?h.jsx("div",{className:"text-sm text-muted-foreground text-center py-8",children:"No events available"}):h.jsx("div",{className:"space-y-3",children:t.events.map((i,u)=>{const c=r.has(u),m=i.attributes&&Object.keys(i.attributes).length>0,v=xw(i.timeUnixMs,t.startTimeUnixMs);return h.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[h.jsx("div",{className:"bg-muted p-3",children:h.jsxs("div",{className:"flex items-start justify-between gap-2",children:[h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("div",{className:"font-medium text-sm text-foreground truncate",children:i.name}),h.jsxs("div",{className:"text-xs text-muted-foreground mt-1 font-mono",children:[v," from span start"]})]}),m&&h.jsx("button",{onClick:()=>l(u),className:"p-1 hover:bg-muted/80 rounded transition-colors","aria-label":c?"Collapse attributes":"Expand attributes","aria-expanded":c,children:h.jsx("svg",{className:`w-4 h-4 text-muted-foreground transition-transform ${c?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]})}),m&&c&&h.jsxs("div",{className:"p-3 bg-background border-t border-border",children:[h.jsx("div",{className:"text-xs font-semibold text-foreground mb-2",children:"Attributes"}),h.jsx("div",{className:"space-y-2",children:Object.entries(i.attributes).map(([g,_])=>h.jsxs("div",{className:"grid grid-cols-[minmax(100px,1fr)_2fr] gap-3 text-xs",children:[h.jsx("div",{className:"font-mono font-medium text-foreground break-words",children:g}),h.jsx("div",{className:"text-foreground break-words",children:typeof _=="object"?h.jsx("pre",{className:"text-xs bg-muted p-2 rounded border border-border overflow-x-auto",children:Xa(_)}):h.jsx("span",{children:Xa(_)})})]},g))})]}),!m&&h.jsx("div",{className:"px-3 pb-3 text-xs text-muted-foreground italic",children:"No attributes"})]},u)})})}function r_(t){return t.length>8?`${t.substring(0,8)}...`:t}function $w({span:t,onLinkClick:r}){const[o,l]=D.useState(new Set),[i,u]=D.useState(null),c=v=>{l(g=>{const _=new Set(g);return _.has(v)?_.delete(v):_.add(v),_})},m=async(v,g,_)=>{try{await navigator.clipboard.writeText(v),u(`${g}-${_}-${v}`),setTimeout(()=>u(null),2e3)}catch(b){console.error("Failed to copy:",b)}};return!t.links||t.links.length===0?h.jsx("div",{className:"text-sm text-muted-foreground text-center py-8",children:"No links available"}):h.jsx("div",{className:"space-y-3",children:t.links.map((v,g)=>{const _=o.has(g),b=v.attributes&&Object.keys(v.attributes).length>0;return h.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[h.jsxs("div",{className:"bg-muted p-3",children:[h.jsxs("div",{className:"mb-2",children:[h.jsx("div",{className:"text-xs font-semibold text-muted-foreground mb-1",children:"Trace ID"}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("code",{className:"text-xs font-mono text-foreground bg-background px-2 py-1 rounded border border-border flex-1 truncate",title:v.traceId,children:r_(v.traceId)}),h.jsx("button",{onClick:()=>m(v.traceId,"trace",g),className:"p-1 hover:bg-muted/80 rounded transition-colors","aria-label":"Copy trace ID",children:h.jsx("svg",{className:`w-4 h-4 ${i===`trace-${g}-${v.traceId}`?"text-green-600":"text-muted-foreground"}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i===`trace-${g}-${v.traceId}`?h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"}):h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]})]}),h.jsxs("div",{className:"mb-2",children:[h.jsx("div",{className:"text-xs font-semibold text-muted-foreground mb-1",children:"Span ID"}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("code",{className:"text-xs font-mono text-foreground bg-background px-2 py-1 rounded border border-border flex-1 truncate",title:v.spanId,children:r_(v.spanId)}),h.jsx("button",{onClick:()=>m(v.spanId,"span",g),className:"p-1 hover:bg-muted/80 rounded transition-colors","aria-label":"Copy span ID",children:h.jsx("svg",{className:`w-4 h-4 ${i===`span-${g}-${v.spanId}`?"text-green-600":"text-muted-foreground"}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:i===`span-${g}-${v.spanId}`?h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"}):h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]})]}),r&&h.jsx("button",{onClick:()=>r(v.traceId,v.spanId),className:"w-full mt-2 px-3 py-2 bg-primary text-primary-foreground text-sm font-medium rounded hover:bg-primary/90 transition-colors",children:"Navigate to Span"}),b&&h.jsxs("button",{onClick:()=>c(g),className:"w-full mt-2 px-3 py-1.5 text-xs text-foreground bg-background border border-border rounded hover:bg-muted transition-colors flex items-center justify-center gap-1","aria-expanded":_,children:[h.jsxs("span",{children:[_?"Hide":"Show"," Attributes (",Object.keys(v.attributes).length,")"]}),h.jsx("svg",{className:`w-3 h-3 transition-transform ${_?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})]}),b&&_&&h.jsx("div",{className:"p-3 bg-background border-t border-border",children:h.jsx("div",{className:"space-y-2",children:Object.entries(v.attributes).map(([x,$])=>h.jsxs("div",{className:"grid grid-cols-[minmax(100px,1fr)_2fr] gap-3 text-xs",children:[h.jsx("div",{className:"font-mono font-medium text-foreground break-words",children:x}),h.jsx("div",{className:"text-foreground break-words",children:typeof $=="object"?h.jsx("pre",{className:"text-xs bg-muted p-2 rounded border border-border overflow-x-auto",children:Xa($)}):h.jsx("span",{children:Xa($)})})]},x))})})]},g)})})}function zw({span:t,onClose:r,onLinkClick:o,initialTab:l="attributes"}){const[i,u]=D.useState(l),[c,m]=D.useState(!1),v=D.useCallback(_=>{u(_)},[]),g=D.useCallback(async()=>{try{await navigator.clipboard.writeText(t.spanId),m(!0),setTimeout(()=>m(!1),2e3)}catch(_){console.error("Failed to copy span ID:",_)}},[t.spanId]);return h.jsxs("div",{className:"flex flex-col h-full bg-background border-l border-border",onKeyDown:D.useCallback(_=>{_.key==="Escape"&&r()},[r]),tabIndex:-1,role:"complementary","aria-label":"Span details",children:[h.jsxs("div",{className:"p-4 border-b border-border",children:[h.jsxs("div",{className:"flex items-center justify-between mb-3",children:[h.jsx("h2",{className:"text-lg font-semibold text-foreground truncate",children:"Span Details"}),h.jsx("button",{onClick:r,className:"p-1 hover:bg-muted rounded transition-colors","aria-label":"Close detail pane",title:"Close (Esc)",children:h.jsx("svg",{className:"w-5 h-5 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),h.jsx("div",{className:"mb-2",children:h.jsx("div",{className:"text-sm font-medium text-foreground truncate",title:t.name,children:t.name})}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-xs text-muted-foreground",children:"Span ID:"}),h.jsx("code",{className:"text-xs font-mono text-foreground bg-muted px-2 py-1 rounded flex-1 truncate",title:t.spanId,children:t.spanId}),h.jsx("button",{onClick:g,className:"p-1 hover:bg-muted rounded transition-colors","aria-label":"Copy span ID",children:h.jsx("svg",{className:`w-4 h-4 ${c?"text-green-600 dark:text-green-400":"text-muted-foreground"}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:c?h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"}):h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]})]}),h.jsx("div",{className:"flex border-b border-border",role:"tablist","aria-label":"Span detail tabs",children:["attributes","events","links"].map(_=>{const b=_==="attributes"?Object.keys(t.attributes).length:_==="events"?t.events.length:t.links.length;return h.jsxs("button",{role:"tab","aria-selected":i===_,onClick:()=>v(_),className:`px-4 py-2 text-sm font-medium transition-colors ${i===_?"text-blue-600 dark:text-blue-400 border-b-2 border-blue-600 dark:border-blue-400":"text-muted-foreground hover:text-foreground"}`,children:[_.charAt(0).toUpperCase()+_.slice(1),b>0&&h.jsxs("span",{className:"ml-1 text-xs text-muted-foreground",children:["(",b,")"]})]},_)})}),h.jsxs("div",{className:"flex-1 overflow-auto p-4",children:[i==="attributes"&&h.jsx(_w,{span:t}),i==="events"&&h.jsx(Sw,{span:t}),i==="links"&&h.jsx($w,{span:t,onLinkClick:o})]})]})}function Gz(){return h.jsxs("div",{className:"flex flex-col h-full bg-background animate-pulse",children:[h.jsxs("div",{className:"border-b border-border p-4",children:[h.jsx("div",{className:"h-4 bg-muted rounded w-1/4 mb-3"}),h.jsxs("div",{className:"flex gap-4",children:[h.jsx("div",{className:"h-3 bg-muted rounded w-32"}),h.jsx("div",{className:"h-3 bg-muted rounded w-24"}),h.jsx("div",{className:"h-3 bg-muted rounded w-20"})]})]}),h.jsx("div",{className:"flex-1 p-4 space-y-2",children:Array.from({length:15}).map((t,r)=>h.jsxs("div",{className:"flex items-start gap-3",children:[h.jsx("div",{className:"h-4 bg-muted rounded w-32"}),h.jsx("div",{className:"h-4 rounded w-16",style:{backgroundColor:r%4===0?"#ef4444":r%4===1?"#f97316":r%4===2?"#3b82f6":"#6b7280",opacity:.3}}),h.jsx("div",{className:"h-4 bg-muted rounded",style:{width:`${80+r*7%40}px`}}),h.jsx("div",{className:"h-4 bg-muted/80 rounded flex-1",style:{maxWidth:`${300+r*13%200}px`}})]},r))})]})}const a_=()=>{},Vz=D.createContext({register:a_,unregister:a_});function ap(t,r){const{register:o,unregister:l}=D.useContext(Vz);D.useEffect(()=>(o(t,r),()=>l(t)),[t,r,o,l])}function Ew({open:t,onClose:r,groups:o}){if(!t)return null;const l=i=>{i.key==="Escape"&&(i.stopPropagation(),r())};return h.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:r,onKeyDown:l,children:h.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Keyboard Shortcuts",className:"bg-zinc-900 border border-zinc-700 rounded-lg shadow-xl max-w-2xl w-full mx-4 max-h-[80vh] overflow-y-auto",onClick:i=>i.stopPropagation(),children:[h.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-zinc-700",children:[h.jsx("h2",{className:"text-lg font-semibold text-zinc-100",children:"Keyboard Shortcuts"}),h.jsx("button",{onClick:r,"aria-label":"Close",className:"text-zinc-400 hover:text-zinc-200 text-xl leading-none",children:"×"})]}),h.jsx("div",{className:"p-6 grid grid-cols-1 sm:grid-cols-2 gap-6",children:o.map(i=>h.jsxs("div",{children:[h.jsx("h3",{className:"text-sm font-medium text-zinc-400 mb-3",children:i.name}),h.jsx("ul",{className:"space-y-2",children:i.shortcuts.map(u=>h.jsxs("li",{className:"flex items-center justify-between text-sm",children:[h.jsx("span",{className:"text-zinc-300",children:u.description}),h.jsx("span",{className:"flex gap-1 ml-4",children:u.keys.map(c=>h.jsx("kbd",{className:"px-1.5 py-0.5 text-xs font-mono bg-zinc-800 border border-zinc-600 rounded text-zinc-300",children:c},c))})]},u.keys.join("+")))})]},i.name))})]})})}const Tw={name:"General",shortcuts:[{keys:["Shift","?"],description:"Toggle shortcuts help"},{keys:["Shift","S"],description:"Services tab"},{keys:["Shift","L"],description:"Logs tab"},{keys:["Shift","M"],description:"Metrics tab"}]};function kw({children:t,onNavigateServices:r,onNavigateLogs:o,onNavigateMetrics:l}){const[i,u]=D.useState(()=>new Map),[c,m]=D.useState(!1),v=D.useCallback((x,$)=>{u(O=>{const T=new Map(O);return T.set(x,$),T})},[]),g=D.useCallback(x=>{u($=>{const O=new Map($);return O.delete(x),O})},[]);D.useEffect(()=>{function x($){const O=$.target;if(!(O.tagName==="INPUT"||O.tagName==="TEXTAREA"||O.tagName==="SELECT"||O.isContentEditable)){if($.shiftKey&&$.key==="?"){$.preventDefault(),m(T=>!T);return}if($.key==="Escape"&&c){$.preventDefault(),m(!1);return}if($.shiftKey&&$.key==="S"){$.preventDefault(),r();return}if($.shiftKey&&$.key==="L"){$.preventDefault(),o();return}if($.shiftKey&&$.key==="M"){$.preventDefault(),l();return}}}return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[c,r,o,l]);const _=D.useMemo(()=>[Tw,...i.values()],[i]),b=D.useMemo(()=>({register:v,unregister:g}),[v,g]);return h.jsxs(Vz.Provider,{value:b,children:[t,h.jsx(Ew,{open:c,onClose:()=>m(!1),groups:_})]})}const Nw={name:"Trace Viewer",shortcuts:[{keys:["↑/K"],description:"Previous span"},{keys:["↓/J"],description:"Next span"},{keys:["←"],description:"Collapse span"},{keys:["→"],description:"Expand span"},{keys:["Enter"],description:"Focus detail pane"},{keys:["C"],description:"Copy span name"},{keys:["Esc"],description:"Deselect span"},{keys:["Ctrl","Shift","E"],description:"Expand all"},{keys:["Ctrl","Shift","C"],description:"Collapse all"}]};function jw(t){if(t.length===0)return null;const r=new Map;let o=1/0,l=-1/0,i="";for(const c of t){const m=parseInt(c.Timestamp,10)/1e6,v=(c.Duration?parseInt(c.Duration,10):0)/1e6,g=m+v,_=[],b=c["Events.Name"]??[],x=c["Events.Timestamp"]??[],$=c["Events.Attributes"]??[];for(let re=0;re<b.length;re++)_.push({timeUnixMs:x[re]?parseInt(x[re],10)/1e6:m,name:b[re]??"",attributes:$[re]??{}});const O=[],T=c["Links.TraceId"]??[],q=c["Links.SpanId"]??[],ne=c["Links.Attributes"]??[];for(let re=0;re<T.length;re++)O.push({traceId:T[re]??"",spanId:q[re]??"",attributes:ne[re]??{}});const te={spanId:c.SpanId,parentSpanId:c.ParentSpanId||void 0,traceId:c.TraceId,name:c.SpanName??"",startTimeUnixMs:m,endTimeUnixMs:g,durationMs:v,kind:c.SpanKind??"INTERNAL",status:c.StatusCode??"UNSET",statusMessage:c.StatusMessage,serviceName:c.ServiceName??"unknown",attributes:c.SpanAttributes??{},resourceAttributes:c.ResourceAttributes??{},events:_,links:O,children:[]};r.set(te.spanId,te),o=Math.min(o,m),l=Math.max(l,g),i||(i=te.traceId)}if(r.size===0)return null;const u=[];for(const[,c]of r){if(c.parentSpanId===c.spanId){u.push(c);continue}!c.parentSpanId||!r.has(c.parentSpanId)?u.push(c):r.get(c.parentSpanId).children.push(c)}for(const[,c]of r)c.children.sort((m,v)=>m.startTimeUnixMs-v.startTimeUnixMs);return u.sort((c,m)=>c.startTimeUnixMs-m.startTimeUnixMs),{traceId:i,rootSpans:u,minTimeMs:o,maxTimeMs:l,totalSpanCount:r.size}}function Ow(t,r,o){var u;const l=o.find(c=>c.span.spanId===r);if(!l)return!1;let i=l.span;for(;i!=null&&i.parentSpanId;){if(i.parentSpanId===t.spanId)return!0;i=(u=o.find(c=>c.span.spanId===i.parentSpanId))==null?void 0:u.span}return!1}function ww({rows:t,onSpanClick:r,selectedSpanId:o,isLoading:l,error:i}){var Ve;ap("trace-viewer",Nw);const[u,c]=D.useState(new Set),[m,v]=D.useState(null),[g,_]=D.useState(null),b=o??m,x=D.useRef(null),$=D.useRef(null),O=D.useMemo(()=>jw(t),[t]),T=D.useMemo(()=>O?fw(O.rootSpans,u):[],[O,u]),q=Rz({count:T.length,getScrollElement:()=>x.current,estimateSize:()=>32,overscan:5}),ne=ge=>{c(ce=>{const _e=new Set(ce);return _e.has(ge)?_e.delete(ge):_e.add(ge),_e})},te=D.useCallback(ge=>{v(ge.spanId),r==null||r(ge),$.current&&($.current.textContent=`Selected span: ${ge.name}, duration: ${Mr(ge.durationMs)}`)},[r]),re=D.useCallback(()=>{c(new Set)},[]),J=D.useCallback(()=>{O&&c(new Set(mw(O.rootSpans)))},[O]),X=D.useCallback(()=>{if(T.length===0)return;const ge=T.findIndex(ce=>ce.span.spanId===b);if(ge>0){const ce=T[ge-1];ce&&te(ce.span)}else if(ge===-1&&T.length>0){const ce=T[T.length-1];ce&&te(ce.span)}},[T,b,te]),oe=D.useCallback(()=>{if(T.length===0)return;const ge=T.findIndex(ce=>ce.span.spanId===b);if(ge>=0&&ge<T.length-1){const ce=T[ge+1];ce&&te(ce.span)}else if(ge===-1&&T.length>0){const ce=T[0];ce&&te(ce.span)}},[T,b,te]),ue=D.useCallback(ge=>{if(!b)return;const ce=T.find(_e=>_e.span.spanId===b);!ce||ce.span.children.length===0||c(ge?_e=>new Set([..._e,ce.span.spanId]):_e=>{const Ke=new Set(_e);return Ke.delete(ce.span.spanId),Ke})},[b,T]),pe=D.useCallback(()=>{v(null)},[]);if(D.useEffect(()=>{if(!b)return;const ge=T.findIndex(ce=>ce.span.spanId===b);ge!==-1&&q.scrollToIndex(ge,{align:"center",behavior:"smooth"})},[b,T,q]),D.useEffect(()=>{const ge=ce=>{var _e,Ke,R;if((Ke=(_e=x.current)==null?void 0:_e.parentElement)!=null&&Ke.contains(document.activeElement))switch(ce.key){case"ArrowUp":case"k":case"K":ce.preventDefault(),X();break;case"ArrowDown":case"j":case"J":ce.preventDefault(),oe();break;case"ArrowLeft":ce.preventDefault(),ue(!0);break;case"ArrowRight":ce.preventDefault(),ue(!1);break;case"Escape":ce.preventDefault(),pe();break;case"Enter":if(b){ce.preventDefault();const F=document.querySelector('[role="complementary"][aria-label="Span details"]');F&&(F.scrollIntoView({behavior:"smooth",block:"start"}),(R=F.focus)==null||R.call(F))}break;case"e":case"E":ce.ctrlKey&&ce.shiftKey&&(ce.preventDefault(),re());break;case"c":case"C":if(ce.ctrlKey&&ce.shiftKey)ce.preventDefault(),J();else if(!ce.ctrlKey&&!ce.metaKey){ce.preventDefault();const F=T.find(he=>he.span.spanId===b);F&&navigator.clipboard.writeText(F.span.name).catch(()=>{})}break}};return window.addEventListener("keydown",ge),()=>window.removeEventListener("keydown",ge)},[X,oe,ue,pe,re,J,b,T]),l)return h.jsx(Gz,{});if(i)return h.jsx("div",{className:"flex items-center justify-center h-64 bg-background",children:h.jsxs("div",{className:"text-red-600 dark:text-red-400",children:[h.jsx("div",{className:"font-semibold",children:"Error loading trace"}),h.jsx("div",{className:"text-sm",children:i.message})]})});if(t.length===0||!O)return h.jsx("div",{className:"flex items-center justify-center h-64 bg-background",children:h.jsx("div",{className:"text-muted-foreground",children:"No trace data available"})});const Ue=O.maxTimeMs-O.minTimeMs,fe=b&&T.length>0?(Ve=T.find(ge=>ge.span.spanId===b))==null?void 0:Ve.span:null;return h.jsxs("div",{className:"flex h-full bg-background",children:[h.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[h.jsx("div",{ref:$,className:"sr-only",role:"status","aria-live":"polite","aria-atomic":"true"}),h.jsx(hw,{trace:O}),h.jsx("div",{ref:x,className:"flex-1 overflow-auto outline-none",role:"tree","aria-label":"Trace timeline",tabIndex:0,children:h.jsx("div",{style:{height:`${q.getTotalSize()}px`,width:"100%",position:"relative"},children:q.getVirtualItems().map(ge=>{const ce=T[ge.index];if(!ce)return null;const{span:_e,level:Ke}=ce,R=u.has(_e.spanId),F=_e.spanId===b,he=_e.spanId===g,Ie=g?Ow(_e,g,T):!1,xe=sw(_e.startTimeUnixMs,O.minTimeMs,O.maxTimeMs),z=cw(_e.durationMs,Ue);return h.jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:`${ge.size}px`,transform:`translateY(${ge.start}px)`},children:h.jsx(bw,{span:_e,level:Ke,isCollapsed:R,isSelected:F,isHovered:he,isParentOfHovered:Ie,relativeStart:xe,relativeDuration:z,onClick:()=>te(_e),onToggleCollapse:()=>ne(_e.spanId),onMouseEnter:()=>_(_e.spanId),onMouseLeave:()=>_(null)})},_e.spanId)})})})]}),fe&&h.jsx("div",{className:"w-96 h-full flex-shrink-0",children:h.jsx(zw,{span:fe,onClose:pe,onLinkClick:void 0})})]})}function Dw({service:t,traceId:r,rows:o,isLoading:l,error:i,selectedSpanId:u,onSpanClick:c,onBack:m}){return h.jsxs("div",{children:[h.jsxs("div",{className:"flex items-center gap-1.5 text-sm text-muted-foreground mb-4",children:[h.jsxs("button",{onClick:m,className:"hover:text-foreground transition-colors",children:["Services / ",t]}),h.jsx("span",{children:"/"}),h.jsxs("span",{className:"text-foreground font-mono text-xs",children:[r.slice(0,16),"..."]})]}),h.jsx(ww,{rows:o,isLoading:l,error:i,selectedSpanId:u,onSpanClick:c})]})}function Uw(t){const r=new Date(t);return`${String(r.getHours()).padStart(2,"0")}:${String(r.getMinutes()).padStart(2,"0")}:${String(r.getSeconds()).padStart(2,"0")}.${String(r.getMilliseconds()).padStart(3,"0")}`}function Aw(t,r){const o=t-r,l=o>=0?"+":"-",i=Math.abs(o);return i<1e3?`${l}${i.toFixed(4)}ms`:i<6e4?`${l}${(i/1e3).toFixed(4)}s`:`${l}${Math.floor(i/6e4)}m${(i%6e4/1e3).toFixed(4)}s`}function o_(t,r=120){return t.length<=r?t:t.slice(0,r)+"..."}function Iw(t){const r=t.toUpperCase();return r==="FATAL"||r==="ERROR"?{text:"text-red-900 dark:text-red-100",bg:"bg-red-100 dark:bg-red-900/30"}:r==="WARN"||r==="WARNING"?{text:"text-orange-900 dark:text-orange-100",bg:"bg-orange-100 dark:bg-orange-900/30"}:r==="INFO"?{text:"text-blue-900 dark:text-blue-100",bg:"bg-blue-100 dark:bg-blue-900/30"}:r==="DEBUG"?{text:"text-gray-900 dark:text-gray-100",bg:"bg-gray-100 dark:bg-gray-700/30"}:r==="TRACE"?{text:"text-gray-700 dark:text-gray-300",bg:"bg-gray-50 dark:bg-gray-800/30"}:{text:"text-gray-600 dark:text-gray-400",bg:"bg-gray-50 dark:bg-gray-800/20"}}function Mw(t,r){if(!r||!t)return t;const o=[];let l=0;const i=r.toLowerCase(),u=t.toLowerCase();let c=u.indexOf(i);for(;c!==-1;){c>l&&o.push(t.slice(l,c));const m=t.slice(c,c+r.length);o.push(h.jsx("mark",{className:"bg-yellow-200 dark:bg-yellow-700 text-foreground",children:m},`${c}-${m}`)),l=c+r.length,c=u.indexOf(i,l)}return l<t.length&&o.push(t.slice(l)),o.length>0?h.jsx(h.Fragment,{children:o}):t}const Cw=D.memo(function({log:r,isSelected:o,onClick:l,searchText:i,relativeTime:u,referenceTimeMs:c}){const m=Iw(r.severityText),v=D.useMemo(()=>r.body||"",[r.body]),g=u&&c!=null?Aw(r.timeUnixMs,c):Uw(r.timeUnixMs),_=v.split(`
94
94
  `).length,b=_>1;return h.jsxs("div",{style:{contain:"layout style paint"},className:`flex items-center gap-3 px-4 h-[44px] border-b border-border cursor-pointer overflow-hidden outline-none ${o?"bg-blue-50 dark:bg-blue-900/30 border-l-4 border-l-blue-500":"hover:bg-muted"}`,onClick:l,role:"button",tabIndex:0,onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),l())},children:[h.jsx("div",{className:"flex-shrink-0 w-28 font-mono text-xs text-muted-foreground",children:g}),h.jsx("div",{className:`flex-shrink-0 w-24 text-xs font-semibold px-2 py-0.5 rounded truncate ${m.bg} ${m.text}`,children:r.severityText}),h.jsx("div",{className:"flex-shrink-0 w-32 text-xs truncate",style:{color:ol(r.serviceName)},children:r.serviceName}),h.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:[h.jsx("div",{className:"text-sm text-foreground truncate",children:i?Mw(o_(v.split(`
95
95
  `)[0]||"",100),i):o_(v.split(`
96
- `)[0]||"",100)}),b&&h.jsxs("span",{className:"flex-shrink-0 text-xs text-muted-foreground",children:["+",_-1," lines"]}),r.traceId&&h.jsxs("span",{className:"flex-shrink-0 text-xs text-indigo-600 dark:text-indigo-400",children:["trace: ",r.traceId.slice(0,16),"..."]})]})]})});function Rw({log:t}){const r=D.useMemo(()=>Object.entries(t.attributes).sort(([o],[l])=>o.localeCompare(l)),[t.attributes]);return r.length===0?h.jsx("div",{className:"text-sm text-muted-foreground text-center py-8",children:"No attributes available"}):h.jsx("div",{className:"space-y-2",children:r.map(([o,l])=>{const i=qz(l),u=Xa(l);return h.jsxs("div",{className:"p-2 rounded bg-muted",children:[h.jsx("div",{className:"font-mono font-medium text-xs text-foreground mb-1",title:o,children:o}),h.jsx("div",{children:i?h.jsx("pre",{className:"text-xs text-foreground bg-background p-2 rounded border border-border overflow-x-auto",children:u}):h.jsx("span",{className:"text-sm text-foreground break-words",children:u})})]},o)})})}function Zw({data:t,level:r=0}){return h.jsx("div",{className:"font-mono text-sm",children:Array.isArray(t)?h.jsx(Yz,{items:t,level:r}):h.jsx(Kz,{obj:t,level:r})})}function Kz({obj:t,level:r}){const o=Object.entries(t);return o.length===0?h.jsx("span",{className:"text-muted-foreground",children:"{}"}):h.jsx("div",{children:o.map(([l,i])=>h.jsx(Jz,{objKey:l,value:i,level:r},l))})}function Yz({items:t,level:r}){return t.length===0?h.jsx("span",{className:"text-muted-foreground",children:"[]"}):h.jsx("div",{children:t.map((o,l)=>h.jsx(Jz,{objKey:String(l),value:o,level:r,isArrayItem:!0},l))})}function Jz({objKey:t,value:r,level:o,isArrayItem:l=!1}){const[i,u]=D.useState(o<2),c=r!==null&&typeof r=="object"&&(Array.isArray(r)?r.length>0:Object.keys(r).length>0),m=o*16;return c?h.jsxs("div",{children:[h.jsxs("div",{style:{paddingLeft:`${m}px`},className:"py-0.5 hover:bg-muted cursor-pointer",onClick:()=>u(!i),children:[h.jsx("span",{className:"inline-block w-4 text-muted-foreground",children:i?"▼":"▶"}),!l&&h.jsxs("span",{className:"text-blue-600 dark:text-blue-400",children:[t,": "]}),h.jsx("span",{className:"text-muted-foreground",children:Array.isArray(r)?`Array(${r.length})`:`Object(${Object.keys(r).length})`})]}),i&&h.jsx("div",{children:Array.isArray(r)?h.jsx(Yz,{items:r,level:o+1}):h.jsx(Kz,{obj:r,level:o+1})})]}):h.jsxs("div",{style:{paddingLeft:`${m}px`},className:"py-0.5 hover:bg-muted",children:[!l&&h.jsxs("span",{className:"text-blue-600 dark:text-blue-400",children:[t,": "]}),h.jsx("span",{className:"text-foreground",children:Lw(r)})]})}function Lw(t){return t===null?"null":t===void 0?"undefined":typeof t=="string"?`"${t}"`:typeof t=="boolean"?t?"true":"false":String(t)}function Bw({log:t,onClose:r,onTraceLinkClick:o,initialTab:l="message",wordWrap:i=!0}){const u=!!t.traceId,[c,m]=D.useState(l==="context"&&!u?"message":l),[v,g]=D.useState(!1),_=D.useRef(null),b=D.useCallback(async()=>{try{await navigator.clipboard.writeText(t.logId),g(!0),setTimeout(()=>g(!1),2e3)}catch(O){console.error("Failed to copy log ID:",O)}},[t.logId]),x=D.useCallback(O=>{O.key==="Escape"&&r()},[r]);D.useEffect(()=>{var O;(O=_.current)==null||O.focus()},[]);const $=Hw(t.severityText);return h.jsxs("div",{ref:_,className:"w-[500px] flex flex-col h-full bg-background border-l border-border outline-none",onKeyDown:x,role:"complementary","aria-label":"Log details",tabIndex:-1,children:[h.jsxs("div",{className:"p-4 border-b border-border",children:[h.jsxs("div",{className:"flex items-center justify-between mb-3",children:[h.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"Log Details"}),h.jsx("button",{onClick:r,className:"p-2 hover:bg-muted rounded transition-colors","aria-label":"Close detail pane",children:h.jsx("svg",{className:"w-6 h-6 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),h.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[h.jsx("div",{className:`text-xs font-semibold px-2 py-0.5 rounded ${$.bg} ${$.text}`,children:t.severityText}),h.jsx("div",{className:"text-sm text-muted-foreground",children:t.serviceName})]}),h.jsx("div",{className:"text-xs font-medium text-muted-foreground mt-3 mb-1",children:"Timestamp"}),h.jsx("div",{className:"text-xs text-foreground font-mono",children:new Date(t.timeUnixMs).toISOString()}),h.jsx("div",{className:"text-xs font-medium text-muted-foreground mt-3 mb-1",children:"Log ID"}),h.jsx("div",{className:"flex items-center gap-2",children:h.jsxs("button",{onClick:b,className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground font-mono bg-muted px-2 py-1 rounded",title:"Click to copy log ID",children:[h.jsx("span",{className:"truncate max-w-[200px]",children:t.logId}),h.jsx("svg",{className:"w-3 h-3 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:v?h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"}):h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})]})})]}),h.jsx("div",{className:"flex border-b border-border",children:["message","attributes","resource",...t.traceId?["context"]:[]].map(O=>h.jsx("button",{onClick:()=>m(O),className:`px-4 py-2 text-sm font-medium transition-colors ${c===O?"text-blue-600 dark:text-blue-400 border-b-2 border-blue-600 dark:border-blue-400":"text-muted-foreground hover:text-foreground"}`,children:O==="context"?"Trace":O.charAt(0).toUpperCase()+O.slice(1)},O))}),h.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[c==="message"&&h.jsx("pre",{className:`text-sm text-foreground font-mono bg-muted p-3 rounded ${i?"whitespace-pre-wrap break-words":"whitespace-pre overflow-x-auto"}`,children:t.body||"No message body"}),c==="attributes"&&h.jsx(Rw,{log:t}),c==="resource"&&h.jsxs("div",{children:[h.jsxs("div",{className:"mb-3",children:[h.jsx("div",{className:"text-sm font-semibold text-foreground mb-2",children:"Service Name"}),h.jsx("div",{className:"text-sm text-foreground bg-muted p-2 rounded font-mono",children:t.serviceName})]}),t.scopeName&&h.jsxs("div",{className:"mb-3",children:[h.jsx("div",{className:"text-sm font-semibold text-foreground mb-2",children:"Scope Name"}),h.jsx("div",{className:"text-sm text-foreground bg-muted p-2 rounded font-mono",children:t.scopeName})]}),h.jsxs("div",{children:[h.jsx("div",{className:"text-sm font-semibold text-foreground mb-2",children:"Resource Attributes"}),Object.keys(t.resourceAttributes).length>0?h.jsx(Zw,{data:t.resourceAttributes}):h.jsx("div",{className:"text-sm text-muted-foreground text-center py-4",children:"No resource attributes"})]})]}),c==="context"&&t.traceId&&h.jsxs("div",{className:"space-y-3",children:[h.jsxs("div",{children:[h.jsx("div",{className:"text-sm font-semibold text-foreground mb-2",children:"Trace ID"}),h.jsx("div",{className:"text-sm text-foreground bg-muted p-2 rounded font-mono break-all",children:t.traceId})]}),t.spanId&&h.jsxs("div",{children:[h.jsx("div",{className:"text-sm font-semibold text-foreground mb-2",children:"Span ID"}),h.jsx("div",{className:"text-sm text-foreground bg-muted p-2 rounded font-mono break-all",children:t.spanId})]}),o&&t.spanId&&h.jsx("button",{onClick:()=>o(t.traceId,t.spanId),className:"w-full px-4 py-2 bg-blue-600 dark:bg-blue-500 text-white rounded hover:bg-blue-700 dark:hover:bg-blue-600 transition-colors text-sm",children:"View Trace"})]})]})]})}function Hw(t){const r=t.toUpperCase();return r==="FATAL"||r==="ERROR"?{text:"text-red-900 dark:text-red-100",bg:"bg-red-100 dark:bg-red-900/30"}:r==="WARN"||r==="WARNING"?{text:"text-orange-900 dark:text-orange-100",bg:"bg-orange-100 dark:bg-orange-900/30"}:r==="INFO"?{text:"text-blue-900 dark:text-blue-100",bg:"bg-blue-100 dark:bg-blue-900/30"}:r==="DEBUG"?{text:"text-gray-900 dark:text-gray-100",bg:"bg-gray-100 dark:bg-gray-700/30"}:{text:"text-gray-600 dark:text-gray-400",bg:"bg-gray-50 dark:bg-gray-800/20"}}const qw={name:"Log Viewer",shortcuts:[{keys:["↑/K"],description:"Previous log"},{keys:["↓/J"],description:"Next log"},{keys:["G"],description:"Scroll to bottom"},{keys:["Home"],description:"First log"},{keys:["/"],description:"Focus search"},{keys:["F"],description:"Toggle filters"},{keys:["Enter"],description:"Open log detail"},{keys:["C"],description:"Copy log body"},{keys:["W"],description:"Toggle word wrap"},{keys:["T"],description:"Toggle timestamps"},{keys:["Esc"],description:"Close detail/filter pane"}]},l_=44,Gw=20,Vw=1e3,Kw=50,Yw={position:"absolute",top:0,left:0,width:"100%"};function Jw(t){let r=0;for(let o=0;o<t.length;o++){const l=t.charCodeAt(o);r=(r<<5)-r+l,r=r&r}return Math.abs(r).toString(36)}function Qw(t,r){if(r)return r;const o=t??0;return o>=21?"FATAL":o>=17?"ERROR":o>=13?"WARN":o>=9?"INFO":o>=5?"DEBUG":o>=1?"TRACE":"UNSPECIFIED"}function Xw(t){return t.map(r=>{const o=parseInt(r.Timestamp,10)/1e6,l=r.Body??"",i=Qw(r.SeverityNumber,r.SeverityText);return{logId:`${r.Timestamp}-${r.ServiceName??"unknown"}-${Jw(l)}`,timeUnixMs:o,body:l,severityText:i,severityNumber:r.SeverityNumber??0,serviceName:r.ServiceName??"unknown",traceId:r.TraceId,spanId:r.SpanId,attributes:r.LogAttributes??{},resourceAttributes:r.ResourceAttributes??{},scopeName:r.ScopeName}}).sort((r,o)=>r.timeUnixMs-o.timeUnixMs)}function Fw({rows:t,onLogClick:r,onTraceLinkClick:o,selectedLogId:l,isLoading:i,error:u,streaming:c=!1,maxLogs:m=Vw,searchText:v="",onAtBottomChange:g}){ap("log-viewer",qw);const[_,b]=D.useState(null),[x,$]=D.useState(!1),[O,T]=D.useState(!0),[q,ne]=D.useState(!0),[te,re]=D.useState(!1),J=l??_,X=D.useRef(null),oe=D.useRef(null),ue=D.useRef(!0),pe=D.useRef(!1),Ue=D.useMemo(()=>Xw(t),[t]),fe=D.useMemo(()=>c&&Ue.length>m?Ue.slice(Ue.length-m):Ue,[Ue,c,m]),Ve=D.useMemo(()=>fe.find(B=>B.logId===J)??null,[fe,J]),ge=D.useMemo(()=>{if(Ve)return Ve.timeUnixMs;const B=fe[0];return B?B.timeUnixMs:0},[Ve,fe]);D.useEffect(()=>{l&&$(!0)},[l]);const ce=D.useCallback(()=>{if(!X.current)return!0;const{scrollTop:B,scrollHeight:K,clientHeight:be}=X.current;return K<=be?!0:K-B-be<Kw},[]),_e=D.useRef(!0),Ke=D.useCallback(()=>{const B=ce();ue.current=B,T(B),B!==_e.current&&(_e.current=B,g==null||g(B))},[ce,g]);D.useEffect(()=>{const B=ce();ue.current=B,T(B)},[fe.length,ce]),D.useEffect(()=>{c&&ue.current&&X.current&&(X.current.scrollTop=X.current.scrollHeight)},[fe,c]);const R=Rz({count:fe.length,getScrollElement:()=>X.current,estimateSize:()=>l_,overscan:Gw});D.useEffect(()=>{if(pe.current||!l||fe.length===0)return;const B=fe.findIndex(K=>K.logId===l);B!==-1&&(pe.current=!0,R.scrollToIndex(B,{align:"center"}))},[l,fe,R]);const F=D.useCallback(B=>{b(B.logId),$(!0),r==null||r(B),oe.current&&(oe.current.textContent=`Selected log from ${B.serviceName}: ${B.body.slice(0,100)}`)},[r]),he=D.useMemo(()=>{const B=new Map;return fe.forEach(K=>{B.set(K.logId,()=>F(K))}),B},[fe,F]),Ie=D.useCallback(()=>{$(!1),b(null)},[]),xe=D.useCallback(()=>{X.current&&(X.current.scrollTop=X.current.scrollHeight,ue.current=!0,T(!0),_e.current||(_e.current=!0,g==null||g(!0)))},[g]),z=D.useCallback(()=>{const B=fe.findIndex(K=>K.logId===J);if(B>0){const K=fe[B-1];K&&(F(K),R.scrollToIndex(B-1,{align:"auto"}))}else if(B===-1&&fe.length>0){const K=fe.length-1,be=fe[K];be&&(F(be),R.scrollToIndex(K,{align:"auto"}))}},[fe,J,F,R]),G=D.useCallback(()=>{const B=fe.findIndex(K=>K.logId===J);if(B>=0&&B<fe.length-1){const K=fe[B+1];K&&(F(K),R.scrollToIndex(B+1,{align:"auto"}))}else if(B===-1&&fe.length>0){const K=fe[0];K&&(F(K),R.scrollToIndex(0,{align:"auto"}))}},[fe,J,F,R]);return D.useEffect(()=>{const B=K=>{var je;const be=K.target instanceof HTMLInputElement||K.target instanceof HTMLTextAreaElement||K.target instanceof HTMLSelectElement;if(be&&K.key==="Escape"){K.target.blur();return}if(!be)switch(K.key){case"ArrowUp":case"k":case"K":K.preventDefault(),z();break;case"ArrowDown":case"j":case"J":K.preventDefault(),G();break;case"Escape":if(x)K.preventDefault(),Ie();else{const ye=document.querySelector('[data-testid="log-filter"]'),Q=ye==null?void 0:ye.querySelector('[data-testid="log-filter-toggle"]');Q&&(ye!=null&&ye.querySelector(".border-t"))&&(K.preventDefault(),Q.click())}break;case"g":case"G":K.preventDefault(),xe();break;case"/":{K.preventDefault();const ye=document.querySelector('[data-testid="filter-bodyContains"]');if(ye){const Q=document.querySelector('[data-testid="log-filter"]'),Te=Q==null?void 0:Q.querySelector('[data-testid="log-filter-toggle"]');Te&&!(Q!=null&&Q.querySelector(".border-t"))?(Te.click(),requestAnimationFrame(()=>{var Rt;(Rt=document.querySelector('[data-testid="filter-bodyContains"]'))==null||Rt.focus()})):ye.focus()}break}case"f":case"F":K.preventDefault(),(je=document.querySelector('[data-testid="log-filter-toggle"]'))==null||je.click();break;case"Enter":if(J&&!x){K.preventDefault();const ye=fe.find(Q=>Q.logId===J);ye&&F(ye)}break;case"Home":if(K.preventDefault(),fe.length>0){const ye=fe[0];ye&&(F(ye),R.scrollToIndex(0))}break;case"c":case"C":if(K.ctrlKey||K.metaKey)break;K.preventDefault(),Ve&&navigator.clipboard.writeText(Ve.body).catch(()=>{});break;case"w":case"W":K.preventDefault(),ne(ye=>!ye);break;case"t":case"T":K.preventDefault(),re(ye=>!ye);break}};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[fe,J,Ve,z,G,F,Ie,xe,x,R]),i&&!fe.length?h.jsx(Gz,{}):u?h.jsx("div",{className:"flex items-center justify-center h-full bg-background",children:h.jsxs("div",{className:"text-center p-6",children:[h.jsx("div",{className:"text-red-600 dark:text-red-400 mb-2",children:"Failed to load logs"}),h.jsx("div",{className:"text-sm text-muted-foreground",children:u.message})]})}):fe.length===0?h.jsx("div",{className:"flex items-center justify-center h-full bg-background",children:h.jsxs("div",{className:"text-center p-6",children:[h.jsx("div",{className:"text-muted-foreground mb-2",children:"No logs"}),h.jsx("div",{className:"text-sm text-muted-foreground",children:c?"Waiting for logs...":"No log data available"})]})}):h.jsxs("div",{className:"flex flex-col h-full min-h-0 bg-background",children:[h.jsx("div",{ref:oe,className:"sr-only",role:"status","aria-live":"polite","aria-atomic":"true"}),h.jsxs("div",{className:"flex flex-1 min-h-0",children:[h.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[h.jsx("div",{className:"border-b border-border px-4 py-3",children:h.jsx("div",{className:"flex items-center justify-between",children:h.jsx("div",{className:"flex items-center gap-2",children:h.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 bg-muted rounded-md text-sm font-medium text-muted-foreground",children:[h.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h7"})}),fe.length," ",fe.length===1?"log":"logs"]})})})}),h.jsxs("div",{className:"flex-1 relative",children:[h.jsx("div",{ref:X,className:"absolute inset-0 overflow-auto",onScroll:Ke,children:h.jsx("div",{style:{height:`${R.getTotalSize()}px`,width:"100%",position:"relative"},children:R.getVirtualItems().map(B=>{const K=fe[B.index];return K?h.jsx("div",{style:{...Yw,height:l_,transform:`translateY(${B.start}px)`},children:h.jsx(Cw,{log:K,isSelected:K.logId===J,onClick:he.get(K.logId),searchText:v,relativeTime:te,referenceTimeMs:ge})},B.index):null})})}),!O&&h.jsx("button",{onClick:xe,className:"absolute bottom-4 right-4 px-3 py-1.5 text-xs font-medium rounded-md bg-primary hover:bg-primary/90 text-primary-foreground shadow-lg transition-colors z-10","aria-label":"Scroll to bottom",children:h.jsxs("span",{className:"flex items-center gap-1",children:[h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3",children:h.jsx("path",{fillRule:"evenodd",d:"M8 2a.75.75 0 0 1 .75.75v8.69l3.22-3.22a.75.75 0 1 1 1.06 1.06l-4.5 4.5a.75.75 0 0 1-1.06 0l-4.5-4.5a.75.75 0 0 1 1.06-1.06l3.22 3.22V2.75A.75.75 0 0 1 8 2Z",clipRule:"evenodd"})}),"(",h.jsx("span",{className:"underline underline-offset-4",children:"G"}),")"]})})]})]}),x&&Ve&&h.jsx(Bw,{log:Ve,onClose:Ie,onTraceLinkClick:o,wordWrap:q})]})]})}const u_=[{label:"Last 5 Minutes",ms:5*6e4},{label:"Last 15 Minutes",ms:15*6e4},{label:"Last 30 Minutes",ms:30*6e4},{label:"Last 1 Hour",ms:60*6e4},{label:"Last 2 Hours",ms:120*6e4},{label:"Last 6 Hours",ms:360*6e4},{label:"Last 12 Hours",ms:720*6e4},{label:"Last 24 Hours",ms:1440*6e4}],Ta=500;function Uf(t){return String(BigInt(Math.floor(t))*1000000n)}function ka(t){const r={};let o=!1;for(const l of t.split(",")){const i=l.trim();if(!i)continue;const u=i.indexOf("=");if(u<1)continue;const c=i.slice(0,u).trim(),m=i.slice(u+1).trim();c&&(r[c]=m,o=!0)}return o?r:void 0}function s_(t){if(!t)return"";const r=Number(BigInt(t)/1000000n),o=new Date(r),l=i=>String(i).padStart(2,"0");return`${o.getFullYear()}-${l(o.getMonth()+1)}-${l(o.getDate())}T${l(o.getHours())}:${l(o.getMinutes())}`}function Pw(t,r){const o=[];return r.length===1?o.push(`service:${r[0]}`):r.length>1&&o.push(`services:${r.length}`),t.severityText&&o.push(`severity:${t.severityText}`),t.scopeName&&o.push(`scope:${t.scopeName}`),t.bodyContains&&o.push(`body:"${t.bodyContains}"`),t.traceId&&o.push(`trace:${t.traceId.slice(0,8)}…`),t.spanId&&o.push(`span:${t.spanId.slice(0,8)}…`),t.limit!=null&&o.push(`limit:${t.limit}`),t.sortOrder==="ASC"&&o.push("sort:oldest"),o.join(" | ")}const Yt="w-full bg-muted/50 border border-border rounded px-2 py-1.5 text-sm text-foreground placeholder:text-muted-foreground/50",Kt="text-xs text-muted-foreground";function Na(t,r){const[o,l]=D.useState(t);return D.useEffect(()=>{const i=setTimeout(()=>l(t),r);return()=>clearTimeout(i)},[t,r]),o}function Ww({options:t,selected:r,onChange:o,testId:l}){const[i,u]=D.useState(!1),c=D.useRef(null);D.useEffect(()=>{if(!i)return;const g=_=>{c.current&&!c.current.contains(_.target)&&u(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[i]);const m=g=>{r.includes(g)?o(r.filter(_=>_!==g)):o([...r,g])},v=r.length===0?"All":r.length===1?r[0]:`${r.length} selected`;return h.jsxs("div",{ref:c,className:"relative","data-testid":l,children:[h.jsxs("button",{type:"button",onClick:()=>u(g=>!g),className:`${Yt} text-left flex items-center justify-between`,"data-testid":l?`${l}-trigger`:void 0,children:[h.jsx("span",{className:"truncate",children:v}),h.jsx("span",{className:"text-muted-foreground text-xs ml-1",children:i?"▲":"▼"})]}),i&&h.jsxs("div",{className:"absolute z-10 mt-1 w-full bg-background border border-border rounded shadow-lg max-h-48 overflow-y-auto","data-testid":l?`${l}-dropdown`:void 0,children:[t.length===0&&h.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"No options"}),t.map(g=>h.jsxs("label",{className:"flex items-center gap-2 px-2 py-1.5 hover:bg-muted/30 cursor-pointer text-sm",children:[h.jsx("input",{type:"checkbox",checked:r.includes(g),onChange:()=>m(g),className:"accent-foreground","data-testid":l?`${l}-option-${g}`:void 0}),h.jsx("span",{className:"truncate",children:g})]},g)),r.length>0&&h.jsx("button",{type:"button",onClick:()=>o([]),className:"w-full px-2 py-1.5 text-xs text-muted-foreground hover:bg-muted/30 border-t border-border","data-testid":l?`${l}-clear`:void 0,children:"Clear all"})]})]})}function e6({value:t,onChange:r,rows:o=[],selectedServices:l=[],onSelectedServicesChange:i}){const[u,c]=D.useState(!1),[m,v]=D.useState("lookback"),[g,_]=D.useState(-1),b=D.useRef(new Set),x=D.useRef(new Set),$=D.useRef(new Set),O=D.useMemo(()=>{for(const Q of o)Q.ServiceName&&b.current.add(Q.ServiceName);return Array.from(b.current).sort()},[o]),T=D.useMemo(()=>{for(const Q of o)Q.SeverityText&&x.current.add(Q.SeverityText);return Array.from(x.current).sort()},[o]),q=D.useMemo(()=>{for(const Q of o)Q.ScopeName&&$.current.add(Q.ScopeName);return Array.from($.current).sort()},[o]),[ne,te]=D.useState(t.bodyContains??""),[re,J]=D.useState(t.traceId??""),[X,oe]=D.useState(t.spanId??""),[ue,pe]=D.useState(""),[Ue,fe]=D.useState(""),[Ve,ge]=D.useState(""),ce=Na(ne,Ta),_e=Na(re,Ta),Ke=Na(X,Ta),R=Na(ue,Ta),F=Na(Ue,Ta),he=Na(Ve,Ta),Ie=D.useRef(!0);D.useEffect(()=>{if(Ie.current){Ie.current=!1;return}const Q={...t};ce?Q.bodyContains=ce:delete Q.bodyContains,_e?Q.traceId=_e:delete Q.traceId,Ke?Q.spanId=Ke:delete Q.spanId;const Te=ka(R);Te?Q.logAttributes=Te:delete Q.logAttributes;const Rt=ka(F);Rt?Q.resourceAttributes=Rt:delete Q.resourceAttributes;const Mn=ka(he);Mn?Q.scopeAttributes=Mn:delete Q.scopeAttributes,r(Q)},[ce,_e,Ke,R,F,he]);const xe=D.useCallback(Q=>{const Te={...t};for(const[Wa,jn]of Object.entries(Q))jn===void 0||jn===""?delete Te[Wa]:Te[Wa]=jn;ce&&(Te.bodyContains=ce),_e&&(Te.traceId=_e),Ke&&(Te.spanId=Ke);const Rt=ka(R);Rt&&(Te.logAttributes=Rt);const Mn=ka(F);Mn&&(Te.resourceAttributes=Mn);const Zr=ka(he);Zr&&(Te.scopeAttributes=Zr),r(Te)},[t,r,ce,_e,Ke,R,F,he]),z=D.useRef(xe);z.current=xe;const G=D.useCallback(Q=>{i==null||i(Q),Q.length===1?z.current({serviceName:Q[0]}):z.current({serviceName:void 0})},[i]),B=D.useCallback(Q=>{if(_(Q),Q<0)xe({timestampMin:void 0,timestampMax:void 0});else{const Te=u_[Q];Te&&xe({timestampMin:Uf(Date.now()-Te.ms),timestampMax:void 0})}},[xe]),K=D.useCallback(Q=>{if(!Q){xe({timestampMin:void 0});return}xe({timestampMin:Uf(new Date(Q).getTime())})},[xe]),be=D.useCallback(Q=>{if(!Q){xe({timestampMax:void 0});return}xe({timestampMax:Uf(new Date(Q).getTime())})},[xe]),je=D.useCallback(Q=>{v(Q),_(-1),xe({timestampMin:void 0,timestampMax:void 0})},[xe]),ye=Pw(t,l);return h.jsxs("div",{className:"border border-border rounded-lg","data-testid":"log-filter",children:[h.jsxs("button",{onClick:()=>c(Q=>!Q),className:"w-full flex items-center justify-between px-4 py-2.5 text-sm font-medium text-foreground hover:bg-muted/30 transition-colors","data-testid":"log-filter-toggle",children:[h.jsxs("span",{className:"flex items-center gap-2",children:[h.jsxs("span",{children:[h.jsx("span",{className:"underline underline-offset-4",children:"F"}),"ilters"]}),!u&&ye&&h.jsx("span",{className:"text-xs text-muted-foreground truncate max-w-md","data-testid":"filter-summary",children:ye})]}),h.jsx("span",{className:"text-muted-foreground text-xs",children:u?"▲":"▼"})]}),u&&h.jsxs("div",{className:"px-4 pb-4 pt-1 border-t border-border space-y-3",children:[h.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3",children:[h.jsxs("div",{className:"space-y-1",children:[h.jsx("span",{className:Kt,children:"Service"}),h.jsx(Ww,{options:O,selected:l,onChange:G,testId:"filter-serviceName"})]}),h.jsxs("label",{className:"space-y-1",children:[h.jsx("span",{className:Kt,children:"Severity"}),h.jsxs("select",{value:t.severityText??"",onChange:Q=>xe({severityText:Q.target.value||void 0}),className:Yt,"data-testid":"filter-severityText",children:[h.jsx("option",{value:"",children:"All"}),T.map(Q=>h.jsx("option",{value:Q,children:Q},Q))]})]}),h.jsxs("label",{className:"space-y-1",children:[h.jsx("span",{className:Kt,children:"Body contains"}),h.jsx("input",{type:"text",placeholder:"Search log body... (/)",value:ne,onChange:Q=>te(Q.target.value),className:Yt,"data-testid":"filter-bodyContains"})]}),h.jsxs("label",{className:"space-y-1",children:[h.jsx("span",{className:Kt,children:"Sort"}),h.jsxs("select",{value:t.sortOrder??"DESC",onChange:Q=>xe({sortOrder:Q.target.value}),className:Yt,"data-testid":"filter-sortOrder",children:[h.jsx("option",{value:"DESC",children:"Newest first"}),h.jsx("option",{value:"ASC",children:"Oldest first"})]})]}),h.jsxs("label",{className:"space-y-1",children:[h.jsx("span",{className:Kt,children:"Limit"}),h.jsx("input",{type:"number",min:1,max:1e3,value:t.limit??"",onChange:Q=>{const Te=Number(Q.target.value);xe({limit:Te>=1&&Te<=1e3?Te:void 0})},className:Yt,"data-testid":"filter-limit"})]}),h.jsxs("label",{className:"space-y-1",children:[h.jsx("span",{className:Kt,children:"Trace ID"}),h.jsx("input",{type:"text",placeholder:"Trace ID",value:re,onChange:Q=>J(Q.target.value),className:Yt,"data-testid":"filter-traceId"})]}),h.jsxs("label",{className:"space-y-1",children:[h.jsx("span",{className:Kt,children:"Span ID"}),h.jsx("input",{type:"text",placeholder:"Span ID",value:X,onChange:Q=>oe(Q.target.value),className:Yt,"data-testid":"filter-spanId"})]}),h.jsxs("label",{className:"space-y-1",children:[h.jsx("span",{className:Kt,children:"Scope"}),h.jsxs("select",{value:t.scopeName??"",onChange:Q=>xe({scopeName:Q.target.value||void 0}),className:Yt,"data-testid":"filter-scopeName",children:[h.jsx("option",{value:"",children:"All"}),q.map(Q=>h.jsx("option",{value:Q,children:Q},Q))]})]}),h.jsxs("label",{className:"space-y-1",children:[h.jsx("span",{className:Kt,children:"Log attributes"}),h.jsx("input",{type:"text",placeholder:"key1=val1, key2=val2",value:ue,onChange:Q=>pe(Q.target.value),className:Yt,"data-testid":"filter-logAttributes"})]}),h.jsxs("label",{className:"space-y-1",children:[h.jsx("span",{className:Kt,children:"Resource attributes"}),h.jsx("input",{type:"text",placeholder:"key1=val1, key2=val2",value:Ue,onChange:Q=>fe(Q.target.value),className:Yt,"data-testid":"filter-resourceAttributes"})]}),h.jsxs("label",{className:"space-y-1",children:[h.jsx("span",{className:Kt,children:"Scope attributes"}),h.jsx("input",{type:"text",placeholder:"key1=val1, key2=val2",value:Ve,onChange:Q=>ge(Q.target.value),className:Yt,"data-testid":"filter-scopeAttributes"})]})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:Kt,children:"Time range"}),h.jsxs("div",{className:"flex rounded-md border border-border overflow-hidden text-xs",children:[h.jsx("button",{className:`px-2 py-1 ${m==="lookback"?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted/30"}`,onClick:()=>je("lookback"),"data-testid":"time-mode-lookback",children:"Lookback"}),h.jsx("button",{className:`px-2 py-1 ${m==="absolute"?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted/30"}`,onClick:()=>je("absolute"),"data-testid":"time-mode-absolute",children:"Absolute"})]})]}),m==="lookback"?h.jsxs("select",{value:g,onChange:Q=>B(Number(Q.target.value)),className:`${Yt} max-w-xs`,"data-testid":"filter-lookback",children:[h.jsx("option",{value:-1,children:"All time"}),u_.map((Q,Te)=>h.jsx("option",{value:Te,children:Q.label},Te))]}):h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs("label",{className:"space-y-1 flex-1",children:[h.jsx("span",{className:Kt,children:"From"}),h.jsx("input",{type:"datetime-local",value:s_(t.timestampMin),onChange:Q=>K(Q.target.value),className:Yt,"data-testid":"filter-timestampMin"})]}),h.jsxs("label",{className:"space-y-1 flex-1",children:[h.jsx("span",{className:Kt,children:"To"}),h.jsx("input",{type:"datetime-local",value:s_(t.timestampMax),onChange:Q=>be(Q.target.value),className:Yt,"data-testid":"filter-timestampMax"})]})]})]})]})]})}const t6={name:"Services",shortcuts:[{keys:["Backspace"],description:"Go back"}]},c_={Gauge:0,Sum:1,Histogram:2,ExponentialHistogram:3,Summary:4};function n6(t){const r=t.hasData?t.data:null,o=t.hasData?t.loading:!1,l=t.hasData?t.error:null,i=D.useMemo(()=>r!=null&&r.metrics?[...r.metrics].sort((u,c)=>u.name.localeCompare(c.name)||(c_[u.type]??99)-(c_[c.type]??99)):[],[r]);return o&&!i.length?h.jsx("p",{className:"text-muted-foreground py-4",children:"Loading metrics…"}):l?h.jsxs("p",{className:"text-red-400 py-4",children:["Error: ",l.message]}):i.length?h.jsx("div",{className:"overflow-x-auto",children:h.jsxs("table",{className:"w-full text-sm text-left text-foreground border-collapse",children:[h.jsx("thead",{className:"text-xs uppercase text-muted-foreground border-b border-border",children:h.jsxs("tr",{children:[h.jsx("th",{className:"px-3 py-2",children:"Name"}),h.jsx("th",{className:"px-3 py-2",children:"Type"}),h.jsx("th",{className:"px-3 py-2",children:"Unit"}),h.jsx("th",{className:"px-3 py-2",children:"Description"})]})}),h.jsx("tbody",{children:i.map(u=>h.jsxs("tr",{className:"border-b border-border/50 hover:bg-muted/40",children:[h.jsx("td",{className:"px-3 py-2 font-mono whitespace-nowrap",children:u.name}),h.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:u.type}),h.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:u.unit||"–"}),h.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:u.description||"–"})]},`${u.name}-${u.type}`))})]})}):h.jsx("p",{className:"text-muted-foreground py-4",children:"No metrics discovered."})}Lz({name:"dashboard",components:{Card:{props:ie({title:U().nullable(),description:U().nullable(),padding:Ge(["sm","md","lg"]).nullable()}),hasChildren:!0,description:"A card container with optional title"},Grid:{props:ie({columns:ee().min(1).max(4).nullable(),gap:Ge(["sm","md","lg"]).nullable()}),hasChildren:!0,description:"Grid layout with configurable columns"},Stack:{props:ie({direction:Ge(["horizontal","vertical"]).nullable(),gap:Ge(["sm","md","lg"]).nullable(),align:Ge(["start","center","end","stretch"]).nullable()}),hasChildren:!0,description:"Flex stack for horizontal or vertical layouts"},Metric:{props:ie({label:U(),valuePath:U(),format:Ge(["number","currency","percent"]).nullable(),trend:Ge(["up","down","neutral"]).nullable(),trendValue:U().nullable()}),hasChildren:!1,description:"Display a single metric with optional trend indicator"},Chart:{props:ie({type:Ge(["bar","line","pie","area"]),dataPath:U(),title:U().nullable(),height:ee().nullable()}),hasChildren:!1,description:"Display a chart from array data"},Table:{props:ie({dataPath:U(),columns:le(ie({key:U(),label:U(),format:Ge(["text","currency","date","badge"]).nullable()}))}),hasChildren:!1,description:"Display tabular data"},List:{props:ie({dataPath:U(),emptyMessage:U().nullable()}),hasChildren:!0,description:"Render a list from array data"},Button:{props:ie({label:U(),variant:Ge(["primary","secondary","danger","ghost"]).nullable(),size:Ge(["sm","md","lg"]).nullable(),action:U(),disabled:Kn().nullable()}),hasChildren:!1,description:"Clickable button with action"},DatePicker:{props:ie({label:U().nullable(),bindPath:U(),placeholder:U().nullable()}),hasChildren:!1,description:"Date picker input"},Heading:{props:ie({text:U(),level:Ge(["h1","h2","h3","h4"]).nullable()}),hasChildren:!1,description:"Section heading"},Text:{props:ie({content:U(),variant:Ge(["body","caption","label"]).nullable(),color:Ge(["default","muted","success","warning","danger"]).nullable()}),hasChildren:!1,description:"Text paragraph"},Badge:{props:ie({text:U(),variant:Ge(["default","success","warning","danger","info"]).nullable()}),hasChildren:!1,description:"Small status badge"},Divider:{props:ie({label:U().nullable()}),hasChildren:!1,description:"Visual divider"},Empty:{props:ie({title:U(),description:U().nullable(),action:U().nullable(),actionLabel:U().nullable()}),hasChildren:!1,description:"Empty state placeholder"}}});function i6({element:t}){const{text:r,variant:o}=t.props;return h.jsx("span",{style:{display:"inline-block",padding:"2px 8px",borderRadius:12,fontSize:12,fontWeight:500,background:"hsl(var(--border))",color:{default:"hsl(var(--foreground))",success:"#22c55e",warning:"#eab308",danger:"#ef4444",info:"hsl(var(--muted-foreground))"}[o||"default"]},children:r})}function r6({element:t,children:r}){const{title:o,description:l,padding:i}=t.props;return h.jsxs("div",{style:{background:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"var(--radius)"},children:[(o||l)&&h.jsxs("div",{style:{padding:"16px 20px",borderBottom:"1px solid hsl(var(--border))"},children:[o&&h.jsx("h3",{style:{margin:0,fontSize:16,fontWeight:600},children:o}),l&&h.jsx("p",{style:{margin:"4px 0 0",fontSize:14,color:"hsl(var(--muted-foreground))"},children:l})]}),h.jsx("div",{style:{padding:{sm:"12px",md:"16px",lg:"24px"}[i||""]||"16px"},children:r})]})}function a6({element:t}){const{label:r}=t.props;return r?h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,margin:"16px 0"},children:[h.jsx("hr",{style:{flex:1,border:"none",borderTop:"1px solid hsl(var(--border))"}}),h.jsx("span",{style:{fontSize:12,color:"hsl(var(--muted-foreground))"},children:r}),h.jsx("hr",{style:{flex:1,border:"none",borderTop:"1px solid hsl(var(--border))"}})]}):h.jsx("hr",{style:{border:"none",borderTop:"1px solid hsl(var(--border))",margin:"16px 0"}})}function o6({element:t,onAction:r}){const{title:o,description:l,action:i,actionLabel:u}=t.props;return h.jsxs("div",{style:{textAlign:"center",padding:"40px 20px"},children:[h.jsx("h3",{style:{margin:"0 0 8px",fontSize:16,fontWeight:600},children:o}),l&&h.jsx("p",{style:{margin:"0 0 16px",fontSize:14,color:"hsl(var(--muted-foreground))"},children:l}),i&&u&&h.jsx("button",{onClick:()=>r==null?void 0:r(i),style:{padding:"8px 16px",borderRadius:"var(--radius)",border:"1px solid hsl(var(--border))",background:"hsl(var(--card))",color:"hsl(var(--foreground))",fontSize:14,cursor:"pointer"},children:u})]})}function l6({element:t,children:r}){const{columns:o,gap:l}=t.props;return h.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(${o||2}, 1fr)`,gap:{sm:"8px",md:"16px",lg:"24px"}[l||"md"]},children:r})}function u6({element:t}){const{text:r,level:o}=t.props;return h.jsx(o||"h2",{style:{margin:"0 0 16px",fontSize:{h1:"28px",h2:"24px",h3:"20px",h4:"16px"}[o||"h2"],fontWeight:600},children:r})}function s6({element:t,children:r}){const{direction:o,gap:l,align:i}=t.props;return h.jsx("div",{style:{display:"flex",flexDirection:o==="horizontal"?"row":"column",gap:{sm:"8px",md:"16px",lg:"24px"}[l||"md"],alignItems:{start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"}[i||"stretch"]},children:r})}function c6({element:t}){const{content:r,color:o}=t.props;return h.jsx("p",{style:{margin:0,color:{default:"hsl(var(--foreground))",muted:"hsl(var(--muted-foreground))",success:"#22c55e",warning:"#eab308",danger:"#ef4444"}[o||"default"]},children:r})}const d6=[{key:"services",label:"Services",shortcutKey:"S"},{key:"logs",label:"Logs",shortcutKey:"L"},{key:"metrics",label:"Metrics",shortcutKey:"M"}];function f6(){const t=new URLSearchParams(window.location.search),r=t.get("service"),o=t.get("trace"),l=t.get("span"),i=t.get("tab");return{tab:r?"services":i==="logs"||i==="metrics"?i:"services",service:r,trace:o,span:l}}function Bn(t,{replace:r=!1}={}){const o=new URLSearchParams;t.tab!=="services"&&o.set("tab",t.tab),t.service&&o.set("service",t.service),t.trace&&o.set("trace",t.trace),t.span&&o.set("span",t.span);const l=o.toString(),i=`${window.location.pathname}${l?`?${l}`:""}`;r?history.replaceState(null,"",i):history.pushState(null,"",i),dispatchEvent(new PopStateEvent("popstate"))}function m6(t){return window.addEventListener("popstate",t),()=>window.removeEventListener("popstate",t)}let d_="",f_={tab:"services",service:null,trace:null,span:null};function h6(){const t=window.location.search;return t!==d_&&(d_=t,f_=f6()),f_}function p6(){return D.useSyncExternalStore(m6,h6)}function Af(t){const r={};let o=!1;for(const l of t.split(",")){const i=l.trim();if(!i)continue;const u=i.indexOf("=");u<1||(r[i.slice(0,u)]=i.slice(u+1),o=!0)}return o?r:void 0}function If(t){return t?Object.entries(t).map(([r,o])=>`${r}=${o}`).join(","):""}function g6(){const t=new URLSearchParams(window.location.search),r={limit:200,sortOrder:"DESC"},o=t.get("severity");o&&(r.severityText=o);const l=t.get("body");l&&(r.bodyContains=l);const i=t.get("sort");(i==="ASC"||i==="DESC")&&(r.sortOrder=i);const u=t.get("limit");if(u){const q=parseInt(u,10);q>=1&&q<=1e3&&(r.limit=q)}const c=t.get("traceId");c&&(r.traceId=c);const m=t.get("spanId");m&&(r.spanId=m);const v=t.get("scope");v&&(r.scopeName=v);const g=t.get("tsMin");g&&(r.timestampMin=g);const _=t.get("tsMax");_&&(r.timestampMax=_);const b=t.get("logAttrs");b&&(r.logAttributes=Af(b));const x=t.get("resAttrs");x&&(r.resourceAttributes=Af(x));const $=t.get("scopeAttrs");$&&(r.scopeAttributes=Af($));const O=t.get("services"),T=O?O.split(",").filter(Boolean):[];return T.length===1&&(r.serviceName=T[0]),{filters:r,selectedServices:T,selectedLogId:t.get("log")||null}}function v6(t,r,o){const l=new URLSearchParams;l.set("tab","logs"),t.severityText&&l.set("severity",t.severityText),t.bodyContains&&l.set("body",t.bodyContains),r.length&&l.set("services",r.join(",")),t.sortOrder&&t.sortOrder!=="DESC"&&l.set("sort",t.sortOrder),t.limit!=null&&t.limit!==200&&l.set("limit",String(t.limit)),t.traceId&&l.set("traceId",t.traceId),t.spanId&&l.set("spanId",t.spanId),t.scopeName&&l.set("scope",t.scopeName),t.timestampMin&&l.set("tsMin",t.timestampMin),t.timestampMax&&l.set("tsMax",t.timestampMax);const i=If(t.logAttributes);i&&l.set("logAttrs",i);const u=If(t.resourceAttributes);u&&l.set("resAttrs",u);const c=If(t.scopeAttributes);c&&l.set("scopeAttrs",c),o&&l.set("log",o);const m=l.toString(),v=`${window.location.pathname}${m?`?${m}`:""}`;history.replaceState(null,"",v)}function m_(t){const r=t.trim();if(!r)return;const o=r.match(/^(\d+(?:\.\d+)?)\s*(us|ms|s)$/i);if(!o)return;const l=parseFloat(o[1]),i=o[2].toLowerCase();return String(Math.round(l*{us:1e3,ms:1e6,s:1e9}[i]))}function b6(){const[t]=D.useState(()=>g6()),[r,o]=D.useState(t.filters),[l,i]=D.useState(t.selectedServices),[u,c]=D.useState(t.selectedLogId);D.useEffect(()=>{v6(r,l,u)},[r,l,u]);const{logs:m,isLive:v,loading:g,error:_,setLive:b}=XO({params:r,pollIntervalMs:3e3}),x=D.useMemo(()=>{if(l.length<=1)return m;const T=new Set(l);return m.filter(q=>T.has(q.ServiceName??""))},[m,l]),$=D.useCallback(T=>{c(T.logId)},[]),O=D.useCallback((T,q)=>{var ne;Bn({tab:"services",service:((ne=x.find(te=>te.TraceId===T))==null?void 0:ne.ServiceName)??void 0,trace:T,span:q})},[x]);return h.jsxs("div",{style:{height:"calc(100vh - 160px)"},className:"flex flex-col",children:[h.jsx("div",{className:"shrink-0 mb-3",children:h.jsx(e6,{value:r,onChange:o,rows:m,selectedServices:l,onSelectedServicesChange:i})}),h.jsx("div",{className:"flex-1 min-h-0",children:h.jsx(Fw,{rows:x,isLoading:g,error:_??void 0,streaming:v,selectedLogId:u??void 0,onLogClick:$,onTraceLinkClick:O,onAtBottomChange:T=>b(T)})})]})}const y6={method:"searchTracesPage",params:{limit:1e3,sortOrder:"DESC"}};function _6({onSelect:t}){const{data:r,loading:o,error:l}=ac(y6);return h.jsx(uw,{services:D.useMemo(()=>{if(!(r!=null&&r.data))return[];const i=new Set;for(const u of r.data)i.add(u.ServiceName??"unknown");return Array.from(i).sort().map(u=>({name:u}))},[r]),isLoading:o,error:l??void 0,onSelect:t})}function x6({service:t,onBack:r,onSelectTrace:o}){const[l,i]=D.useState(()=>({method:"searchTracesPage",params:{serviceName:t,limit:20,sortOrder:"DESC"}})),u=D.useCallback($=>{const O={serviceName:t,limit:$.limit,sortOrder:"DESC"};if($.operation&&(O.spanName=$.operation),$.lookbackMs&&(O.timestampMin=String((Date.now()-$.lookbackMs)*1e6)),$.minDuration){const T=m_($.minDuration);T&&(O.durationMin=T)}if($.maxDuration){const T=m_($.maxDuration);T&&(O.durationMax=T)}i({method:"searchTracesPage",params:O})},[t]),{data:c,loading:m,error:v}=ac(l),g=rp(),[_,b]=D.useState(()=>new Map);D.useEffect(()=>{var T;if(!((T=c==null?void 0:c.data)!=null&&T.length)){b(new Map);return}const $=[...new Set(c.data.map(q=>q.TraceId))],O=new AbortController;return Promise.allSettled($.map(q=>g.getTrace(q,{signal:O.signal}).then(ne=>[q,ne]))).then(q=>{if(!O.signal.aborted){const ne=q.filter(te=>te.status==="fulfilled").map(te=>te.value);b(new Map(ne))}}).catch(q=>{O.signal.aborted||console.error("Failed to fetch full traces",q)}),()=>O.abort()},[c,g]);const x=D.useMemo(()=>{if(!(c!=null&&c.data))return[];const $=new Set;for(const O of c.data)O.SpanName&&$.add(O.SpanName);return Array.from($).sort()},[c]);return h.jsx(dw,{service:t,traces:D.useMemo(()=>{if(!(c!=null&&c.data))return[];const $=new Map;for(const O of c.data){const T=O.TraceId;$.has(T)||$.set(T,[]),$.get(T).push(O)}return Array.from($.entries()).map(([O,T])=>{const q=_.get(O)??T,ne=q.find(oe=>!oe.ParentSpanId)??q[0],te=ne.Duration?parseInt(ne.Duration,10):0,re=new Map;let J=0;for(const oe of q){const ue=oe.ServiceName??"unknown",pe=re.get(ue)??{count:0,hasError:!1};pe.count++,oe.StatusCode==="ERROR"&&(pe.hasError=!0,J++),re.set(ue,pe)}const X=Array.from(re.entries()).map(([oe,ue])=>({name:oe,count:ue.count,hasError:ue.hasError})).sort((oe,ue)=>ue.count-oe.count);return{traceId:O,rootSpanName:ne.SpanName??"unknown",serviceName:ne.ServiceName??"unknown",durationMs:te/1e6,statusCode:ne.StatusCode??"UNSET",timestampMs:parseInt(ne.Timestamp,10)/1e6,spanCount:q.length,services:X,errorCount:J}})},[c,_]),operations:x,isLoading:m,error:v??void 0,onSelectTrace:o,onBack:r,onSearch:u})}function S6({service:t,traceId:r,selectedSpanId:o,onSelectSpan:l,onBack:i}){const{data:u,loading:c,error:m}=ac(D.useMemo(()=>({method:"getTrace",params:{traceId:r}}),[r]));return h.jsx(Dw,{service:t,traceId:r,rows:u??[],isLoading:c,error:m??void 0,selectedSpanId:o??void 0,onSpanClick:v=>l(v.spanId),onBack:i})}function $6({selectedService:t,selectedTraceId:r,selectedSpanId:o,onSelectService:l,onSelectTrace:i,onSelectSpan:u,onBackToServices:c,onBackToTraceList:m}){ap("services-tab",t6);const v=D.useRef(c);v.current=c;const g=D.useRef(m);return g.current=m,D.useEffect(()=>{const _=b=>{b.target instanceof HTMLInputElement||b.target instanceof HTMLTextAreaElement||b.target instanceof HTMLSelectElement||b.key==="Backspace"&&(b.preventDefault(),r&&t?g.current():t&&v.current())};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[t,r]),r&&t?h.jsx(S6,{service:t,traceId:r,selectedSpanId:o,onSelectSpan:u,onBack:m}):t?h.jsx(x6,{service:t,onBack:c,onSelectTrace:i}):h.jsx(_6,{onSelect:l})}const z6=ew(WO,{Card:r6,Grid:l6,Stack:s6,Heading:u6,Text:c6,Badge:i6,Divider:a6,Empty:o6,LogTimeline:()=>null,TraceDetail:()=>null,MetricTimeSeries:()=>null,MetricHistogram:()=>null,MetricStat:()=>null,MetricTable:()=>null,MetricDiscovery:n6}),E6={root:"root",elements:{root:{key:"root",type:"Stack",children:["heading","description","discovery-card"],parentKey:"",props:{direction:"vertical",gap:"md",align:null}},heading:{key:"heading",type:"Heading",children:[],parentKey:"root",props:{text:"Metrics",level:"h2"}},description:{key:"description",type:"Text",children:[],parentKey:"root",props:{content:"Discovered OpenTelemetry metrics",variant:"body",color:"muted"}},"discovery-card":{key:"discovery-card",type:"Card",children:["metric-discovery"],parentKey:"root",props:{title:null,description:null,padding:null}},"metric-discovery":{key:"metric-discovery",type:"MetricDiscovery",children:[],parentKey:"discovery-card",dataSource:{method:"discoverMetrics"},props:{}}}};function T6(){return h.jsx(z6,{tree:E6})}const k6=new AO({baseUrl:"http://localhost:8000/signals"});function N6(){const{tab:t,service:r,trace:o,span:l}=p6(),i=D.useCallback(_=>{Bn({tab:_})},[]),u=D.useCallback(_=>{Bn({tab:"services",service:_})},[]),c=D.useCallback(_=>{Bn({tab:"services",service:r,trace:_})},[r]),m=D.useCallback(_=>{Bn({tab:"services",service:r,trace:o,span:_},{replace:!0})},[r,o]),v=D.useCallback(()=>{Bn({tab:"services"})},[]),g=D.useCallback(()=>{Bn({tab:"services",service:r})},[r]);return h.jsx(YO,{client:k6,children:h.jsx(kw,{onNavigateServices:()=>Bn({tab:"services"}),onNavigateLogs:()=>Bn({tab:"logs"}),onNavigateMetrics:()=>Bn({tab:"metrics"}),children:h.jsxs("div",{children:[h.jsx(rw,{tabs:d6,active:t,onChange:i}),t==="logs"&&h.jsx(b6,{}),t==="services"&&h.jsx($6,{selectedService:r,selectedTraceId:o,selectedSpanId:l,onSelectService:u,onSelectTrace:c,onSelectSpan:m,onBackToServices:v,onBackToTraceList:g}),t==="metrics"&&h.jsx(T6,{})]})})})}document.documentElement.classList.add("dark");document.body.classList.add("bg-background");O4.createRoot(document.getElementById("root")).render(h.jsx($4.StrictMode,{children:h.jsxs("div",{className:"min-h-screen bg-background text-foreground p-6",children:[h.jsxs("div",{className:"flex items-center justify-between mb-6",children:[h.jsx("h1",{className:"text-xl font-normal",style:{fontFamily:"ui-monospace, monospace"},children:h.jsx("span",{children:"k>"})}),h.jsxs("button",{className:"text-xs text-zinc-500 hover:text-zinc-300 transition-colors",onClick:()=>document.dispatchEvent(new KeyboardEvent("keydown",{key:"?",shiftKey:!0,bubbles:!0})),children:["Press"," ",h.jsx("kbd",{className:"px-1 py-0.5 text-xs border border-zinc-700 rounded bg-zinc-800",children:"?"})," ","for shortcuts"]})]}),h.jsx(N6,{})]})}));
96
+ `)[0]||"",100)}),b&&h.jsxs("span",{className:"flex-shrink-0 text-xs text-muted-foreground",children:["+",_-1," lines"]}),r.traceId&&h.jsxs("span",{className:"flex-shrink-0 text-xs text-indigo-600 dark:text-indigo-400",children:["trace: ",r.traceId.slice(0,16),"..."]})]})]})});function Rw({log:t}){const r=D.useMemo(()=>Object.entries(t.attributes).sort(([o],[l])=>o.localeCompare(l)),[t.attributes]);return r.length===0?h.jsx("div",{className:"text-sm text-muted-foreground text-center py-8",children:"No attributes available"}):h.jsx("div",{className:"space-y-2",children:r.map(([o,l])=>{const i=qz(l),u=Xa(l);return h.jsxs("div",{className:"p-2 rounded bg-muted",children:[h.jsx("div",{className:"font-mono font-medium text-xs text-foreground mb-1",title:o,children:o}),h.jsx("div",{children:i?h.jsx("pre",{className:"text-xs text-foreground bg-background p-2 rounded border border-border overflow-x-auto",children:u}):h.jsx("span",{className:"text-sm text-foreground break-words",children:u})})]},o)})})}function Zw({data:t,level:r=0}){return h.jsx("div",{className:"font-mono text-sm",children:Array.isArray(t)?h.jsx(Yz,{items:t,level:r}):h.jsx(Kz,{obj:t,level:r})})}function Kz({obj:t,level:r}){const o=Object.entries(t);return o.length===0?h.jsx("span",{className:"text-muted-foreground",children:"{}"}):h.jsx("div",{children:o.map(([l,i])=>h.jsx(Jz,{objKey:l,value:i,level:r},l))})}function Yz({items:t,level:r}){return t.length===0?h.jsx("span",{className:"text-muted-foreground",children:"[]"}):h.jsx("div",{children:t.map((o,l)=>h.jsx(Jz,{objKey:String(l),value:o,level:r,isArrayItem:!0},l))})}function Jz({objKey:t,value:r,level:o,isArrayItem:l=!1}){const[i,u]=D.useState(o<2),c=r!==null&&typeof r=="object"&&(Array.isArray(r)?r.length>0:Object.keys(r).length>0),m=o*16;return c?h.jsxs("div",{children:[h.jsxs("div",{style:{paddingLeft:`${m}px`},className:"py-0.5 hover:bg-muted cursor-pointer",onClick:()=>u(!i),children:[h.jsx("span",{className:"inline-block w-4 text-muted-foreground",children:i?"▼":"▶"}),!l&&h.jsxs("span",{className:"text-blue-600 dark:text-blue-400",children:[t,": "]}),h.jsx("span",{className:"text-muted-foreground",children:Array.isArray(r)?`Array(${r.length})`:`Object(${Object.keys(r).length})`})]}),i&&h.jsx("div",{children:Array.isArray(r)?h.jsx(Yz,{items:r,level:o+1}):h.jsx(Kz,{obj:r,level:o+1})})]}):h.jsxs("div",{style:{paddingLeft:`${m}px`},className:"py-0.5 hover:bg-muted",children:[!l&&h.jsxs("span",{className:"text-blue-600 dark:text-blue-400",children:[t,": "]}),h.jsx("span",{className:"text-foreground",children:Lw(r)})]})}function Lw(t){return t===null?"null":t===void 0?"undefined":typeof t=="string"?`"${t}"`:typeof t=="boolean"?t?"true":"false":String(t)}function Bw({log:t,onClose:r,onTraceLinkClick:o,initialTab:l="message",wordWrap:i=!0}){const u=!!t.traceId,[c,m]=D.useState(l==="context"&&!u?"message":l),[v,g]=D.useState(!1),_=D.useRef(null),b=D.useCallback(async()=>{try{await navigator.clipboard.writeText(t.logId),g(!0),setTimeout(()=>g(!1),2e3)}catch(O){console.error("Failed to copy log ID:",O)}},[t.logId]),x=D.useCallback(O=>{O.key==="Escape"&&r()},[r]);D.useEffect(()=>{var O;(O=_.current)==null||O.focus()},[]);const $=Hw(t.severityText);return h.jsxs("div",{ref:_,className:"w-[500px] flex flex-col h-full bg-background border-l border-border outline-none",onKeyDown:x,role:"complementary","aria-label":"Log details",tabIndex:-1,children:[h.jsxs("div",{className:"p-4 border-b border-border",children:[h.jsxs("div",{className:"flex items-center justify-between mb-3",children:[h.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"Log Details"}),h.jsx("button",{onClick:r,className:"p-2 hover:bg-muted rounded transition-colors","aria-label":"Close detail pane",children:h.jsx("svg",{className:"w-6 h-6 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),h.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[h.jsx("div",{className:`text-xs font-semibold px-2 py-0.5 rounded ${$.bg} ${$.text}`,children:t.severityText}),h.jsx("div",{className:"text-sm text-muted-foreground",children:t.serviceName})]}),h.jsx("div",{className:"text-xs font-medium text-muted-foreground mt-3 mb-1",children:"Timestamp"}),h.jsx("div",{className:"text-xs text-foreground font-mono",children:new Date(t.timeUnixMs).toISOString()}),h.jsx("div",{className:"text-xs font-medium text-muted-foreground mt-3 mb-1",children:"Log ID"}),h.jsx("div",{className:"flex items-center gap-2",children:h.jsxs("button",{onClick:b,className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground font-mono bg-muted px-2 py-1 rounded",title:"Click to copy log ID",children:[h.jsx("span",{className:"truncate max-w-[200px]",children:t.logId}),h.jsx("svg",{className:"w-3 h-3 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:v?h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"}):h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})]})})]}),h.jsx("div",{className:"flex border-b border-border",children:["message","attributes","resource",...t.traceId?["context"]:[]].map(O=>h.jsx("button",{onClick:()=>m(O),className:`px-4 py-2 text-sm font-medium transition-colors ${c===O?"text-blue-600 dark:text-blue-400 border-b-2 border-blue-600 dark:border-blue-400":"text-muted-foreground hover:text-foreground"}`,children:O==="context"?"Trace":O.charAt(0).toUpperCase()+O.slice(1)},O))}),h.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[c==="message"&&h.jsx("pre",{className:`text-sm text-foreground font-mono bg-muted p-3 rounded ${i?"whitespace-pre-wrap break-words":"whitespace-pre overflow-x-auto"}`,children:t.body||"No message body"}),c==="attributes"&&h.jsx(Rw,{log:t}),c==="resource"&&h.jsxs("div",{children:[h.jsxs("div",{className:"mb-3",children:[h.jsx("div",{className:"text-sm font-semibold text-foreground mb-2",children:"Service Name"}),h.jsx("div",{className:"text-sm text-foreground bg-muted p-2 rounded font-mono",children:t.serviceName})]}),t.scopeName&&h.jsxs("div",{className:"mb-3",children:[h.jsx("div",{className:"text-sm font-semibold text-foreground mb-2",children:"Scope Name"}),h.jsx("div",{className:"text-sm text-foreground bg-muted p-2 rounded font-mono",children:t.scopeName})]}),h.jsxs("div",{children:[h.jsx("div",{className:"text-sm font-semibold text-foreground mb-2",children:"Resource Attributes"}),Object.keys(t.resourceAttributes).length>0?h.jsx(Zw,{data:t.resourceAttributes}):h.jsx("div",{className:"text-sm text-muted-foreground text-center py-4",children:"No resource attributes"})]})]}),c==="context"&&t.traceId&&h.jsxs("div",{className:"space-y-3",children:[h.jsxs("div",{children:[h.jsx("div",{className:"text-sm font-semibold text-foreground mb-2",children:"Trace ID"}),h.jsx("div",{className:"text-sm text-foreground bg-muted p-2 rounded font-mono break-all",children:t.traceId})]}),t.spanId&&h.jsxs("div",{children:[h.jsx("div",{className:"text-sm font-semibold text-foreground mb-2",children:"Span ID"}),h.jsx("div",{className:"text-sm text-foreground bg-muted p-2 rounded font-mono break-all",children:t.spanId})]}),o&&t.spanId&&h.jsx("button",{onClick:()=>o(t.traceId,t.spanId),className:"w-full px-4 py-2 bg-blue-600 dark:bg-blue-500 text-white rounded hover:bg-blue-700 dark:hover:bg-blue-600 transition-colors text-sm",children:"View Trace"})]})]})]})}function Hw(t){const r=t.toUpperCase();return r==="FATAL"||r==="ERROR"?{text:"text-red-900 dark:text-red-100",bg:"bg-red-100 dark:bg-red-900/30"}:r==="WARN"||r==="WARNING"?{text:"text-orange-900 dark:text-orange-100",bg:"bg-orange-100 dark:bg-orange-900/30"}:r==="INFO"?{text:"text-blue-900 dark:text-blue-100",bg:"bg-blue-100 dark:bg-blue-900/30"}:r==="DEBUG"?{text:"text-gray-900 dark:text-gray-100",bg:"bg-gray-100 dark:bg-gray-700/30"}:{text:"text-gray-600 dark:text-gray-400",bg:"bg-gray-50 dark:bg-gray-800/20"}}const qw={name:"Log Viewer",shortcuts:[{keys:["↑/K"],description:"Previous log"},{keys:["↓/J"],description:"Next log"},{keys:["G"],description:"Scroll to bottom"},{keys:["Home"],description:"First log"},{keys:["/"],description:"Focus search"},{keys:["F"],description:"Toggle filters"},{keys:["Enter"],description:"Open log detail"},{keys:["C"],description:"Copy log body"},{keys:["W"],description:"Toggle word wrap"},{keys:["T"],description:"Toggle timestamps"},{keys:["Esc"],description:"Close detail/filter pane"}]},l_=44,Gw=20,Vw=1e3,Kw=50,Yw={position:"absolute",top:0,left:0,width:"100%"};function Jw(t){let r=0;for(let o=0;o<t.length;o++){const l=t.charCodeAt(o);r=(r<<5)-r+l,r=r&r}return Math.abs(r).toString(36)}function Qw(t,r){if(r)return r;const o=t??0;return o>=21?"FATAL":o>=17?"ERROR":o>=13?"WARN":o>=9?"INFO":o>=5?"DEBUG":o>=1?"TRACE":"UNSPECIFIED"}function Xw(t){return t.map(r=>{const o=parseInt(r.Timestamp,10)/1e6,l=r.Body??"",i=Qw(r.SeverityNumber,r.SeverityText);return{logId:`${r.Timestamp}-${r.ServiceName??"unknown"}-${Jw(l)}`,timeUnixMs:o,body:l,severityText:i,severityNumber:r.SeverityNumber??0,serviceName:r.ServiceName??"unknown",traceId:r.TraceId,spanId:r.SpanId,attributes:r.LogAttributes??{},resourceAttributes:r.ResourceAttributes??{},scopeName:r.ScopeName}}).sort((r,o)=>r.timeUnixMs-o.timeUnixMs)}function Fw({rows:t,onLogClick:r,onTraceLinkClick:o,selectedLogId:l,isLoading:i,error:u,streaming:c=!1,maxLogs:m=Vw,searchText:v="",onAtBottomChange:g}){ap("log-viewer",qw);const[_,b]=D.useState(null),[x,$]=D.useState(!1),[O,T]=D.useState(!0),[q,ne]=D.useState(!0),[te,re]=D.useState(!1),J=l??_,X=D.useRef(null),oe=D.useRef(null),ue=D.useRef(!0),pe=D.useRef(!1),Ue=D.useMemo(()=>Xw(t),[t]),fe=D.useMemo(()=>c&&Ue.length>m?Ue.slice(Ue.length-m):Ue,[Ue,c,m]),Ve=D.useMemo(()=>fe.find(B=>B.logId===J)??null,[fe,J]),ge=D.useMemo(()=>{if(Ve)return Ve.timeUnixMs;const B=fe[0];return B?B.timeUnixMs:0},[Ve,fe]);D.useEffect(()=>{l&&$(!0)},[l]);const ce=D.useCallback(()=>{if(!X.current)return!0;const{scrollTop:B,scrollHeight:K,clientHeight:be}=X.current;return K<=be?!0:K-B-be<Kw},[]),_e=D.useRef(!0),Ke=D.useCallback(()=>{const B=ce();ue.current=B,T(B),B!==_e.current&&(_e.current=B,g==null||g(B))},[ce,g]);D.useEffect(()=>{const B=ce();ue.current=B,T(B)},[fe.length,ce]),D.useEffect(()=>{c&&ue.current&&X.current&&(X.current.scrollTop=X.current.scrollHeight)},[fe,c]);const R=Rz({count:fe.length,getScrollElement:()=>X.current,estimateSize:()=>l_,overscan:Gw});D.useEffect(()=>{if(pe.current||!l||fe.length===0)return;const B=fe.findIndex(K=>K.logId===l);B!==-1&&(pe.current=!0,R.scrollToIndex(B,{align:"center"}))},[l,fe,R]);const F=D.useCallback(B=>{b(B.logId),$(!0),r==null||r(B),oe.current&&(oe.current.textContent=`Selected log from ${B.serviceName}: ${B.body.slice(0,100)}`)},[r]),he=D.useMemo(()=>{const B=new Map;return fe.forEach(K=>{B.set(K.logId,()=>F(K))}),B},[fe,F]),Ie=D.useCallback(()=>{$(!1),b(null)},[]),xe=D.useCallback(()=>{X.current&&(X.current.scrollTop=X.current.scrollHeight,ue.current=!0,T(!0),_e.current||(_e.current=!0,g==null||g(!0)))},[g]),z=D.useCallback(()=>{const B=fe.findIndex(K=>K.logId===J);if(B>0){const K=fe[B-1];K&&(F(K),R.scrollToIndex(B-1,{align:"auto"}))}else if(B===-1&&fe.length>0){const K=fe.length-1,be=fe[K];be&&(F(be),R.scrollToIndex(K,{align:"auto"}))}},[fe,J,F,R]),G=D.useCallback(()=>{const B=fe.findIndex(K=>K.logId===J);if(B>=0&&B<fe.length-1){const K=fe[B+1];K&&(F(K),R.scrollToIndex(B+1,{align:"auto"}))}else if(B===-1&&fe.length>0){const K=fe[0];K&&(F(K),R.scrollToIndex(0,{align:"auto"}))}},[fe,J,F,R]);return D.useEffect(()=>{const B=K=>{var je;const be=K.target instanceof HTMLInputElement||K.target instanceof HTMLTextAreaElement||K.target instanceof HTMLSelectElement;if(be&&K.key==="Escape"){K.target.blur();return}if(!be)switch(K.key){case"ArrowUp":case"k":case"K":K.preventDefault(),z();break;case"ArrowDown":case"j":case"J":K.preventDefault(),G();break;case"Escape":if(x)K.preventDefault(),Ie();else{const ye=document.querySelector('[data-testid="log-filter"]'),Q=ye==null?void 0:ye.querySelector('[data-testid="log-filter-toggle"]');Q&&(ye!=null&&ye.querySelector(".border-t"))&&(K.preventDefault(),Q.click())}break;case"g":case"G":K.preventDefault(),xe();break;case"/":{K.preventDefault();const ye=document.querySelector('[data-testid="filter-bodyContains"]');if(ye){const Q=document.querySelector('[data-testid="log-filter"]'),Te=Q==null?void 0:Q.querySelector('[data-testid="log-filter-toggle"]');Te&&!(Q!=null&&Q.querySelector(".border-t"))?(Te.click(),requestAnimationFrame(()=>{var Rt;(Rt=document.querySelector('[data-testid="filter-bodyContains"]'))==null||Rt.focus()})):ye.focus()}break}case"f":case"F":K.preventDefault(),(je=document.querySelector('[data-testid="log-filter-toggle"]'))==null||je.click();break;case"Enter":if(J&&!x){K.preventDefault();const ye=fe.find(Q=>Q.logId===J);ye&&F(ye)}break;case"Home":if(K.preventDefault(),fe.length>0){const ye=fe[0];ye&&(F(ye),R.scrollToIndex(0))}break;case"c":case"C":if(K.ctrlKey||K.metaKey)break;K.preventDefault(),Ve&&navigator.clipboard.writeText(Ve.body).catch(()=>{});break;case"w":case"W":K.preventDefault(),ne(ye=>!ye);break;case"t":case"T":K.preventDefault(),re(ye=>!ye);break}};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[fe,J,Ve,z,G,F,Ie,xe,x,R]),i&&!fe.length?h.jsx(Gz,{}):u?h.jsx("div",{className:"flex items-center justify-center h-full bg-background",children:h.jsxs("div",{className:"text-center p-6",children:[h.jsx("div",{className:"text-red-600 dark:text-red-400 mb-2",children:"Failed to load logs"}),h.jsx("div",{className:"text-sm text-muted-foreground",children:u.message})]})}):fe.length===0?h.jsx("div",{className:"flex items-center justify-center h-full bg-background",children:h.jsxs("div",{className:"text-center p-6",children:[h.jsx("div",{className:"text-muted-foreground mb-2",children:"No logs"}),h.jsx("div",{className:"text-sm text-muted-foreground",children:c?"Waiting for logs...":"No log data available"})]})}):h.jsxs("div",{className:"flex flex-col h-full min-h-0 bg-background",children:[h.jsx("div",{ref:oe,className:"sr-only",role:"status","aria-live":"polite","aria-atomic":"true"}),h.jsxs("div",{className:"flex flex-1 min-h-0",children:[h.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[h.jsx("div",{className:"border-b border-border px-4 py-3",children:h.jsx("div",{className:"flex items-center justify-between",children:h.jsx("div",{className:"flex items-center gap-2",children:h.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 bg-muted rounded-md text-sm font-medium text-muted-foreground",children:[h.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h7"})}),fe.length," ",fe.length===1?"log":"logs"]})})})}),h.jsxs("div",{className:"flex-1 relative",children:[h.jsx("div",{ref:X,className:"absolute inset-0 overflow-auto",onScroll:Ke,children:h.jsx("div",{style:{height:`${R.getTotalSize()}px`,width:"100%",position:"relative"},children:R.getVirtualItems().map(B=>{const K=fe[B.index];return K?h.jsx("div",{style:{...Yw,height:l_,transform:`translateY(${B.start}px)`},children:h.jsx(Cw,{log:K,isSelected:K.logId===J,onClick:he.get(K.logId),searchText:v,relativeTime:te,referenceTimeMs:ge})},B.index):null})})}),!O&&h.jsx("button",{onClick:xe,className:"absolute bottom-4 right-4 px-3 py-1.5 text-xs font-medium rounded-md bg-primary hover:bg-primary/90 text-primary-foreground shadow-lg transition-colors z-10","aria-label":"Scroll to bottom",children:h.jsxs("span",{className:"flex items-center gap-1",children:[h.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",fill:"currentColor",className:"w-3 h-3",children:h.jsx("path",{fillRule:"evenodd",d:"M8 2a.75.75 0 0 1 .75.75v8.69l3.22-3.22a.75.75 0 1 1 1.06 1.06l-4.5 4.5a.75.75 0 0 1-1.06 0l-4.5-4.5a.75.75 0 0 1 1.06-1.06l3.22 3.22V2.75A.75.75 0 0 1 8 2Z",clipRule:"evenodd"})}),"(",h.jsx("span",{className:"underline underline-offset-4",children:"G"}),")"]})})]})]}),x&&Ve&&h.jsx(Bw,{log:Ve,onClose:Ie,onTraceLinkClick:o,wordWrap:q})]})]})}const u_=[{label:"Last 5 Minutes",ms:5*6e4},{label:"Last 15 Minutes",ms:15*6e4},{label:"Last 30 Minutes",ms:30*6e4},{label:"Last 1 Hour",ms:60*6e4},{label:"Last 2 Hours",ms:120*6e4},{label:"Last 6 Hours",ms:360*6e4},{label:"Last 12 Hours",ms:720*6e4},{label:"Last 24 Hours",ms:1440*6e4}],Ta=500;function Uf(t){return String(BigInt(Math.floor(t))*1000000n)}function ka(t){const r={};let o=!1;for(const l of t.split(",")){const i=l.trim();if(!i)continue;const u=i.indexOf("=");if(u<1)continue;const c=i.slice(0,u).trim(),m=i.slice(u+1).trim();c&&(r[c]=m,o=!0)}return o?r:void 0}function s_(t){if(!t)return"";const r=Number(BigInt(t)/1000000n),o=new Date(r),l=i=>String(i).padStart(2,"0");return`${o.getFullYear()}-${l(o.getMonth()+1)}-${l(o.getDate())}T${l(o.getHours())}:${l(o.getMinutes())}`}function Pw(t,r){const o=[];return r.length===1?o.push(`service:${r[0]}`):r.length>1&&o.push(`services:${r.length}`),t.severityText&&o.push(`severity:${t.severityText}`),t.scopeName&&o.push(`scope:${t.scopeName}`),t.bodyContains&&o.push(`body:"${t.bodyContains}"`),t.traceId&&o.push(`trace:${t.traceId.slice(0,8)}…`),t.spanId&&o.push(`span:${t.spanId.slice(0,8)}…`),t.limit!=null&&o.push(`limit:${t.limit}`),t.sortOrder==="ASC"&&o.push("sort:oldest"),o.join(" | ")}const Yt="w-full bg-muted/50 border border-border rounded px-2 py-1.5 text-sm text-foreground placeholder:text-muted-foreground/50",Kt="text-xs text-muted-foreground";function Na(t,r){const[o,l]=D.useState(t);return D.useEffect(()=>{const i=setTimeout(()=>l(t),r);return()=>clearTimeout(i)},[t,r]),o}function Ww({options:t,selected:r,onChange:o,testId:l}){const[i,u]=D.useState(!1),c=D.useRef(null);D.useEffect(()=>{if(!i)return;const g=_=>{c.current&&!c.current.contains(_.target)&&u(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[i]);const m=g=>{r.includes(g)?o(r.filter(_=>_!==g)):o([...r,g])},v=r.length===0?"All":r.length===1?r[0]:`${r.length} selected`;return h.jsxs("div",{ref:c,className:"relative","data-testid":l,children:[h.jsxs("button",{type:"button",onClick:()=>u(g=>!g),className:`${Yt} text-left flex items-center justify-between`,"data-testid":l?`${l}-trigger`:void 0,children:[h.jsx("span",{className:"truncate",children:v}),h.jsx("span",{className:"text-muted-foreground text-xs ml-1",children:i?"▲":"▼"})]}),i&&h.jsxs("div",{className:"absolute z-10 mt-1 w-full bg-background border border-border rounded shadow-lg max-h-48 overflow-y-auto","data-testid":l?`${l}-dropdown`:void 0,children:[t.length===0&&h.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"No options"}),t.map(g=>h.jsxs("label",{className:"flex items-center gap-2 px-2 py-1.5 hover:bg-muted/30 cursor-pointer text-sm",children:[h.jsx("input",{type:"checkbox",checked:r.includes(g),onChange:()=>m(g),className:"accent-foreground","data-testid":l?`${l}-option-${g}`:void 0}),h.jsx("span",{className:"truncate",children:g})]},g)),r.length>0&&h.jsx("button",{type:"button",onClick:()=>o([]),className:"w-full px-2 py-1.5 text-xs text-muted-foreground hover:bg-muted/30 border-t border-border","data-testid":l?`${l}-clear`:void 0,children:"Clear all"})]})]})}function e6({value:t,onChange:r,rows:o=[],selectedServices:l=[],onSelectedServicesChange:i}){const[u,c]=D.useState(!1),[m,v]=D.useState("lookback"),[g,_]=D.useState(-1),b=D.useRef(new Set),x=D.useRef(new Set),$=D.useRef(new Set),O=D.useMemo(()=>{for(const Q of o)Q.ServiceName&&b.current.add(Q.ServiceName);return Array.from(b.current).sort()},[o]),T=D.useMemo(()=>{for(const Q of o)Q.SeverityText&&x.current.add(Q.SeverityText);return Array.from(x.current).sort()},[o]),q=D.useMemo(()=>{for(const Q of o)Q.ScopeName&&$.current.add(Q.ScopeName);return Array.from($.current).sort()},[o]),[ne,te]=D.useState(t.bodyContains??""),[re,J]=D.useState(t.traceId??""),[X,oe]=D.useState(t.spanId??""),[ue,pe]=D.useState(""),[Ue,fe]=D.useState(""),[Ve,ge]=D.useState(""),ce=Na(ne,Ta),_e=Na(re,Ta),Ke=Na(X,Ta),R=Na(ue,Ta),F=Na(Ue,Ta),he=Na(Ve,Ta),Ie=D.useRef(!0);D.useEffect(()=>{if(Ie.current){Ie.current=!1;return}const Q={...t};ce?Q.bodyContains=ce:delete Q.bodyContains,_e?Q.traceId=_e:delete Q.traceId,Ke?Q.spanId=Ke:delete Q.spanId;const Te=ka(R);Te?Q.logAttributes=Te:delete Q.logAttributes;const Rt=ka(F);Rt?Q.resourceAttributes=Rt:delete Q.resourceAttributes;const Mn=ka(he);Mn?Q.scopeAttributes=Mn:delete Q.scopeAttributes,r(Q)},[ce,_e,Ke,R,F,he]);const xe=D.useCallback(Q=>{const Te={...t};for(const[Wa,jn]of Object.entries(Q))jn===void 0||jn===""?delete Te[Wa]:Te[Wa]=jn;ce&&(Te.bodyContains=ce),_e&&(Te.traceId=_e),Ke&&(Te.spanId=Ke);const Rt=ka(R);Rt&&(Te.logAttributes=Rt);const Mn=ka(F);Mn&&(Te.resourceAttributes=Mn);const Zr=ka(he);Zr&&(Te.scopeAttributes=Zr),r(Te)},[t,r,ce,_e,Ke,R,F,he]),z=D.useRef(xe);z.current=xe;const G=D.useCallback(Q=>{i==null||i(Q),Q.length===1?z.current({serviceName:Q[0]}):z.current({serviceName:void 0})},[i]),B=D.useCallback(Q=>{if(_(Q),Q<0)xe({timestampMin:void 0,timestampMax:void 0});else{const Te=u_[Q];Te&&xe({timestampMin:Uf(Date.now()-Te.ms),timestampMax:void 0})}},[xe]),K=D.useCallback(Q=>{if(!Q){xe({timestampMin:void 0});return}xe({timestampMin:Uf(new Date(Q).getTime())})},[xe]),be=D.useCallback(Q=>{if(!Q){xe({timestampMax:void 0});return}xe({timestampMax:Uf(new Date(Q).getTime())})},[xe]),je=D.useCallback(Q=>{v(Q),_(-1),xe({timestampMin:void 0,timestampMax:void 0})},[xe]),ye=Pw(t,l);return h.jsxs("div",{className:"border border-border rounded-lg","data-testid":"log-filter",children:[h.jsxs("button",{onClick:()=>c(Q=>!Q),className:"w-full flex items-center justify-between px-4 py-2.5 text-sm font-medium text-foreground hover:bg-muted/30 transition-colors","data-testid":"log-filter-toggle",children:[h.jsxs("span",{className:"flex items-center gap-2",children:[h.jsxs("span",{children:[h.jsx("span",{className:"underline underline-offset-4",children:"F"}),"ilters"]}),!u&&ye&&h.jsx("span",{className:"text-xs text-muted-foreground truncate max-w-md","data-testid":"filter-summary",children:ye})]}),h.jsx("span",{className:"text-muted-foreground text-xs",children:u?"▲":"▼"})]}),u&&h.jsxs("div",{className:"px-4 pb-4 pt-1 border-t border-border space-y-3",children:[h.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3",children:[h.jsxs("div",{className:"space-y-1",children:[h.jsx("span",{className:Kt,children:"Service"}),h.jsx(Ww,{options:O,selected:l,onChange:G,testId:"filter-serviceName"})]}),h.jsxs("label",{className:"space-y-1",children:[h.jsx("span",{className:Kt,children:"Severity"}),h.jsxs("select",{value:t.severityText??"",onChange:Q=>xe({severityText:Q.target.value||void 0}),className:Yt,"data-testid":"filter-severityText",children:[h.jsx("option",{value:"",children:"All"}),T.map(Q=>h.jsx("option",{value:Q,children:Q},Q))]})]}),h.jsxs("label",{className:"space-y-1",children:[h.jsx("span",{className:Kt,children:"Body contains"}),h.jsx("input",{type:"text",placeholder:"Search log body... (/)",value:ne,onChange:Q=>te(Q.target.value),className:Yt,"data-testid":"filter-bodyContains"})]}),h.jsxs("label",{className:"space-y-1",children:[h.jsx("span",{className:Kt,children:"Sort"}),h.jsxs("select",{value:t.sortOrder??"DESC",onChange:Q=>xe({sortOrder:Q.target.value}),className:Yt,"data-testid":"filter-sortOrder",children:[h.jsx("option",{value:"DESC",children:"Newest first"}),h.jsx("option",{value:"ASC",children:"Oldest first"})]})]}),h.jsxs("label",{className:"space-y-1",children:[h.jsx("span",{className:Kt,children:"Limit"}),h.jsx("input",{type:"number",min:1,max:1e3,value:t.limit??"",onChange:Q=>{const Te=Number(Q.target.value);xe({limit:Te>=1&&Te<=1e3?Te:void 0})},className:Yt,"data-testid":"filter-limit"})]}),h.jsxs("label",{className:"space-y-1",children:[h.jsx("span",{className:Kt,children:"Trace ID"}),h.jsx("input",{type:"text",placeholder:"Trace ID",value:re,onChange:Q=>J(Q.target.value),className:Yt,"data-testid":"filter-traceId"})]}),h.jsxs("label",{className:"space-y-1",children:[h.jsx("span",{className:Kt,children:"Span ID"}),h.jsx("input",{type:"text",placeholder:"Span ID",value:X,onChange:Q=>oe(Q.target.value),className:Yt,"data-testid":"filter-spanId"})]}),h.jsxs("label",{className:"space-y-1",children:[h.jsx("span",{className:Kt,children:"Scope"}),h.jsxs("select",{value:t.scopeName??"",onChange:Q=>xe({scopeName:Q.target.value||void 0}),className:Yt,"data-testid":"filter-scopeName",children:[h.jsx("option",{value:"",children:"All"}),q.map(Q=>h.jsx("option",{value:Q,children:Q},Q))]})]}),h.jsxs("label",{className:"space-y-1",children:[h.jsx("span",{className:Kt,children:"Log attributes"}),h.jsx("input",{type:"text",placeholder:"key1=val1, key2=val2",value:ue,onChange:Q=>pe(Q.target.value),className:Yt,"data-testid":"filter-logAttributes"})]}),h.jsxs("label",{className:"space-y-1",children:[h.jsx("span",{className:Kt,children:"Resource attributes"}),h.jsx("input",{type:"text",placeholder:"key1=val1, key2=val2",value:Ue,onChange:Q=>fe(Q.target.value),className:Yt,"data-testid":"filter-resourceAttributes"})]}),h.jsxs("label",{className:"space-y-1",children:[h.jsx("span",{className:Kt,children:"Scope attributes"}),h.jsx("input",{type:"text",placeholder:"key1=val1, key2=val2",value:Ve,onChange:Q=>ge(Q.target.value),className:Yt,"data-testid":"filter-scopeAttributes"})]})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:Kt,children:"Time range"}),h.jsxs("div",{className:"flex rounded-md border border-border overflow-hidden text-xs",children:[h.jsx("button",{className:`px-2 py-1 ${m==="lookback"?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted/30"}`,onClick:()=>je("lookback"),"data-testid":"time-mode-lookback",children:"Lookback"}),h.jsx("button",{className:`px-2 py-1 ${m==="absolute"?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted/30"}`,onClick:()=>je("absolute"),"data-testid":"time-mode-absolute",children:"Absolute"})]})]}),m==="lookback"?h.jsxs("select",{value:g,onChange:Q=>B(Number(Q.target.value)),className:`${Yt} max-w-xs`,"data-testid":"filter-lookback",children:[h.jsx("option",{value:-1,children:"All time"}),u_.map((Q,Te)=>h.jsx("option",{value:Te,children:Q.label},Te))]}):h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs("label",{className:"space-y-1 flex-1",children:[h.jsx("span",{className:Kt,children:"From"}),h.jsx("input",{type:"datetime-local",value:s_(t.timestampMin),onChange:Q=>K(Q.target.value),className:Yt,"data-testid":"filter-timestampMin"})]}),h.jsxs("label",{className:"space-y-1 flex-1",children:[h.jsx("span",{className:Kt,children:"To"}),h.jsx("input",{type:"datetime-local",value:s_(t.timestampMax),onChange:Q=>be(Q.target.value),className:Yt,"data-testid":"filter-timestampMax"})]})]})]})]})]})}const t6={name:"Services",shortcuts:[{keys:["Backspace"],description:"Go back"}]},c_={Gauge:0,Sum:1,Histogram:2,ExponentialHistogram:3,Summary:4};function n6(t){const r=t.hasData?t.data:null,o=t.hasData?t.loading:!1,l=t.hasData?t.error:null,i=D.useMemo(()=>r!=null&&r.metrics?[...r.metrics].sort((u,c)=>u.name.localeCompare(c.name)||(c_[u.type]??99)-(c_[c.type]??99)):[],[r]);return o&&!i.length?h.jsx("p",{className:"text-muted-foreground py-4",children:"Loading metrics…"}):l?h.jsxs("p",{className:"text-red-400 py-4",children:["Error: ",l.message]}):i.length?h.jsx("div",{className:"overflow-x-auto",children:h.jsxs("table",{className:"w-full text-sm text-left text-foreground border-collapse",children:[h.jsx("thead",{className:"text-xs uppercase text-muted-foreground border-b border-border",children:h.jsxs("tr",{children:[h.jsx("th",{className:"px-3 py-2",children:"Name"}),h.jsx("th",{className:"px-3 py-2",children:"Type"}),h.jsx("th",{className:"px-3 py-2",children:"Unit"}),h.jsx("th",{className:"px-3 py-2",children:"Description"})]})}),h.jsx("tbody",{children:i.map(u=>h.jsxs("tr",{className:"border-b border-border/50 hover:bg-muted/40",children:[h.jsx("td",{className:"px-3 py-2 font-mono whitespace-nowrap",children:u.name}),h.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:u.type}),h.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:u.unit||"–"}),h.jsx("td",{className:"px-3 py-2 text-muted-foreground",children:u.description||"–"})]},`${u.name}-${u.type}`))})]})}):h.jsx("p",{className:"text-muted-foreground py-4",children:"No metrics discovered."})}Lz({name:"dashboard",components:{Card:{props:ie({title:U().nullable(),description:U().nullable(),padding:Ge(["sm","md","lg"]).nullable()}),hasChildren:!0,description:"A card container with optional title"},Grid:{props:ie({columns:ee().min(1).max(4).nullable(),gap:Ge(["sm","md","lg"]).nullable()}),hasChildren:!0,description:"Grid layout with configurable columns"},Stack:{props:ie({direction:Ge(["horizontal","vertical"]).nullable(),gap:Ge(["sm","md","lg"]).nullable(),align:Ge(["start","center","end","stretch"]).nullable()}),hasChildren:!0,description:"Flex stack for horizontal or vertical layouts"},Metric:{props:ie({label:U(),valuePath:U(),format:Ge(["number","currency","percent"]).nullable(),trend:Ge(["up","down","neutral"]).nullable(),trendValue:U().nullable()}),hasChildren:!1,description:"Display a single metric with optional trend indicator"},Chart:{props:ie({type:Ge(["bar","line","pie","area"]),dataPath:U(),title:U().nullable(),height:ee().nullable()}),hasChildren:!1,description:"Display a chart from array data"},Table:{props:ie({dataPath:U(),columns:le(ie({key:U(),label:U(),format:Ge(["text","currency","date","badge"]).nullable()}))}),hasChildren:!1,description:"Display tabular data"},List:{props:ie({dataPath:U(),emptyMessage:U().nullable()}),hasChildren:!0,description:"Render a list from array data"},Button:{props:ie({label:U(),variant:Ge(["primary","secondary","danger","ghost"]).nullable(),size:Ge(["sm","md","lg"]).nullable(),action:U(),disabled:Kn().nullable()}),hasChildren:!1,description:"Clickable button with action"},DatePicker:{props:ie({label:U().nullable(),bindPath:U(),placeholder:U().nullable()}),hasChildren:!1,description:"Date picker input"},Heading:{props:ie({text:U(),level:Ge(["h1","h2","h3","h4"]).nullable()}),hasChildren:!1,description:"Section heading"},Text:{props:ie({content:U(),variant:Ge(["body","caption","label"]).nullable(),color:Ge(["default","muted","success","warning","danger"]).nullable()}),hasChildren:!1,description:"Text paragraph"},Badge:{props:ie({text:U(),variant:Ge(["default","success","warning","danger","info"]).nullable()}),hasChildren:!1,description:"Small status badge"},Divider:{props:ie({label:U().nullable()}),hasChildren:!1,description:"Visual divider"},Empty:{props:ie({title:U(),description:U().nullable(),action:U().nullable(),actionLabel:U().nullable()}),hasChildren:!1,description:"Empty state placeholder"}}});function i6({element:t}){const{text:r,variant:o}=t.props;return h.jsx("span",{style:{display:"inline-block",padding:"2px 8px",borderRadius:12,fontSize:12,fontWeight:500,background:"hsl(var(--border))",color:{default:"hsl(var(--foreground))",success:"#22c55e",warning:"#eab308",danger:"#ef4444",info:"hsl(var(--muted-foreground))"}[o||"default"]},children:r})}function r6({element:t,children:r}){const{title:o,description:l,padding:i}=t.props;return h.jsxs("div",{style:{background:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"var(--radius)"},children:[(o||l)&&h.jsxs("div",{style:{padding:"16px 20px",borderBottom:"1px solid hsl(var(--border))"},children:[o&&h.jsx("h3",{style:{margin:0,fontSize:16,fontWeight:600},children:o}),l&&h.jsx("p",{style:{margin:"4px 0 0",fontSize:14,color:"hsl(var(--muted-foreground))"},children:l})]}),h.jsx("div",{style:{padding:{sm:"12px",md:"16px",lg:"24px"}[i||""]||"16px"},children:r})]})}function a6({element:t}){const{label:r}=t.props;return r?h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,margin:"16px 0"},children:[h.jsx("hr",{style:{flex:1,border:"none",borderTop:"1px solid hsl(var(--border))"}}),h.jsx("span",{style:{fontSize:12,color:"hsl(var(--muted-foreground))"},children:r}),h.jsx("hr",{style:{flex:1,border:"none",borderTop:"1px solid hsl(var(--border))"}})]}):h.jsx("hr",{style:{border:"none",borderTop:"1px solid hsl(var(--border))",margin:"16px 0"}})}function o6({element:t,onAction:r}){const{title:o,description:l,action:i,actionLabel:u}=t.props;return h.jsxs("div",{style:{textAlign:"center",padding:"40px 20px"},children:[h.jsx("h3",{style:{margin:"0 0 8px",fontSize:16,fontWeight:600},children:o}),l&&h.jsx("p",{style:{margin:"0 0 16px",fontSize:14,color:"hsl(var(--muted-foreground))"},children:l}),i&&u&&h.jsx("button",{onClick:()=>r==null?void 0:r(i),style:{padding:"8px 16px",borderRadius:"var(--radius)",border:"1px solid hsl(var(--border))",background:"hsl(var(--card))",color:"hsl(var(--foreground))",fontSize:14,cursor:"pointer"},children:u})]})}function l6({element:t,children:r}){const{columns:o,gap:l}=t.props;return h.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(${o||2}, 1fr)`,gap:{sm:"8px",md:"16px",lg:"24px"}[l||"md"]},children:r})}function u6({element:t}){const{text:r,level:o}=t.props;return h.jsx(o||"h2",{style:{margin:"0 0 16px",fontSize:{h1:"28px",h2:"24px",h3:"20px",h4:"16px"}[o||"h2"],fontWeight:600},children:r})}function s6({element:t,children:r}){const{direction:o,gap:l,align:i}=t.props;return h.jsx("div",{style:{display:"flex",flexDirection:o==="horizontal"?"row":"column",gap:{sm:"8px",md:"16px",lg:"24px"}[l||"md"],alignItems:{start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"}[i||"stretch"]},children:r})}function c6({element:t}){const{content:r,color:o}=t.props;return h.jsx("p",{style:{margin:0,color:{default:"hsl(var(--foreground))",muted:"hsl(var(--muted-foreground))",success:"#22c55e",warning:"#eab308",danger:"#ef4444"}[o||"default"]},children:r})}const d6=[{key:"services",label:"Services",shortcutKey:"S"},{key:"logs",label:"Logs",shortcutKey:"L"},{key:"metrics",label:"Metrics",shortcutKey:"M"}];function f6(){const t=new URLSearchParams(window.location.search),r=t.get("service"),o=t.get("trace"),l=t.get("span"),i=t.get("tab");return{tab:r?"services":i==="logs"||i==="metrics"?i:"services",service:r,trace:o,span:l}}function Bn(t,{replace:r=!1}={}){const o=new URLSearchParams;t.tab!=="services"&&o.set("tab",t.tab),t.service&&o.set("service",t.service),t.trace&&o.set("trace",t.trace),t.span&&o.set("span",t.span);const l=o.toString(),i=`${window.location.pathname}${l?`?${l}`:""}`;r?history.replaceState(null,"",i):history.pushState(null,"",i),dispatchEvent(new PopStateEvent("popstate"))}function m6(t){return window.addEventListener("popstate",t),()=>window.removeEventListener("popstate",t)}let d_="",f_={tab:"services",service:null,trace:null,span:null};function h6(){const t=window.location.search;return t!==d_&&(d_=t,f_=f6()),f_}function p6(){return D.useSyncExternalStore(m6,h6)}function Af(t){const r={};let o=!1;for(const l of t.split(",")){const i=l.trim();if(!i)continue;const u=i.indexOf("=");u<1||(r[i.slice(0,u)]=i.slice(u+1),o=!0)}return o?r:void 0}function If(t){return t?Object.entries(t).map(([r,o])=>`${r}=${o}`).join(","):""}function g6(){const t=new URLSearchParams(window.location.search),r={limit:200,sortOrder:"DESC"},o=t.get("severity");o&&(r.severityText=o);const l=t.get("body");l&&(r.bodyContains=l);const i=t.get("sort");(i==="ASC"||i==="DESC")&&(r.sortOrder=i);const u=t.get("limit");if(u){const q=parseInt(u,10);q>=1&&q<=1e3&&(r.limit=q)}const c=t.get("traceId");c&&(r.traceId=c);const m=t.get("spanId");m&&(r.spanId=m);const v=t.get("scope");v&&(r.scopeName=v);const g=t.get("tsMin");g&&(r.timestampMin=g);const _=t.get("tsMax");_&&(r.timestampMax=_);const b=t.get("logAttrs");b&&(r.logAttributes=Af(b));const x=t.get("resAttrs");x&&(r.resourceAttributes=Af(x));const $=t.get("scopeAttrs");$&&(r.scopeAttributes=Af($));const O=t.get("services"),T=O?O.split(",").filter(Boolean):[];return T.length===1&&(r.serviceName=T[0]),{filters:r,selectedServices:T,selectedLogId:t.get("log")||null}}function v6(t,r,o){const l=new URLSearchParams;l.set("tab","logs"),t.severityText&&l.set("severity",t.severityText),t.bodyContains&&l.set("body",t.bodyContains),r.length&&l.set("services",r.join(",")),t.sortOrder&&t.sortOrder!=="DESC"&&l.set("sort",t.sortOrder),t.limit!=null&&t.limit!==200&&l.set("limit",String(t.limit)),t.traceId&&l.set("traceId",t.traceId),t.spanId&&l.set("spanId",t.spanId),t.scopeName&&l.set("scope",t.scopeName),t.timestampMin&&l.set("tsMin",t.timestampMin),t.timestampMax&&l.set("tsMax",t.timestampMax);const i=If(t.logAttributes);i&&l.set("logAttrs",i);const u=If(t.resourceAttributes);u&&l.set("resAttrs",u);const c=If(t.scopeAttributes);c&&l.set("scopeAttrs",c),o&&l.set("log",o);const m=l.toString(),v=`${window.location.pathname}${m?`?${m}`:""}`;history.replaceState(null,"",v)}function m_(t){const r=t.trim();if(!r)return;const o=r.match(/^(\d+(?:\.\d+)?)\s*(us|ms|s)$/i);if(!o)return;const l=parseFloat(o[1]),i=o[2].toLowerCase();return String(Math.round(l*{us:1e3,ms:1e6,s:1e9}[i]))}function b6(){const[t]=D.useState(()=>g6()),[r,o]=D.useState(t.filters),[l,i]=D.useState(t.selectedServices),[u,c]=D.useState(t.selectedLogId);D.useEffect(()=>{v6(r,l,u)},[r,l,u]);const{logs:m,isLive:v,loading:g,error:_,setLive:b}=XO({params:r,pollIntervalMs:3e3}),x=D.useMemo(()=>{if(l.length<=1)return m;const T=new Set(l);return m.filter(q=>T.has(q.ServiceName??""))},[m,l]),$=D.useCallback(T=>{c(T.logId)},[]),O=D.useCallback((T,q)=>{var ne;Bn({tab:"services",service:((ne=x.find(te=>te.TraceId===T))==null?void 0:ne.ServiceName)??void 0,trace:T,span:q})},[x]);return h.jsxs("div",{style:{height:"calc(100vh - 160px)"},className:"flex flex-col",children:[h.jsx("div",{className:"shrink-0 mb-3",children:h.jsx(e6,{value:r,onChange:o,rows:m,selectedServices:l,onSelectedServicesChange:i})}),h.jsx("div",{className:"flex-1 min-h-0",children:h.jsx(Fw,{rows:x,isLoading:g,error:_??void 0,streaming:v,selectedLogId:u??void 0,onLogClick:$,onTraceLinkClick:O,onAtBottomChange:T=>b(T)})})]})}const y6={method:"searchTracesPage",params:{limit:1e3,sortOrder:"DESC"}};function _6({onSelect:t}){const{data:r,loading:o,error:l}=ac(y6);return h.jsx(uw,{services:D.useMemo(()=>{if(!(r!=null&&r.data))return[];const i=new Set;for(const u of r.data)i.add(u.ServiceName??"unknown");return Array.from(i).sort().map(u=>({name:u}))},[r]),isLoading:o,error:l??void 0,onSelect:t})}function x6({service:t,onBack:r,onSelectTrace:o}){const[l,i]=D.useState(()=>({method:"searchTracesPage",params:{serviceName:t,limit:20,sortOrder:"DESC"}})),u=D.useCallback($=>{const O={serviceName:t,limit:$.limit,sortOrder:"DESC"};if($.operation&&(O.spanName=$.operation),$.lookbackMs&&(O.timestampMin=String((Date.now()-$.lookbackMs)*1e6)),$.minDuration){const T=m_($.minDuration);T&&(O.durationMin=T)}if($.maxDuration){const T=m_($.maxDuration);T&&(O.durationMax=T)}i({method:"searchTracesPage",params:O})},[t]),{data:c,loading:m,error:v}=ac(l),g=rp(),[_,b]=D.useState(()=>new Map);D.useEffect(()=>{var T;if(!((T=c==null?void 0:c.data)!=null&&T.length)){b(new Map);return}const $=[...new Set(c.data.map(q=>q.TraceId))],O=new AbortController;return Promise.allSettled($.map(q=>g.getTrace(q,{signal:O.signal}).then(ne=>[q,ne]))).then(q=>{if(!O.signal.aborted){const ne=q.filter(te=>te.status==="fulfilled").map(te=>te.value);b(new Map(ne))}}).catch(q=>{O.signal.aborted||console.error("Failed to fetch full traces",q)}),()=>O.abort()},[c,g]);const x=D.useMemo(()=>{if(!(c!=null&&c.data))return[];const $=new Set;for(const O of c.data)O.SpanName&&$.add(O.SpanName);return Array.from($).sort()},[c]);return h.jsx(dw,{service:t,traces:D.useMemo(()=>{if(!(c!=null&&c.data))return[];const $=new Map;for(const O of c.data){const T=O.TraceId;$.has(T)||$.set(T,[]),$.get(T).push(O)}return Array.from($.entries()).map(([O,T])=>{const q=_.get(O)??T,ne=q.find(oe=>!oe.ParentSpanId)??q[0],te=ne.Duration?parseInt(ne.Duration,10):0,re=new Map;let J=0;for(const oe of q){const ue=oe.ServiceName??"unknown",pe=re.get(ue)??{count:0,hasError:!1};pe.count++,oe.StatusCode==="ERROR"&&(pe.hasError=!0,J++),re.set(ue,pe)}const X=Array.from(re.entries()).map(([oe,ue])=>({name:oe,count:ue.count,hasError:ue.hasError})).sort((oe,ue)=>ue.count-oe.count);return{traceId:O,rootSpanName:ne.SpanName??"unknown",serviceName:ne.ServiceName??"unknown",durationMs:te/1e6,statusCode:ne.StatusCode??"UNSET",timestampMs:parseInt(ne.Timestamp,10)/1e6,spanCount:q.length,services:X,errorCount:J}})},[c,_]),operations:x,isLoading:m,error:v??void 0,onSelectTrace:o,onBack:r,onSearch:u})}function S6({service:t,traceId:r,selectedSpanId:o,onSelectSpan:l,onBack:i}){const{data:u,loading:c,error:m}=ac(D.useMemo(()=>({method:"getTrace",params:{traceId:r}}),[r]));return h.jsx(Dw,{service:t,traceId:r,rows:u??[],isLoading:c,error:m??void 0,selectedSpanId:o??void 0,onSpanClick:v=>l(v.spanId),onBack:i})}function $6({selectedService:t,selectedTraceId:r,selectedSpanId:o,onSelectService:l,onSelectTrace:i,onSelectSpan:u,onBackToServices:c,onBackToTraceList:m}){ap("services-tab",t6);const v=D.useRef(c);v.current=c;const g=D.useRef(m);return g.current=m,D.useEffect(()=>{const _=b=>{b.target instanceof HTMLInputElement||b.target instanceof HTMLTextAreaElement||b.target instanceof HTMLSelectElement||b.key==="Backspace"&&(b.preventDefault(),r&&t?g.current():t&&v.current())};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[t,r]),r&&t?h.jsx(S6,{service:t,traceId:r,selectedSpanId:o,onSelectSpan:u,onBack:m}):t?h.jsx(x6,{service:t,onBack:c,onSelectTrace:i}):h.jsx(_6,{onSelect:l})}const z6=ew(WO,{Card:r6,Grid:l6,Stack:s6,Heading:u6,Text:c6,Badge:i6,Divider:a6,Empty:o6,LogTimeline:()=>null,TraceDetail:()=>null,MetricTimeSeries:()=>null,MetricHistogram:()=>null,MetricStat:()=>null,MetricTable:()=>null,MetricDiscovery:n6}),E6={root:"root",elements:{root:{key:"root",type:"Stack",children:["heading","description","discovery-card"],parentKey:"",props:{direction:"vertical",gap:"md",align:null}},heading:{key:"heading",type:"Heading",children:[],parentKey:"root",props:{text:"Metrics",level:"h2"}},description:{key:"description",type:"Text",children:[],parentKey:"root",props:{content:"Discovered OpenTelemetry metrics",variant:"body",color:"muted"}},"discovery-card":{key:"discovery-card",type:"Card",children:["metric-discovery"],parentKey:"root",props:{title:null,description:null,padding:null}},"metric-discovery":{key:"metric-discovery",type:"MetricDiscovery",children:[],parentKey:"discovery-card",dataSource:{method:"discoverMetrics"},props:{}}}};function T6(){return h.jsx(z6,{tree:E6})}const k6=new AO({baseUrl:"/signals"});function N6(){const{tab:t,service:r,trace:o,span:l}=p6(),i=D.useCallback(_=>{Bn({tab:_})},[]),u=D.useCallback(_=>{Bn({tab:"services",service:_})},[]),c=D.useCallback(_=>{Bn({tab:"services",service:r,trace:_})},[r]),m=D.useCallback(_=>{Bn({tab:"services",service:r,trace:o,span:_},{replace:!0})},[r,o]),v=D.useCallback(()=>{Bn({tab:"services"})},[]),g=D.useCallback(()=>{Bn({tab:"services",service:r})},[r]);return h.jsx(YO,{client:k6,children:h.jsx(kw,{onNavigateServices:()=>Bn({tab:"services"}),onNavigateLogs:()=>Bn({tab:"logs"}),onNavigateMetrics:()=>Bn({tab:"metrics"}),children:h.jsxs("div",{children:[h.jsx(rw,{tabs:d6,active:t,onChange:i}),t==="logs"&&h.jsx(b6,{}),t==="services"&&h.jsx($6,{selectedService:r,selectedTraceId:o,selectedSpanId:l,onSelectService:u,onSelectTrace:c,onSelectSpan:m,onBackToServices:v,onBackToTraceList:g}),t==="metrics"&&h.jsx(T6,{})]})})})}document.documentElement.classList.add("dark");document.body.classList.add("bg-background");O4.createRoot(document.getElementById("root")).render(h.jsx($4.StrictMode,{children:h.jsxs("div",{className:"min-h-screen bg-background text-foreground p-6",children:[h.jsxs("div",{className:"flex items-center justify-between mb-6",children:[h.jsx("h1",{className:"text-xl font-normal",style:{fontFamily:"ui-monospace, monospace"},children:h.jsx("span",{children:"k>"})}),h.jsxs("button",{className:"text-xs text-zinc-500 hover:text-zinc-300 transition-colors",onClick:()=>document.dispatchEvent(new KeyboardEvent("keydown",{key:"?",shiftKey:!0,bubbles:!0})),children:["Press"," ",h.jsx("kbd",{className:"px-1 py-0.5 text-xs border border-zinc-700 rounded bg-zinc-800",children:"?"})," ","for shortcuts"]})]}),h.jsx(N6,{})]})}));
@@ -9,7 +9,7 @@
9
9
  type="image/svg+xml"
10
10
  href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' fill='none'%3E%3Crect width='32' height='32' rx='4' fill='%230a0a0a'/%3E%3Ctext x='3' y='22' font-family='ui-monospace,monospace' font-size='16' font-weight='400' fill='%23fafafa'%3Ek%3E%3C/text%3E%3C/svg%3E"
11
11
  />
12
- <script type="module" crossorigin src="/assets/index-oJZ3KchX.js"></script>
12
+ <script type="module" crossorigin src="/assets/index-5oZTtMlU.js"></script>
13
13
  <link rel="stylesheet" crossorigin href="/assets/index-C5X3Abtu.css">
14
14
  </head>
15
15
  <body>
@@ -17,6 +17,7 @@ let node_path = require("node:path");
17
17
  let node_url = require("node:url");
18
18
  let _fastify_vite = require("@fastify/vite");
19
19
  _fastify_vite = require_config.__toESM(_fastify_vite);
20
+ let node_os = require("node:os");
20
21
 
21
22
  //#region src/routes/index.ts
22
23
  const apiRoutes = async function(fastify, opts) {
@@ -29,10 +30,64 @@ const otelCollectorRoutes = async function(fastify, opts) {
29
30
  fastify.register(_kopai_collector.collectorRoutes, opts);
30
31
  };
31
32
 
33
+ //#endregion
34
+ //#region src/startup-banner.ts
35
+ const isTTY = process.stdout.isTTY;
36
+ const bold = isTTY ? "\x1B[1m" : "";
37
+ const dim = isTTY ? "\x1B[2m" : "";
38
+ const green = isTTY ? "\x1B[32m" : "";
39
+ const cyan = isTTY ? "\x1B[36m" : "";
40
+ const reset = isTTY ? "\x1B[0m" : "";
41
+ function getNetworkAddress() {
42
+ const nets = (0, node_os.networkInterfaces)();
43
+ for (const interfaces of Object.values(nets)) {
44
+ if (!interfaces) continue;
45
+ for (const net of interfaces) if (net.family === "IPv4" && !net.internal) return net.address;
46
+ }
47
+ }
48
+ function printStartupBanner({ host, port, collectorPort, version }) {
49
+ const localHost = host === "0.0.0.0" || host === "::" ? "localhost" : host;
50
+ const networkAddress = getNetworkAddress();
51
+ const lines = [
52
+ "",
53
+ ` ${bold}${green}|--k> @kopai/app${reset} ${dim}v${version}${reset}`,
54
+ ""
55
+ ];
56
+ const rows = [
57
+ [
58
+ "Dashboard",
59
+ `http://${localHost}:${port}`,
60
+ ""
61
+ ],
62
+ [
63
+ "API Docs",
64
+ `http://${localHost}:${port}/documentation`,
65
+ "/documentation"
66
+ ],
67
+ [
68
+ "Collector",
69
+ `http://${localHost}:${collectorPort}`,
70
+ ""
71
+ ]
72
+ ];
73
+ const maxLocalLen = Math.max(...rows.map(([, url]) => url.length));
74
+ for (const [label, localUrl, path] of rows) {
75
+ const padded = localUrl.padEnd(maxLocalLen);
76
+ let line = ` ${green}▸${reset} ${bold}${label.padEnd(16)}${reset}${cyan}${padded}${reset}`;
77
+ if (networkAddress) {
78
+ const netUrl = `http://${networkAddress}:${label === "Collector" ? collectorPort : port}${path}`;
79
+ line += ` ${dim}${cyan}${netUrl}${reset}`;
80
+ }
81
+ lines.push(line);
82
+ }
83
+ lines.push("");
84
+ console.log(lines.join("\n"));
85
+ }
86
+
32
87
  //#endregion
33
88
  //#region src/server.ts
34
89
  const __dirname$1 = (0, node_path.dirname)((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
35
- const apiServer = (0, fastify.default)({ logger: true });
90
+ const apiServer = (0, fastify.default)({ logger: { level: "warn" } });
36
91
  apiServer.setValidatorCompiler(fastify_type_provider_zod.validatorCompiler);
37
92
  apiServer.setSerializerCompiler(fastify_type_provider_zod.serializerCompiler);
38
93
  const uiRoutes = ["/", "/*"];
@@ -90,46 +145,39 @@ apiServer.after(() => {
90
145
  await fastify$2.vite.ready();
91
146
  });
92
147
  });
93
- const collectorServer = (0, fastify.default)({ logger: true });
148
+ const collectorServer = (0, fastify.default)({ logger: { level: "warn" } });
94
149
  collectorServer.setValidatorCompiler(fastify_type_provider_zod.validatorCompiler);
95
150
  collectorServer.setSerializerCompiler(fastify_type_provider_zod.serializerCompiler);
96
151
  collectorServer.after(() => {
97
152
  collectorServer.register(otelCollectorRoutes, { telemetryDatasource });
98
153
  });
99
154
  async function run() {
100
- console.log(`|--k> @kopai/app v${require_cli.version}\n\n`);
101
155
  await apiServer.ready();
156
+ await collectorServer.ready();
102
157
  const host = require_config.env.HOST || "localhost";
103
158
  const port = require_config.env.PORT;
104
- const STANDARD_OTEL_HTTP_COLLECTOR_PORT = 4318;
105
- apiServer.listen({
159
+ const collectorPort = 4318;
160
+ await apiServer.listen({
106
161
  port,
107
- host,
108
- listenTextResolver(address) {
109
- return `API server listening at ${address}`;
110
- }
111
- }, (err, address) => {
112
- if (err) {
113
- console.error(err);
114
- process.exit(1);
115
- }
116
- apiServer.log.info(`API server documentation available at ${address}/documentation`);
162
+ host
117
163
  });
118
- await collectorServer.ready();
119
- collectorServer.listen({
120
- port: STANDARD_OTEL_HTTP_COLLECTOR_PORT,
164
+ await collectorServer.listen({
165
+ port: collectorPort,
166
+ host
167
+ });
168
+ printStartupBanner({
121
169
  host,
122
- listenTextResolver(address) {
123
- return `OTEL collector server listening at ${address}:${STANDARD_OTEL_HTTP_COLLECTOR_PORT}`;
124
- }
125
- }, (err) => {
126
- if (err) {
127
- console.error(err);
128
- process.exit(1);
129
- }
170
+ port,
171
+ collectorPort,
172
+ version: require_cli.version
130
173
  });
174
+ apiServer.log.level = "info";
175
+ collectorServer.log.level = "info";
131
176
  }
132
- run();
177
+ run().catch((err) => {
178
+ console.error(err);
179
+ process.exit(1);
180
+ });
133
181
  (0, close_with_grace.default)(async ({ signal, err }) => {
134
182
  if (err) {
135
183
  collectorServer.log.fatal({ err }, "Closing OTEL collector server with error");
@@ -12,6 +12,7 @@ import { createOptimizedDatasource, initializeDatabase } from "@kopai/sqlite-dat
12
12
  import { dirname, resolve } from "node:path";
13
13
  import { fileURLToPath } from "node:url";
14
14
  import FastifyVite from "@fastify/vite";
15
+ import { networkInterfaces } from "node:os";
15
16
 
16
17
  //#region src/routes/index.ts
17
18
  const apiRoutes = async function(fastify, opts) {
@@ -24,10 +25,64 @@ const otelCollectorRoutes = async function(fastify, opts) {
24
25
  fastify.register(collectorRoutes, opts);
25
26
  };
26
27
 
28
+ //#endregion
29
+ //#region src/startup-banner.ts
30
+ const isTTY = process.stdout.isTTY;
31
+ const bold = isTTY ? "\x1B[1m" : "";
32
+ const dim = isTTY ? "\x1B[2m" : "";
33
+ const green = isTTY ? "\x1B[32m" : "";
34
+ const cyan = isTTY ? "\x1B[36m" : "";
35
+ const reset = isTTY ? "\x1B[0m" : "";
36
+ function getNetworkAddress() {
37
+ const nets = networkInterfaces();
38
+ for (const interfaces of Object.values(nets)) {
39
+ if (!interfaces) continue;
40
+ for (const net of interfaces) if (net.family === "IPv4" && !net.internal) return net.address;
41
+ }
42
+ }
43
+ function printStartupBanner({ host, port, collectorPort, version }) {
44
+ const localHost = host === "0.0.0.0" || host === "::" ? "localhost" : host;
45
+ const networkAddress = getNetworkAddress();
46
+ const lines = [
47
+ "",
48
+ ` ${bold}${green}|--k> @kopai/app${reset} ${dim}v${version}${reset}`,
49
+ ""
50
+ ];
51
+ const rows = [
52
+ [
53
+ "Dashboard",
54
+ `http://${localHost}:${port}`,
55
+ ""
56
+ ],
57
+ [
58
+ "API Docs",
59
+ `http://${localHost}:${port}/documentation`,
60
+ "/documentation"
61
+ ],
62
+ [
63
+ "Collector",
64
+ `http://${localHost}:${collectorPort}`,
65
+ ""
66
+ ]
67
+ ];
68
+ const maxLocalLen = Math.max(...rows.map(([, url]) => url.length));
69
+ for (const [label, localUrl, path] of rows) {
70
+ const padded = localUrl.padEnd(maxLocalLen);
71
+ let line = ` ${green}▸${reset} ${bold}${label.padEnd(16)}${reset}${cyan}${padded}${reset}`;
72
+ if (networkAddress) {
73
+ const netUrl = `http://${networkAddress}:${label === "Collector" ? collectorPort : port}${path}`;
74
+ line += ` ${dim}${cyan}${netUrl}${reset}`;
75
+ }
76
+ lines.push(line);
77
+ }
78
+ lines.push("");
79
+ console.log(lines.join("\n"));
80
+ }
81
+
27
82
  //#endregion
28
83
  //#region src/server.ts
29
84
  const __dirname = dirname(fileURLToPath(import.meta.url));
30
- const apiServer = fastify({ logger: true });
85
+ const apiServer = fastify({ logger: { level: "warn" } });
31
86
  apiServer.setValidatorCompiler(validatorCompiler);
32
87
  apiServer.setSerializerCompiler(serializerCompiler);
33
88
  const uiRoutes = ["/", "/*"];
@@ -85,46 +140,39 @@ apiServer.after(() => {
85
140
  await fastify.vite.ready();
86
141
  });
87
142
  });
88
- const collectorServer = fastify({ logger: true });
143
+ const collectorServer = fastify({ logger: { level: "warn" } });
89
144
  collectorServer.setValidatorCompiler(validatorCompiler);
90
145
  collectorServer.setSerializerCompiler(serializerCompiler);
91
146
  collectorServer.after(() => {
92
147
  collectorServer.register(otelCollectorRoutes, { telemetryDatasource });
93
148
  });
94
149
  async function run() {
95
- console.log(`|--k> @kopai/app v${version}\n\n`);
96
150
  await apiServer.ready();
151
+ await collectorServer.ready();
97
152
  const host = env.HOST || "localhost";
98
153
  const port = env.PORT;
99
- const STANDARD_OTEL_HTTP_COLLECTOR_PORT = 4318;
100
- apiServer.listen({
154
+ const collectorPort = 4318;
155
+ await apiServer.listen({
101
156
  port,
102
- host,
103
- listenTextResolver(address) {
104
- return `API server listening at ${address}`;
105
- }
106
- }, (err, address) => {
107
- if (err) {
108
- console.error(err);
109
- process.exit(1);
110
- }
111
- apiServer.log.info(`API server documentation available at ${address}/documentation`);
157
+ host
112
158
  });
113
- await collectorServer.ready();
114
- collectorServer.listen({
115
- port: STANDARD_OTEL_HTTP_COLLECTOR_PORT,
159
+ await collectorServer.listen({
160
+ port: collectorPort,
161
+ host
162
+ });
163
+ printStartupBanner({
116
164
  host,
117
- listenTextResolver(address) {
118
- return `OTEL collector server listening at ${address}:${STANDARD_OTEL_HTTP_COLLECTOR_PORT}`;
119
- }
120
- }, (err) => {
121
- if (err) {
122
- console.error(err);
123
- process.exit(1);
124
- }
165
+ port,
166
+ collectorPort,
167
+ version
125
168
  });
169
+ apiServer.log.level = "info";
170
+ collectorServer.log.level = "info";
126
171
  }
127
- run();
172
+ run().catch((err) => {
173
+ console.error(err);
174
+ process.exit(1);
175
+ });
128
176
  closeWithGrace(async ({ signal, err }) => {
129
177
  if (err) {
130
178
  collectorServer.log.fatal({ err }, "Closing OTEL collector server with error");
@@ -140,4 +188,4 @@ closeWithGrace(async ({ signal, err }) => {
140
188
 
141
189
  //#endregion
142
190
  export { };
143
- //# sourceMappingURL=server-YFpVoJ3q.mjs.map
191
+ //# sourceMappingURL=server-DOf6Bn7W.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-DOf6Bn7W.mjs","names":[],"sources":["../src/routes/index.ts","../src/collector/index.ts","../src/startup-banner.ts","../src/server.ts"],"sourcesContent":["import type { FastifyPluginAsyncZod } from \"fastify-type-provider-zod\";\nimport { signalsRoutes } from \"@kopai/api\";\nimport { type datasource } from \"@kopai/core\";\n\nexport const apiRoutes: FastifyPluginAsyncZod<{\n readTelemetryDatasource: datasource.ReadTelemetryDatasource;\n}> = async function (fastify, opts) {\n fastify.register(signalsRoutes, {\n readTelemetryDatasource: opts.readTelemetryDatasource,\n });\n};\n","import type { FastifyPluginAsyncZod } from \"fastify-type-provider-zod\";\nimport { collectorRoutes } from \"@kopai/collector\";\nimport type { datasource } from \"@kopai/core\";\n\nexport const otelCollectorRoutes: FastifyPluginAsyncZod<{\n telemetryDatasource: datasource.WriteTelemetryDatasource;\n}> = async function (fastify, opts) {\n fastify.register(collectorRoutes, opts);\n};\n","import { networkInterfaces } from \"node:os\";\n\nconst isTTY = process.stdout.isTTY;\nconst bold = isTTY ? \"\\x1b[1m\" : \"\";\nconst dim = isTTY ? \"\\x1b[2m\" : \"\";\nconst green = isTTY ? \"\\x1b[32m\" : \"\";\nconst cyan = isTTY ? \"\\x1b[36m\" : \"\";\nconst reset = isTTY ? \"\\x1b[0m\" : \"\";\n\nfunction getNetworkAddress(): string | undefined {\n const nets = networkInterfaces();\n for (const interfaces of Object.values(nets)) {\n if (!interfaces) continue;\n for (const net of interfaces) {\n if (net.family === \"IPv4\" && !net.internal) {\n return net.address;\n }\n }\n }\n return undefined;\n}\n\nexport function printStartupBanner({\n host,\n port,\n collectorPort,\n version,\n}: {\n host: string;\n port: number;\n collectorPort: number;\n version: string;\n}) {\n const localHost = host === \"0.0.0.0\" || host === \"::\" ? \"localhost\" : host;\n const networkAddress = getNetworkAddress();\n\n const lines: string[] = [\n \"\",\n ` ${bold}${green}|--k> @kopai/app${reset} ${dim}v${version}${reset}`,\n \"\",\n ];\n\n const rows: [string, string, string][] = [\n [\"Dashboard\", `http://${localHost}:${port}`, \"\"],\n [\"API Docs\", `http://${localHost}:${port}/documentation`, \"/documentation\"],\n [\"Collector\", `http://${localHost}:${collectorPort}`, \"\"],\n ];\n\n const maxLocalLen = Math.max(...rows.map(([, url]) => url.length));\n\n for (const [label, localUrl, path] of rows) {\n const padded = localUrl.padEnd(maxLocalLen);\n let line = ` ${green}▸${reset} ${bold}${label.padEnd(16)}${reset}${cyan}${padded}${reset}`;\n if (networkAddress) {\n const netPort = label === \"Collector\" ? collectorPort : port;\n const netUrl = `http://${networkAddress}:${netPort}${path}`;\n line += ` ${dim}${cyan}${netUrl}${reset}`;\n }\n lines.push(line);\n }\n\n lines.push(\"\");\n console.log(lines.join(\"\\n\"));\n}\n","import fastify from \"fastify\";\nimport {\n jsonSchemaTransformObject,\n jsonSchemaTransform,\n serializerCompiler,\n validatorCompiler,\n} from \"fastify-type-provider-zod\";\nimport fastifySwagger from \"@fastify/swagger\";\nimport fastifySwaggerUI from \"@fastify/swagger-ui\";\nimport closeWithGrace from \"close-with-grace\";\n\nimport { env } from \"./config.js\";\nimport { version } from \"./version.js\";\nimport { apiRoutes } from \"./routes/index.js\";\nimport { otelCollectorRoutes } from \"./collector/index.js\";\nimport {\n initializeDatabase,\n createOptimizedDatasource,\n} from \"@kopai/sqlite-datasource\";\nimport { resolve, dirname } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport FastifyVite from \"@fastify/vite\";\nimport { printStartupBanner } from \"./startup-banner.js\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\nconst apiServer = fastify({\n logger: { level: \"warn\" },\n});\n\n// Add schema validator and serializer\napiServer.setValidatorCompiler(validatorCompiler);\napiServer.setSerializerCompiler(serializerCompiler);\n\nconst uiRoutes = [\"/\", \"/*\"];\napiServer.register(fastifySwagger, {\n openapi: {\n info: {\n title: \"Kopai App\",\n description: \"Kopai App documentation\",\n version,\n },\n servers: [],\n },\n transform: ({ schema, url, ...rest }) => {\n if (uiRoutes.includes(url)) return { schema: { hide: true }, url };\n return jsonSchemaTransform({ schema, url, ...rest });\n },\n transformObject: jsonSchemaTransformObject,\n});\n\napiServer.register(fastifySwaggerUI, {\n routePrefix: \"/documentation\",\n logo: {\n type: \"image/svg+xml\",\n content: Buffer.from(\n \"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxNjAgNDAiIGZpbGw9Im5vbmUiPjx0ZXh0IHg9IjAiIHk9IjI4IiBmb250LWZhbWlseT0idWktbW9ub3NwYWNlLCBtb25vc3BhY2UiIGZvbnQtc2l6ZT0iMjAiIGZvbnQtd2VpZ2h0PSI0MDAiIGZpbGw9IiNmYWZhZmEiPnwtLWsmZ3Q7IGtvcGFpPC90ZXh0Pjwvc3ZnPg==\",\n \"base64\"\n ),\n href: \"/documentation\",\n target: \"_blank\",\n },\n theme: {\n favicon: [\n {\n filename: \"favicon.svg\",\n rel: \"icon\",\n sizes: \"32x32\",\n type: \"image/svg+xml\",\n content: Buffer.from(\n \"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMiAzMiIgZmlsbD0ibm9uZSI+PHJlY3Qgd2lkdGg9IjMyIiBoZWlnaHQ9IjMyIiByeD0iNCIgZmlsbD0iIzBhMGEwYSIvPjx0ZXh0IHg9IjMiIHk9IjIyIiBmb250LWZhbWlseT0idWktbW9ub3NwYWNlLCBtb25vc3BhY2UiIGZvbnQtc2l6ZT0iMTYiIGZvbnQtd2VpZ2h0PSI0MDAiIGZpbGw9IiNmYWZhZmEiPmsmZ3Q7PC90ZXh0Pjwvc3ZnPg==\",\n \"base64\"\n ),\n },\n ],\n },\n});\n\nconst sqliteDatabase = initializeDatabase(env.SQLITE_DB_FILE_PATH);\nconst telemetryDatasource = createOptimizedDatasource(sqliteDatabase);\n\napiServer.after(() => {\n apiServer.register(apiRoutes, {\n readTelemetryDatasource: telemetryDatasource,\n });\n apiServer.register(async (fastify) => {\n await fastify.register(FastifyVite, {\n root: resolve(__dirname, \"..\"),\n distDir: \"dist\",\n dev: false,\n spa: true,\n });\n fastify.get(\"/\", (_req, reply) => reply.html());\n fastify.get(\"/*\", (_req, reply) => reply.html());\n await fastify.vite.ready();\n });\n});\n\nconst collectorServer = fastify({\n logger: { level: \"warn\" },\n});\n\ncollectorServer.setValidatorCompiler(validatorCompiler);\ncollectorServer.setSerializerCompiler(serializerCompiler);\n\ncollectorServer.after(() => {\n collectorServer.register(otelCollectorRoutes, {\n telemetryDatasource,\n });\n});\n\nasync function run() {\n await apiServer.ready();\n await collectorServer.ready();\n\n const host = env.HOST || \"localhost\";\n const port = env.PORT;\n const collectorPort = 4318;\n\n await apiServer.listen({ port, host });\n await collectorServer.listen({ port: collectorPort, host });\n\n printStartupBanner({ host, port, collectorPort, version });\n\n apiServer.log.level = \"info\";\n collectorServer.log.level = \"info\";\n}\n\nrun().catch((err) => {\n console.error(err);\n process.exit(1);\n});\n\ncloseWithGrace(async ({ signal, err }) => {\n if (err) {\n collectorServer.log.fatal(\n { err },\n \"Closing OTEL collector server with error\"\n );\n apiServer.log.fatal({ err }, \"Closing API server with error\");\n } else {\n collectorServer.log.info(\n `Received signal ${signal}, closing OTEL collector server`\n );\n apiServer.log.info(`Received signal ${signal}, closing API server`);\n }\n\n await collectorServer.close();\n sqliteDatabase?.close();\n await apiServer.close();\n});\n"],"mappings":";;;;;;;;;;;;;;;;;AAIA,MAAa,YAER,eAAgB,SAAS,MAAM;AAClC,SAAQ,SAAS,eAAe,EAC9B,yBAAyB,KAAK,yBAC/B,CAAC;;;;;ACLJ,MAAa,sBAER,eAAgB,SAAS,MAAM;AAClC,SAAQ,SAAS,iBAAiB,KAAK;;;;;ACLzC,MAAM,QAAQ,QAAQ,OAAO;AAC7B,MAAM,OAAO,QAAQ,YAAY;AACjC,MAAM,MAAM,QAAQ,YAAY;AAChC,MAAM,QAAQ,QAAQ,aAAa;AACnC,MAAM,OAAO,QAAQ,aAAa;AAClC,MAAM,QAAQ,QAAQ,YAAY;AAElC,SAAS,oBAAwC;CAC/C,MAAM,OAAO,mBAAmB;AAChC,MAAK,MAAM,cAAc,OAAO,OAAO,KAAK,EAAE;AAC5C,MAAI,CAAC,WAAY;AACjB,OAAK,MAAM,OAAO,WAChB,KAAI,IAAI,WAAW,UAAU,CAAC,IAAI,SAChC,QAAO,IAAI;;;AAOnB,SAAgB,mBAAmB,EACjC,MACA,MACA,eACA,WAMC;CACD,MAAM,YAAY,SAAS,aAAa,SAAS,OAAO,cAAc;CACtE,MAAM,iBAAiB,mBAAmB;CAE1C,MAAM,QAAkB;EACtB;EACA,KAAK,OAAO,MAAM,kBAAkB,MAAM,GAAG,IAAI,GAAG,UAAU;EAC9D;EACD;CAED,MAAM,OAAmC;EACvC;GAAC;GAAa,UAAU,UAAU,GAAG;GAAQ;GAAG;EAChD;GAAC;GAAY,UAAU,UAAU,GAAG,KAAK;GAAiB;GAAiB;EAC3E;GAAC;GAAa,UAAU,UAAU,GAAG;GAAiB;GAAG;EAC1D;CAED,MAAM,cAAc,KAAK,IAAI,GAAG,KAAK,KAAK,GAAG,SAAS,IAAI,OAAO,CAAC;AAElE,MAAK,MAAM,CAAC,OAAO,UAAU,SAAS,MAAM;EAC1C,MAAM,SAAS,SAAS,OAAO,YAAY;EAC3C,IAAI,OAAO,KAAK,MAAM,GAAG,MAAM,GAAG,OAAO,MAAM,OAAO,GAAG,GAAG,QAAQ,OAAO,SAAS;AACpF,MAAI,gBAAgB;GAElB,MAAM,SAAS,UAAU,eAAe,GADxB,UAAU,cAAc,gBAAgB,OACH;AACrD,WAAQ,KAAK,MAAM,OAAO,SAAS;;AAErC,QAAM,KAAK,KAAK;;AAGlB,OAAM,KAAK,GAAG;AACd,SAAQ,IAAI,MAAM,KAAK,KAAK,CAAC;;;;;ACtC/B,MAAM,YAAY,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;AAEzD,MAAM,YAAY,QAAQ,EACxB,QAAQ,EAAE,OAAO,QAAQ,EAC1B,CAAC;AAGF,UAAU,qBAAqB,kBAAkB;AACjD,UAAU,sBAAsB,mBAAmB;AAEnD,MAAM,WAAW,CAAC,KAAK,KAAK;AAC5B,UAAU,SAAS,gBAAgB;CACjC,SAAS;EACP,MAAM;GACJ,OAAO;GACP,aAAa;GACb;GACD;EACD,SAAS,EAAE;EACZ;CACD,YAAY,EAAE,QAAQ,KAAK,GAAG,WAAW;AACvC,MAAI,SAAS,SAAS,IAAI,CAAE,QAAO;GAAE,QAAQ,EAAE,MAAM,MAAM;GAAE;GAAK;AAClE,SAAO,oBAAoB;GAAE;GAAQ;GAAK,GAAG;GAAM,CAAC;;CAEtD,iBAAiB;CAClB,CAAC;AAEF,UAAU,SAAS,kBAAkB;CACnC,aAAa;CACb,MAAM;EACJ,MAAM;EACN,SAAS,OAAO,KACd,wRACA,SACD;EACD,MAAM;EACN,QAAQ;EACT;CACD,OAAO,EACL,SAAS,CACP;EACE,UAAU;EACV,KAAK;EACL,OAAO;EACP,MAAM;EACN,SAAS,OAAO,KACd,gVACA,SACD;EACF,CACF,EACF;CACF,CAAC;AAEF,MAAM,iBAAiB,mBAAmB,IAAI,oBAAoB;AAClE,MAAM,sBAAsB,0BAA0B,eAAe;AAErE,UAAU,YAAY;AACpB,WAAU,SAAS,WAAW,EAC5B,yBAAyB,qBAC1B,CAAC;AACF,WAAU,SAAS,OAAO,YAAY;AACpC,QAAM,QAAQ,SAAS,aAAa;GAClC,MAAM,QAAQ,WAAW,KAAK;GAC9B,SAAS;GACT,KAAK;GACL,KAAK;GACN,CAAC;AACF,UAAQ,IAAI,MAAM,MAAM,UAAU,MAAM,MAAM,CAAC;AAC/C,UAAQ,IAAI,OAAO,MAAM,UAAU,MAAM,MAAM,CAAC;AAChD,QAAM,QAAQ,KAAK,OAAO;GAC1B;EACF;AAEF,MAAM,kBAAkB,QAAQ,EAC9B,QAAQ,EAAE,OAAO,QAAQ,EAC1B,CAAC;AAEF,gBAAgB,qBAAqB,kBAAkB;AACvD,gBAAgB,sBAAsB,mBAAmB;AAEzD,gBAAgB,YAAY;AAC1B,iBAAgB,SAAS,qBAAqB,EAC5C,qBACD,CAAC;EACF;AAEF,eAAe,MAAM;AACnB,OAAM,UAAU,OAAO;AACvB,OAAM,gBAAgB,OAAO;CAE7B,MAAM,OAAO,IAAI,QAAQ;CACzB,MAAM,OAAO,IAAI;CACjB,MAAM,gBAAgB;AAEtB,OAAM,UAAU,OAAO;EAAE;EAAM;EAAM,CAAC;AACtC,OAAM,gBAAgB,OAAO;EAAE,MAAM;EAAe;EAAM,CAAC;AAE3D,oBAAmB;EAAE;EAAM;EAAM;EAAe;EAAS,CAAC;AAE1D,WAAU,IAAI,QAAQ;AACtB,iBAAgB,IAAI,QAAQ;;AAG9B,KAAK,CAAC,OAAO,QAAQ;AACnB,SAAQ,MAAM,IAAI;AAClB,SAAQ,KAAK,EAAE;EACf;AAEF,eAAe,OAAO,EAAE,QAAQ,UAAU;AACxC,KAAI,KAAK;AACP,kBAAgB,IAAI,MAClB,EAAE,KAAK,EACP,2CACD;AACD,YAAU,IAAI,MAAM,EAAE,KAAK,EAAE,gCAAgC;QACxD;AACL,kBAAgB,IAAI,KAClB,mBAAmB,OAAO,iCAC3B;AACD,YAAU,IAAI,KAAK,mBAAmB,OAAO,sBAAsB;;AAGrE,OAAM,gBAAgB,OAAO;AAC7B,iBAAgB,OAAO;AACvB,OAAM,UAAU,OAAO;EACvB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kopai/app",
3
- "version": "0.8.0",
3
+ "version": "0.10.0",
4
4
  "description": "Local OpenTelemetry backend for testing instrumentation - no Docker, no config, just npx",
5
5
  "keywords": [
6
6
  "opentelemetry",
@@ -54,11 +54,11 @@
54
54
  "fastify": "^5.7.4",
55
55
  "fastify-type-provider-zod": "^6.1.0",
56
56
  "zod": "^4.3.6",
57
- "@kopai/api": "0.2.3",
58
57
  "@kopai/collector": "0.4.0",
59
58
  "@kopai/core": "0.5.0",
60
59
  "@kopai/sqlite-datasource": "0.6.0",
61
- "@kopai/ui": "0.1.0"
60
+ "@kopai/ui": "0.2.0",
61
+ "@kopai/api": "0.2.3"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@types/react": "^19.2.10",
@@ -1 +0,0 @@
1
- {"version":3,"file":"server-YFpVoJ3q.mjs","names":[],"sources":["../src/routes/index.ts","../src/collector/index.ts","../src/server.ts"],"sourcesContent":["import type { FastifyPluginAsyncZod } from \"fastify-type-provider-zod\";\nimport { signalsRoutes } from \"@kopai/api\";\nimport { type datasource } from \"@kopai/core\";\n\nexport const apiRoutes: FastifyPluginAsyncZod<{\n readTelemetryDatasource: datasource.ReadTelemetryDatasource;\n}> = async function (fastify, opts) {\n fastify.register(signalsRoutes, {\n readTelemetryDatasource: opts.readTelemetryDatasource,\n });\n};\n","import type { FastifyPluginAsyncZod } from \"fastify-type-provider-zod\";\nimport { collectorRoutes } from \"@kopai/collector\";\nimport type { datasource } from \"@kopai/core\";\n\nexport const otelCollectorRoutes: FastifyPluginAsyncZod<{\n telemetryDatasource: datasource.WriteTelemetryDatasource;\n}> = async function (fastify, opts) {\n fastify.register(collectorRoutes, opts);\n};\n","import fastify from \"fastify\";\nimport {\n jsonSchemaTransformObject,\n jsonSchemaTransform,\n serializerCompiler,\n validatorCompiler,\n} from \"fastify-type-provider-zod\";\nimport fastifySwagger from \"@fastify/swagger\";\nimport fastifySwaggerUI from \"@fastify/swagger-ui\";\nimport closeWithGrace from \"close-with-grace\";\n\nimport { env } from \"./config.js\";\nimport { version } from \"./version.js\";\nimport { apiRoutes } from \"./routes/index.js\";\nimport { otelCollectorRoutes } from \"./collector/index.js\";\nimport {\n initializeDatabase,\n createOptimizedDatasource,\n} from \"@kopai/sqlite-datasource\";\nimport { resolve, dirname } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport FastifyVite from \"@fastify/vite\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\nconst apiServer = fastify({\n logger: true,\n});\n\n// Add schema validator and serializer\napiServer.setValidatorCompiler(validatorCompiler);\napiServer.setSerializerCompiler(serializerCompiler);\n\nconst uiRoutes = [\"/\", \"/*\"];\napiServer.register(fastifySwagger, {\n openapi: {\n info: {\n title: \"Kopai App\",\n description: \"Kopai App documentation\",\n version,\n },\n servers: [],\n },\n transform: ({ schema, url, ...rest }) => {\n if (uiRoutes.includes(url)) return { schema: { hide: true }, url };\n return jsonSchemaTransform({ schema, url, ...rest });\n },\n transformObject: jsonSchemaTransformObject,\n});\n\napiServer.register(fastifySwaggerUI, {\n routePrefix: \"/documentation\",\n logo: {\n type: \"image/svg+xml\",\n content: Buffer.from(\n \"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxNjAgNDAiIGZpbGw9Im5vbmUiPjx0ZXh0IHg9IjAiIHk9IjI4IiBmb250LWZhbWlseT0idWktbW9ub3NwYWNlLCBtb25vc3BhY2UiIGZvbnQtc2l6ZT0iMjAiIGZvbnQtd2VpZ2h0PSI0MDAiIGZpbGw9IiNmYWZhZmEiPnwtLWsmZ3Q7IGtvcGFpPC90ZXh0Pjwvc3ZnPg==\",\n \"base64\"\n ),\n href: \"/documentation\",\n target: \"_blank\",\n },\n theme: {\n favicon: [\n {\n filename: \"favicon.svg\",\n rel: \"icon\",\n sizes: \"32x32\",\n type: \"image/svg+xml\",\n content: Buffer.from(\n \"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMiAzMiIgZmlsbD0ibm9uZSI+PHJlY3Qgd2lkdGg9IjMyIiBoZWlnaHQ9IjMyIiByeD0iNCIgZmlsbD0iIzBhMGEwYSIvPjx0ZXh0IHg9IjMiIHk9IjIyIiBmb250LWZhbWlseT0idWktbW9ub3NwYWNlLCBtb25vc3BhY2UiIGZvbnQtc2l6ZT0iMTYiIGZvbnQtd2VpZ2h0PSI0MDAiIGZpbGw9IiNmYWZhZmEiPmsmZ3Q7PC90ZXh0Pjwvc3ZnPg==\",\n \"base64\"\n ),\n },\n ],\n },\n});\n\nconst sqliteDatabase = initializeDatabase(env.SQLITE_DB_FILE_PATH);\nconst telemetryDatasource = createOptimizedDatasource(sqliteDatabase);\n\napiServer.after(() => {\n apiServer.register(apiRoutes, {\n readTelemetryDatasource: telemetryDatasource,\n });\n apiServer.register(async (fastify) => {\n await fastify.register(FastifyVite, {\n root: resolve(__dirname, \"..\"),\n distDir: \"dist\",\n dev: false,\n spa: true,\n });\n fastify.get(\"/\", (_req, reply) => reply.html());\n fastify.get(\"/*\", (_req, reply) => reply.html());\n await fastify.vite.ready();\n });\n});\n\nconst collectorServer = fastify({\n logger: true,\n});\n\ncollectorServer.setValidatorCompiler(validatorCompiler);\ncollectorServer.setSerializerCompiler(serializerCompiler);\n\ncollectorServer.after(() => {\n collectorServer.register(otelCollectorRoutes, {\n telemetryDatasource,\n });\n});\n\nasync function run() {\n console.log(`|--k> @kopai/app v${version}\\n\\n`);\n\n await apiServer.ready();\n\n const host = env.HOST || \"localhost\";\n const port = env.PORT;\n const STANDARD_OTEL_HTTP_COLLECTOR_PORT = 4318;\n\n apiServer.listen(\n {\n port,\n host,\n listenTextResolver(address) {\n return `API server listening at ${address}`;\n },\n },\n (err, address) => {\n if (err) {\n console.error(err);\n process.exit(1);\n }\n apiServer.log.info(\n `API server documentation available at ${address}/documentation`\n );\n }\n );\n\n await collectorServer.ready();\n\n collectorServer.listen(\n {\n port: STANDARD_OTEL_HTTP_COLLECTOR_PORT,\n host,\n listenTextResolver(address) {\n return `OTEL collector server listening at ${address}:${STANDARD_OTEL_HTTP_COLLECTOR_PORT}`;\n },\n },\n (err) => {\n if (err) {\n console.error(err);\n process.exit(1);\n }\n }\n );\n}\n\nrun();\n\ncloseWithGrace(async ({ signal, err }) => {\n if (err) {\n collectorServer.log.fatal(\n { err },\n \"Closing OTEL collector server with error\"\n );\n apiServer.log.fatal({ err }, \"Closing API server with error\");\n } else {\n collectorServer.log.info(\n `Received signal ${signal}, closing OTEL collector server`\n );\n apiServer.log.info(`Received signal ${signal}, closing API server`);\n }\n\n await collectorServer.close();\n sqliteDatabase?.close();\n await apiServer.close();\n});\n"],"mappings":";;;;;;;;;;;;;;;;AAIA,MAAa,YAER,eAAgB,SAAS,MAAM;AAClC,SAAQ,SAAS,eAAe,EAC9B,yBAAyB,KAAK,yBAC/B,CAAC;;;;;ACLJ,MAAa,sBAER,eAAgB,SAAS,MAAM;AAClC,SAAQ,SAAS,iBAAiB,KAAK;;;;;ACgBzC,MAAM,YAAY,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;AAEzD,MAAM,YAAY,QAAQ,EACxB,QAAQ,MACT,CAAC;AAGF,UAAU,qBAAqB,kBAAkB;AACjD,UAAU,sBAAsB,mBAAmB;AAEnD,MAAM,WAAW,CAAC,KAAK,KAAK;AAC5B,UAAU,SAAS,gBAAgB;CACjC,SAAS;EACP,MAAM;GACJ,OAAO;GACP,aAAa;GACb;GACD;EACD,SAAS,EAAE;EACZ;CACD,YAAY,EAAE,QAAQ,KAAK,GAAG,WAAW;AACvC,MAAI,SAAS,SAAS,IAAI,CAAE,QAAO;GAAE,QAAQ,EAAE,MAAM,MAAM;GAAE;GAAK;AAClE,SAAO,oBAAoB;GAAE;GAAQ;GAAK,GAAG;GAAM,CAAC;;CAEtD,iBAAiB;CAClB,CAAC;AAEF,UAAU,SAAS,kBAAkB;CACnC,aAAa;CACb,MAAM;EACJ,MAAM;EACN,SAAS,OAAO,KACd,wRACA,SACD;EACD,MAAM;EACN,QAAQ;EACT;CACD,OAAO,EACL,SAAS,CACP;EACE,UAAU;EACV,KAAK;EACL,OAAO;EACP,MAAM;EACN,SAAS,OAAO,KACd,gVACA,SACD;EACF,CACF,EACF;CACF,CAAC;AAEF,MAAM,iBAAiB,mBAAmB,IAAI,oBAAoB;AAClE,MAAM,sBAAsB,0BAA0B,eAAe;AAErE,UAAU,YAAY;AACpB,WAAU,SAAS,WAAW,EAC5B,yBAAyB,qBAC1B,CAAC;AACF,WAAU,SAAS,OAAO,YAAY;AACpC,QAAM,QAAQ,SAAS,aAAa;GAClC,MAAM,QAAQ,WAAW,KAAK;GAC9B,SAAS;GACT,KAAK;GACL,KAAK;GACN,CAAC;AACF,UAAQ,IAAI,MAAM,MAAM,UAAU,MAAM,MAAM,CAAC;AAC/C,UAAQ,IAAI,OAAO,MAAM,UAAU,MAAM,MAAM,CAAC;AAChD,QAAM,QAAQ,KAAK,OAAO;GAC1B;EACF;AAEF,MAAM,kBAAkB,QAAQ,EAC9B,QAAQ,MACT,CAAC;AAEF,gBAAgB,qBAAqB,kBAAkB;AACvD,gBAAgB,sBAAsB,mBAAmB;AAEzD,gBAAgB,YAAY;AAC1B,iBAAgB,SAAS,qBAAqB,EAC5C,qBACD,CAAC;EACF;AAEF,eAAe,MAAM;AACnB,SAAQ,IAAI,qBAAqB,QAAQ,MAAM;AAE/C,OAAM,UAAU,OAAO;CAEvB,MAAM,OAAO,IAAI,QAAQ;CACzB,MAAM,OAAO,IAAI;CACjB,MAAM,oCAAoC;AAE1C,WAAU,OACR;EACE;EACA;EACA,mBAAmB,SAAS;AAC1B,UAAO,2BAA2B;;EAErC,GACA,KAAK,YAAY;AAChB,MAAI,KAAK;AACP,WAAQ,MAAM,IAAI;AAClB,WAAQ,KAAK,EAAE;;AAEjB,YAAU,IAAI,KACZ,yCAAyC,QAAQ,gBAClD;GAEJ;AAED,OAAM,gBAAgB,OAAO;AAE7B,iBAAgB,OACd;EACE,MAAM;EACN;EACA,mBAAmB,SAAS;AAC1B,UAAO,sCAAsC,QAAQ,GAAG;;EAE3D,GACA,QAAQ;AACP,MAAI,KAAK;AACP,WAAQ,MAAM,IAAI;AAClB,WAAQ,KAAK,EAAE;;GAGpB;;AAGH,KAAK;AAEL,eAAe,OAAO,EAAE,QAAQ,UAAU;AACxC,KAAI,KAAK;AACP,kBAAgB,IAAI,MAClB,EAAE,KAAK,EACP,2CACD;AACD,YAAU,IAAI,MAAM,EAAE,KAAK,EAAE,gCAAgC;QACxD;AACL,kBAAgB,IAAI,KAClB,mBAAmB,OAAO,iCAC3B;AACD,YAAU,IAAI,KAAK,mBAAmB,OAAO,sBAAsB;;AAGrE,OAAM,gBAAgB,OAAO;AAC7B,iBAAgB,OAAO;AACvB,OAAM,UAAU,OAAO;EACvB"}