From 7093552d2ce71b58ef93308a9a6f0d435e0681e0 Mon Sep 17 00:00:00 2001 From: Vishal Rana Date: Fri, 16 Oct 2026 15:16:02 -0700 Subject: [PATCH 1/2] site: lean landing with a live replay of the measured run The landing page now leads with Fanout's measured ingest and real product captures, with no hand-drawn visuals. - Hero: a uPlot replay of the v2026.10.8-alpha sustained mixed phase. Points are trailing five-second rates from Fanout's accepted-row counters. The headline and legend show the five-minute averages, and the live rate appears beside the replay clock. Without JavaScript, or with reduced motion, the complete run renders as SVG. uPlot loads on the landing page only. - A stat band, then three captures from a Fanout instance receiving the OpenTelemetry Demo: the System overview, the service map and a trace waterfall, in light and dark to match the site theme. - The Preview, Contrast, Pipeline, Benchmark and Refusals sections are removed; the limits they listed move to status/capabilities. - site/scripts/benchmark-data.mjs derives the data module from a fanout-bench report, and check-benchmark-numbers.mjs keeps the README and docs figures in line with it. - `just landing-captures` refreshes the captures from the seeded e2e server or an existing instance. Its trace pick reuses the waterfall's pagination, now shared from ui/host/src/dashboards/trace/pagination.ts. Claude-Session: https://claude.ai/code/session_01XA52nWyQ3R5f5kK8kjpAQW --- README.md | 9 +- docs/testing.md | 2 + internal/mcp/apps/panels.html | 116 +- .../{chat-D8Nl9xGT.js => chat-_owdy9Bf.js} | 4 +- .../ui/dist/assets/chat._threadId-BsJLgkqj.js | 1 - .../ui/dist/assets/chat._threadId-eVfsC4Jb.js | 1 + .../ui/dist/assets/chat.index-BsJLgkqj.js | 1 - .../ui/dist/assets/chat.index-eVfsC4Jb.js | 1 + ...js => dashboards._dashboardId-09220iIf.js} | 2 +- ...ZMYeFV.js => dashboards.index-mQSdDlyY.js} | 2 +- .../{index-ZyJwWZ_-.js => index-CNsdEvGl.js} | 4 +- ...-DpQJtTNR.js => mcp-app-frame-tweTxib0.js} | 2 +- .../{page-D0-Qm4dK.js => page-vAmZFsvk.js} | 2 +- ...tings-gNliABpX.js => settings-BnFwabAq.js} | 2 +- internal/ui/dist/index.html | 2 +- justfile | 4 + site/package-lock.json | 9 +- site/package.json | 5 +- site/scripts/benchmark-data.mjs | 172 ++ site/scripts/benchmark-data.test.mjs | 126 + site/scripts/check-benchmark-numbers.mjs | 69 + site/scripts/throughput-replay.test.mjs | 293 ++ site/src/assets/landing/overview-dark.png | Bin 0 -> 342721 bytes site/src/assets/landing/overview-light.png | Bin 0 -> 394207 bytes site/src/assets/landing/service-map-dark.png | Bin 0 -> 150016 bytes site/src/assets/landing/service-map-light.png | Bin 0 -> 150701 bytes site/src/assets/landing/trace-dark.png | Bin 0 -> 286558 bytes site/src/assets/landing/trace-light.png | Bin 0 -> 272860 bytes site/src/components/landing/Benchmark.astro | 119 - .../components/landing/BenchmarkSweep.astro | 8 +- site/src/components/landing/CaptureRow.astro | 43 + site/src/components/landing/Contrast.astro | 160 - site/src/components/landing/Hero.astro | 355 +-- site/src/components/landing/Pipeline.astro | 169 -- site/src/components/landing/Preview.astro | 319 -- .../components/landing/ProductCapture.astro | 53 + site/src/components/landing/ProofStrip.astro | 86 +- site/src/components/landing/Refusals.astro | 67 - site/src/components/landing/Section.astro | 80 - .../components/landing/ThroughputReplay.astro | 152 + .../landing/ThroughputReplayClient.astro | 8 + .../components/landing/throughput-replay.ts | 203 ++ .../content/docs/explanation/performance.mdx | 137 +- site/src/content/docs/index.mdx | 114 +- site/src/content/docs/status/capabilities.mdx | 12 +- site/src/data/benchmark.ts | 2574 +++++++++++++++-- site/src/styles/fanout.css | 5 +- ui/host/e2e/global-setup.ts | 3 + ui/host/e2e/landing-captures.spec.ts | 202 ++ ui/host/e2e/landing-trace-support.test.ts | 80 + ui/host/e2e/landing-trace-support.ts | 47 + ui/host/src/dashboards/trace/components.tsx | 5 +- ui/host/src/dashboards/trace/pagination.ts | 7 + .../src/dashboards/trace/trace-components.tsx | 2 +- 54 files changed, 4069 insertions(+), 1770 deletions(-) rename internal/ui/dist/assets/{chat-D8Nl9xGT.js => chat-_owdy9Bf.js} (99%) delete mode 100644 internal/ui/dist/assets/chat._threadId-BsJLgkqj.js create mode 100644 internal/ui/dist/assets/chat._threadId-eVfsC4Jb.js delete mode 100644 internal/ui/dist/assets/chat.index-BsJLgkqj.js create mode 100644 internal/ui/dist/assets/chat.index-eVfsC4Jb.js rename internal/ui/dist/assets/{dashboards._dashboardId-ClSSKrZi.js => dashboards._dashboardId-09220iIf.js} (75%) rename internal/ui/dist/assets/{dashboards.index-DTZMYeFV.js => dashboards.index-mQSdDlyY.js} (70%) rename internal/ui/dist/assets/{index-ZyJwWZ_-.js => index-CNsdEvGl.js} (99%) rename internal/ui/dist/assets/{mcp-app-frame-DpQJtTNR.js => mcp-app-frame-tweTxib0.js} (99%) rename internal/ui/dist/assets/{page-D0-Qm4dK.js => page-vAmZFsvk.js} (96%) rename internal/ui/dist/assets/{settings-gNliABpX.js => settings-BnFwabAq.js} (99%) create mode 100644 site/scripts/benchmark-data.mjs create mode 100644 site/scripts/benchmark-data.test.mjs create mode 100644 site/scripts/check-benchmark-numbers.mjs create mode 100644 site/scripts/throughput-replay.test.mjs create mode 100644 site/src/assets/landing/overview-dark.png create mode 100644 site/src/assets/landing/overview-light.png create mode 100644 site/src/assets/landing/service-map-dark.png create mode 100644 site/src/assets/landing/service-map-light.png create mode 100644 site/src/assets/landing/trace-dark.png create mode 100644 site/src/assets/landing/trace-light.png delete mode 100644 site/src/components/landing/Benchmark.astro create mode 100644 site/src/components/landing/CaptureRow.astro delete mode 100644 site/src/components/landing/Contrast.astro delete mode 100644 site/src/components/landing/Pipeline.astro delete mode 100644 site/src/components/landing/Preview.astro create mode 100644 site/src/components/landing/ProductCapture.astro delete mode 100644 site/src/components/landing/Refusals.astro delete mode 100644 site/src/components/landing/Section.astro create mode 100644 site/src/components/landing/ThroughputReplay.astro create mode 100644 site/src/components/landing/ThroughputReplayClient.astro create mode 100644 site/src/components/landing/throughput-replay.ts create mode 100644 ui/host/e2e/landing-captures.spec.ts create mode 100644 ui/host/e2e/landing-trace-support.test.ts create mode 100644 ui/host/e2e/landing-trace-support.ts create mode 100644 ui/host/src/dashboards/trace/pagination.ts diff --git a/README.md b/README.md index 8c97eab1..ee08baf2 100644 --- a/README.md +++ b/README.md @@ -163,11 +163,10 @@ runbook](docs/operations.md). ## Performance -Fanout v2026.10.7-alpha accepted **422,408 mixed OpenTelemetry items/s for five minutes** -on a Hetzner Cloud ccx33 (8 dedicated vCPUs, 32 GB RAM), with telemetrygen on a separate -ccx33 over a private network. The run measured ingest only. See the [performance -methodology](https://fanout.run/explanation/performance) and [raw -evidence](https://github.com/labstack/fanout-bench/tree/main/published/2026-10-16-ccx33x2-v2026.10.7-alpha). +Fanout v2026.10.8-alpha accepted **415,859 mixed OpenTelemetry items/s** +over 303.5 seconds on a Hetzner Cloud ccx33 (8 dedicated vCPUs, 32 GB RAM), with +telemetrygen on a separate ccx33. The ingest run on 16 October 2026 passed every +quality gate. See the [performance methodology](https://fanout.run/explanation/performance). [Fanout Bench](https://github.com/labstack/fanout-bench) reproduces the measurement on your hardware. ## Build from source diff --git a/docs/testing.md b/docs/testing.md index 751a34f6..ae6d509c 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -166,3 +166,5 @@ to check the sidebar and compile pages, then run the table, social-card and canonical guards included in that script. `just site-build` also installs site dependencies; use the installed build directly when dependency installation is outside the verification environment's scope. Neither command publishes the site. + +Refresh the landing page’s light and dark product captures with `rtk just landing-captures` (real seeded server and local Chrome); to capture a real workload on an existing instance such as Fanout v2026.10.7-alpha through a local tunnel, set `FANOUT_LANDING_BASE_URL=http://127.0.0.1:17520` and `FANOUT_LANDING_SESSION_COOKIE` to the `name=value` session cookie from first-admin setup before running the same command (no server startup or seed, default live dashboard range, and a complete trace with at least 10 spans across 3 services, preferring success). diff --git a/internal/mcp/apps/panels.html b/internal/mcp/apps/panels.html index 684b331e..d73d396a 100644 --- a/internal/mcp/apps/panels.html +++ b/internal/mcp/apps/panels.html @@ -1,18 +1,18 @@ -Fanout panels +- "app": Tool callable by the app from this server only`),csp:f6().optional(),permissions:f6().optional()}),Q({mimeTypes:Z(Y()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),Q({method:$(`ui/download-file`),params:Q({contents:Z(g6([h5,g5])).describe(`Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.`)})}),Q({method:$(`ui/message`),params:Q({role:$(`user`).describe(`Message role, currently only "user" is supported.`),content:Z(_5).describe(`Message content blocks (text, image, etc.).`)})}),Q({method:$(`ui/notifications/sandbox-resource-ready`),params:Q({html:Y().describe(`HTML content to load into the inner iframe.`),sandbox:Y().optional().describe(`Optional override for the inner iframe's sandbox attribute.`),csp:J9.optional().describe(`CSP configuration from resource metadata.`),permissions:Y9.optional().describe(`Sandbox permissions from resource metadata.`)})});var rFe=Q({method:$(`ui/notifications/tool-result`),params:E5.describe(`Standard MCP tool execution result.`)}),Z9=Q({toolInfo:Q({id:$6.optional().describe(`JSON-RPC id of the tools/call request.`),tool:C5.describe(`Tool definition including name, inputSchema, etc.`)}).optional().describe(`Metadata of the tool call that instantiated this App.`),theme:VPe.optional().describe(`Current color theme preference.`),styles:XPe.optional().describe(`Style configuration for theming the app.`),displayMode:q9.optional().describe(`How the UI is currently displayed.`),availableDisplayModes:Z(q9).optional().describe(`Display modes the host supports.`),containerDimensions:g6([Q({height:X().describe(`Fixed container height in pixels.`)}),Q({maxHeight:g6([X(),c6()]).optional().describe(`Maximum container height in pixels.`)})]).and(g6([Q({width:X().describe(`Fixed container width in pixels.`)}),Q({maxWidth:g6([X(),c6()]).optional().describe(`Maximum container width in pixels.`)})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other +container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:Y().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:Y().optional().describe(`User's timezone in IANA format.`),userAgent:Y().optional().describe(`Host application identifier.`),platform:g6([$(`web`),$(`desktop`),$(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:Q({touch:s6().optional().describe(`Whether the device supports touch input.`),hover:s6().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:Q({top:X().describe(`Top safe area inset in pixels.`),right:X().describe(`Right safe area inset in pixels.`),bottom:X().describe(`Bottom safe area inset in pixels.`),left:X().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough(),iFe=Q({method:$(`ui/notifications/host-context-changed`),params:Z9.describe(`Partial context update containing only changed fields.`)});Q({method:$(`ui/update-model-context`),params:Q({content:Z(_5).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:b6(Y(),d6().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),Q({method:$(`ui/initialize`),params:Q({appInfo:d8.describe(`App identification (name and version).`),appCapabilities:eFe.describe(`Features and capabilities this app provides.`),protocolVersion:Y().describe(`Protocol version this app supports.`)})});var aFe=Q({protocolVersion:Y().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:d8.describe(`Host application identification and version.`),hostCapabilities:$Pe.describe(`Features and capabilities provided by the host.`),hostContext:Z9.describe(`Rich context about the host environment.`)}).passthrough(),oFe={target:`draft-2020-12`};async function Q9(e,t){let n=e[`~standard`];if(n.jsonSchema)return n.jsonSchema[t](oFe);throw Error(`Schema (vendor: ${n.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function $9(e,t,n=``){let r=await e[`~standard`].validate(t);if(r.issues){let e=r.issues.map(e=>{let t=e.path?.map(e=>typeof e==`object`?e.key:e).join(`.`);return t?`${t}: ${e.message}`:e.message}).join(`; `);throw Error(n+e)}return r.value}function sFe(e,t){let n={...e,...t};return t.experimental!==void 0&&(n.experimental={...e.experimental,...t.experimental}),t.tools!==void 0&&(n.tools={...e.tools,...t.tools}),n}var cFe=class e extends CPe{_appInfo;_appCapabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_registeredEvents=new Set;_events=new LPe;_methods=new RPe;setRequestHandler=(...e)=>{let[t,...n]=G9(`request`,e)??e;this._methods.claim(t,`setRequestHandler`),super.setRequestHandler.call(this,t,...n)};setNotificationHandler=(...e)=>{let[t,...n]=G9(`notification`,e)??e;this._methods.claim(t,`setNotificationHandler`),super.setNotificationHandler.call(this,t,...n)};removeRequestHandler=e=>{this._methods.release(e),super.removeRequestHandler(e)};removeNotificationHandler=e=>{this._methods.release(e),super.removeNotificationHandler(e)};replaceRequestHandler=(e,...t)=>{this._methods.replace(e),super.setRequestHandler.call(this,e,...t)};_assertInitialized(e){if(this._initializedSent)return;let t=`[ext-apps] App.${e}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(t);console.warn(`${t}. This will throw in a future release.`)}eventSchemas={toolinput:KPe,toolinputpartial:qPe,toolresult:rFe,toolcancelled:JPe,hostcontextchanged:iFe};static ONE_SHOT_EVENTS=new Set([`toolinput`,`toolinputpartial`,`toolresult`,`toolcancelled`]);_everHadListener=new Set;_assertHandlerTiming(t){if(!e.ONE_SHOT_EVENTS.has(t)||this._everHadListener.has(t)||(this._everHadListener.add(t),!this._initializedSent))return;let n=`[ext-apps] "${String(t)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(n);console.warn(n)}setEventHandler(e,t){t&&this._assertHandlerTiming(e),this._ensureEventSlot(e),this._events.setHandler(e,t)}addEventListener(e,t){this._assertHandlerTiming(e),this._ensureEventSlot(e),this._events.addEventListener(e,t)}removeEventListener(e,t){this._events.removeEventListener(e,t)}_ensureEventSlot(e){if(this._registeredEvents.has(e))return;let t=this.eventSchemas[e];if(!t)throw Error(`Unknown event: ${String(e)}`);this.setNotificationHandler(t.shape.method.value,{params:t.shape.params},t=>{let n=t;e===`hostcontextchanged`&&(this._hostContext={...this._hostContext,...n}),this._events.dispatch(e,n)}),this._registeredEvents.add(e)}getEventHandler(e){return this._events.getHandler(e)}warnIfRequestHandlerReplaced(e,t,n){t&&n&&console.warn(`[MCP Apps] ${e} handler replaced. Previous handler will no longer be called.`)}constructor(e,t={},n={autoResize:!0}){super(n),this._appInfo=e,this._appCapabilities=t,this.options=n,this._methods.replace(`notifications/cancelled`),this._methods.replace(`notifications/progress`),!n.allowUnsafeEval&&b2({jitless:!0}),this.replaceRequestHandler(`ping`,e=>(console.log(`Received ping:`,e.params),{})),this.setEventHandler(`hostcontextchanged`,void 0)}buildContext(e){return e}registerAppCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after transport is established`);this._appCapabilities=sFe(this._appCapabilities,e)}registerTool(e,t,n){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let r=this,i=()=>{r._initializedSent&&r._appCapabilities.tools?.listChanged&&r.sendToolListChanged()},a=t.inputSchema!==void 0,o={title:t.title,description:t.description,inputSchema:t.inputSchema,outputSchema:t.outputSchema,annotations:t.annotations,_meta:t._meta,enabled:!0,enable(){this.enabled=!0,i()},disable(){this.enabled=!1,i()},update(e){Object.assign(this,e),i()},remove(){r._registeredTools[e]===o&&(delete r._registeredTools[e],i())},handler:async(t,r)=>{if(!o.enabled)throw Error(`Tool ${e} is disabled`);let i;if(a){let a=o.inputSchema;i=await n(a?await $9(a,t??{},`Invalid input for tool ${e}: `):t??{},r)}else i=await n(r);return o.outputSchema&&!i.isError&&(i.structuredContent=await $9(o.outputSchema,i.structuredContent,`Invalid output for tool ${e}: `)),i}};return this._registeredTools[e]=o,!this._appCapabilities.tools&&!this.transport&&this.registerAppCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),i(),o}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(e,t)=>{let n=this._registeredTools[e.name];if(!n)throw Error(`Tool ${e.name} not found`);return n.handler(e.arguments,t)},this.onlisttools=async(e,t)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([e,t])=>t.enabled).map(async([e,t])=>{let n={name:e,title:t.title,description:t.description,inputSchema:t.inputSchema?await Q9(t.inputSchema,`input`):{type:`object`,properties:{}}};return t.outputSchema&&(n.outputSchema=await Q9(t.outputSchema,`output`)),t.annotations&&(n.annotations=t.annotations),t._meta&&(n._meta=t._meta),n}))}))}async sendToolListChanged(e={}){this._assertInitialized(`sendToolListChanged`),await this.notification({method:`notifications/tools/list_changed`,params:e})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler(`toolinput`)}set ontoolinput(e){this.setEventHandler(`toolinput`,e)}get ontoolinputpartial(){return this.getEventHandler(`toolinputpartial`)}set ontoolinputpartial(e){this.setEventHandler(`toolinputpartial`,e)}get ontoolresult(){return this.getEventHandler(`toolresult`)}set ontoolresult(e){this.setEventHandler(`toolresult`,e)}get ontoolcancelled(){return this.getEventHandler(`toolcancelled`)}set ontoolcancelled(e){this.setEventHandler(`toolcancelled`,e)}get onhostcontextchanged(){return this.getEventHandler(`hostcontextchanged`)}set onhostcontextchanged(e){this.setEventHandler(`hostcontextchanged`,e)}_onteardown;get onteardown(){return this._onteardown}set onteardown(e){this.warnIfRequestHandlerReplaced(`onteardown`,this._onteardown,e),this._onteardown=e,this.replaceRequestHandler(`ui/resource-teardown`,{params:ZPe.shape.params,result:QPe},(e,t)=>{if(!this._onteardown)throw Error(`No onteardown handler set`);return this._onteardown(e,t)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced(`oncalltool`,this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler(`tools/call`,(e,t)=>{if(!this._oncalltool)throw Error(`No oncalltool handler set`);return this._oncalltool(e.params,t)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(e){this.warnIfRequestHandlerReplaced(`onlisttools`,this._onlisttools,e),this._onlisttools=e,this.replaceRequestHandler(`tools/list`,(e,t)=>{if(!this._onlisttools)throw Error(`No onlisttools handler set`);return this._onlisttools(e.params,t)})}assertCapabilityForMethod(e){if(e===`sampling/createMessage`&&!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${e})`)}assertRequestHandlerCapability(e){switch(e){case`tools/call`:case`tools/list`:if(!this._appCapabilities.tools)throw Error(`Client does not support tool capability (required for ${e})`);return;default:return}}assertNotificationCapability(e){}async callServerTool(e,t){if(this._assertInitialized(`callServerTool`),typeof e==`string`)throw Error(`callServerTool() expects an object as its first argument, but received a string ("${e}"). Did you mean: callServerTool({ name: "${e}", arguments: { ... } })?`);return await this.request({method:`tools/call`,params:e},{onprogress:()=>{},resetTimeoutOnProgress:!0,...t})}async readServerResource(e,t){return this._assertInitialized(`readServerResource`),await this.request({method:`resources/read`,params:e},t)}async listServerResources(e,t){return this._assertInitialized(`listServerResources`),await this.request({method:`resources/list`,params:e},t)}async createSamplingMessage(e,t){return this._assertInitialized(`createSamplingMessage`),await this.request({method:`sampling/createMessage`,params:e},t)}sendMessage(e,t){return this._assertInitialized(`sendMessage`),this.request({method:`ui/message`,params:e},GPe,t)}sendLog(e){return this.notification({method:`notifications/message`,params:e})}updateModelContext(e,t){return this._assertInitialized(`updateModelContext`),this.request({method:`ui/update-model-context`,params:e},a8,t)}openLink(e,t){return this._assertInitialized(`openLink`),this.request({method:`ui/open-link`,params:e},UPe,t)}sendOpenLink=this.openLink;downloadFile(e,t){return this._assertInitialized(`downloadFile`),this.request({method:`ui/download-file`,params:e},WPe,t)}requestTeardown(e={}){return this.notification({method:`ui/notifications/request-teardown`,params:e})}requestDisplayMode(e,t){return this._assertInitialized(`requestDisplayMode`),this.request({method:`ui/request-display-mode`,params:e},tFe,t)}sendSizeChanged(e){return this.notification({method:`ui/notifications/size-changed`,params:e})}setupSizeChangedNotifications(){let e=!1,t=0,n=0,r=()=>{e||(e=!0,requestAnimationFrame(()=>{e=!1;let r=document.documentElement,i=r.style.height;r.style.height=`max-content`;let a=Math.ceil(r.getBoundingClientRect().height);r.style.height=i;let o=Math.ceil(window.innerWidth);(o!==t||a!==n)&&(t=o,n=a,this.sendSizeChanged({width:o,height:a}))}))};r();let i=new ResizeObserver(r);return i.observe(document.documentElement),i.observe(document.body),()=>i.disconnect()}async connect(e=new K9(window.parent,window.parent),t){if(this.transport)throw Error(`App is already connected. Call close() before connecting again.`);this._initializedSent=!1;try{await super.connect(e);let n=await this.request({method:`ui/initialize`,params:{appCapabilities:this._appCapabilities,appInfo:this._appInfo,protocolVersion:BPe}},aFe,t);if(n===void 0)throw Error(`Server sent invalid initialize result: ${n}`);this._hostCapabilities=n.hostCapabilities,this._hostInfo=n.hostInfo,this._hostContext=n.hostContext,await this.notification({method:`ui/notifications/initialized`}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(e){throw this.close(),e}}};function lFe({appInfo:e,capabilities:t,onAppCreated:n,autoResize:r=!0,strict:i}){let[a,o]=(0,A.useState)(null),[s,c]=(0,A.useState)(!1),[l,u]=(0,A.useState)(null);return(0,A.useEffect)(()=>{let a=!0,s;async function l(){try{let l=new K9(window.parent,window.parent);if(s=new cFe(e,t,{autoResize:r,strict:i}),n?.(s),await s.connect(l),!a){s.close();return}o(s),c(!0),u(null)}catch(e){a&&(o(null),c(!1),u(e instanceof Error?e:Error(`Failed to connect`)))}}return l(),()=>{a=!1,s?.close()}},[]),{app:a,isConnected:s,error:l}}function uFe(){let[e,t]=(0,A.useState)(null),[n,r]=(0,A.useState)(),[i,a]=(0,A.useState)(null);function o(e){try{if(e.isError)throw Error(`Tool error`);let n=Zg(e.structuredContent);t(n),a(null)}catch{a(`This view could not be loaded. Please try again.`)}}let s=lFe({autoResize:!1,appInfo:{name:`Fanout panels`,version:`1.0.0`},capabilities:{},onAppCreated:e=>{e.ontoolresult=o,e.onhostcontextchanged=e=>r(t=>({...t,...e})),e.onerror=()=>a(`This view could not be refreshed. Please try again.`)}});return(0,A.useEffect)(()=>{s.app&&r(s.app.getHostContext())},[s.app]),{...s,fragment:e,host:n,toolError:i}}function dFe(e,t){let n,r=()=>{let r=e.getBoundingClientRect().height;n!==void 0&&Math.abs(r-n)<2||(n=r,t({height:Math.round(r)}))},i=new ResizeObserver(r);return i.observe(e),r(),()=>i.disconnect()}var fFe=new uee({defaultOptions:{queries:{retry:!1}}});function pFe(){let{app:e,fragment:t,host:n,error:r,toolError:i}=uFe(),a=(0,A.useRef)(null);(0,A.useEffect)(()=>{if(e&&a.current)return dFe(a.current,t=>e.sendSizeChanged(t))},[e]);let o=(0,A.useMemo)(()=>e?ZEe(e):void 0,[e]),s=n?.theme===`dark`,c=i??(r?`This view could not be loaded. Please try again.`:null);return(0,z.jsx)(xn,{theme:Aee,cssVariablesResolver:Dee,forceColorScheme:s?`dark`:`light`,children:(0,z.jsx)(Lh,{client:fFe,children:(0,z.jsx)(`div`,{ref:a,"data-app-content":!0,children:t&&o&&n?(0,z.jsxs)(z.Fragment,{children:[c&&(0,z.jsx)(xd,{color:`bad`,m:`md`,children:c}),(0,z.jsx)(XEe,{fragment:t,dark:s,onQuery:o.query,drillClient:o.drill,resolveVariables:o.resolveVariables,hostDisplayMode:n.displayMode??`inline`,onDisplayMode:n.availableDisplayModes?.includes(`fullscreen`)?async t=>(await e.requestDisplayMode({mode:t})).mode===t:void 0})]}):c?(0,z.jsx)(xd,{color:`bad`,m:`md`,children:c}):(0,z.jsx)(Rf,{mih:180,children:(0,z.jsx)(el,{size:`sm`,"aria-label":`Loading panel view`})})})})})}(0,See.createRoot)(document.getElementById(`root`)).render((0,z.jsx)(A.StrictMode,{children:(0,z.jsx)(pFe,{})}));
diff --git a/internal/ui/dist/assets/chat-D8Nl9xGT.js b/internal/ui/dist/assets/chat-_owdy9Bf.js similarity index 99% rename from internal/ui/dist/assets/chat-D8Nl9xGT.js rename to internal/ui/dist/assets/chat-_owdy9Bf.js index 146c2b18..c333d6e2 100644 --- a/internal/ui/dist/assets/chat-D8Nl9xGT.js +++ b/internal/ui/dist/assets/chat-_owdy9Bf.js @@ -1,2 +1,2 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mcp-app-frame-DpQJtTNR.js","assets/useRouter-ByJ6_rwb.js","assets/brand-Bcp2Tp5I.js","assets/use-computed-color-scheme-BIja2o3c.js","assets/auth-C8kS8ur3.js","assets/useNavigate-B1zgPEUp.js","assets/index-ZyJwWZ_-.js","assets/preload-helper-DpsUT6aH.js","assets/theme-DdznftKI.js","assets/Tooltip-DhnGSmh7.js","assets/useQuery-CEXOTfck.js","assets/index-ByVYR1iM.css"])))=>i.map(i=>d[i]); -import{i as e,r as t,s as n}from"./useRouter-ByJ6_rwb.js";import{A as r,C as i,M as a,S as o,T as s,_ as c,a as l,c as u,d,f,i as p,l as m,m as h,n as g,o as ee,p as _,r as v,tt as y,u as b,x,y as S}from"./brand-Bcp2Tp5I.js";import{c as C,d as w,f as T,g as E,h as D,l as O,o as te,p as k,s as A,t as j}from"./preload-helper-DpsUT6aH.js";import{t as M}from"./Tooltip-DhnGSmh7.js";import{c as N,d as P,l as F,o as I,r as ne,s as re,t as ie,u as ae}from"./dashboard-change-chips-C08J6wNb.js";var L=n(e(),1),R=t(),oe=[`borderBottomWidth`,`borderLeftWidth`,`borderRightWidth`,`borderTopWidth`,`boxSizing`,`fontFamily`,`fontSize`,`fontStyle`,`fontWeight`,`letterSpacing`,`lineHeight`,`paddingBottom`,`paddingLeft`,`paddingRight`,`paddingTop`,`tabSize`,`textIndent`,`textRendering`,`textTransform`,`width`,`wordBreak`,`wordSpacing`,`scrollbarGutter`],z={"min-height":`0`,"max-height":`none`,height:`0`,visibility:`hidden`,overflow:`hidden`,position:`absolute`,"z-index":`-1000`,top:`0`,right:`0`,display:`block`};function B(e){Object.keys(z).forEach(t=>{e.style.setProperty(t,z[t],`important`)})}function se(e){let t=window.getComputedStyle(e);if(t===null)return null;let n={};for(let e of oe)n[e]=t[e];return n.boxSizing===``?null:{sizingStyle:n,paddingSize:parseFloat(n.paddingBottom)+parseFloat(n.paddingTop),borderSize:parseFloat(n.borderBottomWidth)+parseFloat(n.borderTopWidth)}}var V=null;function ce(e,t,n=1,r=1/0){V||(V=document.createElement(`textarea`),V.setAttribute(`tabindex`,`-1`),V.setAttribute(`aria-hidden`,`true`),V.setAttribute(`aria-label`,`autosize measurement`),B(V)),V.parentNode===null&&document.body.appendChild(V);let{paddingSize:i,borderSize:a,sizingStyle:o}=e,{boxSizing:s}=o;Object.keys(o).forEach(e=>{V.style[e]=o[e]}),B(V),V.value=t;let c=s===`border-box`?V.scrollHeight+a:V.scrollHeight-i;V.value=t,c=s===`border-box`?V.scrollHeight+a:V.scrollHeight-i,V.value=`x`;let l=V.scrollHeight-i,u=l*n;s===`border-box`&&(u=u+i+a),c=Math.max(u,c);let d=l*r;return s===`border-box`&&(d=d+i+a),c=Math.min(d,c),[c,l]}function le({maxRows:e,minRows:t,onChange:n,ref:r,...i}){let a=i.value!==void 0,o=(0,L.useRef)(null),s=y(o,r),c=(0,L.useRef)(0),l=(0,L.useRef)(0),u=()=>{let n=o.current;if(!n)return;let r=se(n);if(!r)return;let[i]=ce(r,n.value||n.placeholder||`x`,t,e);c.current!==i&&(c.current=i,n.style.setProperty(`height`,`${i}px`,`important`))},d=(0,L.useEffectEvent)(u),f=e=>{a||u(),n?.(e)};return(0,L.useLayoutEffect)(u),(0,L.useEffect)(()=>{let e=()=>u();return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,L.useEffect)(()=>{let e=o.current;if(!e||typeof ResizeObserver>`u`)return;l.current=e.offsetWidth;let t=0,n=new ResizeObserver(()=>{o.current&&o.current.offsetWidth!==l.current&&(l.current=o.current.offsetWidth,cancelAnimationFrame(t),t=requestAnimationFrame(d))});return n.observe(e),()=>{cancelAnimationFrame(t),n.disconnect()}},[]),(0,L.useEffect)(()=>{let e=()=>u();return document.fonts.addEventListener(`loadingdone`,e),()=>document.fonts.removeEventListener(`loadingdone`,e)},[]),(0,L.useEffect)(()=>{let e=e=>{if(o.current?.form===e.target&&!a){let e=o.current.value;requestAnimationFrame(()=>{o.current&&e!==o.current.value&&u()})}};return document.body.addEventListener(`reset`,e),()=>document.body.removeEventListener(`reset`,e)},[a]),(0,R.jsx)(`textarea`,{rows:t,...i,onChange:f,ref:s})}var H=s(e=>{let{autosize:t,maxRows:n,minRows:r,__staticSelector:i,resize:o,bottomSection:s,bottomSectionProps:c,...l}=a([`Input`,`InputWrapper`,`Textarea`],null,e),u=t&&P()!==`test`,d=u?{maxRows:n,minRows:r}:{};return(0,R.jsx)(h,{component:u?le:`textarea`,...l,__staticSelector:i||`Textarea`,__bottomSection:s,__bottomSectionProps:c,multiline:!0,"data-no-overflow":t&&n===void 0||void 0,__vars:{"--input-resize":o},...d})});H.classes=h.classes,H.displayName=`@mantine/core/Textarea`;var U={root:`m_d08caa0`},W=s(e=>{let t=a(`Typography`,null,e),{classNames:n,className:o,style:s,styles:c,unstyled:l,attributes:u,...d}=t,f=r({name:`Typography`,classes:U,props:t,className:o,style:s,classNames:n,styles:c,unstyled:l,attributes:u});return(0,R.jsx)(i,{...f(`root`),...d})});W.classes=U,W.displayName=`@mantine/core/Typography`;var ue=new Map([[`bold`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M184.49,136.49l-80,80a12,12,0,0,1-17-17L159,128,87.51,56.49a12,12,0,1,1,17-17l80,80A12,12,0,0,1,184.49,136.49Z`}))],[`duotone`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M176,128,96,208V48Z`,opacity:`0.2`}),L.createElement(`path`,{d:`M181.66,122.34l-80-80A8,8,0,0,0,88,48V208a8,8,0,0,0,13.66,5.66l80-80A8,8,0,0,0,181.66,122.34ZM104,188.69V67.31L164.69,128Z`}))],[`fill`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M181.66,133.66l-80,80A8,8,0,0,1,88,208V48a8,8,0,0,1,13.66-5.66l80,80A8,8,0,0,1,181.66,133.66Z`}))],[`light`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M180.24,132.24l-80,80a6,6,0,0,1-8.48-8.48L167.51,128,91.76,52.24a6,6,0,0,1,8.48-8.48l80,80A6,6,0,0,1,180.24,132.24Z`}))],[`regular`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M181.66,133.66l-80,80a8,8,0,0,1-11.32-11.32L164.69,128,90.34,53.66a8,8,0,0,1,11.32-11.32l80,80A8,8,0,0,1,181.66,133.66Z`}))],[`thin`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M178.83,130.83l-80,80a4,4,0,0,1-5.66-5.66L170.34,128,93.17,50.83a4,4,0,0,1,5.66-5.66l80,80A4,4,0,0,1,178.83,130.83Z`}))]]),de=new Map([[`bold`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M230.14,25.86a20,20,0,0,0-19.57-5.11l-.22.07L18.44,79a20,20,0,0,0-3.06,37.25L99,157l40.71,83.65a19.81,19.81,0,0,0,18,11.38c.57,0,1.15,0,1.73-.07A19.82,19.82,0,0,0,177,237.56L235.18,45.65a1.42,1.42,0,0,0,.07-.22A20,20,0,0,0,230.14,25.86ZM156.91,221.07l-34.37-70.64,46-45.95a12,12,0,0,0-17-17l-46,46L34.93,99.09,210,46Z`}))],[`duotone`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M223.69,42.18l-58.22,192a8,8,0,0,1-14.92,1.25L108,148,20.58,105.45a8,8,0,0,1,1.25-14.92l192-58.22A8,8,0,0,1,223.69,42.18Z`,opacity:`0.2`}),L.createElement(`path`,{d:`M227.32,28.68a16,16,0,0,0-15.66-4.08l-.15,0L19.57,82.84a16,16,0,0,0-2.49,29.8L102,154l41.3,84.87A15.86,15.86,0,0,0,157.74,248q.69,0,1.38-.06a15.88,15.88,0,0,0,14-11.51l58.2-191.94c0-.05,0-.1,0-.15A16,16,0,0,0,227.32,28.68ZM157.83,231.85l-.05.14,0-.07-40.06-82.3,48-48a8,8,0,0,0-11.31-11.31l-48,48L24.08,98.25l-.07,0,.14,0L216,40Z`}))],[`fill`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M231.4,44.34s0,.1,0,.15l-58.2,191.94a15.88,15.88,0,0,1-14,11.51q-.69.06-1.38.06a15.86,15.86,0,0,1-14.42-9.15L107,164.15a4,4,0,0,1,.77-4.58l57.92-57.92a8,8,0,0,0-11.31-11.31L96.43,148.26a4,4,0,0,1-4.58.77L17.08,112.64a16,16,0,0,1,2.49-29.8l191.94-58.2.15,0A16,16,0,0,1,231.4,44.34Z`}))],[`light`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M225.88,30.12a13.83,13.83,0,0,0-13.7-3.58l-.11,0L20.14,84.77A14,14,0,0,0,18,110.85l85.56,41.64L145.12,238a13.87,13.87,0,0,0,12.61,8c.4,0,.81,0,1.21-.05a13.9,13.9,0,0,0,12.29-10.09l58.2-191.93,0-.11A13.83,13.83,0,0,0,225.88,30.12Zm-8,10.4L159.73,232.43l0,.11a2,2,0,0,1-3.76.26l-40.68-83.58,49-49a6,6,0,1,0-8.49-8.49l-49,49L23.15,100a2,2,0,0,1,.31-3.74l.11,0L215.48,38.08a1.94,1.94,0,0,1,1.92.52A2,2,0,0,1,217.92,40.52Z`}))],[`regular`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M227.32,28.68a16,16,0,0,0-15.66-4.08l-.15,0L19.57,82.84a16,16,0,0,0-2.49,29.8L102,154l41.3,84.87A15.86,15.86,0,0,0,157.74,248q.69,0,1.38-.06a15.88,15.88,0,0,0,14-11.51l58.2-191.94c0-.05,0-.1,0-.15A16,16,0,0,0,227.32,28.68ZM157.83,231.85l-.05.14,0-.07-40.06-82.3,48-48a8,8,0,0,0-11.31-11.31l-48,48L24.08,98.25l-.07,0,.14,0L216,40Z`}))],[`thin`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M224.47,31.52a11.87,11.87,0,0,0-11.82-3L20.74,86.67a12,12,0,0,0-1.91,22.38L105,151l41.92,86.15A11.88,11.88,0,0,0,157.74,244c.34,0,.69,0,1,0a11.89,11.89,0,0,0,10.52-8.63l58.21-192,0-.08A11.85,11.85,0,0,0,224.47,31.52Zm-4.62,9.54-58.23,192a4,4,0,0,1-7.48.59l-41.3-84.86,50-50a4,4,0,1,0-5.66-5.66l-50,50-84.9-41.31a3.88,3.88,0,0,1-2.27-4,3.93,3.93,0,0,1,3-3.54L214.9,36.16A3.93,3.93,0,0,1,216,36a4,4,0,0,1,2.79,1.19A3.93,3.93,0,0,1,219.85,41.06Z`}))]]),fe=new Map([[`bold`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M200,36H56A20,20,0,0,0,36,56V200a20,20,0,0,0,20,20H200a20,20,0,0,0,20-20V56A20,20,0,0,0,200,36Zm-4,160H60V60H196Z`}))],[`duotone`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M208,56V200a8,8,0,0,1-8,8H56a8,8,0,0,1-8-8V56a8,8,0,0,1,8-8H200A8,8,0,0,1,208,56Z`,opacity:`0.2`}),L.createElement(`path`,{d:`M200,40H56A16,16,0,0,0,40,56V200a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Zm0,160H56V56H200V200Z`}))],[`fill`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z`}))],[`light`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M200,42H56A14,14,0,0,0,42,56V200a14,14,0,0,0,14,14H200a14,14,0,0,0,14-14V56A14,14,0,0,0,200,42Zm2,158a2,2,0,0,1-2,2H56a2,2,0,0,1-2-2V56a2,2,0,0,1,2-2H200a2,2,0,0,1,2,2Z`}))],[`regular`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M200,40H56A16,16,0,0,0,40,56V200a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Zm0,160H56V56H200V200Z`}))],[`thin`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M200,44H56A12,12,0,0,0,44,56V200a12,12,0,0,0,12,12H200a12,12,0,0,0,12-12V56A12,12,0,0,0,200,44Zm4,156a4,4,0,0,1-4,4H56a4,4,0,0,1-4-4V56a4,4,0,0,1,4-4H200a4,4,0,0,1,4,4Z`}))]]),G=L.forwardRef((e,t)=>L.createElement(l,{ref:t,...e,weights:ue}));G.displayName=`CaretRightIcon`;var K=G,q=L.forwardRef((e,t)=>L.createElement(l,{ref:t,...e,weights:de}));q.displayName=`PaperPlaneTiltIcon`;var pe=q,J=L.forwardRef((e,t)=>L.createElement(l,{ref:t,...e,weights:fe}));J.displayName=`StopIcon`;var me=J;function he(e){return e.dashboard.panels.length===1?e.dashboard.panels[0].title:e.dashboard.name}function ge(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Missing panel view`);let t=e;if(!t.view||![`preset`,`query`].includes(t.view.kind)||!/^[a-f0-9]{64}$/.test(t.view.key))throw Error(`Invalid panel view identity`);if(t.dashboard?.version!==1||!Array.isArray(t.dashboard.panels)||!t.dashboard.panels.length||t.dashboard.panels.length>40||!Array.isArray(t.results)||t.dashboard.panels.some(e=>!e||typeof e.id!=`string`||!e.id)||t.results.some(e=>!e||typeof e.id!=`string`))throw Error(`Invalid panel view`);let n=new Set(t.dashboard.panels.map(e=>e.id));if(n.size!==t.dashboard.panels.length||t.results.length!==n.size||new Set(t.results.map(e=>e.id)).size!==n.size||t.results.some(e=>!n.has(e.id)||![`ok`,`empty`,`error`].includes(e.status)))throw Error(`Panel results do not match the view`);if(t.vars!==void 0&&(!t.vars||typeof t.vars!=`object`||Array.isArray(t.vars)||Object.values(t.vars).some(e=>typeof e!=`string`&&!(Array.isArray(e)&&e.every(e=>typeof e==`string`)))))throw Error(`Invalid panel variables`);if(t.trace!==void 0&&(!t.trace?.data||!Array.isArray(t.trace.data.spans)||!Array.isArray(t.trace.data.logs)||!Array.isArray(t.trace.data.services)))throw Error(`Invalid trace detail`);return t}var Y=new WeakSet;function X(e){if(!e||typeof e!=`object`||Array.isArray(e))return;if(Y.has(e))return e;let t=e;if(Object.keys(t).sort().join(`,`)===`is_error,resource_uri,tool_input,tool_name,tool_result`&&t.resource_uri===`ui://fanout/panels.html`&&typeof t.tool_name==`string`&&t.tool_name&&typeof t.is_error==`boolean`&&t.tool_input&&typeof t.tool_input==`object`&&!Array.isArray(t.tool_input)){try{ge(t.tool_result)}catch{return}return Y.add(t),t}}var _e=64,ve=300;function ye(){let e=(0,L.useRef)(null),t=(0,L.useRef)(!0),n=(0,L.useRef)(()=>{}),r=(0,L.useRef)(null),i=(0,L.useRef)(null),a=(0,L.useCallback)(()=>{let t=e.current;if(!t)return;let n=t.getBoundingClientRect().top,r=[...t.querySelectorAll(`[data-chat-anchor]`)].find(e=>e.getBoundingClientRect().bottom>n);i.current=r?{node:r,top:r.getBoundingClientRect().top}:null},[]),o=(0,L.useCallback)(()=>{let n=e.current;n&&t.current?n.scrollTop=n.scrollHeight:n&&i.current?.node.isConnected&&(n.scrollTop+=i.current.node.getBoundingClientRect().top-i.current.top),a()},[a]);return{scrollRef:(0,L.useCallback)(r=>{if(n.current(),e.current=r,!r)return;let o=0,s=!1,c=()=>{o=Date.now()},l=()=>{s=!0},u=()=>{s=!1},d=()=>{r.scrollHeight-r.clientHeight-r.scrollTop<=_e?t.current=!0:(s||Date.now()-o{r.removeEventListener(`scroll`,d),r.removeEventListener(`wheel`,c),r.removeEventListener(`touchmove`,c),r.removeEventListener(`keydown`,c),r.removeEventListener(`pointerdown`,l),window.removeEventListener(`pointerup`,u),n.current=()=>{}},t.current=!0,r.scrollTop=r.scrollHeight,i.current=null},[a]),contentRef:(0,L.useCallback)(e=>{r.current?.disconnect(),r.current=null,e&&(r.current=new ResizeObserver(o),r.current.observe(e))},[o]),toBottom:(0,L.useCallback)(()=>{t.current=!0,o()},[o])}}function be(e=1500){let[t,n]=(0,L.useState)(`idle`),r=(0,L.useRef)(null);(0,L.useEffect)(()=>()=>{r.current&&clearTimeout(r.current)},[]);function i(t){r.current&&clearTimeout(r.current),n(`idle`),(navigator.clipboard?navigator.clipboard.writeText(t):Promise.reject(Error(`clipboard unavailable`))).then(()=>n(`copied`),()=>n(`failed`)).finally(()=>{r.current=setTimeout(()=>n(`idle`),e)})}return{state:t,copy:i}}var xe={schema:`Telemetry`,context:`Context`,draft:`Draft`,validation:`Validation`,preview:`Preview`,save:`Save`},Z=e=>`${(e/1e3).toFixed(1)} s`;function Se({receipt:e,running:t=!1,activity:n=``,awaitingAnswer:r=!1}){let[i,a]=(0,L.useState)(!1),o=(0,L.useId)(),s=e.saved,l=s?.receipt.save_check,p=Object.values(e.stages).filter(e=>e.state===`complete`).length,m=[e.stages.schema.state===`complete`?`Read telemetry`:void 0,e.panel_count===void 0?void 0:`${e.panel_count} ${e.panel_count===1?`panel`:`panels`}`,l?.checked?`Checked in ${Z(l.elapsed_ms)}`:void 0,s?`Saved v${s.version}`:void 0].filter(Boolean).join(` · `)||`Building dashboard`,h=[...s?C(s.receipt):[],...e.corrections.map(e=>`Fixed ${e.panel_id}.${e.path.replace(/^panels\[\d+\]\./,``)}`)];return(0,R.jsx)(x,{"data-build-receipt":e.turn_id,"data-dashboard-result":s?.id,"data-chat-anchor":!0,withBorder:!0,radius:`md`,p:`sm`,children:(0,R.jsxs)(u,{gap:6,children:[(0,R.jsxs)(c,{gap:`xs`,justify:`space-between`,children:[(0,R.jsxs)(f,{size:`sm`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:[m,(0,R.jsxs)(f,{span:!0,c:`dimmed`,size:`xs`,children:[` · `,p,` stages complete`]})]}),(0,R.jsxs)(d,{component:`button`,variant:`subtle`,color:`gray`,size:`compact-xs`,"aria-expanded":i,"aria-controls":o,onClick:()=>a(e=>!e),children:[`Details`,h.length>4?` (+${h.length-4})`:``]})]}),t&&r&&(0,R.jsxs)(c,{gap:`xs`,"data-build-running":!0,children:[(0,R.jsx)(S,{type:`dots`,size:`sm`}),(0,R.jsx)(f,{c:`dimmed`,size:`sm`,children:n||`Analyzing your system`})]}),(0,R.jsx)(ie,{labels:h.slice(0,4)}),e.explanations.map(e=>t?e.split(` · `).filter(e=>!e.endsWith(`: incomplete`)).join(` · `):e).filter(Boolean).map((e,t)=>(0,R.jsx)(f,{size:`xs`,c:`dimmed`,"data-receipt-attention":!0,children:e},t)),s&&(0,R.jsx)(d,{renderRoot:e=>(0,R.jsx)(E,{...e,to:`/dashboards/$dashboardId`,params:{dashboardId:s.id},search:{}}),variant:`subtle`,size:`compact-sm`,color:`gray`,style:{alignSelf:`flex-start`},children:`Open dashboard`}),(0,R.jsx)(ae,{expanded:i,id:o,children:(0,R.jsxs)(u,{gap:4,children:[s&&(0,R.jsxs)(f,{size:`xs`,children:[s.label,` `,s.name,` · opens the current dashboard`]}),Object.entries(e.stages).map(([e,n])=>(0,R.jsxs)(f,{size:`xs`,c:`dimmed`,children:[xe[e],`: `,t&&n.state===`incomplete`?`in progress`:n.state,n.elapsed_ms===void 0?``:` · ${Z(n.elapsed_ms)}`]},e)),e.save_attempts.map((e,t)=>e.state===`retried`&&(0,R.jsxs)(f,{size:`xs`,c:`dimmed`,children:[`Save attempt `,t+1,`: retried`]},e.call_id)),!!e.context_counts.deploys&&(0,R.jsxs)(f,{size:`xs`,children:[e.context_counts.deploys,` deploys observed`]}),!!e.context_counts.anomalies&&(0,R.jsxs)(f,{size:`xs`,children:[e.context_counts.anomalies,` anomalies observed`]}),e.panels.map(e=>(0,R.jsxs)(f,{size:`xs`,children:[`Preview · `,e.id,`: `,e.status,e.elapsed_ms===void 0?``:` · ${Z(e.elapsed_ms)}`]},e.id)),l&&(0,R.jsxs)(f,{size:`xs`,children:[`Save check: `,l.checked?`checked`:`incomplete`,` · `,Z(l.elapsed_ms)]}),l?.panels.map(e=>(0,R.jsxs)(f,{size:`xs`,children:[`Save · `,e.id,`: `,e.status,` · `,e.rows??0,` rows`,e.elapsed_ms===void 0?``:` · ${Z(e.elapsed_ms)}`]},e.id)),h.slice(4).map((e,t)=>(0,R.jsx)(f,{size:`xs`,children:e},t)),e.corrections.map((e,t)=>(0,R.jsxs)(f,{size:`xs`,children:[`Fixed `,e.panel_id,`.`,e.path,`: `,e.message]},t))]})})]})})}var Ce=(0,L.lazy)(()=>j(()=>import(`./mcp-app-frame-DpQJtTNR.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))),Q=e=>e.tool_result.view.kind===`preset`;function we(e){let t=new Map,n=new Set,r=[],i=()=>{let e=new Map;for(let t of r){let n=t.content.tool_result.view.key;e.set(n,t)}let i=new Set([...e.values()].map(e=>e.id)),a=[...e.values()].some(e=>Q(e.content)),o=r.filter(e=>i.has(e.id)).at(-1)?.id;for(let e of r)i.has(e.id)?t.set(e.id,{content:e.content,expanded:Q(e.content)||!a&&e.id===o}):n.add(e.id);r=[]};for(let t of e)if(t.role===`user`&&i(),t.role===`activity`&&t.activityType===`mcp-app`){let e=X(t.content);e&&r.push({id:t.id,content:e})}return i(),{views:t,duplicates:n}}function Te(e){let t=new Map,n=new Map,r=new Map,i=`unattributed`;for(let a of e){if(a.role===`user`&&(n.clear(),r.clear(),i=a.id),a.role===`assistant`){i=a.id;for(let e of a.toolCalls??[])n.set(e.id,{assistant:i,name:e.function.name})}if(a.role===`tool`){let e=w(a.content);if(!a.error&&!e?.error&&e?.isError!==!0)continue;let o=n.get(a.toolCallId);if(o&&T.has(o.name)&&O(a))continue;let s=o?.assistant??i,c=r.get(s)??a.id;r.set(s,c);let l=t.get(c)??[],u=k(e?.error)?e?.error:void 0,d=typeof u?.message==`string`?u.message:typeof a.error==`string`&&a.error?a.error:`Tool execution failed`;l.push({name:o?.name??`Tool`,message:d,readOnly:u?.code===`answer_only`}),t.set(c,l)}}return t}function Ee({failures:e}){let[t,n]=(0,L.useState)(!1),r=e.filter(e=>!e.readOnly);return(0,R.jsxs)(i,{"data-chat-anchor":!0,children:[e.some(e=>e.readOnly)&&(0,R.jsx)(f,{size:`sm`,c:`dimmed`,children:`Not saved: Explain is read-only`}),r.length>0&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(o,{className:`chat-app-toggle`,"aria-expanded":t,onClick:()=>n(e=>!e),style:{color:`var(--mantine-color-dimmed)`},children:[(0,R.jsx)(`span`,{className:`chat-app-chevron`,"aria-hidden":`true`,children:t?(0,R.jsx)(N,{size:14}):(0,R.jsx)(K,{size:14})}),(0,R.jsxs)(`span`,{className:`chat-app-summary`,children:[r.length,` tool `,r.length===1?`call`:`calls`,` failed`]})]}),t&&(0,R.jsx)(u,{gap:`xs`,pl:`md`,children:r.map((e,t)=>(0,R.jsxs)(f,{size:`sm`,c:`dimmed`,style:{whiteSpace:`pre-wrap`,overflowWrap:`anywhere`},children:[e.name,`: `,e.message]},t))})]})]})}function De({view:e}){let[t,n]=(0,L.useState)(e.expanded);(0,L.useEffect)(()=>n(e.expanded),[e.expanded]);let r=e.content.tool_result,i=he(r),a=[...new Set(r.dashboard.panels.map(e=>e.viz===`timeseries`?`time series`:e.viz.replaceAll(`_`,` `)))].join(`, `),s=r.results.reduce((e,t)=>e+(t.frame?.rows??0),0),c=new Map;for(let e of r.results)e.status!==`ok`&&c.set(e.status,(c.get(e.status)??0)+1);let l=r.dashboard.panels.length>1?[`${r.dashboard.panels.length} panels`,...Array.from(c,([e,t])=>`${t} ${e}`)].join(` · `):c.size?[...c.keys()].join(`, `):`${s} ${s===1?`row`:`rows`}`;return(0,R.jsxs)(x,{"data-chat-app":!0,"data-chat-anchor":!0,withBorder:!0,radius:`lg`,style:{overflow:`hidden`},children:[(0,R.jsxs)(o,{className:`chat-app-toggle`,"aria-expanded":t,onClick:()=>n(e=>!e),children:[(0,R.jsx)(`span`,{className:`chat-app-chevron`,"aria-hidden":`true`,children:t?(0,R.jsx)(N,{size:14}):(0,R.jsx)(K,{size:14})}),(0,R.jsxs)(`span`,{className:`chat-app-summary`,children:[i,` · `,a,` · `,l]})]}),t&&(0,R.jsx)(L.Suspense,{fallback:(0,R.jsx)(b,{mih:180,children:(0,R.jsx)(S,{size:`sm`})}),children:(0,R.jsx)(Ce,{content:e.content})})]})}var Oe=[`Summarize system health for the last hour`,`Find the source of elevated errors`,`Map the current service dependencies`,`Show the slowest endpoints`];function ke(){let{agentAvailable:e,messages:t,messageTimes:n,ready:r,running:a,activity:o,provisional:s,stopped:l,error:p,threadMissing:h,send:g,retry:v,reloadThread:y,newThread:C}=A(),{scrollRef:w,contentRef:T,toBottom:E}=ye(),D=te(t),O=t.filter(e=>e.role===`user`).at(-1)?.id;if((0,L.useEffect)(()=>{O&&E()},[O,E]),!e)return(0,R.jsx)(m,{size:`sm`,py:96,children:(0,R.jsx)(x,{withBorder:!0,radius:`lg`,p:{base:`xl`,sm:40},children:(0,R.jsxs)(u,{gap:`md`,children:[(0,R.jsx)(f,{c:`brand`,fw:700,size:`xs`,tt:`uppercase`,lts:`0.12em`,children:`Optional capability`}),(0,R.jsx)(ee,{order:1,fz:28,children:`Chat is not configured`}),(0,R.jsx)(f,{c:`dimmed`,children:`Add an AI provider key to enable chat. Telemetry ingest, dashboards, traces, logs, and metrics remain available without it.`}),(0,R.jsx)(d,{component:`a`,href:`/dashboards`,variant:`light`,mt:`sm`,children:`Open dashboards`})]})})});let k=we(t),j=Te(t),M=t.filter(e=>k.duplicates.has(e.id)?!1:e.role===`tool`?j.has(e.id):e.role===`assistant`?!e.toolCalls?.length&&typeof e.content==`string`&&e.content.trim().length>0:e.role===`activity`?e.activityType===`mcp-app`||e.activityType===`agent-outcome`:e.role===`user`),N=t.findIndex(e=>e.id===O),P=t.slice(N+1).some(e=>e.role===`assistant`&&!e.toolCalls?.length&&typeof e.content==`string`&&e.content.length>0),F=t.slice(N+1).filter(e=>e.role===`assistant`&&!e.toolCalls?.length&&typeof e.content==`string`&&e.content.trim().length>0).at(-1),I=a&&s&&!s.collapsed&&s.text&&!P;return(0,R.jsxs)(i,{className:`chat-pane`,children:[(0,R.jsx)(i,{className:`chat-scroll`,ref:w,tabIndex:0,role:`log`,"aria-label":`Conversation`,children:(0,R.jsxs)(m,{size:880,px:{base:`md`,sm:`xl`},py:`lg`,ref:T,children:[h&&(0,R.jsx)(_,{color:`warn`,radius:`lg`,title:`This chat no longer exists`,children:(0,R.jsxs)(c,{justify:`space-between`,children:[(0,R.jsx)(f,{size:`sm`,children:`It was deleted, or the link is wrong.`}),(0,R.jsx)(d,{size:`compact-sm`,variant:`light`,onClick:C,children:`New chat`})]})}),!h&&!r&&p&&(0,R.jsx)(Ae,{message:p,onRetry:y,onNewThread:C}),!h&&!r&&!p&&(0,R.jsxs)(b,{mih:`40vh`,children:[(0,R.jsx)(S,{size:`sm`}),(0,R.jsx)(f,{c:`dimmed`,size:`sm`,ml:`sm`,children:`Loading chat`})]}),!h&&r&&(0,R.jsxs)(R.Fragment,{children:[M.length===0&&(0,R.jsx)(Me,{onSelect:g}),(0,R.jsxs)(u,{gap:`lg`,children:[M.filter(e=>e.id!==F?.id).map(e=>j.has(e.id)?(0,R.jsx)(Ee,{failures:j.get(e.id)},e.id):(0,R.jsxs)(i,{children:[(0,R.jsx)(Ne,{message:e,time:n[e.id],appView:k.views.get(e.id)}),D.has(e.id)&&(0,R.jsx)(i,{mt:`sm`,children:(0,R.jsx)(Se,{receipt:D.get(e.id),running:a&&e.id===O,awaitingAnswer:!P&&!I,activity:o})})]},e.id)),(F||I)&&(0,R.jsx)(i,{"data-answer-position":!0,children:(0,R.jsx)(Ne,{message:I?{id:s.id,role:`assistant`,content:s.text}:F,provisional:!!I,time:I?void 0:n[F.id]})},`answer-${O??`draft`}`),a&&!P&&!I&&!D.has(O??``)&&(0,R.jsxs)(c,{gap:`xs`,role:`status`,children:[(0,R.jsx)(S,{type:`dots`,size:`sm`}),(0,R.jsx)(f,{c:`dimmed`,size:`sm`,children:o||`Analyzing your system`})]}),l&&(0,R.jsx)(f,{c:`dimmed`,size:`sm`,children:`Stopped`}),p&&(0,R.jsx)(Ae,{message:p,onRetry:v})]})]})]})}),!h&&(0,R.jsx)(je,{})]})}function Ae({message:e,onRetry:t,onNewThread:n}){return(0,R.jsx)(_,{color:`bad`,radius:`lg`,title:`Something went wrong`,children:(0,R.jsxs)(c,{justify:`space-between`,gap:`sm`,wrap:`nowrap`,children:[(0,R.jsx)(f,{size:`sm`,children:e}),(0,R.jsxs)(c,{gap:`xs`,wrap:`nowrap`,children:[n&&(0,R.jsx)(d,{size:`compact-sm`,variant:`subtle`,color:`bad`,onClick:n,children:`New chat`}),(0,R.jsx)(d,{size:`compact-sm`,variant:`light`,color:`bad`,onClick:t,children:`Retry`})]})]})})}function je(){let{input:e,setInput:t,inputRef:n,submit:r,send:a,stop:o,ready:s,running:l}=A();return(0,R.jsx)(i,{className:`chat-composer`,children:(0,R.jsxs)(m,{size:880,px:{base:`md`,sm:`xl`},children:[(0,R.jsx)(x,{component:`form`,onSubmit:r,className:`chat-composer-field`,withBorder:!0,radius:24,py:6,pl:`lg`,pr:6,children:(0,R.jsxs)(c,{align:`flex-end`,gap:`xs`,wrap:`nowrap`,children:[(0,R.jsx)(H,{ref:n,"aria-label":`Message Fanout`,value:e,onChange:e=>t(e.currentTarget.value),onKeyDown:t=>{t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),a(e))},placeholder:l?`Fanout is working…`:`Ask about health, errors, or latency…`,disabled:!s,autosize:!0,minRows:1,maxRows:8,variant:`unstyled`,flex:1}),l?(0,R.jsx)(M,{label:`Stop`,children:(0,R.jsx)(D,{type:`button`,variant:`default`,size:40,radius:`xl`,"aria-label":`Stop`,onClick:o,children:(0,R.jsx)(me,{size:16,weight:`fill`})})}):(0,R.jsx)(D,{type:`submit`,variant:`filled`,size:40,radius:`xl`,disabled:!e.trim()||!s,"aria-label":`Send message`,children:(0,R.jsx)(pe,{size:17,weight:`fill`})})]})}),(0,R.jsx)(f,{c:`dimmed`,size:`xs`,ta:`center`,mt:6,children:`Enter to send, Shift+Enter for a new line`})]})})}function Me({onSelect:e}){return(0,R.jsxs)(u,{align:`center`,gap:`md`,pt:{base:32,sm:88},pb:`xl`,ta:`center`,children:[(0,R.jsx)(g,{size:`large`}),(0,R.jsx)(ee,{order:1,fz:24,fw:500,lh:1.25,maw:560,children:`What do you want to know about your system?`}),(0,R.jsx)(c,{justify:`center`,gap:`xs`,mt:`xs`,maw:720,children:Oe.map(t=>(0,R.jsx)(d,{variant:`default`,size:`sm`,radius:`xl`,onClick:()=>void e(t),children:t},t))})]})}function Ne({message:e,time:t,appView:n,provisional:r=!1}){if(e.role===`activity`)return e.activityType===`agent-outcome`&&e.content&&typeof e.content==`object`&&`message`in e.content&&typeof e.content.message==`string`?`status`in e.content&&e.content.status===`stopped`?(0,R.jsx)(f,{c:`dimmed`,size:`sm`,"data-chat-anchor":!0,children:e.content.message}):(0,R.jsx)(_,{color:`bad`,title:`Something went wrong`,"data-chat-anchor":!0,children:e.content.message}):e.activityType===`mcp-app`?n?(0,R.jsx)(De,{view:n}):(0,R.jsx)(_,{color:`bad`,"data-chat-anchor":!0,children:`This view could not be loaded. Please try again.`}):null;if(e.role===`assistant`&&e.toolCalls?.length)return null;let a=typeof e.content==`string`?e.content:JSON.stringify(e.content);if(!a&&e.role===`assistant`)return null;let o=e.role===`user`,s=t?new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}).format(new Date(t)):``;return(0,R.jsxs)(i,{className:`chat-message${r?` chat-message--provisional`:``}`,"data-chat-anchor":!0,"data-role":o?`user`:`assistant`,children:[o?(0,R.jsx)(x,{radius:`lg`,px:`md`,py:`sm`,bg:`var(--mantine-color-brand-light)`,maw:`70%`,ml:`auto`,w:`fit-content`,children:(0,R.jsx)(f,{style:{whiteSpace:`pre-wrap`},children:a})}):(0,R.jsx)(W,{className:`chat-markdown${r?` chat-markdown--provisional`:``}`,"data-provisional":r||void 0,children:(0,R.jsx)(re,{remarkPlugins:[I],components:Fe,children:a})}),(r||s||!o)&&(0,R.jsx)(c,{className:`chat-message-meta`,gap:6,justify:o?`flex-end`:`flex-start`,mt:4,h:24,children:r?(0,R.jsx)(S,{type:`dots`,size:20}):(0,R.jsxs)(R.Fragment,{children:[s&&t&&(0,R.jsx)(f,{c:`dimmed`,size:`xs`,title:ne(t),children:s}),!o&&(0,R.jsx)(Pe,{text:a,label:`Copy message`})]})})]})}function Pe({text:e,label:t}){let{state:n,copy:r}=be();return(0,R.jsx)(M,{label:n===`failed`?`Could not copy`:n===`copied`?`Copied`:t,children:(0,R.jsx)(D,{variant:`subtle`,color:`gray`,size:`sm`,"aria-label":t,"data-state":n===`idle`?void 0:n,onClick:()=>r(e),children:n===`copied`?(0,R.jsx)(p,{size:13,weight:`bold`}):(0,R.jsx)(v,{size:13})})})}var Fe={table:({children:e})=>(0,R.jsx)(i,{className:`chat-table`,children:(0,R.jsx)(F,{striped:!0,highlightOnHover:!0,withTableBorder:!0,verticalSpacing:`xs`,fz:`sm`,children:e})}),thead:({children:e})=>(0,R.jsx)(F.Thead,{children:e}),tbody:({children:e})=>(0,R.jsx)(F.Tbody,{children:e}),tr:({children:e})=>(0,R.jsx)(F.Tr,{children:e}),th:({children:e})=>(0,R.jsx)(F.Th,{children:e}),td:({children:e})=>(0,R.jsx)(F.Td,{children:e}),pre:({children:e})=>(0,R.jsx)(Ie,{children:e}),a:({href:e,children:t})=>(0,R.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,children:t})};function Ie({children:e}){let t=$(e);return(0,R.jsxs)(i,{className:`chat-code`,pos:`relative`,children:[(0,R.jsx)(i,{className:`chat-code-actions`,pos:`absolute`,top:6,right:6,children:(0,R.jsx)(Pe,{text:t,label:`Copy code`})}),(0,R.jsx)(`pre`,{children:e})]})}function $(e){return typeof e==`string`?e:Array.isArray(e)?e.map($).join(``):e&&typeof e==`object`&&`props`in e?$(e.props.children):``}export{X as n,ke as t}; \ No newline at end of file +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mcp-app-frame-tweTxib0.js","assets/useRouter-ByJ6_rwb.js","assets/brand-Bcp2Tp5I.js","assets/use-computed-color-scheme-BIja2o3c.js","assets/auth-C8kS8ur3.js","assets/useNavigate-B1zgPEUp.js","assets/index-CNsdEvGl.js","assets/preload-helper-DpsUT6aH.js","assets/theme-DdznftKI.js","assets/Tooltip-DhnGSmh7.js","assets/useQuery-CEXOTfck.js","assets/index-ByVYR1iM.css"])))=>i.map(i=>d[i]); +import{i as e,r as t,s as n}from"./useRouter-ByJ6_rwb.js";import{A as r,C as i,M as a,S as o,T as s,_ as c,a as l,c as u,d,f,i as p,l as m,m as h,n as g,o as ee,p as _,r as v,tt as y,u as b,x,y as S}from"./brand-Bcp2Tp5I.js";import{c as C,d as w,f as T,g as E,h as D,l as O,o as te,p as k,s as A,t as j}from"./preload-helper-DpsUT6aH.js";import{t as M}from"./Tooltip-DhnGSmh7.js";import{c as N,d as P,l as F,o as I,r as ne,s as re,t as ie,u as ae}from"./dashboard-change-chips-C08J6wNb.js";var L=n(e(),1),R=t(),oe=[`borderBottomWidth`,`borderLeftWidth`,`borderRightWidth`,`borderTopWidth`,`boxSizing`,`fontFamily`,`fontSize`,`fontStyle`,`fontWeight`,`letterSpacing`,`lineHeight`,`paddingBottom`,`paddingLeft`,`paddingRight`,`paddingTop`,`tabSize`,`textIndent`,`textRendering`,`textTransform`,`width`,`wordBreak`,`wordSpacing`,`scrollbarGutter`],z={"min-height":`0`,"max-height":`none`,height:`0`,visibility:`hidden`,overflow:`hidden`,position:`absolute`,"z-index":`-1000`,top:`0`,right:`0`,display:`block`};function B(e){Object.keys(z).forEach(t=>{e.style.setProperty(t,z[t],`important`)})}function se(e){let t=window.getComputedStyle(e);if(t===null)return null;let n={};for(let e of oe)n[e]=t[e];return n.boxSizing===``?null:{sizingStyle:n,paddingSize:parseFloat(n.paddingBottom)+parseFloat(n.paddingTop),borderSize:parseFloat(n.borderBottomWidth)+parseFloat(n.borderTopWidth)}}var V=null;function ce(e,t,n=1,r=1/0){V||(V=document.createElement(`textarea`),V.setAttribute(`tabindex`,`-1`),V.setAttribute(`aria-hidden`,`true`),V.setAttribute(`aria-label`,`autosize measurement`),B(V)),V.parentNode===null&&document.body.appendChild(V);let{paddingSize:i,borderSize:a,sizingStyle:o}=e,{boxSizing:s}=o;Object.keys(o).forEach(e=>{V.style[e]=o[e]}),B(V),V.value=t;let c=s===`border-box`?V.scrollHeight+a:V.scrollHeight-i;V.value=t,c=s===`border-box`?V.scrollHeight+a:V.scrollHeight-i,V.value=`x`;let l=V.scrollHeight-i,u=l*n;s===`border-box`&&(u=u+i+a),c=Math.max(u,c);let d=l*r;return s===`border-box`&&(d=d+i+a),c=Math.min(d,c),[c,l]}function le({maxRows:e,minRows:t,onChange:n,ref:r,...i}){let a=i.value!==void 0,o=(0,L.useRef)(null),s=y(o,r),c=(0,L.useRef)(0),l=(0,L.useRef)(0),u=()=>{let n=o.current;if(!n)return;let r=se(n);if(!r)return;let[i]=ce(r,n.value||n.placeholder||`x`,t,e);c.current!==i&&(c.current=i,n.style.setProperty(`height`,`${i}px`,`important`))},d=(0,L.useEffectEvent)(u),f=e=>{a||u(),n?.(e)};return(0,L.useLayoutEffect)(u),(0,L.useEffect)(()=>{let e=()=>u();return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,L.useEffect)(()=>{let e=o.current;if(!e||typeof ResizeObserver>`u`)return;l.current=e.offsetWidth;let t=0,n=new ResizeObserver(()=>{o.current&&o.current.offsetWidth!==l.current&&(l.current=o.current.offsetWidth,cancelAnimationFrame(t),t=requestAnimationFrame(d))});return n.observe(e),()=>{cancelAnimationFrame(t),n.disconnect()}},[]),(0,L.useEffect)(()=>{let e=()=>u();return document.fonts.addEventListener(`loadingdone`,e),()=>document.fonts.removeEventListener(`loadingdone`,e)},[]),(0,L.useEffect)(()=>{let e=e=>{if(o.current?.form===e.target&&!a){let e=o.current.value;requestAnimationFrame(()=>{o.current&&e!==o.current.value&&u()})}};return document.body.addEventListener(`reset`,e),()=>document.body.removeEventListener(`reset`,e)},[a]),(0,R.jsx)(`textarea`,{rows:t,...i,onChange:f,ref:s})}var H=s(e=>{let{autosize:t,maxRows:n,minRows:r,__staticSelector:i,resize:o,bottomSection:s,bottomSectionProps:c,...l}=a([`Input`,`InputWrapper`,`Textarea`],null,e),u=t&&P()!==`test`,d=u?{maxRows:n,minRows:r}:{};return(0,R.jsx)(h,{component:u?le:`textarea`,...l,__staticSelector:i||`Textarea`,__bottomSection:s,__bottomSectionProps:c,multiline:!0,"data-no-overflow":t&&n===void 0||void 0,__vars:{"--input-resize":o},...d})});H.classes=h.classes,H.displayName=`@mantine/core/Textarea`;var U={root:`m_d08caa0`},W=s(e=>{let t=a(`Typography`,null,e),{classNames:n,className:o,style:s,styles:c,unstyled:l,attributes:u,...d}=t,f=r({name:`Typography`,classes:U,props:t,className:o,style:s,classNames:n,styles:c,unstyled:l,attributes:u});return(0,R.jsx)(i,{...f(`root`),...d})});W.classes=U,W.displayName=`@mantine/core/Typography`;var ue=new Map([[`bold`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M184.49,136.49l-80,80a12,12,0,0,1-17-17L159,128,87.51,56.49a12,12,0,1,1,17-17l80,80A12,12,0,0,1,184.49,136.49Z`}))],[`duotone`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M176,128,96,208V48Z`,opacity:`0.2`}),L.createElement(`path`,{d:`M181.66,122.34l-80-80A8,8,0,0,0,88,48V208a8,8,0,0,0,13.66,5.66l80-80A8,8,0,0,0,181.66,122.34ZM104,188.69V67.31L164.69,128Z`}))],[`fill`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M181.66,133.66l-80,80A8,8,0,0,1,88,208V48a8,8,0,0,1,13.66-5.66l80,80A8,8,0,0,1,181.66,133.66Z`}))],[`light`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M180.24,132.24l-80,80a6,6,0,0,1-8.48-8.48L167.51,128,91.76,52.24a6,6,0,0,1,8.48-8.48l80,80A6,6,0,0,1,180.24,132.24Z`}))],[`regular`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M181.66,133.66l-80,80a8,8,0,0,1-11.32-11.32L164.69,128,90.34,53.66a8,8,0,0,1,11.32-11.32l80,80A8,8,0,0,1,181.66,133.66Z`}))],[`thin`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M178.83,130.83l-80,80a4,4,0,0,1-5.66-5.66L170.34,128,93.17,50.83a4,4,0,0,1,5.66-5.66l80,80A4,4,0,0,1,178.83,130.83Z`}))]]),de=new Map([[`bold`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M230.14,25.86a20,20,0,0,0-19.57-5.11l-.22.07L18.44,79a20,20,0,0,0-3.06,37.25L99,157l40.71,83.65a19.81,19.81,0,0,0,18,11.38c.57,0,1.15,0,1.73-.07A19.82,19.82,0,0,0,177,237.56L235.18,45.65a1.42,1.42,0,0,0,.07-.22A20,20,0,0,0,230.14,25.86ZM156.91,221.07l-34.37-70.64,46-45.95a12,12,0,0,0-17-17l-46,46L34.93,99.09,210,46Z`}))],[`duotone`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M223.69,42.18l-58.22,192a8,8,0,0,1-14.92,1.25L108,148,20.58,105.45a8,8,0,0,1,1.25-14.92l192-58.22A8,8,0,0,1,223.69,42.18Z`,opacity:`0.2`}),L.createElement(`path`,{d:`M227.32,28.68a16,16,0,0,0-15.66-4.08l-.15,0L19.57,82.84a16,16,0,0,0-2.49,29.8L102,154l41.3,84.87A15.86,15.86,0,0,0,157.74,248q.69,0,1.38-.06a15.88,15.88,0,0,0,14-11.51l58.2-191.94c0-.05,0-.1,0-.15A16,16,0,0,0,227.32,28.68ZM157.83,231.85l-.05.14,0-.07-40.06-82.3,48-48a8,8,0,0,0-11.31-11.31l-48,48L24.08,98.25l-.07,0,.14,0L216,40Z`}))],[`fill`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M231.4,44.34s0,.1,0,.15l-58.2,191.94a15.88,15.88,0,0,1-14,11.51q-.69.06-1.38.06a15.86,15.86,0,0,1-14.42-9.15L107,164.15a4,4,0,0,1,.77-4.58l57.92-57.92a8,8,0,0,0-11.31-11.31L96.43,148.26a4,4,0,0,1-4.58.77L17.08,112.64a16,16,0,0,1,2.49-29.8l191.94-58.2.15,0A16,16,0,0,1,231.4,44.34Z`}))],[`light`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M225.88,30.12a13.83,13.83,0,0,0-13.7-3.58l-.11,0L20.14,84.77A14,14,0,0,0,18,110.85l85.56,41.64L145.12,238a13.87,13.87,0,0,0,12.61,8c.4,0,.81,0,1.21-.05a13.9,13.9,0,0,0,12.29-10.09l58.2-191.93,0-.11A13.83,13.83,0,0,0,225.88,30.12Zm-8,10.4L159.73,232.43l0,.11a2,2,0,0,1-3.76.26l-40.68-83.58,49-49a6,6,0,1,0-8.49-8.49l-49,49L23.15,100a2,2,0,0,1,.31-3.74l.11,0L215.48,38.08a1.94,1.94,0,0,1,1.92.52A2,2,0,0,1,217.92,40.52Z`}))],[`regular`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M227.32,28.68a16,16,0,0,0-15.66-4.08l-.15,0L19.57,82.84a16,16,0,0,0-2.49,29.8L102,154l41.3,84.87A15.86,15.86,0,0,0,157.74,248q.69,0,1.38-.06a15.88,15.88,0,0,0,14-11.51l58.2-191.94c0-.05,0-.1,0-.15A16,16,0,0,0,227.32,28.68ZM157.83,231.85l-.05.14,0-.07-40.06-82.3,48-48a8,8,0,0,0-11.31-11.31l-48,48L24.08,98.25l-.07,0,.14,0L216,40Z`}))],[`thin`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M224.47,31.52a11.87,11.87,0,0,0-11.82-3L20.74,86.67a12,12,0,0,0-1.91,22.38L105,151l41.92,86.15A11.88,11.88,0,0,0,157.74,244c.34,0,.69,0,1,0a11.89,11.89,0,0,0,10.52-8.63l58.21-192,0-.08A11.85,11.85,0,0,0,224.47,31.52Zm-4.62,9.54-58.23,192a4,4,0,0,1-7.48.59l-41.3-84.86,50-50a4,4,0,1,0-5.66-5.66l-50,50-84.9-41.31a3.88,3.88,0,0,1-2.27-4,3.93,3.93,0,0,1,3-3.54L214.9,36.16A3.93,3.93,0,0,1,216,36a4,4,0,0,1,2.79,1.19A3.93,3.93,0,0,1,219.85,41.06Z`}))]]),fe=new Map([[`bold`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M200,36H56A20,20,0,0,0,36,56V200a20,20,0,0,0,20,20H200a20,20,0,0,0,20-20V56A20,20,0,0,0,200,36Zm-4,160H60V60H196Z`}))],[`duotone`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M208,56V200a8,8,0,0,1-8,8H56a8,8,0,0,1-8-8V56a8,8,0,0,1,8-8H200A8,8,0,0,1,208,56Z`,opacity:`0.2`}),L.createElement(`path`,{d:`M200,40H56A16,16,0,0,0,40,56V200a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Zm0,160H56V56H200V200Z`}))],[`fill`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z`}))],[`light`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M200,42H56A14,14,0,0,0,42,56V200a14,14,0,0,0,14,14H200a14,14,0,0,0,14-14V56A14,14,0,0,0,200,42Zm2,158a2,2,0,0,1-2,2H56a2,2,0,0,1-2-2V56a2,2,0,0,1,2-2H200a2,2,0,0,1,2,2Z`}))],[`regular`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M200,40H56A16,16,0,0,0,40,56V200a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Zm0,160H56V56H200V200Z`}))],[`thin`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M200,44H56A12,12,0,0,0,44,56V200a12,12,0,0,0,12,12H200a12,12,0,0,0,12-12V56A12,12,0,0,0,200,44Zm4,156a4,4,0,0,1-4,4H56a4,4,0,0,1-4-4V56a4,4,0,0,1,4-4H200a4,4,0,0,1,4,4Z`}))]]),G=L.forwardRef((e,t)=>L.createElement(l,{ref:t,...e,weights:ue}));G.displayName=`CaretRightIcon`;var K=G,q=L.forwardRef((e,t)=>L.createElement(l,{ref:t,...e,weights:de}));q.displayName=`PaperPlaneTiltIcon`;var pe=q,J=L.forwardRef((e,t)=>L.createElement(l,{ref:t,...e,weights:fe}));J.displayName=`StopIcon`;var me=J;function he(e){return e.dashboard.panels.length===1?e.dashboard.panels[0].title:e.dashboard.name}function ge(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Missing panel view`);let t=e;if(!t.view||![`preset`,`query`].includes(t.view.kind)||!/^[a-f0-9]{64}$/.test(t.view.key))throw Error(`Invalid panel view identity`);if(t.dashboard?.version!==1||!Array.isArray(t.dashboard.panels)||!t.dashboard.panels.length||t.dashboard.panels.length>40||!Array.isArray(t.results)||t.dashboard.panels.some(e=>!e||typeof e.id!=`string`||!e.id)||t.results.some(e=>!e||typeof e.id!=`string`))throw Error(`Invalid panel view`);let n=new Set(t.dashboard.panels.map(e=>e.id));if(n.size!==t.dashboard.panels.length||t.results.length!==n.size||new Set(t.results.map(e=>e.id)).size!==n.size||t.results.some(e=>!n.has(e.id)||![`ok`,`empty`,`error`].includes(e.status)))throw Error(`Panel results do not match the view`);if(t.vars!==void 0&&(!t.vars||typeof t.vars!=`object`||Array.isArray(t.vars)||Object.values(t.vars).some(e=>typeof e!=`string`&&!(Array.isArray(e)&&e.every(e=>typeof e==`string`)))))throw Error(`Invalid panel variables`);if(t.trace!==void 0&&(!t.trace?.data||!Array.isArray(t.trace.data.spans)||!Array.isArray(t.trace.data.logs)||!Array.isArray(t.trace.data.services)))throw Error(`Invalid trace detail`);return t}var Y=new WeakSet;function X(e){if(!e||typeof e!=`object`||Array.isArray(e))return;if(Y.has(e))return e;let t=e;if(Object.keys(t).sort().join(`,`)===`is_error,resource_uri,tool_input,tool_name,tool_result`&&t.resource_uri===`ui://fanout/panels.html`&&typeof t.tool_name==`string`&&t.tool_name&&typeof t.is_error==`boolean`&&t.tool_input&&typeof t.tool_input==`object`&&!Array.isArray(t.tool_input)){try{ge(t.tool_result)}catch{return}return Y.add(t),t}}var _e=64,ve=300;function ye(){let e=(0,L.useRef)(null),t=(0,L.useRef)(!0),n=(0,L.useRef)(()=>{}),r=(0,L.useRef)(null),i=(0,L.useRef)(null),a=(0,L.useCallback)(()=>{let t=e.current;if(!t)return;let n=t.getBoundingClientRect().top,r=[...t.querySelectorAll(`[data-chat-anchor]`)].find(e=>e.getBoundingClientRect().bottom>n);i.current=r?{node:r,top:r.getBoundingClientRect().top}:null},[]),o=(0,L.useCallback)(()=>{let n=e.current;n&&t.current?n.scrollTop=n.scrollHeight:n&&i.current?.node.isConnected&&(n.scrollTop+=i.current.node.getBoundingClientRect().top-i.current.top),a()},[a]);return{scrollRef:(0,L.useCallback)(r=>{if(n.current(),e.current=r,!r)return;let o=0,s=!1,c=()=>{o=Date.now()},l=()=>{s=!0},u=()=>{s=!1},d=()=>{r.scrollHeight-r.clientHeight-r.scrollTop<=_e?t.current=!0:(s||Date.now()-o{r.removeEventListener(`scroll`,d),r.removeEventListener(`wheel`,c),r.removeEventListener(`touchmove`,c),r.removeEventListener(`keydown`,c),r.removeEventListener(`pointerdown`,l),window.removeEventListener(`pointerup`,u),n.current=()=>{}},t.current=!0,r.scrollTop=r.scrollHeight,i.current=null},[a]),contentRef:(0,L.useCallback)(e=>{r.current?.disconnect(),r.current=null,e&&(r.current=new ResizeObserver(o),r.current.observe(e))},[o]),toBottom:(0,L.useCallback)(()=>{t.current=!0,o()},[o])}}function be(e=1500){let[t,n]=(0,L.useState)(`idle`),r=(0,L.useRef)(null);(0,L.useEffect)(()=>()=>{r.current&&clearTimeout(r.current)},[]);function i(t){r.current&&clearTimeout(r.current),n(`idle`),(navigator.clipboard?navigator.clipboard.writeText(t):Promise.reject(Error(`clipboard unavailable`))).then(()=>n(`copied`),()=>n(`failed`)).finally(()=>{r.current=setTimeout(()=>n(`idle`),e)})}return{state:t,copy:i}}var xe={schema:`Telemetry`,context:`Context`,draft:`Draft`,validation:`Validation`,preview:`Preview`,save:`Save`},Z=e=>`${(e/1e3).toFixed(1)} s`;function Se({receipt:e,running:t=!1,activity:n=``,awaitingAnswer:r=!1}){let[i,a]=(0,L.useState)(!1),o=(0,L.useId)(),s=e.saved,l=s?.receipt.save_check,p=Object.values(e.stages).filter(e=>e.state===`complete`).length,m=[e.stages.schema.state===`complete`?`Read telemetry`:void 0,e.panel_count===void 0?void 0:`${e.panel_count} ${e.panel_count===1?`panel`:`panels`}`,l?.checked?`Checked in ${Z(l.elapsed_ms)}`:void 0,s?`Saved v${s.version}`:void 0].filter(Boolean).join(` · `)||`Building dashboard`,h=[...s?C(s.receipt):[],...e.corrections.map(e=>`Fixed ${e.panel_id}.${e.path.replace(/^panels\[\d+\]\./,``)}`)];return(0,R.jsx)(x,{"data-build-receipt":e.turn_id,"data-dashboard-result":s?.id,"data-chat-anchor":!0,withBorder:!0,radius:`md`,p:`sm`,children:(0,R.jsxs)(u,{gap:6,children:[(0,R.jsxs)(c,{gap:`xs`,justify:`space-between`,children:[(0,R.jsxs)(f,{size:`sm`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:[m,(0,R.jsxs)(f,{span:!0,c:`dimmed`,size:`xs`,children:[` · `,p,` stages complete`]})]}),(0,R.jsxs)(d,{component:`button`,variant:`subtle`,color:`gray`,size:`compact-xs`,"aria-expanded":i,"aria-controls":o,onClick:()=>a(e=>!e),children:[`Details`,h.length>4?` (+${h.length-4})`:``]})]}),t&&r&&(0,R.jsxs)(c,{gap:`xs`,"data-build-running":!0,children:[(0,R.jsx)(S,{type:`dots`,size:`sm`}),(0,R.jsx)(f,{c:`dimmed`,size:`sm`,children:n||`Analyzing your system`})]}),(0,R.jsx)(ie,{labels:h.slice(0,4)}),e.explanations.map(e=>t?e.split(` · `).filter(e=>!e.endsWith(`: incomplete`)).join(` · `):e).filter(Boolean).map((e,t)=>(0,R.jsx)(f,{size:`xs`,c:`dimmed`,"data-receipt-attention":!0,children:e},t)),s&&(0,R.jsx)(d,{renderRoot:e=>(0,R.jsx)(E,{...e,to:`/dashboards/$dashboardId`,params:{dashboardId:s.id},search:{}}),variant:`subtle`,size:`compact-sm`,color:`gray`,style:{alignSelf:`flex-start`},children:`Open dashboard`}),(0,R.jsx)(ae,{expanded:i,id:o,children:(0,R.jsxs)(u,{gap:4,children:[s&&(0,R.jsxs)(f,{size:`xs`,children:[s.label,` `,s.name,` · opens the current dashboard`]}),Object.entries(e.stages).map(([e,n])=>(0,R.jsxs)(f,{size:`xs`,c:`dimmed`,children:[xe[e],`: `,t&&n.state===`incomplete`?`in progress`:n.state,n.elapsed_ms===void 0?``:` · ${Z(n.elapsed_ms)}`]},e)),e.save_attempts.map((e,t)=>e.state===`retried`&&(0,R.jsxs)(f,{size:`xs`,c:`dimmed`,children:[`Save attempt `,t+1,`: retried`]},e.call_id)),!!e.context_counts.deploys&&(0,R.jsxs)(f,{size:`xs`,children:[e.context_counts.deploys,` deploys observed`]}),!!e.context_counts.anomalies&&(0,R.jsxs)(f,{size:`xs`,children:[e.context_counts.anomalies,` anomalies observed`]}),e.panels.map(e=>(0,R.jsxs)(f,{size:`xs`,children:[`Preview · `,e.id,`: `,e.status,e.elapsed_ms===void 0?``:` · ${Z(e.elapsed_ms)}`]},e.id)),l&&(0,R.jsxs)(f,{size:`xs`,children:[`Save check: `,l.checked?`checked`:`incomplete`,` · `,Z(l.elapsed_ms)]}),l?.panels.map(e=>(0,R.jsxs)(f,{size:`xs`,children:[`Save · `,e.id,`: `,e.status,` · `,e.rows??0,` rows`,e.elapsed_ms===void 0?``:` · ${Z(e.elapsed_ms)}`]},e.id)),h.slice(4).map((e,t)=>(0,R.jsx)(f,{size:`xs`,children:e},t)),e.corrections.map((e,t)=>(0,R.jsxs)(f,{size:`xs`,children:[`Fixed `,e.panel_id,`.`,e.path,`: `,e.message]},t))]})})]})})}var Ce=(0,L.lazy)(()=>j(()=>import(`./mcp-app-frame-tweTxib0.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))),Q=e=>e.tool_result.view.kind===`preset`;function we(e){let t=new Map,n=new Set,r=[],i=()=>{let e=new Map;for(let t of r){let n=t.content.tool_result.view.key;e.set(n,t)}let i=new Set([...e.values()].map(e=>e.id)),a=[...e.values()].some(e=>Q(e.content)),o=r.filter(e=>i.has(e.id)).at(-1)?.id;for(let e of r)i.has(e.id)?t.set(e.id,{content:e.content,expanded:Q(e.content)||!a&&e.id===o}):n.add(e.id);r=[]};for(let t of e)if(t.role===`user`&&i(),t.role===`activity`&&t.activityType===`mcp-app`){let e=X(t.content);e&&r.push({id:t.id,content:e})}return i(),{views:t,duplicates:n}}function Te(e){let t=new Map,n=new Map,r=new Map,i=`unattributed`;for(let a of e){if(a.role===`user`&&(n.clear(),r.clear(),i=a.id),a.role===`assistant`){i=a.id;for(let e of a.toolCalls??[])n.set(e.id,{assistant:i,name:e.function.name})}if(a.role===`tool`){let e=w(a.content);if(!a.error&&!e?.error&&e?.isError!==!0)continue;let o=n.get(a.toolCallId);if(o&&T.has(o.name)&&O(a))continue;let s=o?.assistant??i,c=r.get(s)??a.id;r.set(s,c);let l=t.get(c)??[],u=k(e?.error)?e?.error:void 0,d=typeof u?.message==`string`?u.message:typeof a.error==`string`&&a.error?a.error:`Tool execution failed`;l.push({name:o?.name??`Tool`,message:d,readOnly:u?.code===`answer_only`}),t.set(c,l)}}return t}function Ee({failures:e}){let[t,n]=(0,L.useState)(!1),r=e.filter(e=>!e.readOnly);return(0,R.jsxs)(i,{"data-chat-anchor":!0,children:[e.some(e=>e.readOnly)&&(0,R.jsx)(f,{size:`sm`,c:`dimmed`,children:`Not saved: Explain is read-only`}),r.length>0&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(o,{className:`chat-app-toggle`,"aria-expanded":t,onClick:()=>n(e=>!e),style:{color:`var(--mantine-color-dimmed)`},children:[(0,R.jsx)(`span`,{className:`chat-app-chevron`,"aria-hidden":`true`,children:t?(0,R.jsx)(N,{size:14}):(0,R.jsx)(K,{size:14})}),(0,R.jsxs)(`span`,{className:`chat-app-summary`,children:[r.length,` tool `,r.length===1?`call`:`calls`,` failed`]})]}),t&&(0,R.jsx)(u,{gap:`xs`,pl:`md`,children:r.map((e,t)=>(0,R.jsxs)(f,{size:`sm`,c:`dimmed`,style:{whiteSpace:`pre-wrap`,overflowWrap:`anywhere`},children:[e.name,`: `,e.message]},t))})]})]})}function De({view:e}){let[t,n]=(0,L.useState)(e.expanded);(0,L.useEffect)(()=>n(e.expanded),[e.expanded]);let r=e.content.tool_result,i=he(r),a=[...new Set(r.dashboard.panels.map(e=>e.viz===`timeseries`?`time series`:e.viz.replaceAll(`_`,` `)))].join(`, `),s=r.results.reduce((e,t)=>e+(t.frame?.rows??0),0),c=new Map;for(let e of r.results)e.status!==`ok`&&c.set(e.status,(c.get(e.status)??0)+1);let l=r.dashboard.panels.length>1?[`${r.dashboard.panels.length} panels`,...Array.from(c,([e,t])=>`${t} ${e}`)].join(` · `):c.size?[...c.keys()].join(`, `):`${s} ${s===1?`row`:`rows`}`;return(0,R.jsxs)(x,{"data-chat-app":!0,"data-chat-anchor":!0,withBorder:!0,radius:`lg`,style:{overflow:`hidden`},children:[(0,R.jsxs)(o,{className:`chat-app-toggle`,"aria-expanded":t,onClick:()=>n(e=>!e),children:[(0,R.jsx)(`span`,{className:`chat-app-chevron`,"aria-hidden":`true`,children:t?(0,R.jsx)(N,{size:14}):(0,R.jsx)(K,{size:14})}),(0,R.jsxs)(`span`,{className:`chat-app-summary`,children:[i,` · `,a,` · `,l]})]}),t&&(0,R.jsx)(L.Suspense,{fallback:(0,R.jsx)(b,{mih:180,children:(0,R.jsx)(S,{size:`sm`})}),children:(0,R.jsx)(Ce,{content:e.content})})]})}var Oe=[`Summarize system health for the last hour`,`Find the source of elevated errors`,`Map the current service dependencies`,`Show the slowest endpoints`];function ke(){let{agentAvailable:e,messages:t,messageTimes:n,ready:r,running:a,activity:o,provisional:s,stopped:l,error:p,threadMissing:h,send:g,retry:v,reloadThread:y,newThread:C}=A(),{scrollRef:w,contentRef:T,toBottom:E}=ye(),D=te(t),O=t.filter(e=>e.role===`user`).at(-1)?.id;if((0,L.useEffect)(()=>{O&&E()},[O,E]),!e)return(0,R.jsx)(m,{size:`sm`,py:96,children:(0,R.jsx)(x,{withBorder:!0,radius:`lg`,p:{base:`xl`,sm:40},children:(0,R.jsxs)(u,{gap:`md`,children:[(0,R.jsx)(f,{c:`brand`,fw:700,size:`xs`,tt:`uppercase`,lts:`0.12em`,children:`Optional capability`}),(0,R.jsx)(ee,{order:1,fz:28,children:`Chat is not configured`}),(0,R.jsx)(f,{c:`dimmed`,children:`Add an AI provider key to enable chat. Telemetry ingest, dashboards, traces, logs, and metrics remain available without it.`}),(0,R.jsx)(d,{component:`a`,href:`/dashboards`,variant:`light`,mt:`sm`,children:`Open dashboards`})]})})});let k=we(t),j=Te(t),M=t.filter(e=>k.duplicates.has(e.id)?!1:e.role===`tool`?j.has(e.id):e.role===`assistant`?!e.toolCalls?.length&&typeof e.content==`string`&&e.content.trim().length>0:e.role===`activity`?e.activityType===`mcp-app`||e.activityType===`agent-outcome`:e.role===`user`),N=t.findIndex(e=>e.id===O),P=t.slice(N+1).some(e=>e.role===`assistant`&&!e.toolCalls?.length&&typeof e.content==`string`&&e.content.length>0),F=t.slice(N+1).filter(e=>e.role===`assistant`&&!e.toolCalls?.length&&typeof e.content==`string`&&e.content.trim().length>0).at(-1),I=a&&s&&!s.collapsed&&s.text&&!P;return(0,R.jsxs)(i,{className:`chat-pane`,children:[(0,R.jsx)(i,{className:`chat-scroll`,ref:w,tabIndex:0,role:`log`,"aria-label":`Conversation`,children:(0,R.jsxs)(m,{size:880,px:{base:`md`,sm:`xl`},py:`lg`,ref:T,children:[h&&(0,R.jsx)(_,{color:`warn`,radius:`lg`,title:`This chat no longer exists`,children:(0,R.jsxs)(c,{justify:`space-between`,children:[(0,R.jsx)(f,{size:`sm`,children:`It was deleted, or the link is wrong.`}),(0,R.jsx)(d,{size:`compact-sm`,variant:`light`,onClick:C,children:`New chat`})]})}),!h&&!r&&p&&(0,R.jsx)(Ae,{message:p,onRetry:y,onNewThread:C}),!h&&!r&&!p&&(0,R.jsxs)(b,{mih:`40vh`,children:[(0,R.jsx)(S,{size:`sm`}),(0,R.jsx)(f,{c:`dimmed`,size:`sm`,ml:`sm`,children:`Loading chat`})]}),!h&&r&&(0,R.jsxs)(R.Fragment,{children:[M.length===0&&(0,R.jsx)(Me,{onSelect:g}),(0,R.jsxs)(u,{gap:`lg`,children:[M.filter(e=>e.id!==F?.id).map(e=>j.has(e.id)?(0,R.jsx)(Ee,{failures:j.get(e.id)},e.id):(0,R.jsxs)(i,{children:[(0,R.jsx)(Ne,{message:e,time:n[e.id],appView:k.views.get(e.id)}),D.has(e.id)&&(0,R.jsx)(i,{mt:`sm`,children:(0,R.jsx)(Se,{receipt:D.get(e.id),running:a&&e.id===O,awaitingAnswer:!P&&!I,activity:o})})]},e.id)),(F||I)&&(0,R.jsx)(i,{"data-answer-position":!0,children:(0,R.jsx)(Ne,{message:I?{id:s.id,role:`assistant`,content:s.text}:F,provisional:!!I,time:I?void 0:n[F.id]})},`answer-${O??`draft`}`),a&&!P&&!I&&!D.has(O??``)&&(0,R.jsxs)(c,{gap:`xs`,role:`status`,children:[(0,R.jsx)(S,{type:`dots`,size:`sm`}),(0,R.jsx)(f,{c:`dimmed`,size:`sm`,children:o||`Analyzing your system`})]}),l&&(0,R.jsx)(f,{c:`dimmed`,size:`sm`,children:`Stopped`}),p&&(0,R.jsx)(Ae,{message:p,onRetry:v})]})]})]})}),!h&&(0,R.jsx)(je,{})]})}function Ae({message:e,onRetry:t,onNewThread:n}){return(0,R.jsx)(_,{color:`bad`,radius:`lg`,title:`Something went wrong`,children:(0,R.jsxs)(c,{justify:`space-between`,gap:`sm`,wrap:`nowrap`,children:[(0,R.jsx)(f,{size:`sm`,children:e}),(0,R.jsxs)(c,{gap:`xs`,wrap:`nowrap`,children:[n&&(0,R.jsx)(d,{size:`compact-sm`,variant:`subtle`,color:`bad`,onClick:n,children:`New chat`}),(0,R.jsx)(d,{size:`compact-sm`,variant:`light`,color:`bad`,onClick:t,children:`Retry`})]})]})})}function je(){let{input:e,setInput:t,inputRef:n,submit:r,send:a,stop:o,ready:s,running:l}=A();return(0,R.jsx)(i,{className:`chat-composer`,children:(0,R.jsxs)(m,{size:880,px:{base:`md`,sm:`xl`},children:[(0,R.jsx)(x,{component:`form`,onSubmit:r,className:`chat-composer-field`,withBorder:!0,radius:24,py:6,pl:`lg`,pr:6,children:(0,R.jsxs)(c,{align:`flex-end`,gap:`xs`,wrap:`nowrap`,children:[(0,R.jsx)(H,{ref:n,"aria-label":`Message Fanout`,value:e,onChange:e=>t(e.currentTarget.value),onKeyDown:t=>{t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),a(e))},placeholder:l?`Fanout is working…`:`Ask about health, errors, or latency…`,disabled:!s,autosize:!0,minRows:1,maxRows:8,variant:`unstyled`,flex:1}),l?(0,R.jsx)(M,{label:`Stop`,children:(0,R.jsx)(D,{type:`button`,variant:`default`,size:40,radius:`xl`,"aria-label":`Stop`,onClick:o,children:(0,R.jsx)(me,{size:16,weight:`fill`})})}):(0,R.jsx)(D,{type:`submit`,variant:`filled`,size:40,radius:`xl`,disabled:!e.trim()||!s,"aria-label":`Send message`,children:(0,R.jsx)(pe,{size:17,weight:`fill`})})]})}),(0,R.jsx)(f,{c:`dimmed`,size:`xs`,ta:`center`,mt:6,children:`Enter to send, Shift+Enter for a new line`})]})})}function Me({onSelect:e}){return(0,R.jsxs)(u,{align:`center`,gap:`md`,pt:{base:32,sm:88},pb:`xl`,ta:`center`,children:[(0,R.jsx)(g,{size:`large`}),(0,R.jsx)(ee,{order:1,fz:24,fw:500,lh:1.25,maw:560,children:`What do you want to know about your system?`}),(0,R.jsx)(c,{justify:`center`,gap:`xs`,mt:`xs`,maw:720,children:Oe.map(t=>(0,R.jsx)(d,{variant:`default`,size:`sm`,radius:`xl`,onClick:()=>void e(t),children:t},t))})]})}function Ne({message:e,time:t,appView:n,provisional:r=!1}){if(e.role===`activity`)return e.activityType===`agent-outcome`&&e.content&&typeof e.content==`object`&&`message`in e.content&&typeof e.content.message==`string`?`status`in e.content&&e.content.status===`stopped`?(0,R.jsx)(f,{c:`dimmed`,size:`sm`,"data-chat-anchor":!0,children:e.content.message}):(0,R.jsx)(_,{color:`bad`,title:`Something went wrong`,"data-chat-anchor":!0,children:e.content.message}):e.activityType===`mcp-app`?n?(0,R.jsx)(De,{view:n}):(0,R.jsx)(_,{color:`bad`,"data-chat-anchor":!0,children:`This view could not be loaded. Please try again.`}):null;if(e.role===`assistant`&&e.toolCalls?.length)return null;let a=typeof e.content==`string`?e.content:JSON.stringify(e.content);if(!a&&e.role===`assistant`)return null;let o=e.role===`user`,s=t?new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}).format(new Date(t)):``;return(0,R.jsxs)(i,{className:`chat-message${r?` chat-message--provisional`:``}`,"data-chat-anchor":!0,"data-role":o?`user`:`assistant`,children:[o?(0,R.jsx)(x,{radius:`lg`,px:`md`,py:`sm`,bg:`var(--mantine-color-brand-light)`,maw:`70%`,ml:`auto`,w:`fit-content`,children:(0,R.jsx)(f,{style:{whiteSpace:`pre-wrap`},children:a})}):(0,R.jsx)(W,{className:`chat-markdown${r?` chat-markdown--provisional`:``}`,"data-provisional":r||void 0,children:(0,R.jsx)(re,{remarkPlugins:[I],components:Fe,children:a})}),(r||s||!o)&&(0,R.jsx)(c,{className:`chat-message-meta`,gap:6,justify:o?`flex-end`:`flex-start`,mt:4,h:24,children:r?(0,R.jsx)(S,{type:`dots`,size:20}):(0,R.jsxs)(R.Fragment,{children:[s&&t&&(0,R.jsx)(f,{c:`dimmed`,size:`xs`,title:ne(t),children:s}),!o&&(0,R.jsx)(Pe,{text:a,label:`Copy message`})]})})]})}function Pe({text:e,label:t}){let{state:n,copy:r}=be();return(0,R.jsx)(M,{label:n===`failed`?`Could not copy`:n===`copied`?`Copied`:t,children:(0,R.jsx)(D,{variant:`subtle`,color:`gray`,size:`sm`,"aria-label":t,"data-state":n===`idle`?void 0:n,onClick:()=>r(e),children:n===`copied`?(0,R.jsx)(p,{size:13,weight:`bold`}):(0,R.jsx)(v,{size:13})})})}var Fe={table:({children:e})=>(0,R.jsx)(i,{className:`chat-table`,children:(0,R.jsx)(F,{striped:!0,highlightOnHover:!0,withTableBorder:!0,verticalSpacing:`xs`,fz:`sm`,children:e})}),thead:({children:e})=>(0,R.jsx)(F.Thead,{children:e}),tbody:({children:e})=>(0,R.jsx)(F.Tbody,{children:e}),tr:({children:e})=>(0,R.jsx)(F.Tr,{children:e}),th:({children:e})=>(0,R.jsx)(F.Th,{children:e}),td:({children:e})=>(0,R.jsx)(F.Td,{children:e}),pre:({children:e})=>(0,R.jsx)(Ie,{children:e}),a:({href:e,children:t})=>(0,R.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,children:t})};function Ie({children:e}){let t=$(e);return(0,R.jsxs)(i,{className:`chat-code`,pos:`relative`,children:[(0,R.jsx)(i,{className:`chat-code-actions`,pos:`absolute`,top:6,right:6,children:(0,R.jsx)(Pe,{text:t,label:`Copy code`})}),(0,R.jsx)(`pre`,{children:e})]})}function $(e){return typeof e==`string`?e:Array.isArray(e)?e.map($).join(``):e&&typeof e==`object`&&`props`in e?$(e.props.children):``}export{X as n,ke as t}; \ No newline at end of file diff --git a/internal/ui/dist/assets/chat._threadId-BsJLgkqj.js b/internal/ui/dist/assets/chat._threadId-BsJLgkqj.js deleted file mode 100644 index ff4beaf2..00000000 --- a/internal/ui/dist/assets/chat._threadId-BsJLgkqj.js +++ /dev/null @@ -1 +0,0 @@ -import{t as e}from"./chat-D8Nl9xGT.js";var t=e;export{t as component}; \ No newline at end of file diff --git a/internal/ui/dist/assets/chat._threadId-eVfsC4Jb.js b/internal/ui/dist/assets/chat._threadId-eVfsC4Jb.js new file mode 100644 index 00000000..40445052 --- /dev/null +++ b/internal/ui/dist/assets/chat._threadId-eVfsC4Jb.js @@ -0,0 +1 @@ +import{t as e}from"./chat-_owdy9Bf.js";var t=e;export{t as component}; \ No newline at end of file diff --git a/internal/ui/dist/assets/chat.index-BsJLgkqj.js b/internal/ui/dist/assets/chat.index-BsJLgkqj.js deleted file mode 100644 index ff4beaf2..00000000 --- a/internal/ui/dist/assets/chat.index-BsJLgkqj.js +++ /dev/null @@ -1 +0,0 @@ -import{t as e}from"./chat-D8Nl9xGT.js";var t=e;export{t as component}; \ No newline at end of file diff --git a/internal/ui/dist/assets/chat.index-eVfsC4Jb.js b/internal/ui/dist/assets/chat.index-eVfsC4Jb.js new file mode 100644 index 00000000..40445052 --- /dev/null +++ b/internal/ui/dist/assets/chat.index-eVfsC4Jb.js @@ -0,0 +1 @@ +import{t as e}from"./chat-_owdy9Bf.js";var t=e;export{t as component}; \ No newline at end of file diff --git a/internal/ui/dist/assets/dashboards._dashboardId-ClSSKrZi.js b/internal/ui/dist/assets/dashboards._dashboardId-09220iIf.js similarity index 75% rename from internal/ui/dist/assets/dashboards._dashboardId-ClSSKrZi.js rename to internal/ui/dist/assets/dashboards._dashboardId-09220iIf.js index b3492536..934c3a8e 100644 --- a/internal/ui/dist/assets/dashboards._dashboardId-ClSSKrZi.js +++ b/internal/ui/dist/assets/dashboards._dashboardId-09220iIf.js @@ -1 +1 @@ -import{r as e}from"./useRouter-ByJ6_rwb.js";import{n as t}from"./useNavigate-B1zgPEUp.js";import{_ as n,b as r}from"./theme-DdznftKI.js";import{t as i}from"./page-D0-Qm4dK.js";import{t as a}from"./index-ZyJwWZ_-.js";var o=e();function s(){let{dashboardId:e}=a.useParams(),s=n(a.useSearch()),c=t(),l=(t,n,i)=>void c({to:`/dashboards/$dashboardId`,params:{dashboardId:t},search:r(n),replace:i,resetScroll:t!==e});return(0,o.jsx)(i,{dashboardId:e,search:s,onSearch:(t,n)=>l(e,t,n),onOpen:(e,t)=>l(e,{},t)})}export{s as component}; \ No newline at end of file +import{r as e}from"./useRouter-ByJ6_rwb.js";import{n as t}from"./useNavigate-B1zgPEUp.js";import{_ as n,b as r}from"./theme-DdznftKI.js";import{t as i}from"./page-vAmZFsvk.js";import{t as a}from"./index-CNsdEvGl.js";var o=e();function s(){let{dashboardId:e}=a.useParams(),s=n(a.useSearch()),c=t(),l=(t,n,i)=>void c({to:`/dashboards/$dashboardId`,params:{dashboardId:t},search:r(n),replace:i,resetScroll:t!==e});return(0,o.jsx)(i,{dashboardId:e,search:s,onSearch:(t,n)=>l(e,t,n),onOpen:(e,t)=>l(e,{},t)})}export{s as component}; \ No newline at end of file diff --git a/internal/ui/dist/assets/dashboards.index-DTZMYeFV.js b/internal/ui/dist/assets/dashboards.index-mQSdDlyY.js similarity index 70% rename from internal/ui/dist/assets/dashboards.index-DTZMYeFV.js rename to internal/ui/dist/assets/dashboards.index-mQSdDlyY.js index 6ba3a360..51fc1531 100644 --- a/internal/ui/dist/assets/dashboards.index-DTZMYeFV.js +++ b/internal/ui/dist/assets/dashboards.index-mQSdDlyY.js @@ -1 +1 @@ -import{r as e}from"./useRouter-ByJ6_rwb.js";import{n as t}from"./useNavigate-B1zgPEUp.js";import{_ as n,b as r}from"./theme-DdznftKI.js";import{t as i}from"./page-D0-Qm4dK.js";import{n as a}from"./index-ZyJwWZ_-.js";var o=e();function s(){let e=n(a.useSearch()),s=t();return(0,o.jsx)(i,{search:e,onSearch:()=>void 0,onOpen:(t,n)=>void s({to:`/dashboards/$dashboardId`,params:{dashboardId:t},search:r(e),replace:n})})}export{s as component}; \ No newline at end of file +import{r as e}from"./useRouter-ByJ6_rwb.js";import{n as t}from"./useNavigate-B1zgPEUp.js";import{_ as n,b as r}from"./theme-DdznftKI.js";import{t as i}from"./page-vAmZFsvk.js";import{n as a}from"./index-CNsdEvGl.js";var o=e();function s(){let e=n(a.useSearch()),s=t();return(0,o.jsx)(i,{search:e,onSearch:()=>void 0,onOpen:(t,n)=>void s({to:`/dashboards/$dashboardId`,params:{dashboardId:t},search:r(e),replace:n})})}export{s as component}; \ No newline at end of file diff --git a/internal/ui/dist/assets/index-ZyJwWZ_-.js b/internal/ui/dist/assets/index-CNsdEvGl.js similarity index 99% rename from internal/ui/dist/assets/index-ZyJwWZ_-.js rename to internal/ui/dist/assets/index-CNsdEvGl.js index 80468ec9..a475a6b9 100644 --- a/internal/ui/dist/assets/index-ZyJwWZ_-.js +++ b/internal/ui/dist/assets/index-CNsdEvGl.js @@ -1,4 +1,4 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/routes-D2AdaqvY.js","assets/useRouter-ByJ6_rwb.js","assets/useNavigate-B1zgPEUp.js","assets/settings-gNliABpX.js","assets/brand-Bcp2Tp5I.js","assets/Tooltip-DhnGSmh7.js","assets/useQuery-CEXOTfck.js","assets/auth-C8kS8ur3.js","assets/WarningCircle.es-CQHtdoVp.js","assets/chat.index-BsJLgkqj.js","assets/chat-D8Nl9xGT.js","assets/preload-helper-DpsUT6aH.js","assets/dashboard-change-chips-C08J6wNb.js","assets/chat._threadId-BsJLgkqj.js","assets/dashboards.index-DTZMYeFV.js","assets/theme-DdznftKI.js","assets/use-computed-color-scheme-BIja2o3c.js","assets/page-D0-Qm4dK.js","assets/dashboards._dashboardId-ClSSKrZi.js"])))=>i.map(i=>d[i]); +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/routes-D2AdaqvY.js","assets/useRouter-ByJ6_rwb.js","assets/useNavigate-B1zgPEUp.js","assets/settings-BnFwabAq.js","assets/brand-Bcp2Tp5I.js","assets/Tooltip-DhnGSmh7.js","assets/useQuery-CEXOTfck.js","assets/auth-C8kS8ur3.js","assets/WarningCircle.es-CQHtdoVp.js","assets/chat.index-eVfsC4Jb.js","assets/chat-_owdy9Bf.js","assets/preload-helper-DpsUT6aH.js","assets/dashboard-change-chips-C08J6wNb.js","assets/chat._threadId-eVfsC4Jb.js","assets/dashboards.index-mQSdDlyY.js","assets/theme-DdznftKI.js","assets/use-computed-color-scheme-BIja2o3c.js","assets/page-vAmZFsvk.js","assets/dashboards._dashboardId-09220iIf.js"])))=>i.map(i=>d[i]); import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./useRouter-ByJ6_rwb.js";import{A as s,B as c,C as l,F as u,G as d,H as f,I as p,J as m,K as h,L as g,M as _,N as v,P as y,R as b,S as ee,T as x,V as S,W as te,X as C,Y as ne,_ as re,_t as ie,a as w,at as ae,c as oe,d as se,f as ce,gt as le,ht as ue,it as de,k as fe,lt as pe,mt as T,nt as me,p as he,pt as ge,st as _e,t as ve,tt as ye,u as be,ut as xe,w as Se,y as Ce}from"./brand-Bcp2Tp5I.js";import{i as E,n as we,t as Te}from"./useNavigate-B1zgPEUp.js";import{A as Ee,B as De,C as Oe,D as ke,E as Ae,F as je,I as Me,M as Ne,N as Pe,O as Fe,P as Ie,R as Le,S as Re,T as ze,V as Be,_ as Ve,a as He,b as Ue,h as We,i as Ge,j as Ke,k as qe,m as Je,n as Ye,r as Xe,s as Ze,t as Qe,u as $e,v as et,x as tt,y as nt,z as rt}from"./preload-helper-DpsUT6aH.js";import{A as it,B as at,E as ot,H as st,Q as ct,S as lt,T as ut,U as dt,V as ft,W as pt,X as mt,Y as ht,Z as gt,_ as _t,a as vt,at as yt,b as bt,ct as xt,dt as St,et as Ct,it as wt,lt as Tt,n as Et,nt as Dt,ot as Ot,rt as kt,st as At,t as jt,tt as Mt,ut as Nt,x as Pt,z as Ft}from"./theme-DdznftKI.js";import{E as It,T as Lt,o as Rt,t as zt,x as Bt}from"./Tooltip-DhnGSmh7.js";import{n as Vt,t as Ht}from"./use-computed-color-scheme-BIja2o3c.js";import{C as Ut,E as Wt,F as Gt,L as Kt,T as qt,_ as Jt,a as Yt,b as Xt,c as Zt,d as Qt,f as $t,g as en,h as tn,l as nn,m as rn,n as an,o as on,p as sn,r as cn,s as ln,t as un,u as dn,v as fn,w as pn,y as mn}from"./useQuery-CEXOTfck.js";import{a as hn,i as gn,n as _n,r as vn,s as yn,t as bn}from"./auth-C8kS8ur3.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var xn=e((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0>>1,a=e[r];if(0>>1;ri(c,n))li(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(li(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function ee(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,x||(x=!0,ie());else{var t=n(l);t!==null&&oe(ee,t.startTime-e)}}}var x=!1,S=-1,te=5,C=-1;function ne(){return g?!0:!(e.unstable_now()-Ct&&ne());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&oe(ee,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?ie():x=!1}}}var ie;if(typeof y==`function`)ie=function(){y(re)};else if(typeof MessageChannel<`u`){var w=new MessageChannel,ae=w.port2;w.port1.onmessage=re,ie=function(){ae.postMessage(null)}}else ie=function(){_(re,0)};function oe(t,n){S=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(S),S=-1):h=!0,oe(ee,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,x||(x=!0,ie()))),r},e.unstable_shouldYield=ne,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Sn=e(((e,t)=>{t.exports=xn()})),Cn=e((e=>{var n=Sn(),r=t(),i=ie();function a(e){var t=`https://react.dev/errors/`+e;if(1De||(e.current=Ee[De],Ee[De]=null,De--)}function Ae(e,t){De++,Ee[De]=e.current,e.current=t}var je=Oe(null),Me=Oe(null),Ne=Oe(null),Pe=Oe(null);function Fe(e,t){switch(Ae(Ne,t),Ae(Me,e),Ae(je,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Cp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Cp(t),e=wp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}ke(je),Ae(je,e)}function Ie(){ke(je),ke(Me),ke(Ne)}function Le(e){var t=e.memoizedState;t!==null&&(bh._currentValue=t.memoizedState,Ae(Pe,e)),t=je.current;var n=wp(t,e.type);t!==n&&(Ae(Me,e),Ae(je,n))}function Re(e){Me.current===e&&(ke(je),ke(Me)),Pe.current===e&&(ke(Pe),bh._currentValue=Te)}var ze,Be;function Ve(e){if(ze===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ze=t&&t[1]||``,Be=-1)`:-1s(e,t,n)},i,a=LC,o=!EC.jitless,s=o&&RC.value,c=t.catchall,l;e._zod.parse=(u,d)=>{l??=n.value;let f=u.value;if(!a(f))return u.issues.push({expected:`object`,code:`invalid_type`,input:f,inst:e}),u;let p=[];if(o&&s&&d?.async===!1&&d.jitless!==!0)i||=r(t.shape),u=i(u,d);else{u.value={};let e=l.shape;for(let t of l.keys){let n=e[t],r=n._zod.run({value:f[t],issues:[]},d),i=n._zod.optin===`optional`&&n._zod.optout===`optional`;r instanceof Promise?p.push(r.then(e=>i?Dw(e,u,t,f):Ew(e,u,t))):i?Dw(r,u,t,f):Ew(r,u,t)}}if(!c)return p.length?Promise.all(p).then(()=>u):u;let m=[],h=l.keySet,g=c._zod,_=g.def.type;for(let e of Object.keys(f)){if(h.has(e))continue;if(_===`never`){m.push(e);continue}let t=g.run({value:f[e],issues:[]},d);t instanceof Promise?p.push(t.then(t=>Ew(t,u,e))):Ew(t,u,e)}return m.length&&u.issues.push({code:`unrecognized_keys`,keys:m,input:f,inst:e}),p.length?Promise.all(p).then(()=>u):u}});function kw(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;return t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>ew(e,r,DC())))}),t}var Aw=$(`$ZodUnion`,(e,t)=>{xw.init(e,t),NC(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),NC(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),NC(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),NC(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>MC(e.source)).join(`|`)})$`)}}),e._zod.parse=(n,r)=>{let i=!1,a=[];for(let e of t.options){let t=e._zod.run({value:n.value,issues:[]},r);if(t instanceof Promise)a.push(t),i=!0;else{if(t.issues.length===0)return t;a.push(t)}}return i?Promise.all(a).then(t=>kw(t,n,e,r)):kw(a,n,e,r)}}),jw=$(`$ZodIntersection`,(e,t)=>{xw.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Nw(e,t,n)):Nw(e,i,a)}});function Mw(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(zC(e)&&zC(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Mw(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r{xw.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!zC(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[];if(t.keyType._zod.values){let o=t.keyType._zod.values;n.value={};for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(...QC(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...QC(e,o.issues)),n.value[e]=o.value)}let s;for(let e in i)o.has(e)||(s??=[],s.push(e));s&&s.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:s})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){n.issues.push({origin:`record`,code:`invalid_key`,issues:s.issues.map(e=>ew(e,r,DC())),input:o,path:[o],inst:e}),n.value[s.value]=s.value;continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...QC(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...QC(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),Fw=$(`$ZodEnum`,(e,t)=>{xw.init(e,t);let n=OC(t.entries);e._zod.values=new Set(n),e._zod.pattern=RegExp(`^(${n.filter(e=>BC.has(typeof e)).map(e=>typeof e==`string`?VC(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,r)=>{let i=t.value;return e._zod.values.has(i)||t.issues.push({code:`invalid_value`,values:n,input:i,inst:e}),t}}),Iw=$(`$ZodLiteral`,(e,t)=>{xw.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?VC(e):e?e.toString():String(e)).join(`|`)})$`),e._zod.parse=(n,r)=>{let i=n.value;return e._zod.values.has(i)||n.issues.push({code:`invalid_value`,values:t.values,input:i,inst:e}),n}}),Lw=$(`$ZodTransform`,(e,t)=>{xw.init(e,t),e._zod.parse=(e,n)=>{let r=t.transform(e.value,e);if(n.async)return(r instanceof Promise?r:Promise.resolve(r)).then(t=>(e.value=t,e));if(r instanceof Promise)throw new TC;return e.value=r,e}}),Rw=$(`$ZodOptional`,(e,t)=>{xw.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,NC(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),NC(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${MC(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>t.innerType._zod.optin===`optional`?t.innerType._zod.run(e,n):e.value===void 0?e:t.innerType._zod.run(e,n)}),zw=$(`$ZodNullable`,(e,t)=>{xw.init(e,t),NC(e._zod,`optin`,()=>t.innerType._zod.optin),NC(e._zod,`optout`,()=>t.innerType._zod.optout),NC(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${MC(e.source)}|null)$`):void 0}),NC(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Bw=$(`$ZodDefault`,(e,t)=>{xw.init(e,t),e._zod.optin=`optional`,NC(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Vw(e,t)):Vw(r,t)}});function Vw(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Hw=$(`$ZodPrefault`,(e,t)=>{xw.init(e,t),e._zod.optin=`optional`,NC(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Uw=$(`$ZodNonOptional`,(e,t)=>{xw.init(e,t),NC(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Ww(t,e)):Ww(i,e)}});function Ww(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var Gw=$(`$ZodCatch`,(e,t)=>{xw.init(e,t),e._zod.optin=`optional`,NC(e._zod,`optout`,()=>t.innerType._zod.optout),NC(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>ew(e,n,DC()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>ew(e,n,DC()))},input:e.value}),e.issues=[]),e)}}),Kw=$(`$ZodPipe`,(e,t)=>{xw.init(e,t),NC(e._zod,`values`,()=>t.in._zod.values),NC(e._zod,`optin`,()=>t.in._zod.optin),NC(e._zod,`optout`,()=>t.out._zod.optout),e._zod.parse=(e,n)=>{let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>qw(e,t,n)):qw(r,t,n)}});function qw(e,t,n){return ZC(e)?e:t.out._zod.run({value:e.value,issues:e.issues},n)}var Jw=$(`$ZodReadonly`,(e,t)=>{xw.init(e,t),NC(e._zod,`propValues`,()=>t.innerType._zod.propValues),NC(e._zod,`values`,()=>t.innerType._zod.values),NC(e._zod,`optin`,()=>t.innerType._zod.optin),NC(e._zod,`optout`,()=>t.innerType._zod.optout),e._zod.parse=(e,n)=>{let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Yw):Yw(r)}});function Yw(e){return e.value=Object.freeze(e.value),e}var Xw=$(`$ZodLazy`,(e,t)=>{xw.init(e,t),NC(e._zod,`innerType`,()=>t.getter()),NC(e._zod,`pattern`,()=>e._zod.innerType._zod.pattern),NC(e._zod,`propValues`,()=>e._zod.innerType._zod.propValues),NC(e._zod,`optin`,()=>e._zod.innerType._zod.optin),NC(e._zod,`optout`,()=>e._zod.innerType._zod.optout),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),Zw=$(`$ZodCustom`,(e,t)=>{mw.init(e,t),xw.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Qw(t,n,r,e));Qw(i,n,r,e)}});function Qw(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(nw(e))}}var $w=class{constructor(){this._map=new Map,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==`object`&&`id`in n){if(this._idmap.has(n.id))throw Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};return delete n.id,{...n,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}};function eT(){return new $w}var tT=eT();function nT(e){return new e({type:`unknown`})}function rT(e,t){return new e({type:`never`,...UC(t)})}function iT(e,t){return new hw({check:`max_length`,...UC(t),maximum:e})}function aT(e,t){return new gw({check:`min_length`,...UC(t),minimum:e})}function oT(e,t){return new _w({check:`length_equals`,...UC(t),length:e})}function sT(e){return new vw({check:`overwrite`,tx:e})}function cT(e,t,n){return new e({type:`array`,element:t,...UC(n)})}function lT(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...UC(n)})}var uT=(e,t)=>{iw.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>sw(e,t)},flatten:{value:t=>ow(e,t)},addIssue:{value:t=>e.issues.push(t)},addIssues:{value:t=>e.issues.push(...t)},isEmpty:{get(){return e.issues.length===0}}})};$(`ZodError`,uT);var dT=$(`ZodError`,uT,{Parent:Error}),fT=cw(dT),pT=lw(dT),mT=uw(dT),hT=fw(dT),gT=$(`ZodType`,(e,t)=>(xw.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),e.clone=(t,n)=>HC(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>fT(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>mT(e,t,n),e.parseAsync=async(t,n)=>pT(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>hT(e,t,n),e.spa=e.safeParseAsync,e.refine=(t,n)=>e.check($T(t,n)),e.superRefine=t=>e.check(eE(t)),e.overwrite=t=>e.check(sT(t)),e.optional=()=>FT(e),e.nullable=()=>LT(e),e.nullish=()=>FT(LT(e)),e.nonoptional=t=>UT(e,t),e.array=()=>ST(e),e.or=t=>TT([e,t]),e.and=t=>DT(e,t),e.transform=t=>qT(e,NT(t)),e.default=t=>zT(e,t),e.prefault=t=>VT(e,t),e.catch=t=>GT(e,t),e.pipe=t=>qT(e,t),e.readonly=()=>YT(e),e.describe=t=>{let n=e.clone();return tT.add(n,{description:t}),n},Object.defineProperty(e,"description",{get(){return tT.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return tT.get(e);let n=e.clone();return tT.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),_T=$(`ZodUnknown`,(e,t)=>{Sw.init(e,t),gT.init(e,t)});function vT(){return nT(_T)}var yT=$(`ZodNever`,(e,t)=>{Cw.init(e,t),gT.init(e,t)});function bT(e){return rT(yT,e)}var xT=$(`ZodArray`,(e,t)=>{Tw.init(e,t),gT.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(aT(t,n)),e.nonempty=t=>e.check(aT(1,t)),e.max=(t,n)=>e.check(iT(t,n)),e.length=(t,n)=>e.check(oT(t,n)),e.unwrap=()=>e.element});function ST(e,t){return cT(xT,e,t)}var CT=$(`ZodObject`,(e,t)=>{Ow.init(e,t),gT.init(e,t),NC(e,`shape`,()=>t.shape),e.keyof=()=>AT(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:vT()}),e.loose=()=>e.clone({...e._zod.def,catchall:vT()}),e.strict=()=>e.clone({...e._zod.def,catchall:bT()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>qC(e,t),e.merge=t=>JC(e,t),e.pick=t=>GC(e,t),e.omit=t=>KC(e,t),e.partial=(...t)=>YC(PT,e,t[0]),e.required=(...t)=>XC(HT,e,t[0])}),wT=$(`ZodUnion`,(e,t)=>{Aw.init(e,t),gT.init(e,t),e.options=t.options});function TT(e,t){return new wT({type:`union`,options:e,...UC(t)})}var ET=$(`ZodIntersection`,(e,t)=>{jw.init(e,t),gT.init(e,t)});function DT(e,t){return new ET({type:`intersection`,left:e,right:t})}var OT=$(`ZodRecord`,(e,t)=>{Pw.init(e,t),gT.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType}),kT=$(`ZodEnum`,(e,t)=>{Fw.init(e,t),gT.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new kT({...t,checks:[],...UC(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new kT({...t,checks:[],...UC(r),entries:i})}});function AT(e,t){return new kT({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...UC(t)})}var jT=$(`ZodLiteral`,(e,t)=>{Iw.init(e,t),gT.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})}),MT=$(`ZodTransform`,(e,t)=>{Lw.init(e,t),gT.init(e,t),e._zod.parse=(n,r)=>{n.addIssue=r=>{if(typeof r==`string`)n.issues.push(nw(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,t.continue??=!0,n.issues.push(nw(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function NT(e){return new MT({type:`transform`,transform:e})}var PT=$(`ZodOptional`,(e,t)=>{Rw.init(e,t),gT.init(e,t),e.unwrap=()=>e._zod.def.innerType});function FT(e){return new PT({type:`optional`,innerType:e})}var IT=$(`ZodNullable`,(e,t)=>{zw.init(e,t),gT.init(e,t),e.unwrap=()=>e._zod.def.innerType});function LT(e){return new IT({type:`nullable`,innerType:e})}var RT=$(`ZodDefault`,(e,t)=>{Bw.init(e,t),gT.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function zT(e,t){return new RT({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}var BT=$(`ZodPrefault`,(e,t)=>{Hw.init(e,t),gT.init(e,t),e.unwrap=()=>e._zod.def.innerType});function VT(e,t){return new BT({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():t}})}var HT=$(`ZodNonOptional`,(e,t)=>{Uw.init(e,t),gT.init(e,t),e.unwrap=()=>e._zod.def.innerType});function UT(e,t){return new HT({type:`nonoptional`,innerType:e,...UC(t)})}var WT=$(`ZodCatch`,(e,t)=>{Gw.init(e,t),gT.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function GT(e,t){return new WT({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var KT=$(`ZodPipe`,(e,t)=>{Kw.init(e,t),gT.init(e,t),e.in=t.in,e.out=t.out});function qT(e,t){return new KT({type:`pipe`,in:e,out:t})}var JT=$(`ZodReadonly`,(e,t)=>{Jw.init(e,t),gT.init(e,t)});function YT(e){return new JT({type:`readonly`,innerType:e})}var XT=$(`ZodLazy`,(e,t)=>{Xw.init(e,t),gT.init(e,t),e.unwrap=()=>e._zod.def.getter()}),ZT=$(`ZodCustom`,(e,t)=>{Zw.init(e,t),gT.init(e,t)});function QT(e){let t=new mw({check:`custom`});return t._zod.check=e,t}function $T(e,t={}){return lT(ZT,e,t)}function eE(e){let t=QT(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(nw(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(nw(r))}},e(n.value,n)));return t}var tE=`@ag-ui/client`;function nE(e){if(!e.metadata||!Object.prototype.hasOwnProperty.call(e.metadata,tE))return;let t=e.metadata?.[tE];if(!t||typeof t!=`object`||Array.isArray(t))return[];if(!Object.prototype.hasOwnProperty.call(t,`authoritativeActivityTypes`))return;let n=t.authoritativeActivityTypes;return n===null?null:Array.isArray(n)&&n.every(e=>typeof e==`string`)?n:[]}var rE=e=>{if(typeof structuredClone==`function`)return structuredClone(e);try{return JSON.parse(JSON.stringify(e))}catch{return Array.isArray(e)?[...e]:{...e}}};function iE(){return Po()}function aE(e){return e instanceof TypeError&&/read[- ]?only|not extensible|cannot add property|cannot delete property|can't be deleted|unable to delete property|object is frozen|is not writable/i.test(e.message)}function oE(e){if(Object.freeze(e),typeof e==`object`&&e)for(let t of Object.values(e))typeof t==`object`&&t&&!Object.isFrozen(t)&&oE(t);return e}var sE=524288;function cE(e,t,n){let r=0,i=[e,t],a=new WeakSet;for(;i.length>0;){let e=i.pop();if(typeof e==`string`){if(r+=e.length,r>n)return!0}else if(typeof e==`object`&&e){if(a.has(e))continue;if(a.add(e),Array.isArray(e))for(let t=0;tn)return!0;i.push(e[o])}}}}return!1}async function lE(e,t,n,r){let i=typeof process<`u`&&!0,a=i&&!!{}.VITEST_WORKER_ID,o=i&&!!{}.VITEST_WORKER_ID,s=o&&!cE(t,n,sE),c=s?rE(t):t,l=s?rE(n):n,u=!1,d=!1,f;for(let t of e)try{s&&(oE(c),oE(l));let e=await r(t,c,l);if(e===void 0)continue;let n=!1;if(e.messages!==void 0&&e.messages!==c&&(c=rE(e.messages),u=!0,n=!0),e.state!==void 0&&e.state!==l&&(l=rE(e.state),d=!0,n=!0),s&&n&&cE(c,l,sE)&&(s=!1),f=e.stopPropagation,f===!0)break}catch(e){if(a&&e instanceof TypeError)throw e;s&&o&&aE(e)?console.error(`AG-UI: Subscriber attempted to mutate frozen inputs in-place. Return mutations via AgentStateMutation instead of mutating directly.`,e):console.error(`Subscriber error:`,e);continue}return{...u?{messages:Object.isFrozen(c)?rE(c):c}:{},...d?{state:Object.isFrozen(l)?rE(l):l}:{},...f===void 0?{}:{stopPropagation:f}}}function uE(e){if(!e)return{enabled:!1,events:!1,lifecycle:!1,verbose:!1};if(e===!0)return{enabled:!0,events:!0,lifecycle:!0,verbose:!0};let t=e.events??!0,n=e.lifecycle??!0,r=e.verbose??!1;return{enabled:t||n,events:t,lifecycle:n,verbose:r}}function dE(e){if(e instanceof fE)return e;if(e===!0)return new fE(uE(!0))}var fE=class{constructor(e){this.config=e}event(e,t,n,r){this.config.events&&(this.config.verbose?console.debug(`[${e}] ${t}`,typeof n==`string`?n:JSON.stringify(n)):console.debug(`[${e}] ${t}`,r??n))}lifecycle(e,t,n){this.config.lifecycle&&(n?console.debug(`[${e}] ${t}`,n):console.debug(`[${e}] ${t}`))}get eventsEnabled(){return this.config.events}get lifecycleEnabled(){return this.config.lifecycle}get enabled(){return this.config.enabled}};function pE(e){return e.enabled?new fE(e):void 0}function mE(e,t,n){if(t){let r=e.find(e=>e.id===t);if(r?.role===`assistant`)return r;r&&console.warn(`TOOL_CALL_START: parentMessageId '${t}' matches a '${r.role}' message, not assistant — falling back to toolCallId`);let i={id:r?n:t,role:`assistant`,toolCalls:[]};return e.push(i),i}let r={id:n,role:`assistant`,toolCalls:[]};return e.push(r),r}function hE(e,t){return!e||t.metadata===void 0?!1:(e.metadata=Bo(e.metadata,rE(t.metadata)),!0)}var gE=(e,t,n,r,i)=>{let a=dE(i),o=rE(n.messages),s=rE(e.state),c={},l=[],u=new Set,d=e=>{let t=e.outcome?.type===`success`?e.outcome.pendingToolCallIds:void 0;return t!==void 0&&t.length>0?[...t]:l.filter(e=>!u.has(e))},f=e=>{e.messages!==void 0&&(o=e.messages,c.messages=e.messages),e.state!==void 0&&(s=e.state,c.state=e.state)},p=()=>{let e=rE(c);return c={},e.messages!==void 0||e.state!==void 0?il(e):Tc};return t.pipe(hl(async t=>{let i=await lE(r,o,s,(r,i,a)=>r.onEvent?.({event:t,agent:n,input:e,messages:i,state:a}));if(f(i),i.stopPropagation===!0?a?.event(`APPLY`,`Event dropped:`,t,{type:t.type,reason:`stopPropagation by subscriber`}):a?.event(`APPLY`,`Event applied:`,t,{type:t.type,subscribers:r.length}),i.stopPropagation===!0)return p();switch(t.type){case A.TEXT_MESSAGE_START:{let i=await lE(r,o,s,(r,i,a)=>r.onTextMessageStartEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(f(i),i.stopPropagation!==!0){let{messageId:e,role:n=`assistant`,name:r,subagentRunId:i}=t,a=o.find(t=>t.id===e);if(a?.role===`activity`)return console.warn(`TEXT_MESSAGE_START: Message '${e}' is an activity message — message ids must be unique across activity and text messages`),p();let s=a;if(!s){let t={id:e,role:n,content:``,...r!==void 0&&{name:r},...i!=null&&{subagentRunId:i}};o.push(t),s=t}let c=hE(s,t);(!a||c)&&f({messages:o})}return p()}case A.TEXT_MESSAGE_CONTENT:{let{messageId:i,delta:a}=t,c=o.find(e=>e.id===i);if(!c)return console.warn(`TEXT_MESSAGE_CONTENT: No message found with ID '${i}'`),p();if(c.role===`activity`)return console.warn(`TEXT_MESSAGE_CONTENT: Message '${i}' is an activity message — message ids must be unique across activity and text messages`),p();let l=await lE(r,o,s,(r,i,a)=>r.onTextMessageContentEvent?.({event:t,messages:i,state:a,agent:n,input:e,textMessageBuffer:typeof c.content==`string`?c.content:``}));return f(l),l.stopPropagation!==!0&&(c.content=`${typeof c.content==`string`?c.content:``}${a}`,hE(c,t),f({messages:o})),p()}case A.TEXT_MESSAGE_END:{let{messageId:i}=t,a=o.find(e=>e.id===i);if(!a)return console.warn(`TEXT_MESSAGE_END: No message found with ID '${i}'`),p();if(a.role===`activity`)return console.warn(`TEXT_MESSAGE_END: Message '${i}' is an activity message — message ids must be unique across activity and text messages`),p();let c=await lE(r,o,s,(r,i,o)=>r.onTextMessageEndEvent?.({event:t,messages:i,state:o,agent:n,input:e,textMessageBuffer:typeof a.content==`string`?a.content:``}));return f(c),c.stopPropagation!==!0&&hE(a,t)&&f({messages:o}),await Promise.all(r.map(t=>{t.onNewMessage?.({message:a,messages:o,state:s,agent:n,input:e})})),p()}case A.TOOL_CALL_START:{let i=await lE(r,o,s,(r,i,a)=>r.onToolCallStartEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(f(i),i.stopPropagation!==!0){let{toolCallId:e,toolCallName:n,parentMessageId:r,subagentRunId:i}=t;l.includes(e)||l.push(e);let a=o.find(t=>t.toolCalls?.some(t=>t.id===e))?.toolCalls?.find(t=>t.id===e);if(a){let r=a.function.name!==n;return r&&(console.warn(`TOOL_CALL_START: tool call '${e}' already exists with name '${a.function.name}' — updating it to '${n}'`),a.function.name=n),(hE(a,t)||r)&&f({messages:o}),p()}let s=new Set(o.map(e=>e.id)),c=mE(o,r,e);!s.has(c.id)&&i!=null&&c.subagentRunId===void 0&&(c.subagentRunId=i),c.toolCalls??=[];let u={id:e,type:`function`,function:{name:n,arguments:``}};c.toolCalls.push(u),hE(u,t),f({messages:o})}return p()}case A.TOOL_CALL_ARGS:{let{toolCallId:i,delta:a}=t,c=o.find(e=>e.toolCalls?.some(e=>e.id===i));if(!c)return console.warn(`TOOL_CALL_ARGS: No message found containing tool call with ID '${i}'`),p();let l=c.toolCalls?.find(e=>e.id===i);if(!l)return console.warn(`TOOL_CALL_ARGS: No tool call found with ID '${i}'`),p();let u=await lE(r,o,s,(r,i,a)=>{let o=l.function.arguments,s=l.function.name,c={};try{c=wl(o)}catch{}return r.onToolCallArgsEvent?.({event:t,messages:i,state:a,agent:n,input:e,toolCallBuffer:o,toolCallName:s,partialToolCallArgs:c})});return f(u),u.stopPropagation!==!0&&(l.function.arguments+=a,hE(l,t),f({messages:o})),p()}case A.TOOL_CALL_END:{let{toolCallId:i}=t,a=o.find(e=>e.toolCalls?.some(e=>e.id===i));if(!a)return console.warn(`TOOL_CALL_END: No message found containing tool call with ID '${i}'`),p();let c=a.toolCalls?.find(e=>e.id===i);if(!c)return console.warn(`TOOL_CALL_END: No tool call found with ID '${i}'`),p();let l=await lE(r,o,s,(r,i,a)=>{let o=c.function.arguments,s=c.function.name,l={};try{l=JSON.parse(o)}catch{}return r.onToolCallEndEvent?.({event:t,messages:i,state:a,agent:n,input:e,toolCallName:s,toolCallArgs:l})});return f(l),l.stopPropagation!==!0&&hE(c,t)&&f({messages:o}),await Promise.all(r.map(t=>{t.onNewToolCall?.({toolCall:c,messages:o,state:s,agent:n,input:e})})),p()}case A.TOOL_CALL_RESULT:{let i=await lE(r,o,s,(r,i,a)=>r.onToolCallResultEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(f(i),i.stopPropagation!==!0){let{messageId:i,toolCallId:a,content:c,role:l,subagentRunId:d}=t;u.add(a);let p={id:i,toolCallId:a,role:l||`tool`,content:c,...d!=null&&{subagentRunId:d}};hE(p,t);let m=o.findIndex(e=>e.role===`assistant`&&e.toolCalls?.some(e=>e.id===a));if(m===-1)o.push(p);else{let e=m+1;for(;e{t.onNewMessage?.({message:p,messages:o,state:s,agent:n,input:e})})),f({messages:o})}return p()}case A.STATE_SNAPSHOT:{let i=await lE(r,o,s,(r,i,a)=>r.onStateSnapshotEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(f(i),i.stopPropagation!==!0){let{snapshot:e}=t;s=e,f({state:s})}return p()}case A.STATE_DELTA:{let i=await lE(r,o,s,(r,i,a)=>r.onStateDeltaEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(f(i),i.stopPropagation!==!0){let{delta:e}=t;try{s=Cs.applyPatch(s,e,!0,!1).newDocument,f({state:s})}catch(t){let n=t instanceof Error?t.message:String(t);console.warn(`Failed to apply state patch:\nCurrent state: ${JSON.stringify(s,null,2)}\nPatch operations: ${JSON.stringify(e,null,2)}\nError: ${n}`)}}return p()}case A.MESSAGES_SNAPSHOT:{let i=await lE(r,o,s,(r,i,a)=>r.onMessagesSnapshotEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(f(i),i.stopPropagation!==!0){let{messages:e}=t,n=e.map(e=>{if(e.subagentRunId!==null)return e;let t={...e};return delete t.subagentRunId,t}),r=new Map(n.map(e=>[e.id,e])),i=nE(t),a=n.some(e=>e.role===`activity`),s=n.some(e=>e.role===`reasoning`),c=e=>e.role===`activity`&&(i?!i.includes(e.activityType):i!==null&&!a)||e.role===`reasoning`&&!s;o=o.filter(e=>r.has(e.id)||c(e)).map(e=>r.get(e.id)??e);let l=new Set(o.map(e=>e.id));for(let e of n)l.has(e.id)||o.push(e);f({messages:o})}return p()}case A.ACTIVITY_SNAPSHOT:{let i=t,a=o.findIndex(e=>e.id===i.messageId),c=a>=0?o[a]:void 0,l=c?.role===`activity`?c:void 0,u=i.replace??!0,d=await lE(r,o,s,(t,r,a)=>t.onActivitySnapshotEvent?.({event:i,messages:r,state:a,agent:n,input:e,activityMessage:l,existingMessage:c}));if(f(d),d.stopPropagation!==!0){let t={id:i.messageId,role:`activity`,activityType:i.activityType,content:rE(i.content),...i.subagentRunId!=null&&{subagentRunId:i.subagentRunId}},c,d;a===-1?(o.push(t),c=t,d=t):l?(u&&(o[a]={...l,activityType:i.activityType,content:rE(i.content),subagentRunId:i.subagentRunId},i.subagentRunId??delete o[a].subagentRunId),d=o[a]):u&&(o[a]=t,c=t,d=t),hE(d,i),f({messages:o}),c&&await Promise.all(r.map(t=>t.onNewMessage?.({message:c,messages:o,state:s,agent:n,input:e})))}return p()}case A.ACTIVITY_DELTA:{let i=t,a=o.findIndex(e=>e.id===i.messageId);if(a===-1)return p();let c=o[a];if(c.role!==`activity`)return console.warn(`ACTIVITY_DELTA: Message '${i.messageId}' is not an activity message`),p();let l=c,u=await lE(r,o,s,(t,r,a)=>t.onActivityDeltaEvent?.({event:i,messages:r,state:a,agent:n,input:e,activityMessage:l}));if(f(u),u.stopPropagation!==!0)try{hE(l,i)&&f({messages:o});let e=rE(l.content??{}),t=Cs.applyPatch(e,i.patch??[],!0,!1).newDocument;o[a]={...l,content:rE(t),activityType:i.activityType},f({messages:o})}catch(e){let t=e instanceof Error?e.message:String(e);console.warn(`Failed to apply activity patch for '${i.messageId}': ${t}`)}return p()}case A.RAW:return f(await lE(r,o,s,(r,i,a)=>r.onRawEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),p();case A.CUSTOM:return f(await lE(r,o,s,(r,i,a)=>r.onCustomEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),p();case A.RUN_STARTED:{let i=await lE(r,o,s,(r,i,a)=>r.onRunStartedEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(f(i),l=[],u=new Set,i.stopPropagation!==!0){let e=t;if(e.input?.messages){for(let t of e.input.messages){let e=t;if(t.subagentRunId===null){let n={...t};delete n.subagentRunId,e=n}o.find(t=>t.id===e.id)||o.push(e)}f({messages:o})}}return p()}case A.RUN_FINISHED:{let i=t,a=i.outcome?.type===`interrupt`?{event:i,outcome:`interrupt`,interrupts:i.outcome.interrupts}:i.outcome?.type===`cancelled`?{event:i,outcome:`cancelled`}:{event:i,outcome:`success`,result:i.result,pendingToolCallIds:d(i)},c=await lE(r,o,s,(t,r,i)=>t.onRunFinishedEvent?.({...a,messages:r,state:i,agent:n,input:e}));return f(c),c.stopPropagation!==!0&&(n.pendingInterrupts=a.outcome===`interrupt`?a.interrupts.map(e=>{if(e.subagentRunId!==null)return e;let t={...e};return delete t.subagentRunId,t}):[]),p()}case A.RUN_ERROR:return f(await lE(r,o,s,(r,i,a)=>r.onRunErrorEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),p();case A.STEP_STARTED:return f(await lE(r,o,s,(r,i,a)=>r.onStepStartedEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),p();case A.STEP_FINISHED:return f(await lE(r,o,s,(r,i,a)=>r.onStepFinishedEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),p();case A.TEXT_MESSAGE_CHUNK:throw Error(`TEXT_MESSAGE_CHUNK must be transformed before being applied`);case A.TOOL_CALL_CHUNK:throw Error(`TOOL_CALL_CHUNK must be transformed before being applied`);case A.REASONING_START:return f(await lE(r,o,s,(r,i,a)=>r.onReasoningStartEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),p();case A.REASONING_MESSAGE_START:{let i=await lE(r,o,s,(r,i,a)=>r.onReasoningMessageStartEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(f(i),i.stopPropagation!==!0){let{messageId:e,subagentRunId:n}=t,r=o.find(t=>t.id===e);if(r?.role===`activity`)return console.warn(`REASONING_MESSAGE_START: Message '${e}' is an activity message — message ids must be unique across activity and reasoning messages`),p();let i=r;if(!i){let t={id:e,role:`reasoning`,content:``,...n!=null&&{subagentRunId:n}};o.push(t),i=t}let a=hE(i,t);(!r||a)&&f({messages:o})}return p()}case A.REASONING_MESSAGE_CONTENT:{let{messageId:i,delta:a}=t,c=o.find(e=>e.id===i);if(!c)return console.warn(`REASONING_MESSAGE_CONTENT: No message found with ID '${i}'`),p();if(c.role===`activity`)return console.warn(`REASONING_MESSAGE_CONTENT: Message '${i}' is an activity message — message ids must be unique across activity and reasoning messages`),p();let l=await lE(r,o,s,(r,i,a)=>r.onReasoningMessageContentEvent?.({event:t,messages:i,state:a,agent:n,input:e,reasoningMessageBuffer:typeof c.content==`string`?c.content:``}));return f(l),l.stopPropagation!==!0&&(c.content=`${typeof c.content==`string`?c.content:``}${a}`,hE(c,t),f({messages:o})),p()}case A.REASONING_MESSAGE_END:{let{messageId:i}=t,a=o.find(e=>e.id===i);if(!a)return console.warn(`REASONING_MESSAGE_END: No message found with ID '${i}'`),p();if(a.role===`activity`)return console.warn(`REASONING_MESSAGE_END: Message '${i}' is an activity message — message ids must be unique across activity and reasoning messages`),p();let c=await lE(r,o,s,(r,i,o)=>r.onReasoningMessageEndEvent?.({event:t,messages:i,state:o,agent:n,input:e,reasoningMessageBuffer:typeof a.content==`string`?a.content:``}));return f(c),c.stopPropagation!==!0&&hE(a,t)&&f({messages:o}),await Promise.all(r.map(t=>{t.onNewMessage?.({message:a,messages:o,state:s,agent:n,input:e})})),p()}case A.REASONING_MESSAGE_CHUNK:throw Error(`REASONING_MESSAGE_CHUNK must be transformed before being applied`);case A.REASONING_END:return f(await lE(r,o,s,(r,i,a)=>r.onReasoningEndEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),p();case A.REASONING_ENCRYPTED_VALUE:{let{subtype:i,entityId:a,encryptedValue:l}=t,u=await lE(r,o,s,(r,i,a)=>r.onReasoningEncryptedValueEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(f(u),u.stopPropagation!==!0){let e=!1;if(i===`tool-call`){for(let t of o)if(t.role===`assistant`&&t.toolCalls){let n=t.toolCalls.find(e=>e.id===a);if(n){n.encryptedValue=l,e=!0;break}}}else{let t=o.find(e=>e.id===a);t?.role!==`activity`&&t&&(t.encryptedValue=l,e=!0)}e&&(c.messages=o)}return p()}case A.SUBAGENT_STARTED:return f(await lE(r,o,s,(r,i,a)=>r.onSubagentStartedEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),p();case A.SUBAGENT_FINISHED:return f(await lE(r,o,s,(r,i,a)=>r.onSubagentFinishedEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),p();case A.SUBAGENT_ERROR:return f(await lE(r,o,s,(r,i,a)=>r.onSubagentErrorEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),p()}return t.type,p()}),ul(),r.length>0?vl({}):e=>e)};function _E(e,t){typeof process<`u`&&{}.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(`[ag-ui][compat] Converting deprecated ${e} to ${t}. The old shape leaves the protocol after its shim window — see the repo-root DEPRECATIONS.md. Set SUPPRESS_TRANSFORMATION_WARNINGS=true to silence.`)}var vE=e=>t=>{let n=dE(e),r=new Set,i=new Set,a=new Set,o=new Set,s={message:new Map,toolCall:new Map,activity:new Map,reasoning:new Map},c=!1,l=!1,u=!1,d=new Map,f=e=>{let t=d.get(e);return t||(t=new Map,d.set(e,t)),t},p=()=>{for(let e of d.values())if(e.size>0)return!0;return!1},m=new Map,h=new Set,g=!1,_=!1,v=()=>{_=!1,r.clear(),i.clear(),a.clear(),o.clear(),s.message.clear(),s.toolCall.clear(),s.activity.clear(),s.reasoning.clear(),d.clear(),m.clear(),h.clear(),c=!1,l=!1,g=!0},y=(e,t)=>{let n=e??[];if(Array.isArray(n))for(let e of n){if(!e||typeof e.id!=`string`)continue;if(e.subagentRunId===null)return new j(`Cannot send a message (id '${e.id}') with 'subagentRunId: null'. The field is optional — omit it entirely.`);let n=e.role===`reasoning`?s.reasoning:e.role===`activity`?s.activity:s.message;(t||!n.has(e.id))&&n.set(e.id,{subagentRunId:e.subagentRunId});for(let n of e.toolCalls??[])n&&typeof n.id==`string`&&(t||!s.toolCall.has(n.id))&&s.toolCall.set(n.id,{subagentRunId:e.subagentRunId??void 0})}},b=(e,t,n,r,i)=>{if(t!==void 0&&n&&n.subagentRunId!==t)return new j(`Cannot send '${e}': subagentRunId '${t}' does not match the ${r} '${i}' opener's subagent '${n.subagentRunId??`(the parent agent)`}'.`)};return t.pipe(ll(e=>{let t=e.type;if(n?.event(`VERIFY`,`Event:`,e,{type:e.type}),l&&t!==A.RUN_STARTED)return N(()=>new j(`Cannot send event type '${t}': The run has already errored with 'RUN_ERROR'. No further events can be sent.`));if(c&&t!==A.RUN_ERROR&&t!==A.RUN_STARTED)return N(()=>new j(`Cannot send event type '${t}': The run has already finished with 'RUN_FINISHED'. Start a new run with 'RUN_STARTED'.`));if(!u){if(u=!0,t!==A.RUN_STARTED&&t!==A.RUN_ERROR)return N(()=>new j(`First event must be 'RUN_STARTED'`))}else if(t===A.RUN_STARTED){if(g&&!c&&!l)return N(()=>new j(`Cannot send 'RUN_STARTED' while a run is still active. The previous run must be finished with 'RUN_FINISHED' before starting a new run.`));(c||l)&&v()}if(e.subagentRunId===null){_||(_=!0,_E(`subagentRunId: null`,`an absent field`));let{subagentRunId:t,...n}=e;e=n}if(t===A.SUBAGENT_STARTED||t===A.SUBAGENT_FINISHED||t===A.SUBAGENT_ERROR){let n=t===A.SUBAGENT_STARTED?[`description`,`parentSubagentRunId`,`parentToolCallId`,`parentMessageId`]:t===A.SUBAGENT_FINISHED?[`outcome`]:[`code`];for(let r of n)if(e[r]===null)return N(()=>new j(`Cannot send '${t}' with '${r}: null'. The field is optional — omit it entirely.`));let r=e.outcome;if(r!=null&&r.type!==`success`&&r.type!==`suspended`)return N(()=>new j(`Cannot send '${t}' with outcome type '${String(r.type)}'. The outcome is either { type: "success" } or { type: "suspended" }.`));if(r&&r.interruptIds===null)return N(()=>new j(`Cannot send '${t}' with 'outcome.interruptIds: null'. The field is optional — omit it entirely.`));if(r&&Array.isArray(r.interruptIds)&&r.interruptIds.some(e=>typeof e!=`string`))return N(()=>new j(`Cannot send '${t}' with a non-string entry in 'outcome.interruptIds'. Interrupt ids are strings.`))}if(t===A.RUN_FINISHED){let t=e.outcome;if(t?.type===`interrupt`&&Array.isArray(t.interrupts)){for(let e of t.interrupts)if(e&&e.subagentRunId===null)return N(()=>new j(`Cannot send 'RUN_FINISHED' with an interrupt (id '${e.id}') carrying 'subagentRunId: null'. The field is optional — omit it entirely.`))}}switch(t){case A.TEXT_MESSAGE_START:{let n=e.messageId;if(r.has(n))return N(()=>new j(`Cannot send 'TEXT_MESSAGE_START' event: A text message with ID '${n}' is already in progress. Complete it with 'TEXT_MESSAGE_END' first.`));let i=s.message.get(n);if(i){let r=b(t,e.subagentRunId,i,`message`,n);if(r)return N(()=>r)}return r.add(n),i||s.message.set(n,{subagentRunId:e.subagentRunId}),il(e)}case A.TEXT_MESSAGE_CONTENT:{let n=e.messageId;if(!r.has(n))return N(()=>new j(`Cannot send 'TEXT_MESSAGE_CONTENT' event: No active text message found with ID '${n}'. Start a text message with 'TEXT_MESSAGE_START' first.`));let i=b(t,e.subagentRunId,s.message.get(n),`message`,n);return i?N(()=>i):il(e)}case A.TEXT_MESSAGE_END:{let n=e.messageId;if(!r.has(n))return N(()=>new j(`Cannot send 'TEXT_MESSAGE_END' event: No active text message found with ID '${n}'. A 'TEXT_MESSAGE_START' event must be sent first.`));let i=b(t,e.subagentRunId,s.message.get(n),`message`,n);return i?N(()=>i):(r.delete(n),il(e))}case A.TOOL_CALL_START:{let n=e.toolCallId;if(i.has(n))return N(()=>new j(`Cannot send 'TOOL_CALL_START' event: A tool call with ID '${n}' is already in progress. Complete it with 'TOOL_CALL_END' first.`));let r=e.parentMessageId,a=e.subagentRunId,o;if(r!==void 0){let e=s.message.get(r);if(e){if(a!==void 0&&a!==e.subagentRunId)return N(()=>new j(`Cannot send 'TOOL_CALL_START': subagentRunId '${a}' does not match its parent message '${r}' owner '${e.subagentRunId??`(the parent agent)`}'. A tool call belongs to the message that carries it.`));o=e}}let c=s.toolCall.get(n);if(c){let e=b(t,a,c,`tool call`,n);if(e)return N(()=>e);if(a===void 0&&o&&o.subagentRunId!==c.subagentRunId)return N(()=>new j(`Cannot send 'TOOL_CALL_START': tool call '${n}' is owned by '${c.subagentRunId??`(the parent agent)`}' but its parent message '${r}' is owned by '${o.subagentRunId??`(the parent agent)`}'. A tool call belongs to the message that carries it.`))}return i.add(n),c||s.toolCall.set(n,a===void 0?o??{subagentRunId:void 0}:{subagentRunId:a}),il(e)}case A.TOOL_CALL_ARGS:{let n=e.toolCallId;if(!i.has(n))return N(()=>new j(`Cannot send 'TOOL_CALL_ARGS' event: No active tool call found with ID '${n}'. Start a tool call with 'TOOL_CALL_START' first.`));let r=b(t,e.subagentRunId,s.toolCall.get(n),`tool call`,n);return r?N(()=>r):il(e)}case A.TOOL_CALL_END:{let n=e.toolCallId;if(!i.has(n))return N(()=>new j(`Cannot send 'TOOL_CALL_END' event: No active tool call found with ID '${n}'. A 'TOOL_CALL_START' event must be sent first.`));let r=b(t,e.subagentRunId,s.toolCall.get(n),`tool call`,n);return r?N(()=>r):(i.delete(n),il(e))}case A.STEP_STARTED:{let t=e.stepName,n=e.subagentRunId;return f(n).has(t)?N(()=>new j(`Step "${t}" is already active for 'STEP_STARTED'${n===void 0?``:` in subagent '${n}'`}`)):(f(n).set(t,!0),il(e))}case A.STEP_FINISHED:{let t=e.stepName,n=e.subagentRunId;if(!f(n).has(t)){let e,r=!1;for(let[i,a]of d)if(i!==n&&a.has(t)){e=i,r=!0;break}return N(r?()=>new j(`Cannot send 'STEP_FINISHED' for step "${t}" attributed to ${n===void 0?`the parent agent`:`subagent '${n}'`}: that step is open under ${e===void 0?`the parent agent`:`subagent '${e}'`}. A step must be finished by whoever started it.`):()=>new j(`Cannot send 'STEP_FINISHED' for step "${t}" that was not started`))}return f(n).delete(t),il(e)}case A.ACTIVITY_SNAPSHOT:{let t=e.messageId;return(!s.activity.has(t)||e.replace!==!1)&&s.activity.set(t,{subagentRunId:e.subagentRunId}),il(e)}case A.TOOL_CALL_RESULT:{let t=e.messageId;return typeof t==`string`&&s.message.set(t,{subagentRunId:e.subagentRunId}),il(e)}case A.REASONING_START:case A.REASONING_MESSAGE_START:{let n=e.messageId,r=t===A.REASONING_START,i=r?a:o;if(i.has(n))return N(()=>new j(r?`Cannot send 'REASONING_START' event: A reasoning span with ID '${n}' is already in progress. Complete it with 'REASONING_END' first.`:`Cannot send 'REASONING_MESSAGE_START' event: A reasoning message with ID '${n}' is already in progress. Complete it with 'REASONING_MESSAGE_END' first.`));let c=s.reasoning.get(n);if(c){let r=b(t,e.subagentRunId,c,`reasoning message`,n);if(r)return N(()=>r)}return i.add(n),c||s.reasoning.set(n,{subagentRunId:e.subagentRunId}),il(e)}case A.REASONING_MESSAGE_CONTENT:case A.REASONING_MESSAGE_END:case A.REASONING_END:{let n=e.messageId,r=t===A.REASONING_END,i=r?a:o;if(!i.has(n))return N(()=>new j(r?`Cannot send 'REASONING_END' event: No active reasoning span found with ID '${n}'. A 'REASONING_START' event must be sent first.`:`Cannot send '${t}' event: No active reasoning message found with ID '${n}'. Start a reasoning message with 'REASONING_MESSAGE_START' first.`));let c=b(t,e.subagentRunId,s.reasoning.get(n),`reasoning message`,n);return c?N(()=>c):((t===A.REASONING_END||t===A.REASONING_MESSAGE_END)&&i.delete(n),il(e))}case A.REASONING_ENCRYPTED_VALUE:{let n=e.entityId,r=e.subtype,i=r===`tool-call`?s.toolCall.get(n):r===`message`?s.message.get(n)??s.reasoning.get(n):s.reasoning.get(n),a=r===`tool-call`?`tool call`:r===`message`?`message`:`reasoning message`,o=b(t,e.subagentRunId,i,a,n);return o?N(()=>o):il(e)}case A.ACTIVITY_DELTA:{let n=e.messageId,r=b(t,e.subagentRunId,s.activity.get(n),`activity`,n);return r?N(()=>r):il(e)}case A.SUBAGENT_STARTED:{if(typeof e.subagentRunId!=`string`)return N(()=>new j(`Cannot send 'SUBAGENT_STARTED' without a 'subagentRunId'.`));if(typeof e.name!=`string`)return N(()=>new j(`Cannot send 'SUBAGENT_STARTED' without a 'name'.`));let t=e.subagentRunId,n=e.parentSubagentRunId;return m.has(t)?N(()=>new j(`Cannot send 'SUBAGENT_STARTED': subagent '${t}' is already active. Finish it with 'SUBAGENT_FINISHED' first.`)):h.has(t)?N(()=>new j(`Cannot send 'SUBAGENT_STARTED': subagent '${t}' has already finished in this run. Subagent IDs are per-invocation and cannot be reused.`)):n!==void 0&&!m.has(n)&&!h.has(n)?N(()=>new j(`Cannot send 'SUBAGENT_STARTED': parentSubagentRunId '${n}' has not been started in this run.`)):(m.set(t,!0),il(e))}case A.SUBAGENT_FINISHED:case A.SUBAGENT_ERROR:{if(typeof e.subagentRunId!=`string`)return N(()=>new j(`Cannot send '${t}' without a 'subagentRunId'.`));if(t===A.SUBAGENT_ERROR&&typeof e.message!=`string`)return N(()=>new j(`Cannot send 'SUBAGENT_ERROR' without a 'message'.`));let n=e.subagentRunId;return m.has(n)?(m.delete(n),h.add(n),il(e)):N(()=>new j(`Cannot send '${t}': no active subagent found with ID '${n}'. A 'SUBAGENT_STARTED' event must be sent first.`))}case A.MESSAGES_SNAPSHOT:{let t=y(e.messages,!0);if(t)return N(()=>t)}return il(e);case A.RUN_STARTED:g=!0;{let t=y((e.input??{}).messages,!1);if(t)return N(()=>t)}return il(e);case A.RUN_FINISHED:if(p()){let e=[];for(let[t,n]of d)for(let r of n.keys())e.push(t===void 0?r:`${r} (subagent '${t}')`);let t=e.join(`, `);return N(()=>new j(`Cannot send 'RUN_FINISHED' while steps are still active: ${t}`))}if(r.size>0){let e=Array.from(r.keys()).join(`, `);return N(()=>new j(`Cannot send 'RUN_FINISHED' while text messages are still active: ${e}`))}if(o.size>0){let e=Array.from(o.keys()).join(`, `);return N(()=>new j(`Cannot send 'RUN_FINISHED' while reasoning messages are still active: ${e}`))}if(a.size>0){let e=Array.from(a.keys()).join(`, `);return N(()=>new j(`Cannot send 'RUN_FINISHED' while reasoning spans are still active: ${e}`))}if(i.size>0){let e=Array.from(i.keys()).join(`, `);return N(()=>new j(`Cannot send 'RUN_FINISHED' while tool calls are still active: ${e}`))}if(m.size>0){let e=Array.from(m.keys()).join(`, `);return N(()=>new j(`Cannot send 'RUN_FINISHED' while subagents are still active: ${e}`))}return c=!0,il(e);case A.RUN_ERROR:return l=!0,il(e);case A.CUSTOM:return il(e);default:return il(e)}}))},yE=function(e){return e.HEADERS=`headers`,e.DATA=`data`,e}({}),bE=e=>fl(()=>rl(e())).pipe(bl(e=>{if(!e.ok){let t=e.headers.get(`content-type`)||``;return rl(e.text()).pipe(ll(n=>{let r=n;if(t.includes(`application/json`))try{r=JSON.parse(n)}catch{}let i=Error(`HTTP ${e.status}: ${typeof r==`string`?r:JSON.stringify(r)}`);return i.status=e.status,i.payload=r,N(()=>i)}))}let t={type:yE.HEADERS,status:e.status,headers:e.headers},n=e.body?.getReader();return n?new fc(e=>{let r=!1;return e.next(t),(async()=>{try{for(;!e.closed;){let{done:t,value:i}=await n.read();if(t){r=!0;break}let a={type:yE.DATA,data:i};e.next(a)}e.complete()}catch(t){r=!0,e.error(t)}})(),()=>{r||n.cancel().catch(e=>{e?.name!==`AbortError`&&console.warn(`Failed to cancel HTTP response stream:`,e)})}}):N(()=>Error(`Failed to getReader() from response`))})),xE=10485760,SE=(e,t)=>{let n=dE(t),r=new xc,i=new TextDecoder(`utf-8`,{fatal:!1}),a=``;e.subscribe({next:e=>{if(e.type!==yE.HEADERS&&e.type===yE.DATA&&e.data){let t=i.decode(e.data,{stream:!0});a+=t;let n=a.split(/\n\n/);a=n.pop()||``;for(let e of n)o(e);if(a.length>xE){r.error(Error(`SSE buffer size exceeded maximum limit of ${xE/1048576} MB`));return}}},error:e=>r.error(e),complete:()=>{a&&(a+=i.decode(),o(a)),r.complete()}});function o(e){let t=e.split(` `),i=[];for(let e of t)e.startsWith(`data:`)&&i.push(e.slice(5).replace(/^ /,``));if(i.length>0)try{let e=i.join(` `),t=JSON.parse(e);n?.event(`SSE`,`Event received:`,t,{type:t?.type}),r.next(t)}catch(e){r.error(e)}}return r.asObservable()},CE=10485760,wE=()=>typeof process<`u`&&!!{}.SUPPRESS_TRANSFORMATION_WARNINGS,TE=(e,t)=>{let n=dE(t),r=new xc,i=new Uint8Array,a=!1;e.subscribe({next:e=>{if(e.type!==yE.HEADERS&&e.type===yE.DATA&&e.data){let t=new Uint8Array(i.length+e.data.length);t.set(i,0),t.set(e.data,i.length),i=t,o()}},error:e=>r.error(e),complete:()=>{if(o(),!a){if(i.length>0){r.error(Error(`The binary stream ended mid-frame: ${i.length} trailing bytes could not be read as a complete message.`));return}r.complete()}}});function o(){if(!a)for(;i.length>=4;){let e=4+new DataView(i.buffer,i.byteOffset,4).getUint32(0,!1);if(e>CE){r.error(Error(`Protobuf message size exceeded maximum limit of ${CE/1048576} MB`));return}if(i.length{let n=dE(t),r=new xc,i=new wc(1),a=!1,o,s=!1,c=()=>{s=!0,o?.unsubscribe()},l=e=>{c(),r.error(e)},u=()=>{c(),r.complete()};return o=e.subscribe({next:e=>{if(i.next(e),e.type===yE.HEADERS&&!a){a=!0;let t=e.headers.get(`content-type`);n?.lifecycle(`HTTP`,`Stream format detected:`,{contentType:t,parser:t===`application/vnd.ag-ui.event+proto`?`protobuf`:`sse`}),t===`application/vnd.ag-ui.event+proto`?TE(i,n).subscribe({next:e=>r.next(e),error:e=>l(e),complete:()=>u()}):SE(i,n).subscribe({next:e=>{if(typeof e!=`object`||!e||Array.isArray(e)){let t=Error(`Invalid event: the frame is not a JSON object.`);n?.event(`HTTP`,`Event invalid:`,{json:e,error:String(t)}),l(t);return}let t=e;if(typeof t.type!=`string`||t.type.length===0){let t=Error(`Invalid event: the frame carries no event type.`);n?.event(`HTTP`,`Event invalid:`,{json:e,error:String(t)}),l(t);return}n?.event(`HTTP`,`Event received:`,e,{type:t.type}),r.next(e)},error:e=>{if(e?.name===`AbortError`){r.next({type:A.RUN_ERROR,message:e.message||`Request aborted`,code:`abort`,rawEvent:e}),u();return}return l(e)},complete:()=>u()})}else a||l(Error(`No headers event received before data events`))},error:e=>{i.error(e),l(e)},complete:()=>{i.complete()}}),s&&o.unsubscribe(),r.asObservable()},DE={TextMessageStart:`TextMessageStart`,TextMessageContent:`TextMessageContent`,TextMessageEnd:`TextMessageEnd`,ActionExecutionStart:`ActionExecutionStart`,ActionExecutionArgs:`ActionExecutionArgs`,ActionExecutionEnd:`ActionExecutionEnd`,ActionExecutionResult:`ActionExecutionResult`,AgentStateMessage:`AgentStateMessage`,MetaEvent:`MetaEvent`,RunStarted:`RunStarted`,RunFinished:`RunFinished`,RunError:`RunError`,NodeStarted:`NodeStarted`,NodeFinished:`NodeFinished`},OE=e=>{if(typeof e==`string`)return e;if(!Array.isArray(e))return;let t=e.filter(e=>e.type===`text`).map(e=>e.text).filter(e=>e.length>0);if(t.length!==0)return t.join(` -`)};function kE(e,t){return Ho(t)&&AE(`[ag-ui][legacy] The result of tool call '${e}' carries content parts the legacy protocol cannot represent; only its text parts are bridged and the rest is dropped.`),Vo(t)}var AE=e=>{typeof process<`u`&&{}.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(e)},jE=(e,t,n)=>r=>{let i={},a=!0,o=!0,s=``,c=null,l=null,u=[],d={},f=!1,p=e=>{typeof e==`object`&&e&&(`messages`in e&&delete e.messages,i=e)};return r.pipe(ll(r=>{switch(r.type){case A.TEXT_MESSAGE_START:{let e=r;return[{type:DE.TextMessageStart,messageId:e.messageId,role:e.role}]}case A.TEXT_MESSAGE_CONTENT:{let e=r;return[{type:DE.TextMessageContent,messageId:e.messageId,content:e.delta}]}case A.TEXT_MESSAGE_END:{let e=r;return[{type:DE.TextMessageEnd,messageId:e.messageId}]}case A.TOOL_CALL_START:{let e=r;return u.push({id:e.toolCallId,type:`function`,function:{name:e.toolCallName,arguments:``}}),o=!0,d[e.toolCallId]=e.toolCallName,[{type:DE.ActionExecutionStart,actionExecutionId:e.toolCallId,actionName:e.toolCallName,parentMessageId:e.parentMessageId}]}case A.TOOL_CALL_ARGS:{let c=r,d=u.find(e=>e.id===c.toolCallId);if(!d)return AE(`[ag-ui][legacy] TOOL_CALL_ARGS: No tool call found with ID '${c.toolCallId}'`),[];d.function.arguments+=c.delta;let f=!1;if(l){let e=l.find(e=>e.tool==d.function.name);if(e)try{let t=JSON.parse(wl(d.function.arguments));e.tool_argument&&e.tool_argument in t?(p({...i,[e.state_key]:t[e.tool_argument]}),f=!0):e.tool_argument||(p({...i,[e.state_key]:t}),f=!0)}catch{}}return[{type:DE.ActionExecutionArgs,actionExecutionId:c.toolCallId,args:c.delta},...f?[{type:DE.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:o}]:[]]}case A.TOOL_CALL_END:{let e=r;return[{type:DE.ActionExecutionEnd,actionExecutionId:e.toolCallId}]}case A.TOOL_CALL_RESULT:{let e=r,t=d[e.toolCallId];return(t===void 0||t===``)&&AE(`[ag-ui][legacy] No usable tool name was seen for tool call '${e.toolCallId}' (${t===void 0?`no TOOL_CALL_START reached this bridge`:`its TOOL_CALL_START carried an empty toolCallName`}), so its result is being bridged with the fabricated action name "unknown". Downstream consumers route on that name.`),[{type:DE.ActionExecutionResult,actionExecutionId:e.toolCallId,result:kE(e.toolCallId,e.content),actionName:t||`unknown`}]}case A.RAW:return f||(f=!0,AE(`[ag-ui][legacy] Dropping RAW events: the legacy runtime protocol has no equivalent, so the provider payloads they carry do not reach the legacy stream. Reported once per stream.`)),[];case A.CUSTOM:{let e=r;switch(e.name){case`Exit`:a=!1;break;case`PredictState`:l=e.value}return[{type:DE.MetaEvent,name:e.name,value:e.value}]}case A.STATE_SNAPSHOT:return p(r.snapshot),[{type:DE.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:o}];case A.STATE_DELTA:{let c=r,l;try{l=Cs.applyPatch(i,c.delta,!0,!1).newDocument}catch(e){let t=e instanceof Error?e.message:String(e);return AE(`[ag-ui][legacy] Failed to apply state patch:\nCurrent state: ${JSON.stringify(i,null,2)}\nPatch operations: ${JSON.stringify(c.delta,null,2)}\nError: ${t}`),[]}return p(l),[{type:DE.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:o}]}case A.MESSAGES_SNAPSHOT:return c=r.messages,[{type:DE.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify({...i,...c?{messages:c}:{}}),active:!0}];case A.RUN_STARTED:return[];case A.RUN_FINISHED:{if(c&&(i.messages=c),Object.keys(i).length===0)return[];let r=null;if(c)try{r=ME(c)}catch(e){return[{type:DE.RunError,message:e.message}]}return[{type:DE.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify({...i,...r?{messages:r}:{}}),active:!1}]}case A.RUN_ERROR:{let e=r;return[{type:DE.RunError,message:e.message,code:e.code}]}case A.STEP_STARTED:return s=r.stepName,u=[],l=null,[{type:DE.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:!0}];case A.STEP_FINISHED:return u=[],l=null,[{type:DE.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:!1}];default:return[]}}))};function ME(e){let t=[];for(let n of e)if(n.role===`assistant`||n.role===`user`||n.role===`system`){let e=OE(n.content);if(e){let r={id:n.id,role:n.role,content:e};t.push(r)}if(n.role===`assistant`&&n.toolCalls&&n.toolCalls.length>0)for(let e of n.toolCalls){let r;try{r=JSON.parse(e.function.arguments)}catch(t){throw Error(`Failed to parse arguments for tool call '${e.id}' (${e.function.name}): ${t.message}`)}let i={id:e.id,name:e.function.name,arguments:r,parentMessageId:n.id};t.push(i)}}else if(n.role===`tool`){let r=`unknown`;for(let t of e)if(t.role===`assistant`&&t.toolCalls?.length){for(let e of t.toolCalls)if(e.id===n.toolCallId){r=e.function.name;break}}let i={id:n.id,result:kE(n.toolCallId,n.content),actionExecutionId:n.toolCallId,actionName:r};t.push(i)}return t}var NE=e=>e.kind===`tool`?e.fields.toolCallId:e.fields.messageId,PE=e=>e===`tool`?`toolCallId`:`messageId`,FE=(e,t,n,r,i)=>{if(r!==void 0&&r!==i)throw Error(`Cannot continue ${e} '${t}': chunk ${n} '${r}' does not match the open stream's ${n} ${i===void 0?`(absent)`:`'${i}'`}.`)},IE=(e,t)=>t.metadata===void 0?e:{...e,metadata:t.metadata},LE=(e,t)=>{let n=IE(e,t);return t.rawEvent===void 0?n:{...n,rawEvent:t.rawEvent}},RE=e=>new Set(Object.keys(e.shape)),zE=RE($v),BE=RE(ry),VE=RE(By),HE=(e,t)=>{let n;for(let r of Object.keys(e))t.has(r)||((n??={})[r]=e[r]);return n},UE=e=>{typeof process<`u`&&{}.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(`[ag-ui][transform] ${e} Set SUPPRESS_TRANSFORMATION_WARNINGS=true to silence.`)},WE=(e,t,n,r)=>{if(t===void 0||n||e.length===0)return;let i=e[e.length-1],a=Object.keys(t).filter(e=>Object.prototype.hasOwnProperty.call(i,e));a.length>0&&UE(`A ${r} carried ${a.map(e=>`'${e}'`).join(`, `)}, which the synthesized ${String(i.type)} already describes. The synthesized value is kept and the chunk's is dropped — this stage does not judge a described field, so the producer's value cannot be substituted for its own.`),e[e.length-1]={...t,...i}},GE=e=>t=>{let n=dE(e),r=new Map,i=e=>{let t=r.get(e);if(!t)return[];switch(r.delete(e),t.kind){case`text`:{let e={type:A.TEXT_MESSAGE_END,messageId:t.fields.messageId,...t.fields.subagentRunId!==void 0&&{subagentRunId:t.fields.subagentRunId}};return n?.event(`TRANSFORM`,`TEXT_MESSAGE_END`,e,{messageId:e.messageId}),[e]}case`tool`:{let e={type:A.TOOL_CALL_END,toolCallId:t.fields.toolCallId,...t.fields.subagentRunId!==void 0&&{subagentRunId:t.fields.subagentRunId}};return n?.event(`TRANSFORM`,`TOOL_CALL_END`,e,{toolCallId:e.toolCallId}),[e]}case`reasoning`:{let e={type:A.REASONING_MESSAGE_END,messageId:t.fields.messageId,...t.fields.subagentRunId!==void 0&&{subagentRunId:t.fields.subagentRunId}};return n?.event(`TRANSFORM`,`REASONING_MESSAGE_END`,e,{messageId:e.messageId}),[e]}}},a=()=>[...r.keys()].flatMap(e=>i(e)),o=(e,t)=>{for(let[n,i]of r)if(i.kind===e&&NE(i)===t)return{owner:n}},s=(e,t,n,i,a)=>{if(t!==void 0){let r=o(e,t);if(r){if(n!==void 0&&n!==r.owner)throw Error(`Cannot continue ${a} '${t}': chunk subagentRunId '${n}' does not match the open stream's subagent '${r.owner??`(the parent agent)`}'.`);return r.owner}return n}if(n!==void 0)return n;if(r.get(void 0)?.kind===e)return;let s=[...r.entries()].filter(([,t])=>t.kind===e);if(s.length===1)return s[0][0];if(s.length>1)throw Error(`Ambiguous ${i}: it carries neither a ${PE(e)} nor a subagentRunId, but ${s.length} lanes have an open ${a}. Attribute the chunk to the subagent it belongs to.`)};return t.pipe(ll(e=>{switch(e.type){case A.TEXT_MESSAGE_START:case A.TEXT_MESSAGE_CONTENT:case A.TEXT_MESSAGE_END:case A.TOOL_CALL_START:case A.TOOL_CALL_ARGS:case A.TOOL_CALL_END:case A.TOOL_CALL_RESULT:case A.STATE_SNAPSHOT:case A.STATE_DELTA:case A.CUSTOM:case A.STEP_STARTED:case A.STEP_FINISHED:case A.REASONING_START:case A.REASONING_MESSAGE_START:case A.REASONING_MESSAGE_CONTENT:case A.REASONING_MESSAGE_END:case A.REASONING_END:return[...i(e.subagentRunId??void 0),e];case A.RUN_STARTED:case A.RUN_FINISHED:case A.RUN_ERROR:case A.MESSAGES_SNAPSHOT:return[...a(),e];case A.RAW:case A.ACTIVITY_SNAPSHOT:case A.ACTIVITY_DELTA:case A.REASONING_ENCRYPTED_VALUE:case A.SUBAGENT_STARTED:return[e];case A.SUBAGENT_FINISHED:case A.SUBAGENT_ERROR:{let t=e.subagentRunId;return t==null?[e]:[...i(t),e]}case A.TEXT_MESSAGE_CHUNK:{let t=e,a=HE(e,zE),o=s(`text`,t.messageId,t.subagentRunId??void 0,`TEXT_MESSAGE_CHUNK`,`text message`),c=r.get(o),l=[],u=!1,d;if(c?.kind===`text`&&(t.messageId===void 0||t.messageId===c.fields.messageId))FE(`text message`,c.fields.messageId,`role`,t.role,c.fields.role),FE(`text message`,c.fields.messageId,`name`,t.name,c.fields.name),d=c.fields;else{if(l.push(...i(o)),t.messageId===void 0)throw Error(`First TEXT_MESSAGE_CHUNK must have a messageId`);d={messageId:t.messageId,role:t.role===void 0?`assistant`:t.role,name:t.name,subagentRunId:t.subagentRunId},r.set(o,{kind:`text`,fields:d});let e=IE({type:A.TEXT_MESSAGE_START,messageId:t.messageId,role:d.role,...t.name!==void 0&&{name:t.name},...t.subagentRunId!==void 0&&{subagentRunId:t.subagentRunId}},t);l.push(e),n?.event(`TRANSFORM`,`TEXT_MESSAGE_START`,e,{messageId:t.messageId})}if(t.delta!==void 0||t.rawEvent!==void 0){let e=t.subagentRunId===void 0?d.subagentRunId:t.subagentRunId,r=LE({...a,type:A.TEXT_MESSAGE_CONTENT,messageId:d.messageId,delta:t.delta===void 0?``:t.delta,...e!==void 0&&{subagentRunId:e}},t);l.push(r),u=!0,n?.event(`TRANSFORM`,`TEXT_MESSAGE_CONTENT`,r,{messageId:d.messageId})}if(l.length===0&&(t.metadata!==void 0||t.rawEvent!==void 0||t.subagentRunId===null||a!==void 0)){let e=t.subagentRunId===void 0?d.subagentRunId:t.subagentRunId;l.push({...a,type:A.TEXT_MESSAGE_CONTENT,messageId:d.messageId,delta:``,...t.metadata!==void 0&&{metadata:t.metadata},...t.rawEvent!==void 0&&{rawEvent:t.rawEvent},...e!==void 0&&{subagentRunId:e}}),u=!0}return WE(l,a,u,`TEXT_MESSAGE_CHUNK`),l}case A.TOOL_CALL_CHUNK:{let t=e,a=HE(e,BE),o=s(`tool`,t.toolCallId,t.subagentRunId??void 0,`TOOL_CALL_CHUNK`,`tool call`),c=r.get(o),l=[],u=!1,d;if(c?.kind===`tool`&&(t.toolCallId===void 0||t.toolCallId===c.fields.toolCallId))FE(`tool call`,c.fields.toolCallId,`toolCallName`,t.toolCallName,c.fields.toolCallName),FE(`tool call`,c.fields.toolCallId,`parentMessageId`,t.parentMessageId,c.fields.parentMessageId),d=c.fields;else{if(l.push(...i(o)),t.toolCallId===void 0)throw Error(`First TOOL_CALL_CHUNK must have a toolCallId`);if(t.toolCallName===void 0)throw Error(`First TOOL_CALL_CHUNK must have a toolCallName`);d={toolCallId:t.toolCallId,toolCallName:t.toolCallName,parentMessageId:t.parentMessageId,subagentRunId:t.subagentRunId},r.set(o,{kind:`tool`,fields:d});let e=IE({type:A.TOOL_CALL_START,toolCallId:t.toolCallId,toolCallName:t.toolCallName,...t.parentMessageId!==void 0&&{parentMessageId:t.parentMessageId},...t.subagentRunId!==void 0&&{subagentRunId:t.subagentRunId}},t);l.push(e),n?.event(`TRANSFORM`,`TOOL_CALL_START`,e,{toolCallId:t.toolCallId,toolCallName:t.toolCallName})}if(t.delta!==void 0||t.rawEvent!==void 0){let e=t.subagentRunId===void 0?d.subagentRunId:t.subagentRunId,r=LE({...a,type:A.TOOL_CALL_ARGS,toolCallId:d.toolCallId,delta:t.delta===void 0?``:t.delta,...e!==void 0&&{subagentRunId:e}},t);l.push(r),u=!0,n?.event(`TRANSFORM`,`TOOL_CALL_ARGS`,r,{toolCallId:d.toolCallId})}if(l.length===0&&(t.metadata!==void 0||t.rawEvent!==void 0||t.subagentRunId===null||a!==void 0)){let e=t.subagentRunId===void 0?d.subagentRunId:t.subagentRunId;l.push({...a,type:A.TOOL_CALL_ARGS,toolCallId:d.toolCallId,delta:``,...t.metadata!==void 0&&{metadata:t.metadata},...t.rawEvent!==void 0&&{rawEvent:t.rawEvent},...e!==void 0&&{subagentRunId:e}}),u=!0}return WE(l,a,u,`TOOL_CALL_CHUNK`),l}case A.REASONING_MESSAGE_CHUNK:{let t=e,a=HE(e,VE),o=s(`reasoning`,t.messageId,t.subagentRunId??void 0,`REASONING_MESSAGE_CHUNK`,`reasoning message`),c=r.get(o),l=[],u=!1,d;if(c?.kind===`reasoning`&&(t.messageId===void 0||t.messageId===c.fields.messageId))d=c.fields;else{if(l.push(...i(o)),t.messageId===void 0)throw Error(`First REASONING_MESSAGE_CHUNK must have a messageId`);d={messageId:t.messageId,subagentRunId:t.subagentRunId},r.set(o,{kind:`reasoning`,fields:d});let e=IE({type:A.REASONING_MESSAGE_START,messageId:t.messageId,role:`reasoning`,...t.subagentRunId!==void 0&&{subagentRunId:t.subagentRunId}},t);l.push(e),n?.event(`TRANSFORM`,`REASONING_MESSAGE_START`,e,{messageId:t.messageId})}if(t.delta!==void 0||t.rawEvent!==void 0){let e=t.subagentRunId===void 0?d.subagentRunId:t.subagentRunId,r=LE({...a,type:A.REASONING_MESSAGE_CONTENT,messageId:d.messageId,delta:t.delta===void 0?``:t.delta,...e!==void 0&&{subagentRunId:e}},t);l.push(r),u=!0,n?.event(`TRANSFORM`,`REASONING_MESSAGE_CONTENT`,r,{messageId:d.messageId})}if(l.length===0&&(t.metadata!==void 0||t.rawEvent!==void 0||t.subagentRunId===null||a!==void 0)){let e=t.subagentRunId===void 0?d.subagentRunId:t.subagentRunId;l.push({...a,type:A.REASONING_MESSAGE_CONTENT,messageId:d.messageId,delta:``,...t.metadata!==void 0&&{metadata:t.metadata},...t.rawEvent!==void 0&&{rawEvent:t.rawEvent},...e!==void 0&&{subagentRunId:e}}),u=!0}return WE(l,a,u,`REASONING_MESSAGE_CHUNK`),l}}return e.type,[e]}),yl(()=>{a()}))},KE=Symbol(`agui.strip.drop`);function qE(e){let t=e;for(;;){if(t instanceof PT||t instanceof IT||t instanceof RT||t instanceof JT||t instanceof WT){t=t.unwrap();continue}if(t instanceof KT){t=t.def.in;continue}if(t instanceof XT){t=t.def.getter();continue}return t}}function JE(e){let t=e.def;return typeof t?.discriminator==`string`?t.discriminator:void 0}function YE(e){let t=e,n=Array.isArray(t.def?.values)?t.def.values:t.values?Array.from(t.values):void 0;return n&&n.length===1?n[0]:t.value}function XE(e){let t=qE(e);return t instanceof jT?YE(t):void 0}function ZE(e,t,n,r){let i=qE(t);if(i instanceof CT){if(typeof e!=`object`||!e||Array.isArray(e))return e;let t=i.shape,a=e,o={},s=i.meta()?.specOpen===!0;for(let e of Object.keys(a)){let i=Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;if(i===void 0){if(s){o[e]=a[e];continue}r.push(`${n}/${e}`);continue}let c=r.length,l=ZE(a[e],i,`${n}/${e}`,r);if(l===KE){if(r.length=c,i.safeParse(void 0).success){r.push(`${n}/${e}`);continue}return KE}o[e]=l}return o}if(i instanceof xT){if(!Array.isArray(e))return e;let t=i.element,a=[];return e.forEach((e,i)=>{let o=r.length,s=ZE(e,t,`${n}/${i}`,r);if(s===KE){r.length=o,r.push(`${n}/${i}`);return}a.push(s)}),a}if(i instanceof OT){if(typeof e!=`object`||!e||Array.isArray(e))return e;let t=i.def.valueType,a=e,o={};for(let e of Object.keys(a)){let i=r.length,s=ZE(a[e],t,`${n}/${e}`,r);if(s===KE){r.length=i,r.push(`${n}/${e}`);continue}o[e]=s}return o}if(i instanceof wT){let t=i.options,a=JE(i);if(a!==void 0){if(typeof e!=`object`||!e||Array.isArray(e))return e;let i=e[a];for(let o of t){let t=qE(o);if(!(t instanceof CT))continue;let s=t.shape;if(XE(s[a])===i)return ZE(e,o,n,r)}return KE}let o=t.filter(e=>qE(e)instanceof CT),s=typeof e==`object`&&!!e&&!Array.isArray(e);if(o.length>1&&s)return e;for(let i of t){let t=qE(i);if(t instanceof xT&&Array.isArray(e)||t instanceof CT&&s)return ZE(e,i,n,r)}return e}return e}function QE(e,t){let n=[],r=ZE(e,t,``,n);if(r===KE)throw Error(`Internal error: the stripper found the whole value unrecognisable, which the schemas are not supposed to allow — schema/stripper mismatch.`);return{value:r,stripped:n}}var $E=new Set(Object.values(A));function eD(e){return $E.has(e.type)}var tD=new Map(Ky.options.map(e=>{let t=e.shape;return[String(YE(t.type)),e]})),nD=()=>typeof process<`u`&&!!{}.SUPPRESS_TRANSFORMATION_WARNINGS;function rD(e){nD()||console.warn(`[ag-ui][enforce] ${e}`)}var iD=e=>t=>{let n=dE(e);return t.pipe(ll(e=>{if(!eD(e))return rD(`Dropping unrecognised event '${String(e.type)}': no middleware translated it and the protocol does not describe it.`),n?.event(`ENFORCE`,`Unrecognised event dropped:`,e,{type:e.type}),Tc;let t=tD.get(e.type);if(t===void 0)throw Error(`No validator for recognised event type '${String(e.type)}'`);let{value:r,stripped:i}=QE(e,t);for(let t of i)rD(`Removed unrecognised material at '${t}' on ${String(e.type)}. Nothing handled it; see the repo-root DEPRECATIONS.md if it is a retired shape.`);return il(t.parse(r))}))};function aD(e){let{value:t,stripped:n}=QE(Ro(e,`RunAgentInput`),Ey);for(let e of n)rD(`Removed unrecognised material at '${e}' from the outgoing input.`);return Ey.parse(t)}var oD=class{runNext(e,t){return t.run(e).pipe(GE(!1))}runNextWithState(e,t){let n=rE(e.messages||[]),r=rE(e.state===void 0?{}:e.state),i=new wc;return gE(e,i,t,[]).subscribe({next:e=>{e.messages!==void 0&&(n=e.messages),e.state!==void 0&&(r=e.state)},error:()=>{}}),this.runNext(e,t).pipe(hl(async e=>(i.next(e),await new Promise(e=>setTimeout(e,0)),{event:e,messages:rE(n),state:rE(r)})))}},sD=class extends oD{constructor(e){super(),this.fn=e}run(e,t){return this.fn(e,t)}};function cD(e){return e.startsWith(`image/`)?`image`:e.startsWith(`audio/`)?`audio`:e.startsWith(`video/`)?`video`:`document`}function lD(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`binary`&&`mimeType`in e&&typeof e.mimeType==`string`}function uD(e){let t=cD(e.mimeType);return e.data?{type:t,source:{type:`data`,value:e.data,mimeType:e.mimeType},...e.filename?{metadata:{filename:e.filename}}:{}}:e.url?{type:t,source:{type:`url`,value:e.url,mimeType:e.mimeType},...e.filename?{metadata:{filename:e.filename}}:{}}:((typeof process>`u`||!{}.SUPPRESS_TRANSFORMATION_WARNINGS)&&console.warn(`[ag-ui][compat] A binary content part carries only an id ('${e.id??``}') and cannot be converted to a modern media part; a 1.0 peer will not accept it. Provide data or a url. See the repo-root DEPRECATIONS.md.`),e)}function dD(e,t,n){if(typeof e!=`object`||!e||!(`type`in e)||e.type!==t.type||!(`source`in e))return!1;let r=e.source;return typeof r!=`object`||!r||!(`type`in r)||r.type!==t.source.type||!(`value`in r)||r.value!==t.source.value||!(`mimeType`in r)||r.mimeType!==t.source.mimeType?!1:!n||`metadata`in e&&typeof e.metadata==`object`&&e.metadata!==null&&`filename`in e.metadata&&e.metadata.filename===n}function fD(e){let t=e.content;if(!Array.isArray(t))return e;let n=t.flatMap(e=>{if(lD(e)){let n=uD(e);return n.type!==`binary`&&t.some(t=>dD(t,n,e.filename))?[]:[n]}return[e]});return{...e,content:n}}var pD=`THINKING_START`,mD=`THINKING_END`,hD=`THINKING_TEXT_MESSAGE_START`,gD=`THINKING_TEXT_MESSAGE_CONTENT`,_D=`THINKING_TEXT_MESSAGE_END`;function vD(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var yD={event:[`rawEvent`,`subagentRunId`],[A.RUN_STARTED]:[`parentRunId`,`input`],[A.RUN_FINISHED]:[`result`,`outcome`],[A.RUN_ERROR]:[`usage`],[A.SUBAGENT_FINISHED]:[`result`],[A.TOOL_CALL_START]:[`parentMessageId`],[A.TOOL_CALL_CHUNK]:[`parentMessageId`],[A.TOOL_CALL_RESULT]:[`role`],"RUN_FINISHED.outcome":[`pendingToolCallIds`],"RUN_FINISHED.usage[]":[`provider`,`reasoningTokens`,`cachedInputTokens`,`cacheWriteInputTokens`],RunAgentInput:[`forwardedProps`],Tool:[`parameters`],ResumeEntry:[`payload`],"input content":[`metadata`]},bD=new Map(Object.entries(yD).filter(([e])=>Object.values(A).includes(e))),xD=e=>_E(e,`an absent field`);function SD(e,t,n,r){if(!vD(e))return e;let i;for(let a of t)e[a]===null&&(r(n===void 0?`${a}: null`:`${n}.${a}: null`),i??={...e},delete i[a]);return i??e}function CD(e,t,n){if(!vD(e)||!Array.isArray(e[t]))return e;let r=e[t],i=r.map(n);return i.some((e,t)=>e!==r[t])?{...e,[t]:i}:e}function wD(e,t){return CD(e,`content`,e=>{if(!vD(e))return e;switch(e.type){case`image`:case`audio`:case`video`:case`document`:return SD(e,yD[`input content`],`${e.type} input content`,t);default:return e}})}function TD(e,t=xD){let n=SD(e,yD.RunAgentInput,`RunAgentInput`,t);return n=CD(n,`tools`,e=>SD(e,yD.Tool,`Tool`,t)),n=CD(n,`resume`,e=>SD(e,yD.ResumeEntry,`ResumeEntry`,t)),CD(n,`messages`,e=>wD(e,t))}var ED=class extends oD{constructor(...e){super(...e),this.currentReasoningId=null,this.currentMessageId=null,this.nullsNoticedThisRun=new Set,this.noticeNullOncePerRun=e=>{this.nullsNoticedThisRun.has(e)||(this.nullsNoticedThisRun.add(e),_E(e,`an absent field`))}}warn(e,t){_E(e,t)}mintedContinuationId(e,t){if(t!==null)return t;let n=iE();return this.warnAside(`Minting a messageId ('${n}') for ${e}: no THINKING opener preceded it, so there was no id to continue. The id is this client's invention, not the producer's, and verification will reject the translated event for naming something nothing opened.`),n}warnAside(e){typeof process<`u`&&{}.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(`[ag-ui][compat] ${e} Set SUPPRESS_TRANSFORMATION_WARNINGS=true to silence.`)}run(e,t){return this.currentReasoningId=null,this.currentMessageId=null,this.nullsNoticedThisRun.clear(),e.messages=e.messages.map(fD),t.run(e).pipe(sl(e=>this.transformEvent(e)))}transformEvent(e){let t=this.noticeNullOncePerRun;e.type===A.RUN_STARTED&&this.nullsNoticedThisRun.clear(),e=SD(e,yD.event,void 0,t);let n=bD.get(e.type);switch(n&&(e=SD(e,n,e.type,t)),e.type){case pD:{this.currentReasoningId=iE();let{title:t,...n}=e;return this.warn(pD,A.REASONING_START),t!==void 0&&this.warnAside(`Dropping ${pD}.title ${JSON.stringify(t)}: ${A.REASONING_START} has no title field, so the span's label cannot be carried and nothing downstream can recover it.`),{...n,type:A.REASONING_START,messageId:this.currentReasoningId}}case hD:return this.currentMessageId=iE(),this.warn(hD,A.REASONING_MESSAGE_START),{...e,type:A.REASONING_MESSAGE_START,messageId:this.currentMessageId,role:`reasoning`};case gD:{let{delta:t,...n}=e;return this.warn(gD,A.REASONING_MESSAGE_CONTENT),{...n,type:A.REASONING_MESSAGE_CONTENT,messageId:this.mintedContinuationId(gD,this.currentMessageId),delta:t}}case _D:{let t=this.mintedContinuationId(_D,this.currentMessageId);return this.currentMessageId=null,this.warn(_D,A.REASONING_MESSAGE_END),{...e,type:A.REASONING_MESSAGE_END,messageId:t}}case mD:{let t=this.mintedContinuationId(mD,this.currentReasoningId);return this.currentReasoningId=null,this.warn(mD,A.REASONING_END),{...e,type:A.REASONING_END,messageId:t}}case A.RUN_FINISHED:{let n=e,r=SD(n.outcome,yD[`RUN_FINISHED.outcome`],`RUN_FINISHED.outcome`,t);return CD(r===n.outcome?n:{...n,outcome:r},`usage`,e=>SD(e,yD[`RUN_FINISHED.usage[]`],`RUN_FINISHED.usage[]`,t))}case A.MESSAGES_SNAPSHOT:{let t=e;return Array.isArray(t.messages)?{...t,messages:t.messages.map(e=>this.upgradeInboundMessage(e))}:e}case A.RUN_STARTED:{let n=TD(e.input,t),r=n===e.input?e:{...e,input:n},i=r;return!i.input||!Array.isArray(i.input.messages)?r:{...i,input:{...i.input,messages:i.input.messages.map(e=>this.upgradeInboundMessage(e))}}}default:return e}}upgradeInboundMessage(e){e=wD(e,this.noticeNullOncePerRun);let t=e.content;return!Array.isArray(t)||!t.some(e=>typeof e==`object`&&!!e&&e.type===`binary`)?e:(this.warn(`binary input content`,`the modern media content parts`),fD(e))}},DD=()=>e=>fl(()=>{let t=new ED;return e.pipe(sl(e=>t.transformEvent(e)))});function OD(e,t=new Date){return e.expiresAt!==void 0&&new Date(e.expiresAt)<=t}function kD(){return typeof process<`u`&&!!{}.SUPPRESS_TRANSFORMATION_WARNINGS}function AD(e){kD()||console.warn(`[ag-ui][compat] Flattening message content for a <=0.0.39 peer DROPS non-text parts (${e.join(`, `)}). The peer cannot receive them; upgrade it to keep media content. See the repo-root DEPRECATIONS.md.`)}function jD(e){kD()||console.warn(`[ag-ui][compat] Not flattening message content for a <=0.0.39 peer: ${e} content part(s) claim type "text" but carry a malformed 'text' value. That is a defect in the message, not media the peer cannot represent, and a downgrade must not repair it — the content is passed on unchanged so the outgoing enforcement boundary reports it. See the repo-root DEPRECATIONS.md.`)}function MD(e){let t=e.content;if(Array.isArray(t)){let n=e=>typeof e==`object`&&!!e&&`type`in e&&e.type===`text`,r=e=>n(e)&&typeof e.text==`string`,i=t.filter(e=>n(e)&&!r(e));if(i.length>0)return jD(i.length),e;let a=t.filter(e=>!r(e)).map(e=>typeof e==`object`&&e&&`type`in e?String(e.type):typeof e);a.length>0&&AD(a);let o=t.filter(r).map(e=>e.text).join(``);return{...e,content:o}}return typeof t==`string`?e:t===void 0?{...e,content:``}:e}var ND=class extends oD{run(e,t){let{parentRunId:n,...r}=e,i={...r,messages:r.messages.map(MD)};return this.runNext(i,t)}},PD=`THINKING_START`,FD=`THINKING_END`,ID=`THINKING_TEXT_MESSAGE_START`,LD=`THINKING_TEXT_MESSAGE_CONTENT`,RD=`THINKING_TEXT_MESSAGE_END`,zD=class extends oD{constructor(...e){super(...e),this.currentReasoningId=null,this.currentMessageId=null}warnAboutTransformation(e,t){typeof process<`u`&&{}.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(`AG-UI is converting ${e} to ${t}. To remove this warning, upgrade your AG-UI integration package (e.g. @ag-ui/langgraph). To surpress it, set SUPPRESS_TRANSFORMATION_WARNINGS=true in your .env file.`)}run(e,t){return this.currentReasoningId=null,this.currentMessageId=null,this.runNext(e,t).pipe(sl(e=>this.transformEvent(e)))}transformEvent(e){switch(e.type){case PD:{this.currentReasoningId=iE();let{title:t,...n}=e;return this.warnAboutTransformation(PD,A.REASONING_START),{...n,type:A.REASONING_START,messageId:this.currentReasoningId}}case ID:return this.currentMessageId=iE(),this.warnAboutTransformation(ID,A.REASONING_MESSAGE_START),{...e,type:A.REASONING_MESSAGE_START,messageId:this.currentMessageId,role:`reasoning`};case LD:{let{delta:t,...n}=e;return this.warnAboutTransformation(LD,A.REASONING_MESSAGE_CONTENT),{...n,type:A.REASONING_MESSAGE_CONTENT,messageId:this.currentMessageId??iE(),delta:t}}case RD:{let t=this.currentMessageId??iE();return this.warnAboutTransformation(RD,A.REASONING_MESSAGE_END),{...e,type:A.REASONING_MESSAGE_END,messageId:t}}case FD:{let t=this.currentReasoningId??iE();return this.warnAboutTransformation(FD,A.REASONING_END),{...e,type:A.REASONING_END,messageId:t}}default:return e}}},BD=`SUBAGENT_STARTED`,VD=`SUBAGENT_FINISHED`,HD=`SUBAGENT_ERROR`;function UD(e){if(e&&typeof e==`object`&&`subagentRunId`in e){let{subagentRunId:t,...n}=e;return n}return e}function WD(e){return e.map(e=>UD(e))}var GD=class extends oD{warnDroppedLifecycleEvent(e){typeof process<`u`&&{}.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(`AG-UI is dropping ${e} because the target agent predates subagent support. To remove this warning, upgrade your AG-UI integration package. To suppress it, set SUPPRESS_TRANSFORMATION_WARNINGS=true in your .env file.`)}run(e,t){let n={...e,messages:(e.messages??[]).map(e=>UD(e))};return this.runNext(n,t).pipe(Sl(e=>{let t=e.type;(t===BD||t===VD||t===HD)&&this.warnDroppedLifecycleEvent(t)}),pl(e=>{let t=e.type;return t!==BD&&t!==VD&&t!==HD}),sl(e=>{let t=UD(e);if(t.type===A.MESSAGES_SNAPSHOT){let e=t;if(Array.isArray(e.messages))return{...e,messages:WD(e.messages)}}if(t.type===A.RUN_FINISHED){let e=t;if(e.outcome&&Array.isArray(e.outcome.interrupts))return{...e,outcome:{...e.outcome,interrupts:e.outcome.interrupts.map(e=>UD(e))}}}if(t.type===A.RUN_STARTED){let e=t;if(e.input&&Array.isArray(e.input.messages))return{...e,input:{...e.input,messages:WD(e.input.messages)}}}return t}))}},KD=`1.0.2`,qD=!1,JD=new WeakSet,YD=(e,t)=>/^\d+\.\d+$/.test(e)?CC(e,t)>0?`newer`:`not-newer`:`uninterpretable`,XD=e=>{let t=e.protocolVersion;if(t!==void 0&&t!==`1.0`)switch(YD(t,`1.0`)){case`uninterpretable`:console.warn(`[ag-ui] The producer declared protocol version '${t}', which this client cannot interpret.`);return;case`newer`:console.warn(`[ag-ui] The producer speaks protocol ${t}; this client speaks 1.0. Unrecognised material will be stripped with warnings.`);return;case`not-newer`:return}},ZD=class e{resolvePeerCeiling(t){if(this.resolvingPeerCeiling)return KD;let n=Object.getOwnPropertyDescriptor(this,`maxVersion`),r=Object.getOwnPropertyDescriptor(this,`maxProtocolVersion`),i=Object.getPrototypeOf(this);for(;i&&i!==e.prototype;)n??=Object.getOwnPropertyDescriptor(i,`maxVersion`),r??=Object.getOwnPropertyDescriptor(i,`maxProtocolVersion`),i=Object.getPrototypeOf(i);if(t===`maxVersion`&&n)return KD;let a=t===`maxProtocolVersion`?n:r;if(!a)return KD;this.resolvingPeerCeiling=!0;try{return a.get?a.get.call(this):a.value}finally{this.resolvingPeerCeiling=!1}}get maxProtocolVersion(){return this.resolvePeerCeiling(`maxProtocolVersion`)}get maxVersion(){return!this.resolvingPeerCeiling&&!qD&&(qD=!0,console.warn(`[ag-ui] AbstractAgent.maxVersion is deprecated — use maxProtocolVersion. Same value; the new name says whose version it is and that it is a ceiling.`)),this.resolvePeerCeiling(`maxVersion`)}get debug(){return this._debug}set debug(e){this._debug=uE(e),this._debugLogger=pE(this._debug)}get debugLogger(){return this._debugLogger}set debugLogger(e){this._debugLogger=typeof e==`boolean`?e?pE(uE(!0)):void 0:e}resolvedCeilingDuringConstruction(){let e=this.maxProtocolVersion;if(typeof e!=`string`||!wC(e))throw new j(`maxProtocolVersion resolved to ${JSON.stringify(e)} during construction, which is not a version this client can compare. A ceiling read from an instance field is not available yet — return a literal from the getter.`);return e}constructor({agentId:e,description:t,threadId:n,initialMessages:r,initialState:i,debug:a}={}){this.subscribers=[],this.isRunning=!1,this.pendingInterrupts=[],this.middlewares=[],this.resolvingPeerCeiling=!1,this.agentId=e,this.description=t??``,this.threadId=n??Po(),this.messages=rE(r??[]),this.state=rE(i??{}),this._debug=uE(a),this._debugLogger=pE(this._debug);let o=this.resolvedCeilingDuringConstruction();CC(o,`0.0.39`)<=0&&this.middlewares.unshift(new ND),CC(o,`0.0.45`)<=0&&this.middlewares.unshift(new zD),CC(o,`0.0.57`)<=0&&this.middlewares.unshift(new GD)}subscribe(e){return this.subscribers.push(e),{unsubscribe:()=>{this.subscribers=this.subscribers.filter(t=>t!==e)}}}use(...e){let t=e.map(e=>typeof e==`function`?new sD(e):e);return this.middlewares.push(...t),this}async runAgent(e,t){try{this.isRunning=!0,this.agentId=this.agentId??Po();let n=this.prepareRunAgentInput(e);this.debugLogger?.lifecycle(`LIFECYCLE`,`Run started:`,{agentId:this.agentId,threadId:this.threadId});let r,i=new Set(this.messages.map(e=>e.id)),a=[{onRunStartedEvent:({event:e})=>XD(e),onRunFinishedEvent:e=>{e.outcome===`success`&&(r=e.result)}},...this.subscribers,t??{}];JD.add(n),await this.onInitialize(n,a),this.activeRunDetach$=new xc;let o;this.activeRunCompletionPromise=new Promise(e=>{o=e}),await ol(uc(()=>[...this.middlewares,new ED].reduceRight((e,t)=>({run:n=>t.run(n,e),get messages(){return e.messages},get state(){return e.state}}),this).run(n),iD(this.debugLogger),GE(this.debugLogger),vE(this.debugLogger),e=>e.pipe(xl(this.activeRunDetach$)),e=>this.applyBeforeSourceError(n,e,a),ml(e=>(this.debugLogger?.lifecycle(`LIFECYCLE`,`Run errored:`,{agentId:this.agentId,error:e instanceof Error?e.message:String(e)}),this.isRunning=!1,this.onError(n,e,a))),yl(()=>{this.debugLogger?.lifecycle(`LIFECYCLE`,`Run finished:`,{agentId:this.agentId,threadId:this.threadId}),this.isRunning=!1,this.onFinalize(n,a),o?.(),o=void 0,this.activeRunCompletionPromise=void 0,this.activeRunDetach$=void 0}))(il(null)));let s=rE(this.messages).filter(e=>!i.has(e.id));return{result:r,newMessages:s}}finally{this.isRunning=!1}}connect(e){throw new zo}async connectAgent(e,t){try{this.isRunning=!0,this.agentId=this.agentId??Po();let n=this.prepareRunAgentInput(e),r,i=new Set(this.messages.map(e=>e.id)),a=[{onRunStartedEvent:({event:e})=>XD(e),onRunFinishedEvent:e=>{e.outcome===`success`&&(r=e.result)}},...this.subscribers,t??{}];await this.onInitialize(n,a),this.activeRunDetach$=new xc;let o;this.activeRunCompletionPromise=new Promise(e=>{o=e}),await ol(uc(()=>fl(()=>this.connect(n)),e=>iD(this.debugLogger)(DD()(e)),GE(this.debugLogger),vE(this.debugLogger),e=>e.pipe(xl(this.activeRunDetach$)),e=>this.applyBeforeSourceError(n,e,a),ml(e=>(this.isRunning=!1,e instanceof zo?Tc:this.onError(n,e,a))),yl(()=>{this.isRunning=!1,this.onFinalize(n,a),o?.(),o=void 0,this.activeRunCompletionPromise=void 0,this.activeRunDetach$=void 0}))(il(null)),{defaultValue:void 0});let s=rE(this.messages).filter(e=>!i.has(e.id));return{result:r,newMessages:s}}finally{this.isRunning=!1}}abortRun(){}async detachActiveRun(){if(!this.activeRunDetach$)return;let e=this.activeRunCompletionPromise??Promise.resolve();this.activeRunDetach$.next(),this.activeRunDetach$?.complete(),await e}applyBeforeSourceError(e,t,n){return fl(()=>{let r,i=t.pipe(ml(e=>(r={error:e},Tc)));return this.processApplyEvents(e,this.apply(e,i,n),n).pipe(_l(fl(()=>{let e=r;return e?N(()=>e.error):Tc})))})}apply(e,t,n){return gE(e,t,this,n,this.debugLogger)}processApplyEvents(e,t,n){return t.pipe(Sl(t=>{t.messages&&(this.messages=t.messages,n.forEach(t=>{t.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),t.state!==void 0&&(this.state=t.state,n.forEach(t=>{t.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})}))}))}prepareRunAgentInput(e){let t=rE(this.messages);for(let e of t)e.subagentRunId===null&&delete e.subagentRunId;let n=t.filter(e=>e.role!==`activity`);return{threadId:this.threadId,runId:e?.runId||Po(),...CC(this.maxProtocolVersion,KD)>=0&&{protocolVersion:`1.0`},tools:rE(e?.tools??[]),context:rE(e?.context??[]),forwardedProps:rE(e?.forwardedProps??{}),state:rE(this.state),messages:n,...e?.resume===void 0?{}:{resume:rE(e.resume)}}}async onInitialize(e,t){if(JD.has(e)&&this.pendingInterrupts.length>0){let t=new Set((e.resume??[]).map(e=>e.interruptId)),n=this.pendingInterrupts.map(e=>e.id).filter(e=>!t.has(e));if(n.length>0)throw new j(`Thread has ${n.length} pending interrupt(s) not addressed by resume: ${n.join(`, `)}`);for(let t of this.pendingInterrupts)if(OD(t)&&(e.resume??[]).find(e=>e.interruptId===t.id)?.status!==`cancelled`)throw new j(`Interrupt ${t.id} expired at ${t.expiresAt} and can no longer be answered. Cancel it to continue the thread.`)}let n=await lE(t,this.messages,this.state,(t,n,r)=>t.onRunInitialized?.({messages:n,state:r,agent:this,input:e}));if(n.messages!==void 0||n.state!==void 0){if(n.messages){this.messages=n.messages;for(let e of n.messages)e.subagentRunId===null&&delete e.subagentRunId;e.messages=n.messages.filter(e=>e.role!==`activity`),t.forEach(t=>{t.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})}n.state!==void 0&&(this.state=n.state,e.state=n.state,t.forEach(t=>{t.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})}))}}onError(e,t,n){return rl(lE(n,this.messages,this.state,(n,r,i)=>n.onRunFailed?.({error:t,messages:r,state:i,agent:this,input:e}))).pipe(sl(r=>{let i=r;if((i.messages!==void 0||i.state!==void 0)&&(i.messages!==void 0&&(this.messages=i.messages,n.forEach(t=>{t.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),i.state!==void 0&&(this.state=i.state,n.forEach(t=>{t.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})}))),i.stopPropagation!==!0){let e=String(t);if(t.name!==`AbortError`&&t.message!==`Fetch is aborted`&&t.message!==`signal is aborted without reason`&&t.message!==`component unmounted`&&e!==`component unmounted`)throw console.error(`Agent execution failed:`,t),t}return{}}))}async onFinalize(e,t){let n=await lE(t,this.messages,this.state,(t,n,r)=>t.onRunFinalized?.({messages:n,state:r,agent:this,input:e}));(n.messages!==void 0||n.state!==void 0)&&(n.messages!==void 0&&(this.messages=n.messages,t.forEach(t=>{t.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),n.state!==void 0&&(this.state=n.state,t.forEach(t=>{t.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})})))}clone(){let e=Object.create(Object.getPrototypeOf(this));return e.agentId=this.agentId,e.description=this.description,e.threadId=this.threadId,e.messages=rE(this.messages),e.state=rE(this.state),e._debug=this._debug,e._debugLogger=this._debugLogger,e.isRunning=this.isRunning,e.subscribers=[...this.subscribers],e.middlewares=[...this.middlewares],e.pendingInterrupts=rE(this.pendingInterrupts),e}addMessage(e){this.messages.push(e),(async()=>{for(let t of this.subscribers)await t.onNewMessage?.({message:e,messages:this.messages,state:this.state,agent:this});if(e.role===`assistant`&&e.toolCalls)for(let t of e.toolCalls)for(let e of this.subscribers)await e.onNewToolCall?.({toolCall:t,messages:this.messages,state:this.state,agent:this});for(let e of this.subscribers)await e.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}addMessages(e){this.messages.push(...e),(async()=>{for(let t of e){for(let e of this.subscribers)await e.onNewMessage?.({message:t,messages:this.messages,state:this.state,agent:this});if(t.role===`assistant`&&t.toolCalls)for(let e of t.toolCalls)for(let t of this.subscribers)await t.onNewToolCall?.({toolCall:e,messages:this.messages,state:this.state,agent:this})}for(let e of this.subscribers)await e.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}setMessages(e){this.messages=rE(e),(async()=>{for(let e of this.subscribers)await e.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}setState(e){this.state=rE(e),(async()=>{for(let e of this.subscribers)await e.onStateChanged?.({messages:this.messages,state:this.state,agent:this})})()}legacy_to_be_removed_runAgentBridged(e){this.agentId=this.agentId??Po();let t=this.prepareRunAgentInput(e);return[...this.middlewares,new ED].reduceRight((e,t)=>({run:n=>t.run(n,e),get messages(){return e.messages},get state(){return e.state}}),this).run(t).pipe(iD(this.debugLogger),GE(this.debugLogger),vE(this.debugLogger),jE(this.threadId,t.runId,this.agentId),e=>e.pipe(sl(e=>(this.debugLogger?.event(`LEGACY`,`Event:`,e,{type:e.type}),e))))}};function QD(e){if(!Array.isArray(e.messages))return e;let t=!1,n=e.messages.map(e=>{if(e.subagentRunId===null){t=!0;let n={...e};return delete n.subagentRunId,n}return e});return t?{...e,messages:n}:e}var $D=class extends ZD{requestInit(e){return{method:`POST`,headers:{...this.headers,"Content-Type":`application/json`,Accept:`text/event-stream`},body:JSON.stringify(QD(e)),signal:this.abortController.signal}}runAgent(e,t){return this.abortController=e?.abortController??new AbortController,super.runAgent(e,t)}abortRun(){this.abortController.abort(),super.abortRun()}constructor(e){super(e),this.abortController=new AbortController,this.url=e.url,this.headers=rE(e.headers??{}),this.fetch=e.fetch??((e,t)=>fetch(e,t))}run(e){return EE(bE(()=>this.fetch(this.url,this.requestInit(aD(e)))),this.debugLogger)}clone(){let e=super.clone();e.url=this.url,e.headers=rE(this.headers??{}),e.fetch=this.fetch;let t=new AbortController,n=this.abortController.signal;return n.aborted&&t.abort(n.reason),e.abortController=t,e}},eO=class extends Yt{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:ln(t,n.data),hasPreviousPage:Zt(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}},tO=class extends $t{#e;#t;#n;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}build(e,t,n){let r=new cn({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=nO(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=nO(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=nO(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=nO(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){dn.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>en(t,e))}findAll(e={}){return this.getAll().filter(t=>en(e,t))}notify(e){dn.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return dn.batch(()=>Promise.all(e.map(e=>e.continue().catch(fn))))}};function nO(e){return e.options.scope?.id}var rO=class extends $t{#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){let r=t.queryKey,i=t.queryHash??tn(r,t),a=this.get(i);return a||(a=new on({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){this.#e.get(e.queryHash)===e&&(e.destroy(),this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){dn.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Jt(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>Jt(e,t)):t}notify(e){dn.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){dn.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){dn.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},iO=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new rO,this.#t=e.mutationCache||new tO,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=Qt.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=nn.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Xt(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=sn(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return dn.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;dn.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return dn.batch(()=>{let r=n.findAll(e),i=new Set(r);return r.forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,predicate:e=>i.has(e)},t)})}cancelQueries(e,t={}){let n={revert:!0,...t},r=dn.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(fn).catch(fn)}invalidateQueries(e,t={}){return dn.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=dn.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(fn)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(fn)}async query(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t),r=n.isStaleByTime(Xt(t.staleTime,n))?await n.fetch(t):n.state.data,i=t.select;return i?i(r):r}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(Xt(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(fn).catch(fn)}infiniteQuery(e){return e._type=`infinite`,this.query(e)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(fn).catch(fn)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return nn.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(rn(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{mn(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(rn(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{mn(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=tn(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===Ut&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}};function aO(e,t){return an(e,eO,t)}var oO=new Map([[`bold`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M232,44H160a43.86,43.86,0,0,0-32,13.85A43.86,43.86,0,0,0,96,44H24A12,12,0,0,0,12,56V200a12,12,0,0,0,12,12H96a20,20,0,0,1,20,20,12,12,0,0,0,24,0,20,20,0,0,1,20-20h72a12,12,0,0,0,12-12V56A12,12,0,0,0,232,44ZM96,188H36V68H96a20,20,0,0,1,20,20V192.81A43.79,43.79,0,0,0,96,188Zm124,0H160a43.71,43.71,0,0,0-20,4.83V88a20,20,0,0,1,20-20h60Z`}))],[`duotone`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M232,56V200H160a32,32,0,0,0-32,32,32,32,0,0,0-32-32H24V56H96a32,32,0,0,1,32,32,32,32,0,0,1,32-32Z`,opacity:`0.2`}),D.createElement(`path`,{d:`M232,48H160a40,40,0,0,0-32,16A40,40,0,0,0,96,48H24a8,8,0,0,0-8,8V200a8,8,0,0,0,8,8H96a24,24,0,0,1,24,24,8,8,0,0,0,16,0,24,24,0,0,1,24-24h72a8,8,0,0,0,8-8V56A8,8,0,0,0,232,48ZM96,192H32V64H96a24,24,0,0,1,24,24V200A39.81,39.81,0,0,0,96,192Zm128,0H160a39.81,39.81,0,0,0-24,8V88a24,24,0,0,1,24-24h64Z`}))],[`fill`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M240,56V200a8,8,0,0,1-8,8H160a24,24,0,0,0-24,23.94,7.9,7.9,0,0,1-5.12,7.55A8,8,0,0,1,120,232a24,24,0,0,0-24-24H24a8,8,0,0,1-8-8V56a8,8,0,0,1,8-8H88a32,32,0,0,1,32,32v87.73a8.17,8.17,0,0,0,7.47,8.25,8,8,0,0,0,8.53-8V80a32,32,0,0,1,32-32h64A8,8,0,0,1,240,56Z`}))],[`light`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M232,50H160a38,38,0,0,0-32,17.55A38,38,0,0,0,96,50H24a6,6,0,0,0-6,6V200a6,6,0,0,0,6,6H96a26,26,0,0,1,26,26,6,6,0,0,0,12,0,26,26,0,0,1,26-26h72a6,6,0,0,0,6-6V56A6,6,0,0,0,232,50ZM96,194H30V62H96a26,26,0,0,1,26,26V204.31A37.86,37.86,0,0,0,96,194Zm130,0H160a37.87,37.87,0,0,0-26,10.32V88a26,26,0,0,1,26-26h66Z`}))],[`regular`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M232,48H160a40,40,0,0,0-32,16A40,40,0,0,0,96,48H24a8,8,0,0,0-8,8V200a8,8,0,0,0,8,8H96a24,24,0,0,1,24,24,8,8,0,0,0,16,0,24,24,0,0,1,24-24h72a8,8,0,0,0,8-8V56A8,8,0,0,0,232,48ZM96,192H32V64H96a24,24,0,0,1,24,24V200A39.81,39.81,0,0,0,96,192Zm128,0H160a39.81,39.81,0,0,0-24,8V88a24,24,0,0,1,24-24h64Z`}))],[`thin`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M232,52H160a36,36,0,0,0-32,19.54A36,36,0,0,0,96,52H24a4,4,0,0,0-4,4V200a4,4,0,0,0,4,4H96a28,28,0,0,1,28,28,4,4,0,0,0,8,0,28,28,0,0,1,28-28h72a4,4,0,0,0,4-4V56A4,4,0,0,0,232,52ZM96,196H28V60H96a28,28,0,0,1,28,28V209.4A35.93,35.93,0,0,0,96,196Zm132,0H160a35.94,35.94,0,0,0-28,13.41V88a28,28,0,0,1,28-28h68Z`}))]]),sO=new Map([[`bold`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M232.49,215.51,185,168a92.12,92.12,0,1,0-17,17l47.53,47.54a12,12,0,0,0,17-17ZM44,112a68,68,0,1,1,68,68A68.07,68.07,0,0,1,44,112Z`}))],[`duotone`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M192,112a80,80,0,1,1-80-80A80,80,0,0,1,192,112Z`,opacity:`0.2`}),D.createElement(`path`,{d:`M229.66,218.34,179.6,168.28a88.21,88.21,0,1,0-11.32,11.31l50.06,50.07a8,8,0,0,0,11.32-11.32ZM40,112a72,72,0,1,1,72,72A72.08,72.08,0,0,1,40,112Z`}))],[`fill`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M168,112a56,56,0,1,1-56-56A56,56,0,0,1,168,112Zm61.66,117.66a8,8,0,0,1-11.32,0l-50.06-50.07a88,88,0,1,1,11.32-11.31l50.06,50.06A8,8,0,0,1,229.66,229.66ZM112,184a72,72,0,1,0-72-72A72.08,72.08,0,0,0,112,184Z`}))],[`light`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M228.24,219.76l-51.38-51.38a86.15,86.15,0,1,0-8.48,8.48l51.38,51.38a6,6,0,0,0,8.48-8.48ZM38,112a74,74,0,1,1,74,74A74.09,74.09,0,0,1,38,112Z`}))],[`regular`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M229.66,218.34l-50.07-50.06a88.11,88.11,0,1,0-11.31,11.31l50.06,50.07a8,8,0,0,0,11.32-11.32ZM40,112a72,72,0,1,1,72,72A72.08,72.08,0,0,1,40,112Z`}))],[`thin`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M226.83,221.17l-52.7-52.7a84.1,84.1,0,1,0-5.66,5.66l52.7,52.7a4,4,0,0,0,5.66-5.66ZM36,112a76,76,0,1,1,76,76A76.08,76.08,0,0,1,36,112Z`}))]]),cO=new Map([[`bold`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M236.37,139.4a12,12,0,0,0-12-3A84.07,84.07,0,0,1,119.6,31.59a12,12,0,0,0-15-15A108.86,108.86,0,0,0,49.69,55.07,108,108,0,0,0,136,228a107.09,107.09,0,0,0,64.93-21.69,108.86,108.86,0,0,0,38.44-54.94A12,12,0,0,0,236.37,139.4Zm-49.88,47.74A84,84,0,0,1,68.86,69.51,84.93,84.93,0,0,1,92.27,48.29Q92,52.13,92,56A108.12,108.12,0,0,0,200,164q3.87,0,7.71-.27A84.79,84.79,0,0,1,186.49,187.14Z`}))],[`duotone`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M227.89,147.89A96,96,0,1,1,108.11,28.11,96.09,96.09,0,0,0,227.89,147.89Z`,opacity:`0.2`}),D.createElement(`path`,{d:`M233.54,142.23a8,8,0,0,0-8-2,88.08,88.08,0,0,1-109.8-109.8,8,8,0,0,0-10-10,104.84,104.84,0,0,0-52.91,37A104,104,0,0,0,136,224a103.09,103.09,0,0,0,62.52-20.88,104.84,104.84,0,0,0,37-52.91A8,8,0,0,0,233.54,142.23ZM188.9,190.34A88,88,0,0,1,65.66,67.11a89,89,0,0,1,31.4-26A106,106,0,0,0,96,56,104.11,104.11,0,0,0,200,160a106,106,0,0,0,14.92-1.06A89,89,0,0,1,188.9,190.34Z`}))],[`fill`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M235.54,150.21a104.84,104.84,0,0,1-37,52.91A104,104,0,0,1,32,120,103.09,103.09,0,0,1,52.88,57.48a104.84,104.84,0,0,1,52.91-37,8,8,0,0,1,10,10,88.08,88.08,0,0,0,109.8,109.8,8,8,0,0,1,10,10Z`}))],[`light`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M232.13,143.64a6,6,0,0,0-6-1.49A90.07,90.07,0,0,1,113.86,29.85a6,6,0,0,0-7.49-7.48A102.88,102.88,0,0,0,54.48,58.68,102,102,0,0,0,197.32,201.52a102.88,102.88,0,0,0,36.31-51.89A6,6,0,0,0,232.13,143.64Zm-42,48.29a90,90,0,0,1-126-126A90.9,90.9,0,0,1,99.65,37.66,102.06,102.06,0,0,0,218.34,156.35,90.9,90.9,0,0,1,190.1,191.93Z`}))],[`regular`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M233.54,142.23a8,8,0,0,0-8-2,88.08,88.08,0,0,1-109.8-109.8,8,8,0,0,0-10-10,104.84,104.84,0,0,0-52.91,37A104,104,0,0,0,136,224a103.09,103.09,0,0,0,62.52-20.88,104.84,104.84,0,0,0,37-52.91A8,8,0,0,0,233.54,142.23ZM188.9,190.34A88,88,0,0,1,65.66,67.11a89,89,0,0,1,31.4-26A106,106,0,0,0,96,56,104.11,104.11,0,0,0,200,160a106,106,0,0,0,14.92-1.06A89,89,0,0,1,188.9,190.34Z`}))],[`thin`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M230.72,145.06a4,4,0,0,0-4-1A92.08,92.08,0,0,1,111.94,29.27a4,4,0,0,0-5-5A100.78,100.78,0,0,0,56.08,59.88a100,100,0,0,0,140,140,100.78,100.78,0,0,0,35.59-50.87A4,4,0,0,0,230.72,145.06ZM191.3,193.53A92,92,0,0,1,62.47,64.7a93,93,0,0,1,39.88-30.35,100.09,100.09,0,0,0,119.3,119.3A93,93,0,0,1,191.3,193.53Z`}))]]),lO=new Map([[`bold`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M240.49,15.51a12,12,0,0,0-17,0L173.94,65.09l-2.54-2.55a36.05,36.05,0,0,0-50.91,0L100,83l-3.51-3.52a12,12,0,0,0-17,17L83,100,62.54,120.49a36,36,0,0,0,0,50.91l2.55,2.54L15.51,223.51a12,12,0,0,0,17,17l49.57-49.58,2.54,2.55a36.06,36.06,0,0,0,50.91,0L156,173l3.51,3.52a12,12,0,0,0,17-17L173,156l20.49-20.49a36,36,0,0,0,0-50.91l-2.55-2.54,49.58-49.57A12,12,0,0,0,240.49,15.51Zm-121.95,161a12,12,0,0,1-17,0L79.51,154.43a12,12,0,0,1,0-17L100,117l39,39Zm58-57.95h0L156,139l-39-39,20.49-20.49a12,12,0,0,1,17,0l22.06,22.06a12,12,0,0,1,0,17ZM85.27,33.37a12,12,0,0,1,21.46-10.74l8,16A12,12,0,1,1,93.27,49.37Zm-68,57.26a12,12,0,0,1,16.1-5.36l16,8a12,12,0,1,1-10.74,21.46l-16-8A12,12,0,0,1,17.27,90.63Zm221.46,74.74a12,12,0,0,1-16.1,5.36l-16-8a12,12,0,0,1,10.74-21.46l16,8A12,12,0,0,1,238.73,165.37Zm-68,57.26a12,12,0,1,1-21.46,10.74l-8-16a12,12,0,0,1,21.46-10.74Z`}))],[`duotone`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M185,127,127,185a24,24,0,0,1-33.94,0L71,162.91A24,24,0,0,1,71,129L129,71a24,24,0,0,1,33.94,0L185,93.09A24,24,0,0,1,185,127Z`,opacity:`0.2`}),D.createElement(`path`,{d:`M237.66,18.34a8,8,0,0,0-11.32,0l-52.4,52.41-5.37-5.38a32.05,32.05,0,0,0-45.26,0L100,88.69l-6.34-6.35A8,8,0,0,0,82.34,93.66L88.69,100,65.37,123.31a32,32,0,0,0,0,45.26l5.38,5.37-52.41,52.4a8,8,0,0,0,11.32,11.32l52.4-52.41,5.37,5.38a32.06,32.06,0,0,0,45.26,0L156,167.31l6.34,6.35a8,8,0,0,0,11.32-11.32L167.31,156l23.32-23.31a32,32,0,0,0,0-45.26l-5.38-5.37,52.41-52.4A8,8,0,0,0,237.66,18.34Zm-116.29,161a16,16,0,0,1-22.62,0L76.69,157.25a16,16,0,0,1,0-22.62L100,111.31,144.69,156Zm57.94-57.94h0L156,144.69,111.31,100l23.32-23.31a16,16,0,0,1,22.62,0l22.06,22a16,16,0,0,1,0,22.63ZM88.57,35A8,8,0,0,1,103.43,29l8,20A8,8,0,0,1,96.57,55ZM24.57,93A8,8,0,0,1,35,88.57l20,8A8,8,0,0,1,49,111.43l-20-8A8,8,0,0,1,24.57,93ZM231.43,163a8,8,0,0,1-10.4,4.46l-20-8A8,8,0,1,1,207,144.57l20,8A8,8,0,0,1,231.43,163Zm-64,58.06A8,8,0,0,1,152.57,227l-8-20A8,8,0,0,1,159.43,201Z`}))],[`fill`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M88.57,35A8,8,0,0,1,103.43,29l8,20A8,8,0,0,1,96.57,55ZM29,103.43l20,8A8,8,0,1,0,55,96.57l-20-8A8,8,0,0,0,29,103.43ZM227,152.57l-20-8A8,8,0,1,0,201,159.43l20,8A8,8,0,0,0,227,152.57ZM159.43,201A8,8,0,0,0,144.57,207l8,20A8,8,0,1,0,167.43,221ZM237.91,18.52a8,8,0,0,0-11.5-.18L174,70.75l-5.38-5.38a32,32,0,0,0-45.28,0L106.14,82.54a4,4,0,0,0,0,5.66l61.7,61.66a4,4,0,0,0,5.66,0l16.74-16.74a32.76,32.76,0,0,0,9.81-22.52,31.82,31.82,0,0,0-9.37-23.17l-5.38-5.37,52.2-52.17A8.22,8.22,0,0,0,237.91,18.52ZM85.64,90.34a8,8,0,0,0-11.49.18,8.22,8.22,0,0,0,.41,11.37L80.67,108,65.34,123.31A31.82,31.82,0,0,0,56,146.47,32.75,32.75,0,0,0,65.77,169l5,4.94L18.49,226.13a8.21,8.21,0,0,0-.61,11.1,8,8,0,0,0,11.72.43L82,185.25l5.37,5.38a32.1,32.1,0,0,0,45.29,0L148,175.31l6.34,6.35a8,8,0,0,0,11.32-11.32Z`}))],[`light`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M236.24,19.76a6,6,0,0,0-8.48,0L173.94,73.57l-6.79-6.78a30,30,0,0,0-42.42,0L100,91.51l-7.76-7.75a6,6,0,0,0-8.48,8.48L91.51,100,66.79,124.73a30,30,0,0,0,0,42.42l6.78,6.79L19.76,227.76a6,6,0,1,0,8.48,8.48l53.82-53.81,6.79,6.78a30,30,0,0,0,42.42,0L156,164.49l7.76,7.75a6,6,0,0,0,8.48-8.48L164.49,156l24.72-24.73a30,30,0,0,0,0-42.42l-6.78-6.79,53.81-53.82A6,6,0,0,0,236.24,19.76Zm-113.45,161a18,18,0,0,1-25.46,0L75.27,158.67a18,18,0,0,1,0-25.46L100,108.49,147.51,156Zm57.94-57.94L156,147.51,108.49,100l24.72-24.73a18,18,0,0,1,25.46,0l22.06,22.06a18,18,0,0,1,0,25.46ZM90.43,34.23a6,6,0,0,1,11.14-4.46l8,20a6,6,0,1,1-11.14,4.46Zm-64,59.54a6,6,0,0,1,7.8-3.34l20,8a6,6,0,1,1-4.46,11.14l-20-8A6,6,0,0,1,26.43,93.77Zm203.14,68.46a6,6,0,0,1-7.8,3.34l-20-8a6,6,0,0,1,4.46-11.14l20,8A6,6,0,0,1,229.57,162.23Zm-64,59.54a6,6,0,1,1-11.14,4.46l-8-20a6,6,0,0,1,11.14-4.46Z`}))],[`regular`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M237.66,18.34a8,8,0,0,0-11.32,0l-52.4,52.41-5.37-5.38a32.05,32.05,0,0,0-45.26,0L100,88.69l-6.34-6.35A8,8,0,0,0,82.34,93.66L88.69,100,65.37,123.31a32,32,0,0,0,0,45.26l5.38,5.37-52.41,52.4a8,8,0,0,0,11.32,11.32l52.4-52.41,5.37,5.38a32,32,0,0,0,45.26,0L156,167.31l6.34,6.35a8,8,0,0,0,11.32-11.32L167.31,156l23.32-23.31a32,32,0,0,0,0-45.26l-5.38-5.37,52.41-52.4A8,8,0,0,0,237.66,18.34Zm-116.29,161a16,16,0,0,1-22.62,0L76.69,157.25a16,16,0,0,1,0-22.62L100,111.31,144.69,156Zm57.94-57.94L156,144.69,111.31,100l23.32-23.31a16,16,0,0,1,22.62,0l22.06,22A16,16,0,0,1,179.31,121.37ZM88.57,35A8,8,0,0,1,103.43,29l8,20A8,8,0,0,1,96.57,55ZM24.57,93A8,8,0,0,1,35,88.57l20,8A8,8,0,0,1,49,111.43l-20-8A8,8,0,0,1,24.57,93ZM231.43,163a8,8,0,0,1-10.4,4.46l-20-8A8,8,0,1,1,207,144.57l20,8A8,8,0,0,1,231.43,163Zm-64,58.06A8,8,0,0,1,152.57,227l-8-20A8,8,0,0,1,159.43,201Z`}))],[`thin`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M234.83,21.17a4,4,0,0,0-5.66,0L173.94,76.4l-8.2-8.2a28,28,0,0,0-39.6,0L100,94.34l-9.17-9.17a4,4,0,0,0-5.66,5.66L94.34,100,68.2,126.14a28,28,0,0,0,0,39.6l8.2,8.2L21.17,229.17a4,4,0,0,0,5.66,5.66L82.06,179.6l8.2,8.2a28,28,0,0,0,39.6,0L156,161.66l9.17,9.17a4,4,0,0,0,5.66-5.66L161.66,156l26.14-26.14a28,28,0,0,0,0-39.6l-8.2-8.2,55.23-55.23A4,4,0,0,0,234.83,21.17Zm-110.63,161a20,20,0,0,1-28.28,0L73.86,160.08a20,20,0,0,1,0-28.28L100,105.66,150.34,156Zm57.94-57.94L156,150.34,105.66,100,131.8,73.86a20,20,0,0,1,28.28,0l22.06,22.06A20,20,0,0,1,182.14,124.2ZM92.29,33.49a4,4,0,1,1,7.42-3l8,20a4,4,0,0,1-2.22,5.2A3.91,3.91,0,0,1,104,56a4,4,0,0,1-3.71-2.51Zm-64,61a4,4,0,0,1,5.2-2.22l20,8A4,4,0,0,1,52,108a3.91,3.91,0,0,1-1.49-.29l-20-8A4,4,0,0,1,28.29,94.51Zm199.42,67A4,4,0,0,1,224,164a3.91,3.91,0,0,1-1.49-.29l-20-8a4,4,0,1,1,3-7.42l20,8A4,4,0,0,1,227.71,161.49Zm-64,61a4,4,0,0,1-2.22,5.2A3.91,3.91,0,0,1,160,228a4,4,0,0,1-3.71-2.51l-8-20a4,4,0,0,1,7.42-3Z`}))]]),uO=new Map([[`bold`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M228,128a12,12,0,0,1-12,12H140v76a12,12,0,0,1-24,0V140H40a12,12,0,0,1,0-24h76V40a12,12,0,0,1,24,0v76h76A12,12,0,0,1,228,128Z`}))],[`duotone`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z`,opacity:`0.2`}),D.createElement(`path`,{d:`M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z`}))],[`fill`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM184,136H136v48a8,8,0,0,1-16,0V136H72a8,8,0,0,1,0-16h48V72a8,8,0,0,1,16,0v48h48a8,8,0,0,1,0,16Z`}))],[`light`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M222,128a6,6,0,0,1-6,6H134v82a6,6,0,0,1-12,0V134H40a6,6,0,0,1,0-12h82V40a6,6,0,0,1,12,0v82h82A6,6,0,0,1,222,128Z`}))],[`regular`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z`}))],[`thin`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M220,128a4,4,0,0,1-4,4H132v84a4,4,0,0,1-8,0V132H40a4,4,0,0,1,0-8h84V40a4,4,0,0,1,8,0v84h84A4,4,0,0,1,220,128Z`}))]]),dO=new Map([[`bold`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M124,216a12,12,0,0,1-12,12H48a12,12,0,0,1-12-12V40A12,12,0,0,1,48,28h64a12,12,0,0,1,0,24H60V204h52A12,12,0,0,1,124,216Zm108.49-96.49-40-40a12,12,0,0,0-17,17L195,116H112a12,12,0,0,0,0,24h83l-19.52,19.51a12,12,0,0,0,17,17l40-40A12,12,0,0,0,232.49,119.51Z`}))],[`duotone`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M224,56V200a16,16,0,0,1-16,16H48V40H208A16,16,0,0,1,224,56Z`,opacity:`0.2`}),D.createElement(`path`,{d:`M120,216a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V40a8,8,0,0,1,8-8h64a8,8,0,0,1,0,16H56V208h56A8,8,0,0,1,120,216Zm109.66-93.66-40-40a8,8,0,0,0-11.32,11.32L204.69,120H112a8,8,0,0,0,0,16h92.69l-26.35,26.34a8,8,0,0,0,11.32,11.32l40-40A8,8,0,0,0,229.66,122.34Z`}))],[`fill`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M120,216a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V40a8,8,0,0,1,8-8h64a8,8,0,0,1,0,16H56V208h56A8,8,0,0,1,120,216Zm109.66-93.66-40-40A8,8,0,0,0,176,88v32H112a8,8,0,0,0,0,16h64v32a8,8,0,0,0,13.66,5.66l40-40A8,8,0,0,0,229.66,122.34Z`}))],[`light`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M118,216a6,6,0,0,1-6,6H48a6,6,0,0,1-6-6V40a6,6,0,0,1,6-6h64a6,6,0,0,1,0,12H54V210h58A6,6,0,0,1,118,216Zm110.24-92.24-40-40a6,6,0,0,0-8.48,8.48L209.51,122H112a6,6,0,0,0,0,12h97.51l-29.75,29.76a6,6,0,1,0,8.48,8.48l40-40A6,6,0,0,0,228.24,123.76Z`}))],[`regular`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M120,216a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V40a8,8,0,0,1,8-8h64a8,8,0,0,1,0,16H56V208h56A8,8,0,0,1,120,216Zm109.66-93.66-40-40a8,8,0,0,0-11.32,11.32L204.69,120H112a8,8,0,0,0,0,16h92.69l-26.35,26.34a8,8,0,0,0,11.32,11.32l40-40A8,8,0,0,0,229.66,122.34Z`}))],[`thin`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M116,216a4,4,0,0,1-4,4H48a4,4,0,0,1-4-4V40a4,4,0,0,1,4-4h64a4,4,0,0,1,0,8H52V212h60A4,4,0,0,1,116,216Zm110.83-90.83-40-40a4,4,0,0,0-5.66,5.66L214.34,124H112a4,4,0,0,0,0,8H214.34l-33.17,33.17a4,4,0,0,0,5.66,5.66l40-40A4,4,0,0,0,226.83,125.17Z`}))]]),fO=new Map([[`bold`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M199,125.31l-49.88-18.39L130.69,57a19.92,19.92,0,0,0-37.38,0L74.92,106.92,25,125.31a19.92,19.92,0,0,0,0,37.38l49.88,18.39L93.31,231a19.92,19.92,0,0,0,37.38,0l18.39-49.88L199,162.69a19.92,19.92,0,0,0,0-37.38Zm-63.38,35.16a12,12,0,0,0-7.11,7.11L112,212.28l-16.47-44.7a12,12,0,0,0-7.11-7.11L43.72,144l44.7-16.47a12,12,0,0,0,7.11-7.11L112,75.72l16.47,44.7a12,12,0,0,0,7.11,7.11L180.28,144ZM140,40a12,12,0,0,1,12-12h12V16a12,12,0,0,1,24,0V28h12a12,12,0,0,1,0,24H188V64a12,12,0,0,1-24,0V52H152A12,12,0,0,1,140,40ZM252,88a12,12,0,0,1-12,12h-4v4a12,12,0,0,1-24,0v-4h-4a12,12,0,0,1,0-24h4V72a12,12,0,0,1,24,0v4h4A12,12,0,0,1,252,88Z`}))],[`duotone`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M194.82,151.43l-55.09,20.3-20.3,55.09a7.92,7.92,0,0,1-14.86,0l-20.3-55.09-55.09-20.3a7.92,7.92,0,0,1,0-14.86l55.09-20.3,20.3-55.09a7.92,7.92,0,0,1,14.86,0l20.3,55.09,55.09,20.3A7.92,7.92,0,0,1,194.82,151.43Z`,opacity:`0.2`}),D.createElement(`path`,{d:`M197.58,129.06,146,110l-19-51.62a15.92,15.92,0,0,0-29.88,0L78,110l-51.62,19a15.92,15.92,0,0,0,0,29.88L78,178l19,51.62a15.92,15.92,0,0,0,29.88,0L146,178l51.62-19a15.92,15.92,0,0,0,0-29.88ZM137,164.22a8,8,0,0,0-4.74,4.74L112,223.85,91.78,169A8,8,0,0,0,87,164.22L32.15,144,87,123.78A8,8,0,0,0,91.78,119L112,64.15,132.22,119a8,8,0,0,0,4.74,4.74L191.85,144ZM144,40a8,8,0,0,1,8-8h16V16a8,8,0,0,1,16,0V32h16a8,8,0,0,1,0,16H184V64a8,8,0,0,1-16,0V48H152A8,8,0,0,1,144,40ZM248,88a8,8,0,0,1-8,8h-8v8a8,8,0,0,1-16,0V96h-8a8,8,0,0,1,0-16h8V72a8,8,0,0,1,16,0v8h8A8,8,0,0,1,248,88Z`}))],[`fill`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M208,144a15.78,15.78,0,0,1-10.42,14.94L146,178l-19,51.62a15.92,15.92,0,0,1-29.88,0L78,178l-51.62-19a15.92,15.92,0,0,1,0-29.88L78,110l19-51.62a15.92,15.92,0,0,1,29.88,0L146,110l51.62,19A15.78,15.78,0,0,1,208,144ZM152,48h16V64a8,8,0,0,0,16,0V48h16a8,8,0,0,0,0-16H184V16a8,8,0,0,0-16,0V32H152a8,8,0,0,0,0,16Zm88,32h-8V72a8,8,0,0,0-16,0v8h-8a8,8,0,0,0,0,16h8v8a8,8,0,0,0,16,0V96h8a8,8,0,0,0,0-16Z`}))],[`light`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M196.89,130.94,144.4,111.6,125.06,59.11a13.92,13.92,0,0,0-26.12,0L79.6,111.6,27.11,130.94a13.92,13.92,0,0,0,0,26.12L79.6,176.4l19.34,52.49a13.92,13.92,0,0,0,26.12,0L144.4,176.4l52.49-19.34a13.92,13.92,0,0,0,0-26.12Zm-4.15,14.86-55.08,20.3a6,6,0,0,0-3.56,3.56l-20.3,55.08a1.92,1.92,0,0,1-3.6,0L89.9,169.66a6,6,0,0,0-3.56-3.56L31.26,145.8a1.92,1.92,0,0,1,0-3.6l55.08-20.3a6,6,0,0,0,3.56-3.56l20.3-55.08a1.92,1.92,0,0,1,3.6,0l20.3,55.08a6,6,0,0,0,3.56,3.56l55.08,20.3a1.92,1.92,0,0,1,0,3.6ZM146,40a6,6,0,0,1,6-6h18V16a6,6,0,0,1,12,0V34h18a6,6,0,0,1,0,12H182V64a6,6,0,0,1-12,0V46H152A6,6,0,0,1,146,40ZM246,88a6,6,0,0,1-6,6H230v10a6,6,0,0,1-12,0V94H208a6,6,0,0,1,0-12h10V72a6,6,0,0,1,12,0V82h10A6,6,0,0,1,246,88Z`}))],[`regular`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M197.58,129.06,146,110l-19-51.62a15.92,15.92,0,0,0-29.88,0L78,110l-51.62,19a15.92,15.92,0,0,0,0,29.88L78,178l19,51.62a15.92,15.92,0,0,0,29.88,0L146,178l51.62-19a15.92,15.92,0,0,0,0-29.88ZM137,164.22a8,8,0,0,0-4.74,4.74L112,223.85,91.78,169A8,8,0,0,0,87,164.22L32.15,144,87,123.78A8,8,0,0,0,91.78,119L112,64.15,132.22,119a8,8,0,0,0,4.74,4.74L191.85,144ZM144,40a8,8,0,0,1,8-8h16V16a8,8,0,0,1,16,0V32h16a8,8,0,0,1,0,16H184V64a8,8,0,0,1-16,0V48H152A8,8,0,0,1,144,40ZM248,88a8,8,0,0,1-8,8h-8v8a8,8,0,0,1-16,0V96h-8a8,8,0,0,1,0-16h8V72a8,8,0,0,1,16,0v8h8A8,8,0,0,1,248,88Z`}))],[`thin`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M196.2,132.81l-53.36-19.65L123.19,59.8a11.93,11.93,0,0,0-22.38,0L81.16,113.16,27.8,132.81a11.93,11.93,0,0,0,0,22.38l53.36,19.65,19.65,53.36a11.93,11.93,0,0,0,22.38,0l19.65-53.36,53.36-19.65a11.93,11.93,0,0,0,0-22.38Zm-2.77,14.87L138.35,168a4,4,0,0,0-2.37,2.37l-20.3,55.08a3.92,3.92,0,0,1-7.36,0L88,170.35A4,4,0,0,0,85.65,168l-55.08-20.3a3.92,3.92,0,0,1,0-7.36L85.65,120A4,4,0,0,0,88,117.65l20.3-55.08a3.92,3.92,0,0,1,7.36,0L136,117.65a4,4,0,0,0,2.37,2.37l55.08,20.3a3.92,3.92,0,0,1,0,7.36ZM148,40a4,4,0,0,1,4-4h20V16a4,4,0,0,1,8,0V36h20a4,4,0,0,1,0,8H180V64a4,4,0,0,1-8,0V44H152A4,4,0,0,1,148,40Zm96,48a4,4,0,0,1-4,4H228v12a4,4,0,0,1-8,0V92H208a4,4,0,0,1,0-8h12V72a4,4,0,0,1,8,0V84h12A4,4,0,0,1,244,88Z`}))]]),pO=new Map([[`bold`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M116,36V20a12,12,0,0,1,24,0V36a12,12,0,0,1-24,0Zm80,92a68,68,0,1,1-68-68A68.07,68.07,0,0,1,196,128Zm-24,0a44,44,0,1,0-44,44A44.05,44.05,0,0,0,172,128ZM51.51,68.49a12,12,0,1,0,17-17l-12-12a12,12,0,0,0-17,17Zm0,119-12,12a12,12,0,0,0,17,17l12-12a12,12,0,1,0-17-17ZM196,72a12,12,0,0,0,8.49-3.51l12-12a12,12,0,0,0-17-17l-12,12A12,12,0,0,0,196,72Zm8.49,115.51a12,12,0,0,0-17,17l12,12a12,12,0,0,0,17-17ZM48,128a12,12,0,0,0-12-12H20a12,12,0,0,0,0,24H36A12,12,0,0,0,48,128Zm80,80a12,12,0,0,0-12,12v16a12,12,0,0,0,24,0V220A12,12,0,0,0,128,208Zm108-92H220a12,12,0,0,0,0,24h16a12,12,0,0,0,0-24Z`}))],[`duotone`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M184,128a56,56,0,1,1-56-56A56,56,0,0,1,184,128Z`,opacity:`0.2`}),D.createElement(`path`,{d:`M120,40V16a8,8,0,0,1,16,0V40a8,8,0,0,1-16,0Zm72,88a64,64,0,1,1-64-64A64.07,64.07,0,0,1,192,128Zm-16,0a48,48,0,1,0-48,48A48.05,48.05,0,0,0,176,128ZM58.34,69.66A8,8,0,0,0,69.66,58.34l-16-16A8,8,0,0,0,42.34,53.66Zm0,116.68-16,16a8,8,0,0,0,11.32,11.32l16-16a8,8,0,0,0-11.32-11.32ZM192,72a8,8,0,0,0,5.66-2.34l16-16a8,8,0,0,0-11.32-11.32l-16,16A8,8,0,0,0,192,72Zm5.66,114.34a8,8,0,0,0-11.32,11.32l16,16a8,8,0,0,0,11.32-11.32ZM48,128a8,8,0,0,0-8-8H16a8,8,0,0,0,0,16H40A8,8,0,0,0,48,128Zm80,80a8,8,0,0,0-8,8v24a8,8,0,0,0,16,0V216A8,8,0,0,0,128,208Zm112-88H216a8,8,0,0,0,0,16h24a8,8,0,0,0,0-16Z`}))],[`fill`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M120,40V16a8,8,0,0,1,16,0V40a8,8,0,0,1-16,0Zm8,24a64,64,0,1,0,64,64A64.07,64.07,0,0,0,128,64ZM58.34,69.66A8,8,0,0,0,69.66,58.34l-16-16A8,8,0,0,0,42.34,53.66Zm0,116.68-16,16a8,8,0,0,0,11.32,11.32l16-16a8,8,0,0,0-11.32-11.32ZM192,72a8,8,0,0,0,5.66-2.34l16-16a8,8,0,0,0-11.32-11.32l-16,16A8,8,0,0,0,192,72Zm5.66,114.34a8,8,0,0,0-11.32,11.32l16,16a8,8,0,0,0,11.32-11.32ZM48,128a8,8,0,0,0-8-8H16a8,8,0,0,0,0,16H40A8,8,0,0,0,48,128Zm80,80a8,8,0,0,0-8,8v24a8,8,0,0,0,16,0V216A8,8,0,0,0,128,208Zm112-88H216a8,8,0,0,0,0,16h24a8,8,0,0,0,0-16Z`}))],[`light`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M122,40V16a6,6,0,0,1,12,0V40a6,6,0,0,1-12,0Zm68,88a62,62,0,1,1-62-62A62.07,62.07,0,0,1,190,128Zm-12,0a50,50,0,1,0-50,50A50.06,50.06,0,0,0,178,128ZM59.76,68.24a6,6,0,1,0,8.48-8.48l-16-16a6,6,0,0,0-8.48,8.48Zm0,119.52-16,16a6,6,0,1,0,8.48,8.48l16-16a6,6,0,1,0-8.48-8.48ZM192,70a6,6,0,0,0,4.24-1.76l16-16a6,6,0,0,0-8.48-8.48l-16,16A6,6,0,0,0,192,70Zm4.24,117.76a6,6,0,0,0-8.48,8.48l16,16a6,6,0,0,0,8.48-8.48ZM46,128a6,6,0,0,0-6-6H16a6,6,0,0,0,0,12H40A6,6,0,0,0,46,128Zm82,82a6,6,0,0,0-6,6v24a6,6,0,0,0,12,0V216A6,6,0,0,0,128,210Zm112-88H216a6,6,0,0,0,0,12h24a6,6,0,0,0,0-12Z`}))],[`regular`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M120,40V16a8,8,0,0,1,16,0V40a8,8,0,0,1-16,0Zm72,88a64,64,0,1,1-64-64A64.07,64.07,0,0,1,192,128Zm-16,0a48,48,0,1,0-48,48A48.05,48.05,0,0,0,176,128ZM58.34,69.66A8,8,0,0,0,69.66,58.34l-16-16A8,8,0,0,0,42.34,53.66Zm0,116.68-16,16a8,8,0,0,0,11.32,11.32l16-16a8,8,0,0,0-11.32-11.32ZM192,72a8,8,0,0,0,5.66-2.34l16-16a8,8,0,0,0-11.32-11.32l-16,16A8,8,0,0,0,192,72Zm5.66,114.34a8,8,0,0,0-11.32,11.32l16,16a8,8,0,0,0,11.32-11.32ZM48,128a8,8,0,0,0-8-8H16a8,8,0,0,0,0,16H40A8,8,0,0,0,48,128Zm80,80a8,8,0,0,0-8,8v24a8,8,0,0,0,16,0V216A8,8,0,0,0,128,208Zm112-88H216a8,8,0,0,0,0,16h24a8,8,0,0,0,0-16Z`}))],[`thin`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M124,40V16a4,4,0,0,1,8,0V40a4,4,0,0,1-8,0Zm64,88a60,60,0,1,1-60-60A60.07,60.07,0,0,1,188,128Zm-8,0a52,52,0,1,0-52,52A52.06,52.06,0,0,0,180,128ZM61.17,66.83a4,4,0,0,0,5.66-5.66l-16-16a4,4,0,0,0-5.66,5.66Zm0,122.34-16,16a4,4,0,0,0,5.66,5.66l16-16a4,4,0,0,0-5.66-5.66ZM192,68a4,4,0,0,0,2.83-1.17l16-16a4,4,0,1,0-5.66-5.66l-16,16A4,4,0,0,0,192,68Zm2.83,121.17a4,4,0,0,0-5.66,5.66l16,16a4,4,0,0,0,5.66-5.66ZM40,124H16a4,4,0,0,0,0,8H40a4,4,0,0,0,0-8Zm88,88a4,4,0,0,0-4,4v24a4,4,0,0,0,8,0V216A4,4,0,0,0,128,212Zm112-88H216a4,4,0,0,0,0,8h24a4,4,0,0,0,0-8Z`}))]]),mO=D.forwardRef((e,t)=>D.createElement(w,{ref:t,...e,weights:oO}));mO.displayName=`BookOpenIcon`;var hO=mO,gO=D.forwardRef((e,t)=>D.createElement(w,{ref:t,...e,weights:sO}));gO.displayName=`MagnifyingGlassIcon`;var _O=gO,vO=D.forwardRef((e,t)=>D.createElement(w,{ref:t,...e,weights:cO}));vO.displayName=`MoonIcon`;var yO=vO,bO=D.forwardRef((e,t)=>D.createElement(w,{ref:t,...e,weights:lO}));bO.displayName=`PlugsConnectedIcon`;var xO=bO,SO=D.forwardRef((e,t)=>D.createElement(w,{ref:t,...e,weights:uO}));SO.displayName=`PlusIcon`;var CO=SO,wO=D.forwardRef((e,t)=>D.createElement(w,{ref:t,...e,weights:dO}));wO.displayName=`SignOutIcon`;var TO=wO,EO=D.forwardRef((e,t)=>D.createElement(w,{ref:t,...e,weights:fO}));EO.displayName=`SparkleIcon`;var DO=EO,OO=D.forwardRef((e,t)=>D.createElement(w,{ref:t,...e,weights:pO}));OO.displayName=`SunIcon`;var kO=OO,AO=[`agent-threads`];async function jO(e){let t=await gn(e);if(!t.ok)throw Error(`Request failed (${t.status})`);return t.json()}var MO=[];for(let e=0;e<256;++e)MO.push((e+256).toString(16).slice(1));function NO(e,t=0){return(MO[e[t+0]]+MO[e[t+1]]+MO[e[t+2]]+MO[e[t+3]]+`-`+MO[e[t+4]]+MO[e[t+5]]+`-`+MO[e[t+6]]+MO[e[t+7]]+`-`+MO[e[t+8]]+MO[e[t+9]]+`-`+MO[e[t+10]]+MO[e[t+11]]+MO[e[t+12]]+MO[e[t+13]]+MO[e[t+14]]+MO[e[t+15]]).toLowerCase()}var PO=new Uint8Array(16);function FO(){return crypto.getRandomValues(PO)}var IO={};function LO(e,t,n){let r;if(e)r=zO(e.random??e.rng?.()??FO(),e.msecs,e.seq,t,n);else{let e=Date.now(),i=FO();RO(IO,e,i),r=zO(i,IO.msecs,IO.seq,t,n)}return t??NO(r)}function RO(e,t,n){return e.msecs??=-1/0,e.seq??=0,t>e.msecs?(e.seq=BO(n),e.msecs=t):(e.seq=e.seq+1|0,e.seq===0&&e.msecs++),e}function zO(e,t,n,r,i=0){if(e.length<16)throw Error(`Random bytes length must be >= 16`);if(!r)r=new Uint8Array(16),i=0;else if(i<0||i+16>r.length)throw RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);return t??=Date.now(),n??=BO(e),r[i++]=t/1099511627776&255,r[i++]=t/4294967296&255,r[i++]=t/16777216&255,r[i++]=t/65536&255,r[i++]=t/256&255,r[i++]=t&255,r[i++]=112|n>>>28&15,r[i++]=n>>>20&255,r[i++]=128|n>>>14&63,r[i++]=n>>>6&255,r[i++]=n<<2&255|e[10]&3,r[i++]=e[11],r[i++]=e[12],r[i++]=e[13],r[i++]=e[14],r[i++]=e[15],r}function BO(e){return(e[6]&127)<<24|e[7]<<16|e[8]<<8|e[9]}function VO(){return LO()}function HO(){let{setColorScheme:e}=Vt(),t=Ht(`light`,{getInitialValueInEffect:!0}),n=t===`dark`?`light`:`dark`,[r,i]=(0,D.useState)(!1);return(0,O.jsx)(zt,{label:`Switch to ${n} theme`,opened:r,children:(0,O.jsx)(We,{variant:`subtle`,color:`gray`,"aria-label":`Switch to ${n} theme`,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),onFocus:()=>i(!0),onBlur:()=>i(!1),onClick:()=>{i(!1),e(n)},children:t===`dark`?(0,O.jsx)(kO,{size:17,weight:`bold`}):(0,O.jsx)(yO,{size:17,weight:`bold`})})})}var UO={home:`https://fanout.run/start/what-fanout-is`,ingest:`https://fanout.run/start/send-telemetry`};async function WO(e,t){let n=new URLSearchParams({page_size:`30`});e&&n.set(`q`,e),t&&n.set(`cursor`,t);let r=await gn(`/api/agent/threads?${n}`);if(!r.ok)throw Error(`Unable to load chats (${r.status})`);return r.json()}function GO({agentAvailable:e,activeThreadID:t,activeDashboardID:n,autoFocusSearch:r=!1,onNewChat:i,onSelectThread:a,onDeletedThread:o,onSelectDashboard:s,onCreateDashboard:c,onInvestigateService:l,ref:u}){let d=qt(),[f,p]=(0,D.useState)(``),[m]=ca(f.trim(),250),[h,g]=(0,D.useState)(null),[_,v]=(0,D.useState)(null),[y,b]=(0,D.useState)(``),[x,S]=(0,D.useState)(``),[te,C]=(0,D.useState)(!1),ne=(0,D.useRef)(null);(0,D.useImperativeHandle)(u,()=>({focusSearch:()=>ne.current?.focus()}),[]),(0,D.useEffect)(()=>{r&&requestAnimationFrame(()=>ne.current?.focus())},[r]);let ie=aO({queryKey:[...AO,m],queryFn:({pageParam:e})=>WO(m,e),initialPageParam:``,getNextPageParam:e=>e.next_cursor??void 0,enabled:e}),w=un({queryKey:ut,queryFn:it,refetchInterval:3e4,staleTime:ot}),ae=(0,D.useMemo)(()=>ie.data?.pages.flatMap(e=>e.items)??[],[ie.data]),le=(0,D.useMemo)(()=>ZO(ae),[ae]),ue=un({queryKey:[`telemetry-schema`,`1h`],queryFn:()=>jO(`/api/telemetry/schema?window=1h`),enabled:!!m&&!!l,staleTime:6e4}),de=(0,D.useMemo)(()=>{if(!m)return[];let e=m.toLowerCase();return(ue.data?.services??[]).map(e=>e.value).filter(t=>t.toLowerCase().includes(e)).slice(0,6)},[ue.data,m]),fe=(0,D.useMemo)(()=>{let e=w.data??[],t=m.toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)):e},[w.data,m]);function pe(e){S(``),b(e.title),g(e)}async function T(){if(h&&y.trim()){C(!0),S(``);try{let e=await gn(`/api/agent/threads/${encodeURIComponent(h.id)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({title:y.trim()})});if(!e.ok)throw Error(`Unable to rename chat (${e.status})`);await d.invalidateQueries({queryKey:AO}),g(null)}catch(e){S(e instanceof Error?e.message:`Unable to rename this chat.`)}finally{C(!1)}}}async function me(){if(_){C(!0),S(``);try{let e=await gn(`/api/agent/threads/${encodeURIComponent(_.id)}`,{method:`DELETE`});if(!e.ok)throw Error(`Unable to delete chat (${e.status})`);let t=_.id;v(null),await d.invalidateQueries({queryKey:AO}),await d.invalidateQueries({queryKey:ut}),o(t)}catch(e){S(e instanceof Error?e.message:`Unable to delete this chat.`)}finally{C(!1)}}}return(0,O.jsxs)(oe,{gap:`sm`,h:`100%`,component:`nav`,"aria-label":`Navigation`,children:[e&&(0,O.jsx)(se,{leftSection:(0,O.jsx)(CO,{size:16,weight:`bold`}),onClick:i,children:`New chat`}),(0,O.jsx)(Rt,{type:`auto`,offsetScrollbars:!0,flex:1,mx:-4,px:4,children:(0,O.jsxs)(oe,{gap:`lg`,pb:`sm`,children:[e&&(0,O.jsxs)(oe,{gap:4,children:[(0,O.jsx)(KO,{children:`Chats`}),ie.isLoading&&(0,O.jsx)(be,{py:`md`,children:(0,O.jsx)(Ce,{size:`xs`})}),ie.isError&&(0,O.jsx)(he,{color:`bad`,radius:`md`,p:`xs`,children:`Chats could not be loaded.`}),!ie.isLoading&&!ie.isError&&ae.length===0&&(0,O.jsx)(ce,{c:`dimmed`,size:`sm`,px:`sm`,py:`xs`,children:m?`No matching chats`:`No chats yet`}),le.map(e=>(0,O.jsxs)(oe,{gap:2,children:[le.length>1&&(0,O.jsx)(ce,{c:`dimmed`,size:`xs`,px:`sm`,pt:4,children:e.label}),e.threads.map(e=>(0,O.jsx)(qO,{thread:e,active:e.id===t,onSelect:()=>a(e.id),onRename:()=>pe(e),onDelete:()=>{S(``),v(e)}},e.id))]},e.label)),ie.hasNextPage&&(0,O.jsx)(se,{variant:`subtle`,color:`gray`,size:`compact-sm`,loading:ie.isFetchingNextPage,onClick:()=>void ie.fetchNextPage(),children:`See all`})]}),m&&l&&ue.isLoading&&(0,O.jsx)(be,{py:`md`,children:(0,O.jsx)(Ce,{size:`xs`})}),m&&l&&(ue.isSuccess||ue.isError)&&(0,O.jsxs)(oe,{gap:4,children:[(0,O.jsx)(KO,{children:`Services`}),ue.isError&&(0,O.jsx)(ce,{c:`dimmed`,size:`sm`,px:`sm`,children:`Services could not be searched`}),ue.isSuccess&&de.length===0&&(0,O.jsx)(ce,{c:`dimmed`,size:`sm`,px:`sm`,children:`No matching services`}),de.map(e=>(0,O.jsx)(ee,{className:`rail-row`,p:`sm`,onClick:()=>l(e),children:(0,O.jsx)(ce,{size:`sm`,fw:500,truncate:!0,children:e})},e))]}),(0,O.jsxs)(oe,{gap:4,children:[(0,O.jsx)(KO,{children:`Dashboards`}),w.isLoading&&(0,O.jsx)(be,{py:`md`,children:(0,O.jsx)(Ce,{size:`xs`})}),w.isError&&(0,O.jsx)(he,{color:`bad`,radius:`md`,p:`xs`,children:`Dashboards could not be loaded.`}),!w.isLoading&&!w.isError&&m&&fe.length===0&&(0,O.jsx)(ce,{c:`dimmed`,size:`sm`,px:`sm`,py:`xs`,children:`No matching dashboards`}),fe.map(e=>{let t=e.id===n;return(0,O.jsxs)(oe,{gap:0,children:[(0,O.jsx)(ee,{component:`a`,href:`/dashboards/${encodeURIComponent(e.id)}`,className:`rail-row`,"data-active":t||void 0,"aria-current":t?`page`:void 0,p:`sm`,onClick:t=>{t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(t.preventDefault(),s(e.id))},children:(0,O.jsxs)(re,{justify:`space-between`,gap:`sm`,wrap:`nowrap`,children:[(0,O.jsx)(ce,{size:`sm`,fw:t?600:500,truncate:!0,children:e.name}),e.is_default&&(0,O.jsx)(Je,{size:`xs`,variant:`light`,color:`gray`,children:`Default`})]})}),e.origin&&(0,O.jsx)(ee,{component:`a`,href:`/chat/${encodeURIComponent(e.origin.thread_id)}`,"data-request-provenance":!0,px:`sm`,pb:`xs`,onClick:t=>{t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(t.preventDefault(),a(e.origin.thread_id))},children:(0,O.jsxs)(ce,{size:`xs`,c:`dimmed`,lineClamp:2,children:[`Built from: `,e.origin.request_excerpt]})})]},e.id)}),e&&(0,O.jsx)(se,{variant:`subtle`,color:`gray`,size:`compact-sm`,justify:`flex-start`,leftSection:(0,O.jsx)(DO,{size:14,weight:`fill`}),onClick:c,children:w.data?.length===0?`New dashboard`:`Create with AI`})]})]})}),(0,O.jsx)(yn,{ref:ne,value:f,onChange:e=>p(e.currentTarget.value),leftSection:(0,O.jsx)(_O,{size:15}),rightSection:(0,O.jsx)(dt,{size:`xs`,children:`⌘K`}),rightSectionWidth:44,placeholder:`Search`,"aria-label":`Search chats, dashboards and services`,size:`sm`}),(0,O.jsx)(Wt,{opened:h!==null,onClose:()=>!te&&g(null),title:`Rename chat`,centered:!0,children:(0,O.jsx)(`form`,{onSubmit:e=>{e.preventDefault(),T()},children:(0,O.jsxs)(oe,{children:[(0,O.jsx)(yn,{label:`Name`,value:y,onChange:e=>b(e.currentTarget.value),maxLength:120,autoFocus:!0}),x&&(0,O.jsx)(he,{color:`bad`,children:x}),(0,O.jsxs)(re,{justify:`flex-end`,children:[(0,O.jsx)(se,{variant:`default`,onClick:()=>g(null),disabled:te,children:`Cancel`}),(0,O.jsx)(se,{type:`submit`,loading:te,disabled:!y.trim(),children:`Save`})]})]})})}),(0,O.jsx)(Wt,{opened:_!==null,onClose:()=>!te&&v(null),title:`Delete chat?`,centered:!0,children:(0,O.jsxs)(oe,{children:[(0,O.jsxs)(ce,{size:`sm`,children:[`This permanently removes `,(0,O.jsx)(ce,{span:!0,fw:650,children:_?.title}),` and its saved messages.`]}),x&&(0,O.jsx)(he,{color:`bad`,children:x}),(0,O.jsxs)(re,{justify:`flex-end`,children:[(0,O.jsx)(se,{variant:`default`,onClick:()=>v(null),disabled:te,children:`Cancel`}),(0,O.jsx)(se,{color:`bad`,loading:te,onClick:()=>void me(),children:`Delete`})]})]})})]})}function KO({children:e}){return(0,O.jsx)(ce,{c:`dimmed`,size:`xs`,fw:700,tt:`uppercase`,lts:`0.08em`,px:`sm`,children:e})}function qO({thread:e,active:t,onSelect:n,onRename:r,onDelete:i}){return(0,O.jsx)(l,{"data-active":t||void 0,className:`rail-row`,children:(0,O.jsxs)(re,{gap:2,wrap:`nowrap`,children:[(0,O.jsx)(ee,{onClick:n,"aria-current":t?`page`:void 0,p:`sm`,flex:1,style:{minWidth:0},children:(0,O.jsxs)(oe,{gap:0,children:[(0,O.jsx)(ce,{size:`sm`,fw:t?600:500,truncate:!0,children:e.title}),(0,O.jsx)(ce,{c:`dimmed`,size:`xs`,children:QO(e.updated_at)})]})}),(0,O.jsxs)(st,{position:`bottom-end`,withinPortal:!0,children:[(0,O.jsx)(st.Target,{children:(0,O.jsx)(We,{className:`rail-row-actions`,variant:`subtle`,color:`gray`,size:`sm`,mr:4,"aria-label":`Actions for ${e.title}`,children:(0,O.jsx)(ft,{size:18,weight:`bold`})})}),(0,O.jsxs)(st.Dropdown,{children:[(0,O.jsx)(st.Item,{leftSection:(0,O.jsx)(at,{size:15}),onClick:r,children:`Rename`}),(0,O.jsx)(st.Item,{color:`bad`,leftSection:(0,O.jsx)(Ft,{size:15}),onClick:i,children:`Delete`})]})]})]})})}function JO(e){return e.includes(`T`)?new Date(e):new Date(`${e.replace(` `,`T`)}Z`)}function YO(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}var XO=[`Today`,`Yesterday`,`Previous 7 days`,`Older`];function ZO(e){let t=YO(new Date),n=new Map;for(let r of e){let e=Math.floor((t-YO(JO(r.updated_at)))/864e5),i=e<=0?`Today`:e===1?`Yesterday`:e<=7?`Previous 7 days`:`Older`,a=n.get(i)??[];a.push(r),n.set(i,a)}return XO.filter(e=>n.has(e)).map(e=>({label:e,threads:n.get(e)}))}function QO(e){let t=JO(e),n=YO(new Date);return Math.floor((n-YO(t))/864e5)<=1?new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}).format(t):new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(t)}function $O({children:e}){let{agentAvailable:t,threadID:n,threadMissing:r,newThread:i,selectThread:a,openChat:o}=Ze(),s=we(),c=sa({select:e=>e.location.pathname}),{dashboardId:l}=wt({strict:!1}),u=c===`/chat`||c.startsWith(`/chat/`),[d,f]=la(!1),[p,m]=(0,D.useState)(!1),[h,g]=(0,D.useState)(``),_=(0,D.useRef)(null),v=ae(`(max-width: 62em)`),y=(0,D.useRef)(v);y.current=v,(0,D.useEffect)(()=>{f.close()},[c]),(0,D.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`&&(e.preventDefault(),y.current?(m(!0),f.open()):_.current?.focusSearch())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let b={agentAvailable:t,activeThreadID:u&&!r&&c!==`/chat`?n:void 0,activeDashboardID:l,onNewChat:i,onSelectThread:a,onDeletedThread:e=>{e===n&&i()},onSelectDashboard:e=>void s({to:`/dashboards/$dashboardId`,params:{dashboardId:e},search:{}}),onCreateDashboard:()=>o(Ge),onInvestigateService:e=>o(`Investigate the ${e} service. Explain its errors and latency.`)};return(0,O.jsxs)(po,{header:{height:52},navbar:{width:256,breakpoint:`md`,collapsed:{mobile:!0}},padding:0,children:[(0,O.jsx)(po.Header,{children:(0,O.jsxs)(re,{h:`100%`,px:{base:`sm`,sm:`md`},justify:`space-between`,wrap:`nowrap`,children:[(0,O.jsxs)(re,{gap:`sm`,wrap:`nowrap`,children:[(0,O.jsx)(Do,{hiddenFrom:`md`,opened:d,onClick:()=>{m(!1),f.toggle()},size:`sm`,"aria-label":d?`Close navigation`:`Open navigation`}),(0,O.jsx)(ve,{size:`small`})]}),(0,O.jsxs)(re,{gap:`xs`,wrap:`nowrap`,children:[(0,O.jsx)(zt,{label:`Documentation`,children:(0,O.jsx)(We,{component:`a`,href:UO.home,target:`_blank`,rel:`noopener noreferrer`,variant:`subtle`,color:`gray`,"aria-label":`Documentation`,children:(0,O.jsx)(hO,{size:17,weight:`bold`})})}),(0,O.jsx)(HO,{}),(0,O.jsx)(ek,{onError:g})]})]})}),(0,O.jsx)(po.Navbar,{p:`sm`,children:(0,O.jsx)(GO,{ref:_,...b})}),(0,O.jsx)(pt,{opened:d,onClose:f.close,hiddenFrom:`md`,size:288,padding:`sm`,title:(0,O.jsx)(ve,{size:`small`}),overlayProps:{backgroundOpacity:.24,blur:1},children:(0,O.jsx)(GO,{...b,autoFocusSearch:d&&p})}),(0,O.jsxs)(po.Main,{children:[h&&(0,O.jsx)(he,{color:`bad`,m:`md`,withCloseButton:!0,onClose:()=>g(``),children:h}),e]})]})}function ek({onError:e}){let t=we(),n=vn(),r=(n.display_name.trim()||n.email.trim()||`?`).charAt(0).toUpperCase();return(0,O.jsxs)(st,{position:`bottom-end`,withinPortal:!0,shadow:`md`,children:[(0,O.jsx)(st.Target,{children:(0,O.jsx)(We,{variant:`subtle`,color:`gray`,size:`lg`,radius:`xl`,"aria-label":`Account menu`,children:(0,O.jsx)(wo,{size:26,radius:`xl`,color:`brand`,children:r})})}),(0,O.jsxs)(st.Dropdown,{children:[(0,O.jsx)(st.Label,{children:n.email||`Signed in`}),(0,O.jsx)(st.Item,{leftSection:(0,O.jsx)(xO,{size:15}),onClick:()=>void t({to:`/settings`}),children:`Connect telemetry`}),(0,O.jsx)(st.Divider,{}),(0,O.jsx)(st.Item,{leftSection:(0,O.jsx)(TO,{size:15}),onClick:()=>void hn().catch(t=>e(t instanceof Error?t.message:`Sign-out failed — your session is still active.`)),children:`Sign out`})]})]})}function tk(){let{agent_available:e}=_n(),t=we(),n=qt(),{threadId:r}=wt({strict:!1}),[i,a]=(0,D.useState)(VO),o=(0,D.useRef)(new Set),s=r??i,[c,l]=(0,D.useState)([]),[u,d]=(0,D.useState)({}),[f,p]=(0,D.useState)(``),[m,h]=(0,D.useState)(!1),[g,_]=(0,D.useState)(!1),[v,y]=(0,D.useState)(``),[b,ee]=(0,D.useState)(null),x=(0,D.useRef)(null),[S,te]=(0,D.useState)(!1),C=(0,D.useRef)(!1),[ne,re]=(0,D.useState)(``),[ie,w]=(0,D.useState)(``),[ae,oe]=(0,D.useState)(0),se=(0,D.useRef)(null),ce=(0,D.useRef)({}),le=(0,D.useRef)(null),ue=(0,D.useRef)(new Map),de=(0,D.useMemo)(()=>new $D({url:`/api/agent/runs`,threadId:s,fetch:(e,t)=>gn(e,t)}),[s]),fe=!e||f===s;function pe(){ue.current.clear(),y(``),x.current=null,ee(null)}let T=e=>e.filter(e=>e.role!==`reasoning`);function me(){let e=x.current?.text.split(/(?<=[.!?])\s/)[0]?.trim().replace(/[.!?]+$/,``);return e?e+`…`:``}function he(e){return C.current||e instanceof Error&&e.name===`AbortError`}(0,D.useEffect)(()=>{let t=!0;if(l([]),ce.current={},d({}),p(``),h(!1),_(!1),C.current=!1,te(!1),pe(),w(``),!e){p(s);return}!r||o.current.has(s)?(de.setMessages([]),p(s)):gn(`/api/agent/threads/${encodeURIComponent(s)}`).then(async e=>{if(e.status===404)return null;if(!e.ok)throw Error(`Unable to load thread (${e.status})`);return e.json()}).then(e=>{if(t){if(e===null){h(!0),p(s);return}de.setMessages(T(e.messages??[])),l(T(e.messages??[])),p(s)}}).catch(()=>{t&&(se.current=null,w(`This chat could not be restored. Start a new chat or try again.`))});let i=de.subscribe({onEvent:({event:e,messages:t})=>{switch(e.type){case`REASONING_MESSAGE_START`:return x.current={id:e.messageId,text:``,collapsed:!1},ee(x.current),y(``),{stopPropagation:!0};case`REASONING_MESSAGE_CONTENT`:{let t=e,n={id:t.messageId,text:(x.current?.text??``)+t.delta,collapsed:!1};return x.current=n,ee(n),{stopPropagation:!0}}case`REASONING_START`:case`REASONING_MESSAGE_END`:case`REASONING_END`:return{stopPropagation:!0};default:l(T(t))}},onMessagesChanged:({messages:e})=>l(T(e)),onRunInitialized:()=>{C.current=!1,te(!1),_(!0),w(``)},onTextMessageContentEvent:({event:e})=>{e.delta&&(x.current=null,ee(null),y(``))},onToolCallStartEvent:({event:e})=>{ue.current.set(e.toolCallId,Xe(e.toolCallName)),y(Xe(e.toolCallName)),x.current&&(x.current={...x.current,collapsed:!0},ee(x.current))},onToolCallResultEvent:({event:e,messages:t})=>{ue.current.delete(e.toolCallId),y([...ue.current.values()].at(-1)??me());let r=$e(e.toolCallId,e.content,t);r&&(n.invalidateQueries({queryKey:ut}),n.invalidateQueries({queryKey:[`dashboard`,r.id]}),n.invalidateQueries({queryKey:[`dashboard-versions`,r.id]}))},onRunErrorEvent:({event:e})=>{e.code===`abort`||C.current?(w(``),te(!0)):(console.warn(`Agent run error`,e.code),w(He(e.code))),_(!1),pe()},onRunFinalized:({messages:e})=>{let t=T(e);l(t),d(e=>{let n={...e};for(let e of t)e.role===`assistant`&&!n[e.id]&&(n[e.id]=Date.now());return n}),_(!1),pe(),o.current.delete(s),n.invalidateQueries({queryKey:AO})},onRunFailed:e=>{he(e.error)?(w(``),te(!0)):(console.error(`Agent run failed`,e),w(He())),_(!1),pe(),o.current.delete(s),n.invalidateQueries({queryKey:AO})}});return()=>{t=!1,i.unsubscribe(),de.abortRun()}},[de,e,n,ae,s]),(0,D.useEffect)(()=>{if(!e)return;let n=e=>{let n=e.target,i=n?.matches(`input, textarea, [contenteditable='true']`);e.key===`/`&&!i&&(e.preventDefault(),r?requestAnimationFrame(()=>le.current?.focus()):t({to:`/chat`}).then(()=>requestAnimationFrame(()=>le.current?.focus()))),e.key===`Escape`&&n===le.current&&(re(``),le.current?.blur())};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t,r]);async function ge(){_(!0),w(``);try{await de.runAgent({forwardedProps:{...ce.current}})}catch(e){he(e)?(w(``),te(!0)):(console.error(`Agent run failed`,e),w(He())),_(!1),pe(),o.current.delete(s)}}async function _e(n,i){let a=n.trim();if(!e||!a||g||!fe||m)return;ce.current={...i},r||(o.current.add(s),t({to:`/chat/$threadId`,params:{threadId:s},replace:!0}));let c={id:VO(),role:`user`,content:a};de.addMessage(c),l([...de.messages]),d(e=>({...e,[c.id]:Date.now()})),re(``),await ge()}(0,D.useEffect)(()=>{let e=se.current;fe&&r&&e&&(se.current=null,_e(e.text,e.options))},[fe,r,s]);function ve(e){e.preventDefault(),_e(ne)}function ye(){C.current=!0,w(``),te(!0),de.abortRun(),_(!1),pe(),o.current.delete(s)}function be(){!g&&de.messages.some(e=>e.role===`user`)&&ge()}function xe(n,r){if(!e)return;let i=VO();o.current.add(i),se.current=n?{text:n,options:{...r}}:null,t({to:`/chat/$threadId`,params:{threadId:i}})}function Se(){de.abortRun(),se.current=null,ce.current={},a(VO()),t({to:`/chat`})}function Ce(e){se.current=null,ce.current={},t({to:`/chat/$threadId`,params:{threadId:e}})}function E(){oe(e=>e+1)}return(0,O.jsx)(Ye.Provider,{value:{agentAvailable:e,threadID:s,threadMissing:m,messages:c,messageTimes:u,ready:fe,running:g,activity:v,provisional:b,stopped:S,input:ne,setInput:re,error:ie,inputRef:le,send:_e,submit:ve,stop:ye,retry:be,reloadThread:E,openChat:xe,newThread:Se,selectThread:Ce},children:(0,O.jsx)($O,{children:(0,O.jsx)(Zi,{})})})}function nk(){let e=(0,D.useMemo)(()=>new iO,[]);return(0,O.jsx)(pn,{client:e,children:(0,O.jsx)(bn,{children:(0,O.jsx)(tk,{})})})}var rk=kt({component:nk,notFoundComponent:()=>(0,O.jsx)(Te,{to:`/`,replace:!0})}),ik=Dt(`/`)({component:Mt(()=>Qe(()=>import(`./routes-D2AdaqvY.js`),__vite__mapDeps([0,1,2])),`component`)}),ak=Dt(`/settings`)({component:Mt(()=>Qe(()=>import(`./settings-gNliABpX.js`),__vite__mapDeps([3,1,4,5,6,7,2,8])),`component`)}),ok=Dt(`/chat/`)({component:Mt(()=>Qe(()=>import(`./chat.index-BsJLgkqj.js`),__vite__mapDeps([9,10,1,4,11,5,12])),`component`)}),sk=Dt(`/chat/$threadId`)({component:Mt(()=>Qe(()=>import(`./chat._threadId-BsJLgkqj.js`),__vite__mapDeps([13,10,1,4,11,5,12])),`component`)}),ck=Dt(`/dashboards/`)({component:Mt(()=>Qe(()=>import(`./dashboards.index-DTZMYeFV.js`),__vite__mapDeps([14,1,2,15,4,11,5,16,6,7,17,12,8])),`component`),validateSearch:e=>bt(_t(e))}),lk=Dt(`/dashboards/$dashboardId`)({component:Mt(()=>Qe(()=>import(`./dashboards._dashboardId-ClSSKrZi.js`),__vite__mapDeps([18,1,2,15,4,11,5,16,6,7,17,12,8])),`component`),validateSearch:e=>bt(_t(e))}),uk=ik.update({id:`/`,path:`/`,getParentRoute:()=>rk}),dk=ak.update({id:`/settings`,path:`/settings`,getParentRoute:()=>rk}),fk=ok.update({id:`/chat/`,path:`/chat/`,getParentRoute:()=>rk}),pk=sk.update({id:`/chat/$threadId`,path:`/chat/$threadId`,getParentRoute:()=>rk}),mk=ck.update({id:`/dashboards/`,path:`/dashboards/`,getParentRoute:()=>rk}),hk={IndexRoute:uk,SettingsRoute:dk,ChatThreadIdRoute:pk,DashboardsDashboardIdRoute:lk.update({id:`/dashboards/$dashboardId`,path:`/dashboards/$dashboardId`,getParentRoute:()=>rk}),ChatIndexRoute:fk,DashboardsIndexRoute:mk},gk=ra({routeTree:rk._addFileChildren(hk)._addFileTypes(),parseSearch:Pt,stringifySearch:lt,defaultPreload:`intent`,scrollRestoration:!0}),_k=vt(S),vk=Ea({...Et,variantColorResolver:_k});(0,Fo.createRoot)(document.getElementById(`root`)).render((0,O.jsx)(D.StrictMode,{children:(0,O.jsx)(Ta,{theme:vk,defaultColorScheme:`auto`,cssVariablesResolver:jt,children:(0,O.jsx)(oa,{router:gk})})}));export{a_ as A,Cv as C,uv as D,V as E,Fu as F,Zm as M,qm as N,nv as O,Km as P,cv as S,gv as T,Hv as _,S_ as a,iv as b,vv as c,W as d,ov as f,mv as g,E_ as h,jO as i,$g as j,A_ as k,$_ as l,fv as m,ck as n,x_ as o,U as p,UO as r,K_ as s,lk as t,Z_ as u,K as v,qv as w,q_ as x,G as y}; \ No newline at end of file +`)};function kE(e,t){return Ho(t)&&AE(`[ag-ui][legacy] The result of tool call '${e}' carries content parts the legacy protocol cannot represent; only its text parts are bridged and the rest is dropped.`),Vo(t)}var AE=e=>{typeof process<`u`&&{}.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(e)},jE=(e,t,n)=>r=>{let i={},a=!0,o=!0,s=``,c=null,l=null,u=[],d={},f=!1,p=e=>{typeof e==`object`&&e&&(`messages`in e&&delete e.messages,i=e)};return r.pipe(ll(r=>{switch(r.type){case A.TEXT_MESSAGE_START:{let e=r;return[{type:DE.TextMessageStart,messageId:e.messageId,role:e.role}]}case A.TEXT_MESSAGE_CONTENT:{let e=r;return[{type:DE.TextMessageContent,messageId:e.messageId,content:e.delta}]}case A.TEXT_MESSAGE_END:{let e=r;return[{type:DE.TextMessageEnd,messageId:e.messageId}]}case A.TOOL_CALL_START:{let e=r;return u.push({id:e.toolCallId,type:`function`,function:{name:e.toolCallName,arguments:``}}),o=!0,d[e.toolCallId]=e.toolCallName,[{type:DE.ActionExecutionStart,actionExecutionId:e.toolCallId,actionName:e.toolCallName,parentMessageId:e.parentMessageId}]}case A.TOOL_CALL_ARGS:{let c=r,d=u.find(e=>e.id===c.toolCallId);if(!d)return AE(`[ag-ui][legacy] TOOL_CALL_ARGS: No tool call found with ID '${c.toolCallId}'`),[];d.function.arguments+=c.delta;let f=!1;if(l){let e=l.find(e=>e.tool==d.function.name);if(e)try{let t=JSON.parse(wl(d.function.arguments));e.tool_argument&&e.tool_argument in t?(p({...i,[e.state_key]:t[e.tool_argument]}),f=!0):e.tool_argument||(p({...i,[e.state_key]:t}),f=!0)}catch{}}return[{type:DE.ActionExecutionArgs,actionExecutionId:c.toolCallId,args:c.delta},...f?[{type:DE.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:o}]:[]]}case A.TOOL_CALL_END:{let e=r;return[{type:DE.ActionExecutionEnd,actionExecutionId:e.toolCallId}]}case A.TOOL_CALL_RESULT:{let e=r,t=d[e.toolCallId];return(t===void 0||t===``)&&AE(`[ag-ui][legacy] No usable tool name was seen for tool call '${e.toolCallId}' (${t===void 0?`no TOOL_CALL_START reached this bridge`:`its TOOL_CALL_START carried an empty toolCallName`}), so its result is being bridged with the fabricated action name "unknown". Downstream consumers route on that name.`),[{type:DE.ActionExecutionResult,actionExecutionId:e.toolCallId,result:kE(e.toolCallId,e.content),actionName:t||`unknown`}]}case A.RAW:return f||(f=!0,AE(`[ag-ui][legacy] Dropping RAW events: the legacy runtime protocol has no equivalent, so the provider payloads they carry do not reach the legacy stream. Reported once per stream.`)),[];case A.CUSTOM:{let e=r;switch(e.name){case`Exit`:a=!1;break;case`PredictState`:l=e.value}return[{type:DE.MetaEvent,name:e.name,value:e.value}]}case A.STATE_SNAPSHOT:return p(r.snapshot),[{type:DE.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:o}];case A.STATE_DELTA:{let c=r,l;try{l=Cs.applyPatch(i,c.delta,!0,!1).newDocument}catch(e){let t=e instanceof Error?e.message:String(e);return AE(`[ag-ui][legacy] Failed to apply state patch:\nCurrent state: ${JSON.stringify(i,null,2)}\nPatch operations: ${JSON.stringify(c.delta,null,2)}\nError: ${t}`),[]}return p(l),[{type:DE.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:o}]}case A.MESSAGES_SNAPSHOT:return c=r.messages,[{type:DE.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify({...i,...c?{messages:c}:{}}),active:!0}];case A.RUN_STARTED:return[];case A.RUN_FINISHED:{if(c&&(i.messages=c),Object.keys(i).length===0)return[];let r=null;if(c)try{r=ME(c)}catch(e){return[{type:DE.RunError,message:e.message}]}return[{type:DE.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify({...i,...r?{messages:r}:{}}),active:!1}]}case A.RUN_ERROR:{let e=r;return[{type:DE.RunError,message:e.message,code:e.code}]}case A.STEP_STARTED:return s=r.stepName,u=[],l=null,[{type:DE.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:!0}];case A.STEP_FINISHED:return u=[],l=null,[{type:DE.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:!1}];default:return[]}}))};function ME(e){let t=[];for(let n of e)if(n.role===`assistant`||n.role===`user`||n.role===`system`){let e=OE(n.content);if(e){let r={id:n.id,role:n.role,content:e};t.push(r)}if(n.role===`assistant`&&n.toolCalls&&n.toolCalls.length>0)for(let e of n.toolCalls){let r;try{r=JSON.parse(e.function.arguments)}catch(t){throw Error(`Failed to parse arguments for tool call '${e.id}' (${e.function.name}): ${t.message}`)}let i={id:e.id,name:e.function.name,arguments:r,parentMessageId:n.id};t.push(i)}}else if(n.role===`tool`){let r=`unknown`;for(let t of e)if(t.role===`assistant`&&t.toolCalls?.length){for(let e of t.toolCalls)if(e.id===n.toolCallId){r=e.function.name;break}}let i={id:n.id,result:kE(n.toolCallId,n.content),actionExecutionId:n.toolCallId,actionName:r};t.push(i)}return t}var NE=e=>e.kind===`tool`?e.fields.toolCallId:e.fields.messageId,PE=e=>e===`tool`?`toolCallId`:`messageId`,FE=(e,t,n,r,i)=>{if(r!==void 0&&r!==i)throw Error(`Cannot continue ${e} '${t}': chunk ${n} '${r}' does not match the open stream's ${n} ${i===void 0?`(absent)`:`'${i}'`}.`)},IE=(e,t)=>t.metadata===void 0?e:{...e,metadata:t.metadata},LE=(e,t)=>{let n=IE(e,t);return t.rawEvent===void 0?n:{...n,rawEvent:t.rawEvent}},RE=e=>new Set(Object.keys(e.shape)),zE=RE($v),BE=RE(ry),VE=RE(By),HE=(e,t)=>{let n;for(let r of Object.keys(e))t.has(r)||((n??={})[r]=e[r]);return n},UE=e=>{typeof process<`u`&&{}.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(`[ag-ui][transform] ${e} Set SUPPRESS_TRANSFORMATION_WARNINGS=true to silence.`)},WE=(e,t,n,r)=>{if(t===void 0||n||e.length===0)return;let i=e[e.length-1],a=Object.keys(t).filter(e=>Object.prototype.hasOwnProperty.call(i,e));a.length>0&&UE(`A ${r} carried ${a.map(e=>`'${e}'`).join(`, `)}, which the synthesized ${String(i.type)} already describes. The synthesized value is kept and the chunk's is dropped — this stage does not judge a described field, so the producer's value cannot be substituted for its own.`),e[e.length-1]={...t,...i}},GE=e=>t=>{let n=dE(e),r=new Map,i=e=>{let t=r.get(e);if(!t)return[];switch(r.delete(e),t.kind){case`text`:{let e={type:A.TEXT_MESSAGE_END,messageId:t.fields.messageId,...t.fields.subagentRunId!==void 0&&{subagentRunId:t.fields.subagentRunId}};return n?.event(`TRANSFORM`,`TEXT_MESSAGE_END`,e,{messageId:e.messageId}),[e]}case`tool`:{let e={type:A.TOOL_CALL_END,toolCallId:t.fields.toolCallId,...t.fields.subagentRunId!==void 0&&{subagentRunId:t.fields.subagentRunId}};return n?.event(`TRANSFORM`,`TOOL_CALL_END`,e,{toolCallId:e.toolCallId}),[e]}case`reasoning`:{let e={type:A.REASONING_MESSAGE_END,messageId:t.fields.messageId,...t.fields.subagentRunId!==void 0&&{subagentRunId:t.fields.subagentRunId}};return n?.event(`TRANSFORM`,`REASONING_MESSAGE_END`,e,{messageId:e.messageId}),[e]}}},a=()=>[...r.keys()].flatMap(e=>i(e)),o=(e,t)=>{for(let[n,i]of r)if(i.kind===e&&NE(i)===t)return{owner:n}},s=(e,t,n,i,a)=>{if(t!==void 0){let r=o(e,t);if(r){if(n!==void 0&&n!==r.owner)throw Error(`Cannot continue ${a} '${t}': chunk subagentRunId '${n}' does not match the open stream's subagent '${r.owner??`(the parent agent)`}'.`);return r.owner}return n}if(n!==void 0)return n;if(r.get(void 0)?.kind===e)return;let s=[...r.entries()].filter(([,t])=>t.kind===e);if(s.length===1)return s[0][0];if(s.length>1)throw Error(`Ambiguous ${i}: it carries neither a ${PE(e)} nor a subagentRunId, but ${s.length} lanes have an open ${a}. Attribute the chunk to the subagent it belongs to.`)};return t.pipe(ll(e=>{switch(e.type){case A.TEXT_MESSAGE_START:case A.TEXT_MESSAGE_CONTENT:case A.TEXT_MESSAGE_END:case A.TOOL_CALL_START:case A.TOOL_CALL_ARGS:case A.TOOL_CALL_END:case A.TOOL_CALL_RESULT:case A.STATE_SNAPSHOT:case A.STATE_DELTA:case A.CUSTOM:case A.STEP_STARTED:case A.STEP_FINISHED:case A.REASONING_START:case A.REASONING_MESSAGE_START:case A.REASONING_MESSAGE_CONTENT:case A.REASONING_MESSAGE_END:case A.REASONING_END:return[...i(e.subagentRunId??void 0),e];case A.RUN_STARTED:case A.RUN_FINISHED:case A.RUN_ERROR:case A.MESSAGES_SNAPSHOT:return[...a(),e];case A.RAW:case A.ACTIVITY_SNAPSHOT:case A.ACTIVITY_DELTA:case A.REASONING_ENCRYPTED_VALUE:case A.SUBAGENT_STARTED:return[e];case A.SUBAGENT_FINISHED:case A.SUBAGENT_ERROR:{let t=e.subagentRunId;return t==null?[e]:[...i(t),e]}case A.TEXT_MESSAGE_CHUNK:{let t=e,a=HE(e,zE),o=s(`text`,t.messageId,t.subagentRunId??void 0,`TEXT_MESSAGE_CHUNK`,`text message`),c=r.get(o),l=[],u=!1,d;if(c?.kind===`text`&&(t.messageId===void 0||t.messageId===c.fields.messageId))FE(`text message`,c.fields.messageId,`role`,t.role,c.fields.role),FE(`text message`,c.fields.messageId,`name`,t.name,c.fields.name),d=c.fields;else{if(l.push(...i(o)),t.messageId===void 0)throw Error(`First TEXT_MESSAGE_CHUNK must have a messageId`);d={messageId:t.messageId,role:t.role===void 0?`assistant`:t.role,name:t.name,subagentRunId:t.subagentRunId},r.set(o,{kind:`text`,fields:d});let e=IE({type:A.TEXT_MESSAGE_START,messageId:t.messageId,role:d.role,...t.name!==void 0&&{name:t.name},...t.subagentRunId!==void 0&&{subagentRunId:t.subagentRunId}},t);l.push(e),n?.event(`TRANSFORM`,`TEXT_MESSAGE_START`,e,{messageId:t.messageId})}if(t.delta!==void 0||t.rawEvent!==void 0){let e=t.subagentRunId===void 0?d.subagentRunId:t.subagentRunId,r=LE({...a,type:A.TEXT_MESSAGE_CONTENT,messageId:d.messageId,delta:t.delta===void 0?``:t.delta,...e!==void 0&&{subagentRunId:e}},t);l.push(r),u=!0,n?.event(`TRANSFORM`,`TEXT_MESSAGE_CONTENT`,r,{messageId:d.messageId})}if(l.length===0&&(t.metadata!==void 0||t.rawEvent!==void 0||t.subagentRunId===null||a!==void 0)){let e=t.subagentRunId===void 0?d.subagentRunId:t.subagentRunId;l.push({...a,type:A.TEXT_MESSAGE_CONTENT,messageId:d.messageId,delta:``,...t.metadata!==void 0&&{metadata:t.metadata},...t.rawEvent!==void 0&&{rawEvent:t.rawEvent},...e!==void 0&&{subagentRunId:e}}),u=!0}return WE(l,a,u,`TEXT_MESSAGE_CHUNK`),l}case A.TOOL_CALL_CHUNK:{let t=e,a=HE(e,BE),o=s(`tool`,t.toolCallId,t.subagentRunId??void 0,`TOOL_CALL_CHUNK`,`tool call`),c=r.get(o),l=[],u=!1,d;if(c?.kind===`tool`&&(t.toolCallId===void 0||t.toolCallId===c.fields.toolCallId))FE(`tool call`,c.fields.toolCallId,`toolCallName`,t.toolCallName,c.fields.toolCallName),FE(`tool call`,c.fields.toolCallId,`parentMessageId`,t.parentMessageId,c.fields.parentMessageId),d=c.fields;else{if(l.push(...i(o)),t.toolCallId===void 0)throw Error(`First TOOL_CALL_CHUNK must have a toolCallId`);if(t.toolCallName===void 0)throw Error(`First TOOL_CALL_CHUNK must have a toolCallName`);d={toolCallId:t.toolCallId,toolCallName:t.toolCallName,parentMessageId:t.parentMessageId,subagentRunId:t.subagentRunId},r.set(o,{kind:`tool`,fields:d});let e=IE({type:A.TOOL_CALL_START,toolCallId:t.toolCallId,toolCallName:t.toolCallName,...t.parentMessageId!==void 0&&{parentMessageId:t.parentMessageId},...t.subagentRunId!==void 0&&{subagentRunId:t.subagentRunId}},t);l.push(e),n?.event(`TRANSFORM`,`TOOL_CALL_START`,e,{toolCallId:t.toolCallId,toolCallName:t.toolCallName})}if(t.delta!==void 0||t.rawEvent!==void 0){let e=t.subagentRunId===void 0?d.subagentRunId:t.subagentRunId,r=LE({...a,type:A.TOOL_CALL_ARGS,toolCallId:d.toolCallId,delta:t.delta===void 0?``:t.delta,...e!==void 0&&{subagentRunId:e}},t);l.push(r),u=!0,n?.event(`TRANSFORM`,`TOOL_CALL_ARGS`,r,{toolCallId:d.toolCallId})}if(l.length===0&&(t.metadata!==void 0||t.rawEvent!==void 0||t.subagentRunId===null||a!==void 0)){let e=t.subagentRunId===void 0?d.subagentRunId:t.subagentRunId;l.push({...a,type:A.TOOL_CALL_ARGS,toolCallId:d.toolCallId,delta:``,...t.metadata!==void 0&&{metadata:t.metadata},...t.rawEvent!==void 0&&{rawEvent:t.rawEvent},...e!==void 0&&{subagentRunId:e}}),u=!0}return WE(l,a,u,`TOOL_CALL_CHUNK`),l}case A.REASONING_MESSAGE_CHUNK:{let t=e,a=HE(e,VE),o=s(`reasoning`,t.messageId,t.subagentRunId??void 0,`REASONING_MESSAGE_CHUNK`,`reasoning message`),c=r.get(o),l=[],u=!1,d;if(c?.kind===`reasoning`&&(t.messageId===void 0||t.messageId===c.fields.messageId))d=c.fields;else{if(l.push(...i(o)),t.messageId===void 0)throw Error(`First REASONING_MESSAGE_CHUNK must have a messageId`);d={messageId:t.messageId,subagentRunId:t.subagentRunId},r.set(o,{kind:`reasoning`,fields:d});let e=IE({type:A.REASONING_MESSAGE_START,messageId:t.messageId,role:`reasoning`,...t.subagentRunId!==void 0&&{subagentRunId:t.subagentRunId}},t);l.push(e),n?.event(`TRANSFORM`,`REASONING_MESSAGE_START`,e,{messageId:t.messageId})}if(t.delta!==void 0||t.rawEvent!==void 0){let e=t.subagentRunId===void 0?d.subagentRunId:t.subagentRunId,r=LE({...a,type:A.REASONING_MESSAGE_CONTENT,messageId:d.messageId,delta:t.delta===void 0?``:t.delta,...e!==void 0&&{subagentRunId:e}},t);l.push(r),u=!0,n?.event(`TRANSFORM`,`REASONING_MESSAGE_CONTENT`,r,{messageId:d.messageId})}if(l.length===0&&(t.metadata!==void 0||t.rawEvent!==void 0||t.subagentRunId===null||a!==void 0)){let e=t.subagentRunId===void 0?d.subagentRunId:t.subagentRunId;l.push({...a,type:A.REASONING_MESSAGE_CONTENT,messageId:d.messageId,delta:``,...t.metadata!==void 0&&{metadata:t.metadata},...t.rawEvent!==void 0&&{rawEvent:t.rawEvent},...e!==void 0&&{subagentRunId:e}}),u=!0}return WE(l,a,u,`REASONING_MESSAGE_CHUNK`),l}}return e.type,[e]}),yl(()=>{a()}))},KE=Symbol(`agui.strip.drop`);function qE(e){let t=e;for(;;){if(t instanceof PT||t instanceof IT||t instanceof RT||t instanceof JT||t instanceof WT){t=t.unwrap();continue}if(t instanceof KT){t=t.def.in;continue}if(t instanceof XT){t=t.def.getter();continue}return t}}function JE(e){let t=e.def;return typeof t?.discriminator==`string`?t.discriminator:void 0}function YE(e){let t=e,n=Array.isArray(t.def?.values)?t.def.values:t.values?Array.from(t.values):void 0;return n&&n.length===1?n[0]:t.value}function XE(e){let t=qE(e);return t instanceof jT?YE(t):void 0}function ZE(e,t,n,r){let i=qE(t);if(i instanceof CT){if(typeof e!=`object`||!e||Array.isArray(e))return e;let t=i.shape,a=e,o={},s=i.meta()?.specOpen===!0;for(let e of Object.keys(a)){let i=Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;if(i===void 0){if(s){o[e]=a[e];continue}r.push(`${n}/${e}`);continue}let c=r.length,l=ZE(a[e],i,`${n}/${e}`,r);if(l===KE){if(r.length=c,i.safeParse(void 0).success){r.push(`${n}/${e}`);continue}return KE}o[e]=l}return o}if(i instanceof xT){if(!Array.isArray(e))return e;let t=i.element,a=[];return e.forEach((e,i)=>{let o=r.length,s=ZE(e,t,`${n}/${i}`,r);if(s===KE){r.length=o,r.push(`${n}/${i}`);return}a.push(s)}),a}if(i instanceof OT){if(typeof e!=`object`||!e||Array.isArray(e))return e;let t=i.def.valueType,a=e,o={};for(let e of Object.keys(a)){let i=r.length,s=ZE(a[e],t,`${n}/${e}`,r);if(s===KE){r.length=i,r.push(`${n}/${e}`);continue}o[e]=s}return o}if(i instanceof wT){let t=i.options,a=JE(i);if(a!==void 0){if(typeof e!=`object`||!e||Array.isArray(e))return e;let i=e[a];for(let o of t){let t=qE(o);if(!(t instanceof CT))continue;let s=t.shape;if(XE(s[a])===i)return ZE(e,o,n,r)}return KE}let o=t.filter(e=>qE(e)instanceof CT),s=typeof e==`object`&&!!e&&!Array.isArray(e);if(o.length>1&&s)return e;for(let i of t){let t=qE(i);if(t instanceof xT&&Array.isArray(e)||t instanceof CT&&s)return ZE(e,i,n,r)}return e}return e}function QE(e,t){let n=[],r=ZE(e,t,``,n);if(r===KE)throw Error(`Internal error: the stripper found the whole value unrecognisable, which the schemas are not supposed to allow — schema/stripper mismatch.`);return{value:r,stripped:n}}var $E=new Set(Object.values(A));function eD(e){return $E.has(e.type)}var tD=new Map(Ky.options.map(e=>{let t=e.shape;return[String(YE(t.type)),e]})),nD=()=>typeof process<`u`&&!!{}.SUPPRESS_TRANSFORMATION_WARNINGS;function rD(e){nD()||console.warn(`[ag-ui][enforce] ${e}`)}var iD=e=>t=>{let n=dE(e);return t.pipe(ll(e=>{if(!eD(e))return rD(`Dropping unrecognised event '${String(e.type)}': no middleware translated it and the protocol does not describe it.`),n?.event(`ENFORCE`,`Unrecognised event dropped:`,e,{type:e.type}),Tc;let t=tD.get(e.type);if(t===void 0)throw Error(`No validator for recognised event type '${String(e.type)}'`);let{value:r,stripped:i}=QE(e,t);for(let t of i)rD(`Removed unrecognised material at '${t}' on ${String(e.type)}. Nothing handled it; see the repo-root DEPRECATIONS.md if it is a retired shape.`);return il(t.parse(r))}))};function aD(e){let{value:t,stripped:n}=QE(Ro(e,`RunAgentInput`),Ey);for(let e of n)rD(`Removed unrecognised material at '${e}' from the outgoing input.`);return Ey.parse(t)}var oD=class{runNext(e,t){return t.run(e).pipe(GE(!1))}runNextWithState(e,t){let n=rE(e.messages||[]),r=rE(e.state===void 0?{}:e.state),i=new wc;return gE(e,i,t,[]).subscribe({next:e=>{e.messages!==void 0&&(n=e.messages),e.state!==void 0&&(r=e.state)},error:()=>{}}),this.runNext(e,t).pipe(hl(async e=>(i.next(e),await new Promise(e=>setTimeout(e,0)),{event:e,messages:rE(n),state:rE(r)})))}},sD=class extends oD{constructor(e){super(),this.fn=e}run(e,t){return this.fn(e,t)}};function cD(e){return e.startsWith(`image/`)?`image`:e.startsWith(`audio/`)?`audio`:e.startsWith(`video/`)?`video`:`document`}function lD(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`binary`&&`mimeType`in e&&typeof e.mimeType==`string`}function uD(e){let t=cD(e.mimeType);return e.data?{type:t,source:{type:`data`,value:e.data,mimeType:e.mimeType},...e.filename?{metadata:{filename:e.filename}}:{}}:e.url?{type:t,source:{type:`url`,value:e.url,mimeType:e.mimeType},...e.filename?{metadata:{filename:e.filename}}:{}}:((typeof process>`u`||!{}.SUPPRESS_TRANSFORMATION_WARNINGS)&&console.warn(`[ag-ui][compat] A binary content part carries only an id ('${e.id??``}') and cannot be converted to a modern media part; a 1.0 peer will not accept it. Provide data or a url. See the repo-root DEPRECATIONS.md.`),e)}function dD(e,t,n){if(typeof e!=`object`||!e||!(`type`in e)||e.type!==t.type||!(`source`in e))return!1;let r=e.source;return typeof r!=`object`||!r||!(`type`in r)||r.type!==t.source.type||!(`value`in r)||r.value!==t.source.value||!(`mimeType`in r)||r.mimeType!==t.source.mimeType?!1:!n||`metadata`in e&&typeof e.metadata==`object`&&e.metadata!==null&&`filename`in e.metadata&&e.metadata.filename===n}function fD(e){let t=e.content;if(!Array.isArray(t))return e;let n=t.flatMap(e=>{if(lD(e)){let n=uD(e);return n.type!==`binary`&&t.some(t=>dD(t,n,e.filename))?[]:[n]}return[e]});return{...e,content:n}}var pD=`THINKING_START`,mD=`THINKING_END`,hD=`THINKING_TEXT_MESSAGE_START`,gD=`THINKING_TEXT_MESSAGE_CONTENT`,_D=`THINKING_TEXT_MESSAGE_END`;function vD(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var yD={event:[`rawEvent`,`subagentRunId`],[A.RUN_STARTED]:[`parentRunId`,`input`],[A.RUN_FINISHED]:[`result`,`outcome`],[A.RUN_ERROR]:[`usage`],[A.SUBAGENT_FINISHED]:[`result`],[A.TOOL_CALL_START]:[`parentMessageId`],[A.TOOL_CALL_CHUNK]:[`parentMessageId`],[A.TOOL_CALL_RESULT]:[`role`],"RUN_FINISHED.outcome":[`pendingToolCallIds`],"RUN_FINISHED.usage[]":[`provider`,`reasoningTokens`,`cachedInputTokens`,`cacheWriteInputTokens`],RunAgentInput:[`forwardedProps`],Tool:[`parameters`],ResumeEntry:[`payload`],"input content":[`metadata`]},bD=new Map(Object.entries(yD).filter(([e])=>Object.values(A).includes(e))),xD=e=>_E(e,`an absent field`);function SD(e,t,n,r){if(!vD(e))return e;let i;for(let a of t)e[a]===null&&(r(n===void 0?`${a}: null`:`${n}.${a}: null`),i??={...e},delete i[a]);return i??e}function CD(e,t,n){if(!vD(e)||!Array.isArray(e[t]))return e;let r=e[t],i=r.map(n);return i.some((e,t)=>e!==r[t])?{...e,[t]:i}:e}function wD(e,t){return CD(e,`content`,e=>{if(!vD(e))return e;switch(e.type){case`image`:case`audio`:case`video`:case`document`:return SD(e,yD[`input content`],`${e.type} input content`,t);default:return e}})}function TD(e,t=xD){let n=SD(e,yD.RunAgentInput,`RunAgentInput`,t);return n=CD(n,`tools`,e=>SD(e,yD.Tool,`Tool`,t)),n=CD(n,`resume`,e=>SD(e,yD.ResumeEntry,`ResumeEntry`,t)),CD(n,`messages`,e=>wD(e,t))}var ED=class extends oD{constructor(...e){super(...e),this.currentReasoningId=null,this.currentMessageId=null,this.nullsNoticedThisRun=new Set,this.noticeNullOncePerRun=e=>{this.nullsNoticedThisRun.has(e)||(this.nullsNoticedThisRun.add(e),_E(e,`an absent field`))}}warn(e,t){_E(e,t)}mintedContinuationId(e,t){if(t!==null)return t;let n=iE();return this.warnAside(`Minting a messageId ('${n}') for ${e}: no THINKING opener preceded it, so there was no id to continue. The id is this client's invention, not the producer's, and verification will reject the translated event for naming something nothing opened.`),n}warnAside(e){typeof process<`u`&&{}.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(`[ag-ui][compat] ${e} Set SUPPRESS_TRANSFORMATION_WARNINGS=true to silence.`)}run(e,t){return this.currentReasoningId=null,this.currentMessageId=null,this.nullsNoticedThisRun.clear(),e.messages=e.messages.map(fD),t.run(e).pipe(sl(e=>this.transformEvent(e)))}transformEvent(e){let t=this.noticeNullOncePerRun;e.type===A.RUN_STARTED&&this.nullsNoticedThisRun.clear(),e=SD(e,yD.event,void 0,t);let n=bD.get(e.type);switch(n&&(e=SD(e,n,e.type,t)),e.type){case pD:{this.currentReasoningId=iE();let{title:t,...n}=e;return this.warn(pD,A.REASONING_START),t!==void 0&&this.warnAside(`Dropping ${pD}.title ${JSON.stringify(t)}: ${A.REASONING_START} has no title field, so the span's label cannot be carried and nothing downstream can recover it.`),{...n,type:A.REASONING_START,messageId:this.currentReasoningId}}case hD:return this.currentMessageId=iE(),this.warn(hD,A.REASONING_MESSAGE_START),{...e,type:A.REASONING_MESSAGE_START,messageId:this.currentMessageId,role:`reasoning`};case gD:{let{delta:t,...n}=e;return this.warn(gD,A.REASONING_MESSAGE_CONTENT),{...n,type:A.REASONING_MESSAGE_CONTENT,messageId:this.mintedContinuationId(gD,this.currentMessageId),delta:t}}case _D:{let t=this.mintedContinuationId(_D,this.currentMessageId);return this.currentMessageId=null,this.warn(_D,A.REASONING_MESSAGE_END),{...e,type:A.REASONING_MESSAGE_END,messageId:t}}case mD:{let t=this.mintedContinuationId(mD,this.currentReasoningId);return this.currentReasoningId=null,this.warn(mD,A.REASONING_END),{...e,type:A.REASONING_END,messageId:t}}case A.RUN_FINISHED:{let n=e,r=SD(n.outcome,yD[`RUN_FINISHED.outcome`],`RUN_FINISHED.outcome`,t);return CD(r===n.outcome?n:{...n,outcome:r},`usage`,e=>SD(e,yD[`RUN_FINISHED.usage[]`],`RUN_FINISHED.usage[]`,t))}case A.MESSAGES_SNAPSHOT:{let t=e;return Array.isArray(t.messages)?{...t,messages:t.messages.map(e=>this.upgradeInboundMessage(e))}:e}case A.RUN_STARTED:{let n=TD(e.input,t),r=n===e.input?e:{...e,input:n},i=r;return!i.input||!Array.isArray(i.input.messages)?r:{...i,input:{...i.input,messages:i.input.messages.map(e=>this.upgradeInboundMessage(e))}}}default:return e}}upgradeInboundMessage(e){e=wD(e,this.noticeNullOncePerRun);let t=e.content;return!Array.isArray(t)||!t.some(e=>typeof e==`object`&&!!e&&e.type===`binary`)?e:(this.warn(`binary input content`,`the modern media content parts`),fD(e))}},DD=()=>e=>fl(()=>{let t=new ED;return e.pipe(sl(e=>t.transformEvent(e)))});function OD(e,t=new Date){return e.expiresAt!==void 0&&new Date(e.expiresAt)<=t}function kD(){return typeof process<`u`&&!!{}.SUPPRESS_TRANSFORMATION_WARNINGS}function AD(e){kD()||console.warn(`[ag-ui][compat] Flattening message content for a <=0.0.39 peer DROPS non-text parts (${e.join(`, `)}). The peer cannot receive them; upgrade it to keep media content. See the repo-root DEPRECATIONS.md.`)}function jD(e){kD()||console.warn(`[ag-ui][compat] Not flattening message content for a <=0.0.39 peer: ${e} content part(s) claim type "text" but carry a malformed 'text' value. That is a defect in the message, not media the peer cannot represent, and a downgrade must not repair it — the content is passed on unchanged so the outgoing enforcement boundary reports it. See the repo-root DEPRECATIONS.md.`)}function MD(e){let t=e.content;if(Array.isArray(t)){let n=e=>typeof e==`object`&&!!e&&`type`in e&&e.type===`text`,r=e=>n(e)&&typeof e.text==`string`,i=t.filter(e=>n(e)&&!r(e));if(i.length>0)return jD(i.length),e;let a=t.filter(e=>!r(e)).map(e=>typeof e==`object`&&e&&`type`in e?String(e.type):typeof e);a.length>0&&AD(a);let o=t.filter(r).map(e=>e.text).join(``);return{...e,content:o}}return typeof t==`string`?e:t===void 0?{...e,content:``}:e}var ND=class extends oD{run(e,t){let{parentRunId:n,...r}=e,i={...r,messages:r.messages.map(MD)};return this.runNext(i,t)}},PD=`THINKING_START`,FD=`THINKING_END`,ID=`THINKING_TEXT_MESSAGE_START`,LD=`THINKING_TEXT_MESSAGE_CONTENT`,RD=`THINKING_TEXT_MESSAGE_END`,zD=class extends oD{constructor(...e){super(...e),this.currentReasoningId=null,this.currentMessageId=null}warnAboutTransformation(e,t){typeof process<`u`&&{}.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(`AG-UI is converting ${e} to ${t}. To remove this warning, upgrade your AG-UI integration package (e.g. @ag-ui/langgraph). To surpress it, set SUPPRESS_TRANSFORMATION_WARNINGS=true in your .env file.`)}run(e,t){return this.currentReasoningId=null,this.currentMessageId=null,this.runNext(e,t).pipe(sl(e=>this.transformEvent(e)))}transformEvent(e){switch(e.type){case PD:{this.currentReasoningId=iE();let{title:t,...n}=e;return this.warnAboutTransformation(PD,A.REASONING_START),{...n,type:A.REASONING_START,messageId:this.currentReasoningId}}case ID:return this.currentMessageId=iE(),this.warnAboutTransformation(ID,A.REASONING_MESSAGE_START),{...e,type:A.REASONING_MESSAGE_START,messageId:this.currentMessageId,role:`reasoning`};case LD:{let{delta:t,...n}=e;return this.warnAboutTransformation(LD,A.REASONING_MESSAGE_CONTENT),{...n,type:A.REASONING_MESSAGE_CONTENT,messageId:this.currentMessageId??iE(),delta:t}}case RD:{let t=this.currentMessageId??iE();return this.warnAboutTransformation(RD,A.REASONING_MESSAGE_END),{...e,type:A.REASONING_MESSAGE_END,messageId:t}}case FD:{let t=this.currentReasoningId??iE();return this.warnAboutTransformation(FD,A.REASONING_END),{...e,type:A.REASONING_END,messageId:t}}default:return e}}},BD=`SUBAGENT_STARTED`,VD=`SUBAGENT_FINISHED`,HD=`SUBAGENT_ERROR`;function UD(e){if(e&&typeof e==`object`&&`subagentRunId`in e){let{subagentRunId:t,...n}=e;return n}return e}function WD(e){return e.map(e=>UD(e))}var GD=class extends oD{warnDroppedLifecycleEvent(e){typeof process<`u`&&{}.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(`AG-UI is dropping ${e} because the target agent predates subagent support. To remove this warning, upgrade your AG-UI integration package. To suppress it, set SUPPRESS_TRANSFORMATION_WARNINGS=true in your .env file.`)}run(e,t){let n={...e,messages:(e.messages??[]).map(e=>UD(e))};return this.runNext(n,t).pipe(Sl(e=>{let t=e.type;(t===BD||t===VD||t===HD)&&this.warnDroppedLifecycleEvent(t)}),pl(e=>{let t=e.type;return t!==BD&&t!==VD&&t!==HD}),sl(e=>{let t=UD(e);if(t.type===A.MESSAGES_SNAPSHOT){let e=t;if(Array.isArray(e.messages))return{...e,messages:WD(e.messages)}}if(t.type===A.RUN_FINISHED){let e=t;if(e.outcome&&Array.isArray(e.outcome.interrupts))return{...e,outcome:{...e.outcome,interrupts:e.outcome.interrupts.map(e=>UD(e))}}}if(t.type===A.RUN_STARTED){let e=t;if(e.input&&Array.isArray(e.input.messages))return{...e,input:{...e.input,messages:WD(e.input.messages)}}}return t}))}},KD=`1.0.2`,qD=!1,JD=new WeakSet,YD=(e,t)=>/^\d+\.\d+$/.test(e)?CC(e,t)>0?`newer`:`not-newer`:`uninterpretable`,XD=e=>{let t=e.protocolVersion;if(t!==void 0&&t!==`1.0`)switch(YD(t,`1.0`)){case`uninterpretable`:console.warn(`[ag-ui] The producer declared protocol version '${t}', which this client cannot interpret.`);return;case`newer`:console.warn(`[ag-ui] The producer speaks protocol ${t}; this client speaks 1.0. Unrecognised material will be stripped with warnings.`);return;case`not-newer`:return}},ZD=class e{resolvePeerCeiling(t){if(this.resolvingPeerCeiling)return KD;let n=Object.getOwnPropertyDescriptor(this,`maxVersion`),r=Object.getOwnPropertyDescriptor(this,`maxProtocolVersion`),i=Object.getPrototypeOf(this);for(;i&&i!==e.prototype;)n??=Object.getOwnPropertyDescriptor(i,`maxVersion`),r??=Object.getOwnPropertyDescriptor(i,`maxProtocolVersion`),i=Object.getPrototypeOf(i);if(t===`maxVersion`&&n)return KD;let a=t===`maxProtocolVersion`?n:r;if(!a)return KD;this.resolvingPeerCeiling=!0;try{return a.get?a.get.call(this):a.value}finally{this.resolvingPeerCeiling=!1}}get maxProtocolVersion(){return this.resolvePeerCeiling(`maxProtocolVersion`)}get maxVersion(){return!this.resolvingPeerCeiling&&!qD&&(qD=!0,console.warn(`[ag-ui] AbstractAgent.maxVersion is deprecated — use maxProtocolVersion. Same value; the new name says whose version it is and that it is a ceiling.`)),this.resolvePeerCeiling(`maxVersion`)}get debug(){return this._debug}set debug(e){this._debug=uE(e),this._debugLogger=pE(this._debug)}get debugLogger(){return this._debugLogger}set debugLogger(e){this._debugLogger=typeof e==`boolean`?e?pE(uE(!0)):void 0:e}resolvedCeilingDuringConstruction(){let e=this.maxProtocolVersion;if(typeof e!=`string`||!wC(e))throw new j(`maxProtocolVersion resolved to ${JSON.stringify(e)} during construction, which is not a version this client can compare. A ceiling read from an instance field is not available yet — return a literal from the getter.`);return e}constructor({agentId:e,description:t,threadId:n,initialMessages:r,initialState:i,debug:a}={}){this.subscribers=[],this.isRunning=!1,this.pendingInterrupts=[],this.middlewares=[],this.resolvingPeerCeiling=!1,this.agentId=e,this.description=t??``,this.threadId=n??Po(),this.messages=rE(r??[]),this.state=rE(i??{}),this._debug=uE(a),this._debugLogger=pE(this._debug);let o=this.resolvedCeilingDuringConstruction();CC(o,`0.0.39`)<=0&&this.middlewares.unshift(new ND),CC(o,`0.0.45`)<=0&&this.middlewares.unshift(new zD),CC(o,`0.0.57`)<=0&&this.middlewares.unshift(new GD)}subscribe(e){return this.subscribers.push(e),{unsubscribe:()=>{this.subscribers=this.subscribers.filter(t=>t!==e)}}}use(...e){let t=e.map(e=>typeof e==`function`?new sD(e):e);return this.middlewares.push(...t),this}async runAgent(e,t){try{this.isRunning=!0,this.agentId=this.agentId??Po();let n=this.prepareRunAgentInput(e);this.debugLogger?.lifecycle(`LIFECYCLE`,`Run started:`,{agentId:this.agentId,threadId:this.threadId});let r,i=new Set(this.messages.map(e=>e.id)),a=[{onRunStartedEvent:({event:e})=>XD(e),onRunFinishedEvent:e=>{e.outcome===`success`&&(r=e.result)}},...this.subscribers,t??{}];JD.add(n),await this.onInitialize(n,a),this.activeRunDetach$=new xc;let o;this.activeRunCompletionPromise=new Promise(e=>{o=e}),await ol(uc(()=>[...this.middlewares,new ED].reduceRight((e,t)=>({run:n=>t.run(n,e),get messages(){return e.messages},get state(){return e.state}}),this).run(n),iD(this.debugLogger),GE(this.debugLogger),vE(this.debugLogger),e=>e.pipe(xl(this.activeRunDetach$)),e=>this.applyBeforeSourceError(n,e,a),ml(e=>(this.debugLogger?.lifecycle(`LIFECYCLE`,`Run errored:`,{agentId:this.agentId,error:e instanceof Error?e.message:String(e)}),this.isRunning=!1,this.onError(n,e,a))),yl(()=>{this.debugLogger?.lifecycle(`LIFECYCLE`,`Run finished:`,{agentId:this.agentId,threadId:this.threadId}),this.isRunning=!1,this.onFinalize(n,a),o?.(),o=void 0,this.activeRunCompletionPromise=void 0,this.activeRunDetach$=void 0}))(il(null)));let s=rE(this.messages).filter(e=>!i.has(e.id));return{result:r,newMessages:s}}finally{this.isRunning=!1}}connect(e){throw new zo}async connectAgent(e,t){try{this.isRunning=!0,this.agentId=this.agentId??Po();let n=this.prepareRunAgentInput(e),r,i=new Set(this.messages.map(e=>e.id)),a=[{onRunStartedEvent:({event:e})=>XD(e),onRunFinishedEvent:e=>{e.outcome===`success`&&(r=e.result)}},...this.subscribers,t??{}];await this.onInitialize(n,a),this.activeRunDetach$=new xc;let o;this.activeRunCompletionPromise=new Promise(e=>{o=e}),await ol(uc(()=>fl(()=>this.connect(n)),e=>iD(this.debugLogger)(DD()(e)),GE(this.debugLogger),vE(this.debugLogger),e=>e.pipe(xl(this.activeRunDetach$)),e=>this.applyBeforeSourceError(n,e,a),ml(e=>(this.isRunning=!1,e instanceof zo?Tc:this.onError(n,e,a))),yl(()=>{this.isRunning=!1,this.onFinalize(n,a),o?.(),o=void 0,this.activeRunCompletionPromise=void 0,this.activeRunDetach$=void 0}))(il(null)),{defaultValue:void 0});let s=rE(this.messages).filter(e=>!i.has(e.id));return{result:r,newMessages:s}}finally{this.isRunning=!1}}abortRun(){}async detachActiveRun(){if(!this.activeRunDetach$)return;let e=this.activeRunCompletionPromise??Promise.resolve();this.activeRunDetach$.next(),this.activeRunDetach$?.complete(),await e}applyBeforeSourceError(e,t,n){return fl(()=>{let r,i=t.pipe(ml(e=>(r={error:e},Tc)));return this.processApplyEvents(e,this.apply(e,i,n),n).pipe(_l(fl(()=>{let e=r;return e?N(()=>e.error):Tc})))})}apply(e,t,n){return gE(e,t,this,n,this.debugLogger)}processApplyEvents(e,t,n){return t.pipe(Sl(t=>{t.messages&&(this.messages=t.messages,n.forEach(t=>{t.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),t.state!==void 0&&(this.state=t.state,n.forEach(t=>{t.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})}))}))}prepareRunAgentInput(e){let t=rE(this.messages);for(let e of t)e.subagentRunId===null&&delete e.subagentRunId;let n=t.filter(e=>e.role!==`activity`);return{threadId:this.threadId,runId:e?.runId||Po(),...CC(this.maxProtocolVersion,KD)>=0&&{protocolVersion:`1.0`},tools:rE(e?.tools??[]),context:rE(e?.context??[]),forwardedProps:rE(e?.forwardedProps??{}),state:rE(this.state),messages:n,...e?.resume===void 0?{}:{resume:rE(e.resume)}}}async onInitialize(e,t){if(JD.has(e)&&this.pendingInterrupts.length>0){let t=new Set((e.resume??[]).map(e=>e.interruptId)),n=this.pendingInterrupts.map(e=>e.id).filter(e=>!t.has(e));if(n.length>0)throw new j(`Thread has ${n.length} pending interrupt(s) not addressed by resume: ${n.join(`, `)}`);for(let t of this.pendingInterrupts)if(OD(t)&&(e.resume??[]).find(e=>e.interruptId===t.id)?.status!==`cancelled`)throw new j(`Interrupt ${t.id} expired at ${t.expiresAt} and can no longer be answered. Cancel it to continue the thread.`)}let n=await lE(t,this.messages,this.state,(t,n,r)=>t.onRunInitialized?.({messages:n,state:r,agent:this,input:e}));if(n.messages!==void 0||n.state!==void 0){if(n.messages){this.messages=n.messages;for(let e of n.messages)e.subagentRunId===null&&delete e.subagentRunId;e.messages=n.messages.filter(e=>e.role!==`activity`),t.forEach(t=>{t.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})}n.state!==void 0&&(this.state=n.state,e.state=n.state,t.forEach(t=>{t.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})}))}}onError(e,t,n){return rl(lE(n,this.messages,this.state,(n,r,i)=>n.onRunFailed?.({error:t,messages:r,state:i,agent:this,input:e}))).pipe(sl(r=>{let i=r;if((i.messages!==void 0||i.state!==void 0)&&(i.messages!==void 0&&(this.messages=i.messages,n.forEach(t=>{t.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),i.state!==void 0&&(this.state=i.state,n.forEach(t=>{t.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})}))),i.stopPropagation!==!0){let e=String(t);if(t.name!==`AbortError`&&t.message!==`Fetch is aborted`&&t.message!==`signal is aborted without reason`&&t.message!==`component unmounted`&&e!==`component unmounted`)throw console.error(`Agent execution failed:`,t),t}return{}}))}async onFinalize(e,t){let n=await lE(t,this.messages,this.state,(t,n,r)=>t.onRunFinalized?.({messages:n,state:r,agent:this,input:e}));(n.messages!==void 0||n.state!==void 0)&&(n.messages!==void 0&&(this.messages=n.messages,t.forEach(t=>{t.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),n.state!==void 0&&(this.state=n.state,t.forEach(t=>{t.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})})))}clone(){let e=Object.create(Object.getPrototypeOf(this));return e.agentId=this.agentId,e.description=this.description,e.threadId=this.threadId,e.messages=rE(this.messages),e.state=rE(this.state),e._debug=this._debug,e._debugLogger=this._debugLogger,e.isRunning=this.isRunning,e.subscribers=[...this.subscribers],e.middlewares=[...this.middlewares],e.pendingInterrupts=rE(this.pendingInterrupts),e}addMessage(e){this.messages.push(e),(async()=>{for(let t of this.subscribers)await t.onNewMessage?.({message:e,messages:this.messages,state:this.state,agent:this});if(e.role===`assistant`&&e.toolCalls)for(let t of e.toolCalls)for(let e of this.subscribers)await e.onNewToolCall?.({toolCall:t,messages:this.messages,state:this.state,agent:this});for(let e of this.subscribers)await e.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}addMessages(e){this.messages.push(...e),(async()=>{for(let t of e){for(let e of this.subscribers)await e.onNewMessage?.({message:t,messages:this.messages,state:this.state,agent:this});if(t.role===`assistant`&&t.toolCalls)for(let e of t.toolCalls)for(let t of this.subscribers)await t.onNewToolCall?.({toolCall:e,messages:this.messages,state:this.state,agent:this})}for(let e of this.subscribers)await e.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}setMessages(e){this.messages=rE(e),(async()=>{for(let e of this.subscribers)await e.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}setState(e){this.state=rE(e),(async()=>{for(let e of this.subscribers)await e.onStateChanged?.({messages:this.messages,state:this.state,agent:this})})()}legacy_to_be_removed_runAgentBridged(e){this.agentId=this.agentId??Po();let t=this.prepareRunAgentInput(e);return[...this.middlewares,new ED].reduceRight((e,t)=>({run:n=>t.run(n,e),get messages(){return e.messages},get state(){return e.state}}),this).run(t).pipe(iD(this.debugLogger),GE(this.debugLogger),vE(this.debugLogger),jE(this.threadId,t.runId,this.agentId),e=>e.pipe(sl(e=>(this.debugLogger?.event(`LEGACY`,`Event:`,e,{type:e.type}),e))))}};function QD(e){if(!Array.isArray(e.messages))return e;let t=!1,n=e.messages.map(e=>{if(e.subagentRunId===null){t=!0;let n={...e};return delete n.subagentRunId,n}return e});return t?{...e,messages:n}:e}var $D=class extends ZD{requestInit(e){return{method:`POST`,headers:{...this.headers,"Content-Type":`application/json`,Accept:`text/event-stream`},body:JSON.stringify(QD(e)),signal:this.abortController.signal}}runAgent(e,t){return this.abortController=e?.abortController??new AbortController,super.runAgent(e,t)}abortRun(){this.abortController.abort(),super.abortRun()}constructor(e){super(e),this.abortController=new AbortController,this.url=e.url,this.headers=rE(e.headers??{}),this.fetch=e.fetch??((e,t)=>fetch(e,t))}run(e){return EE(bE(()=>this.fetch(this.url,this.requestInit(aD(e)))),this.debugLogger)}clone(){let e=super.clone();e.url=this.url,e.headers=rE(this.headers??{}),e.fetch=this.fetch;let t=new AbortController,n=this.abortController.signal;return n.aborted&&t.abort(n.reason),e.abortController=t,e}},eO=class extends Yt{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type=`infinite`,super.setOptions(e)}getOptimisticResult(e){return e._type=`infinite`,super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`forward`}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:`backward`}}})}createResult(e,t){let{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,c=n.fetchMeta?.fetchMore?.direction,l=o&&c===`forward`,u=i&&c===`forward`,d=o&&c===`backward`,f=i&&c===`backward`;return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:ln(t,n.data),hasPreviousPage:Zt(t,n.data),isFetchNextPageError:l,isFetchingNextPage:u,isFetchPreviousPageError:d,isFetchingPreviousPage:f,isRefetchError:s&&!l&&!d,isRefetching:a&&!u&&!f}}},tO=class extends $t{#e;#t;#n;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}build(e,t,n){let r=new cn({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=nO(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=nO(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=nO(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=nO(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){dn.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>en(t,e))}findAll(e={}){return this.getAll().filter(t=>en(e,t))}notify(e){dn.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return dn.batch(()=>Promise.all(e.map(e=>e.continue().catch(fn))))}};function nO(e){return e.options.scope?.id}var rO=class extends $t{#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){let r=t.queryKey,i=t.queryHash??tn(r,t),a=this.get(i);return a||(a=new on({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){this.#e.get(e.queryHash)===e&&(e.destroy(),this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){dn.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Jt(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>Jt(e,t)):t}notify(e){dn.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){dn.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){dn.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},iO=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new rO,this.#t=e.mutationCache||new tO,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=Qt.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=nn.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Xt(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=sn(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return dn.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;dn.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return dn.batch(()=>{let r=n.findAll(e),i=new Set(r);return r.forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,predicate:e=>i.has(e)},t)})}cancelQueries(e,t={}){let n={revert:!0,...t},r=dn.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(fn).catch(fn)}invalidateQueries(e,t={}){return dn.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=dn.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(fn)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(fn)}async query(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t),r=n.isStaleByTime(Xt(t.staleTime,n))?await n.fetch(t):n.state.data,i=t.select;return i?i(r):r}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(Xt(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(fn).catch(fn)}infiniteQuery(e){return e._type=`infinite`,this.query(e)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(fn).catch(fn)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return nn.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(rn(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{mn(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(rn(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{mn(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=tn(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===Ut&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}};function aO(e,t){return an(e,eO,t)}var oO=new Map([[`bold`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M232,44H160a43.86,43.86,0,0,0-32,13.85A43.86,43.86,0,0,0,96,44H24A12,12,0,0,0,12,56V200a12,12,0,0,0,12,12H96a20,20,0,0,1,20,20,12,12,0,0,0,24,0,20,20,0,0,1,20-20h72a12,12,0,0,0,12-12V56A12,12,0,0,0,232,44ZM96,188H36V68H96a20,20,0,0,1,20,20V192.81A43.79,43.79,0,0,0,96,188Zm124,0H160a43.71,43.71,0,0,0-20,4.83V88a20,20,0,0,1,20-20h60Z`}))],[`duotone`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M232,56V200H160a32,32,0,0,0-32,32,32,32,0,0,0-32-32H24V56H96a32,32,0,0,1,32,32,32,32,0,0,1,32-32Z`,opacity:`0.2`}),D.createElement(`path`,{d:`M232,48H160a40,40,0,0,0-32,16A40,40,0,0,0,96,48H24a8,8,0,0,0-8,8V200a8,8,0,0,0,8,8H96a24,24,0,0,1,24,24,8,8,0,0,0,16,0,24,24,0,0,1,24-24h72a8,8,0,0,0,8-8V56A8,8,0,0,0,232,48ZM96,192H32V64H96a24,24,0,0,1,24,24V200A39.81,39.81,0,0,0,96,192Zm128,0H160a39.81,39.81,0,0,0-24,8V88a24,24,0,0,1,24-24h64Z`}))],[`fill`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M240,56V200a8,8,0,0,1-8,8H160a24,24,0,0,0-24,23.94,7.9,7.9,0,0,1-5.12,7.55A8,8,0,0,1,120,232a24,24,0,0,0-24-24H24a8,8,0,0,1-8-8V56a8,8,0,0,1,8-8H88a32,32,0,0,1,32,32v87.73a8.17,8.17,0,0,0,7.47,8.25,8,8,0,0,0,8.53-8V80a32,32,0,0,1,32-32h64A8,8,0,0,1,240,56Z`}))],[`light`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M232,50H160a38,38,0,0,0-32,17.55A38,38,0,0,0,96,50H24a6,6,0,0,0-6,6V200a6,6,0,0,0,6,6H96a26,26,0,0,1,26,26,6,6,0,0,0,12,0,26,26,0,0,1,26-26h72a6,6,0,0,0,6-6V56A6,6,0,0,0,232,50ZM96,194H30V62H96a26,26,0,0,1,26,26V204.31A37.86,37.86,0,0,0,96,194Zm130,0H160a37.87,37.87,0,0,0-26,10.32V88a26,26,0,0,1,26-26h66Z`}))],[`regular`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M232,48H160a40,40,0,0,0-32,16A40,40,0,0,0,96,48H24a8,8,0,0,0-8,8V200a8,8,0,0,0,8,8H96a24,24,0,0,1,24,24,8,8,0,0,0,16,0,24,24,0,0,1,24-24h72a8,8,0,0,0,8-8V56A8,8,0,0,0,232,48ZM96,192H32V64H96a24,24,0,0,1,24,24V200A39.81,39.81,0,0,0,96,192Zm128,0H160a39.81,39.81,0,0,0-24,8V88a24,24,0,0,1,24-24h64Z`}))],[`thin`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M232,52H160a36,36,0,0,0-32,19.54A36,36,0,0,0,96,52H24a4,4,0,0,0-4,4V200a4,4,0,0,0,4,4H96a28,28,0,0,1,28,28,4,4,0,0,0,8,0,28,28,0,0,1,28-28h72a4,4,0,0,0,4-4V56A4,4,0,0,0,232,52ZM96,196H28V60H96a28,28,0,0,1,28,28V209.4A35.93,35.93,0,0,0,96,196Zm132,0H160a35.94,35.94,0,0,0-28,13.41V88a28,28,0,0,1,28-28h68Z`}))]]),sO=new Map([[`bold`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M232.49,215.51,185,168a92.12,92.12,0,1,0-17,17l47.53,47.54a12,12,0,0,0,17-17ZM44,112a68,68,0,1,1,68,68A68.07,68.07,0,0,1,44,112Z`}))],[`duotone`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M192,112a80,80,0,1,1-80-80A80,80,0,0,1,192,112Z`,opacity:`0.2`}),D.createElement(`path`,{d:`M229.66,218.34,179.6,168.28a88.21,88.21,0,1,0-11.32,11.31l50.06,50.07a8,8,0,0,0,11.32-11.32ZM40,112a72,72,0,1,1,72,72A72.08,72.08,0,0,1,40,112Z`}))],[`fill`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M168,112a56,56,0,1,1-56-56A56,56,0,0,1,168,112Zm61.66,117.66a8,8,0,0,1-11.32,0l-50.06-50.07a88,88,0,1,1,11.32-11.31l50.06,50.06A8,8,0,0,1,229.66,229.66ZM112,184a72,72,0,1,0-72-72A72.08,72.08,0,0,0,112,184Z`}))],[`light`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M228.24,219.76l-51.38-51.38a86.15,86.15,0,1,0-8.48,8.48l51.38,51.38a6,6,0,0,0,8.48-8.48ZM38,112a74,74,0,1,1,74,74A74.09,74.09,0,0,1,38,112Z`}))],[`regular`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M229.66,218.34l-50.07-50.06a88.11,88.11,0,1,0-11.31,11.31l50.06,50.07a8,8,0,0,0,11.32-11.32ZM40,112a72,72,0,1,1,72,72A72.08,72.08,0,0,1,40,112Z`}))],[`thin`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M226.83,221.17l-52.7-52.7a84.1,84.1,0,1,0-5.66,5.66l52.7,52.7a4,4,0,0,0,5.66-5.66ZM36,112a76,76,0,1,1,76,76A76.08,76.08,0,0,1,36,112Z`}))]]),cO=new Map([[`bold`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M236.37,139.4a12,12,0,0,0-12-3A84.07,84.07,0,0,1,119.6,31.59a12,12,0,0,0-15-15A108.86,108.86,0,0,0,49.69,55.07,108,108,0,0,0,136,228a107.09,107.09,0,0,0,64.93-21.69,108.86,108.86,0,0,0,38.44-54.94A12,12,0,0,0,236.37,139.4Zm-49.88,47.74A84,84,0,0,1,68.86,69.51,84.93,84.93,0,0,1,92.27,48.29Q92,52.13,92,56A108.12,108.12,0,0,0,200,164q3.87,0,7.71-.27A84.79,84.79,0,0,1,186.49,187.14Z`}))],[`duotone`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M227.89,147.89A96,96,0,1,1,108.11,28.11,96.09,96.09,0,0,0,227.89,147.89Z`,opacity:`0.2`}),D.createElement(`path`,{d:`M233.54,142.23a8,8,0,0,0-8-2,88.08,88.08,0,0,1-109.8-109.8,8,8,0,0,0-10-10,104.84,104.84,0,0,0-52.91,37A104,104,0,0,0,136,224a103.09,103.09,0,0,0,62.52-20.88,104.84,104.84,0,0,0,37-52.91A8,8,0,0,0,233.54,142.23ZM188.9,190.34A88,88,0,0,1,65.66,67.11a89,89,0,0,1,31.4-26A106,106,0,0,0,96,56,104.11,104.11,0,0,0,200,160a106,106,0,0,0,14.92-1.06A89,89,0,0,1,188.9,190.34Z`}))],[`fill`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M235.54,150.21a104.84,104.84,0,0,1-37,52.91A104,104,0,0,1,32,120,103.09,103.09,0,0,1,52.88,57.48a104.84,104.84,0,0,1,52.91-37,8,8,0,0,1,10,10,88.08,88.08,0,0,0,109.8,109.8,8,8,0,0,1,10,10Z`}))],[`light`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M232.13,143.64a6,6,0,0,0-6-1.49A90.07,90.07,0,0,1,113.86,29.85a6,6,0,0,0-7.49-7.48A102.88,102.88,0,0,0,54.48,58.68,102,102,0,0,0,197.32,201.52a102.88,102.88,0,0,0,36.31-51.89A6,6,0,0,0,232.13,143.64Zm-42,48.29a90,90,0,0,1-126-126A90.9,90.9,0,0,1,99.65,37.66,102.06,102.06,0,0,0,218.34,156.35,90.9,90.9,0,0,1,190.1,191.93Z`}))],[`regular`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M233.54,142.23a8,8,0,0,0-8-2,88.08,88.08,0,0,1-109.8-109.8,8,8,0,0,0-10-10,104.84,104.84,0,0,0-52.91,37A104,104,0,0,0,136,224a103.09,103.09,0,0,0,62.52-20.88,104.84,104.84,0,0,0,37-52.91A8,8,0,0,0,233.54,142.23ZM188.9,190.34A88,88,0,0,1,65.66,67.11a89,89,0,0,1,31.4-26A106,106,0,0,0,96,56,104.11,104.11,0,0,0,200,160a106,106,0,0,0,14.92-1.06A89,89,0,0,1,188.9,190.34Z`}))],[`thin`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M230.72,145.06a4,4,0,0,0-4-1A92.08,92.08,0,0,1,111.94,29.27a4,4,0,0,0-5-5A100.78,100.78,0,0,0,56.08,59.88a100,100,0,0,0,140,140,100.78,100.78,0,0,0,35.59-50.87A4,4,0,0,0,230.72,145.06ZM191.3,193.53A92,92,0,0,1,62.47,64.7a93,93,0,0,1,39.88-30.35,100.09,100.09,0,0,0,119.3,119.3A93,93,0,0,1,191.3,193.53Z`}))]]),lO=new Map([[`bold`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M240.49,15.51a12,12,0,0,0-17,0L173.94,65.09l-2.54-2.55a36.05,36.05,0,0,0-50.91,0L100,83l-3.51-3.52a12,12,0,0,0-17,17L83,100,62.54,120.49a36,36,0,0,0,0,50.91l2.55,2.54L15.51,223.51a12,12,0,0,0,17,17l49.57-49.58,2.54,2.55a36.06,36.06,0,0,0,50.91,0L156,173l3.51,3.52a12,12,0,0,0,17-17L173,156l20.49-20.49a36,36,0,0,0,0-50.91l-2.55-2.54,49.58-49.57A12,12,0,0,0,240.49,15.51Zm-121.95,161a12,12,0,0,1-17,0L79.51,154.43a12,12,0,0,1,0-17L100,117l39,39Zm58-57.95h0L156,139l-39-39,20.49-20.49a12,12,0,0,1,17,0l22.06,22.06a12,12,0,0,1,0,17ZM85.27,33.37a12,12,0,0,1,21.46-10.74l8,16A12,12,0,1,1,93.27,49.37Zm-68,57.26a12,12,0,0,1,16.1-5.36l16,8a12,12,0,1,1-10.74,21.46l-16-8A12,12,0,0,1,17.27,90.63Zm221.46,74.74a12,12,0,0,1-16.1,5.36l-16-8a12,12,0,0,1,10.74-21.46l16,8A12,12,0,0,1,238.73,165.37Zm-68,57.26a12,12,0,1,1-21.46,10.74l-8-16a12,12,0,0,1,21.46-10.74Z`}))],[`duotone`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M185,127,127,185a24,24,0,0,1-33.94,0L71,162.91A24,24,0,0,1,71,129L129,71a24,24,0,0,1,33.94,0L185,93.09A24,24,0,0,1,185,127Z`,opacity:`0.2`}),D.createElement(`path`,{d:`M237.66,18.34a8,8,0,0,0-11.32,0l-52.4,52.41-5.37-5.38a32.05,32.05,0,0,0-45.26,0L100,88.69l-6.34-6.35A8,8,0,0,0,82.34,93.66L88.69,100,65.37,123.31a32,32,0,0,0,0,45.26l5.38,5.37-52.41,52.4a8,8,0,0,0,11.32,11.32l52.4-52.41,5.37,5.38a32.06,32.06,0,0,0,45.26,0L156,167.31l6.34,6.35a8,8,0,0,0,11.32-11.32L167.31,156l23.32-23.31a32,32,0,0,0,0-45.26l-5.38-5.37,52.41-52.4A8,8,0,0,0,237.66,18.34Zm-116.29,161a16,16,0,0,1-22.62,0L76.69,157.25a16,16,0,0,1,0-22.62L100,111.31,144.69,156Zm57.94-57.94h0L156,144.69,111.31,100l23.32-23.31a16,16,0,0,1,22.62,0l22.06,22a16,16,0,0,1,0,22.63ZM88.57,35A8,8,0,0,1,103.43,29l8,20A8,8,0,0,1,96.57,55ZM24.57,93A8,8,0,0,1,35,88.57l20,8A8,8,0,0,1,49,111.43l-20-8A8,8,0,0,1,24.57,93ZM231.43,163a8,8,0,0,1-10.4,4.46l-20-8A8,8,0,1,1,207,144.57l20,8A8,8,0,0,1,231.43,163Zm-64,58.06A8,8,0,0,1,152.57,227l-8-20A8,8,0,0,1,159.43,201Z`}))],[`fill`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M88.57,35A8,8,0,0,1,103.43,29l8,20A8,8,0,0,1,96.57,55ZM29,103.43l20,8A8,8,0,1,0,55,96.57l-20-8A8,8,0,0,0,29,103.43ZM227,152.57l-20-8A8,8,0,1,0,201,159.43l20,8A8,8,0,0,0,227,152.57ZM159.43,201A8,8,0,0,0,144.57,207l8,20A8,8,0,1,0,167.43,221ZM237.91,18.52a8,8,0,0,0-11.5-.18L174,70.75l-5.38-5.38a32,32,0,0,0-45.28,0L106.14,82.54a4,4,0,0,0,0,5.66l61.7,61.66a4,4,0,0,0,5.66,0l16.74-16.74a32.76,32.76,0,0,0,9.81-22.52,31.82,31.82,0,0,0-9.37-23.17l-5.38-5.37,52.2-52.17A8.22,8.22,0,0,0,237.91,18.52ZM85.64,90.34a8,8,0,0,0-11.49.18,8.22,8.22,0,0,0,.41,11.37L80.67,108,65.34,123.31A31.82,31.82,0,0,0,56,146.47,32.75,32.75,0,0,0,65.77,169l5,4.94L18.49,226.13a8.21,8.21,0,0,0-.61,11.1,8,8,0,0,0,11.72.43L82,185.25l5.37,5.38a32.1,32.1,0,0,0,45.29,0L148,175.31l6.34,6.35a8,8,0,0,0,11.32-11.32Z`}))],[`light`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M236.24,19.76a6,6,0,0,0-8.48,0L173.94,73.57l-6.79-6.78a30,30,0,0,0-42.42,0L100,91.51l-7.76-7.75a6,6,0,0,0-8.48,8.48L91.51,100,66.79,124.73a30,30,0,0,0,0,42.42l6.78,6.79L19.76,227.76a6,6,0,1,0,8.48,8.48l53.82-53.81,6.79,6.78a30,30,0,0,0,42.42,0L156,164.49l7.76,7.75a6,6,0,0,0,8.48-8.48L164.49,156l24.72-24.73a30,30,0,0,0,0-42.42l-6.78-6.79,53.81-53.82A6,6,0,0,0,236.24,19.76Zm-113.45,161a18,18,0,0,1-25.46,0L75.27,158.67a18,18,0,0,1,0-25.46L100,108.49,147.51,156Zm57.94-57.94L156,147.51,108.49,100l24.72-24.73a18,18,0,0,1,25.46,0l22.06,22.06a18,18,0,0,1,0,25.46ZM90.43,34.23a6,6,0,0,1,11.14-4.46l8,20a6,6,0,1,1-11.14,4.46Zm-64,59.54a6,6,0,0,1,7.8-3.34l20,8a6,6,0,1,1-4.46,11.14l-20-8A6,6,0,0,1,26.43,93.77Zm203.14,68.46a6,6,0,0,1-7.8,3.34l-20-8a6,6,0,0,1,4.46-11.14l20,8A6,6,0,0,1,229.57,162.23Zm-64,59.54a6,6,0,1,1-11.14,4.46l-8-20a6,6,0,0,1,11.14-4.46Z`}))],[`regular`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M237.66,18.34a8,8,0,0,0-11.32,0l-52.4,52.41-5.37-5.38a32.05,32.05,0,0,0-45.26,0L100,88.69l-6.34-6.35A8,8,0,0,0,82.34,93.66L88.69,100,65.37,123.31a32,32,0,0,0,0,45.26l5.38,5.37-52.41,52.4a8,8,0,0,0,11.32,11.32l52.4-52.41,5.37,5.38a32,32,0,0,0,45.26,0L156,167.31l6.34,6.35a8,8,0,0,0,11.32-11.32L167.31,156l23.32-23.31a32,32,0,0,0,0-45.26l-5.38-5.37,52.41-52.4A8,8,0,0,0,237.66,18.34Zm-116.29,161a16,16,0,0,1-22.62,0L76.69,157.25a16,16,0,0,1,0-22.62L100,111.31,144.69,156Zm57.94-57.94L156,144.69,111.31,100l23.32-23.31a16,16,0,0,1,22.62,0l22.06,22A16,16,0,0,1,179.31,121.37ZM88.57,35A8,8,0,0,1,103.43,29l8,20A8,8,0,0,1,96.57,55ZM24.57,93A8,8,0,0,1,35,88.57l20,8A8,8,0,0,1,49,111.43l-20-8A8,8,0,0,1,24.57,93ZM231.43,163a8,8,0,0,1-10.4,4.46l-20-8A8,8,0,1,1,207,144.57l20,8A8,8,0,0,1,231.43,163Zm-64,58.06A8,8,0,0,1,152.57,227l-8-20A8,8,0,0,1,159.43,201Z`}))],[`thin`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M234.83,21.17a4,4,0,0,0-5.66,0L173.94,76.4l-8.2-8.2a28,28,0,0,0-39.6,0L100,94.34l-9.17-9.17a4,4,0,0,0-5.66,5.66L94.34,100,68.2,126.14a28,28,0,0,0,0,39.6l8.2,8.2L21.17,229.17a4,4,0,0,0,5.66,5.66L82.06,179.6l8.2,8.2a28,28,0,0,0,39.6,0L156,161.66l9.17,9.17a4,4,0,0,0,5.66-5.66L161.66,156l26.14-26.14a28,28,0,0,0,0-39.6l-8.2-8.2,55.23-55.23A4,4,0,0,0,234.83,21.17Zm-110.63,161a20,20,0,0,1-28.28,0L73.86,160.08a20,20,0,0,1,0-28.28L100,105.66,150.34,156Zm57.94-57.94L156,150.34,105.66,100,131.8,73.86a20,20,0,0,1,28.28,0l22.06,22.06A20,20,0,0,1,182.14,124.2ZM92.29,33.49a4,4,0,1,1,7.42-3l8,20a4,4,0,0,1-2.22,5.2A3.91,3.91,0,0,1,104,56a4,4,0,0,1-3.71-2.51Zm-64,61a4,4,0,0,1,5.2-2.22l20,8A4,4,0,0,1,52,108a3.91,3.91,0,0,1-1.49-.29l-20-8A4,4,0,0,1,28.29,94.51Zm199.42,67A4,4,0,0,1,224,164a3.91,3.91,0,0,1-1.49-.29l-20-8a4,4,0,1,1,3-7.42l20,8A4,4,0,0,1,227.71,161.49Zm-64,61a4,4,0,0,1-2.22,5.2A3.91,3.91,0,0,1,160,228a4,4,0,0,1-3.71-2.51l-8-20a4,4,0,0,1,7.42-3Z`}))]]),uO=new Map([[`bold`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M228,128a12,12,0,0,1-12,12H140v76a12,12,0,0,1-24,0V140H40a12,12,0,0,1,0-24h76V40a12,12,0,0,1,24,0v76h76A12,12,0,0,1,228,128Z`}))],[`duotone`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z`,opacity:`0.2`}),D.createElement(`path`,{d:`M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z`}))],[`fill`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM184,136H136v48a8,8,0,0,1-16,0V136H72a8,8,0,0,1,0-16h48V72a8,8,0,0,1,16,0v48h48a8,8,0,0,1,0,16Z`}))],[`light`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M222,128a6,6,0,0,1-6,6H134v82a6,6,0,0,1-12,0V134H40a6,6,0,0,1,0-12h82V40a6,6,0,0,1,12,0v82h82A6,6,0,0,1,222,128Z`}))],[`regular`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z`}))],[`thin`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M220,128a4,4,0,0,1-4,4H132v84a4,4,0,0,1-8,0V132H40a4,4,0,0,1,0-8h84V40a4,4,0,0,1,8,0v84h84A4,4,0,0,1,220,128Z`}))]]),dO=new Map([[`bold`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M124,216a12,12,0,0,1-12,12H48a12,12,0,0,1-12-12V40A12,12,0,0,1,48,28h64a12,12,0,0,1,0,24H60V204h52A12,12,0,0,1,124,216Zm108.49-96.49-40-40a12,12,0,0,0-17,17L195,116H112a12,12,0,0,0,0,24h83l-19.52,19.51a12,12,0,0,0,17,17l40-40A12,12,0,0,0,232.49,119.51Z`}))],[`duotone`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M224,56V200a16,16,0,0,1-16,16H48V40H208A16,16,0,0,1,224,56Z`,opacity:`0.2`}),D.createElement(`path`,{d:`M120,216a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V40a8,8,0,0,1,8-8h64a8,8,0,0,1,0,16H56V208h56A8,8,0,0,1,120,216Zm109.66-93.66-40-40a8,8,0,0,0-11.32,11.32L204.69,120H112a8,8,0,0,0,0,16h92.69l-26.35,26.34a8,8,0,0,0,11.32,11.32l40-40A8,8,0,0,0,229.66,122.34Z`}))],[`fill`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M120,216a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V40a8,8,0,0,1,8-8h64a8,8,0,0,1,0,16H56V208h56A8,8,0,0,1,120,216Zm109.66-93.66-40-40A8,8,0,0,0,176,88v32H112a8,8,0,0,0,0,16h64v32a8,8,0,0,0,13.66,5.66l40-40A8,8,0,0,0,229.66,122.34Z`}))],[`light`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M118,216a6,6,0,0,1-6,6H48a6,6,0,0,1-6-6V40a6,6,0,0,1,6-6h64a6,6,0,0,1,0,12H54V210h58A6,6,0,0,1,118,216Zm110.24-92.24-40-40a6,6,0,0,0-8.48,8.48L209.51,122H112a6,6,0,0,0,0,12h97.51l-29.75,29.76a6,6,0,1,0,8.48,8.48l40-40A6,6,0,0,0,228.24,123.76Z`}))],[`regular`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M120,216a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V40a8,8,0,0,1,8-8h64a8,8,0,0,1,0,16H56V208h56A8,8,0,0,1,120,216Zm109.66-93.66-40-40a8,8,0,0,0-11.32,11.32L204.69,120H112a8,8,0,0,0,0,16h92.69l-26.35,26.34a8,8,0,0,0,11.32,11.32l40-40A8,8,0,0,0,229.66,122.34Z`}))],[`thin`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M116,216a4,4,0,0,1-4,4H48a4,4,0,0,1-4-4V40a4,4,0,0,1,4-4h64a4,4,0,0,1,0,8H52V212h60A4,4,0,0,1,116,216Zm110.83-90.83-40-40a4,4,0,0,0-5.66,5.66L214.34,124H112a4,4,0,0,0,0,8H214.34l-33.17,33.17a4,4,0,0,0,5.66,5.66l40-40A4,4,0,0,0,226.83,125.17Z`}))]]),fO=new Map([[`bold`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M199,125.31l-49.88-18.39L130.69,57a19.92,19.92,0,0,0-37.38,0L74.92,106.92,25,125.31a19.92,19.92,0,0,0,0,37.38l49.88,18.39L93.31,231a19.92,19.92,0,0,0,37.38,0l18.39-49.88L199,162.69a19.92,19.92,0,0,0,0-37.38Zm-63.38,35.16a12,12,0,0,0-7.11,7.11L112,212.28l-16.47-44.7a12,12,0,0,0-7.11-7.11L43.72,144l44.7-16.47a12,12,0,0,0,7.11-7.11L112,75.72l16.47,44.7a12,12,0,0,0,7.11,7.11L180.28,144ZM140,40a12,12,0,0,1,12-12h12V16a12,12,0,0,1,24,0V28h12a12,12,0,0,1,0,24H188V64a12,12,0,0,1-24,0V52H152A12,12,0,0,1,140,40ZM252,88a12,12,0,0,1-12,12h-4v4a12,12,0,0,1-24,0v-4h-4a12,12,0,0,1,0-24h4V72a12,12,0,0,1,24,0v4h4A12,12,0,0,1,252,88Z`}))],[`duotone`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M194.82,151.43l-55.09,20.3-20.3,55.09a7.92,7.92,0,0,1-14.86,0l-20.3-55.09-55.09-20.3a7.92,7.92,0,0,1,0-14.86l55.09-20.3,20.3-55.09a7.92,7.92,0,0,1,14.86,0l20.3,55.09,55.09,20.3A7.92,7.92,0,0,1,194.82,151.43Z`,opacity:`0.2`}),D.createElement(`path`,{d:`M197.58,129.06,146,110l-19-51.62a15.92,15.92,0,0,0-29.88,0L78,110l-51.62,19a15.92,15.92,0,0,0,0,29.88L78,178l19,51.62a15.92,15.92,0,0,0,29.88,0L146,178l51.62-19a15.92,15.92,0,0,0,0-29.88ZM137,164.22a8,8,0,0,0-4.74,4.74L112,223.85,91.78,169A8,8,0,0,0,87,164.22L32.15,144,87,123.78A8,8,0,0,0,91.78,119L112,64.15,132.22,119a8,8,0,0,0,4.74,4.74L191.85,144ZM144,40a8,8,0,0,1,8-8h16V16a8,8,0,0,1,16,0V32h16a8,8,0,0,1,0,16H184V64a8,8,0,0,1-16,0V48H152A8,8,0,0,1,144,40ZM248,88a8,8,0,0,1-8,8h-8v8a8,8,0,0,1-16,0V96h-8a8,8,0,0,1,0-16h8V72a8,8,0,0,1,16,0v8h8A8,8,0,0,1,248,88Z`}))],[`fill`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M208,144a15.78,15.78,0,0,1-10.42,14.94L146,178l-19,51.62a15.92,15.92,0,0,1-29.88,0L78,178l-51.62-19a15.92,15.92,0,0,1,0-29.88L78,110l19-51.62a15.92,15.92,0,0,1,29.88,0L146,110l51.62,19A15.78,15.78,0,0,1,208,144ZM152,48h16V64a8,8,0,0,0,16,0V48h16a8,8,0,0,0,0-16H184V16a8,8,0,0,0-16,0V32H152a8,8,0,0,0,0,16Zm88,32h-8V72a8,8,0,0,0-16,0v8h-8a8,8,0,0,0,0,16h8v8a8,8,0,0,0,16,0V96h8a8,8,0,0,0,0-16Z`}))],[`light`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M196.89,130.94,144.4,111.6,125.06,59.11a13.92,13.92,0,0,0-26.12,0L79.6,111.6,27.11,130.94a13.92,13.92,0,0,0,0,26.12L79.6,176.4l19.34,52.49a13.92,13.92,0,0,0,26.12,0L144.4,176.4l52.49-19.34a13.92,13.92,0,0,0,0-26.12Zm-4.15,14.86-55.08,20.3a6,6,0,0,0-3.56,3.56l-20.3,55.08a1.92,1.92,0,0,1-3.6,0L89.9,169.66a6,6,0,0,0-3.56-3.56L31.26,145.8a1.92,1.92,0,0,1,0-3.6l55.08-20.3a6,6,0,0,0,3.56-3.56l20.3-55.08a1.92,1.92,0,0,1,3.6,0l20.3,55.08a6,6,0,0,0,3.56,3.56l55.08,20.3a1.92,1.92,0,0,1,0,3.6ZM146,40a6,6,0,0,1,6-6h18V16a6,6,0,0,1,12,0V34h18a6,6,0,0,1,0,12H182V64a6,6,0,0,1-12,0V46H152A6,6,0,0,1,146,40ZM246,88a6,6,0,0,1-6,6H230v10a6,6,0,0,1-12,0V94H208a6,6,0,0,1,0-12h10V72a6,6,0,0,1,12,0V82h10A6,6,0,0,1,246,88Z`}))],[`regular`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M197.58,129.06,146,110l-19-51.62a15.92,15.92,0,0,0-29.88,0L78,110l-51.62,19a15.92,15.92,0,0,0,0,29.88L78,178l19,51.62a15.92,15.92,0,0,0,29.88,0L146,178l51.62-19a15.92,15.92,0,0,0,0-29.88ZM137,164.22a8,8,0,0,0-4.74,4.74L112,223.85,91.78,169A8,8,0,0,0,87,164.22L32.15,144,87,123.78A8,8,0,0,0,91.78,119L112,64.15,132.22,119a8,8,0,0,0,4.74,4.74L191.85,144ZM144,40a8,8,0,0,1,8-8h16V16a8,8,0,0,1,16,0V32h16a8,8,0,0,1,0,16H184V64a8,8,0,0,1-16,0V48H152A8,8,0,0,1,144,40ZM248,88a8,8,0,0,1-8,8h-8v8a8,8,0,0,1-16,0V96h-8a8,8,0,0,1,0-16h8V72a8,8,0,0,1,16,0v8h8A8,8,0,0,1,248,88Z`}))],[`thin`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M196.2,132.81l-53.36-19.65L123.19,59.8a11.93,11.93,0,0,0-22.38,0L81.16,113.16,27.8,132.81a11.93,11.93,0,0,0,0,22.38l53.36,19.65,19.65,53.36a11.93,11.93,0,0,0,22.38,0l19.65-53.36,53.36-19.65a11.93,11.93,0,0,0,0-22.38Zm-2.77,14.87L138.35,168a4,4,0,0,0-2.37,2.37l-20.3,55.08a3.92,3.92,0,0,1-7.36,0L88,170.35A4,4,0,0,0,85.65,168l-55.08-20.3a3.92,3.92,0,0,1,0-7.36L85.65,120A4,4,0,0,0,88,117.65l20.3-55.08a3.92,3.92,0,0,1,7.36,0L136,117.65a4,4,0,0,0,2.37,2.37l55.08,20.3a3.92,3.92,0,0,1,0,7.36ZM148,40a4,4,0,0,1,4-4h20V16a4,4,0,0,1,8,0V36h20a4,4,0,0,1,0,8H180V64a4,4,0,0,1-8,0V44H152A4,4,0,0,1,148,40Zm96,48a4,4,0,0,1-4,4H228v12a4,4,0,0,1-8,0V92H208a4,4,0,0,1,0-8h12V72a4,4,0,0,1,8,0V84h12A4,4,0,0,1,244,88Z`}))]]),pO=new Map([[`bold`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M116,36V20a12,12,0,0,1,24,0V36a12,12,0,0,1-24,0Zm80,92a68,68,0,1,1-68-68A68.07,68.07,0,0,1,196,128Zm-24,0a44,44,0,1,0-44,44A44.05,44.05,0,0,0,172,128ZM51.51,68.49a12,12,0,1,0,17-17l-12-12a12,12,0,0,0-17,17Zm0,119-12,12a12,12,0,0,0,17,17l12-12a12,12,0,1,0-17-17ZM196,72a12,12,0,0,0,8.49-3.51l12-12a12,12,0,0,0-17-17l-12,12A12,12,0,0,0,196,72Zm8.49,115.51a12,12,0,0,0-17,17l12,12a12,12,0,0,0,17-17ZM48,128a12,12,0,0,0-12-12H20a12,12,0,0,0,0,24H36A12,12,0,0,0,48,128Zm80,80a12,12,0,0,0-12,12v16a12,12,0,0,0,24,0V220A12,12,0,0,0,128,208Zm108-92H220a12,12,0,0,0,0,24h16a12,12,0,0,0,0-24Z`}))],[`duotone`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M184,128a56,56,0,1,1-56-56A56,56,0,0,1,184,128Z`,opacity:`0.2`}),D.createElement(`path`,{d:`M120,40V16a8,8,0,0,1,16,0V40a8,8,0,0,1-16,0Zm72,88a64,64,0,1,1-64-64A64.07,64.07,0,0,1,192,128Zm-16,0a48,48,0,1,0-48,48A48.05,48.05,0,0,0,176,128ZM58.34,69.66A8,8,0,0,0,69.66,58.34l-16-16A8,8,0,0,0,42.34,53.66Zm0,116.68-16,16a8,8,0,0,0,11.32,11.32l16-16a8,8,0,0,0-11.32-11.32ZM192,72a8,8,0,0,0,5.66-2.34l16-16a8,8,0,0,0-11.32-11.32l-16,16A8,8,0,0,0,192,72Zm5.66,114.34a8,8,0,0,0-11.32,11.32l16,16a8,8,0,0,0,11.32-11.32ZM48,128a8,8,0,0,0-8-8H16a8,8,0,0,0,0,16H40A8,8,0,0,0,48,128Zm80,80a8,8,0,0,0-8,8v24a8,8,0,0,0,16,0V216A8,8,0,0,0,128,208Zm112-88H216a8,8,0,0,0,0,16h24a8,8,0,0,0,0-16Z`}))],[`fill`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M120,40V16a8,8,0,0,1,16,0V40a8,8,0,0,1-16,0Zm8,24a64,64,0,1,0,64,64A64.07,64.07,0,0,0,128,64ZM58.34,69.66A8,8,0,0,0,69.66,58.34l-16-16A8,8,0,0,0,42.34,53.66Zm0,116.68-16,16a8,8,0,0,0,11.32,11.32l16-16a8,8,0,0,0-11.32-11.32ZM192,72a8,8,0,0,0,5.66-2.34l16-16a8,8,0,0,0-11.32-11.32l-16,16A8,8,0,0,0,192,72Zm5.66,114.34a8,8,0,0,0-11.32,11.32l16,16a8,8,0,0,0,11.32-11.32ZM48,128a8,8,0,0,0-8-8H16a8,8,0,0,0,0,16H40A8,8,0,0,0,48,128Zm80,80a8,8,0,0,0-8,8v24a8,8,0,0,0,16,0V216A8,8,0,0,0,128,208Zm112-88H216a8,8,0,0,0,0,16h24a8,8,0,0,0,0-16Z`}))],[`light`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M122,40V16a6,6,0,0,1,12,0V40a6,6,0,0,1-12,0Zm68,88a62,62,0,1,1-62-62A62.07,62.07,0,0,1,190,128Zm-12,0a50,50,0,1,0-50,50A50.06,50.06,0,0,0,178,128ZM59.76,68.24a6,6,0,1,0,8.48-8.48l-16-16a6,6,0,0,0-8.48,8.48Zm0,119.52-16,16a6,6,0,1,0,8.48,8.48l16-16a6,6,0,1,0-8.48-8.48ZM192,70a6,6,0,0,0,4.24-1.76l16-16a6,6,0,0,0-8.48-8.48l-16,16A6,6,0,0,0,192,70Zm4.24,117.76a6,6,0,0,0-8.48,8.48l16,16a6,6,0,0,0,8.48-8.48ZM46,128a6,6,0,0,0-6-6H16a6,6,0,0,0,0,12H40A6,6,0,0,0,46,128Zm82,82a6,6,0,0,0-6,6v24a6,6,0,0,0,12,0V216A6,6,0,0,0,128,210Zm112-88H216a6,6,0,0,0,0,12h24a6,6,0,0,0,0-12Z`}))],[`regular`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M120,40V16a8,8,0,0,1,16,0V40a8,8,0,0,1-16,0Zm72,88a64,64,0,1,1-64-64A64.07,64.07,0,0,1,192,128Zm-16,0a48,48,0,1,0-48,48A48.05,48.05,0,0,0,176,128ZM58.34,69.66A8,8,0,0,0,69.66,58.34l-16-16A8,8,0,0,0,42.34,53.66Zm0,116.68-16,16a8,8,0,0,0,11.32,11.32l16-16a8,8,0,0,0-11.32-11.32ZM192,72a8,8,0,0,0,5.66-2.34l16-16a8,8,0,0,0-11.32-11.32l-16,16A8,8,0,0,0,192,72Zm5.66,114.34a8,8,0,0,0-11.32,11.32l16,16a8,8,0,0,0,11.32-11.32ZM48,128a8,8,0,0,0-8-8H16a8,8,0,0,0,0,16H40A8,8,0,0,0,48,128Zm80,80a8,8,0,0,0-8,8v24a8,8,0,0,0,16,0V216A8,8,0,0,0,128,208Zm112-88H216a8,8,0,0,0,0,16h24a8,8,0,0,0,0-16Z`}))],[`thin`,D.createElement(D.Fragment,null,D.createElement(`path`,{d:`M124,40V16a4,4,0,0,1,8,0V40a4,4,0,0,1-8,0Zm64,88a60,60,0,1,1-60-60A60.07,60.07,0,0,1,188,128Zm-8,0a52,52,0,1,0-52,52A52.06,52.06,0,0,0,180,128ZM61.17,66.83a4,4,0,0,0,5.66-5.66l-16-16a4,4,0,0,0-5.66,5.66Zm0,122.34-16,16a4,4,0,0,0,5.66,5.66l16-16a4,4,0,0,0-5.66-5.66ZM192,68a4,4,0,0,0,2.83-1.17l16-16a4,4,0,1,0-5.66-5.66l-16,16A4,4,0,0,0,192,68Zm2.83,121.17a4,4,0,0,0-5.66,5.66l16,16a4,4,0,0,0,5.66-5.66ZM40,124H16a4,4,0,0,0,0,8H40a4,4,0,0,0,0-8Zm88,88a4,4,0,0,0-4,4v24a4,4,0,0,0,8,0V216A4,4,0,0,0,128,212Zm112-88H216a4,4,0,0,0,0,8h24a4,4,0,0,0,0-8Z`}))]]),mO=D.forwardRef((e,t)=>D.createElement(w,{ref:t,...e,weights:oO}));mO.displayName=`BookOpenIcon`;var hO=mO,gO=D.forwardRef((e,t)=>D.createElement(w,{ref:t,...e,weights:sO}));gO.displayName=`MagnifyingGlassIcon`;var _O=gO,vO=D.forwardRef((e,t)=>D.createElement(w,{ref:t,...e,weights:cO}));vO.displayName=`MoonIcon`;var yO=vO,bO=D.forwardRef((e,t)=>D.createElement(w,{ref:t,...e,weights:lO}));bO.displayName=`PlugsConnectedIcon`;var xO=bO,SO=D.forwardRef((e,t)=>D.createElement(w,{ref:t,...e,weights:uO}));SO.displayName=`PlusIcon`;var CO=SO,wO=D.forwardRef((e,t)=>D.createElement(w,{ref:t,...e,weights:dO}));wO.displayName=`SignOutIcon`;var TO=wO,EO=D.forwardRef((e,t)=>D.createElement(w,{ref:t,...e,weights:fO}));EO.displayName=`SparkleIcon`;var DO=EO,OO=D.forwardRef((e,t)=>D.createElement(w,{ref:t,...e,weights:pO}));OO.displayName=`SunIcon`;var kO=OO,AO=[`agent-threads`];async function jO(e){let t=await gn(e);if(!t.ok)throw Error(`Request failed (${t.status})`);return t.json()}var MO=[];for(let e=0;e<256;++e)MO.push((e+256).toString(16).slice(1));function NO(e,t=0){return(MO[e[t+0]]+MO[e[t+1]]+MO[e[t+2]]+MO[e[t+3]]+`-`+MO[e[t+4]]+MO[e[t+5]]+`-`+MO[e[t+6]]+MO[e[t+7]]+`-`+MO[e[t+8]]+MO[e[t+9]]+`-`+MO[e[t+10]]+MO[e[t+11]]+MO[e[t+12]]+MO[e[t+13]]+MO[e[t+14]]+MO[e[t+15]]).toLowerCase()}var PO=new Uint8Array(16);function FO(){return crypto.getRandomValues(PO)}var IO={};function LO(e,t,n){let r;if(e)r=zO(e.random??e.rng?.()??FO(),e.msecs,e.seq,t,n);else{let e=Date.now(),i=FO();RO(IO,e,i),r=zO(i,IO.msecs,IO.seq,t,n)}return t??NO(r)}function RO(e,t,n){return e.msecs??=-1/0,e.seq??=0,t>e.msecs?(e.seq=BO(n),e.msecs=t):(e.seq=e.seq+1|0,e.seq===0&&e.msecs++),e}function zO(e,t,n,r,i=0){if(e.length<16)throw Error(`Random bytes length must be >= 16`);if(!r)r=new Uint8Array(16),i=0;else if(i<0||i+16>r.length)throw RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);return t??=Date.now(),n??=BO(e),r[i++]=t/1099511627776&255,r[i++]=t/4294967296&255,r[i++]=t/16777216&255,r[i++]=t/65536&255,r[i++]=t/256&255,r[i++]=t&255,r[i++]=112|n>>>28&15,r[i++]=n>>>20&255,r[i++]=128|n>>>14&63,r[i++]=n>>>6&255,r[i++]=n<<2&255|e[10]&3,r[i++]=e[11],r[i++]=e[12],r[i++]=e[13],r[i++]=e[14],r[i++]=e[15],r}function BO(e){return(e[6]&127)<<24|e[7]<<16|e[8]<<8|e[9]}function VO(){return LO()}function HO(){let{setColorScheme:e}=Vt(),t=Ht(`light`,{getInitialValueInEffect:!0}),n=t===`dark`?`light`:`dark`,[r,i]=(0,D.useState)(!1);return(0,O.jsx)(zt,{label:`Switch to ${n} theme`,opened:r,children:(0,O.jsx)(We,{variant:`subtle`,color:`gray`,"aria-label":`Switch to ${n} theme`,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),onFocus:()=>i(!0),onBlur:()=>i(!1),onClick:()=>{i(!1),e(n)},children:t===`dark`?(0,O.jsx)(kO,{size:17,weight:`bold`}):(0,O.jsx)(yO,{size:17,weight:`bold`})})})}var UO={home:`https://fanout.run/start/what-fanout-is`,ingest:`https://fanout.run/start/send-telemetry`};async function WO(e,t){let n=new URLSearchParams({page_size:`30`});e&&n.set(`q`,e),t&&n.set(`cursor`,t);let r=await gn(`/api/agent/threads?${n}`);if(!r.ok)throw Error(`Unable to load chats (${r.status})`);return r.json()}function GO({agentAvailable:e,activeThreadID:t,activeDashboardID:n,autoFocusSearch:r=!1,onNewChat:i,onSelectThread:a,onDeletedThread:o,onSelectDashboard:s,onCreateDashboard:c,onInvestigateService:l,ref:u}){let d=qt(),[f,p]=(0,D.useState)(``),[m]=ca(f.trim(),250),[h,g]=(0,D.useState)(null),[_,v]=(0,D.useState)(null),[y,b]=(0,D.useState)(``),[x,S]=(0,D.useState)(``),[te,C]=(0,D.useState)(!1),ne=(0,D.useRef)(null);(0,D.useImperativeHandle)(u,()=>({focusSearch:()=>ne.current?.focus()}),[]),(0,D.useEffect)(()=>{r&&requestAnimationFrame(()=>ne.current?.focus())},[r]);let ie=aO({queryKey:[...AO,m],queryFn:({pageParam:e})=>WO(m,e),initialPageParam:``,getNextPageParam:e=>e.next_cursor??void 0,enabled:e}),w=un({queryKey:ut,queryFn:it,refetchInterval:3e4,staleTime:ot}),ae=(0,D.useMemo)(()=>ie.data?.pages.flatMap(e=>e.items)??[],[ie.data]),le=(0,D.useMemo)(()=>ZO(ae),[ae]),ue=un({queryKey:[`telemetry-schema`,`1h`],queryFn:()=>jO(`/api/telemetry/schema?window=1h`),enabled:!!m&&!!l,staleTime:6e4}),de=(0,D.useMemo)(()=>{if(!m)return[];let e=m.toLowerCase();return(ue.data?.services??[]).map(e=>e.value).filter(t=>t.toLowerCase().includes(e)).slice(0,6)},[ue.data,m]),fe=(0,D.useMemo)(()=>{let e=w.data??[],t=m.toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)):e},[w.data,m]);function pe(e){S(``),b(e.title),g(e)}async function T(){if(h&&y.trim()){C(!0),S(``);try{let e=await gn(`/api/agent/threads/${encodeURIComponent(h.id)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({title:y.trim()})});if(!e.ok)throw Error(`Unable to rename chat (${e.status})`);await d.invalidateQueries({queryKey:AO}),g(null)}catch(e){S(e instanceof Error?e.message:`Unable to rename this chat.`)}finally{C(!1)}}}async function me(){if(_){C(!0),S(``);try{let e=await gn(`/api/agent/threads/${encodeURIComponent(_.id)}`,{method:`DELETE`});if(!e.ok)throw Error(`Unable to delete chat (${e.status})`);let t=_.id;v(null),await d.invalidateQueries({queryKey:AO}),await d.invalidateQueries({queryKey:ut}),o(t)}catch(e){S(e instanceof Error?e.message:`Unable to delete this chat.`)}finally{C(!1)}}}return(0,O.jsxs)(oe,{gap:`sm`,h:`100%`,component:`nav`,"aria-label":`Navigation`,children:[e&&(0,O.jsx)(se,{leftSection:(0,O.jsx)(CO,{size:16,weight:`bold`}),onClick:i,children:`New chat`}),(0,O.jsx)(Rt,{type:`auto`,offsetScrollbars:!0,flex:1,mx:-4,px:4,children:(0,O.jsxs)(oe,{gap:`lg`,pb:`sm`,children:[e&&(0,O.jsxs)(oe,{gap:4,children:[(0,O.jsx)(KO,{children:`Chats`}),ie.isLoading&&(0,O.jsx)(be,{py:`md`,children:(0,O.jsx)(Ce,{size:`xs`})}),ie.isError&&(0,O.jsx)(he,{color:`bad`,radius:`md`,p:`xs`,children:`Chats could not be loaded.`}),!ie.isLoading&&!ie.isError&&ae.length===0&&(0,O.jsx)(ce,{c:`dimmed`,size:`sm`,px:`sm`,py:`xs`,children:m?`No matching chats`:`No chats yet`}),le.map(e=>(0,O.jsxs)(oe,{gap:2,children:[le.length>1&&(0,O.jsx)(ce,{c:`dimmed`,size:`xs`,px:`sm`,pt:4,children:e.label}),e.threads.map(e=>(0,O.jsx)(qO,{thread:e,active:e.id===t,onSelect:()=>a(e.id),onRename:()=>pe(e),onDelete:()=>{S(``),v(e)}},e.id))]},e.label)),ie.hasNextPage&&(0,O.jsx)(se,{variant:`subtle`,color:`gray`,size:`compact-sm`,loading:ie.isFetchingNextPage,onClick:()=>void ie.fetchNextPage(),children:`See all`})]}),m&&l&&ue.isLoading&&(0,O.jsx)(be,{py:`md`,children:(0,O.jsx)(Ce,{size:`xs`})}),m&&l&&(ue.isSuccess||ue.isError)&&(0,O.jsxs)(oe,{gap:4,children:[(0,O.jsx)(KO,{children:`Services`}),ue.isError&&(0,O.jsx)(ce,{c:`dimmed`,size:`sm`,px:`sm`,children:`Services could not be searched`}),ue.isSuccess&&de.length===0&&(0,O.jsx)(ce,{c:`dimmed`,size:`sm`,px:`sm`,children:`No matching services`}),de.map(e=>(0,O.jsx)(ee,{className:`rail-row`,p:`sm`,onClick:()=>l(e),children:(0,O.jsx)(ce,{size:`sm`,fw:500,truncate:!0,children:e})},e))]}),(0,O.jsxs)(oe,{gap:4,children:[(0,O.jsx)(KO,{children:`Dashboards`}),w.isLoading&&(0,O.jsx)(be,{py:`md`,children:(0,O.jsx)(Ce,{size:`xs`})}),w.isError&&(0,O.jsx)(he,{color:`bad`,radius:`md`,p:`xs`,children:`Dashboards could not be loaded.`}),!w.isLoading&&!w.isError&&m&&fe.length===0&&(0,O.jsx)(ce,{c:`dimmed`,size:`sm`,px:`sm`,py:`xs`,children:`No matching dashboards`}),fe.map(e=>{let t=e.id===n;return(0,O.jsxs)(oe,{gap:0,children:[(0,O.jsx)(ee,{component:`a`,href:`/dashboards/${encodeURIComponent(e.id)}`,className:`rail-row`,"data-active":t||void 0,"aria-current":t?`page`:void 0,p:`sm`,onClick:t=>{t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(t.preventDefault(),s(e.id))},children:(0,O.jsxs)(re,{justify:`space-between`,gap:`sm`,wrap:`nowrap`,children:[(0,O.jsx)(ce,{size:`sm`,fw:t?600:500,truncate:!0,children:e.name}),e.is_default&&(0,O.jsx)(Je,{size:`xs`,variant:`light`,color:`gray`,children:`Default`})]})}),e.origin&&(0,O.jsx)(ee,{component:`a`,href:`/chat/${encodeURIComponent(e.origin.thread_id)}`,"data-request-provenance":!0,px:`sm`,pb:`xs`,onClick:t=>{t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(t.preventDefault(),a(e.origin.thread_id))},children:(0,O.jsxs)(ce,{size:`xs`,c:`dimmed`,lineClamp:2,children:[`Built from: `,e.origin.request_excerpt]})})]},e.id)}),e&&(0,O.jsx)(se,{variant:`subtle`,color:`gray`,size:`compact-sm`,justify:`flex-start`,leftSection:(0,O.jsx)(DO,{size:14,weight:`fill`}),onClick:c,children:w.data?.length===0?`New dashboard`:`Create with AI`})]})]})}),(0,O.jsx)(yn,{ref:ne,value:f,onChange:e=>p(e.currentTarget.value),leftSection:(0,O.jsx)(_O,{size:15}),rightSection:(0,O.jsx)(dt,{size:`xs`,children:`⌘K`}),rightSectionWidth:44,placeholder:`Search`,"aria-label":`Search chats, dashboards and services`,size:`sm`}),(0,O.jsx)(Wt,{opened:h!==null,onClose:()=>!te&&g(null),title:`Rename chat`,centered:!0,children:(0,O.jsx)(`form`,{onSubmit:e=>{e.preventDefault(),T()},children:(0,O.jsxs)(oe,{children:[(0,O.jsx)(yn,{label:`Name`,value:y,onChange:e=>b(e.currentTarget.value),maxLength:120,autoFocus:!0}),x&&(0,O.jsx)(he,{color:`bad`,children:x}),(0,O.jsxs)(re,{justify:`flex-end`,children:[(0,O.jsx)(se,{variant:`default`,onClick:()=>g(null),disabled:te,children:`Cancel`}),(0,O.jsx)(se,{type:`submit`,loading:te,disabled:!y.trim(),children:`Save`})]})]})})}),(0,O.jsx)(Wt,{opened:_!==null,onClose:()=>!te&&v(null),title:`Delete chat?`,centered:!0,children:(0,O.jsxs)(oe,{children:[(0,O.jsxs)(ce,{size:`sm`,children:[`This permanently removes `,(0,O.jsx)(ce,{span:!0,fw:650,children:_?.title}),` and its saved messages.`]}),x&&(0,O.jsx)(he,{color:`bad`,children:x}),(0,O.jsxs)(re,{justify:`flex-end`,children:[(0,O.jsx)(se,{variant:`default`,onClick:()=>v(null),disabled:te,children:`Cancel`}),(0,O.jsx)(se,{color:`bad`,loading:te,onClick:()=>void me(),children:`Delete`})]})]})})]})}function KO({children:e}){return(0,O.jsx)(ce,{c:`dimmed`,size:`xs`,fw:700,tt:`uppercase`,lts:`0.08em`,px:`sm`,children:e})}function qO({thread:e,active:t,onSelect:n,onRename:r,onDelete:i}){return(0,O.jsx)(l,{"data-active":t||void 0,className:`rail-row`,children:(0,O.jsxs)(re,{gap:2,wrap:`nowrap`,children:[(0,O.jsx)(ee,{onClick:n,"aria-current":t?`page`:void 0,p:`sm`,flex:1,style:{minWidth:0},children:(0,O.jsxs)(oe,{gap:0,children:[(0,O.jsx)(ce,{size:`sm`,fw:t?600:500,truncate:!0,children:e.title}),(0,O.jsx)(ce,{c:`dimmed`,size:`xs`,children:QO(e.updated_at)})]})}),(0,O.jsxs)(st,{position:`bottom-end`,withinPortal:!0,children:[(0,O.jsx)(st.Target,{children:(0,O.jsx)(We,{className:`rail-row-actions`,variant:`subtle`,color:`gray`,size:`sm`,mr:4,"aria-label":`Actions for ${e.title}`,children:(0,O.jsx)(ft,{size:18,weight:`bold`})})}),(0,O.jsxs)(st.Dropdown,{children:[(0,O.jsx)(st.Item,{leftSection:(0,O.jsx)(at,{size:15}),onClick:r,children:`Rename`}),(0,O.jsx)(st.Item,{color:`bad`,leftSection:(0,O.jsx)(Ft,{size:15}),onClick:i,children:`Delete`})]})]})]})})}function JO(e){return e.includes(`T`)?new Date(e):new Date(`${e.replace(` `,`T`)}Z`)}function YO(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}var XO=[`Today`,`Yesterday`,`Previous 7 days`,`Older`];function ZO(e){let t=YO(new Date),n=new Map;for(let r of e){let e=Math.floor((t-YO(JO(r.updated_at)))/864e5),i=e<=0?`Today`:e===1?`Yesterday`:e<=7?`Previous 7 days`:`Older`,a=n.get(i)??[];a.push(r),n.set(i,a)}return XO.filter(e=>n.has(e)).map(e=>({label:e,threads:n.get(e)}))}function QO(e){let t=JO(e),n=YO(new Date);return Math.floor((n-YO(t))/864e5)<=1?new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}).format(t):new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(t)}function $O({children:e}){let{agentAvailable:t,threadID:n,threadMissing:r,newThread:i,selectThread:a,openChat:o}=Ze(),s=we(),c=sa({select:e=>e.location.pathname}),{dashboardId:l}=wt({strict:!1}),u=c===`/chat`||c.startsWith(`/chat/`),[d,f]=la(!1),[p,m]=(0,D.useState)(!1),[h,g]=(0,D.useState)(``),_=(0,D.useRef)(null),v=ae(`(max-width: 62em)`),y=(0,D.useRef)(v);y.current=v,(0,D.useEffect)(()=>{f.close()},[c]),(0,D.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`&&(e.preventDefault(),y.current?(m(!0),f.open()):_.current?.focusSearch())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let b={agentAvailable:t,activeThreadID:u&&!r&&c!==`/chat`?n:void 0,activeDashboardID:l,onNewChat:i,onSelectThread:a,onDeletedThread:e=>{e===n&&i()},onSelectDashboard:e=>void s({to:`/dashboards/$dashboardId`,params:{dashboardId:e},search:{}}),onCreateDashboard:()=>o(Ge),onInvestigateService:e=>o(`Investigate the ${e} service. Explain its errors and latency.`)};return(0,O.jsxs)(po,{header:{height:52},navbar:{width:256,breakpoint:`md`,collapsed:{mobile:!0}},padding:0,children:[(0,O.jsx)(po.Header,{children:(0,O.jsxs)(re,{h:`100%`,px:{base:`sm`,sm:`md`},justify:`space-between`,wrap:`nowrap`,children:[(0,O.jsxs)(re,{gap:`sm`,wrap:`nowrap`,children:[(0,O.jsx)(Do,{hiddenFrom:`md`,opened:d,onClick:()=>{m(!1),f.toggle()},size:`sm`,"aria-label":d?`Close navigation`:`Open navigation`}),(0,O.jsx)(ve,{size:`small`})]}),(0,O.jsxs)(re,{gap:`xs`,wrap:`nowrap`,children:[(0,O.jsx)(zt,{label:`Documentation`,children:(0,O.jsx)(We,{component:`a`,href:UO.home,target:`_blank`,rel:`noopener noreferrer`,variant:`subtle`,color:`gray`,"aria-label":`Documentation`,children:(0,O.jsx)(hO,{size:17,weight:`bold`})})}),(0,O.jsx)(HO,{}),(0,O.jsx)(ek,{onError:g})]})]})}),(0,O.jsx)(po.Navbar,{p:`sm`,children:(0,O.jsx)(GO,{ref:_,...b})}),(0,O.jsx)(pt,{opened:d,onClose:f.close,hiddenFrom:`md`,size:288,padding:`sm`,title:(0,O.jsx)(ve,{size:`small`}),overlayProps:{backgroundOpacity:.24,blur:1},children:(0,O.jsx)(GO,{...b,autoFocusSearch:d&&p})}),(0,O.jsxs)(po.Main,{children:[h&&(0,O.jsx)(he,{color:`bad`,m:`md`,withCloseButton:!0,onClose:()=>g(``),children:h}),e]})]})}function ek({onError:e}){let t=we(),n=vn(),r=(n.display_name.trim()||n.email.trim()||`?`).charAt(0).toUpperCase();return(0,O.jsxs)(st,{position:`bottom-end`,withinPortal:!0,shadow:`md`,children:[(0,O.jsx)(st.Target,{children:(0,O.jsx)(We,{variant:`subtle`,color:`gray`,size:`lg`,radius:`xl`,"aria-label":`Account menu`,children:(0,O.jsx)(wo,{size:26,radius:`xl`,color:`brand`,children:r})})}),(0,O.jsxs)(st.Dropdown,{children:[(0,O.jsx)(st.Label,{children:n.email||`Signed in`}),(0,O.jsx)(st.Item,{leftSection:(0,O.jsx)(xO,{size:15}),onClick:()=>void t({to:`/settings`}),children:`Connect telemetry`}),(0,O.jsx)(st.Divider,{}),(0,O.jsx)(st.Item,{leftSection:(0,O.jsx)(TO,{size:15}),onClick:()=>void hn().catch(t=>e(t instanceof Error?t.message:`Sign-out failed — your session is still active.`)),children:`Sign out`})]})]})}function tk(){let{agent_available:e}=_n(),t=we(),n=qt(),{threadId:r}=wt({strict:!1}),[i,a]=(0,D.useState)(VO),o=(0,D.useRef)(new Set),s=r??i,[c,l]=(0,D.useState)([]),[u,d]=(0,D.useState)({}),[f,p]=(0,D.useState)(``),[m,h]=(0,D.useState)(!1),[g,_]=(0,D.useState)(!1),[v,y]=(0,D.useState)(``),[b,ee]=(0,D.useState)(null),x=(0,D.useRef)(null),[S,te]=(0,D.useState)(!1),C=(0,D.useRef)(!1),[ne,re]=(0,D.useState)(``),[ie,w]=(0,D.useState)(``),[ae,oe]=(0,D.useState)(0),se=(0,D.useRef)(null),ce=(0,D.useRef)({}),le=(0,D.useRef)(null),ue=(0,D.useRef)(new Map),de=(0,D.useMemo)(()=>new $D({url:`/api/agent/runs`,threadId:s,fetch:(e,t)=>gn(e,t)}),[s]),fe=!e||f===s;function pe(){ue.current.clear(),y(``),x.current=null,ee(null)}let T=e=>e.filter(e=>e.role!==`reasoning`);function me(){let e=x.current?.text.split(/(?<=[.!?])\s/)[0]?.trim().replace(/[.!?]+$/,``);return e?e+`…`:``}function he(e){return C.current||e instanceof Error&&e.name===`AbortError`}(0,D.useEffect)(()=>{let t=!0;if(l([]),ce.current={},d({}),p(``),h(!1),_(!1),C.current=!1,te(!1),pe(),w(``),!e){p(s);return}!r||o.current.has(s)?(de.setMessages([]),p(s)):gn(`/api/agent/threads/${encodeURIComponent(s)}`).then(async e=>{if(e.status===404)return null;if(!e.ok)throw Error(`Unable to load thread (${e.status})`);return e.json()}).then(e=>{if(t){if(e===null){h(!0),p(s);return}de.setMessages(T(e.messages??[])),l(T(e.messages??[])),p(s)}}).catch(()=>{t&&(se.current=null,w(`This chat could not be restored. Start a new chat or try again.`))});let i=de.subscribe({onEvent:({event:e,messages:t})=>{switch(e.type){case`REASONING_MESSAGE_START`:return x.current={id:e.messageId,text:``,collapsed:!1},ee(x.current),y(``),{stopPropagation:!0};case`REASONING_MESSAGE_CONTENT`:{let t=e,n={id:t.messageId,text:(x.current?.text??``)+t.delta,collapsed:!1};return x.current=n,ee(n),{stopPropagation:!0}}case`REASONING_START`:case`REASONING_MESSAGE_END`:case`REASONING_END`:return{stopPropagation:!0};default:l(T(t))}},onMessagesChanged:({messages:e})=>l(T(e)),onRunInitialized:()=>{C.current=!1,te(!1),_(!0),w(``)},onTextMessageContentEvent:({event:e})=>{e.delta&&(x.current=null,ee(null),y(``))},onToolCallStartEvent:({event:e})=>{ue.current.set(e.toolCallId,Xe(e.toolCallName)),y(Xe(e.toolCallName)),x.current&&(x.current={...x.current,collapsed:!0},ee(x.current))},onToolCallResultEvent:({event:e,messages:t})=>{ue.current.delete(e.toolCallId),y([...ue.current.values()].at(-1)??me());let r=$e(e.toolCallId,e.content,t);r&&(n.invalidateQueries({queryKey:ut}),n.invalidateQueries({queryKey:[`dashboard`,r.id]}),n.invalidateQueries({queryKey:[`dashboard-versions`,r.id]}))},onRunErrorEvent:({event:e})=>{e.code===`abort`||C.current?(w(``),te(!0)):(console.warn(`Agent run error`,e.code),w(He(e.code))),_(!1),pe()},onRunFinalized:({messages:e})=>{let t=T(e);l(t),d(e=>{let n={...e};for(let e of t)e.role===`assistant`&&!n[e.id]&&(n[e.id]=Date.now());return n}),_(!1),pe(),o.current.delete(s),n.invalidateQueries({queryKey:AO})},onRunFailed:e=>{he(e.error)?(w(``),te(!0)):(console.error(`Agent run failed`,e),w(He())),_(!1),pe(),o.current.delete(s),n.invalidateQueries({queryKey:AO})}});return()=>{t=!1,i.unsubscribe(),de.abortRun()}},[de,e,n,ae,s]),(0,D.useEffect)(()=>{if(!e)return;let n=e=>{let n=e.target,i=n?.matches(`input, textarea, [contenteditable='true']`);e.key===`/`&&!i&&(e.preventDefault(),r?requestAnimationFrame(()=>le.current?.focus()):t({to:`/chat`}).then(()=>requestAnimationFrame(()=>le.current?.focus()))),e.key===`Escape`&&n===le.current&&(re(``),le.current?.blur())};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t,r]);async function ge(){_(!0),w(``);try{await de.runAgent({forwardedProps:{...ce.current}})}catch(e){he(e)?(w(``),te(!0)):(console.error(`Agent run failed`,e),w(He())),_(!1),pe(),o.current.delete(s)}}async function _e(n,i){let a=n.trim();if(!e||!a||g||!fe||m)return;ce.current={...i},r||(o.current.add(s),t({to:`/chat/$threadId`,params:{threadId:s},replace:!0}));let c={id:VO(),role:`user`,content:a};de.addMessage(c),l([...de.messages]),d(e=>({...e,[c.id]:Date.now()})),re(``),await ge()}(0,D.useEffect)(()=>{let e=se.current;fe&&r&&e&&(se.current=null,_e(e.text,e.options))},[fe,r,s]);function ve(e){e.preventDefault(),_e(ne)}function ye(){C.current=!0,w(``),te(!0),de.abortRun(),_(!1),pe(),o.current.delete(s)}function be(){!g&&de.messages.some(e=>e.role===`user`)&&ge()}function xe(n,r){if(!e)return;let i=VO();o.current.add(i),se.current=n?{text:n,options:{...r}}:null,t({to:`/chat/$threadId`,params:{threadId:i}})}function Se(){de.abortRun(),se.current=null,ce.current={},a(VO()),t({to:`/chat`})}function Ce(e){se.current=null,ce.current={},t({to:`/chat/$threadId`,params:{threadId:e}})}function E(){oe(e=>e+1)}return(0,O.jsx)(Ye.Provider,{value:{agentAvailable:e,threadID:s,threadMissing:m,messages:c,messageTimes:u,ready:fe,running:g,activity:v,provisional:b,stopped:S,input:ne,setInput:re,error:ie,inputRef:le,send:_e,submit:ve,stop:ye,retry:be,reloadThread:E,openChat:xe,newThread:Se,selectThread:Ce},children:(0,O.jsx)($O,{children:(0,O.jsx)(Zi,{})})})}function nk(){let e=(0,D.useMemo)(()=>new iO,[]);return(0,O.jsx)(pn,{client:e,children:(0,O.jsx)(bn,{children:(0,O.jsx)(tk,{})})})}var rk=kt({component:nk,notFoundComponent:()=>(0,O.jsx)(Te,{to:`/`,replace:!0})}),ik=Dt(`/`)({component:Mt(()=>Qe(()=>import(`./routes-D2AdaqvY.js`),__vite__mapDeps([0,1,2])),`component`)}),ak=Dt(`/settings`)({component:Mt(()=>Qe(()=>import(`./settings-BnFwabAq.js`),__vite__mapDeps([3,1,4,5,6,7,2,8])),`component`)}),ok=Dt(`/chat/`)({component:Mt(()=>Qe(()=>import(`./chat.index-eVfsC4Jb.js`),__vite__mapDeps([9,10,1,4,11,5,12])),`component`)}),sk=Dt(`/chat/$threadId`)({component:Mt(()=>Qe(()=>import(`./chat._threadId-eVfsC4Jb.js`),__vite__mapDeps([13,10,1,4,11,5,12])),`component`)}),ck=Dt(`/dashboards/`)({component:Mt(()=>Qe(()=>import(`./dashboards.index-mQSdDlyY.js`),__vite__mapDeps([14,1,2,15,4,11,5,16,6,7,17,12,8])),`component`),validateSearch:e=>bt(_t(e))}),lk=Dt(`/dashboards/$dashboardId`)({component:Mt(()=>Qe(()=>import(`./dashboards._dashboardId-09220iIf.js`),__vite__mapDeps([18,1,2,15,4,11,5,16,6,7,17,12,8])),`component`),validateSearch:e=>bt(_t(e))}),uk=ik.update({id:`/`,path:`/`,getParentRoute:()=>rk}),dk=ak.update({id:`/settings`,path:`/settings`,getParentRoute:()=>rk}),fk=ok.update({id:`/chat/`,path:`/chat/`,getParentRoute:()=>rk}),pk=sk.update({id:`/chat/$threadId`,path:`/chat/$threadId`,getParentRoute:()=>rk}),mk=ck.update({id:`/dashboards/`,path:`/dashboards/`,getParentRoute:()=>rk}),hk={IndexRoute:uk,SettingsRoute:dk,ChatThreadIdRoute:pk,DashboardsDashboardIdRoute:lk.update({id:`/dashboards/$dashboardId`,path:`/dashboards/$dashboardId`,getParentRoute:()=>rk}),ChatIndexRoute:fk,DashboardsIndexRoute:mk},gk=ra({routeTree:rk._addFileChildren(hk)._addFileTypes(),parseSearch:Pt,stringifySearch:lt,defaultPreload:`intent`,scrollRestoration:!0}),_k=vt(S),vk=Ea({...Et,variantColorResolver:_k});(0,Fo.createRoot)(document.getElementById(`root`)).render((0,O.jsx)(D.StrictMode,{children:(0,O.jsx)(Ta,{theme:vk,defaultColorScheme:`auto`,cssVariablesResolver:jt,children:(0,O.jsx)(oa,{router:gk})})}));export{a_ as A,Cv as C,uv as D,V as E,Fu as F,Zm as M,qm as N,nv as O,Km as P,cv as S,gv as T,Hv as _,S_ as a,iv as b,vv as c,W as d,ov as f,mv as g,E_ as h,jO as i,$g as j,A_ as k,$_ as l,fv as m,ck as n,x_ as o,U as p,UO as r,K_ as s,lk as t,Z_ as u,K as v,qv as w,q_ as x,G as y}; \ No newline at end of file diff --git a/internal/ui/dist/assets/mcp-app-frame-DpQJtTNR.js b/internal/ui/dist/assets/mcp-app-frame-tweTxib0.js similarity index 99% rename from internal/ui/dist/assets/mcp-app-frame-DpQJtTNR.js rename to internal/ui/dist/assets/mcp-app-frame-tweTxib0.js index 9d0fbe78..1c645027 100644 --- a/internal/ui/dist/assets/mcp-app-frame-DpQJtTNR.js +++ b/internal/ui/dist/assets/mcp-app-frame-tweTxib0.js @@ -1,4 +1,4 @@ -import{i as e,r as t,s as n}from"./useRouter-ByJ6_rwb.js";import{C as r,d as i,f as a,p as o,u as s,y as c}from"./brand-Bcp2Tp5I.js";import{t as l}from"./use-computed-color-scheme-BIja2o3c.js";import{i as u,l as d}from"./auth-C8kS8ur3.js";import{n as f}from"./chat-D8Nl9xGT.js";import{A as p,C as m,D as h,E as g,F as _,M as v,N as y,O as b,P as x,S,T as C,_ as ee,a as w,b as T,c as E,d as te,f as D,g as ne,h as re,j as ie,k as ae,l as oe,m as se,o as ce,p as O,s as le,u as ue,v as k,w as A,x as j,y as M}from"./index-ZyJwWZ_-.js";var de={invalid_type:`invalid_type`,too_big:`too_big`,too_small:`too_small`,invalid_format:`invalid_format`,not_multiple_of:`not_multiple_of`,unrecognized_keys:`unrecognized_keys`,invalid_union:`invalid_union`,invalid_key:`invalid_key`,invalid_element:`invalid_element`,invalid_value:`invalid_value`,custom:`custom`},fe;fe||={};function pe(e){return x(ce,e)}function me(e){return y(w,e)}function he(e){return v(le,e)}function N(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function P(e,t){if(!Array.isArray(e))return[];let n=new Set(t);return e.filter(e=>{if(typeof e!=`string`||/[\s;'\"]/.test(e))return!1;let t=e.match(/^([a-z]+):\/\/([^/]+)$/i);return!!(t&&n.has(t[1].toLowerCase()))})}function ge(e){let t=N(N(N(e)?.ui)?.csp),n=P(t?.connectDomains,[`http`,`https`,`ws`,`wss`]),r=P(t?.resourceDomains,[`http`,`https`]),i=P(t?.frameDomains,[`http`,`https`]),a=P(t?.baseUriDomains,[`http`,`https`]),o=r.length?` ${r.join(` `)}`:``,s=[`default-src 'none'`,`worker-src blob:`,`script-src 'self' 'unsafe-inline'${o}`,`style-src 'self' 'unsafe-inline'${o}`,`img-src 'self' data:${o}`,`media-src 'self' data:${o}`,`font-src 'self' data:${o}`,`connect-src ${n.length?n.join(` `):`'none'`}`];return i.length&&s.push(`frame-src ${i.join(` `)}`),a.length&&s.push(`base-uri ${a.join(` `)}`),`${s.join(`; `)};`}var _e=Object.create,ve=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,be=Object.getOwnPropertyNames,F=Object.getPrototypeOf,xe=Object.prototype.hasOwnProperty,Se=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ce=(e,t)=>{let n={};for(var r in e)ve(n,r,{get:e[r],enumerable:!0});return t&&ve(n,Symbol.toStringTag,{value:`Module`}),n},we=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=be(t),a=0,o=i.length,s;at[e]).bind(null,s),enumerable:!(r=ye(t,s))||r.enumerable});return e},Te=(e,t,n)=>(n=e==null?{}:_e(F(e)),we(t||!e||!e.__esModule?ve(n,`default`,{value:e,enumerable:!0}):n,e)),Ee=new Set([`https://json-schema.org/draft/2020-12/schema`,`http://json-schema.org/draft/2020-12/schema`]),De=new Set([`https://json-schema.org/draft/2019-09/schema`,`http://json-schema.org/draft/2019-09/schema`]),Oe=new Set([`https://json-schema.org/draft-07/schema`,`http://json-schema.org/draft-07/schema`]),ke=new Set([`https://json-schema.org/draft-06/schema`,`http://json-schema.org/draft-06/schema`]);function Ae(e){return typeof e==`string`&&De.has(e.replace(/#$/,``))}function je(e,t){if(!(`$schema`in e)||typeof e.$schema!=`string`)return`2020-12`;let n=e.$schema.replace(/#$/,``);if(Ee.has(n))return`2020-12`;if(De.has(n))return`2019-09`;if(Oe.has(n)||ke.has(n))return`draft-7`;throw Error(`JSON Schema declares an unsupported dialect ("$schema": "${e.$schema.slice(0,200)}"). The default validator supports JSON Schema 2020-12, 2019-09, draft-07, and draft-06; ${t}`)}var Me=`2025-11-25`,Ne=[Me,`2025-06-18`,`2025-03-26`,`2024-11-05`,`2024-10-07`],Pe=`io.modelcontextprotocol/related-task`,Fe=`io.modelcontextprotocol/protocolVersion`,Ie=`io.modelcontextprotocol/clientInfo`,Le=`io.modelcontextprotocol/serverInfo`,Re=`io.modelcontextprotocol/clientCapabilities`,ze=`io.modelcontextprotocol/subscriptionId`,Be=`io.modelcontextprotocol/logLevel`,Ve=ee(()=>h([g(),j(),O(),oe(),C(g(),Ve),D(Ve)])),I=C(g(),Ve),He=D(Ve),Ue=h([g(),j().int()]),We=g(),Ge=S({ttl:j().optional()}),Ke=S({taskId:g()}),qe=M({progressToken:Ue.optional(),[Pe]:Ke.optional()}),L=S({_meta:qe.optional()}),Je=L.extend({task:Ge.optional()}),R=S({method:g(),params:L.loose().optional()}),z=S({_meta:qe.optional()}),B=S({method:g(),params:z.loose().optional()}),Ye=M({get[Le](){return H.optional().catch(void 0)}}),V=M({_meta:Ye.optional()}),Xe=h([g(),j().int()]),Ze=S({jsonrpc:k(`2.0`),id:Xe,...R.shape}).strict(),Qe=S({jsonrpc:k(`2.0`),...B.shape}).strict(),$e=S({jsonrpc:k(`2.0`),id:Xe,result:V}).strict(),et=S({jsonrpc:k(`2.0`),id:Xe.optional(),error:S({code:j().int(),message:g(),data:b().optional()})}).strict(),tt=h([Ze,Qe,$e,et]),nt=h([$e,et]),rt=V.strict(),it=z.extend({requestId:Xe.optional(),reason:g().optional()}),at=B.extend({method:k(`notifications/cancelled`),params:it}),ot=S({src:g(),mimeType:g().optional(),sizes:D(g()).optional(),theme:E([`light`,`dark`]).optional()}),st=S({icons:D(ot).optional()}),ct=S({name:g(),title:g().optional()}),H=ct.extend({...ct.shape,...st.shape,version:g(),websiteUrl:g().optional(),description:g().optional()}),lt=ne(S({applyDefaults:O().optional()}),I),ut=A(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,ne(S({form:lt.optional(),url:I.optional()}),I.optional())),dt=M({list:I.optional(),cancel:I.optional(),requests:M({sampling:M({createMessage:I.optional()}).optional(),elicitation:M({create:I.optional()}).optional()}).optional()}),ft=M({list:I.optional(),cancel:I.optional(),requests:M({tools:M({call:I.optional()}).optional()}).optional()}),pt=S({experimental:C(g(),I).optional(),sampling:S({context:I.optional(),tools:I.optional()}).optional(),elicitation:ut.optional(),roots:S({listChanged:O().optional()}).optional(),tasks:dt.optional(),extensions:C(g(),I).optional()}),mt=L.extend({protocolVersion:g(),capabilities:pt,clientInfo:H}),ht=R.extend({method:k(`initialize`),params:mt}),gt=S({experimental:C(g(),I).optional(),logging:I.optional(),completions:I.optional(),prompts:S({listChanged:O().optional()}).optional(),resources:S({subscribe:O().optional(),listChanged:O().optional()}).optional(),tools:S({listChanged:O().optional()}).optional(),tasks:ft.optional(),extensions:C(g(),I).optional()}),_t=V.extend({protocolVersion:g(),capabilities:gt,serverInfo:H,instructions:g().optional()}),vt=B.extend({method:k(`notifications/initialized`),params:z.optional()}),yt=R.extend({method:k(`server/discover`),params:L.optional()}),bt=V.extend({supportedVersions:D(g()),capabilities:gt,instructions:g().optional()}),xt=R.extend({method:k(`ping`),params:L.optional()}),St=S({progress:j(),total:m(j()),message:m(g())}),Ct=S({...z.shape,...St.shape,progressToken:Ue}),wt=B.extend({method:k(`notifications/progress`),params:Ct}),Tt=L.extend({cursor:We.optional()}),Et=R.extend({params:Tt.optional()}),Dt=V.extend({nextCursor:We.optional()}),Ot=S({uri:g(),mimeType:m(g()),_meta:C(g(),b()).optional()}),kt=Ot.extend({text:g()}),At=g().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),jt=Ot.extend({blob:At}),Mt=E([`user`,`assistant`]),Nt=S({audience:D(Mt).optional(),priority:j().min(0).max(1).optional(),lastModified:pe({offset:!0}).optional()}),Pt=S({...ct.shape,...st.shape,uri:g(),description:m(g()),mimeType:m(g()),size:m(j()),annotations:Nt.optional(),_meta:m(M({}))}),Ft=S({...ct.shape,...st.shape,uriTemplate:g(),description:m(g()),mimeType:m(g()),annotations:Nt.optional(),_meta:m(M({}))}),It=Et.extend({method:k(`resources/list`)}),Lt=Dt.extend({resources:D(Pt)}),U=Et.extend({method:k(`resources/templates/list`)}),W=Dt.extend({resourceTemplates:D(Ft)}),Rt=L.extend({uri:g()}),zt=Rt,Bt=R.extend({method:k(`resources/read`),params:zt}),Vt=V.extend({contents:D(h([kt,jt]))}),Ht=B.extend({method:k(`notifications/resources/list_changed`),params:z.optional()}),Ut=Rt,Wt=R.extend({method:k(`resources/subscribe`),params:Ut}),Gt=Rt,Kt=R.extend({method:k(`resources/unsubscribe`),params:Gt}),qt=S({toolsListChanged:O().optional(),promptsListChanged:O().optional(),resourcesListChanged:O().optional(),resourceSubscriptions:D(g()).optional()}),Jt=L.extend({notifications:qt}),Yt=R.extend({method:k(`subscriptions/listen`),params:Jt}),Xt=z.extend({notifications:qt}),Zt=B.extend({method:k(`notifications/subscriptions/acknowledged`),params:Xt}),Qt=Ye.extend({[ze]:Xe}),$t=V.extend({_meta:Qt}),en=z.extend({uri:g()}),tn=B.extend({method:k(`notifications/resources/updated`),params:en}),G=S({name:g(),description:m(g()),required:m(O())}),nn=S({...ct.shape,...st.shape,description:m(g()),arguments:m(D(G)),_meta:m(M({}))}),rn=Et.extend({method:k(`prompts/list`)}),an=Dt.extend({prompts:D(nn)}),on=L.extend({name:g(),arguments:C(g(),g()).optional()}),sn=R.extend({method:k(`prompts/get`),params:on}),cn=S({type:k(`text`),text:g(),annotations:Nt.optional(),_meta:C(g(),b()).optional()}),K=S({type:k(`image`),data:At,mimeType:g(),annotations:Nt.optional(),_meta:C(g(),b()).optional()}),ln=S({type:k(`audio`),data:At,mimeType:g(),annotations:Nt.optional(),_meta:C(g(),b()).optional()}),un=S({type:k(`tool_use`),name:g(),id:g(),input:C(g(),b()),_meta:C(g(),b()).optional()}),dn=S({type:k(`resource`),resource:h([kt,jt]),annotations:Nt.optional(),_meta:C(g(),b()).optional()}),fn=Pt.extend({type:k(`resource_link`)}),pn=h([cn,K,ln,fn,dn]),mn=S({role:Mt,content:pn}),hn=V.extend({description:g().optional(),messages:D(mn)}),gn=B.extend({method:k(`notifications/prompts/list_changed`),params:z.optional()}),_n=S({title:g().optional(),readOnlyHint:O().optional(),destructiveHint:O().optional(),idempotentHint:O().optional(),openWorldHint:O().optional()}),vn=S({taskSupport:E([`required`,`optional`,`forbidden`]).optional()}),yn=S({...ct.shape,...st.shape,description:g().optional(),inputSchema:S({type:k(`object`),properties:C(g(),Ve).optional(),required:D(g()).optional()}).catchall(b()),outputSchema:M({$schema:g().optional()}).optional(),annotations:_n.optional(),execution:vn.optional(),_meta:C(g(),b()).optional()}),bn=Et.extend({method:k(`tools/list`)}),xn=Dt.extend({tools:D(yn)}),Sn=V.extend({content:D(pn).default([]),structuredContent:b().optional(),isError:O().optional()}),Cn=Sn.or(V.extend({toolResult:b()})),wn=Je.extend({name:g(),arguments:C(g(),b()).optional()}),Tn=R.extend({method:k(`tools/call`),params:wn}),En=B.extend({method:k(`notifications/tools/list_changed`),params:z.optional()}),Dn=S({autoRefresh:O().default(!0),debounceMs:j().int().nonnegative().default(300)}),On=E([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),kn=L.extend({level:On}),An=R.extend({method:k(`logging/setLevel`),params:kn}),jn=z.extend({level:On,logger:g().optional(),data:b()}),Mn=B.extend({method:k(`notifications/message`),params:jn}),Nn=S({name:g().optional()}),Pn=S({hints:D(Nn).optional(),costPriority:j().min(0).max(1).optional(),speedPriority:j().min(0).max(1).optional(),intelligencePriority:j().min(0).max(1).optional()}),Fn=S({mode:E([`auto`,`required`,`none`]).optional()}),In=S({type:k(`tool_result`),toolUseId:g().describe(`The unique identifier for the corresponding tool call.`),content:D(pn),structuredContent:b().optional(),isError:O().optional(),_meta:C(g(),b()).optional()}),Ln=se(`type`,[cn,K,ln]),Rn=se(`type`,[cn,K,ln,un,In]),zn=S({role:Mt,content:h([Rn,D(Rn)]),_meta:C(g(),b()).optional()}),Bn=Je.extend({messages:D(zn),modelPreferences:Pn.optional(),systemPrompt:g().optional(),includeContext:E([`none`,`thisServer`,`allServers`]).optional(),temperature:j().optional(),maxTokens:j().int(),stopSequences:D(g()).optional(),metadata:I.optional(),tools:D(yn).optional(),toolChoice:Fn.optional()}),Vn=R.extend({method:k(`sampling/createMessage`),params:Bn}),Hn=V.extend({model:g(),stopReason:m(E([`endTurn`,`stopSequence`,`maxTokens`]).or(g())),role:Mt,content:Ln}),Un=V.extend({model:g(),stopReason:m(E([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(g())),role:Mt,content:h([Rn,D(Rn)])}),Wn=S({type:k(`boolean`),title:g().optional(),description:g().optional(),default:O().optional()}),Gn=S({type:k(`string`),title:g().optional(),description:g().optional(),minLength:j().optional(),maxLength:j().optional(),format:E([`email`,`uri`,`date`,`date-time`]).optional(),default:g().optional()}),Kn=S({type:E([`number`,`integer`]),title:g().optional(),description:g().optional(),minimum:j().optional(),maximum:j().optional(),default:j().optional()}),qn=S({type:k(`string`),title:g().optional(),description:g().optional(),enum:D(g()),default:g().optional()}),Jn=S({type:k(`string`),title:g().optional(),description:g().optional(),oneOf:D(S({const:g(),title:g()})),default:g().optional()}),Yn=S({type:k(`string`),title:g().optional(),description:g().optional(),enum:D(g()),enumNames:D(g()).optional(),default:g().optional()}),Xn=h([qn,Jn]),Zn=S({type:k(`array`),title:g().optional(),description:g().optional(),minItems:j().optional(),maxItems:j().optional(),items:S({type:k(`string`),enum:D(g())}),default:D(g()).optional()}),Qn=S({type:k(`array`),title:g().optional(),description:g().optional(),minItems:j().optional(),maxItems:j().optional(),items:S({anyOf:D(S({const:g(),title:g()}))}),default:D(g()).optional()}),$n=h([Zn,Qn]),er=h([Yn,Xn,$n]),tr=h([er,Wn,Gn,Kn]),nr=Je.extend({mode:k(`form`).optional(),message:g(),requestedSchema:S({type:k(`object`),properties:C(g(),tr),required:D(g()).optional()}).catchall(b())}),rr=Je.extend({mode:k(`url`),message:g(),elicitationId:g(),url:g().url()}),ir=h([nr,rr]),ar=R.extend({method:k(`elicitation/create`),params:ir}),or=z.extend({elicitationId:g()}),sr=B.extend({method:k(`notifications/elicitation/complete`),params:or}),cr=V.extend({action:E([`accept`,`decline`,`cancel`]),content:A(e=>e===null?void 0:e,C(g(),h([g(),j(),O(),D(g())])).optional())}),lr=S({type:k(`ref/resource`),uri:g()}),ur=S({type:k(`ref/prompt`),name:g()}),dr=L.extend({ref:h([ur,lr]),argument:S({name:g(),value:g()}),context:S({arguments:C(g(),g()).optional()}).optional()}),fr=R.extend({method:k(`completion/complete`),params:dr}),pr=V.extend({completion:M({values:D(g()).max(100),total:m(j().int()),hasMore:m(O())})}),mr=S({uri:g().startsWith(`file://`),name:g().optional(),_meta:C(g(),b()).optional()}),hr=R.extend({method:k(`roots/list`),params:L.optional()}),gr=V.extend({roots:D(mr)}),_r=B.extend({method:k(`notifications/roots/list_changed`),params:z.optional()}),vr=M({ttl:j().optional(),pollInterval:j().optional()}),yr=E([`working`,`input_required`,`completed`,`failed`,`cancelled`]),br=S({taskId:g(),status:yr,ttl:h([j(),oe()]),createdAt:g(),lastUpdatedAt:g(),pollInterval:m(j()),statusMessage:m(g())}),xr=V.extend({task:br}),Sr=z.merge(br),Cr=B.extend({method:k(`notifications/tasks/status`),params:Sr}),wr=R.extend({method:k(`tasks/get`),params:L.extend({taskId:g()})}),Tr=V.merge(br),Er=R.extend({method:k(`tasks/result`),params:L.extend({taskId:g()})}),Dr=V.loose(),Or=Et.extend({method:k(`tasks/list`)}),kr=Dt.extend({tasks:D(br)}),Ar=R.extend({method:k(`tasks/cancel`),params:L.extend({taskId:g()})}),jr=V.merge(br),Mr=h([xt,ht,yt,fr,An,sn,rn,It,U,Bt,Wt,Kt,Yt,Tn,bn]),Nr=h([at,wt,vt,_r]),Pr=h([rt,Hn,Un,cr,gr]),Fr=h([xt,Vn,ar,hr]),Ir=h([at,wt,Mn,tn,Ht,En,gn,Zt,sr]),Lr=h([rt,_t,bt,pr,hn,an,Lt,W,Vt,Sn,xn,$t]),q=ae().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:de.custom,message:`URL must be parseable`,fatal:!0}),_}).refine(e=>{let t=new URL(e);return t.protocol!==`javascript:`&&t.protocol!==`data:`&&t.protocol!==`vbscript:`},{message:`URL cannot use javascript:, data:, or vbscript: scheme`}),Rr=M({resource:g().url(),authorization_servers:D(q).optional(),jwks_uri:g().url().optional(),scopes_supported:D(g()).optional(),bearer_methods_supported:D(g()).optional(),resource_signing_alg_values_supported:D(g()).optional(),resource_name:g().optional(),resource_documentation:g().optional(),resource_policy_uri:g().url().optional(),resource_tos_uri:g().url().optional(),tls_client_certificate_bound_access_tokens:O().optional(),authorization_details_types_supported:D(g()).optional(),dpop_signing_alg_values_supported:D(g()).optional(),dpop_bound_access_tokens_required:O().optional()}),zr=M({issuer:g(),authorization_endpoint:q,token_endpoint:q,registration_endpoint:q.optional(),scopes_supported:D(g()).optional(),response_types_supported:D(g()),response_modes_supported:D(g()).optional(),grant_types_supported:D(g()).optional(),token_endpoint_auth_methods_supported:D(g()).optional(),token_endpoint_auth_signing_alg_values_supported:D(g()).optional(),service_documentation:q.optional(),revocation_endpoint:q.optional(),revocation_endpoint_auth_methods_supported:D(g()).optional(),revocation_endpoint_auth_signing_alg_values_supported:D(g()).optional(),introspection_endpoint:g().optional(),introspection_endpoint_auth_methods_supported:D(g()).optional(),introspection_endpoint_auth_signing_alg_values_supported:D(g()).optional(),code_challenge_methods_supported:D(g()).optional(),client_id_metadata_document_supported:O().optional(),authorization_response_iss_parameter_supported:O().optional().catch(void 0),dpop_signing_alg_values_supported:D(g()).optional()}),Br=M({issuer:g(),authorization_endpoint:q,token_endpoint:q,userinfo_endpoint:q.optional(),jwks_uri:q,registration_endpoint:q.optional(),scopes_supported:D(g()).optional(),response_types_supported:D(g()),response_modes_supported:D(g()).optional(),grant_types_supported:D(g()).optional(),acr_values_supported:D(g()).optional(),subject_types_supported:D(g()),id_token_signing_alg_values_supported:D(g()),id_token_encryption_alg_values_supported:D(g()).optional(),id_token_encryption_enc_values_supported:D(g()).optional(),userinfo_signing_alg_values_supported:D(g()).optional(),userinfo_encryption_alg_values_supported:D(g()).optional(),userinfo_encryption_enc_values_supported:D(g()).optional(),request_object_signing_alg_values_supported:D(g()).optional(),request_object_encryption_alg_values_supported:D(g()).optional(),request_object_encryption_enc_values_supported:D(g()).optional(),token_endpoint_auth_methods_supported:D(g()).optional(),token_endpoint_auth_signing_alg_values_supported:D(g()).optional(),display_values_supported:D(g()).optional(),claim_types_supported:D(g()).optional(),claims_supported:D(g()).optional(),service_documentation:g().optional(),claims_locales_supported:D(g()).optional(),ui_locales_supported:D(g()).optional(),claims_parameter_supported:O().optional(),request_parameter_supported:O().optional(),request_uri_parameter_supported:O().optional(),require_request_uri_registration:O().optional(),op_policy_uri:q.optional(),op_tos_uri:q.optional(),client_id_metadata_document_supported:O().optional(),authorization_response_iss_parameter_supported:O().optional().catch(void 0)}),Vr=S({...Br.shape,...zr.pick({code_challenge_methods_supported:!0}).shape}),Hr=S({access_token:g(),id_token:g().optional(),token_type:g(),expires_in:he().optional(),scope:g().optional(),refresh_token:g().optional(),issuer:g().optional().catch(void 0)}).strip(),Ur=S({issued_token_type:k(`urn:ietf:params:oauth:token-type:id-jag`),access_token:g(),token_type:g().optional(),expires_in:j().optional(),scope:g().optional()}).strip(),Wr=S({error:g(),error_description:g().optional(),error_uri:g().optional()}),Gr=q.optional().or(k(``).transform(()=>void 0)),Kr=S({redirect_uris:D(q),token_endpoint_auth_method:g().optional(),grant_types:D(g()).optional(),response_types:D(g()).optional(),application_type:g().optional(),client_name:g().optional(),client_uri:q.optional(),logo_uri:Gr,scope:g().optional(),contacts:D(g()).optional(),tos_uri:Gr,policy_uri:g().optional(),jwks_uri:q.optional(),jwks:te().optional(),software_id:g().optional(),software_version:g().optional(),software_statement:g().optional()}).strip(),qr=S({client_id:g(),client_secret:g().optional(),client_id_issued_at:j().optional(),client_secret_expires_at:j().optional(),issuer:g().optional().catch(void 0)}).strip(),Jr=Kr.merge(qr),Yr=S({error:g(),error_description:g().optional()}).strip(),Xr=S({token:g(),token_type_hint:g().optional()}).strip(),Zr=Symbol.for(`mcp.sdk.errorBrands`);function Qr(e,t){let n=new Set,r=t;for(;typeof r==`function`;){let e=r.mcpBrand;Object.prototype.hasOwnProperty.call(r,`mcpBrand`)&&typeof e==`string`&&n.add(e),r=Object.getPrototypeOf(r)}n.size!==0&&Object.defineProperty(e,Zr,{value:n,enumerable:!1,configurable:!0})}function $r(e,t){try{if(typeof t==`object`&&t&&Object.prototype.hasOwnProperty.call(e,`mcpBrand`)&&typeof e.mcpBrand==`string`&&Object.prototype.hasOwnProperty.call(t,Zr)){let n=t[Zr];if(n&&typeof n.has==`function`&&n.has(e.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(e,t)}var ei=function(e){return e.InvalidRequest=`invalid_request`,e.InvalidClient=`invalid_client`,e.InvalidGrant=`invalid_grant`,e.UnauthorizedClient=`unauthorized_client`,e.UnsupportedGrantType=`unsupported_grant_type`,e.InvalidScope=`invalid_scope`,e.AccessDenied=`access_denied`,e.ServerError=`server_error`,e.TemporarilyUnavailable=`temporarily_unavailable`,e.UnsupportedResponseType=`unsupported_response_type`,e.UnsupportedTokenType=`unsupported_token_type`,e.InvalidToken=`invalid_token`,e.MethodNotAllowed=`method_not_allowed`,e.TooManyRequests=`too_many_requests`,e.InvalidClientMetadata=`invalid_client_metadata`,e.InvalidRedirectUri=`invalid_redirect_uri`,e.InsufficientScope=`insufficient_scope`,e.InvalidTarget=`invalid_target`,e.InvalidDpopProof=`invalid_dpop_proof`,e.UseDpopNonce=`use_dpop_nonce`,e}({}),ti=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.OAuthError`})}static[Symbol.hasInstance](e){return $r(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return $r(this,e)}constructor(e,t,n){super(t),this.code=e,this.errorUri=n,this.name=`OAuthError`,Qr(this,new.target)}toResponseObject(){let e={error:this.code,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}static fromResponse(t){return new e(t.error,t.error_description??t.error,t.error_uri)}},J=function(e){return e.NotConnected=`NOT_CONNECTED`,e.AlreadyConnected=`ALREADY_CONNECTED`,e.NotInitialized=`NOT_INITIALIZED`,e.CapabilityNotSupported=`CAPABILITY_NOT_SUPPORTED`,e.RequestTimeout=`REQUEST_TIMEOUT`,e.ConnectionClosed=`CONNECTION_CLOSED`,e.SendFailed=`SEND_FAILED`,e.InvalidResult=`INVALID_RESULT`,e.UnsupportedResultType=`UNSUPPORTED_RESULT_TYPE`,e.InputRequiredRoundsExceeded=`INPUT_REQUIRED_ROUNDS_EXCEEDED`,e.ListPaginationExceeded=`LIST_PAGINATION_EXCEEDED`,e.MethodNotSupportedByProtocolVersion=`METHOD_NOT_SUPPORTED_BY_PROTOCOL_VERSION`,e.EraNegotiationFailed=`ERA_NEGOTIATION_FAILED`,e.ClientHttpNotImplemented=`CLIENT_HTTP_NOT_IMPLEMENTED`,e.ClientHttpAuthentication=`CLIENT_HTTP_AUTHENTICATION`,e.ClientHttpForbidden=`CLIENT_HTTP_FORBIDDEN`,e.ClientHttpUnexpectedContent=`CLIENT_HTTP_UNEXPECTED_CONTENT`,e.ClientHttpFailedToOpenStream=`CLIENT_HTTP_FAILED_TO_OPEN_STREAM`,e.ClientHttpFailedToTerminateSession=`CLIENT_HTTP_FAILED_TO_TERMINATE_SESSION`,e}({}),Y=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.SdkError`})}static[Symbol.hasInstance](e){return $r(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return $r(this,e)}constructor(e,t,n,r){super(t,r),this.code=e,this.data=n,this.name=`SdkError`,Qr(this,new.target)}},ni=class extends Y{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.SdkHttpError`})}constructor(e,t,n,r){super(e,t,n,r),this.name=`SdkHttpError`}get status(){return this.data.status}get statusText(){return this.data.statusText}};function ri(e){let t=typeof e==`string`?new URL(e):new URL(e.href);return t.hash=``,t}function ii(e){if(typeof e!=`object`||!e||Array.isArray(e))return e;let t={...e};return delete t.issuer,t}function ai({requestedResource:e,configuredResource:t}){let n=typeof e==`string`?new URL(e):new URL(e.href),r=typeof t==`string`?new URL(t):new URL(t.href);if(n.origin!==r.origin||n.pathname.length=oi}function li(e){return e.filter(e=>!ci(e))}function ui(e){return e.filter(e=>ci(e))}function di(e){let t=e.structuredContent;return t===void 0||typeof t==`object`&&t&&!Array.isArray(t)||(e.content?.some(e=>e.type===`text`)??!1)?e:{...e,content:[...e.content??[],{type:`text`,text:JSON.stringify(t)}]}}var fi=[`task`,`inputRequests`,`requestState`];function pi(e){return typeof e!=`object`||!e||Array.isArray(e)||e.content!==void 0||fi.some(t=>t in e)?e:{...e,content:[]}}function mi(){let e=ee(()=>h([g(),j(),O(),oe(),C(g(),e),D(e)])),t=C(g(),e),n=h([g(),j().int()]),r=g(),i=S({ttl:j().optional()}),a=S({taskId:g()}),o=M({progressToken:n.optional(),"io.modelcontextprotocol/related-task":a.optional()}),s=S({_meta:o.optional()}),c=s.extend({task:i.optional()}),l=S({method:g(),params:s.loose().optional()}),u=S({_meta:o.optional()}),d=S({method:g(),params:u.loose().optional()}),f=M({_meta:o.optional()}),p=h([g(),j().int()]),_=f.strict(),v=u.extend({requestId:p.optional(),reason:g().optional()}),y=d.extend({method:k(`notifications/cancelled`),params:v}),x=S({src:g(),mimeType:g().optional(),sizes:D(g()).optional(),theme:E([`light`,`dark`]).optional()}),w=S({icons:D(x).optional()}),T=S({name:g(),title:g().optional()}),te=T.extend({...T.shape,...w.shape,version:g(),websiteUrl:g().optional(),description:g().optional()}),re=ne(S({applyDefaults:O().optional()}),t),ie=A(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,ne(S({form:re.optional(),url:t.optional()}),t.optional())),ae=M({list:t.optional(),cancel:t.optional(),requests:M({sampling:M({createMessage:t.optional()}).optional(),elicitation:M({create:t.optional()}).optional()}).optional()}),ce=M({list:t.optional(),cancel:t.optional(),requests:M({tools:M({call:t.optional()}).optional()}).optional()}),le=S({experimental:C(g(),t).optional(),sampling:S({context:t.optional(),tools:t.optional()}).optional(),elicitation:ie.optional(),roots:S({listChanged:O().optional()}).optional(),tasks:ae.optional(),extensions:C(g(),t).optional()}),ue=s.extend({protocolVersion:g(),capabilities:le,clientInfo:te}),de=l.extend({method:k(`initialize`),params:ue}),fe=S({experimental:C(g(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:S({listChanged:O().optional()}).optional(),resources:S({subscribe:O().optional(),listChanged:O().optional()}).optional(),tools:S({listChanged:O().optional()}).optional(),tasks:ce.optional(),extensions:C(g(),t).optional()}),me=f.extend({protocolVersion:g(),capabilities:fe,serverInfo:te,instructions:g().optional()}),he=d.extend({method:k(`notifications/initialized`),params:u.optional()}),N=l.extend({method:k(`ping`),params:s.optional()}),P=S({progress:j(),total:m(j()),message:m(g())}),ge=S({...u.shape,...P.shape,progressToken:n}),_e=d.extend({method:k(`notifications/progress`),params:ge}),ve=s.extend({cursor:r.optional()}),ye=l.extend({params:ve.optional()}),be=f.extend({nextCursor:r.optional()}),F=S({uri:g(),mimeType:m(g()),_meta:C(g(),b()).optional()}),xe=F.extend({text:g()}),Se=g().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),Ce=F.extend({blob:Se}),we=E([`user`,`assistant`]),Te=S({audience:D(we).optional(),priority:j().min(0).max(1).optional(),lastModified:pe({offset:!0}).optional()}),Ee=S({...T.shape,...w.shape,uri:g(),description:m(g()),mimeType:m(g()),size:m(j()),annotations:Te.optional(),_meta:m(M({}))}),De=S({...T.shape,...w.shape,uriTemplate:g(),description:m(g()),mimeType:m(g()),annotations:Te.optional(),_meta:m(M({}))}),Oe=ye.extend({method:k(`resources/list`)}),ke=be.extend({resources:D(Ee)}),Ae=ye.extend({method:k(`resources/templates/list`)}),je=be.extend({resourceTemplates:D(De)}),Me=s.extend({uri:g()}),Ne=Me,Pe=l.extend({method:k(`resources/read`),params:Ne}),Fe=f.extend({contents:D(h([xe,Ce]))}),Ie=d.extend({method:k(`notifications/resources/list_changed`),params:u.optional()}),Le=Me,Re=l.extend({method:k(`resources/subscribe`),params:Le}),ze=Me,Be=l.extend({method:k(`resources/unsubscribe`),params:ze}),Ve=u.extend({uri:g()}),I=d.extend({method:k(`notifications/resources/updated`),params:Ve}),He=S({name:g(),description:m(g()),required:m(O())}),Ue=S({...T.shape,...w.shape,description:m(g()),arguments:m(D(He)),_meta:m(M({}))}),We=ye.extend({method:k(`prompts/list`)}),Ge=be.extend({prompts:D(Ue)}),Ke=s.extend({name:g(),arguments:C(g(),g()).optional()}),qe=l.extend({method:k(`prompts/get`),params:Ke}),L=S({type:k(`text`),text:g(),annotations:Te.optional(),_meta:C(g(),b()).optional()}),Je=S({type:k(`image`),data:Se,mimeType:g(),annotations:Te.optional(),_meta:C(g(),b()).optional()}),R=S({type:k(`audio`),data:Se,mimeType:g(),annotations:Te.optional(),_meta:C(g(),b()).optional()}),z=S({type:k(`tool_use`),name:g(),id:g(),input:C(g(),b()),_meta:C(g(),b()).optional()}),B=S({type:k(`resource`),resource:h([xe,Ce]),annotations:Te.optional(),_meta:C(g(),b()).optional()}),Ye=Ee.extend({type:k(`resource_link`)}),V=h([L,Je,R,Ye,B]),Xe=S({role:we,content:V}),Ze=f.extend({description:g().optional(),messages:D(Xe)}),Qe=d.extend({method:k(`notifications/prompts/list_changed`),params:u.optional()}),$e=S({title:g().optional(),readOnlyHint:O().optional(),destructiveHint:O().optional(),idempotentHint:O().optional(),openWorldHint:O().optional()}),et=S({taskSupport:E([`required`,`optional`,`forbidden`]).optional()}),tt=S({...T.shape,...w.shape,description:g().optional(),inputSchema:S({type:k(`object`),properties:C(g(),e).optional(),required:D(g()).optional()}).catchall(b()),outputSchema:S({type:k(`object`),properties:C(g(),e).optional(),required:D(g()).optional()}).catchall(b()).optional(),annotations:$e.optional(),execution:et.optional(),_meta:C(g(),b()).optional()}),nt=ye.extend({method:k(`tools/list`)}),rt=be.extend({tools:D(tt)}),it=f.extend({content:D(V),structuredContent:C(g(),b()).optional(),isError:O().optional()}),at=c.extend({name:g(),arguments:C(g(),b()).optional()}),ot=l.extend({method:k(`tools/call`),params:at}),st=d.extend({method:k(`notifications/tools/list_changed`),params:u.optional()}),ct=E([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),H=s.extend({level:ct}),lt=l.extend({method:k(`logging/setLevel`),params:H}),ut=u.extend({level:ct,logger:g().optional(),data:b()}),dt=d.extend({method:k(`notifications/message`),params:ut}),ft=S({name:g().optional()}),pt=S({hints:D(ft).optional(),costPriority:j().min(0).max(1).optional(),speedPriority:j().min(0).max(1).optional(),intelligencePriority:j().min(0).max(1).optional()}),mt=S({mode:E([`auto`,`required`,`none`]).optional()}),ht=S({type:k(`tool_result`),toolUseId:g().describe(`The unique identifier for the corresponding tool call.`),content:D(V),structuredContent:S({}).loose().optional(),isError:O().optional(),_meta:C(g(),b()).optional()}),gt=se(`type`,[L,Je,R]),_t=se(`type`,[L,Je,R,z,ht]),vt=S({role:we,content:h([_t,D(_t)]),_meta:C(g(),b()).optional()}),yt=c.extend({messages:D(vt),modelPreferences:pt.optional(),systemPrompt:g().optional(),includeContext:E([`none`,`thisServer`,`allServers`]).optional(),temperature:j().optional(),maxTokens:j().int(),stopSequences:D(g()).optional(),metadata:t.optional(),tools:D(tt).optional(),toolChoice:mt.optional()}),bt=l.extend({method:k(`sampling/createMessage`),params:yt}),xt=f.extend({model:g(),stopReason:m(E([`endTurn`,`stopSequence`,`maxTokens`]).or(g())),role:we,content:gt}),St=f.extend({model:g(),stopReason:m(E([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(g())),role:we,content:h([_t,D(_t)])}),Ct=S({type:k(`boolean`),title:g().optional(),description:g().optional(),default:O().optional()}),wt=S({type:k(`string`),title:g().optional(),description:g().optional(),minLength:j().optional(),maxLength:j().optional(),format:E([`email`,`uri`,`date`,`date-time`]).optional(),default:g().optional()}),Tt=S({type:E([`number`,`integer`]),title:g().optional(),description:g().optional(),minimum:j().optional(),maximum:j().optional(),default:j().optional()}),Et=S({type:k(`string`),title:g().optional(),description:g().optional(),enum:D(g()),default:g().optional()}),Dt=S({type:k(`string`),title:g().optional(),description:g().optional(),oneOf:D(S({const:g(),title:g()})),default:g().optional()}),Ot=S({type:k(`string`),title:g().optional(),description:g().optional(),enum:D(g()),enumNames:D(g()).optional(),default:g().optional()}),kt=h([Et,Dt]),At=S({type:k(`array`),title:g().optional(),description:g().optional(),minItems:j().optional(),maxItems:j().optional(),items:S({type:k(`string`),enum:D(g())}),default:D(g()).optional()}),jt=S({type:k(`array`),title:g().optional(),description:g().optional(),minItems:j().optional(),maxItems:j().optional(),items:S({anyOf:D(S({const:g(),title:g()}))}),default:D(g()).optional()}),Mt=h([At,jt]),Nt=h([Ot,kt,Mt]),Pt=h([Nt,Ct,wt,Tt]),Ft=c.extend({mode:k(`form`).optional(),message:g(),requestedSchema:S({type:k(`object`),properties:C(g(),Pt),required:D(g()).optional()}).catchall(b())}),It=c.extend({mode:k(`url`),message:g(),elicitationId:g(),url:g().url()}),Lt=h([Ft,It]),U=l.extend({method:k(`elicitation/create`),params:Lt}),W=u.extend({elicitationId:g()}),Rt=d.extend({method:k(`notifications/elicitation/complete`),params:W}),zt=f.extend({action:E([`accept`,`decline`,`cancel`]),content:A(e=>e===null?void 0:e,C(g(),h([g(),j(),O(),D(g())])).optional())}),Bt=S({type:k(`ref/resource`),uri:g()}),Vt=S({type:k(`ref/prompt`),name:g()}),Ht=s.extend({ref:h([Vt,Bt]),argument:S({name:g(),value:g()}),context:S({arguments:C(g(),g()).optional()}).optional()}),Ut=l.extend({method:k(`completion/complete`),params:Ht}),Wt=f.extend({completion:M({values:D(g()).max(100),total:m(j().int()),hasMore:m(O())})}),Gt=S({uri:g().startsWith(`file://`),name:g().optional(),_meta:C(g(),b()).optional()}),Kt=l.extend({method:k(`roots/list`),params:s.optional()}),qt=f.extend({roots:D(Gt)}),Jt=d.extend({method:k(`notifications/roots/list_changed`),params:u.optional()}),Yt=M({ttl:j().optional(),pollInterval:j().optional()}),Xt=E([`working`,`input_required`,`completed`,`failed`,`cancelled`]),Zt=S({taskId:g(),status:Xt,ttl:h([j(),oe()]),createdAt:g(),lastUpdatedAt:g(),pollInterval:m(j()),statusMessage:m(g())}),Qt=f.extend({task:Zt}),$t=u.merge(Zt),en=d.extend({method:k(`notifications/tasks/status`),params:$t}),tn=l.extend({method:k(`tasks/get`),params:s.extend({taskId:g()})}),G=f.merge(Zt),nn=l.extend({method:k(`tasks/result`),params:s.extend({taskId:g()})}),rn=f.loose(),an=ye.extend({method:k(`tasks/list`)}),on=be.extend({tasks:D(Zt)}),sn=l.extend({method:k(`tasks/cancel`),params:s.extend({taskId:g()})});return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:n,CursorSchema:r,TaskMetadataSchema:i,RelatedTaskMetadataSchema:a,RequestMetaSchema:o,BaseRequestParamsSchema:s,TaskAugmentedRequestParamsSchema:c,RequestSchema:l,NotificationsParamsSchema:u,NotificationSchema:d,ResultSchema:f,RequestIdSchema:p,EmptyResultSchema:_,CancelledNotificationParamsSchema:v,CancelledNotificationSchema:y,IconSchema:x,IconsSchema:w,BaseMetadataSchema:T,ImplementationSchema:te,ClientTasksCapabilitySchema:ae,ServerTasksCapabilitySchema:ce,ClientCapabilitiesSchema:le,InitializeRequestParamsSchema:ue,InitializeRequestSchema:de,ServerCapabilitiesSchema:fe,InitializeResultSchema:me,InitializedNotificationSchema:he,PingRequestSchema:N,ProgressSchema:P,ProgressNotificationParamsSchema:ge,ProgressNotificationSchema:_e,PaginatedRequestParamsSchema:ve,PaginatedRequestSchema:ye,PaginatedResultSchema:be,ResourceContentsSchema:F,TextResourceContentsSchema:xe,BlobResourceContentsSchema:Ce,RoleSchema:we,AnnotationsSchema:Te,ResourceSchema:Ee,ResourceTemplateSchema:De,ListResourcesRequestSchema:Oe,ListResourcesResultSchema:ke,ListResourceTemplatesRequestSchema:Ae,ListResourceTemplatesResultSchema:je,ResourceRequestParamsSchema:Me,ReadResourceRequestParamsSchema:Ne,ReadResourceRequestSchema:Pe,ReadResourceResultSchema:Fe,ResourceListChangedNotificationSchema:Ie,SubscribeRequestParamsSchema:Le,SubscribeRequestSchema:Re,UnsubscribeRequestParamsSchema:ze,UnsubscribeRequestSchema:Be,ResourceUpdatedNotificationParamsSchema:Ve,ResourceUpdatedNotificationSchema:I,PromptArgumentSchema:He,PromptSchema:Ue,ListPromptsRequestSchema:We,ListPromptsResultSchema:Ge,GetPromptRequestParamsSchema:Ke,GetPromptRequestSchema:qe,TextContentSchema:L,ImageContentSchema:Je,AudioContentSchema:R,ToolUseContentSchema:z,EmbeddedResourceSchema:B,ResourceLinkSchema:Ye,ContentBlockSchema:V,PromptMessageSchema:Xe,GetPromptResultSchema:Ze,PromptListChangedNotificationSchema:Qe,ToolAnnotationsSchema:$e,ToolExecutionSchema:et,ToolSchema:tt,ListToolsRequestSchema:nt,ListToolsResultSchema:rt,CallToolResultSchema:it,CallToolRequestParamsSchema:at,CallToolRequestSchema:ot,ToolListChangedNotificationSchema:st,LoggingLevelSchema:ct,SetLevelRequestParamsSchema:H,SetLevelRequestSchema:lt,LoggingMessageNotificationParamsSchema:ut,LoggingMessageNotificationSchema:dt,ModelHintSchema:ft,ModelPreferencesSchema:pt,ToolChoiceSchema:mt,ToolResultContentSchema:ht,SamplingContentSchema:gt,SamplingMessageContentBlockSchema:_t,SamplingMessageSchema:vt,CreateMessageRequestParamsSchema:yt,CreateMessageRequestSchema:bt,CreateMessageResultSchema:xt,CreateMessageResultWithToolsSchema:St,BooleanSchemaSchema:Ct,StringSchemaSchema:wt,NumberSchemaSchema:Tt,UntitledSingleSelectEnumSchemaSchema:Et,TitledSingleSelectEnumSchemaSchema:Dt,LegacyTitledEnumSchemaSchema:Ot,SingleSelectEnumSchemaSchema:kt,UntitledMultiSelectEnumSchemaSchema:At,TitledMultiSelectEnumSchemaSchema:jt,MultiSelectEnumSchemaSchema:Mt,EnumSchemaSchema:Nt,PrimitiveSchemaDefinitionSchema:Pt,ElicitRequestFormParamsSchema:Ft,ElicitRequestURLParamsSchema:It,ElicitRequestParamsSchema:Lt,ElicitRequestSchema:U,ElicitationCompleteNotificationParamsSchema:W,ElicitationCompleteNotificationSchema:Rt,ElicitResultSchema:zt,ResourceTemplateReferenceSchema:Bt,PromptReferenceSchema:Vt,CompleteRequestParamsSchema:Ht,CompleteRequestSchema:Ut,CompleteResultSchema:Wt,RootSchema:Gt,ListRootsRequestSchema:Kt,ListRootsResultSchema:qt,RootsListChangedNotificationSchema:Jt,TaskCreationParamsSchema:Yt,TaskStatusSchema:Xt,TaskSchema:Zt,CreateTaskResultSchema:Qt,TaskStatusNotificationParamsSchema:$t,TaskStatusNotificationSchema:en,GetTaskRequestSchema:tn,GetTaskResultSchema:G,GetTaskPayloadRequestSchema:nn,GetTaskPayloadResultSchema:rn,ListTasksRequestSchema:an,ListTasksResultSchema:on,CancelTaskRequestSchema:sn,CancelTaskResultSchema:f.merge(Zt),ClientRequestSchema:h([N,de,Ut,lt,qe,We,Oe,Ae,Pe,Re,Be,ot,nt,tn,nn,an,sn]),ClientNotificationSchema:h([y,_e,he,Jt,en]),ClientResultSchema:h([_,xt,St,zt,qt,G,on,Qt]),ServerRequestSchema:h([N,bt,U,Kt,tn,nn,an,sn]),ServerNotificationSchema:h([y,_e,dt,I,Ie,st,Qe,en,Rt]),ServerResultSchema:h([_,me,Wt,Ze,Ge,ke,je,Fe,it,rt,G,on,Qt]),CallToolResultWireSchema:b().superRefine((e,t)=>{if(typeof e==`object`&&e&&!Array.isArray(e)&&e.content===void 0){for(let n of fi)if(n in e){t.addIssue({code:`custom`,message:`content is required when the body carries '${n}' — another result family cannot default into an empty tools/call success`});return}}}).transform(pi).pipe(it)}}var hi;function gi(){return hi??=mi()}function _i(e){return e.type!==`object`}var vi=new Set([`const`,`enum`,`default`,`examples`]),yi=new Set([`properties`,`patternProperties`,`$defs`,`definitions`,`dependentSchemas`,`dependencies`]);function bi(e){return e!==void 0&&!(typeof e==`string`&&e.startsWith(`#`))}function xi(e){let t=typeof e.$schema==`string`?e.$schema:void 0;if(bi(e.$id))return{...t!==void 0&&{$schema:t},type:`object`,properties:{result:e},required:[`result`]};let n=Ae(e.$schema)&&e.$recursiveAnchor!==!0,r=(e,t)=>{if(Array.isArray(e))return e.map(e=>r(e,!1));if(typeof e!=`object`||!e||!t&&bi(e.$id))return e;let i={},a=!1;for(let[o,s]of Object.entries(e))t?i[o]=r(s,!1):(o===`$ref`||o===`$dynamicRef`)&&typeof s==`string`?i[o]=s===`#`?`#/properties/result`:s.startsWith(`#/`)?`#/properties/result${s.slice(1)}`:s:o===`$recursiveRef`&&s===`#`&&n?a=!0:i[o]=vi.has(o)?s:yi.has(o)?r(s,!0):r(s,!1);return a&&(`$ref`in i?i.allOf=[...Array.isArray(i.allOf)?i.allOf:[],{$ref:`#/properties/result`}]:i.$ref=`#/properties/result`),i};return{...t!==void 0&&{$schema:t},type:`object`,properties:{result:r(e,!1)},required:[`result`]}}var Si={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"tasks/get":null,"tasks/result":null,"tasks/list":null,"tasks/cancel":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},Ci={"notifications/cancelled":null,"notifications/progress":null,"notifications/initialized":null,"notifications/roots/list_changed":null,"notifications/tasks/status":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/elicitation/complete":null},wi={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},Ti;function Ei(){if(Ti)return Ti;let e=gi();return Ti={requestSchemas:{ping:e.PingRequestSchema,initialize:e.InitializeRequestSchema,"completion/complete":e.CompleteRequestSchema,"logging/setLevel":e.SetLevelRequestSchema,"prompts/get":e.GetPromptRequestSchema,"prompts/list":e.ListPromptsRequestSchema,"resources/list":e.ListResourcesRequestSchema,"resources/templates/list":e.ListResourceTemplatesRequestSchema,"resources/read":e.ReadResourceRequestSchema,"resources/subscribe":e.SubscribeRequestSchema,"resources/unsubscribe":e.UnsubscribeRequestSchema,"tools/call":e.CallToolRequestSchema,"tools/list":e.ListToolsRequestSchema,"tasks/get":e.GetTaskRequestSchema,"tasks/result":e.GetTaskPayloadRequestSchema,"tasks/list":e.ListTasksRequestSchema,"tasks/cancel":e.CancelTaskRequestSchema,"sampling/createMessage":e.CreateMessageRequestSchema,"elicitation/create":e.ElicitRequestSchema,"roots/list":e.ListRootsRequestSchema},notificationSchemas:{"notifications/cancelled":e.CancelledNotificationSchema,"notifications/progress":e.ProgressNotificationSchema,"notifications/initialized":e.InitializedNotificationSchema,"notifications/roots/list_changed":e.RootsListChangedNotificationSchema,"notifications/tasks/status":e.TaskStatusNotificationSchema,"notifications/message":e.LoggingMessageNotificationSchema,"notifications/resources/updated":e.ResourceUpdatedNotificationSchema,"notifications/resources/list_changed":e.ResourceListChangedNotificationSchema,"notifications/tools/list_changed":e.ToolListChangedNotificationSchema,"notifications/prompts/list_changed":e.PromptListChangedNotificationSchema,"notifications/elicitation/complete":e.ElicitationCompleteNotificationSchema},resultSchemas:{ping:e.EmptyResultSchema,initialize:e.InitializeResultSchema,"completion/complete":e.CompleteResultSchema,"logging/setLevel":e.EmptyResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"resources/subscribe":e.EmptyResultSchema,"resources/unsubscribe":e.EmptyResultSchema,"tools/call":e.CallToolResultWireSchema,"tools/list":e.ListToolsResultSchema,"sampling/createMessage":e.CreateMessageResultWithToolsSchema,"elicitation/create":e.ElicitResultSchema,"roots/list":e.ListRootsResultSchema}},Ti}function Di(e){return Object.prototype.hasOwnProperty.call(Si,e)}function Oi(e){return Object.prototype.hasOwnProperty.call(Ci,e)}function ki(e){return Object.prototype.hasOwnProperty.call(wi,e)}function Ai(e){return ki(e)?Ei().resultSchemas[e]:void 0}function ji(e){return Di(e)?Ei().requestSchemas[e]:void 0}function Mi(e){return Oi(e)?Ei().notificationSchemas[e]:void 0}Object.keys(Si),Object.keys(Ci);function Ni(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Pi(e,t){if(e===void 0)return{ok:!1,reason:`not-in-era`};let n=e.safeParse(t);return n.success?{ok:!0,value:n.data}:{ok:!1,reason:`invalid`,message:String(n.error)}}var Fi={ok:!1,reason:`not-in-era`};function Ii(e){return Ni(e)&&Ni(e.outputSchema)&&_i(e.outputSchema)}function Li(e){return e}var Ri={era:`2025-11-25`,hasRequestMethod:Di,hasNotificationMethod:Oi,validateRequest:(e,t)=>Pi(ji(e),t),validateResult:(e,t)=>Pi(Ai(e),t),validateNotification:(e,t)=>Pi(Mi(e),t),hasInputRequestMethod:()=>!1,validateInputRequest:()=>Fi,validateInputResponse:()=>Fi,samplingResultVariant:((e,t)=>{let n=gi();return Pi(e?n.CreateMessageResultWithToolsSchema:n.CreateMessageResultSchema,t)}),outboundEnvelope:e=>void 0,validateEnvelopeMeta:e=>[],projectCallToolResult(e,t){let n=di(e),r=n.structuredContent;if(r===void 0)return n;let i=typeof r!=`object`||!r||Array.isArray(r),a=t!==void 0&&_i(t);return!i&&!a?n:{...n,structuredContent:{result:r}}},decodeResult(e,t){if(Ni(t)&&`resultType`in t){let e={...t};return delete e.resultType,{kind:`complete`,result:Li(e)}}return{kind:`complete`,result:Li(t)}},encodeResult(e,t){if(e!==`tools/list`)return t;let n=t.tools;return!Array.isArray(n)||!n.some(e=>Ii(e))?t:{...t,tools:n.map(e=>Ii(e)?{...e,outputSchema:xi(e.outputSchema)}:e)}},encodeErrorCode:e=>e===-32002?-32602:e,checkInboundEnvelope:e=>void 0};function zi(){let e=ee(()=>h([g(),j(),O(),oe(),C(g(),e),D(e)])),t=C(g(),e),n=h([g(),j().int()]),r=g(),i=h([g(),j().int()]),a=E([`user`,`assistant`]),o=E([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),s=g().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),c=S({ttl:j().optional()}),l=S({taskId:g()}),u=M({progressToken:n.optional(),"io.modelcontextprotocol/related-task":l.optional()}),d=S({_meta:u.optional()}),f=d.extend({task:c.optional()}),p=S({_meta:u.optional()}),_=S({method:g(),params:p.loose().optional()}),v=S({src:g(),mimeType:g().optional(),sizes:D(g()).optional(),theme:E([`light`,`dark`]).optional()}),y=S({icons:D(v).optional()}),x=S({name:g(),title:g().optional()}),w=x.extend({...x.shape,...y.shape,version:g(),websiteUrl:g().optional(),description:g().optional()}),T=ne(S({applyDefaults:O().optional()}),t),te=A(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,ne(S({form:T.optional(),url:t.optional()}),t.optional())),re=M({list:t.optional(),cancel:t.optional(),requests:M({sampling:M({createMessage:t.optional()}).optional(),elicitation:M({create:t.optional()}).optional()}).optional()}),ie=M({list:t.optional(),cancel:t.optional(),requests:M({tools:M({call:t.optional()}).optional()}).optional()}),ae=S({experimental:C(g(),t).optional(),sampling:S({context:t.optional(),tools:t.optional()}).optional(),elicitation:te.optional(),roots:S({listChanged:O().optional()}).optional(),tasks:re.optional(),extensions:C(g(),t).optional()}),se=S({experimental:C(g(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:S({listChanged:O().optional()}).optional(),resources:S({subscribe:O().optional(),listChanged:O().optional()}).optional(),tools:S({listChanged:O().optional()}).optional(),tasks:ie.optional(),extensions:C(g(),t).optional()}),ce=S({progress:j(),total:m(j()),message:m(g())}),le=S({...p.shape,...ce.shape,progressToken:n}),ue=_.extend({method:k(`notifications/progress`),params:le}),de=p.extend({level:o,logger:g().optional(),data:b()}),fe=_.extend({method:k(`notifications/message`),params:de}),me=S({uri:g(),mimeType:m(g()),_meta:C(g(),b()).optional()}),he=me.extend({text:g()}),N=me.extend({blob:s}),P=S({audience:D(a).optional(),priority:j().min(0).max(1).optional(),lastModified:pe({offset:!0}).optional()}),ge=S({...x.shape,...y.shape,uri:g(),description:m(g()),mimeType:m(g()),size:m(j()),annotations:P.optional(),_meta:m(M({}))}),_e=S({...x.shape,...y.shape,uriTemplate:g(),description:m(g()),mimeType:m(g()),annotations:P.optional(),_meta:m(M({}))}),ve=_.extend({method:k(`notifications/resources/list_changed`),params:p.optional()}),ye=p.extend({uri:g()}),be=_.extend({method:k(`notifications/resources/updated`),params:ye}),F=S({name:g(),description:m(g()),required:m(O())}),xe=S({...x.shape,...y.shape,description:m(g()),arguments:m(D(F)),_meta:m(M({}))}),Se=_.extend({method:k(`notifications/prompts/list_changed`),params:p.optional()}),Ce=S({type:k(`text`),text:g(),annotations:P.optional(),_meta:C(g(),b()).optional()}),we=S({type:k(`image`),data:s,mimeType:g(),annotations:P.optional(),_meta:C(g(),b()).optional()}),Te=S({type:k(`audio`),data:s,mimeType:g(),annotations:P.optional(),_meta:C(g(),b()).optional()}),Ee=S({type:k(`tool_use`),name:g(),id:g(),input:C(g(),b()),_meta:C(g(),b()).optional()}),De=S({type:k(`resource`),resource:h([he,N]),annotations:P.optional(),_meta:C(g(),b()).optional()}),Oe=ge.extend({type:k(`resource_link`)}),ke=h([Ce,we,Te,Oe,De]),Ae=S({role:a,content:ke}),je=S({title:g().optional(),readOnlyHint:O().optional(),destructiveHint:O().optional(),idempotentHint:O().optional(),openWorldHint:O().optional()}),Me=_.extend({method:k(`notifications/tools/list_changed`),params:p.optional()}),Ne=S({name:g().optional()}),Pe=S({hints:D(Ne).optional(),costPriority:j().min(0).max(1).optional(),speedPriority:j().min(0).max(1).optional(),intelligencePriority:j().min(0).max(1).optional()}),ze=S({mode:E([`auto`,`required`,`none`]).optional()}),Ve=S({type:k(`boolean`),title:g().optional(),description:g().optional(),default:O().optional()}),I=S({type:k(`string`),title:g().optional(),description:g().optional(),minLength:j().optional(),maxLength:j().optional(),format:E([`email`,`uri`,`date`,`date-time`]).optional(),default:g().optional()}),He=S({type:E([`number`,`integer`]),title:g().optional(),description:g().optional(),minimum:j().optional(),maximum:j().optional(),default:j().optional()}),Ue=S({type:k(`string`),title:g().optional(),description:g().optional(),enum:D(g()),default:g().optional()}),We=S({type:k(`string`),title:g().optional(),description:g().optional(),oneOf:D(S({const:g(),title:g()})),default:g().optional()}),Ge=S({type:k(`string`),title:g().optional(),description:g().optional(),enum:D(g()),enumNames:D(g()).optional(),default:g().optional()}),Ke=h([Ue,We]),qe=S({type:k(`array`),title:g().optional(),description:g().optional(),minItems:j().optional(),maxItems:j().optional(),items:S({type:k(`string`),enum:D(g())}),default:D(g()).optional()}),L=S({type:k(`array`),title:g().optional(),description:g().optional(),minItems:j().optional(),maxItems:j().optional(),items:S({anyOf:D(S({const:g(),title:g()}))}),default:D(g()).optional()}),Je=h([qe,L]),R=h([Ge,Ke,Je]),z=h([R,Ve,I,He]),B=f.extend({mode:k(`form`).optional(),message:g(),requestedSchema:S({type:k(`object`),properties:C(g(),z),required:D(g()).optional()}).catchall(b())}),Ye=S({type:k(`ref/resource`),uri:g()}),V=S({type:k(`ref/prompt`),name:g()}),Xe=S({uri:g().startsWith(`file://`),name:g().optional(),_meta:C(g(),b()).optional()}),Ze=ae.shape,Qe=S({experimental:Ze.experimental,sampling:Ze.sampling,elicitation:Ze.elicitation,roots:Ze.roots,extensions:Ze.extensions}),$e=se.shape,et=S({experimental:$e.experimental,logging:$e.logging,completions:$e.completions,prompts:$e.prompts,resources:$e.resources,tools:$e.tools,extensions:$e.extensions}),tt=M({progressToken:n.optional(),[Fe]:g(),[Ie]:w.optional(),[Re]:Qe,[Be]:o.optional()}),nt=S({...x.shape,...y.shape,description:g().optional(),inputSchema:M({$schema:g().optional(),type:k(`object`)}),outputSchema:M({$schema:g().optional()}).optional(),annotations:je.optional(),_meta:C(g(),b()).optional()}),rt=S({type:k(`tool_result`),toolUseId:g(),content:D(ke),structuredContent:b().optional(),isError:O().optional(),_meta:C(g(),b()).optional()}),it=h([Ce,we,Te,Ee,rt]),at=S({role:a,content:h([it,D(it)]),_meta:C(g(),b()).optional()}),ot=g(),st=M({[Le]:w.optional().catch(void 0)}),ct=st.optional();function H(e){return M({_meta:ct,resultType:ot.default(`complete`),...e})}let lt=H({}),ut=H({nextCursor:r.optional()}),dt=H({content:D(ke),structuredContent:b().optional(),isError:O().optional()}),ft=H({ttlMs:j().int().min(0),cacheScope:E([`public`,`private`]),tools:D(nt),nextCursor:r.optional()}),pt=H({ttlMs:j().int().min(0),cacheScope:E([`public`,`private`]),prompts:D(xe),nextCursor:r.optional()}),mt=H({description:g().optional(),messages:D(Ae)}),ht=H({ttlMs:j().int().min(0),cacheScope:E([`public`,`private`]),resources:D(ge),nextCursor:r.optional()}),gt=H({ttlMs:j().int().min(0),cacheScope:E([`public`,`private`]),resourceTemplates:D(_e),nextCursor:r.optional()}),_t=H({ttlMs:j().int().min(0),cacheScope:E([`public`,`private`]),contents:D(h([he,N]))}),vt=H({completion:S({values:D(g()).max(100),total:j().int().optional(),hasMore:O().optional()}).loose()}),yt=H({ttlMs:j().int().min(0),cacheScope:E([`public`,`private`])}),bt=H({ttlMs:j().int().min(0).catch(0),cacheScope:E([`public`,`private`]).catch(`private`),supportedVersions:D(g()),capabilities:et,instructions:g().optional()}),xt=S({messages:D(at),modelPreferences:Pe.optional(),systemPrompt:g().optional(),includeContext:E([`none`,`thisServer`,`allServers`]).optional(),temperature:j().optional(),maxTokens:j().int(),stopSequences:D(g()).optional(),metadata:t.optional(),tools:D(nt).optional(),toolChoice:ze.optional()}),St=S({method:k(`sampling/createMessage`),params:xt}),Ct=S({method:k(`roots/list`),params:S({_meta:C(g(),b()).optional()}).optional()}),wt=S({...at.shape,model:g(),stopReason:g().optional()}),Tt=S({roots:D(Xe)}),Et=S({action:E([`accept`,`decline`,`cancel`]),content:C(g(),h([g(),j(),O(),D(g())])).optional()}),Dt=S({mode:k(`url`),message:g(),url:g().url()}),Ot=h([B,Dt]),kt=S({method:k(`elicitation/create`),params:Ot}),At=h([St,Ct,kt]),jt=h([wt,Tt,Et]),Mt=C(g(),At),Nt=C(g(),jt),Pt=H({inputRequests:Mt.optional(),requestState:g().optional()}),Ft={inputResponses:Nt.optional(),requestState:g().optional()},It=S({_meta:tt,...Ft}),Lt=M({progressToken:n.optional()});function U(e,t){return S({method:k(e),params:S({_meta:tt,...t})})}function W(e,t){return S({method:k(e),params:S({_meta:Lt.optional(),...t}).optional()})}let Rt={name:g(),arguments:C(g(),b()).optional(),...Ft},zt={cursor:r.optional()},Bt=U(`tools/call`,Rt),Vt=U(`tools/list`,zt),Ht=U(`prompts/list`,zt),Ut=U(`prompts/get`,{name:g(),arguments:C(g(),g()).optional(),...Ft}),Wt=U(`resources/list`,zt),Gt=U(`resources/templates/list`,zt),Kt=U(`resources/read`,{uri:g(),...Ft}),qt={ref:h([V,Ye]),argument:S({name:g(),value:g()}),context:S({arguments:C(g(),g()).optional()}).optional()},Jt=U(`completion/complete`,qt),Yt=U(`server/discover`,{}),Xt=S({toolsListChanged:O().optional(),promptsListChanged:O().optional(),resourcesListChanged:O().optional(),resourceSubscriptions:D(g()).optional()}),Zt={notifications:Xt},Qt=U(`subscriptions/listen`,Zt),$t=st.extend({"io.modelcontextprotocol/subscriptionId":i}),en=M({_meta:$t,resultType:ot.default(`complete`)}),tn={"tools/call":W(`tools/call`,Rt),"tools/list":W(`tools/list`,zt),"prompts/get":W(`prompts/get`,{name:g(),arguments:C(g(),g()).optional()}),"prompts/list":W(`prompts/list`,zt),"resources/list":W(`resources/list`,zt),"resources/templates/list":W(`resources/templates/list`,zt),"resources/read":W(`resources/read`,{uri:g()}),"completion/complete":W(`completion/complete`,qt),"server/discover":W(`server/discover`,{}),"subscriptions/listen":W(`subscriptions/listen`,Zt)};function G(e){return M({_meta:ct,...e})}let nn={"tools/call":G({content:D(ke),structuredContent:b().optional(),isError:O().optional()}),"tools/list":G({ttlMs:j().int().min(0),cacheScope:E([`public`,`private`]),tools:D(nt),nextCursor:r.optional()}),"prompts/get":G({description:g().optional(),messages:D(Ae)}),"prompts/list":G({ttlMs:j().int().min(0),cacheScope:E([`public`,`private`]),prompts:D(xe),nextCursor:r.optional()}),"resources/list":G({ttlMs:j().int().min(0),cacheScope:E([`public`,`private`]),resources:D(ge),nextCursor:r.optional()}),"resources/templates/list":G({ttlMs:j().int().min(0),cacheScope:E([`public`,`private`]),resourceTemplates:D(_e),nextCursor:r.optional()}),"resources/read":G({ttlMs:j().int().min(0),cacheScope:E([`public`,`private`]),contents:D(h([he,N]))}),"completion/complete":G({completion:S({values:D(g()).max(100),total:j().int().optional(),hasMore:O().optional()}).loose()}),"server/discover":G({ttlMs:j().int().min(0).catch(0),cacheScope:E([`public`,`private`]).catch(`private`),supportedVersions:D(g()),capabilities:et,instructions:g().optional()}),"subscriptions/listen":G({})},rn=M({"io.modelcontextprotocol/subscriptionId":i.optional()}),an=S({method:k(`notifications/subscriptions/acknowledged`),params:S({_meta:rn.optional(),notifications:Xt})}),on=S({_meta:rn.optional(),requestId:i,reason:g().optional()}),sn=S({method:k(`notifications/cancelled`),params:on}),cn={"notifications/cancelled":sn,"notifications/progress":ue,"notifications/message":fe,"notifications/resources/updated":be,"notifications/resources/list_changed":ve,"notifications/tools/list_changed":Me,"notifications/prompts/list_changed":Se,"notifications/subscriptions/acknowledged":an},K=e=>S({jsonrpc:k(`2.0`),id:h([g(),j().int()]),result:e}).strict();return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:n,CursorSchema:r,RequestIdSchema:i,RoleSchema:a,LoggingLevelSchema:o,TaskMetadataSchema:c,RelatedTaskMetadataSchema:l,RequestMetaSchema:u,BaseRequestParamsSchema:d,TaskAugmentedRequestParamsSchema:f,NotificationsParamsSchema:p,NotificationSchema:_,IconSchema:v,IconsSchema:y,BaseMetadataSchema:x,ImplementationSchema:w,ClientTasksCapabilitySchema:re,ServerTasksCapabilitySchema:ie,ClientCapabilitiesSchema:ae,ServerCapabilitiesSchema:se,ProgressSchema:ce,ProgressNotificationParamsSchema:le,ProgressNotificationSchema:ue,LoggingMessageNotificationParamsSchema:de,LoggingMessageNotificationSchema:fe,ResourceContentsSchema:me,TextResourceContentsSchema:he,BlobResourceContentsSchema:N,AnnotationsSchema:P,ResourceSchema:ge,ResourceTemplateSchema:_e,ResourceListChangedNotificationSchema:ve,ResourceUpdatedNotificationParamsSchema:ye,ResourceUpdatedNotificationSchema:be,PromptArgumentSchema:F,PromptSchema:xe,PromptListChangedNotificationSchema:Se,TextContentSchema:Ce,ImageContentSchema:we,AudioContentSchema:Te,ToolUseContentSchema:Ee,EmbeddedResourceSchema:De,ResourceLinkSchema:Oe,ContentBlockSchema:ke,PromptMessageSchema:Ae,ToolAnnotationsSchema:je,ToolListChangedNotificationSchema:Me,ModelHintSchema:Ne,ModelPreferencesSchema:Pe,ToolChoiceSchema:ze,BooleanSchemaSchema:Ve,StringSchemaSchema:I,NumberSchemaSchema:He,UntitledSingleSelectEnumSchemaSchema:Ue,TitledSingleSelectEnumSchemaSchema:We,LegacyTitledEnumSchemaSchema:Ge,SingleSelectEnumSchemaSchema:Ke,UntitledMultiSelectEnumSchemaSchema:qe,TitledMultiSelectEnumSchemaSchema:L,MultiSelectEnumSchemaSchema:Je,EnumSchemaSchema:R,PrimitiveSchemaDefinitionSchema:z,ElicitRequestFormParamsSchema:B,ResourceTemplateReferenceSchema:Ye,PromptReferenceSchema:V,RootSchema:Xe,ClientCapabilities2026Schema:Qe,ServerCapabilities2026Schema:et,RequestMetaEnvelopeSchema:tt,ToolSchema:nt,ToolResultContentSchema:rt,SamplingMessageContentBlockSchema:it,SamplingMessageSchema:at,ResultTypeSchema:ot,ResultMetaSchema:st,ResultSchema:lt,PaginatedResultSchema:ut,CallToolResultSchema:dt,ListToolsResultSchema:ft,ListPromptsResultSchema:pt,GetPromptResultSchema:mt,ListResourcesResultSchema:ht,ListResourceTemplatesResultSchema:gt,ReadResourceResultSchema:_t,CompleteResultSchema:vt,CacheableResultSchema:yt,DiscoverResultSchema:bt,CreateMessageRequestParamsSchema:xt,CreateMessageRequestSchema:St,ListRootsRequestSchema:Ct,CreateMessageResultSchema:wt,ListRootsResultSchema:Tt,ElicitResultSchema:Et,ElicitRequestURLParamsSchema:Dt,ElicitRequestParamsSchema:Ot,ElicitRequestSchema:kt,InputRequestSchema:At,InputResponseSchema:jt,InputRequestsSchema:Mt,InputResponsesSchema:Nt,InputRequiredResultSchema:Pt,InputResponseRequestParamsSchema:It,CallToolRequestSchema:Bt,ListToolsRequestSchema:Vt,ListPromptsRequestSchema:Ht,GetPromptRequestSchema:Ut,ListResourcesRequestSchema:Wt,ListResourceTemplatesRequestSchema:Gt,ReadResourceRequestSchema:Kt,CompleteRequestSchema:Jt,DiscoverRequestSchema:Yt,SubscriptionFilterSchema:Xt,SubscriptionsListenRequestSchema:Qt,SubscriptionsListenResultMetaSchema:$t,SubscriptionsListenResultSchema:en,dispatchRequestSchemas:tn,dispatchResultSchemas:nn,NotificationMetaSchema:rn,SubscriptionsAcknowledgedNotificationSchema:an,CancelledNotificationParamsSchema:on,CancelledNotificationSchema:sn,notificationSchemas2026:cn,JSONRPCResultResponseSchema:K(lt),CallToolResultResponseSchema:K(h([dt,Pt])),ListToolsResultResponseSchema:K(ft),ListPromptsResultResponseSchema:K(pt),GetPromptResultResponseSchema:K(h([mt,Pt])),ListResourcesResultResponseSchema:K(ht),ListResourceTemplatesResultResponseSchema:K(gt),ReadResourceResultResponseSchema:K(h([_t,Pt])),CompleteResultResponseSchema:K(vt),DiscoverResultResponseSchema:K(bt),SubscriptionsListenResultResponseSchema:K(en)}}var Bi;function Vi(){return Bi??=zi()}var Hi=[`tools/list`,`prompts/list`,`resources/list`,`resources/templates/list`,`resources/read`,`server/discover`];function Ui(e){return Hi.includes(e)}var Wi=Symbol(`modelcontextprotocol.resultCacheHintFallback`);function Gi(e){return e[Wi]}function Ki(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function qi(e){return e===`public`||e===`private`}var X=function(e){return e[e.ParseError=-32700]=`ParseError`,e[e.InvalidRequest=-32600]=`InvalidRequest`,e[e.MethodNotFound=-32601]=`MethodNotFound`,e[e.InvalidParams=-32602]=`InvalidParams`,e[e.InternalError=-32603]=`InternalError`,e[e.ResourceNotFound=-32002]=`ResourceNotFound`,e[e.MissingRequiredClientCapability=-32021]=`MissingRequiredClientCapability`,e[e.UnsupportedProtocolVersion=-32022]=`UnsupportedProtocolVersion`,e[e.UrlElicitationRequired=-32042]=`UrlElicitationRequired`,e}({}),Z=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.ProtocolError`})}static[Symbol.hasInstance](e){return $r(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return $r(this,e)}constructor(e,t,n){super(t),this.code=e,this.data=n,this.name=`ProtocolError`,Qr(this,new.target)}static fromError(t,n,r){if(t===X.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new Yi(e.elicitations,n)}if(t===X.UnsupportedProtocolVersion&&r){let e=r;if(Array.isArray(e.supported)&&typeof e.requested==`string`)return new Xi({supported:e.supported,requested:e.requested},n)}if(t===X.InvalidParams||t===X.ResourceNotFound){let e=r;if(typeof e?.uri==`string`&&(t===X.ResourceNotFound||Object.keys(e).length===1))return new Ji(e.uri,n)}if(t===X.MissingRequiredClientCapability&&r){let e=r;if(e.requiredCapabilities!==null&&typeof e.requiredCapabilities==`object`&&!Array.isArray(e.requiredCapabilities))return new Zi({requiredCapabilities:e.requiredCapabilities},n)}return new e(t,n,r)}},Ji=class extends Z{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.ResourceNotFoundError`})}constructor(e,t=`Resource not found: ${e}`){super(X.InvalidParams,t,{uri:e})}get uri(){return this.data.uri}},Yi=class extends Z{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.UrlElicitationRequiredError`})}constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(X.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},Xi=class extends Z{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.UnsupportedProtocolVersionError`})}constructor(e,t=`Unsupported protocol version: ${e.requested}`){super(X.UnsupportedProtocolVersion,t,e)}get supported(){return this.data.supported}get requested(){return this.data.requested}},Zi=class extends Z{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.MissingRequiredClientCapabilityError`})}constructor(e,t=`Missing required client capabilities: ${Object.keys(e.requiredCapabilities).join(`, `)}`){super(X.MissingRequiredClientCapability,t,e)}get requiredCapabilities(){return this.data.requiredCapabilities}},Qi=0,$i=`private`,ea=[`tools/call`,`prompts/get`,`resources/read`];function ta(e,t){let n=t.resultType;if(n===void 0)return{...t,resultType:`complete`};if(n===`complete`||ea.includes(e))return t;throw new Z(X.InternalError,`Handler for ${e} returned resultType '${String(n)}', but results of ${e} only support 'complete' on protocol revision 2026-07-28`)}function na(e,t){let n=Gi(t);if(t.resultType!==`complete`||!Ui(e))return n===void 0?t:sa(t);let r=t,i=Ki(r.ttlMs)?r.ttlMs:aa(n),a=qi(r.cacheScope)?r.cacheScope:oa(n),o={...r,ttlMs:i,cacheScope:a};return delete o[Wi],o}function ra(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ia(e,t){if(t===void 0)return e;let n=e._meta;return n===void 0?{...e,_meta:{[Le]:t}}:!ra(n)||n[`io.modelcontextprotocol/serverInfo`]!==void 0?e:{...e,_meta:{...n,[Le]:t}}}function aa(e){return e!==void 0&&Ki(e.ttlMs)?e.ttlMs:Qi}function oa(e){return e!==void 0&&qi(e.cacheScope)?e.cacheScope:$i}function sa(e){let t={...e};return delete t[Wi],t}var ca=[`elicitation/create`,`sampling/createMessage`,`roots/list`],la;function ua(){if(la)return la;let e=Vi();return la={request:{"elicitation/create":S({method:k(`elicitation/create`),params:e.ElicitRequestParamsSchema}),"sampling/createMessage":S({method:k(`sampling/createMessage`),params:e.CreateMessageRequestParamsSchema}),"roots/list":S({method:k(`roots/list`),params:M({}).optional()})},response:{"elicitation/create":e.ElicitResultSchema,"sampling/createMessage":e.CreateMessageResultSchema,"roots/list":e.ListRootsResultSchema}},la}function da(e){return ca.includes(e)}function fa(e){return da(e)?ua().request[e]:void 0}function pa(e){return da(e)?ua().response[e]:void 0}var ma={"tools/call":null,"tools/list":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"completion/complete":null,"server/discover":null,"subscriptions/listen":null},ha={"notifications/cancelled":null,"notifications/progress":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/subscriptions/acknowledged":null};function ga(e){return Object.prototype.hasOwnProperty.call(ma,e)}function _a(e){return Object.prototype.hasOwnProperty.call(ha,e)}function va(e){return Object.prototype.hasOwnProperty.call(ma,e)}function ya(e){return ga(e)?Vi().dispatchRequestSchemas[e]:void 0}function ba(e){return va(e)?Vi().dispatchResultSchemas[e]:void 0}function xa(e){return _a(e)?Vi().notificationSchemas2026[e]:void 0}Object.keys(ma),Object.keys(ha);function Sa(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ca(e,t){if(e===void 0)return{ok:!1,reason:`not-in-era`};let n=e.safeParse(t);return n.success?{ok:!0,value:n.data}:{ok:!1,reason:`invalid`,message:String(n.error)}}var wa={ok:!1,reason:`not-in-era`},Ta=[Fe,Re];function Ea(e,t){let n=t,r=!1,i=()=>(r||=(n={...n},!0),n),a=t.tools;e===`tools/list`&&Array.isArray(a)&&a.some(e=>Sa(e)&&`execution`in e)&&(i().tools=a.map(e=>{if(!Sa(e)||!(`execution`in e))return e;let t={...e};return delete t.execution,t}));let o=t.capabilities;if(Sa(o)&&`tasks`in o){let e={...o};delete e.tasks,i().capabilities=e}return n}var Da={era:`2026-07-28`,hasRequestMethod:ga,hasNotificationMethod:_a,hasInputRequestMethod:e=>fa(e)!==void 0,validateRequest:(e,t)=>Ca(ya(e),t),validateResult:(e,t)=>Ca(ba(e),t),validateNotification:(e,t)=>Ca(xa(e),t),validateInputRequest:(e,t)=>Ca(fa(e),t),validateInputResponse:(e,t)=>Ca(pa(e),t),samplingResultVariant:()=>wa,outboundEnvelope(e){return{[Fe]:e.protocolVersion,[Ie]:e.clientInfo,[Re]:e.clientCapabilities,...e.logLevel!==void 0&&{"io.modelcontextprotocol/logLevel":e.logLevel}}},validateEnvelopeMeta(e){let t=[];for(let n of Ta)n in e||t.push({key:n,problem:`missing`});let n=Vi().RequestMetaEnvelopeSchema.safeParse(e);if(!n.success)for(let e of n.error.issues){let n=e.path.map(String),r=n.length>0?n.join(`.`):`_meta`;n.length===1&&t.some(e=>e.key===r&&e.problem===`missing`)||t.push({key:r,problem:e.message})}return t},projectCallToolResult:e=>di(e),inputRequestSchema:fa,decodeResult(e,t){if(!Sa(t))return{kind:`invalid`,error:new Y(J.InvalidResult,`Invalid result for ${e}: not an object`,{method:e})};let n=t.resultType;if(n===void 0)return{kind:`invalid`,error:new Y(J.InvalidResult,`Invalid result for ${e}: missing required resultType — servers implementing protocol revision 2026-07-28 MUST include it (the absent-means-complete bridge applies only to earlier-revision servers)`,{method:e,violation:`missing-resultType`})};if(typeof n!=`string`)return{kind:`invalid`,error:new Y(J.InvalidResult,`Invalid result for ${e}: non-string resultType`,{method:e,resultType:n})};if(n===`input_required`){let n=t.inputRequests,r=Sa(n)?n:{},i=t.requestState,a=t._meta===void 0?void 0:Vi().ResultMetaSchema.safeParse(t._meta),o=a?.success?a.data:void 0;return Object.keys(r).length===0&&typeof i!=`string`?{kind:`invalid`,error:new Y(J.InvalidResult,`Invalid result for ${e}: input_required carries neither inputRequests nor requestState (every input_required result must include at least one of the two)`,{method:e,violation:`input-required-missing-both`})}:{kind:`input_required`,inputRequests:r,...typeof i==`string`&&{requestState:i},...o!==void 0&&{_meta:o}}}if(n!==`complete`)return{kind:`invalid`,error:new Y(J.UnsupportedResultType,`Unsupported result type '${n}' for ${e}`,{resultType:n,method:e})};let r=ka(),i=Object.hasOwn(r,e)?r[e]:void 0;if(i!==void 0){let n=i.safeParse(t);if(!n.success)return{kind:`invalid`,error:new Y(J.InvalidResult,`Invalid result for ${e}: ${n.error}`,{method:e})}}let a={...t};return delete a.resultType,{kind:`complete`,result:a}},encodeResult(e,t,n){return ia(na(e,ta(e,Ea(e,t))),n)},encodeErrorCode:e=>e===-32002?-32602:e,checkInboundEnvelope(e){if(e.envelope===void 0)return`Request is missing the required _meta envelope for protocol revision 2026-07-28 (io.modelcontextprotocol/protocolVersion, io.modelcontextprotocol/clientCapabilities)`;let t=Vi().RequestMetaEnvelopeSchema.safeParse(e.envelope);if(!t.success)return`Invalid _meta envelope for protocol revision 2026-07-28: ${t.error.issues.map(e=>e.message).join(`; `)}`}},Oa;function ka(){if(Oa)return Oa;let e=Vi();return Oa={"tools/call":e.CallToolResultSchema,"tools/list":e.ListToolsResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"completion/complete":e.CompleteResultSchema,"server/discover":e.DiscoverResultSchema},Oa}var Aa=`2026-07-28`;function ja(e){return e!==void 0&&ci(e)?Da:Ri}function Ma(e){return e.revision===void 0?e.era===`modern`?Da.era:Ri.era:ja(e.revision).era}function Na(e){return Ia.some(t=>t.hasRequestMethod(e))}function Pa(e){return Ia.some(t=>t.hasNotificationMethod(e))}function Fa(e){return e===`tasks/get`||e===`tasks/cancel`}var Ia=[Ri,Da],La=Ce({AnnotationsSchema:()=>Nt,AudioContentSchema:()=>ln,BaseMetadataSchema:()=>ct,BaseRequestParamsSchema:()=>L,BlobResourceContentsSchema:()=>jt,BooleanSchemaSchema:()=>Wn,CallToolRequestParamsSchema:()=>wn,CallToolRequestSchema:()=>Tn,CallToolResultSchema:()=>Sn,CancelTaskRequestSchema:()=>Ar,CancelTaskResultSchema:()=>jr,CancelledNotificationParamsSchema:()=>it,CancelledNotificationSchema:()=>at,ClientCapabilitiesSchema:()=>pt,ClientNotificationSchema:()=>Nr,ClientRequestSchema:()=>Mr,ClientResultSchema:()=>Pr,ClientTasksCapabilitySchema:()=>dt,CompatibilityCallToolResultSchema:()=>Cn,CompleteRequestParamsSchema:()=>dr,CompleteRequestSchema:()=>fr,CompleteResultSchema:()=>pr,ContentBlockSchema:()=>pn,CreateMessageRequestParamsSchema:()=>Bn,CreateMessageRequestSchema:()=>Vn,CreateMessageResultSchema:()=>Hn,CreateMessageResultWithToolsSchema:()=>Un,CreateTaskResultSchema:()=>xr,CursorSchema:()=>We,DiscoverRequestSchema:()=>yt,DiscoverResultSchema:()=>bt,ElicitRequestFormParamsSchema:()=>nr,ElicitRequestParamsSchema:()=>ir,ElicitRequestSchema:()=>ar,ElicitRequestURLParamsSchema:()=>rr,ElicitResultSchema:()=>cr,ElicitationCompleteNotificationParamsSchema:()=>or,ElicitationCompleteNotificationSchema:()=>sr,EmbeddedResourceSchema:()=>dn,EmptyResultSchema:()=>rt,EnumSchemaSchema:()=>er,GetPromptRequestParamsSchema:()=>on,GetPromptRequestSchema:()=>sn,GetPromptResultSchema:()=>hn,GetTaskPayloadRequestSchema:()=>Er,GetTaskPayloadResultSchema:()=>Dr,GetTaskRequestSchema:()=>wr,GetTaskResultSchema:()=>Tr,IconSchema:()=>ot,IconsSchema:()=>st,ImageContentSchema:()=>K,ImplementationSchema:()=>H,InitializeRequestParamsSchema:()=>mt,InitializeRequestSchema:()=>ht,InitializeResultSchema:()=>_t,InitializedNotificationSchema:()=>vt,JSONArraySchema:()=>He,JSONObjectSchema:()=>I,JSONRPCErrorResponseSchema:()=>et,JSONRPCMessageSchema:()=>tt,JSONRPCNotificationSchema:()=>Qe,JSONRPCRequestSchema:()=>Ze,JSONRPCResponseSchema:()=>nt,JSONRPCResultResponseSchema:()=>$e,JSONValueSchema:()=>Ve,LegacyTitledEnumSchemaSchema:()=>Yn,ListChangedOptionsBaseSchema:()=>Dn,ListPromptsRequestSchema:()=>rn,ListPromptsResultSchema:()=>an,ListResourceTemplatesRequestSchema:()=>U,ListResourceTemplatesResultSchema:()=>W,ListResourcesRequestSchema:()=>It,ListResourcesResultSchema:()=>Lt,ListRootsRequestSchema:()=>hr,ListRootsResultSchema:()=>gr,ListTasksRequestSchema:()=>Or,ListTasksResultSchema:()=>kr,ListToolsRequestSchema:()=>bn,ListToolsResultSchema:()=>xn,LoggingLevelSchema:()=>On,LoggingMessageNotificationParamsSchema:()=>jn,LoggingMessageNotificationSchema:()=>Mn,ModelHintSchema:()=>Nn,ModelPreferencesSchema:()=>Pn,MultiSelectEnumSchemaSchema:()=>$n,NotificationSchema:()=>B,NotificationsParamsSchema:()=>z,NumberSchemaSchema:()=>Kn,PaginatedRequestParamsSchema:()=>Tt,PaginatedRequestSchema:()=>Et,PaginatedResultSchema:()=>Dt,PingRequestSchema:()=>xt,PrimitiveSchemaDefinitionSchema:()=>tr,ProgressNotificationParamsSchema:()=>Ct,ProgressNotificationSchema:()=>wt,ProgressSchema:()=>St,ProgressTokenSchema:()=>Ue,PromptArgumentSchema:()=>G,PromptListChangedNotificationSchema:()=>gn,PromptMessageSchema:()=>mn,PromptReferenceSchema:()=>ur,PromptSchema:()=>nn,ReadResourceRequestParamsSchema:()=>zt,ReadResourceRequestSchema:()=>Bt,ReadResourceResultSchema:()=>Vt,RelatedTaskMetadataSchema:()=>Ke,RequestIdSchema:()=>Xe,RequestMetaSchema:()=>qe,RequestSchema:()=>R,ResourceContentsSchema:()=>Ot,ResourceLinkSchema:()=>fn,ResourceListChangedNotificationSchema:()=>Ht,ResourceRequestParamsSchema:()=>Rt,ResourceSchema:()=>Pt,ResourceTemplateReferenceSchema:()=>lr,ResourceTemplateSchema:()=>Ft,ResourceUpdatedNotificationParamsSchema:()=>en,ResourceUpdatedNotificationSchema:()=>tn,ResultMetaObjectSchema:()=>Ye,ResultSchema:()=>V,RoleSchema:()=>Mt,RootSchema:()=>mr,RootsListChangedNotificationSchema:()=>_r,SamplingContentSchema:()=>Ln,SamplingMessageContentBlockSchema:()=>Rn,SamplingMessageSchema:()=>zn,ServerCapabilitiesSchema:()=>gt,ServerNotificationSchema:()=>Ir,ServerRequestSchema:()=>Fr,ServerResultSchema:()=>Lr,ServerTasksCapabilitySchema:()=>ft,SetLevelRequestParamsSchema:()=>kn,SetLevelRequestSchema:()=>An,SingleSelectEnumSchemaSchema:()=>Xn,StringSchemaSchema:()=>Gn,SubscribeRequestParamsSchema:()=>Ut,SubscribeRequestSchema:()=>Wt,SubscriptionFilterSchema:()=>qt,SubscriptionsAcknowledgedNotificationParamsSchema:()=>Xt,SubscriptionsAcknowledgedNotificationSchema:()=>Zt,SubscriptionsListenRequestParamsSchema:()=>Jt,SubscriptionsListenRequestSchema:()=>Yt,SubscriptionsListenResultMetaSchema:()=>Qt,SubscriptionsListenResultSchema:()=>$t,TaskAugmentedRequestParamsSchema:()=>Je,TaskCreationParamsSchema:()=>vr,TaskMetadataSchema:()=>Ge,TaskSchema:()=>br,TaskStatusNotificationParamsSchema:()=>Sr,TaskStatusNotificationSchema:()=>Cr,TaskStatusSchema:()=>yr,TextContentSchema:()=>cn,TextResourceContentsSchema:()=>kt,TitledMultiSelectEnumSchemaSchema:()=>Qn,TitledSingleSelectEnumSchemaSchema:()=>Jn,ToolAnnotationsSchema:()=>_n,ToolChoiceSchema:()=>Fn,ToolExecutionSchema:()=>vn,ToolListChangedNotificationSchema:()=>En,ToolResultContentSchema:()=>In,ToolSchema:()=>yn,ToolUseContentSchema:()=>un,UnsubscribeRequestParamsSchema:()=>Gt,UnsubscribeRequestSchema:()=>Kt,UntitledMultiSelectEnumSchemaSchema:()=>Zn,UntitledSingleSelectEnumSchemaSchema:()=>qn}),Ra=e=>Ze.safeParse(e).success,za=e=>Qe.safeParse(e).success,Ba=e=>$e.safeParse(e).success,Va=e=>et.safeParse(e).success,Ha=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&e.resultType===`input_required`,Ua=e=>ht.safeParse(e).success,Wa=e=>vt.safeParse(e).success,Ga=`Mcp-Param-`,Ka=`x-mcp-header`,qa=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,Ja=new Set([`string`,`integer`,`boolean`,`number`]);function Ya(e){let t=[],n=new Map,r=(e,i,a)=>{if(typeof e!=`object`||!e)return;let o=e;if(Ka in o){if(!a||i.length===0)return`${Qa(i)}: x-mcp-header is only permitted on properties statically reachable via a chain of 'properties' keys (not under items, additionalProperties, oneOf/anyOf/allOf/not, if/then/else, or $ref)`;let e=o[Ka];if(typeof e!=`string`||e.length===0)return`${Qa(i)}: x-mcp-header MUST be a non-empty string`;if(!qa.test(e))return`${Qa(i)}: x-mcp-header '${e}' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)`;let r=typeof o.type==`string`?o.type:void 0;if(r===void 0||!Ja.has(r))return`${Qa(i)}: x-mcp-header is only permitted on primitive-typed properties (string, integer, boolean); got ${r??``}`;let s=e.toLowerCase(),c=n.get(s);if(c!==void 0)return`x-mcp-header '${e}' is not case-insensitively unique (also declared as '${c}')`;n.set(s,e),t.push({path:i,headerName:e,type:r})}let s=o.properties;if(typeof s==`object`&&s)for(let[e,t]of Object.entries(s)){let n=r(t,[...i,e],a);if(n!==void 0)return n}for(let e of Xa){let t=o[e];if(t===void 0)continue;let n=Array.isArray(t)?t:typeof t==`object`&&t&&Za.has(e)?Object.values(t):[t];for(let t of n){let n=r(t,[...i,`<${e}>`],!1);if(n!==void 0)return n}}},i=r(e,[],!0);return i===void 0?{valid:!0,declarations:t}:{valid:!1,reason:i}}var Xa=[`items`,`prefixItems`,`contains`,`additionalProperties`,`unevaluatedProperties`,`unevaluatedItems`,`propertyNames`,`patternProperties`,`dependentSchemas`,`oneOf`,`anyOf`,`allOf`,`not`,`if`,`then`,`else`,`$defs`,`definitions`],Za=new Set([`patternProperties`,`dependentSchemas`,`$defs`,`definitions`]);function Qa(e){return e.length===0?``:e.join(`.`)}var $a=`=?base64?`,eo=`?=`;function to(e){if(typeof e==`string`)return e;if(typeof e==`boolean`)return e?`true`:`false`;if(typeof e==`number`)return!Number.isFinite(e)||Number.isInteger(e)&&!Number.isSafeInteger(e)?void 0:String(e)}function no(e){if(e.length===0||e.startsWith($a)&&e.endsWith(eo)||e!==e.trim())return!0;for(let t=0;t=32&&n<=126))return!0}return!1}function ro(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCodePoint(e);return btoa(n)}function io(e){return no(e)?`${$a}${ro(e)}${eo}`:e}function ao(e,t){let n=e;for(let e of t){if(typeof n!=`object`||!n)return;n=n[e]}return n}function oo(e,t){let n={};for(let r of e){let e=ao(t,r.path);if(e==null)continue;let i=to(e);i!==void 0&&(n[`${Ga}${r.headerName}`]=io(i))}return n}X.InvalidRequest,X.UnsupportedProtocolVersion,X.InvalidParams,X.MethodNotFound,X.InvalidParams,X.MissingRequiredClientCapability,X.ParseError,X.InvalidRequest,X.MethodNotFound,X.UnsupportedProtocolVersion,X.MissingRequiredClientCapability;var so={"tools/call":`name`,"prompts/get":`name`,"resources/read":`uri`,"tasks/get":`taskId`,"tasks/update":`taskId`,"tasks/cancel":`taskId`};function co(e,t){let n=Object.hasOwn(so,e)?so[e]:void 0;if(n===void 0)return;let r=lo(t)?t[n]:void 0;return{field:n,value:typeof r==`string`?r:void 0}}function lo(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function uo(e,t){return p(e,t)}function fo(e){return new Set(e.flatMap(e=>Object.keys(e.shape)))}function po(e){if(e==null)return!1;let t=typeof e;return t!==`object`&&t!==`function`||!(`~standard`in e)?!1:typeof e[`~standard`]?.validate==`function`}var mo=!1,ho=`draft-2020-12`;function go(e,t=`input`){let n=e[`~standard`],r;if(n.jsonSchema)r=n.jsonSchema[t]({target:ho});else if(n.vendor===`zod`){if(!(`_zod`in e))throw Error(`Schema appears to be from zod 3, which the SDK cannot convert to JSON Schema. Upgrade to zod >=4.2.0, or wrap your JSON Schema with fromJsonSchema().`);mo||(mo=!0,console.warn("[mcp-sdk] Your zod version does not implement `~standard.jsonSchema` (added in zod 4.2.0). Falling back to z.toJSONSchema(). Upgrade to zod >=4.2.0 to silence this warning.")),r=ie(e,{target:ho,io:t})}else throw Error(`Schema library "${n.vendor}" does not implement StandardJSONSchemaV1 (\`~standard.jsonSchema\`). Upgrade to a version that does, or wrap your JSON Schema with fromJsonSchema().`);if(t===`output`)return r.type===void 0&&_o(r)?{type:`object`,...r}:r;if(r.type!==void 0&&r.type!==`object`)throw Error(`MCP tool and prompt schemas must describe objects (got type: ${JSON.stringify(r.type)}). Wrap your schema in z.object({...}) or equivalent.`);return{type:`object`,...r}}function _o(e){if(`properties`in e||`patternProperties`in e||`additionalProperties`in e||`required`in e)return!0;for(let t of[`oneOf`,`anyOf`,`allOf`]){let n=e[t];if(Array.isArray(n)&&n.length>0)return n.every(e=>typeof e==`object`&&!!e&&(e.type===`object`||_o(e)))}return!1}function vo(e){return e.path?.length?`${e.path.map(e=>String(typeof e==`object`?e.key:e)).join(`.`)}: ${e.message}`:e.message}async function yo(e,t){let n=await e[`~standard`].validate(t);return n.issues&&n.issues.length>0?{success:!1,error:n.issues.map(e=>vo(e)).join(`, `)}:{success:!0,data:n.value}}function bo(e){let t=ie(e,{target:ho,io:`input`});return typeof t.pattern==`string`?t.pattern:void 0}var xo=/\\\.\\d\{(\d+)\}/;function So(e){let t=xo.exec(e),n=[void 0,-1,0];return t&&n.push(Number(t[1])),[!1,!0].flatMap(e=>[!1,!0].flatMap(t=>n.map(n=>pe({local:e,offset:t,precision:n}))))}function Co(e,t){let n;switch(e){case`email`:n=[re()];break;case`uri`:n=[ae()];break;case`date`:n=[me()];break;case`date-time`:n=So(t)}return new Set(n.map(e=>bo(e)).filter(e=>e!==void 0))}function wo(e,t,n){return n!==`zod`||Co(e,t).has(t)}function To(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Eo(e){try{return go(e,`input`)}catch(e){let t=e instanceof Error?e.message:String(e);throw new Z(X.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${t}`)}}var Do=new Set([`$comment`,`deprecated`,`description`,`examples`,`readOnly`,`title`,`writeOnly`]);function Oo(e){return Do.has(e)||e.startsWith(`x-`)}var ko=new Set([`$schema`,...Object.keys(nr.shape.requestedSchema.shape)]),Ao={string:fo([Gn,qn,Jn,Yn]),number:fo([Kn]),integer:fo([Kn]),boolean:fo([Wn]),array:fo([Zn,Qn])},jo=new Set(Gn.shape.format.unwrap().options);function Mo(e,t,n,r){if(!To(e))return e;let i=typeof e.type==`string`&&Object.hasOwn(Ao,e.type)?Ao[e.type]:void 0;if(i===void 0)return e;let a={};for(let[o,s]of Object.entries(e))i.has(o)||Oo(o)?a[o]=s:o===`pattern`&&e.type===`string`&&typeof e.format==`string`?jo.has(e.format)?(typeof s!=`string`||!wo(e.format,s,n))&&r.push(`${t}.${o}`):a[o]=s:r.push(`${t}.${o}`);return a}function No(e,t){let n={},r=[];for(let[i,a]of Object.entries(e))i===`properties`&&To(a)?n[i]=Object.fromEntries(Object.entries(a).map(([e,n])=>[e,Mo(n,`properties.${e}`,t,r)])):ko.has(i)?n[i]=a:Oo(i)||r.push(i);if(r.length>0)throw new Z(X.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${r.join(`, `)}`);return n}function Po(e,t){if(!To(e.properties))return t;let n=Object.entries(e.properties).filter(([,e])=>!uo(tr,e).success).map(([e])=>`properties.${e}`);return n.length>0?n.join(`, `):t}function Fo(e,t,n=``){return Array.isArray(e)&&Array.isArray(t)?e.flatMap((e,r)=>Fo(e,t[r],`${n}[${r}]`)):!To(e)||!To(t)?[]:Object.entries(e).flatMap(([e,r])=>{let i=n?`${n}.${e}`:e;return Object.prototype.hasOwnProperty.call(t,e)?Fo(r,t[e],i):Oo(e)?[]:[i]})}function Io(e){if(!po(e.requestedSchema))return{...e,mode:`form`,requestedSchema:e.requestedSchema};let t=e.requestedSchema[`~standard`].vendor,n=No(Eo(e.requestedSchema),t),r=uo(nr.shape.requestedSchema,n);if(!r.success)throw new Z(X.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${Po(n,r.error.message)}`);let i=Fo(n,r.data);if(i.length>0)throw new Z(X.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${i.join(`, `)}`);let a=(r.data.required??[]).filter(e=>!Object.prototype.hasOwnProperty.call(r.data.properties,e));if(a.length>0)throw new Z(X.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${a.join(`, `)}`);return{...e,mode:`form`,requestedSchema:r.data}}function Lo(e){let t=e.inputRequests!==void 0&&Object.keys(e.inputRequests).length>0,n=typeof e.requestState==`string`;if(!t&&!n)throw TypeError(`inputRequired() requires at least one of inputRequests (with at least one entry) or requestState (spec: every InputRequiredResult MUST include at least one of the two)`);return{resultType:`input_required`,...e.inputRequests!==void 0&&{inputRequests:e.inputRequests},...e.requestState!==void 0&&{requestState:e.requestState}}}Object.assign(Lo,{elicit(e){try{return{method:`elicitation/create`,params:Io(e)}}catch(e){throw e instanceof Z?TypeError(e.message,{cause:e}):e}},elicitUrl(e){return{method:`elicitation/create`,params:{...e,mode:`url`}}},createMessage(e){return{method:`sampling/createMessage`,params:e}},listRoots(){return{method:`roots/list`}}});var Ro=!0,zo=10,Bo=250;function Vo(e){return{autoFulfill:e?.autoFulfill??Ro,maxRounds:e?.maxRounds??zo}}function Ho(e,t,n){let r=t!==void 0&&Object.keys(t).length>0;return!r&&n===void 0?e:{...e,...r&&{inputResponses:t},...n!==void 0&&{requestState:n}}}function Uo(e,t){return`Multi-round-trip request '${e}' still required input after ${t} rounds (inputRequired.maxRounds)`}function Wo(e,t){return new Promise((n,r)=>{if(t?.aborted){r(t.reason instanceof Y?t.reason:new Y(J.RequestTimeout,String(t.reason)));return}let i=setTimeout(()=>{t?.removeEventListener(`abort`,a),n()},e),a=()=>{clearTimeout(i),r(t?.reason instanceof Y?t.reason:new Y(J.RequestTimeout,String(t?.reason)))};t?.addEventListener(`abort`,a,{once:!0})})}function Go(e){let t=new AbortController,n=()=>t.abort(e?.reason);return e?.addEventListener(`abort`,n,{once:!0}),e?.aborted&&t.abort(e.reason),{signal:t.signal,abort:e=>t.abort(e),dispose:()=>e?.removeEventListener(`abort`,n)}}async function Ko(e){let{config:t,method:n,originalParams:r,requestOptions:i,hooks:a,signal:o}=e,s=e.flowStartedAt??Date.now(),c=e.firstPayload,l=0;for(;;){if(l+=1,l>t.maxRounds)throw new Y(J.InputRequiredRoundsExceeded,Uo(n,t.maxRounds),{rounds:t.maxRounds,lastResult:{inputRequests:c.inputRequests,...c.requestState!==void 0&&{requestState:c.requestState}}});i.onprogress?.({progress:l,message:`Fulfilling input required by '${n}' (round ${l})`});let e=Object.entries(c.inputRequests??{}),u;if(e.length>0){let t=Go(o);try{let n=await Promise.all(e.map(async([e,n])=>{try{return[e,await a.dispatchInputRequest(e,n,t.signal)]}catch(e){throw t.abort(e),e}}));u=Object.fromEntries(n)}finally{t.dispose()}}else await Wo(Bo,o);let d={...i.timeout!==void 0&&{timeout:i.timeout}};if(i.maxTotalTimeout!==void 0){let e=Date.now()-s,t=i.maxTotalTimeout-e;if(t<=0)throw new Y(J.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:i.maxTotalTimeout,totalElapsed:e});d.maxTotalTimeout=t}let f=await a.retry(Ho(r,u,c.requestState),d);if(Ha(f)){c={inputRequests:f.inputRequests??{},...f.requestState!==void 0&&{requestState:f.requestState}};continue}return f}}var qo=`AnnotationsSchema.AudioContentSchema.BaseMetadataSchema.BlobResourceContentsSchema.BooleanSchemaSchema.CallToolRequestSchema.CallToolRequestParamsSchema.CallToolResultSchema.CancelledNotificationSchema.CancelledNotificationParamsSchema.CancelTaskRequestSchema.CancelTaskResultSchema.ClientCapabilitiesSchema.ClientNotificationSchema.ClientRequestSchema.ClientResultSchema.CompatibilityCallToolResultSchema.CompleteRequestSchema.CompleteRequestParamsSchema.CompleteResultSchema.ContentBlockSchema.CreateMessageRequestSchema.CreateMessageRequestParamsSchema.CreateMessageResultSchema.CreateMessageResultWithToolsSchema.CreateTaskResultSchema.CursorSchema.DiscoverRequestSchema.DiscoverResultSchema.ElicitationCompleteNotificationSchema.ElicitationCompleteNotificationParamsSchema.ElicitRequestSchema.ElicitRequestFormParamsSchema.ElicitRequestParamsSchema.ElicitRequestURLParamsSchema.ElicitResultSchema.EmbeddedResourceSchema.EmptyResultSchema.EnumSchemaSchema.GetPromptRequestSchema.GetPromptRequestParamsSchema.GetPromptResultSchema.GetTaskPayloadRequestSchema.GetTaskPayloadResultSchema.GetTaskRequestSchema.GetTaskResultSchema.IconSchema.IconsSchema.ImageContentSchema.ImplementationSchema.InitializedNotificationSchema.InitializeRequestSchema.InitializeRequestParamsSchema.InitializeResultSchema.JSONArraySchema.JSONObjectSchema.JSONRPCErrorResponseSchema.JSONRPCMessageSchema.JSONRPCNotificationSchema.JSONRPCRequestSchema.JSONRPCResponseSchema.JSONRPCResultResponseSchema.JSONValueSchema.LegacyTitledEnumSchemaSchema.ListPromptsRequestSchema.ListPromptsResultSchema.ListResourcesRequestSchema.ListResourcesResultSchema.ListResourceTemplatesRequestSchema.ListResourceTemplatesResultSchema.ListRootsRequestSchema.ListRootsResultSchema.ListTasksRequestSchema.ListTasksResultSchema.ListToolsRequestSchema.ListToolsResultSchema.LoggingLevelSchema.LoggingMessageNotificationSchema.LoggingMessageNotificationParamsSchema.ModelHintSchema.ModelPreferencesSchema.MultiSelectEnumSchemaSchema.NotificationSchema.NumberSchemaSchema.PaginatedRequestSchema.PaginatedRequestParamsSchema.PaginatedResultSchema.PingRequestSchema.PrimitiveSchemaDefinitionSchema.ProgressSchema.ProgressNotificationSchema.ProgressNotificationParamsSchema.ProgressTokenSchema.PromptSchema.PromptArgumentSchema.PromptListChangedNotificationSchema.PromptMessageSchema.PromptReferenceSchema.ReadResourceRequestSchema.ReadResourceRequestParamsSchema.ReadResourceResultSchema.RelatedTaskMetadataSchema.RequestSchema.RequestIdSchema.RequestMetaSchema.ResourceSchema.ResourceContentsSchema.ResourceLinkSchema.ResourceListChangedNotificationSchema.ResourceRequestParamsSchema.ResourceTemplateSchema.ResourceTemplateReferenceSchema.ResourceUpdatedNotificationSchema.ResourceUpdatedNotificationParamsSchema.ResultMetaObjectSchema.ResultSchema.RoleSchema.RootSchema.RootsListChangedNotificationSchema.SamplingContentSchema.SamplingMessageSchema.SamplingMessageContentBlockSchema.ServerCapabilitiesSchema.ServerNotificationSchema.ServerRequestSchema.ServerResultSchema.SetLevelRequestSchema.SetLevelRequestParamsSchema.SingleSelectEnumSchemaSchema.StringSchemaSchema.SubscribeRequestSchema.SubscribeRequestParamsSchema.SubscriptionFilterSchema.SubscriptionsAcknowledgedNotificationSchema.SubscriptionsAcknowledgedNotificationParamsSchema.SubscriptionsListenRequestSchema.SubscriptionsListenRequestParamsSchema.SubscriptionsListenResultSchema.SubscriptionsListenResultMetaSchema.TaskAugmentedRequestParamsSchema.TaskCreationParamsSchema.TaskMetadataSchema.TaskSchema.TaskStatusSchema.TaskStatusNotificationSchema.TaskStatusNotificationParamsSchema.TextContentSchema.TextResourceContentsSchema.TitledMultiSelectEnumSchemaSchema.TitledSingleSelectEnumSchemaSchema.ToolSchema.ToolAnnotationsSchema.ToolChoiceSchema.ToolExecutionSchema.ToolListChangedNotificationSchema.ToolResultContentSchema.ToolUseContentSchema.UnsubscribeRequestSchema.UnsubscribeRequestParamsSchema.UntitledMultiSelectEnumSchemaSchema.UntitledSingleSelectEnumSchemaSchema`.split(`.`),Jo={IdJagTokenExchangeResponseSchema:Ur,OAuthClientInformationFullSchema:Jr,OAuthClientInformationSchema:qr,OAuthClientMetadataSchema:Kr,OAuthClientRegistrationErrorSchema:Yr,OAuthErrorResponseSchema:Wr,OAuthMetadataSchema:zr,OAuthProtectedResourceMetadataSchema:Rr,OAuthTokenRevocationRequestSchema:Xr,OAuthTokensSchema:Hr,OpenIdProviderDiscoveryMetadataSchema:Vr,OpenIdProviderMetadataSchema:Br},Yo={},Xo={};function Zo(e,t){let n=e.slice(0,-6);Yo[n]=t,Xo[n]=e=>t.safeParse(e).success}for(let e of qo)Zo(e,La[e]);for(let[e,t]of Object.entries(Jo))Zo(e,t);Object.freeze(Yo);var Qo=Object.freeze(Xo);function $o(e){switch(e){case`initialize`:case`notifications/initialized`:return ja(void 0);case`server/discover`:return ja(Aa);default:return}}var es=[Fe,Ie,Re,Be],ts=[`inputResponses`,`requestState`];function ns(e,t){let n=e.params;if(!ss(n))return{message:e,lifted:{}};let r=n._meta,i=ss(r)?es.filter(e=>e in r):[],a=t===`request`?ts.filter(e=>e in n):[];if(i.length===0&&a.length===0)return{message:e,lifted:{}};let o={},s={...n};if(i.length>0&&ss(r)){let e={},t={...r};for(let n of i)e[n]=r[n],delete t[n];o.envelope=e,Object.keys(t).length>0?s._meta=t:delete s._meta}for(let e of a)e===`inputResponses`&&(o.inputResponses=s[e]),e===`requestState`&&(o.requestState=s[e]),delete s[e];return{message:{...e,params:s},lifted:o}}function rs(e,t){let n=e.validateResult(t,void 0);if(n.ok||n.reason!==`not-in-era`)return{"~standard":{version:1,vendor:`mcp-wire-codec`,validate(n){let r=e.validateResult(t,n);return r.ok?{value:r.value}:{issues:[{message:r.reason===`invalid`?r.message:`not-in-era: ${t}`}]}}}}}function is(e){return()=>e}var as=is(void 0),os=class{_transport;_requestMessageId=0;_requestHandlers=new Map;_customSchemaRequestMethods=new Set;_requestHandlerAbortControllers=new Map;_notificationHandlers=new Map;_responseHandlers=new Map;_progressHandlers=new Map;_timeoutInfo=new Map;_pendingDebouncedNotifications=new Set;_negotiatedProtocolVersion;_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(e){this._options=e,this._supportedProtocolVersions=e?.supportedProtocolVersions??Ne,this.setNotificationHandler(`notifications/cancelled`,e=>{this._oncancel(e)}),this.setNotificationHandler(`notifications/progress`,e=>{this._onprogress(e)}),this.setRequestHandler(`ping`,e=>({}))}_shouldDropInbound(e){}_outboundMetaEnvelope(){}_envelopeOutbound(e){let t=this._outboundMetaEnvelope();if(t===void 0)return e;let n=e.params??{};return{...e,params:{...n,_meta:{...t,...n._meta}}}}_resolveNonCompleteResult(e,t){return Promise.reject(new Y(J.UnsupportedResultType,`Unsupported result type '${e.kind}' for ${t.request.method}`,{resultType:e.kind,method:t.request.method}))}_getRequestHandler(e){return this._requestHandlers.get(e)}async _oncancel(e){e.params.requestId!==void 0&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,n,r,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),new Y(J.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{try{t?.()}finally{this._onclose()}};let n=this.transport?.onerror;this._transport.onerror=e=>{n?.(e),this._onerror(e)};let r=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{r?.(e,t),Ba(e)||Va(e)?this._onresponse(e):Ra(e)?this._onrequest(e,t):za(e)?this._onnotification(e,t):this._onerror(Error(`Unknown message type: ${JSON.stringify(e)}`))},e.setSupportedProtocolVersions?.(this._supportedProtocolVersions),await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear();for(let e of this._timeoutInfo.values())clearTimeout(e.timeoutId);this._timeoutInfo.clear();let t=this._requestHandlerAbortControllers;this._requestHandlerAbortControllers=new Map;let n=new Y(J.ConnectionClosed,`Connection closed`);this._transport=void 0;try{this.onclose?.()}finally{for(let t of e.values())t(n);for(let e of t.values())e.abort(n)}}_onerror(e){this.onerror?.(e)}_onnotification(e,t){let{message:n}=ns(e,`notification`),r=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)===`drop`)return;if(t?.classification!==void 0){let e=Ma(t.classification);if(e!==r.era){this._onerror(Error(`Era mismatch on inbound notification '${n.method}': classified as ${e} but this instance serves ${r.era}`));return}}if(Pa(n.method)&&!r.hasNotificationMethod(n.method))return;let i=this._notificationHandlers.get(n.method),a=this.fallbackNotificationHandler;(i!==void 0||a!==void 0)&&Promise.resolve().then(()=>i===void 0?a(n):i(n,r)).catch(e=>this._onerror(Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){let{message:n,lifted:r}=ns(e,`request`),i=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)===`drop`){this._onerror(Error(`Dropped inbound request '${e.method}': not servable on this connection's protocol era`));return}let a=this._transport,o=(e,t,r)=>{let i={jsonrpc:`2.0`,id:n.id,error:{code:e,message:t,...r!==void 0&&{data:r}}};a?.send(i).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)))};if(t?.classification!==void 0){let e=Ma(t.classification);if(e!==i.era){this._onerror(Error(`Era mismatch on inbound request '${n.method}': classified as ${e} but this instance serves ${i.era}`));let r=t.classification.revision??e;o(X.UnsupportedProtocolVersion,`Unsupported protocol version: ${r}`,{supported:this._supportedProtocolVersions,requested:r});return}}if(Na(n.method)&&!i.hasRequestMethod(n.method)&&!(Fa(n.method)&&this._customSchemaRequestMethods.has(n.method))){o(X.MethodNotFound,`Method not found`);return}let s=this._requestHandlers.get(n.method)??this.fallbackRequestHandler;if(s===void 0){o(X.MethodNotFound,`Method not found`);return}let c=i.checkInboundEnvelope(r);if(c!==void 0){o(X.InvalidParams,c);return}let l=(e,t)=>this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,{...t,relatedRequestId:n.id}),u=(e,t,r)=>this._requestWithSchemaViaCodec(this._resolveOutboundCodec(e.method),e,t,{...r,relatedRequestId:n.id}),d=new AbortController;this._requestHandlerAbortControllers.set(n.id,d);let f=r.inputResponses===void 0?void 0:us(r.inputResponses),p={sessionId:a?.sessionId,mcpReq:{id:n.id,method:n.method,_meta:n.params?._meta,...r.envelope!==void 0&&{envelope:r.envelope},...f!==void 0&&{inputResponses:f.accepted},...f!==void 0&&f.droppedKeys.length>0&&{droppedInputResponseKeys:f.droppedKeys},requestState:r.requestState===void 0?as:is(r.requestState),signal:d.signal,send:((e,t,n)=>{let r=this._resolveOutboundCodec(e.method);if(this._assertOutboundRequestInEra(r,e.method),po(t))return u(e,t,n);let i=rs(r,e.method);if(i===void 0)throw TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);return u(e,i,t)}),notify:l},http:t?.authInfo?{authInfo:t.authInfo}:void 0},m=this.buildContext(p,t);Promise.resolve().then(()=>s(n,m)).then(async e=>{if(d.signal.aborted)return;let t;try{t=i.encodeResult(n.method,e,this._outboundServerInfo())}catch(e){this._onerror(Error(`Failed to encode result for ${n.method}: ${e}`)),o(X.InternalError,`Internal error`);return}let r={result:t,jsonrpc:`2.0`,id:n.id};await a?.send(r)},async e=>{if(d.signal.aborted)return;let t=Number.isSafeInteger(e.code)?e.code:X.InternalError,r={jsonrpc:`2.0`,id:n.id,error:{code:i.encodeErrorCode(t),message:e.message??`Internal error`,...e.data!==void 0&&{data:e.data}}};await a?.send(r)}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.get(n.id)===d&&this._requestHandlerAbortControllers.delete(n.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,r=Number(t),i=this._progressHandlers.get(r);if(!i){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(r),o=this._timeoutInfo.get(r);if(o&&a&&o.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(e){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),a(e);return}i(n)}_onresponse(e){let t=Number(e.id),n=this._responseHandlers.get(t);if(n===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t),this._progressHandlers.delete(t),Ba(e)?n(e):n(Z.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}request(e,t,n){let r=this._resolveOutboundCodec(e.method);if(po(t))return Fa(e.method)||this._assertOutboundRequestInEra(r,e.method),this._requestWithSchemaViaCodec(r,e,t,n);this._assertOutboundRequestInEra(r,e.method);let i=rs(r,e.method);if(i===void 0)throw TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to request().`);return this._requestWithSchemaViaCodec(r,e,i,t)}_negotiatedWireCodec(){return ja(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(e){if(this._negotiatedProtocolVersion===void 0){let t=$o(e);if(t)return t}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(e,t){if(Na(t)&&!e.hasRequestMethod(t))throw new Y(J.MethodNotSupportedByProtocolVersion,`Method '${t}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t,era:e.era})}_requestWithSchema(e,t,n){let r=this._resolveOutboundCodec(e.method);return this._assertOutboundRequestInEra(r,e.method),this._requestWithSchemaViaCodec(r,e,t,n)}_requestWithSchemaViaCodec(e,t,n,r){let{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o,headers:s}=r??{},c=Date.now(),l,u;return new Promise((d,f)=>{let p=e=>{f(e)};if(!this._transport){p(Error(`Not connected`));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method)}catch(e){p(e);return}if(r?.signal?.aborted){let e=r.signal.reason;throw e instanceof Y?e:new Y(J.RequestTimeout,String(e))}let m=e.era===`2026-07-28`&&this._transport.hasPerRequestStream===!0?new AbortController:void 0,h=this._requestMessageId++;u=h;let g={...t,jsonrpc:`2.0`,id:h};r?.onprogress&&(this._progressHandlers.set(h,r.onprogress),g.params={...t.params,_meta:{...t.params?._meta,progressToken:h}});let _=this._envelopeOutbound(g),v=!1,y=e=>{v||(this._progressHandlers.delete(h),m===void 0?t.method!==`initialize`&&this._transport?.send(this._envelopeOutbound({jsonrpc:`2.0`,method:`notifications/cancelled`,params:{requestId:h,reason:String(e)}}),{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))):m.abort(),f(e instanceof Y?e:new Y(J.RequestTimeout,String(e))))};this._responseHandlers.set(h,i=>{if(r?.signal?.aborted)return;if(v=!0,i instanceof Error)return f(i);let a;try{a=e.decodeResult(t.method,i.result)}catch(e){return f(e instanceof Error?e:Error(String(e)))}if(a.kind===`invalid`)return f(a.error);if(a.kind===`input_required`){if(r?.allowInputRequired===!0)return d(gs(a));let i={codec:e,request:t,resultSchema:n,options:r,flowStartedAt:c,retry:(r,i)=>this._requestWithSchemaViaCodec(e,r===void 0?{method:t.method}:{method:t.method,params:r},n,i)};return d(this._resolveNonCompleteResult(a,i))}let o=a.result;yo(n,o).then(e=>{e.success?d(e.data):f(new Y(J.InvalidResult,`Invalid result for ${t.method}: ${e.error}`))},f)}),l=()=>y(r?.signal?.reason),r?.signal?.addEventListener(`abort`,l,{once:!0});let b=r?.timeout??6e4;this._setupTimeout(h,b,r?.maxTotalTimeout,()=>y(new Y(J.RequestTimeout,`Request timed out`,{timeout:b})),r?.resetTimeoutOnProgress??!1),this._transport.send(_,{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o,headers:s,requestSignal:m?.signal}).catch(e=>{this._progressHandlers.delete(h),f(e)})}).finally(()=>{l&&r?.signal?.removeEventListener(`abort`,l),u!==void 0&&(this._responseHandlers.delete(u),this._cleanupTimeout(u))})}async notification(e,t){return await this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,t)}async _notificationViaCodec(e,t,n){if(!this._transport)throw new Y(J.NotConnected,`Not connected`);if(Pa(t.method)&&!e.hasNotificationMethod(t.method))throw new Y(J.MethodNotSupportedByProtocolVersion,`Notification '${t.method}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t.method,era:e.era});this.assertNotificationCapability(t.method);let r=this._envelopeOutbound({jsonrpc:`2.0`,...t});if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&n?.relatedRequestId===void 0){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{this._pendingDebouncedNotifications.delete(t.method),this._transport&&this._transport?.send(r,n).catch(e=>this._onerror(e))});return}await this._transport.send(r,n)}setRequestHandler(e,t,n){this.assertRequestHandlerCapability(e);let r;if(typeof t==`function`){if(!Na(e))throw TypeError(`'${e}' is not a spec request method; pass schemas as the second argument to setRequestHandler().`);r=(n,r)=>{let i=this._negotiatedWireCodec(),a=i.validateRequest(e,n);if(!a.ok&&a.reason===`not-in-era`&&(a=i.validateInputRequest(e,n)),!a.ok)throw a.reason===`not-in-era`?new Z(X.InternalError,`No wire schema for ${e} in the resolved era`):Error(a.message);return Promise.resolve(t(a.value,r))}}else if(n)r=async(r,i)=>{let a=await yo(t.params,{...r.params});if(!a.success)throw new Z(X.InvalidParams,`Invalid params for ${e}: ${a.error}`);return n(a.data,i)};else throw TypeError(`setRequestHandler: handler is required`);typeof t==`function`?this._customSchemaRequestMethods.delete(e):this._customSchemaRequestMethods.add(e),this._requestHandlers.set(e,this._wrapHandler(e,r))}_wrapHandler(e,t){return t}_outboundServerInfo(){}removeRequestHandler(e){this._requestHandlers.delete(e),this._customSchemaRequestMethods.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t,n){if(typeof t==`function`){if(!Pa(e))throw TypeError(`'${e}' is not a spec notification method; pass schemas as the second argument to setNotificationHandler().`);this._notificationHandlers.set(e,(n,r)=>{let i=r.validateNotification(e,n);if(!i.ok)throw i.reason===`not-in-era`?new Z(X.InternalError,`No wire schema for ${e} in the resolved era`):Error(i.message);return Promise.resolve(t(i.value))});return}if(!n)throw TypeError(`setNotificationHandler: handler is required`);this._notificationHandlers.set(e,async r=>{let i=await yo(t.params,{...r.params});if(!i.success)throw new Z(X.InvalidParams,`Invalid params for notification ${e}: ${i.error}`);await n(i.data,r)})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function ss(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function cs(e,t){let n={...e};for(let e in t){let r=e,i=t[r];if(i===void 0)continue;let a=n[r];n[r]=ss(a)&&ss(i)?{...a,...i}:i}return n}function ls(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function us(e){let t={},n=[];if(!ls(e))return{accepted:t,droppedKeys:n};for(let[r,i]of Object.entries(e)){if(!ls(i)||`method`in i||`result`in i){n.push(r);continue}t[r]=i}return{accepted:t,droppedKeys:n}}function ds(e){throw new Y(J.SendFailed,`ctx.mcpReq.${e} is not available while fulfilling an embedded input request: the request is fulfilled locally and has no related peer request`)}function fs(e,t,n,r,i){return{sessionId:i,mcpReq:{id:e,method:t,_meta:n?._meta,requestState:is(void 0),signal:r,send:(()=>ds(`send`)),notify:()=>ds(`notify`)}}}async function ps(e,t,n,r,i){if(!ls(r)||typeof r.method!=`string`)throw new Y(J.InvalidResult,`Invalid input request '${n}': each inputRequests entry must be an embedded request object with a method`,{key:n});let a=r.method;if(!t.hasInputRequestMethod(a))throw new Y(J.InvalidResult,`Invalid input request '${n}': '${a}' is not an embedded request the ${t.era} revision defines (expected elicitation/create, sampling/createMessage, or roots/list)`,{key:n,method:a});let o=e.getRequestHandler(a);if(o===void 0)throw new Y(J.CapabilityNotSupported,`Cannot fulfil input request '${n}': no handler is registered for '${a}' on this client. Declare the corresponding capability and register a handler, or handle input_required results manually.`,{key:n,method:a});let s=ls(r.params)?r.params:void 0;return await o({jsonrpc:`2.0`,id:n,method:a,...s!==void 0&&{params:s}},e.buildContext(fs(n,a,s,i,e.sessionId)))}function ms(e,t){return{...e?.signal!==void 0&&{signal:e.signal},...e?.onprogress!==void 0&&{onprogress:e.onprogress},...e?.resetTimeoutOnProgress!==void 0&&{resetTimeoutOnProgress:e.resetTimeoutOnProgress},...e?.headers!==void 0&&{headers:e.headers},...t.timeout!==void 0&&{timeout:t.timeout},...t.maxTotalTimeout!==void 0&&{maxTotalTimeout:t.maxTotalTimeout},allowInputRequired:!0}}function hs(e,t,n,r){let{codec:i,request:a,options:o,flowStartedAt:s}=r,c={inputRequests:n.inputRequests,...n.requestState!==void 0&&{requestState:n.requestState}},l={dispatchInputRequest:(t,n,r)=>ps(e,i,t,n,r),retry:(e,t)=>r.retry(e,ms(o,t))};return Ko({config:t,method:a.method,originalParams:a.params,firstPayload:c,flowStartedAt:s,signal:o?.signal,requestOptions:{...o?.timeout!==void 0&&{timeout:o.timeout},...o?.maxTotalTimeout!==void 0&&{maxTotalTimeout:o.maxTotalTimeout},...o?.onprogress!==void 0&&{onprogress:o.onprogress}},hooks:l})}function gs(e){return{resultType:`input_required`,inputRequests:e.inputRequests,...e.requestState!==void 0&&{requestState:e.requestState},...e._meta!==void 0&&{_meta:e._meta}}}var _s=Te(Se((e=>{var t=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,n=/\\([\u000b\u0020-\u00ff])/g,r=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;e.parse=i;function i(e){if(!e)throw TypeError(`argument string is required`);var i=typeof e==`object`?a(e):e;if(typeof i!=`string`)throw TypeError(`argument string is required to be a string`);var s=i.indexOf(`;`),c=s===-1?i.trim():i.slice(0,s).trim();if(!r.test(c))throw TypeError(`invalid media type`);var l=new o(c.toLowerCase());if(s!==-1){var u,d,f;for(t.lastIndex=s;d=t.exec(i);){if(d.index!==s)throw TypeError(`invalid parameter format`);s+=d[0].length,u=d[1].toLowerCase(),f=d[2],f.charCodeAt(0)===34&&(f=f.slice(1,-1),f.indexOf(`\\`)!==-1&&(f=f.replace(n,`$1`))),l.parameters[u]=f}if(s!==i.length)throw TypeError(`invalid parameter format`)}return l}function a(e){var t;if(typeof e.getHeader==`function`?t=e.getHeader(`content-type`):typeof e.headers==`object`&&(t=e.headers&&e.headers[`content-type`]),typeof t!=`string`)throw TypeError(`content-type header is missing from object`);return t}function o(e){this.parameters=Object.create(null),this.type=e}}))(),1);function vs(e){if(e)try{return _s.parse(e).type}catch{let t=(e.split(`;`,1)[0]??``).trim().toLowerCase();return t===``||e.slice(t.length).includes(`,`)?void 0:t}}function ys(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function bs(e=fetch,t){return t?async(n,r)=>e(n,{...t,...r,headers:r?.headers?{...ys(t.headers),...ys(r.headers)}:t.headers}):e}var xs=new Set([301,302,303,307,308]),Ss=5;function Cs(e,t){return e.protocol===t.protocol&&e.host===t.host||e.protocol===`http:`&&t.protocol===`https:`&&e.hostname===t.hostname&&!e.port&&!t.port}function ws(e,t){let n=xs.has(t.status)?t.headers?.get(`location`):void 0;if(n)try{return new URL(n,e)}catch{return}}var Ts=new WeakSet;function Es(e){let t=(t,n)=>e(t,n);return Ts.add(t),t}function Ds(e){return Ts.has(e)?e:async(t,n)=>{if(n?.redirect===`error`||n?.redirect===`manual`)return e(t,n);let r=(n?.method??`GET`).toUpperCase(),i=t;for(let t=0;;t++){let a=await e(i,{...n,redirect:`manual`}),o=ws(i,a);if(!o||t===Ss)return a;let s=new URL(i),c=r===`GET`||a.status===307||a.status===308,l=!(o.username||o.password)||o.username===s.username&&o.password===s.password;if(!c||!l||!Cs(s,o))return a;await a.text?.().catch(()=>{}),i=o}}}function Os(e,t){if(t.type===`opaqueredirect`)return`Redirect not followed: this runtime does not expose where it points`;let n=ws(t.url||e,t);if(n)return n.username=n.password=n.search=n.hash=``,n.protocol===`http:`&&new URL(t.url||e).protocol===`https:`?(n.protocol=`https:`,`Redirect from https to plain http not followed; try ${n.href} as the endpoint`):`Redirect to ${n.href} not followed; use that URL as the endpoint if it is the intended server`}function ks(e,t){let n=typeof e;if(n!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let n=e.length;if(n!==t.length)return!1;for(let r=0;r1?t[a.href]=e:(a.hash=``,r===``?n=a:Is(e,t,n))}}else if(e!==!0&&e!==!1)return t;let i=n.href+(r?`#`+r:``);if(t[i]!==void 0)throw Error(`Duplicate schema URI "${i}".`);if(t[i]=e,e===!0||e===!1)return t;if(e.__absolute_uri__===void 0&&Object.defineProperty(e,"__absolute_uri__",{enumerable:!1,value:i}),e.$ref&&e.__absolute_ref__===void 0){let t=new URL(e.$ref,n.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_ref__",{enumerable:!1,value:t.href})}if(e.$recursiveRef&&e.__absolute_recursive_ref__===void 0){let t=new URL(e.$recursiveRef,n.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_recursive_ref__",{enumerable:!1,value:t.href})}if(e.$anchor){let r=new URL(`#`+e.$anchor,n.href);t[r.href]=e}for(let i in e){if(Ps[i])continue;let a=`${r}/${As(i)}`,o=e[i];if(Array.isArray(o)){if(Ms[i]){let e=o.length;for(let r=0;r%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,Us=/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,Ws=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,Gs=/^(?:\/(?:[^~/]|~0|~1)*)*$/,Ks=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,qs=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,Js=e=>{if(e[0]===`"`)return!1;let[t,n,...r]=e.split(`@`);return!t||!n||r.length!==0||t.length>64||n.length>253||t[0]===`.`||t.endsWith(`.`)||t.includes(`..`)||!/^[a-z0-9.-]+$/i.test(n)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t)?!1:n.split(`.`).every(e=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(e))},Ys=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,Xs=/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,Zs=e=>e.length>1&&e.length<80&&(/^P\d+([.,]\d+)?W$/.test(e)||/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(e)&&/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(e));function Qs(e){return e.test.bind(e)}var $s={date:tc,time:nc.bind(void 0,!1),"date-time":ic,duration:Zs,uri:sc,"uri-reference":Qs(Vs),"uri-template":Qs(Hs),url:Qs(Us),email:Js,hostname:Qs(Bs),ipv4:Qs(Ys),ipv6:Qs(Xs),regex:lc,uuid:Qs(Ws),"json-pointer":Qs(Gs),"json-pointer-uri-fragment":Qs(Ks),"relative-json-pointer":Qs(qs)};function ec(e){return e%4==0&&(e%100!=0||e%400==0)}function tc(e){let t=e.match(Ls);if(!t)return!1;let n=+t[1],r=+t[2],i=+t[3];return r>=1&&r<=12&&i>=1&&i<=(r==2&&ec(n)?29:Rs[r])}function nc(e,t){let n=t.match(zs);if(!n)return!1;let r=+n[1],i=+n[2],a=+n[3],o=!!n[5];return(r<=23&&i<=59&&a<=59||r==23&&i==59&&a==60)&&(!e||o)}var rc=/t|\s/i;function ic(e){let t=e.split(rc);return t.length==2&&tc(t[0])&&nc(!0,t[1])}var ac=/\/|:/,oc=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function sc(e){return ac.test(e)&&oc.test(e)}var cc=/[^\\]\\Z/;function lc(e){if(cc.test(e))return!1;try{return new RegExp(e,`u`),!0}catch{return!1}}function uc(e){let t=0,n=e.length,r=0,i;for(;r=55296&&i<=56319&&r{if(typeof e!=`string`||/[\s;'\"]/.test(e))return!1;let t=e.match(/^([a-z]+):\/\/([^/]+)$/i);return!!(t&&n.has(t[1].toLowerCase()))})}function ge(e){let t=N(N(N(e)?.ui)?.csp),n=P(t?.connectDomains,[`http`,`https`,`ws`,`wss`]),r=P(t?.resourceDomains,[`http`,`https`]),i=P(t?.frameDomains,[`http`,`https`]),a=P(t?.baseUriDomains,[`http`,`https`]),o=r.length?` ${r.join(` `)}`:``,s=[`default-src 'none'`,`worker-src blob:`,`script-src 'self' 'unsafe-inline'${o}`,`style-src 'self' 'unsafe-inline'${o}`,`img-src 'self' data:${o}`,`media-src 'self' data:${o}`,`font-src 'self' data:${o}`,`connect-src ${n.length?n.join(` `):`'none'`}`];return i.length&&s.push(`frame-src ${i.join(` `)}`),a.length&&s.push(`base-uri ${a.join(` `)}`),`${s.join(`; `)};`}var _e=Object.create,ve=Object.defineProperty,ye=Object.getOwnPropertyDescriptor,be=Object.getOwnPropertyNames,F=Object.getPrototypeOf,xe=Object.prototype.hasOwnProperty,Se=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ce=(e,t)=>{let n={};for(var r in e)ve(n,r,{get:e[r],enumerable:!0});return t&&ve(n,Symbol.toStringTag,{value:`Module`}),n},we=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=be(t),a=0,o=i.length,s;at[e]).bind(null,s),enumerable:!(r=ye(t,s))||r.enumerable});return e},Te=(e,t,n)=>(n=e==null?{}:_e(F(e)),we(t||!e||!e.__esModule?ve(n,`default`,{value:e,enumerable:!0}):n,e)),Ee=new Set([`https://json-schema.org/draft/2020-12/schema`,`http://json-schema.org/draft/2020-12/schema`]),De=new Set([`https://json-schema.org/draft/2019-09/schema`,`http://json-schema.org/draft/2019-09/schema`]),Oe=new Set([`https://json-schema.org/draft-07/schema`,`http://json-schema.org/draft-07/schema`]),ke=new Set([`https://json-schema.org/draft-06/schema`,`http://json-schema.org/draft-06/schema`]);function Ae(e){return typeof e==`string`&&De.has(e.replace(/#$/,``))}function je(e,t){if(!(`$schema`in e)||typeof e.$schema!=`string`)return`2020-12`;let n=e.$schema.replace(/#$/,``);if(Ee.has(n))return`2020-12`;if(De.has(n))return`2019-09`;if(Oe.has(n)||ke.has(n))return`draft-7`;throw Error(`JSON Schema declares an unsupported dialect ("$schema": "${e.$schema.slice(0,200)}"). The default validator supports JSON Schema 2020-12, 2019-09, draft-07, and draft-06; ${t}`)}var Me=`2025-11-25`,Ne=[Me,`2025-06-18`,`2025-03-26`,`2024-11-05`,`2024-10-07`],Pe=`io.modelcontextprotocol/related-task`,Fe=`io.modelcontextprotocol/protocolVersion`,Ie=`io.modelcontextprotocol/clientInfo`,Le=`io.modelcontextprotocol/serverInfo`,Re=`io.modelcontextprotocol/clientCapabilities`,ze=`io.modelcontextprotocol/subscriptionId`,Be=`io.modelcontextprotocol/logLevel`,Ve=ee(()=>h([g(),j(),O(),oe(),C(g(),Ve),D(Ve)])),I=C(g(),Ve),He=D(Ve),Ue=h([g(),j().int()]),We=g(),Ge=S({ttl:j().optional()}),Ke=S({taskId:g()}),qe=M({progressToken:Ue.optional(),[Pe]:Ke.optional()}),L=S({_meta:qe.optional()}),Je=L.extend({task:Ge.optional()}),R=S({method:g(),params:L.loose().optional()}),z=S({_meta:qe.optional()}),B=S({method:g(),params:z.loose().optional()}),Ye=M({get[Le](){return H.optional().catch(void 0)}}),V=M({_meta:Ye.optional()}),Xe=h([g(),j().int()]),Ze=S({jsonrpc:k(`2.0`),id:Xe,...R.shape}).strict(),Qe=S({jsonrpc:k(`2.0`),...B.shape}).strict(),$e=S({jsonrpc:k(`2.0`),id:Xe,result:V}).strict(),et=S({jsonrpc:k(`2.0`),id:Xe.optional(),error:S({code:j().int(),message:g(),data:b().optional()})}).strict(),tt=h([Ze,Qe,$e,et]),nt=h([$e,et]),rt=V.strict(),it=z.extend({requestId:Xe.optional(),reason:g().optional()}),at=B.extend({method:k(`notifications/cancelled`),params:it}),ot=S({src:g(),mimeType:g().optional(),sizes:D(g()).optional(),theme:E([`light`,`dark`]).optional()}),st=S({icons:D(ot).optional()}),ct=S({name:g(),title:g().optional()}),H=ct.extend({...ct.shape,...st.shape,version:g(),websiteUrl:g().optional(),description:g().optional()}),lt=ne(S({applyDefaults:O().optional()}),I),ut=A(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,ne(S({form:lt.optional(),url:I.optional()}),I.optional())),dt=M({list:I.optional(),cancel:I.optional(),requests:M({sampling:M({createMessage:I.optional()}).optional(),elicitation:M({create:I.optional()}).optional()}).optional()}),ft=M({list:I.optional(),cancel:I.optional(),requests:M({tools:M({call:I.optional()}).optional()}).optional()}),pt=S({experimental:C(g(),I).optional(),sampling:S({context:I.optional(),tools:I.optional()}).optional(),elicitation:ut.optional(),roots:S({listChanged:O().optional()}).optional(),tasks:dt.optional(),extensions:C(g(),I).optional()}),mt=L.extend({protocolVersion:g(),capabilities:pt,clientInfo:H}),ht=R.extend({method:k(`initialize`),params:mt}),gt=S({experimental:C(g(),I).optional(),logging:I.optional(),completions:I.optional(),prompts:S({listChanged:O().optional()}).optional(),resources:S({subscribe:O().optional(),listChanged:O().optional()}).optional(),tools:S({listChanged:O().optional()}).optional(),tasks:ft.optional(),extensions:C(g(),I).optional()}),_t=V.extend({protocolVersion:g(),capabilities:gt,serverInfo:H,instructions:g().optional()}),vt=B.extend({method:k(`notifications/initialized`),params:z.optional()}),yt=R.extend({method:k(`server/discover`),params:L.optional()}),bt=V.extend({supportedVersions:D(g()),capabilities:gt,instructions:g().optional()}),xt=R.extend({method:k(`ping`),params:L.optional()}),St=S({progress:j(),total:m(j()),message:m(g())}),Ct=S({...z.shape,...St.shape,progressToken:Ue}),wt=B.extend({method:k(`notifications/progress`),params:Ct}),Tt=L.extend({cursor:We.optional()}),Et=R.extend({params:Tt.optional()}),Dt=V.extend({nextCursor:We.optional()}),Ot=S({uri:g(),mimeType:m(g()),_meta:C(g(),b()).optional()}),kt=Ot.extend({text:g()}),At=g().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),jt=Ot.extend({blob:At}),Mt=E([`user`,`assistant`]),Nt=S({audience:D(Mt).optional(),priority:j().min(0).max(1).optional(),lastModified:pe({offset:!0}).optional()}),Pt=S({...ct.shape,...st.shape,uri:g(),description:m(g()),mimeType:m(g()),size:m(j()),annotations:Nt.optional(),_meta:m(M({}))}),Ft=S({...ct.shape,...st.shape,uriTemplate:g(),description:m(g()),mimeType:m(g()),annotations:Nt.optional(),_meta:m(M({}))}),It=Et.extend({method:k(`resources/list`)}),Lt=Dt.extend({resources:D(Pt)}),U=Et.extend({method:k(`resources/templates/list`)}),W=Dt.extend({resourceTemplates:D(Ft)}),Rt=L.extend({uri:g()}),zt=Rt,Bt=R.extend({method:k(`resources/read`),params:zt}),Vt=V.extend({contents:D(h([kt,jt]))}),Ht=B.extend({method:k(`notifications/resources/list_changed`),params:z.optional()}),Ut=Rt,Wt=R.extend({method:k(`resources/subscribe`),params:Ut}),Gt=Rt,Kt=R.extend({method:k(`resources/unsubscribe`),params:Gt}),qt=S({toolsListChanged:O().optional(),promptsListChanged:O().optional(),resourcesListChanged:O().optional(),resourceSubscriptions:D(g()).optional()}),Jt=L.extend({notifications:qt}),Yt=R.extend({method:k(`subscriptions/listen`),params:Jt}),Xt=z.extend({notifications:qt}),Zt=B.extend({method:k(`notifications/subscriptions/acknowledged`),params:Xt}),Qt=Ye.extend({[ze]:Xe}),$t=V.extend({_meta:Qt}),en=z.extend({uri:g()}),tn=B.extend({method:k(`notifications/resources/updated`),params:en}),G=S({name:g(),description:m(g()),required:m(O())}),nn=S({...ct.shape,...st.shape,description:m(g()),arguments:m(D(G)),_meta:m(M({}))}),rn=Et.extend({method:k(`prompts/list`)}),an=Dt.extend({prompts:D(nn)}),on=L.extend({name:g(),arguments:C(g(),g()).optional()}),sn=R.extend({method:k(`prompts/get`),params:on}),cn=S({type:k(`text`),text:g(),annotations:Nt.optional(),_meta:C(g(),b()).optional()}),K=S({type:k(`image`),data:At,mimeType:g(),annotations:Nt.optional(),_meta:C(g(),b()).optional()}),ln=S({type:k(`audio`),data:At,mimeType:g(),annotations:Nt.optional(),_meta:C(g(),b()).optional()}),un=S({type:k(`tool_use`),name:g(),id:g(),input:C(g(),b()),_meta:C(g(),b()).optional()}),dn=S({type:k(`resource`),resource:h([kt,jt]),annotations:Nt.optional(),_meta:C(g(),b()).optional()}),fn=Pt.extend({type:k(`resource_link`)}),pn=h([cn,K,ln,fn,dn]),mn=S({role:Mt,content:pn}),hn=V.extend({description:g().optional(),messages:D(mn)}),gn=B.extend({method:k(`notifications/prompts/list_changed`),params:z.optional()}),_n=S({title:g().optional(),readOnlyHint:O().optional(),destructiveHint:O().optional(),idempotentHint:O().optional(),openWorldHint:O().optional()}),vn=S({taskSupport:E([`required`,`optional`,`forbidden`]).optional()}),yn=S({...ct.shape,...st.shape,description:g().optional(),inputSchema:S({type:k(`object`),properties:C(g(),Ve).optional(),required:D(g()).optional()}).catchall(b()),outputSchema:M({$schema:g().optional()}).optional(),annotations:_n.optional(),execution:vn.optional(),_meta:C(g(),b()).optional()}),bn=Et.extend({method:k(`tools/list`)}),xn=Dt.extend({tools:D(yn)}),Sn=V.extend({content:D(pn).default([]),structuredContent:b().optional(),isError:O().optional()}),Cn=Sn.or(V.extend({toolResult:b()})),wn=Je.extend({name:g(),arguments:C(g(),b()).optional()}),Tn=R.extend({method:k(`tools/call`),params:wn}),En=B.extend({method:k(`notifications/tools/list_changed`),params:z.optional()}),Dn=S({autoRefresh:O().default(!0),debounceMs:j().int().nonnegative().default(300)}),On=E([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),kn=L.extend({level:On}),An=R.extend({method:k(`logging/setLevel`),params:kn}),jn=z.extend({level:On,logger:g().optional(),data:b()}),Mn=B.extend({method:k(`notifications/message`),params:jn}),Nn=S({name:g().optional()}),Pn=S({hints:D(Nn).optional(),costPriority:j().min(0).max(1).optional(),speedPriority:j().min(0).max(1).optional(),intelligencePriority:j().min(0).max(1).optional()}),Fn=S({mode:E([`auto`,`required`,`none`]).optional()}),In=S({type:k(`tool_result`),toolUseId:g().describe(`The unique identifier for the corresponding tool call.`),content:D(pn),structuredContent:b().optional(),isError:O().optional(),_meta:C(g(),b()).optional()}),Ln=se(`type`,[cn,K,ln]),Rn=se(`type`,[cn,K,ln,un,In]),zn=S({role:Mt,content:h([Rn,D(Rn)]),_meta:C(g(),b()).optional()}),Bn=Je.extend({messages:D(zn),modelPreferences:Pn.optional(),systemPrompt:g().optional(),includeContext:E([`none`,`thisServer`,`allServers`]).optional(),temperature:j().optional(),maxTokens:j().int(),stopSequences:D(g()).optional(),metadata:I.optional(),tools:D(yn).optional(),toolChoice:Fn.optional()}),Vn=R.extend({method:k(`sampling/createMessage`),params:Bn}),Hn=V.extend({model:g(),stopReason:m(E([`endTurn`,`stopSequence`,`maxTokens`]).or(g())),role:Mt,content:Ln}),Un=V.extend({model:g(),stopReason:m(E([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(g())),role:Mt,content:h([Rn,D(Rn)])}),Wn=S({type:k(`boolean`),title:g().optional(),description:g().optional(),default:O().optional()}),Gn=S({type:k(`string`),title:g().optional(),description:g().optional(),minLength:j().optional(),maxLength:j().optional(),format:E([`email`,`uri`,`date`,`date-time`]).optional(),default:g().optional()}),Kn=S({type:E([`number`,`integer`]),title:g().optional(),description:g().optional(),minimum:j().optional(),maximum:j().optional(),default:j().optional()}),qn=S({type:k(`string`),title:g().optional(),description:g().optional(),enum:D(g()),default:g().optional()}),Jn=S({type:k(`string`),title:g().optional(),description:g().optional(),oneOf:D(S({const:g(),title:g()})),default:g().optional()}),Yn=S({type:k(`string`),title:g().optional(),description:g().optional(),enum:D(g()),enumNames:D(g()).optional(),default:g().optional()}),Xn=h([qn,Jn]),Zn=S({type:k(`array`),title:g().optional(),description:g().optional(),minItems:j().optional(),maxItems:j().optional(),items:S({type:k(`string`),enum:D(g())}),default:D(g()).optional()}),Qn=S({type:k(`array`),title:g().optional(),description:g().optional(),minItems:j().optional(),maxItems:j().optional(),items:S({anyOf:D(S({const:g(),title:g()}))}),default:D(g()).optional()}),$n=h([Zn,Qn]),er=h([Yn,Xn,$n]),tr=h([er,Wn,Gn,Kn]),nr=Je.extend({mode:k(`form`).optional(),message:g(),requestedSchema:S({type:k(`object`),properties:C(g(),tr),required:D(g()).optional()}).catchall(b())}),rr=Je.extend({mode:k(`url`),message:g(),elicitationId:g(),url:g().url()}),ir=h([nr,rr]),ar=R.extend({method:k(`elicitation/create`),params:ir}),or=z.extend({elicitationId:g()}),sr=B.extend({method:k(`notifications/elicitation/complete`),params:or}),cr=V.extend({action:E([`accept`,`decline`,`cancel`]),content:A(e=>e===null?void 0:e,C(g(),h([g(),j(),O(),D(g())])).optional())}),lr=S({type:k(`ref/resource`),uri:g()}),ur=S({type:k(`ref/prompt`),name:g()}),dr=L.extend({ref:h([ur,lr]),argument:S({name:g(),value:g()}),context:S({arguments:C(g(),g()).optional()}).optional()}),fr=R.extend({method:k(`completion/complete`),params:dr}),pr=V.extend({completion:M({values:D(g()).max(100),total:m(j().int()),hasMore:m(O())})}),mr=S({uri:g().startsWith(`file://`),name:g().optional(),_meta:C(g(),b()).optional()}),hr=R.extend({method:k(`roots/list`),params:L.optional()}),gr=V.extend({roots:D(mr)}),_r=B.extend({method:k(`notifications/roots/list_changed`),params:z.optional()}),vr=M({ttl:j().optional(),pollInterval:j().optional()}),yr=E([`working`,`input_required`,`completed`,`failed`,`cancelled`]),br=S({taskId:g(),status:yr,ttl:h([j(),oe()]),createdAt:g(),lastUpdatedAt:g(),pollInterval:m(j()),statusMessage:m(g())}),xr=V.extend({task:br}),Sr=z.merge(br),Cr=B.extend({method:k(`notifications/tasks/status`),params:Sr}),wr=R.extend({method:k(`tasks/get`),params:L.extend({taskId:g()})}),Tr=V.merge(br),Er=R.extend({method:k(`tasks/result`),params:L.extend({taskId:g()})}),Dr=V.loose(),Or=Et.extend({method:k(`tasks/list`)}),kr=Dt.extend({tasks:D(br)}),Ar=R.extend({method:k(`tasks/cancel`),params:L.extend({taskId:g()})}),jr=V.merge(br),Mr=h([xt,ht,yt,fr,An,sn,rn,It,U,Bt,Wt,Kt,Yt,Tn,bn]),Nr=h([at,wt,vt,_r]),Pr=h([rt,Hn,Un,cr,gr]),Fr=h([xt,Vn,ar,hr]),Ir=h([at,wt,Mn,tn,Ht,En,gn,Zt,sr]),Lr=h([rt,_t,bt,pr,hn,an,Lt,W,Vt,Sn,xn,$t]),q=ae().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:de.custom,message:`URL must be parseable`,fatal:!0}),_}).refine(e=>{let t=new URL(e);return t.protocol!==`javascript:`&&t.protocol!==`data:`&&t.protocol!==`vbscript:`},{message:`URL cannot use javascript:, data:, or vbscript: scheme`}),Rr=M({resource:g().url(),authorization_servers:D(q).optional(),jwks_uri:g().url().optional(),scopes_supported:D(g()).optional(),bearer_methods_supported:D(g()).optional(),resource_signing_alg_values_supported:D(g()).optional(),resource_name:g().optional(),resource_documentation:g().optional(),resource_policy_uri:g().url().optional(),resource_tos_uri:g().url().optional(),tls_client_certificate_bound_access_tokens:O().optional(),authorization_details_types_supported:D(g()).optional(),dpop_signing_alg_values_supported:D(g()).optional(),dpop_bound_access_tokens_required:O().optional()}),zr=M({issuer:g(),authorization_endpoint:q,token_endpoint:q,registration_endpoint:q.optional(),scopes_supported:D(g()).optional(),response_types_supported:D(g()),response_modes_supported:D(g()).optional(),grant_types_supported:D(g()).optional(),token_endpoint_auth_methods_supported:D(g()).optional(),token_endpoint_auth_signing_alg_values_supported:D(g()).optional(),service_documentation:q.optional(),revocation_endpoint:q.optional(),revocation_endpoint_auth_methods_supported:D(g()).optional(),revocation_endpoint_auth_signing_alg_values_supported:D(g()).optional(),introspection_endpoint:g().optional(),introspection_endpoint_auth_methods_supported:D(g()).optional(),introspection_endpoint_auth_signing_alg_values_supported:D(g()).optional(),code_challenge_methods_supported:D(g()).optional(),client_id_metadata_document_supported:O().optional(),authorization_response_iss_parameter_supported:O().optional().catch(void 0),dpop_signing_alg_values_supported:D(g()).optional()}),Br=M({issuer:g(),authorization_endpoint:q,token_endpoint:q,userinfo_endpoint:q.optional(),jwks_uri:q,registration_endpoint:q.optional(),scopes_supported:D(g()).optional(),response_types_supported:D(g()),response_modes_supported:D(g()).optional(),grant_types_supported:D(g()).optional(),acr_values_supported:D(g()).optional(),subject_types_supported:D(g()),id_token_signing_alg_values_supported:D(g()),id_token_encryption_alg_values_supported:D(g()).optional(),id_token_encryption_enc_values_supported:D(g()).optional(),userinfo_signing_alg_values_supported:D(g()).optional(),userinfo_encryption_alg_values_supported:D(g()).optional(),userinfo_encryption_enc_values_supported:D(g()).optional(),request_object_signing_alg_values_supported:D(g()).optional(),request_object_encryption_alg_values_supported:D(g()).optional(),request_object_encryption_enc_values_supported:D(g()).optional(),token_endpoint_auth_methods_supported:D(g()).optional(),token_endpoint_auth_signing_alg_values_supported:D(g()).optional(),display_values_supported:D(g()).optional(),claim_types_supported:D(g()).optional(),claims_supported:D(g()).optional(),service_documentation:g().optional(),claims_locales_supported:D(g()).optional(),ui_locales_supported:D(g()).optional(),claims_parameter_supported:O().optional(),request_parameter_supported:O().optional(),request_uri_parameter_supported:O().optional(),require_request_uri_registration:O().optional(),op_policy_uri:q.optional(),op_tos_uri:q.optional(),client_id_metadata_document_supported:O().optional(),authorization_response_iss_parameter_supported:O().optional().catch(void 0)}),Vr=S({...Br.shape,...zr.pick({code_challenge_methods_supported:!0}).shape}),Hr=S({access_token:g(),id_token:g().optional(),token_type:g(),expires_in:he().optional(),scope:g().optional(),refresh_token:g().optional(),issuer:g().optional().catch(void 0)}).strip(),Ur=S({issued_token_type:k(`urn:ietf:params:oauth:token-type:id-jag`),access_token:g(),token_type:g().optional(),expires_in:j().optional(),scope:g().optional()}).strip(),Wr=S({error:g(),error_description:g().optional(),error_uri:g().optional()}),Gr=q.optional().or(k(``).transform(()=>void 0)),Kr=S({redirect_uris:D(q),token_endpoint_auth_method:g().optional(),grant_types:D(g()).optional(),response_types:D(g()).optional(),application_type:g().optional(),client_name:g().optional(),client_uri:q.optional(),logo_uri:Gr,scope:g().optional(),contacts:D(g()).optional(),tos_uri:Gr,policy_uri:g().optional(),jwks_uri:q.optional(),jwks:te().optional(),software_id:g().optional(),software_version:g().optional(),software_statement:g().optional()}).strip(),qr=S({client_id:g(),client_secret:g().optional(),client_id_issued_at:j().optional(),client_secret_expires_at:j().optional(),issuer:g().optional().catch(void 0)}).strip(),Jr=Kr.merge(qr),Yr=S({error:g(),error_description:g().optional()}).strip(),Xr=S({token:g(),token_type_hint:g().optional()}).strip(),Zr=Symbol.for(`mcp.sdk.errorBrands`);function Qr(e,t){let n=new Set,r=t;for(;typeof r==`function`;){let e=r.mcpBrand;Object.prototype.hasOwnProperty.call(r,`mcpBrand`)&&typeof e==`string`&&n.add(e),r=Object.getPrototypeOf(r)}n.size!==0&&Object.defineProperty(e,Zr,{value:n,enumerable:!1,configurable:!0})}function $r(e,t){try{if(typeof t==`object`&&t&&Object.prototype.hasOwnProperty.call(e,`mcpBrand`)&&typeof e.mcpBrand==`string`&&Object.prototype.hasOwnProperty.call(t,Zr)){let n=t[Zr];if(n&&typeof n.has==`function`&&n.has(e.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(e,t)}var ei=function(e){return e.InvalidRequest=`invalid_request`,e.InvalidClient=`invalid_client`,e.InvalidGrant=`invalid_grant`,e.UnauthorizedClient=`unauthorized_client`,e.UnsupportedGrantType=`unsupported_grant_type`,e.InvalidScope=`invalid_scope`,e.AccessDenied=`access_denied`,e.ServerError=`server_error`,e.TemporarilyUnavailable=`temporarily_unavailable`,e.UnsupportedResponseType=`unsupported_response_type`,e.UnsupportedTokenType=`unsupported_token_type`,e.InvalidToken=`invalid_token`,e.MethodNotAllowed=`method_not_allowed`,e.TooManyRequests=`too_many_requests`,e.InvalidClientMetadata=`invalid_client_metadata`,e.InvalidRedirectUri=`invalid_redirect_uri`,e.InsufficientScope=`insufficient_scope`,e.InvalidTarget=`invalid_target`,e.InvalidDpopProof=`invalid_dpop_proof`,e.UseDpopNonce=`use_dpop_nonce`,e}({}),ti=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.OAuthError`})}static[Symbol.hasInstance](e){return $r(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return $r(this,e)}constructor(e,t,n){super(t),this.code=e,this.errorUri=n,this.name=`OAuthError`,Qr(this,new.target)}toResponseObject(){let e={error:this.code,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}static fromResponse(t){return new e(t.error,t.error_description??t.error,t.error_uri)}},J=function(e){return e.NotConnected=`NOT_CONNECTED`,e.AlreadyConnected=`ALREADY_CONNECTED`,e.NotInitialized=`NOT_INITIALIZED`,e.CapabilityNotSupported=`CAPABILITY_NOT_SUPPORTED`,e.RequestTimeout=`REQUEST_TIMEOUT`,e.ConnectionClosed=`CONNECTION_CLOSED`,e.SendFailed=`SEND_FAILED`,e.InvalidResult=`INVALID_RESULT`,e.UnsupportedResultType=`UNSUPPORTED_RESULT_TYPE`,e.InputRequiredRoundsExceeded=`INPUT_REQUIRED_ROUNDS_EXCEEDED`,e.ListPaginationExceeded=`LIST_PAGINATION_EXCEEDED`,e.MethodNotSupportedByProtocolVersion=`METHOD_NOT_SUPPORTED_BY_PROTOCOL_VERSION`,e.EraNegotiationFailed=`ERA_NEGOTIATION_FAILED`,e.ClientHttpNotImplemented=`CLIENT_HTTP_NOT_IMPLEMENTED`,e.ClientHttpAuthentication=`CLIENT_HTTP_AUTHENTICATION`,e.ClientHttpForbidden=`CLIENT_HTTP_FORBIDDEN`,e.ClientHttpUnexpectedContent=`CLIENT_HTTP_UNEXPECTED_CONTENT`,e.ClientHttpFailedToOpenStream=`CLIENT_HTTP_FAILED_TO_OPEN_STREAM`,e.ClientHttpFailedToTerminateSession=`CLIENT_HTTP_FAILED_TO_TERMINATE_SESSION`,e}({}),Y=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.SdkError`})}static[Symbol.hasInstance](e){return $r(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return $r(this,e)}constructor(e,t,n,r){super(t,r),this.code=e,this.data=n,this.name=`SdkError`,Qr(this,new.target)}},ni=class extends Y{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.SdkHttpError`})}constructor(e,t,n,r){super(e,t,n,r),this.name=`SdkHttpError`}get status(){return this.data.status}get statusText(){return this.data.statusText}};function ri(e){let t=typeof e==`string`?new URL(e):new URL(e.href);return t.hash=``,t}function ii(e){if(typeof e!=`object`||!e||Array.isArray(e))return e;let t={...e};return delete t.issuer,t}function ai({requestedResource:e,configuredResource:t}){let n=typeof e==`string`?new URL(e):new URL(e.href),r=typeof t==`string`?new URL(t):new URL(t.href);if(n.origin!==r.origin||n.pathname.length=oi}function li(e){return e.filter(e=>!ci(e))}function ui(e){return e.filter(e=>ci(e))}function di(e){let t=e.structuredContent;return t===void 0||typeof t==`object`&&t&&!Array.isArray(t)||(e.content?.some(e=>e.type===`text`)??!1)?e:{...e,content:[...e.content??[],{type:`text`,text:JSON.stringify(t)}]}}var fi=[`task`,`inputRequests`,`requestState`];function pi(e){return typeof e!=`object`||!e||Array.isArray(e)||e.content!==void 0||fi.some(t=>t in e)?e:{...e,content:[]}}function mi(){let e=ee(()=>h([g(),j(),O(),oe(),C(g(),e),D(e)])),t=C(g(),e),n=h([g(),j().int()]),r=g(),i=S({ttl:j().optional()}),a=S({taskId:g()}),o=M({progressToken:n.optional(),"io.modelcontextprotocol/related-task":a.optional()}),s=S({_meta:o.optional()}),c=s.extend({task:i.optional()}),l=S({method:g(),params:s.loose().optional()}),u=S({_meta:o.optional()}),d=S({method:g(),params:u.loose().optional()}),f=M({_meta:o.optional()}),p=h([g(),j().int()]),_=f.strict(),v=u.extend({requestId:p.optional(),reason:g().optional()}),y=d.extend({method:k(`notifications/cancelled`),params:v}),x=S({src:g(),mimeType:g().optional(),sizes:D(g()).optional(),theme:E([`light`,`dark`]).optional()}),w=S({icons:D(x).optional()}),T=S({name:g(),title:g().optional()}),te=T.extend({...T.shape,...w.shape,version:g(),websiteUrl:g().optional(),description:g().optional()}),re=ne(S({applyDefaults:O().optional()}),t),ie=A(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,ne(S({form:re.optional(),url:t.optional()}),t.optional())),ae=M({list:t.optional(),cancel:t.optional(),requests:M({sampling:M({createMessage:t.optional()}).optional(),elicitation:M({create:t.optional()}).optional()}).optional()}),ce=M({list:t.optional(),cancel:t.optional(),requests:M({tools:M({call:t.optional()}).optional()}).optional()}),le=S({experimental:C(g(),t).optional(),sampling:S({context:t.optional(),tools:t.optional()}).optional(),elicitation:ie.optional(),roots:S({listChanged:O().optional()}).optional(),tasks:ae.optional(),extensions:C(g(),t).optional()}),ue=s.extend({protocolVersion:g(),capabilities:le,clientInfo:te}),de=l.extend({method:k(`initialize`),params:ue}),fe=S({experimental:C(g(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:S({listChanged:O().optional()}).optional(),resources:S({subscribe:O().optional(),listChanged:O().optional()}).optional(),tools:S({listChanged:O().optional()}).optional(),tasks:ce.optional(),extensions:C(g(),t).optional()}),me=f.extend({protocolVersion:g(),capabilities:fe,serverInfo:te,instructions:g().optional()}),he=d.extend({method:k(`notifications/initialized`),params:u.optional()}),N=l.extend({method:k(`ping`),params:s.optional()}),P=S({progress:j(),total:m(j()),message:m(g())}),ge=S({...u.shape,...P.shape,progressToken:n}),_e=d.extend({method:k(`notifications/progress`),params:ge}),ve=s.extend({cursor:r.optional()}),ye=l.extend({params:ve.optional()}),be=f.extend({nextCursor:r.optional()}),F=S({uri:g(),mimeType:m(g()),_meta:C(g(),b()).optional()}),xe=F.extend({text:g()}),Se=g().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),Ce=F.extend({blob:Se}),we=E([`user`,`assistant`]),Te=S({audience:D(we).optional(),priority:j().min(0).max(1).optional(),lastModified:pe({offset:!0}).optional()}),Ee=S({...T.shape,...w.shape,uri:g(),description:m(g()),mimeType:m(g()),size:m(j()),annotations:Te.optional(),_meta:m(M({}))}),De=S({...T.shape,...w.shape,uriTemplate:g(),description:m(g()),mimeType:m(g()),annotations:Te.optional(),_meta:m(M({}))}),Oe=ye.extend({method:k(`resources/list`)}),ke=be.extend({resources:D(Ee)}),Ae=ye.extend({method:k(`resources/templates/list`)}),je=be.extend({resourceTemplates:D(De)}),Me=s.extend({uri:g()}),Ne=Me,Pe=l.extend({method:k(`resources/read`),params:Ne}),Fe=f.extend({contents:D(h([xe,Ce]))}),Ie=d.extend({method:k(`notifications/resources/list_changed`),params:u.optional()}),Le=Me,Re=l.extend({method:k(`resources/subscribe`),params:Le}),ze=Me,Be=l.extend({method:k(`resources/unsubscribe`),params:ze}),Ve=u.extend({uri:g()}),I=d.extend({method:k(`notifications/resources/updated`),params:Ve}),He=S({name:g(),description:m(g()),required:m(O())}),Ue=S({...T.shape,...w.shape,description:m(g()),arguments:m(D(He)),_meta:m(M({}))}),We=ye.extend({method:k(`prompts/list`)}),Ge=be.extend({prompts:D(Ue)}),Ke=s.extend({name:g(),arguments:C(g(),g()).optional()}),qe=l.extend({method:k(`prompts/get`),params:Ke}),L=S({type:k(`text`),text:g(),annotations:Te.optional(),_meta:C(g(),b()).optional()}),Je=S({type:k(`image`),data:Se,mimeType:g(),annotations:Te.optional(),_meta:C(g(),b()).optional()}),R=S({type:k(`audio`),data:Se,mimeType:g(),annotations:Te.optional(),_meta:C(g(),b()).optional()}),z=S({type:k(`tool_use`),name:g(),id:g(),input:C(g(),b()),_meta:C(g(),b()).optional()}),B=S({type:k(`resource`),resource:h([xe,Ce]),annotations:Te.optional(),_meta:C(g(),b()).optional()}),Ye=Ee.extend({type:k(`resource_link`)}),V=h([L,Je,R,Ye,B]),Xe=S({role:we,content:V}),Ze=f.extend({description:g().optional(),messages:D(Xe)}),Qe=d.extend({method:k(`notifications/prompts/list_changed`),params:u.optional()}),$e=S({title:g().optional(),readOnlyHint:O().optional(),destructiveHint:O().optional(),idempotentHint:O().optional(),openWorldHint:O().optional()}),et=S({taskSupport:E([`required`,`optional`,`forbidden`]).optional()}),tt=S({...T.shape,...w.shape,description:g().optional(),inputSchema:S({type:k(`object`),properties:C(g(),e).optional(),required:D(g()).optional()}).catchall(b()),outputSchema:S({type:k(`object`),properties:C(g(),e).optional(),required:D(g()).optional()}).catchall(b()).optional(),annotations:$e.optional(),execution:et.optional(),_meta:C(g(),b()).optional()}),nt=ye.extend({method:k(`tools/list`)}),rt=be.extend({tools:D(tt)}),it=f.extend({content:D(V),structuredContent:C(g(),b()).optional(),isError:O().optional()}),at=c.extend({name:g(),arguments:C(g(),b()).optional()}),ot=l.extend({method:k(`tools/call`),params:at}),st=d.extend({method:k(`notifications/tools/list_changed`),params:u.optional()}),ct=E([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),H=s.extend({level:ct}),lt=l.extend({method:k(`logging/setLevel`),params:H}),ut=u.extend({level:ct,logger:g().optional(),data:b()}),dt=d.extend({method:k(`notifications/message`),params:ut}),ft=S({name:g().optional()}),pt=S({hints:D(ft).optional(),costPriority:j().min(0).max(1).optional(),speedPriority:j().min(0).max(1).optional(),intelligencePriority:j().min(0).max(1).optional()}),mt=S({mode:E([`auto`,`required`,`none`]).optional()}),ht=S({type:k(`tool_result`),toolUseId:g().describe(`The unique identifier for the corresponding tool call.`),content:D(V),structuredContent:S({}).loose().optional(),isError:O().optional(),_meta:C(g(),b()).optional()}),gt=se(`type`,[L,Je,R]),_t=se(`type`,[L,Je,R,z,ht]),vt=S({role:we,content:h([_t,D(_t)]),_meta:C(g(),b()).optional()}),yt=c.extend({messages:D(vt),modelPreferences:pt.optional(),systemPrompt:g().optional(),includeContext:E([`none`,`thisServer`,`allServers`]).optional(),temperature:j().optional(),maxTokens:j().int(),stopSequences:D(g()).optional(),metadata:t.optional(),tools:D(tt).optional(),toolChoice:mt.optional()}),bt=l.extend({method:k(`sampling/createMessage`),params:yt}),xt=f.extend({model:g(),stopReason:m(E([`endTurn`,`stopSequence`,`maxTokens`]).or(g())),role:we,content:gt}),St=f.extend({model:g(),stopReason:m(E([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(g())),role:we,content:h([_t,D(_t)])}),Ct=S({type:k(`boolean`),title:g().optional(),description:g().optional(),default:O().optional()}),wt=S({type:k(`string`),title:g().optional(),description:g().optional(),minLength:j().optional(),maxLength:j().optional(),format:E([`email`,`uri`,`date`,`date-time`]).optional(),default:g().optional()}),Tt=S({type:E([`number`,`integer`]),title:g().optional(),description:g().optional(),minimum:j().optional(),maximum:j().optional(),default:j().optional()}),Et=S({type:k(`string`),title:g().optional(),description:g().optional(),enum:D(g()),default:g().optional()}),Dt=S({type:k(`string`),title:g().optional(),description:g().optional(),oneOf:D(S({const:g(),title:g()})),default:g().optional()}),Ot=S({type:k(`string`),title:g().optional(),description:g().optional(),enum:D(g()),enumNames:D(g()).optional(),default:g().optional()}),kt=h([Et,Dt]),At=S({type:k(`array`),title:g().optional(),description:g().optional(),minItems:j().optional(),maxItems:j().optional(),items:S({type:k(`string`),enum:D(g())}),default:D(g()).optional()}),jt=S({type:k(`array`),title:g().optional(),description:g().optional(),minItems:j().optional(),maxItems:j().optional(),items:S({anyOf:D(S({const:g(),title:g()}))}),default:D(g()).optional()}),Mt=h([At,jt]),Nt=h([Ot,kt,Mt]),Pt=h([Nt,Ct,wt,Tt]),Ft=c.extend({mode:k(`form`).optional(),message:g(),requestedSchema:S({type:k(`object`),properties:C(g(),Pt),required:D(g()).optional()}).catchall(b())}),It=c.extend({mode:k(`url`),message:g(),elicitationId:g(),url:g().url()}),Lt=h([Ft,It]),U=l.extend({method:k(`elicitation/create`),params:Lt}),W=u.extend({elicitationId:g()}),Rt=d.extend({method:k(`notifications/elicitation/complete`),params:W}),zt=f.extend({action:E([`accept`,`decline`,`cancel`]),content:A(e=>e===null?void 0:e,C(g(),h([g(),j(),O(),D(g())])).optional())}),Bt=S({type:k(`ref/resource`),uri:g()}),Vt=S({type:k(`ref/prompt`),name:g()}),Ht=s.extend({ref:h([Vt,Bt]),argument:S({name:g(),value:g()}),context:S({arguments:C(g(),g()).optional()}).optional()}),Ut=l.extend({method:k(`completion/complete`),params:Ht}),Wt=f.extend({completion:M({values:D(g()).max(100),total:m(j().int()),hasMore:m(O())})}),Gt=S({uri:g().startsWith(`file://`),name:g().optional(),_meta:C(g(),b()).optional()}),Kt=l.extend({method:k(`roots/list`),params:s.optional()}),qt=f.extend({roots:D(Gt)}),Jt=d.extend({method:k(`notifications/roots/list_changed`),params:u.optional()}),Yt=M({ttl:j().optional(),pollInterval:j().optional()}),Xt=E([`working`,`input_required`,`completed`,`failed`,`cancelled`]),Zt=S({taskId:g(),status:Xt,ttl:h([j(),oe()]),createdAt:g(),lastUpdatedAt:g(),pollInterval:m(j()),statusMessage:m(g())}),Qt=f.extend({task:Zt}),$t=u.merge(Zt),en=d.extend({method:k(`notifications/tasks/status`),params:$t}),tn=l.extend({method:k(`tasks/get`),params:s.extend({taskId:g()})}),G=f.merge(Zt),nn=l.extend({method:k(`tasks/result`),params:s.extend({taskId:g()})}),rn=f.loose(),an=ye.extend({method:k(`tasks/list`)}),on=be.extend({tasks:D(Zt)}),sn=l.extend({method:k(`tasks/cancel`),params:s.extend({taskId:g()})});return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:n,CursorSchema:r,TaskMetadataSchema:i,RelatedTaskMetadataSchema:a,RequestMetaSchema:o,BaseRequestParamsSchema:s,TaskAugmentedRequestParamsSchema:c,RequestSchema:l,NotificationsParamsSchema:u,NotificationSchema:d,ResultSchema:f,RequestIdSchema:p,EmptyResultSchema:_,CancelledNotificationParamsSchema:v,CancelledNotificationSchema:y,IconSchema:x,IconsSchema:w,BaseMetadataSchema:T,ImplementationSchema:te,ClientTasksCapabilitySchema:ae,ServerTasksCapabilitySchema:ce,ClientCapabilitiesSchema:le,InitializeRequestParamsSchema:ue,InitializeRequestSchema:de,ServerCapabilitiesSchema:fe,InitializeResultSchema:me,InitializedNotificationSchema:he,PingRequestSchema:N,ProgressSchema:P,ProgressNotificationParamsSchema:ge,ProgressNotificationSchema:_e,PaginatedRequestParamsSchema:ve,PaginatedRequestSchema:ye,PaginatedResultSchema:be,ResourceContentsSchema:F,TextResourceContentsSchema:xe,BlobResourceContentsSchema:Ce,RoleSchema:we,AnnotationsSchema:Te,ResourceSchema:Ee,ResourceTemplateSchema:De,ListResourcesRequestSchema:Oe,ListResourcesResultSchema:ke,ListResourceTemplatesRequestSchema:Ae,ListResourceTemplatesResultSchema:je,ResourceRequestParamsSchema:Me,ReadResourceRequestParamsSchema:Ne,ReadResourceRequestSchema:Pe,ReadResourceResultSchema:Fe,ResourceListChangedNotificationSchema:Ie,SubscribeRequestParamsSchema:Le,SubscribeRequestSchema:Re,UnsubscribeRequestParamsSchema:ze,UnsubscribeRequestSchema:Be,ResourceUpdatedNotificationParamsSchema:Ve,ResourceUpdatedNotificationSchema:I,PromptArgumentSchema:He,PromptSchema:Ue,ListPromptsRequestSchema:We,ListPromptsResultSchema:Ge,GetPromptRequestParamsSchema:Ke,GetPromptRequestSchema:qe,TextContentSchema:L,ImageContentSchema:Je,AudioContentSchema:R,ToolUseContentSchema:z,EmbeddedResourceSchema:B,ResourceLinkSchema:Ye,ContentBlockSchema:V,PromptMessageSchema:Xe,GetPromptResultSchema:Ze,PromptListChangedNotificationSchema:Qe,ToolAnnotationsSchema:$e,ToolExecutionSchema:et,ToolSchema:tt,ListToolsRequestSchema:nt,ListToolsResultSchema:rt,CallToolResultSchema:it,CallToolRequestParamsSchema:at,CallToolRequestSchema:ot,ToolListChangedNotificationSchema:st,LoggingLevelSchema:ct,SetLevelRequestParamsSchema:H,SetLevelRequestSchema:lt,LoggingMessageNotificationParamsSchema:ut,LoggingMessageNotificationSchema:dt,ModelHintSchema:ft,ModelPreferencesSchema:pt,ToolChoiceSchema:mt,ToolResultContentSchema:ht,SamplingContentSchema:gt,SamplingMessageContentBlockSchema:_t,SamplingMessageSchema:vt,CreateMessageRequestParamsSchema:yt,CreateMessageRequestSchema:bt,CreateMessageResultSchema:xt,CreateMessageResultWithToolsSchema:St,BooleanSchemaSchema:Ct,StringSchemaSchema:wt,NumberSchemaSchema:Tt,UntitledSingleSelectEnumSchemaSchema:Et,TitledSingleSelectEnumSchemaSchema:Dt,LegacyTitledEnumSchemaSchema:Ot,SingleSelectEnumSchemaSchema:kt,UntitledMultiSelectEnumSchemaSchema:At,TitledMultiSelectEnumSchemaSchema:jt,MultiSelectEnumSchemaSchema:Mt,EnumSchemaSchema:Nt,PrimitiveSchemaDefinitionSchema:Pt,ElicitRequestFormParamsSchema:Ft,ElicitRequestURLParamsSchema:It,ElicitRequestParamsSchema:Lt,ElicitRequestSchema:U,ElicitationCompleteNotificationParamsSchema:W,ElicitationCompleteNotificationSchema:Rt,ElicitResultSchema:zt,ResourceTemplateReferenceSchema:Bt,PromptReferenceSchema:Vt,CompleteRequestParamsSchema:Ht,CompleteRequestSchema:Ut,CompleteResultSchema:Wt,RootSchema:Gt,ListRootsRequestSchema:Kt,ListRootsResultSchema:qt,RootsListChangedNotificationSchema:Jt,TaskCreationParamsSchema:Yt,TaskStatusSchema:Xt,TaskSchema:Zt,CreateTaskResultSchema:Qt,TaskStatusNotificationParamsSchema:$t,TaskStatusNotificationSchema:en,GetTaskRequestSchema:tn,GetTaskResultSchema:G,GetTaskPayloadRequestSchema:nn,GetTaskPayloadResultSchema:rn,ListTasksRequestSchema:an,ListTasksResultSchema:on,CancelTaskRequestSchema:sn,CancelTaskResultSchema:f.merge(Zt),ClientRequestSchema:h([N,de,Ut,lt,qe,We,Oe,Ae,Pe,Re,Be,ot,nt,tn,nn,an,sn]),ClientNotificationSchema:h([y,_e,he,Jt,en]),ClientResultSchema:h([_,xt,St,zt,qt,G,on,Qt]),ServerRequestSchema:h([N,bt,U,Kt,tn,nn,an,sn]),ServerNotificationSchema:h([y,_e,dt,I,Ie,st,Qe,en,Rt]),ServerResultSchema:h([_,me,Wt,Ze,Ge,ke,je,Fe,it,rt,G,on,Qt]),CallToolResultWireSchema:b().superRefine((e,t)=>{if(typeof e==`object`&&e&&!Array.isArray(e)&&e.content===void 0){for(let n of fi)if(n in e){t.addIssue({code:`custom`,message:`content is required when the body carries '${n}' — another result family cannot default into an empty tools/call success`});return}}}).transform(pi).pipe(it)}}var hi;function gi(){return hi??=mi()}function _i(e){return e.type!==`object`}var vi=new Set([`const`,`enum`,`default`,`examples`]),yi=new Set([`properties`,`patternProperties`,`$defs`,`definitions`,`dependentSchemas`,`dependencies`]);function bi(e){return e!==void 0&&!(typeof e==`string`&&e.startsWith(`#`))}function xi(e){let t=typeof e.$schema==`string`?e.$schema:void 0;if(bi(e.$id))return{...t!==void 0&&{$schema:t},type:`object`,properties:{result:e},required:[`result`]};let n=Ae(e.$schema)&&e.$recursiveAnchor!==!0,r=(e,t)=>{if(Array.isArray(e))return e.map(e=>r(e,!1));if(typeof e!=`object`||!e||!t&&bi(e.$id))return e;let i={},a=!1;for(let[o,s]of Object.entries(e))t?i[o]=r(s,!1):(o===`$ref`||o===`$dynamicRef`)&&typeof s==`string`?i[o]=s===`#`?`#/properties/result`:s.startsWith(`#/`)?`#/properties/result${s.slice(1)}`:s:o===`$recursiveRef`&&s===`#`&&n?a=!0:i[o]=vi.has(o)?s:yi.has(o)?r(s,!0):r(s,!1);return a&&(`$ref`in i?i.allOf=[...Array.isArray(i.allOf)?i.allOf:[],{$ref:`#/properties/result`}]:i.$ref=`#/properties/result`),i};return{...t!==void 0&&{$schema:t},type:`object`,properties:{result:r(e,!1)},required:[`result`]}}var Si={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"tasks/get":null,"tasks/result":null,"tasks/list":null,"tasks/cancel":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},Ci={"notifications/cancelled":null,"notifications/progress":null,"notifications/initialized":null,"notifications/roots/list_changed":null,"notifications/tasks/status":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/elicitation/complete":null},wi={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},Ti;function Ei(){if(Ti)return Ti;let e=gi();return Ti={requestSchemas:{ping:e.PingRequestSchema,initialize:e.InitializeRequestSchema,"completion/complete":e.CompleteRequestSchema,"logging/setLevel":e.SetLevelRequestSchema,"prompts/get":e.GetPromptRequestSchema,"prompts/list":e.ListPromptsRequestSchema,"resources/list":e.ListResourcesRequestSchema,"resources/templates/list":e.ListResourceTemplatesRequestSchema,"resources/read":e.ReadResourceRequestSchema,"resources/subscribe":e.SubscribeRequestSchema,"resources/unsubscribe":e.UnsubscribeRequestSchema,"tools/call":e.CallToolRequestSchema,"tools/list":e.ListToolsRequestSchema,"tasks/get":e.GetTaskRequestSchema,"tasks/result":e.GetTaskPayloadRequestSchema,"tasks/list":e.ListTasksRequestSchema,"tasks/cancel":e.CancelTaskRequestSchema,"sampling/createMessage":e.CreateMessageRequestSchema,"elicitation/create":e.ElicitRequestSchema,"roots/list":e.ListRootsRequestSchema},notificationSchemas:{"notifications/cancelled":e.CancelledNotificationSchema,"notifications/progress":e.ProgressNotificationSchema,"notifications/initialized":e.InitializedNotificationSchema,"notifications/roots/list_changed":e.RootsListChangedNotificationSchema,"notifications/tasks/status":e.TaskStatusNotificationSchema,"notifications/message":e.LoggingMessageNotificationSchema,"notifications/resources/updated":e.ResourceUpdatedNotificationSchema,"notifications/resources/list_changed":e.ResourceListChangedNotificationSchema,"notifications/tools/list_changed":e.ToolListChangedNotificationSchema,"notifications/prompts/list_changed":e.PromptListChangedNotificationSchema,"notifications/elicitation/complete":e.ElicitationCompleteNotificationSchema},resultSchemas:{ping:e.EmptyResultSchema,initialize:e.InitializeResultSchema,"completion/complete":e.CompleteResultSchema,"logging/setLevel":e.EmptyResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"resources/subscribe":e.EmptyResultSchema,"resources/unsubscribe":e.EmptyResultSchema,"tools/call":e.CallToolResultWireSchema,"tools/list":e.ListToolsResultSchema,"sampling/createMessage":e.CreateMessageResultWithToolsSchema,"elicitation/create":e.ElicitResultSchema,"roots/list":e.ListRootsResultSchema}},Ti}function Di(e){return Object.prototype.hasOwnProperty.call(Si,e)}function Oi(e){return Object.prototype.hasOwnProperty.call(Ci,e)}function ki(e){return Object.prototype.hasOwnProperty.call(wi,e)}function Ai(e){return ki(e)?Ei().resultSchemas[e]:void 0}function ji(e){return Di(e)?Ei().requestSchemas[e]:void 0}function Mi(e){return Oi(e)?Ei().notificationSchemas[e]:void 0}Object.keys(Si),Object.keys(Ci);function Ni(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Pi(e,t){if(e===void 0)return{ok:!1,reason:`not-in-era`};let n=e.safeParse(t);return n.success?{ok:!0,value:n.data}:{ok:!1,reason:`invalid`,message:String(n.error)}}var Fi={ok:!1,reason:`not-in-era`};function Ii(e){return Ni(e)&&Ni(e.outputSchema)&&_i(e.outputSchema)}function Li(e){return e}var Ri={era:`2025-11-25`,hasRequestMethod:Di,hasNotificationMethod:Oi,validateRequest:(e,t)=>Pi(ji(e),t),validateResult:(e,t)=>Pi(Ai(e),t),validateNotification:(e,t)=>Pi(Mi(e),t),hasInputRequestMethod:()=>!1,validateInputRequest:()=>Fi,validateInputResponse:()=>Fi,samplingResultVariant:((e,t)=>{let n=gi();return Pi(e?n.CreateMessageResultWithToolsSchema:n.CreateMessageResultSchema,t)}),outboundEnvelope:e=>void 0,validateEnvelopeMeta:e=>[],projectCallToolResult(e,t){let n=di(e),r=n.structuredContent;if(r===void 0)return n;let i=typeof r!=`object`||!r||Array.isArray(r),a=t!==void 0&&_i(t);return!i&&!a?n:{...n,structuredContent:{result:r}}},decodeResult(e,t){if(Ni(t)&&`resultType`in t){let e={...t};return delete e.resultType,{kind:`complete`,result:Li(e)}}return{kind:`complete`,result:Li(t)}},encodeResult(e,t){if(e!==`tools/list`)return t;let n=t.tools;return!Array.isArray(n)||!n.some(e=>Ii(e))?t:{...t,tools:n.map(e=>Ii(e)?{...e,outputSchema:xi(e.outputSchema)}:e)}},encodeErrorCode:e=>e===-32002?-32602:e,checkInboundEnvelope:e=>void 0};function zi(){let e=ee(()=>h([g(),j(),O(),oe(),C(g(),e),D(e)])),t=C(g(),e),n=h([g(),j().int()]),r=g(),i=h([g(),j().int()]),a=E([`user`,`assistant`]),o=E([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),s=g().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),c=S({ttl:j().optional()}),l=S({taskId:g()}),u=M({progressToken:n.optional(),"io.modelcontextprotocol/related-task":l.optional()}),d=S({_meta:u.optional()}),f=d.extend({task:c.optional()}),p=S({_meta:u.optional()}),_=S({method:g(),params:p.loose().optional()}),v=S({src:g(),mimeType:g().optional(),sizes:D(g()).optional(),theme:E([`light`,`dark`]).optional()}),y=S({icons:D(v).optional()}),x=S({name:g(),title:g().optional()}),w=x.extend({...x.shape,...y.shape,version:g(),websiteUrl:g().optional(),description:g().optional()}),T=ne(S({applyDefaults:O().optional()}),t),te=A(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,ne(S({form:T.optional(),url:t.optional()}),t.optional())),re=M({list:t.optional(),cancel:t.optional(),requests:M({sampling:M({createMessage:t.optional()}).optional(),elicitation:M({create:t.optional()}).optional()}).optional()}),ie=M({list:t.optional(),cancel:t.optional(),requests:M({tools:M({call:t.optional()}).optional()}).optional()}),ae=S({experimental:C(g(),t).optional(),sampling:S({context:t.optional(),tools:t.optional()}).optional(),elicitation:te.optional(),roots:S({listChanged:O().optional()}).optional(),tasks:re.optional(),extensions:C(g(),t).optional()}),se=S({experimental:C(g(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:S({listChanged:O().optional()}).optional(),resources:S({subscribe:O().optional(),listChanged:O().optional()}).optional(),tools:S({listChanged:O().optional()}).optional(),tasks:ie.optional(),extensions:C(g(),t).optional()}),ce=S({progress:j(),total:m(j()),message:m(g())}),le=S({...p.shape,...ce.shape,progressToken:n}),ue=_.extend({method:k(`notifications/progress`),params:le}),de=p.extend({level:o,logger:g().optional(),data:b()}),fe=_.extend({method:k(`notifications/message`),params:de}),me=S({uri:g(),mimeType:m(g()),_meta:C(g(),b()).optional()}),he=me.extend({text:g()}),N=me.extend({blob:s}),P=S({audience:D(a).optional(),priority:j().min(0).max(1).optional(),lastModified:pe({offset:!0}).optional()}),ge=S({...x.shape,...y.shape,uri:g(),description:m(g()),mimeType:m(g()),size:m(j()),annotations:P.optional(),_meta:m(M({}))}),_e=S({...x.shape,...y.shape,uriTemplate:g(),description:m(g()),mimeType:m(g()),annotations:P.optional(),_meta:m(M({}))}),ve=_.extend({method:k(`notifications/resources/list_changed`),params:p.optional()}),ye=p.extend({uri:g()}),be=_.extend({method:k(`notifications/resources/updated`),params:ye}),F=S({name:g(),description:m(g()),required:m(O())}),xe=S({...x.shape,...y.shape,description:m(g()),arguments:m(D(F)),_meta:m(M({}))}),Se=_.extend({method:k(`notifications/prompts/list_changed`),params:p.optional()}),Ce=S({type:k(`text`),text:g(),annotations:P.optional(),_meta:C(g(),b()).optional()}),we=S({type:k(`image`),data:s,mimeType:g(),annotations:P.optional(),_meta:C(g(),b()).optional()}),Te=S({type:k(`audio`),data:s,mimeType:g(),annotations:P.optional(),_meta:C(g(),b()).optional()}),Ee=S({type:k(`tool_use`),name:g(),id:g(),input:C(g(),b()),_meta:C(g(),b()).optional()}),De=S({type:k(`resource`),resource:h([he,N]),annotations:P.optional(),_meta:C(g(),b()).optional()}),Oe=ge.extend({type:k(`resource_link`)}),ke=h([Ce,we,Te,Oe,De]),Ae=S({role:a,content:ke}),je=S({title:g().optional(),readOnlyHint:O().optional(),destructiveHint:O().optional(),idempotentHint:O().optional(),openWorldHint:O().optional()}),Me=_.extend({method:k(`notifications/tools/list_changed`),params:p.optional()}),Ne=S({name:g().optional()}),Pe=S({hints:D(Ne).optional(),costPriority:j().min(0).max(1).optional(),speedPriority:j().min(0).max(1).optional(),intelligencePriority:j().min(0).max(1).optional()}),ze=S({mode:E([`auto`,`required`,`none`]).optional()}),Ve=S({type:k(`boolean`),title:g().optional(),description:g().optional(),default:O().optional()}),I=S({type:k(`string`),title:g().optional(),description:g().optional(),minLength:j().optional(),maxLength:j().optional(),format:E([`email`,`uri`,`date`,`date-time`]).optional(),default:g().optional()}),He=S({type:E([`number`,`integer`]),title:g().optional(),description:g().optional(),minimum:j().optional(),maximum:j().optional(),default:j().optional()}),Ue=S({type:k(`string`),title:g().optional(),description:g().optional(),enum:D(g()),default:g().optional()}),We=S({type:k(`string`),title:g().optional(),description:g().optional(),oneOf:D(S({const:g(),title:g()})),default:g().optional()}),Ge=S({type:k(`string`),title:g().optional(),description:g().optional(),enum:D(g()),enumNames:D(g()).optional(),default:g().optional()}),Ke=h([Ue,We]),qe=S({type:k(`array`),title:g().optional(),description:g().optional(),minItems:j().optional(),maxItems:j().optional(),items:S({type:k(`string`),enum:D(g())}),default:D(g()).optional()}),L=S({type:k(`array`),title:g().optional(),description:g().optional(),minItems:j().optional(),maxItems:j().optional(),items:S({anyOf:D(S({const:g(),title:g()}))}),default:D(g()).optional()}),Je=h([qe,L]),R=h([Ge,Ke,Je]),z=h([R,Ve,I,He]),B=f.extend({mode:k(`form`).optional(),message:g(),requestedSchema:S({type:k(`object`),properties:C(g(),z),required:D(g()).optional()}).catchall(b())}),Ye=S({type:k(`ref/resource`),uri:g()}),V=S({type:k(`ref/prompt`),name:g()}),Xe=S({uri:g().startsWith(`file://`),name:g().optional(),_meta:C(g(),b()).optional()}),Ze=ae.shape,Qe=S({experimental:Ze.experimental,sampling:Ze.sampling,elicitation:Ze.elicitation,roots:Ze.roots,extensions:Ze.extensions}),$e=se.shape,et=S({experimental:$e.experimental,logging:$e.logging,completions:$e.completions,prompts:$e.prompts,resources:$e.resources,tools:$e.tools,extensions:$e.extensions}),tt=M({progressToken:n.optional(),[Fe]:g(),[Ie]:w.optional(),[Re]:Qe,[Be]:o.optional()}),nt=S({...x.shape,...y.shape,description:g().optional(),inputSchema:M({$schema:g().optional(),type:k(`object`)}),outputSchema:M({$schema:g().optional()}).optional(),annotations:je.optional(),_meta:C(g(),b()).optional()}),rt=S({type:k(`tool_result`),toolUseId:g(),content:D(ke),structuredContent:b().optional(),isError:O().optional(),_meta:C(g(),b()).optional()}),it=h([Ce,we,Te,Ee,rt]),at=S({role:a,content:h([it,D(it)]),_meta:C(g(),b()).optional()}),ot=g(),st=M({[Le]:w.optional().catch(void 0)}),ct=st.optional();function H(e){return M({_meta:ct,resultType:ot.default(`complete`),...e})}let lt=H({}),ut=H({nextCursor:r.optional()}),dt=H({content:D(ke),structuredContent:b().optional(),isError:O().optional()}),ft=H({ttlMs:j().int().min(0),cacheScope:E([`public`,`private`]),tools:D(nt),nextCursor:r.optional()}),pt=H({ttlMs:j().int().min(0),cacheScope:E([`public`,`private`]),prompts:D(xe),nextCursor:r.optional()}),mt=H({description:g().optional(),messages:D(Ae)}),ht=H({ttlMs:j().int().min(0),cacheScope:E([`public`,`private`]),resources:D(ge),nextCursor:r.optional()}),gt=H({ttlMs:j().int().min(0),cacheScope:E([`public`,`private`]),resourceTemplates:D(_e),nextCursor:r.optional()}),_t=H({ttlMs:j().int().min(0),cacheScope:E([`public`,`private`]),contents:D(h([he,N]))}),vt=H({completion:S({values:D(g()).max(100),total:j().int().optional(),hasMore:O().optional()}).loose()}),yt=H({ttlMs:j().int().min(0),cacheScope:E([`public`,`private`])}),bt=H({ttlMs:j().int().min(0).catch(0),cacheScope:E([`public`,`private`]).catch(`private`),supportedVersions:D(g()),capabilities:et,instructions:g().optional()}),xt=S({messages:D(at),modelPreferences:Pe.optional(),systemPrompt:g().optional(),includeContext:E([`none`,`thisServer`,`allServers`]).optional(),temperature:j().optional(),maxTokens:j().int(),stopSequences:D(g()).optional(),metadata:t.optional(),tools:D(nt).optional(),toolChoice:ze.optional()}),St=S({method:k(`sampling/createMessage`),params:xt}),Ct=S({method:k(`roots/list`),params:S({_meta:C(g(),b()).optional()}).optional()}),wt=S({...at.shape,model:g(),stopReason:g().optional()}),Tt=S({roots:D(Xe)}),Et=S({action:E([`accept`,`decline`,`cancel`]),content:C(g(),h([g(),j(),O(),D(g())])).optional()}),Dt=S({mode:k(`url`),message:g(),url:g().url()}),Ot=h([B,Dt]),kt=S({method:k(`elicitation/create`),params:Ot}),At=h([St,Ct,kt]),jt=h([wt,Tt,Et]),Mt=C(g(),At),Nt=C(g(),jt),Pt=H({inputRequests:Mt.optional(),requestState:g().optional()}),Ft={inputResponses:Nt.optional(),requestState:g().optional()},It=S({_meta:tt,...Ft}),Lt=M({progressToken:n.optional()});function U(e,t){return S({method:k(e),params:S({_meta:tt,...t})})}function W(e,t){return S({method:k(e),params:S({_meta:Lt.optional(),...t}).optional()})}let Rt={name:g(),arguments:C(g(),b()).optional(),...Ft},zt={cursor:r.optional()},Bt=U(`tools/call`,Rt),Vt=U(`tools/list`,zt),Ht=U(`prompts/list`,zt),Ut=U(`prompts/get`,{name:g(),arguments:C(g(),g()).optional(),...Ft}),Wt=U(`resources/list`,zt),Gt=U(`resources/templates/list`,zt),Kt=U(`resources/read`,{uri:g(),...Ft}),qt={ref:h([V,Ye]),argument:S({name:g(),value:g()}),context:S({arguments:C(g(),g()).optional()}).optional()},Jt=U(`completion/complete`,qt),Yt=U(`server/discover`,{}),Xt=S({toolsListChanged:O().optional(),promptsListChanged:O().optional(),resourcesListChanged:O().optional(),resourceSubscriptions:D(g()).optional()}),Zt={notifications:Xt},Qt=U(`subscriptions/listen`,Zt),$t=st.extend({"io.modelcontextprotocol/subscriptionId":i}),en=M({_meta:$t,resultType:ot.default(`complete`)}),tn={"tools/call":W(`tools/call`,Rt),"tools/list":W(`tools/list`,zt),"prompts/get":W(`prompts/get`,{name:g(),arguments:C(g(),g()).optional()}),"prompts/list":W(`prompts/list`,zt),"resources/list":W(`resources/list`,zt),"resources/templates/list":W(`resources/templates/list`,zt),"resources/read":W(`resources/read`,{uri:g()}),"completion/complete":W(`completion/complete`,qt),"server/discover":W(`server/discover`,{}),"subscriptions/listen":W(`subscriptions/listen`,Zt)};function G(e){return M({_meta:ct,...e})}let nn={"tools/call":G({content:D(ke),structuredContent:b().optional(),isError:O().optional()}),"tools/list":G({ttlMs:j().int().min(0),cacheScope:E([`public`,`private`]),tools:D(nt),nextCursor:r.optional()}),"prompts/get":G({description:g().optional(),messages:D(Ae)}),"prompts/list":G({ttlMs:j().int().min(0),cacheScope:E([`public`,`private`]),prompts:D(xe),nextCursor:r.optional()}),"resources/list":G({ttlMs:j().int().min(0),cacheScope:E([`public`,`private`]),resources:D(ge),nextCursor:r.optional()}),"resources/templates/list":G({ttlMs:j().int().min(0),cacheScope:E([`public`,`private`]),resourceTemplates:D(_e),nextCursor:r.optional()}),"resources/read":G({ttlMs:j().int().min(0),cacheScope:E([`public`,`private`]),contents:D(h([he,N]))}),"completion/complete":G({completion:S({values:D(g()).max(100),total:j().int().optional(),hasMore:O().optional()}).loose()}),"server/discover":G({ttlMs:j().int().min(0).catch(0),cacheScope:E([`public`,`private`]).catch(`private`),supportedVersions:D(g()),capabilities:et,instructions:g().optional()}),"subscriptions/listen":G({})},rn=M({"io.modelcontextprotocol/subscriptionId":i.optional()}),an=S({method:k(`notifications/subscriptions/acknowledged`),params:S({_meta:rn.optional(),notifications:Xt})}),on=S({_meta:rn.optional(),requestId:i,reason:g().optional()}),sn=S({method:k(`notifications/cancelled`),params:on}),cn={"notifications/cancelled":sn,"notifications/progress":ue,"notifications/message":fe,"notifications/resources/updated":be,"notifications/resources/list_changed":ve,"notifications/tools/list_changed":Me,"notifications/prompts/list_changed":Se,"notifications/subscriptions/acknowledged":an},K=e=>S({jsonrpc:k(`2.0`),id:h([g(),j().int()]),result:e}).strict();return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:n,CursorSchema:r,RequestIdSchema:i,RoleSchema:a,LoggingLevelSchema:o,TaskMetadataSchema:c,RelatedTaskMetadataSchema:l,RequestMetaSchema:u,BaseRequestParamsSchema:d,TaskAugmentedRequestParamsSchema:f,NotificationsParamsSchema:p,NotificationSchema:_,IconSchema:v,IconsSchema:y,BaseMetadataSchema:x,ImplementationSchema:w,ClientTasksCapabilitySchema:re,ServerTasksCapabilitySchema:ie,ClientCapabilitiesSchema:ae,ServerCapabilitiesSchema:se,ProgressSchema:ce,ProgressNotificationParamsSchema:le,ProgressNotificationSchema:ue,LoggingMessageNotificationParamsSchema:de,LoggingMessageNotificationSchema:fe,ResourceContentsSchema:me,TextResourceContentsSchema:he,BlobResourceContentsSchema:N,AnnotationsSchema:P,ResourceSchema:ge,ResourceTemplateSchema:_e,ResourceListChangedNotificationSchema:ve,ResourceUpdatedNotificationParamsSchema:ye,ResourceUpdatedNotificationSchema:be,PromptArgumentSchema:F,PromptSchema:xe,PromptListChangedNotificationSchema:Se,TextContentSchema:Ce,ImageContentSchema:we,AudioContentSchema:Te,ToolUseContentSchema:Ee,EmbeddedResourceSchema:De,ResourceLinkSchema:Oe,ContentBlockSchema:ke,PromptMessageSchema:Ae,ToolAnnotationsSchema:je,ToolListChangedNotificationSchema:Me,ModelHintSchema:Ne,ModelPreferencesSchema:Pe,ToolChoiceSchema:ze,BooleanSchemaSchema:Ve,StringSchemaSchema:I,NumberSchemaSchema:He,UntitledSingleSelectEnumSchemaSchema:Ue,TitledSingleSelectEnumSchemaSchema:We,LegacyTitledEnumSchemaSchema:Ge,SingleSelectEnumSchemaSchema:Ke,UntitledMultiSelectEnumSchemaSchema:qe,TitledMultiSelectEnumSchemaSchema:L,MultiSelectEnumSchemaSchema:Je,EnumSchemaSchema:R,PrimitiveSchemaDefinitionSchema:z,ElicitRequestFormParamsSchema:B,ResourceTemplateReferenceSchema:Ye,PromptReferenceSchema:V,RootSchema:Xe,ClientCapabilities2026Schema:Qe,ServerCapabilities2026Schema:et,RequestMetaEnvelopeSchema:tt,ToolSchema:nt,ToolResultContentSchema:rt,SamplingMessageContentBlockSchema:it,SamplingMessageSchema:at,ResultTypeSchema:ot,ResultMetaSchema:st,ResultSchema:lt,PaginatedResultSchema:ut,CallToolResultSchema:dt,ListToolsResultSchema:ft,ListPromptsResultSchema:pt,GetPromptResultSchema:mt,ListResourcesResultSchema:ht,ListResourceTemplatesResultSchema:gt,ReadResourceResultSchema:_t,CompleteResultSchema:vt,CacheableResultSchema:yt,DiscoverResultSchema:bt,CreateMessageRequestParamsSchema:xt,CreateMessageRequestSchema:St,ListRootsRequestSchema:Ct,CreateMessageResultSchema:wt,ListRootsResultSchema:Tt,ElicitResultSchema:Et,ElicitRequestURLParamsSchema:Dt,ElicitRequestParamsSchema:Ot,ElicitRequestSchema:kt,InputRequestSchema:At,InputResponseSchema:jt,InputRequestsSchema:Mt,InputResponsesSchema:Nt,InputRequiredResultSchema:Pt,InputResponseRequestParamsSchema:It,CallToolRequestSchema:Bt,ListToolsRequestSchema:Vt,ListPromptsRequestSchema:Ht,GetPromptRequestSchema:Ut,ListResourcesRequestSchema:Wt,ListResourceTemplatesRequestSchema:Gt,ReadResourceRequestSchema:Kt,CompleteRequestSchema:Jt,DiscoverRequestSchema:Yt,SubscriptionFilterSchema:Xt,SubscriptionsListenRequestSchema:Qt,SubscriptionsListenResultMetaSchema:$t,SubscriptionsListenResultSchema:en,dispatchRequestSchemas:tn,dispatchResultSchemas:nn,NotificationMetaSchema:rn,SubscriptionsAcknowledgedNotificationSchema:an,CancelledNotificationParamsSchema:on,CancelledNotificationSchema:sn,notificationSchemas2026:cn,JSONRPCResultResponseSchema:K(lt),CallToolResultResponseSchema:K(h([dt,Pt])),ListToolsResultResponseSchema:K(ft),ListPromptsResultResponseSchema:K(pt),GetPromptResultResponseSchema:K(h([mt,Pt])),ListResourcesResultResponseSchema:K(ht),ListResourceTemplatesResultResponseSchema:K(gt),ReadResourceResultResponseSchema:K(h([_t,Pt])),CompleteResultResponseSchema:K(vt),DiscoverResultResponseSchema:K(bt),SubscriptionsListenResultResponseSchema:K(en)}}var Bi;function Vi(){return Bi??=zi()}var Hi=[`tools/list`,`prompts/list`,`resources/list`,`resources/templates/list`,`resources/read`,`server/discover`];function Ui(e){return Hi.includes(e)}var Wi=Symbol(`modelcontextprotocol.resultCacheHintFallback`);function Gi(e){return e[Wi]}function Ki(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function qi(e){return e===`public`||e===`private`}var X=function(e){return e[e.ParseError=-32700]=`ParseError`,e[e.InvalidRequest=-32600]=`InvalidRequest`,e[e.MethodNotFound=-32601]=`MethodNotFound`,e[e.InvalidParams=-32602]=`InvalidParams`,e[e.InternalError=-32603]=`InternalError`,e[e.ResourceNotFound=-32002]=`ResourceNotFound`,e[e.MissingRequiredClientCapability=-32021]=`MissingRequiredClientCapability`,e[e.UnsupportedProtocolVersion=-32022]=`UnsupportedProtocolVersion`,e[e.UrlElicitationRequired=-32042]=`UrlElicitationRequired`,e}({}),Z=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.ProtocolError`})}static[Symbol.hasInstance](e){return $r(this,e)}static isInstance(e){if(typeof this!=`function`)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return $r(this,e)}constructor(e,t,n){super(t),this.code=e,this.data=n,this.name=`ProtocolError`,Qr(this,new.target)}static fromError(t,n,r){if(t===X.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new Yi(e.elicitations,n)}if(t===X.UnsupportedProtocolVersion&&r){let e=r;if(Array.isArray(e.supported)&&typeof e.requested==`string`)return new Xi({supported:e.supported,requested:e.requested},n)}if(t===X.InvalidParams||t===X.ResourceNotFound){let e=r;if(typeof e?.uri==`string`&&(t===X.ResourceNotFound||Object.keys(e).length===1))return new Ji(e.uri,n)}if(t===X.MissingRequiredClientCapability&&r){let e=r;if(e.requiredCapabilities!==null&&typeof e.requiredCapabilities==`object`&&!Array.isArray(e.requiredCapabilities))return new Zi({requiredCapabilities:e.requiredCapabilities},n)}return new e(t,n,r)}},Ji=class extends Z{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.ResourceNotFoundError`})}constructor(e,t=`Resource not found: ${e}`){super(X.InvalidParams,t,{uri:e})}get uri(){return this.data.uri}},Yi=class extends Z{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.UrlElicitationRequiredError`})}constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(X.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},Xi=class extends Z{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.UnsupportedProtocolVersionError`})}constructor(e,t=`Unsupported protocol version: ${e.requested}`){super(X.UnsupportedProtocolVersion,t,e)}get supported(){return this.data.supported}get requested(){return this.data.requested}},Zi=class extends Z{static{Object.defineProperty(this,"mcpBrand",{value:`mcp.MissingRequiredClientCapabilityError`})}constructor(e,t=`Missing required client capabilities: ${Object.keys(e.requiredCapabilities).join(`, `)}`){super(X.MissingRequiredClientCapability,t,e)}get requiredCapabilities(){return this.data.requiredCapabilities}},Qi=0,$i=`private`,ea=[`tools/call`,`prompts/get`,`resources/read`];function ta(e,t){let n=t.resultType;if(n===void 0)return{...t,resultType:`complete`};if(n===`complete`||ea.includes(e))return t;throw new Z(X.InternalError,`Handler for ${e} returned resultType '${String(n)}', but results of ${e} only support 'complete' on protocol revision 2026-07-28`)}function na(e,t){let n=Gi(t);if(t.resultType!==`complete`||!Ui(e))return n===void 0?t:sa(t);let r=t,i=Ki(r.ttlMs)?r.ttlMs:aa(n),a=qi(r.cacheScope)?r.cacheScope:oa(n),o={...r,ttlMs:i,cacheScope:a};return delete o[Wi],o}function ra(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ia(e,t){if(t===void 0)return e;let n=e._meta;return n===void 0?{...e,_meta:{[Le]:t}}:!ra(n)||n[`io.modelcontextprotocol/serverInfo`]!==void 0?e:{...e,_meta:{...n,[Le]:t}}}function aa(e){return e!==void 0&&Ki(e.ttlMs)?e.ttlMs:Qi}function oa(e){return e!==void 0&&qi(e.cacheScope)?e.cacheScope:$i}function sa(e){let t={...e};return delete t[Wi],t}var ca=[`elicitation/create`,`sampling/createMessage`,`roots/list`],la;function ua(){if(la)return la;let e=Vi();return la={request:{"elicitation/create":S({method:k(`elicitation/create`),params:e.ElicitRequestParamsSchema}),"sampling/createMessage":S({method:k(`sampling/createMessage`),params:e.CreateMessageRequestParamsSchema}),"roots/list":S({method:k(`roots/list`),params:M({}).optional()})},response:{"elicitation/create":e.ElicitResultSchema,"sampling/createMessage":e.CreateMessageResultSchema,"roots/list":e.ListRootsResultSchema}},la}function da(e){return ca.includes(e)}function fa(e){return da(e)?ua().request[e]:void 0}function pa(e){return da(e)?ua().response[e]:void 0}var ma={"tools/call":null,"tools/list":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"completion/complete":null,"server/discover":null,"subscriptions/listen":null},ha={"notifications/cancelled":null,"notifications/progress":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/subscriptions/acknowledged":null};function ga(e){return Object.prototype.hasOwnProperty.call(ma,e)}function _a(e){return Object.prototype.hasOwnProperty.call(ha,e)}function va(e){return Object.prototype.hasOwnProperty.call(ma,e)}function ya(e){return ga(e)?Vi().dispatchRequestSchemas[e]:void 0}function ba(e){return va(e)?Vi().dispatchResultSchemas[e]:void 0}function xa(e){return _a(e)?Vi().notificationSchemas2026[e]:void 0}Object.keys(ma),Object.keys(ha);function Sa(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ca(e,t){if(e===void 0)return{ok:!1,reason:`not-in-era`};let n=e.safeParse(t);return n.success?{ok:!0,value:n.data}:{ok:!1,reason:`invalid`,message:String(n.error)}}var wa={ok:!1,reason:`not-in-era`},Ta=[Fe,Re];function Ea(e,t){let n=t,r=!1,i=()=>(r||=(n={...n},!0),n),a=t.tools;e===`tools/list`&&Array.isArray(a)&&a.some(e=>Sa(e)&&`execution`in e)&&(i().tools=a.map(e=>{if(!Sa(e)||!(`execution`in e))return e;let t={...e};return delete t.execution,t}));let o=t.capabilities;if(Sa(o)&&`tasks`in o){let e={...o};delete e.tasks,i().capabilities=e}return n}var Da={era:`2026-07-28`,hasRequestMethod:ga,hasNotificationMethod:_a,hasInputRequestMethod:e=>fa(e)!==void 0,validateRequest:(e,t)=>Ca(ya(e),t),validateResult:(e,t)=>Ca(ba(e),t),validateNotification:(e,t)=>Ca(xa(e),t),validateInputRequest:(e,t)=>Ca(fa(e),t),validateInputResponse:(e,t)=>Ca(pa(e),t),samplingResultVariant:()=>wa,outboundEnvelope(e){return{[Fe]:e.protocolVersion,[Ie]:e.clientInfo,[Re]:e.clientCapabilities,...e.logLevel!==void 0&&{"io.modelcontextprotocol/logLevel":e.logLevel}}},validateEnvelopeMeta(e){let t=[];for(let n of Ta)n in e||t.push({key:n,problem:`missing`});let n=Vi().RequestMetaEnvelopeSchema.safeParse(e);if(!n.success)for(let e of n.error.issues){let n=e.path.map(String),r=n.length>0?n.join(`.`):`_meta`;n.length===1&&t.some(e=>e.key===r&&e.problem===`missing`)||t.push({key:r,problem:e.message})}return t},projectCallToolResult:e=>di(e),inputRequestSchema:fa,decodeResult(e,t){if(!Sa(t))return{kind:`invalid`,error:new Y(J.InvalidResult,`Invalid result for ${e}: not an object`,{method:e})};let n=t.resultType;if(n===void 0)return{kind:`invalid`,error:new Y(J.InvalidResult,`Invalid result for ${e}: missing required resultType — servers implementing protocol revision 2026-07-28 MUST include it (the absent-means-complete bridge applies only to earlier-revision servers)`,{method:e,violation:`missing-resultType`})};if(typeof n!=`string`)return{kind:`invalid`,error:new Y(J.InvalidResult,`Invalid result for ${e}: non-string resultType`,{method:e,resultType:n})};if(n===`input_required`){let n=t.inputRequests,r=Sa(n)?n:{},i=t.requestState,a=t._meta===void 0?void 0:Vi().ResultMetaSchema.safeParse(t._meta),o=a?.success?a.data:void 0;return Object.keys(r).length===0&&typeof i!=`string`?{kind:`invalid`,error:new Y(J.InvalidResult,`Invalid result for ${e}: input_required carries neither inputRequests nor requestState (every input_required result must include at least one of the two)`,{method:e,violation:`input-required-missing-both`})}:{kind:`input_required`,inputRequests:r,...typeof i==`string`&&{requestState:i},...o!==void 0&&{_meta:o}}}if(n!==`complete`)return{kind:`invalid`,error:new Y(J.UnsupportedResultType,`Unsupported result type '${n}' for ${e}`,{resultType:n,method:e})};let r=ka(),i=Object.hasOwn(r,e)?r[e]:void 0;if(i!==void 0){let n=i.safeParse(t);if(!n.success)return{kind:`invalid`,error:new Y(J.InvalidResult,`Invalid result for ${e}: ${n.error}`,{method:e})}}let a={...t};return delete a.resultType,{kind:`complete`,result:a}},encodeResult(e,t,n){return ia(na(e,ta(e,Ea(e,t))),n)},encodeErrorCode:e=>e===-32002?-32602:e,checkInboundEnvelope(e){if(e.envelope===void 0)return`Request is missing the required _meta envelope for protocol revision 2026-07-28 (io.modelcontextprotocol/protocolVersion, io.modelcontextprotocol/clientCapabilities)`;let t=Vi().RequestMetaEnvelopeSchema.safeParse(e.envelope);if(!t.success)return`Invalid _meta envelope for protocol revision 2026-07-28: ${t.error.issues.map(e=>e.message).join(`; `)}`}},Oa;function ka(){if(Oa)return Oa;let e=Vi();return Oa={"tools/call":e.CallToolResultSchema,"tools/list":e.ListToolsResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"completion/complete":e.CompleteResultSchema,"server/discover":e.DiscoverResultSchema},Oa}var Aa=`2026-07-28`;function ja(e){return e!==void 0&&ci(e)?Da:Ri}function Ma(e){return e.revision===void 0?e.era===`modern`?Da.era:Ri.era:ja(e.revision).era}function Na(e){return Ia.some(t=>t.hasRequestMethod(e))}function Pa(e){return Ia.some(t=>t.hasNotificationMethod(e))}function Fa(e){return e===`tasks/get`||e===`tasks/cancel`}var Ia=[Ri,Da],La=Ce({AnnotationsSchema:()=>Nt,AudioContentSchema:()=>ln,BaseMetadataSchema:()=>ct,BaseRequestParamsSchema:()=>L,BlobResourceContentsSchema:()=>jt,BooleanSchemaSchema:()=>Wn,CallToolRequestParamsSchema:()=>wn,CallToolRequestSchema:()=>Tn,CallToolResultSchema:()=>Sn,CancelTaskRequestSchema:()=>Ar,CancelTaskResultSchema:()=>jr,CancelledNotificationParamsSchema:()=>it,CancelledNotificationSchema:()=>at,ClientCapabilitiesSchema:()=>pt,ClientNotificationSchema:()=>Nr,ClientRequestSchema:()=>Mr,ClientResultSchema:()=>Pr,ClientTasksCapabilitySchema:()=>dt,CompatibilityCallToolResultSchema:()=>Cn,CompleteRequestParamsSchema:()=>dr,CompleteRequestSchema:()=>fr,CompleteResultSchema:()=>pr,ContentBlockSchema:()=>pn,CreateMessageRequestParamsSchema:()=>Bn,CreateMessageRequestSchema:()=>Vn,CreateMessageResultSchema:()=>Hn,CreateMessageResultWithToolsSchema:()=>Un,CreateTaskResultSchema:()=>xr,CursorSchema:()=>We,DiscoverRequestSchema:()=>yt,DiscoverResultSchema:()=>bt,ElicitRequestFormParamsSchema:()=>nr,ElicitRequestParamsSchema:()=>ir,ElicitRequestSchema:()=>ar,ElicitRequestURLParamsSchema:()=>rr,ElicitResultSchema:()=>cr,ElicitationCompleteNotificationParamsSchema:()=>or,ElicitationCompleteNotificationSchema:()=>sr,EmbeddedResourceSchema:()=>dn,EmptyResultSchema:()=>rt,EnumSchemaSchema:()=>er,GetPromptRequestParamsSchema:()=>on,GetPromptRequestSchema:()=>sn,GetPromptResultSchema:()=>hn,GetTaskPayloadRequestSchema:()=>Er,GetTaskPayloadResultSchema:()=>Dr,GetTaskRequestSchema:()=>wr,GetTaskResultSchema:()=>Tr,IconSchema:()=>ot,IconsSchema:()=>st,ImageContentSchema:()=>K,ImplementationSchema:()=>H,InitializeRequestParamsSchema:()=>mt,InitializeRequestSchema:()=>ht,InitializeResultSchema:()=>_t,InitializedNotificationSchema:()=>vt,JSONArraySchema:()=>He,JSONObjectSchema:()=>I,JSONRPCErrorResponseSchema:()=>et,JSONRPCMessageSchema:()=>tt,JSONRPCNotificationSchema:()=>Qe,JSONRPCRequestSchema:()=>Ze,JSONRPCResponseSchema:()=>nt,JSONRPCResultResponseSchema:()=>$e,JSONValueSchema:()=>Ve,LegacyTitledEnumSchemaSchema:()=>Yn,ListChangedOptionsBaseSchema:()=>Dn,ListPromptsRequestSchema:()=>rn,ListPromptsResultSchema:()=>an,ListResourceTemplatesRequestSchema:()=>U,ListResourceTemplatesResultSchema:()=>W,ListResourcesRequestSchema:()=>It,ListResourcesResultSchema:()=>Lt,ListRootsRequestSchema:()=>hr,ListRootsResultSchema:()=>gr,ListTasksRequestSchema:()=>Or,ListTasksResultSchema:()=>kr,ListToolsRequestSchema:()=>bn,ListToolsResultSchema:()=>xn,LoggingLevelSchema:()=>On,LoggingMessageNotificationParamsSchema:()=>jn,LoggingMessageNotificationSchema:()=>Mn,ModelHintSchema:()=>Nn,ModelPreferencesSchema:()=>Pn,MultiSelectEnumSchemaSchema:()=>$n,NotificationSchema:()=>B,NotificationsParamsSchema:()=>z,NumberSchemaSchema:()=>Kn,PaginatedRequestParamsSchema:()=>Tt,PaginatedRequestSchema:()=>Et,PaginatedResultSchema:()=>Dt,PingRequestSchema:()=>xt,PrimitiveSchemaDefinitionSchema:()=>tr,ProgressNotificationParamsSchema:()=>Ct,ProgressNotificationSchema:()=>wt,ProgressSchema:()=>St,ProgressTokenSchema:()=>Ue,PromptArgumentSchema:()=>G,PromptListChangedNotificationSchema:()=>gn,PromptMessageSchema:()=>mn,PromptReferenceSchema:()=>ur,PromptSchema:()=>nn,ReadResourceRequestParamsSchema:()=>zt,ReadResourceRequestSchema:()=>Bt,ReadResourceResultSchema:()=>Vt,RelatedTaskMetadataSchema:()=>Ke,RequestIdSchema:()=>Xe,RequestMetaSchema:()=>qe,RequestSchema:()=>R,ResourceContentsSchema:()=>Ot,ResourceLinkSchema:()=>fn,ResourceListChangedNotificationSchema:()=>Ht,ResourceRequestParamsSchema:()=>Rt,ResourceSchema:()=>Pt,ResourceTemplateReferenceSchema:()=>lr,ResourceTemplateSchema:()=>Ft,ResourceUpdatedNotificationParamsSchema:()=>en,ResourceUpdatedNotificationSchema:()=>tn,ResultMetaObjectSchema:()=>Ye,ResultSchema:()=>V,RoleSchema:()=>Mt,RootSchema:()=>mr,RootsListChangedNotificationSchema:()=>_r,SamplingContentSchema:()=>Ln,SamplingMessageContentBlockSchema:()=>Rn,SamplingMessageSchema:()=>zn,ServerCapabilitiesSchema:()=>gt,ServerNotificationSchema:()=>Ir,ServerRequestSchema:()=>Fr,ServerResultSchema:()=>Lr,ServerTasksCapabilitySchema:()=>ft,SetLevelRequestParamsSchema:()=>kn,SetLevelRequestSchema:()=>An,SingleSelectEnumSchemaSchema:()=>Xn,StringSchemaSchema:()=>Gn,SubscribeRequestParamsSchema:()=>Ut,SubscribeRequestSchema:()=>Wt,SubscriptionFilterSchema:()=>qt,SubscriptionsAcknowledgedNotificationParamsSchema:()=>Xt,SubscriptionsAcknowledgedNotificationSchema:()=>Zt,SubscriptionsListenRequestParamsSchema:()=>Jt,SubscriptionsListenRequestSchema:()=>Yt,SubscriptionsListenResultMetaSchema:()=>Qt,SubscriptionsListenResultSchema:()=>$t,TaskAugmentedRequestParamsSchema:()=>Je,TaskCreationParamsSchema:()=>vr,TaskMetadataSchema:()=>Ge,TaskSchema:()=>br,TaskStatusNotificationParamsSchema:()=>Sr,TaskStatusNotificationSchema:()=>Cr,TaskStatusSchema:()=>yr,TextContentSchema:()=>cn,TextResourceContentsSchema:()=>kt,TitledMultiSelectEnumSchemaSchema:()=>Qn,TitledSingleSelectEnumSchemaSchema:()=>Jn,ToolAnnotationsSchema:()=>_n,ToolChoiceSchema:()=>Fn,ToolExecutionSchema:()=>vn,ToolListChangedNotificationSchema:()=>En,ToolResultContentSchema:()=>In,ToolSchema:()=>yn,ToolUseContentSchema:()=>un,UnsubscribeRequestParamsSchema:()=>Gt,UnsubscribeRequestSchema:()=>Kt,UntitledMultiSelectEnumSchemaSchema:()=>Zn,UntitledSingleSelectEnumSchemaSchema:()=>qn}),Ra=e=>Ze.safeParse(e).success,za=e=>Qe.safeParse(e).success,Ba=e=>$e.safeParse(e).success,Va=e=>et.safeParse(e).success,Ha=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&e.resultType===`input_required`,Ua=e=>ht.safeParse(e).success,Wa=e=>vt.safeParse(e).success,Ga=`Mcp-Param-`,Ka=`x-mcp-header`,qa=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,Ja=new Set([`string`,`integer`,`boolean`,`number`]);function Ya(e){let t=[],n=new Map,r=(e,i,a)=>{if(typeof e!=`object`||!e)return;let o=e;if(Ka in o){if(!a||i.length===0)return`${Qa(i)}: x-mcp-header is only permitted on properties statically reachable via a chain of 'properties' keys (not under items, additionalProperties, oneOf/anyOf/allOf/not, if/then/else, or $ref)`;let e=o[Ka];if(typeof e!=`string`||e.length===0)return`${Qa(i)}: x-mcp-header MUST be a non-empty string`;if(!qa.test(e))return`${Qa(i)}: x-mcp-header '${e}' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)`;let r=typeof o.type==`string`?o.type:void 0;if(r===void 0||!Ja.has(r))return`${Qa(i)}: x-mcp-header is only permitted on primitive-typed properties (string, integer, boolean); got ${r??``}`;let s=e.toLowerCase(),c=n.get(s);if(c!==void 0)return`x-mcp-header '${e}' is not case-insensitively unique (also declared as '${c}')`;n.set(s,e),t.push({path:i,headerName:e,type:r})}let s=o.properties;if(typeof s==`object`&&s)for(let[e,t]of Object.entries(s)){let n=r(t,[...i,e],a);if(n!==void 0)return n}for(let e of Xa){let t=o[e];if(t===void 0)continue;let n=Array.isArray(t)?t:typeof t==`object`&&t&&Za.has(e)?Object.values(t):[t];for(let t of n){let n=r(t,[...i,`<${e}>`],!1);if(n!==void 0)return n}}},i=r(e,[],!0);return i===void 0?{valid:!0,declarations:t}:{valid:!1,reason:i}}var Xa=[`items`,`prefixItems`,`contains`,`additionalProperties`,`unevaluatedProperties`,`unevaluatedItems`,`propertyNames`,`patternProperties`,`dependentSchemas`,`oneOf`,`anyOf`,`allOf`,`not`,`if`,`then`,`else`,`$defs`,`definitions`],Za=new Set([`patternProperties`,`dependentSchemas`,`$defs`,`definitions`]);function Qa(e){return e.length===0?``:e.join(`.`)}var $a=`=?base64?`,eo=`?=`;function to(e){if(typeof e==`string`)return e;if(typeof e==`boolean`)return e?`true`:`false`;if(typeof e==`number`)return!Number.isFinite(e)||Number.isInteger(e)&&!Number.isSafeInteger(e)?void 0:String(e)}function no(e){if(e.length===0||e.startsWith($a)&&e.endsWith(eo)||e!==e.trim())return!0;for(let t=0;t=32&&n<=126))return!0}return!1}function ro(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCodePoint(e);return btoa(n)}function io(e){return no(e)?`${$a}${ro(e)}${eo}`:e}function ao(e,t){let n=e;for(let e of t){if(typeof n!=`object`||!n)return;n=n[e]}return n}function oo(e,t){let n={};for(let r of e){let e=ao(t,r.path);if(e==null)continue;let i=to(e);i!==void 0&&(n[`${Ga}${r.headerName}`]=io(i))}return n}X.InvalidRequest,X.UnsupportedProtocolVersion,X.InvalidParams,X.MethodNotFound,X.InvalidParams,X.MissingRequiredClientCapability,X.ParseError,X.InvalidRequest,X.MethodNotFound,X.UnsupportedProtocolVersion,X.MissingRequiredClientCapability;var so={"tools/call":`name`,"prompts/get":`name`,"resources/read":`uri`,"tasks/get":`taskId`,"tasks/update":`taskId`,"tasks/cancel":`taskId`};function co(e,t){let n=Object.hasOwn(so,e)?so[e]:void 0;if(n===void 0)return;let r=lo(t)?t[n]:void 0;return{field:n,value:typeof r==`string`?r:void 0}}function lo(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function uo(e,t){return p(e,t)}function fo(e){return new Set(e.flatMap(e=>Object.keys(e.shape)))}function po(e){if(e==null)return!1;let t=typeof e;return t!==`object`&&t!==`function`||!(`~standard`in e)?!1:typeof e[`~standard`]?.validate==`function`}var mo=!1,ho=`draft-2020-12`;function go(e,t=`input`){let n=e[`~standard`],r;if(n.jsonSchema)r=n.jsonSchema[t]({target:ho});else if(n.vendor===`zod`){if(!(`_zod`in e))throw Error(`Schema appears to be from zod 3, which the SDK cannot convert to JSON Schema. Upgrade to zod >=4.2.0, or wrap your JSON Schema with fromJsonSchema().`);mo||(mo=!0,console.warn("[mcp-sdk] Your zod version does not implement `~standard.jsonSchema` (added in zod 4.2.0). Falling back to z.toJSONSchema(). Upgrade to zod >=4.2.0 to silence this warning.")),r=ie(e,{target:ho,io:t})}else throw Error(`Schema library "${n.vendor}" does not implement StandardJSONSchemaV1 (\`~standard.jsonSchema\`). Upgrade to a version that does, or wrap your JSON Schema with fromJsonSchema().`);if(t===`output`)return r.type===void 0&&_o(r)?{type:`object`,...r}:r;if(r.type!==void 0&&r.type!==`object`)throw Error(`MCP tool and prompt schemas must describe objects (got type: ${JSON.stringify(r.type)}). Wrap your schema in z.object({...}) or equivalent.`);return{type:`object`,...r}}function _o(e){if(`properties`in e||`patternProperties`in e||`additionalProperties`in e||`required`in e)return!0;for(let t of[`oneOf`,`anyOf`,`allOf`]){let n=e[t];if(Array.isArray(n)&&n.length>0)return n.every(e=>typeof e==`object`&&!!e&&(e.type===`object`||_o(e)))}return!1}function vo(e){return e.path?.length?`${e.path.map(e=>String(typeof e==`object`?e.key:e)).join(`.`)}: ${e.message}`:e.message}async function yo(e,t){let n=await e[`~standard`].validate(t);return n.issues&&n.issues.length>0?{success:!1,error:n.issues.map(e=>vo(e)).join(`, `)}:{success:!0,data:n.value}}function bo(e){let t=ie(e,{target:ho,io:`input`});return typeof t.pattern==`string`?t.pattern:void 0}var xo=/\\\.\\d\{(\d+)\}/;function So(e){let t=xo.exec(e),n=[void 0,-1,0];return t&&n.push(Number(t[1])),[!1,!0].flatMap(e=>[!1,!0].flatMap(t=>n.map(n=>pe({local:e,offset:t,precision:n}))))}function Co(e,t){let n;switch(e){case`email`:n=[re()];break;case`uri`:n=[ae()];break;case`date`:n=[me()];break;case`date-time`:n=So(t)}return new Set(n.map(e=>bo(e)).filter(e=>e!==void 0))}function wo(e,t,n){return n!==`zod`||Co(e,t).has(t)}function To(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Eo(e){try{return go(e,`input`)}catch(e){let t=e instanceof Error?e.message:String(e);throw new Z(X.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${t}`)}}var Do=new Set([`$comment`,`deprecated`,`description`,`examples`,`readOnly`,`title`,`writeOnly`]);function Oo(e){return Do.has(e)||e.startsWith(`x-`)}var ko=new Set([`$schema`,...Object.keys(nr.shape.requestedSchema.shape)]),Ao={string:fo([Gn,qn,Jn,Yn]),number:fo([Kn]),integer:fo([Kn]),boolean:fo([Wn]),array:fo([Zn,Qn])},jo=new Set(Gn.shape.format.unwrap().options);function Mo(e,t,n,r){if(!To(e))return e;let i=typeof e.type==`string`&&Object.hasOwn(Ao,e.type)?Ao[e.type]:void 0;if(i===void 0)return e;let a={};for(let[o,s]of Object.entries(e))i.has(o)||Oo(o)?a[o]=s:o===`pattern`&&e.type===`string`&&typeof e.format==`string`?jo.has(e.format)?(typeof s!=`string`||!wo(e.format,s,n))&&r.push(`${t}.${o}`):a[o]=s:r.push(`${t}.${o}`);return a}function No(e,t){let n={},r=[];for(let[i,a]of Object.entries(e))i===`properties`&&To(a)?n[i]=Object.fromEntries(Object.entries(a).map(([e,n])=>[e,Mo(n,`properties.${e}`,t,r)])):ko.has(i)?n[i]=a:Oo(i)||r.push(i);if(r.length>0)throw new Z(X.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${r.join(`, `)}`);return n}function Po(e,t){if(!To(e.properties))return t;let n=Object.entries(e.properties).filter(([,e])=>!uo(tr,e).success).map(([e])=>`properties.${e}`);return n.length>0?n.join(`, `):t}function Fo(e,t,n=``){return Array.isArray(e)&&Array.isArray(t)?e.flatMap((e,r)=>Fo(e,t[r],`${n}[${r}]`)):!To(e)||!To(t)?[]:Object.entries(e).flatMap(([e,r])=>{let i=n?`${n}.${e}`:e;return Object.prototype.hasOwnProperty.call(t,e)?Fo(r,t[e],i):Oo(e)?[]:[i]})}function Io(e){if(!po(e.requestedSchema))return{...e,mode:`form`,requestedSchema:e.requestedSchema};let t=e.requestedSchema[`~standard`].vendor,n=No(Eo(e.requestedSchema),t),r=uo(nr.shape.requestedSchema,n);if(!r.success)throw new Z(X.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${Po(n,r.error.message)}`);let i=Fo(n,r.data);if(i.length>0)throw new Z(X.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${i.join(`, `)}`);let a=(r.data.required??[]).filter(e=>!Object.prototype.hasOwnProperty.call(r.data.properties,e));if(a.length>0)throw new Z(X.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${a.join(`, `)}`);return{...e,mode:`form`,requestedSchema:r.data}}function Lo(e){let t=e.inputRequests!==void 0&&Object.keys(e.inputRequests).length>0,n=typeof e.requestState==`string`;if(!t&&!n)throw TypeError(`inputRequired() requires at least one of inputRequests (with at least one entry) or requestState (spec: every InputRequiredResult MUST include at least one of the two)`);return{resultType:`input_required`,...e.inputRequests!==void 0&&{inputRequests:e.inputRequests},...e.requestState!==void 0&&{requestState:e.requestState}}}Object.assign(Lo,{elicit(e){try{return{method:`elicitation/create`,params:Io(e)}}catch(e){throw e instanceof Z?TypeError(e.message,{cause:e}):e}},elicitUrl(e){return{method:`elicitation/create`,params:{...e,mode:`url`}}},createMessage(e){return{method:`sampling/createMessage`,params:e}},listRoots(){return{method:`roots/list`}}});var Ro=!0,zo=10,Bo=250;function Vo(e){return{autoFulfill:e?.autoFulfill??Ro,maxRounds:e?.maxRounds??zo}}function Ho(e,t,n){let r=t!==void 0&&Object.keys(t).length>0;return!r&&n===void 0?e:{...e,...r&&{inputResponses:t},...n!==void 0&&{requestState:n}}}function Uo(e,t){return`Multi-round-trip request '${e}' still required input after ${t} rounds (inputRequired.maxRounds)`}function Wo(e,t){return new Promise((n,r)=>{if(t?.aborted){r(t.reason instanceof Y?t.reason:new Y(J.RequestTimeout,String(t.reason)));return}let i=setTimeout(()=>{t?.removeEventListener(`abort`,a),n()},e),a=()=>{clearTimeout(i),r(t?.reason instanceof Y?t.reason:new Y(J.RequestTimeout,String(t?.reason)))};t?.addEventListener(`abort`,a,{once:!0})})}function Go(e){let t=new AbortController,n=()=>t.abort(e?.reason);return e?.addEventListener(`abort`,n,{once:!0}),e?.aborted&&t.abort(e.reason),{signal:t.signal,abort:e=>t.abort(e),dispose:()=>e?.removeEventListener(`abort`,n)}}async function Ko(e){let{config:t,method:n,originalParams:r,requestOptions:i,hooks:a,signal:o}=e,s=e.flowStartedAt??Date.now(),c=e.firstPayload,l=0;for(;;){if(l+=1,l>t.maxRounds)throw new Y(J.InputRequiredRoundsExceeded,Uo(n,t.maxRounds),{rounds:t.maxRounds,lastResult:{inputRequests:c.inputRequests,...c.requestState!==void 0&&{requestState:c.requestState}}});i.onprogress?.({progress:l,message:`Fulfilling input required by '${n}' (round ${l})`});let e=Object.entries(c.inputRequests??{}),u;if(e.length>0){let t=Go(o);try{let n=await Promise.all(e.map(async([e,n])=>{try{return[e,await a.dispatchInputRequest(e,n,t.signal)]}catch(e){throw t.abort(e),e}}));u=Object.fromEntries(n)}finally{t.dispose()}}else await Wo(Bo,o);let d={...i.timeout!==void 0&&{timeout:i.timeout}};if(i.maxTotalTimeout!==void 0){let e=Date.now()-s,t=i.maxTotalTimeout-e;if(t<=0)throw new Y(J.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:i.maxTotalTimeout,totalElapsed:e});d.maxTotalTimeout=t}let f=await a.retry(Ho(r,u,c.requestState),d);if(Ha(f)){c={inputRequests:f.inputRequests??{},...f.requestState!==void 0&&{requestState:f.requestState}};continue}return f}}var qo=`AnnotationsSchema.AudioContentSchema.BaseMetadataSchema.BlobResourceContentsSchema.BooleanSchemaSchema.CallToolRequestSchema.CallToolRequestParamsSchema.CallToolResultSchema.CancelledNotificationSchema.CancelledNotificationParamsSchema.CancelTaskRequestSchema.CancelTaskResultSchema.ClientCapabilitiesSchema.ClientNotificationSchema.ClientRequestSchema.ClientResultSchema.CompatibilityCallToolResultSchema.CompleteRequestSchema.CompleteRequestParamsSchema.CompleteResultSchema.ContentBlockSchema.CreateMessageRequestSchema.CreateMessageRequestParamsSchema.CreateMessageResultSchema.CreateMessageResultWithToolsSchema.CreateTaskResultSchema.CursorSchema.DiscoverRequestSchema.DiscoverResultSchema.ElicitationCompleteNotificationSchema.ElicitationCompleteNotificationParamsSchema.ElicitRequestSchema.ElicitRequestFormParamsSchema.ElicitRequestParamsSchema.ElicitRequestURLParamsSchema.ElicitResultSchema.EmbeddedResourceSchema.EmptyResultSchema.EnumSchemaSchema.GetPromptRequestSchema.GetPromptRequestParamsSchema.GetPromptResultSchema.GetTaskPayloadRequestSchema.GetTaskPayloadResultSchema.GetTaskRequestSchema.GetTaskResultSchema.IconSchema.IconsSchema.ImageContentSchema.ImplementationSchema.InitializedNotificationSchema.InitializeRequestSchema.InitializeRequestParamsSchema.InitializeResultSchema.JSONArraySchema.JSONObjectSchema.JSONRPCErrorResponseSchema.JSONRPCMessageSchema.JSONRPCNotificationSchema.JSONRPCRequestSchema.JSONRPCResponseSchema.JSONRPCResultResponseSchema.JSONValueSchema.LegacyTitledEnumSchemaSchema.ListPromptsRequestSchema.ListPromptsResultSchema.ListResourcesRequestSchema.ListResourcesResultSchema.ListResourceTemplatesRequestSchema.ListResourceTemplatesResultSchema.ListRootsRequestSchema.ListRootsResultSchema.ListTasksRequestSchema.ListTasksResultSchema.ListToolsRequestSchema.ListToolsResultSchema.LoggingLevelSchema.LoggingMessageNotificationSchema.LoggingMessageNotificationParamsSchema.ModelHintSchema.ModelPreferencesSchema.MultiSelectEnumSchemaSchema.NotificationSchema.NumberSchemaSchema.PaginatedRequestSchema.PaginatedRequestParamsSchema.PaginatedResultSchema.PingRequestSchema.PrimitiveSchemaDefinitionSchema.ProgressSchema.ProgressNotificationSchema.ProgressNotificationParamsSchema.ProgressTokenSchema.PromptSchema.PromptArgumentSchema.PromptListChangedNotificationSchema.PromptMessageSchema.PromptReferenceSchema.ReadResourceRequestSchema.ReadResourceRequestParamsSchema.ReadResourceResultSchema.RelatedTaskMetadataSchema.RequestSchema.RequestIdSchema.RequestMetaSchema.ResourceSchema.ResourceContentsSchema.ResourceLinkSchema.ResourceListChangedNotificationSchema.ResourceRequestParamsSchema.ResourceTemplateSchema.ResourceTemplateReferenceSchema.ResourceUpdatedNotificationSchema.ResourceUpdatedNotificationParamsSchema.ResultMetaObjectSchema.ResultSchema.RoleSchema.RootSchema.RootsListChangedNotificationSchema.SamplingContentSchema.SamplingMessageSchema.SamplingMessageContentBlockSchema.ServerCapabilitiesSchema.ServerNotificationSchema.ServerRequestSchema.ServerResultSchema.SetLevelRequestSchema.SetLevelRequestParamsSchema.SingleSelectEnumSchemaSchema.StringSchemaSchema.SubscribeRequestSchema.SubscribeRequestParamsSchema.SubscriptionFilterSchema.SubscriptionsAcknowledgedNotificationSchema.SubscriptionsAcknowledgedNotificationParamsSchema.SubscriptionsListenRequestSchema.SubscriptionsListenRequestParamsSchema.SubscriptionsListenResultSchema.SubscriptionsListenResultMetaSchema.TaskAugmentedRequestParamsSchema.TaskCreationParamsSchema.TaskMetadataSchema.TaskSchema.TaskStatusSchema.TaskStatusNotificationSchema.TaskStatusNotificationParamsSchema.TextContentSchema.TextResourceContentsSchema.TitledMultiSelectEnumSchemaSchema.TitledSingleSelectEnumSchemaSchema.ToolSchema.ToolAnnotationsSchema.ToolChoiceSchema.ToolExecutionSchema.ToolListChangedNotificationSchema.ToolResultContentSchema.ToolUseContentSchema.UnsubscribeRequestSchema.UnsubscribeRequestParamsSchema.UntitledMultiSelectEnumSchemaSchema.UntitledSingleSelectEnumSchemaSchema`.split(`.`),Jo={IdJagTokenExchangeResponseSchema:Ur,OAuthClientInformationFullSchema:Jr,OAuthClientInformationSchema:qr,OAuthClientMetadataSchema:Kr,OAuthClientRegistrationErrorSchema:Yr,OAuthErrorResponseSchema:Wr,OAuthMetadataSchema:zr,OAuthProtectedResourceMetadataSchema:Rr,OAuthTokenRevocationRequestSchema:Xr,OAuthTokensSchema:Hr,OpenIdProviderDiscoveryMetadataSchema:Vr,OpenIdProviderMetadataSchema:Br},Yo={},Xo={};function Zo(e,t){let n=e.slice(0,-6);Yo[n]=t,Xo[n]=e=>t.safeParse(e).success}for(let e of qo)Zo(e,La[e]);for(let[e,t]of Object.entries(Jo))Zo(e,t);Object.freeze(Yo);var Qo=Object.freeze(Xo);function $o(e){switch(e){case`initialize`:case`notifications/initialized`:return ja(void 0);case`server/discover`:return ja(Aa);default:return}}var es=[Fe,Ie,Re,Be],ts=[`inputResponses`,`requestState`];function ns(e,t){let n=e.params;if(!ss(n))return{message:e,lifted:{}};let r=n._meta,i=ss(r)?es.filter(e=>e in r):[],a=t===`request`?ts.filter(e=>e in n):[];if(i.length===0&&a.length===0)return{message:e,lifted:{}};let o={},s={...n};if(i.length>0&&ss(r)){let e={},t={...r};for(let n of i)e[n]=r[n],delete t[n];o.envelope=e,Object.keys(t).length>0?s._meta=t:delete s._meta}for(let e of a)e===`inputResponses`&&(o.inputResponses=s[e]),e===`requestState`&&(o.requestState=s[e]),delete s[e];return{message:{...e,params:s},lifted:o}}function rs(e,t){let n=e.validateResult(t,void 0);if(n.ok||n.reason!==`not-in-era`)return{"~standard":{version:1,vendor:`mcp-wire-codec`,validate(n){let r=e.validateResult(t,n);return r.ok?{value:r.value}:{issues:[{message:r.reason===`invalid`?r.message:`not-in-era: ${t}`}]}}}}}function is(e){return()=>e}var as=is(void 0),os=class{_transport;_requestMessageId=0;_requestHandlers=new Map;_customSchemaRequestMethods=new Set;_requestHandlerAbortControllers=new Map;_notificationHandlers=new Map;_responseHandlers=new Map;_progressHandlers=new Map;_timeoutInfo=new Map;_pendingDebouncedNotifications=new Set;_negotiatedProtocolVersion;_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(e){this._options=e,this._supportedProtocolVersions=e?.supportedProtocolVersions??Ne,this.setNotificationHandler(`notifications/cancelled`,e=>{this._oncancel(e)}),this.setNotificationHandler(`notifications/progress`,e=>{this._onprogress(e)}),this.setRequestHandler(`ping`,e=>({}))}_shouldDropInbound(e){}_outboundMetaEnvelope(){}_envelopeOutbound(e){let t=this._outboundMetaEnvelope();if(t===void 0)return e;let n=e.params??{};return{...e,params:{...n,_meta:{...t,...n._meta}}}}_resolveNonCompleteResult(e,t){return Promise.reject(new Y(J.UnsupportedResultType,`Unsupported result type '${e.kind}' for ${t.request.method}`,{resultType:e.kind,method:t.request.method}))}_getRequestHandler(e){return this._requestHandlers.get(e)}async _oncancel(e){e.params.requestId!==void 0&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,n,r,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),new Y(J.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{try{t?.()}finally{this._onclose()}};let n=this.transport?.onerror;this._transport.onerror=e=>{n?.(e),this._onerror(e)};let r=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{r?.(e,t),Ba(e)||Va(e)?this._onresponse(e):Ra(e)?this._onrequest(e,t):za(e)?this._onnotification(e,t):this._onerror(Error(`Unknown message type: ${JSON.stringify(e)}`))},e.setSupportedProtocolVersions?.(this._supportedProtocolVersions),await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear();for(let e of this._timeoutInfo.values())clearTimeout(e.timeoutId);this._timeoutInfo.clear();let t=this._requestHandlerAbortControllers;this._requestHandlerAbortControllers=new Map;let n=new Y(J.ConnectionClosed,`Connection closed`);this._transport=void 0;try{this.onclose?.()}finally{for(let t of e.values())t(n);for(let e of t.values())e.abort(n)}}_onerror(e){this.onerror?.(e)}_onnotification(e,t){let{message:n}=ns(e,`notification`),r=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)===`drop`)return;if(t?.classification!==void 0){let e=Ma(t.classification);if(e!==r.era){this._onerror(Error(`Era mismatch on inbound notification '${n.method}': classified as ${e} but this instance serves ${r.era}`));return}}if(Pa(n.method)&&!r.hasNotificationMethod(n.method))return;let i=this._notificationHandlers.get(n.method),a=this.fallbackNotificationHandler;(i!==void 0||a!==void 0)&&Promise.resolve().then(()=>i===void 0?a(n):i(n,r)).catch(e=>this._onerror(Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){let{message:n,lifted:r}=ns(e,`request`),i=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)===`drop`){this._onerror(Error(`Dropped inbound request '${e.method}': not servable on this connection's protocol era`));return}let a=this._transport,o=(e,t,r)=>{let i={jsonrpc:`2.0`,id:n.id,error:{code:e,message:t,...r!==void 0&&{data:r}}};a?.send(i).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)))};if(t?.classification!==void 0){let e=Ma(t.classification);if(e!==i.era){this._onerror(Error(`Era mismatch on inbound request '${n.method}': classified as ${e} but this instance serves ${i.era}`));let r=t.classification.revision??e;o(X.UnsupportedProtocolVersion,`Unsupported protocol version: ${r}`,{supported:this._supportedProtocolVersions,requested:r});return}}if(Na(n.method)&&!i.hasRequestMethod(n.method)&&!(Fa(n.method)&&this._customSchemaRequestMethods.has(n.method))){o(X.MethodNotFound,`Method not found`);return}let s=this._requestHandlers.get(n.method)??this.fallbackRequestHandler;if(s===void 0){o(X.MethodNotFound,`Method not found`);return}let c=i.checkInboundEnvelope(r);if(c!==void 0){o(X.InvalidParams,c);return}let l=(e,t)=>this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,{...t,relatedRequestId:n.id}),u=(e,t,r)=>this._requestWithSchemaViaCodec(this._resolveOutboundCodec(e.method),e,t,{...r,relatedRequestId:n.id}),d=new AbortController;this._requestHandlerAbortControllers.set(n.id,d);let f=r.inputResponses===void 0?void 0:us(r.inputResponses),p={sessionId:a?.sessionId,mcpReq:{id:n.id,method:n.method,_meta:n.params?._meta,...r.envelope!==void 0&&{envelope:r.envelope},...f!==void 0&&{inputResponses:f.accepted},...f!==void 0&&f.droppedKeys.length>0&&{droppedInputResponseKeys:f.droppedKeys},requestState:r.requestState===void 0?as:is(r.requestState),signal:d.signal,send:((e,t,n)=>{let r=this._resolveOutboundCodec(e.method);if(this._assertOutboundRequestInEra(r,e.method),po(t))return u(e,t,n);let i=rs(r,e.method);if(i===void 0)throw TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);return u(e,i,t)}),notify:l},http:t?.authInfo?{authInfo:t.authInfo}:void 0},m=this.buildContext(p,t);Promise.resolve().then(()=>s(n,m)).then(async e=>{if(d.signal.aborted)return;let t;try{t=i.encodeResult(n.method,e,this._outboundServerInfo())}catch(e){this._onerror(Error(`Failed to encode result for ${n.method}: ${e}`)),o(X.InternalError,`Internal error`);return}let r={result:t,jsonrpc:`2.0`,id:n.id};await a?.send(r)},async e=>{if(d.signal.aborted)return;let t=Number.isSafeInteger(e.code)?e.code:X.InternalError,r={jsonrpc:`2.0`,id:n.id,error:{code:i.encodeErrorCode(t),message:e.message??`Internal error`,...e.data!==void 0&&{data:e.data}}};await a?.send(r)}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.get(n.id)===d&&this._requestHandlerAbortControllers.delete(n.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,r=Number(t),i=this._progressHandlers.get(r);if(!i){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(r),o=this._timeoutInfo.get(r);if(o&&a&&o.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(e){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),a(e);return}i(n)}_onresponse(e){let t=Number(e.id),n=this._responseHandlers.get(t);if(n===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t),this._progressHandlers.delete(t),Ba(e)?n(e):n(Z.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}request(e,t,n){let r=this._resolveOutboundCodec(e.method);if(po(t))return Fa(e.method)||this._assertOutboundRequestInEra(r,e.method),this._requestWithSchemaViaCodec(r,e,t,n);this._assertOutboundRequestInEra(r,e.method);let i=rs(r,e.method);if(i===void 0)throw TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to request().`);return this._requestWithSchemaViaCodec(r,e,i,t)}_negotiatedWireCodec(){return ja(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(e){if(this._negotiatedProtocolVersion===void 0){let t=$o(e);if(t)return t}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(e,t){if(Na(t)&&!e.hasRequestMethod(t))throw new Y(J.MethodNotSupportedByProtocolVersion,`Method '${t}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t,era:e.era})}_requestWithSchema(e,t,n){let r=this._resolveOutboundCodec(e.method);return this._assertOutboundRequestInEra(r,e.method),this._requestWithSchemaViaCodec(r,e,t,n)}_requestWithSchemaViaCodec(e,t,n,r){let{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o,headers:s}=r??{},c=Date.now(),l,u;return new Promise((d,f)=>{let p=e=>{f(e)};if(!this._transport){p(Error(`Not connected`));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method)}catch(e){p(e);return}if(r?.signal?.aborted){let e=r.signal.reason;throw e instanceof Y?e:new Y(J.RequestTimeout,String(e))}let m=e.era===`2026-07-28`&&this._transport.hasPerRequestStream===!0?new AbortController:void 0,h=this._requestMessageId++;u=h;let g={...t,jsonrpc:`2.0`,id:h};r?.onprogress&&(this._progressHandlers.set(h,r.onprogress),g.params={...t.params,_meta:{...t.params?._meta,progressToken:h}});let _=this._envelopeOutbound(g),v=!1,y=e=>{v||(this._progressHandlers.delete(h),m===void 0?t.method!==`initialize`&&this._transport?.send(this._envelopeOutbound({jsonrpc:`2.0`,method:`notifications/cancelled`,params:{requestId:h,reason:String(e)}}),{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))):m.abort(),f(e instanceof Y?e:new Y(J.RequestTimeout,String(e))))};this._responseHandlers.set(h,i=>{if(r?.signal?.aborted)return;if(v=!0,i instanceof Error)return f(i);let a;try{a=e.decodeResult(t.method,i.result)}catch(e){return f(e instanceof Error?e:Error(String(e)))}if(a.kind===`invalid`)return f(a.error);if(a.kind===`input_required`){if(r?.allowInputRequired===!0)return d(gs(a));let i={codec:e,request:t,resultSchema:n,options:r,flowStartedAt:c,retry:(r,i)=>this._requestWithSchemaViaCodec(e,r===void 0?{method:t.method}:{method:t.method,params:r},n,i)};return d(this._resolveNonCompleteResult(a,i))}let o=a.result;yo(n,o).then(e=>{e.success?d(e.data):f(new Y(J.InvalidResult,`Invalid result for ${t.method}: ${e.error}`))},f)}),l=()=>y(r?.signal?.reason),r?.signal?.addEventListener(`abort`,l,{once:!0});let b=r?.timeout??6e4;this._setupTimeout(h,b,r?.maxTotalTimeout,()=>y(new Y(J.RequestTimeout,`Request timed out`,{timeout:b})),r?.resetTimeoutOnProgress??!1),this._transport.send(_,{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o,headers:s,requestSignal:m?.signal}).catch(e=>{this._progressHandlers.delete(h),f(e)})}).finally(()=>{l&&r?.signal?.removeEventListener(`abort`,l),u!==void 0&&(this._responseHandlers.delete(u),this._cleanupTimeout(u))})}async notification(e,t){return await this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,t)}async _notificationViaCodec(e,t,n){if(!this._transport)throw new Y(J.NotConnected,`Not connected`);if(Pa(t.method)&&!e.hasNotificationMethod(t.method))throw new Y(J.MethodNotSupportedByProtocolVersion,`Notification '${t.method}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t.method,era:e.era});this.assertNotificationCapability(t.method);let r=this._envelopeOutbound({jsonrpc:`2.0`,...t});if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&n?.relatedRequestId===void 0){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{this._pendingDebouncedNotifications.delete(t.method),this._transport&&this._transport?.send(r,n).catch(e=>this._onerror(e))});return}await this._transport.send(r,n)}setRequestHandler(e,t,n){this.assertRequestHandlerCapability(e);let r;if(typeof t==`function`){if(!Na(e))throw TypeError(`'${e}' is not a spec request method; pass schemas as the second argument to setRequestHandler().`);r=(n,r)=>{let i=this._negotiatedWireCodec(),a=i.validateRequest(e,n);if(!a.ok&&a.reason===`not-in-era`&&(a=i.validateInputRequest(e,n)),!a.ok)throw a.reason===`not-in-era`?new Z(X.InternalError,`No wire schema for ${e} in the resolved era`):Error(a.message);return Promise.resolve(t(a.value,r))}}else if(n)r=async(r,i)=>{let a=await yo(t.params,{...r.params});if(!a.success)throw new Z(X.InvalidParams,`Invalid params for ${e}: ${a.error}`);return n(a.data,i)};else throw TypeError(`setRequestHandler: handler is required`);typeof t==`function`?this._customSchemaRequestMethods.delete(e):this._customSchemaRequestMethods.add(e),this._requestHandlers.set(e,this._wrapHandler(e,r))}_wrapHandler(e,t){return t}_outboundServerInfo(){}removeRequestHandler(e){this._requestHandlers.delete(e),this._customSchemaRequestMethods.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t,n){if(typeof t==`function`){if(!Pa(e))throw TypeError(`'${e}' is not a spec notification method; pass schemas as the second argument to setNotificationHandler().`);this._notificationHandlers.set(e,(n,r)=>{let i=r.validateNotification(e,n);if(!i.ok)throw i.reason===`not-in-era`?new Z(X.InternalError,`No wire schema for ${e} in the resolved era`):Error(i.message);return Promise.resolve(t(i.value))});return}if(!n)throw TypeError(`setNotificationHandler: handler is required`);this._notificationHandlers.set(e,async r=>{let i=await yo(t.params,{...r.params});if(!i.success)throw new Z(X.InvalidParams,`Invalid params for notification ${e}: ${i.error}`);await n(i.data,r)})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function ss(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function cs(e,t){let n={...e};for(let e in t){let r=e,i=t[r];if(i===void 0)continue;let a=n[r];n[r]=ss(a)&&ss(i)?{...a,...i}:i}return n}function ls(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function us(e){let t={},n=[];if(!ls(e))return{accepted:t,droppedKeys:n};for(let[r,i]of Object.entries(e)){if(!ls(i)||`method`in i||`result`in i){n.push(r);continue}t[r]=i}return{accepted:t,droppedKeys:n}}function ds(e){throw new Y(J.SendFailed,`ctx.mcpReq.${e} is not available while fulfilling an embedded input request: the request is fulfilled locally and has no related peer request`)}function fs(e,t,n,r,i){return{sessionId:i,mcpReq:{id:e,method:t,_meta:n?._meta,requestState:is(void 0),signal:r,send:(()=>ds(`send`)),notify:()=>ds(`notify`)}}}async function ps(e,t,n,r,i){if(!ls(r)||typeof r.method!=`string`)throw new Y(J.InvalidResult,`Invalid input request '${n}': each inputRequests entry must be an embedded request object with a method`,{key:n});let a=r.method;if(!t.hasInputRequestMethod(a))throw new Y(J.InvalidResult,`Invalid input request '${n}': '${a}' is not an embedded request the ${t.era} revision defines (expected elicitation/create, sampling/createMessage, or roots/list)`,{key:n,method:a});let o=e.getRequestHandler(a);if(o===void 0)throw new Y(J.CapabilityNotSupported,`Cannot fulfil input request '${n}': no handler is registered for '${a}' on this client. Declare the corresponding capability and register a handler, or handle input_required results manually.`,{key:n,method:a});let s=ls(r.params)?r.params:void 0;return await o({jsonrpc:`2.0`,id:n,method:a,...s!==void 0&&{params:s}},e.buildContext(fs(n,a,s,i,e.sessionId)))}function ms(e,t){return{...e?.signal!==void 0&&{signal:e.signal},...e?.onprogress!==void 0&&{onprogress:e.onprogress},...e?.resetTimeoutOnProgress!==void 0&&{resetTimeoutOnProgress:e.resetTimeoutOnProgress},...e?.headers!==void 0&&{headers:e.headers},...t.timeout!==void 0&&{timeout:t.timeout},...t.maxTotalTimeout!==void 0&&{maxTotalTimeout:t.maxTotalTimeout},allowInputRequired:!0}}function hs(e,t,n,r){let{codec:i,request:a,options:o,flowStartedAt:s}=r,c={inputRequests:n.inputRequests,...n.requestState!==void 0&&{requestState:n.requestState}},l={dispatchInputRequest:(t,n,r)=>ps(e,i,t,n,r),retry:(e,t)=>r.retry(e,ms(o,t))};return Ko({config:t,method:a.method,originalParams:a.params,firstPayload:c,flowStartedAt:s,signal:o?.signal,requestOptions:{...o?.timeout!==void 0&&{timeout:o.timeout},...o?.maxTotalTimeout!==void 0&&{maxTotalTimeout:o.maxTotalTimeout},...o?.onprogress!==void 0&&{onprogress:o.onprogress}},hooks:l})}function gs(e){return{resultType:`input_required`,inputRequests:e.inputRequests,...e.requestState!==void 0&&{requestState:e.requestState},...e._meta!==void 0&&{_meta:e._meta}}}var _s=Te(Se((e=>{var t=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,n=/\\([\u000b\u0020-\u00ff])/g,r=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;e.parse=i;function i(e){if(!e)throw TypeError(`argument string is required`);var i=typeof e==`object`?a(e):e;if(typeof i!=`string`)throw TypeError(`argument string is required to be a string`);var s=i.indexOf(`;`),c=s===-1?i.trim():i.slice(0,s).trim();if(!r.test(c))throw TypeError(`invalid media type`);var l=new o(c.toLowerCase());if(s!==-1){var u,d,f;for(t.lastIndex=s;d=t.exec(i);){if(d.index!==s)throw TypeError(`invalid parameter format`);s+=d[0].length,u=d[1].toLowerCase(),f=d[2],f.charCodeAt(0)===34&&(f=f.slice(1,-1),f.indexOf(`\\`)!==-1&&(f=f.replace(n,`$1`))),l.parameters[u]=f}if(s!==i.length)throw TypeError(`invalid parameter format`)}return l}function a(e){var t;if(typeof e.getHeader==`function`?t=e.getHeader(`content-type`):typeof e.headers==`object`&&(t=e.headers&&e.headers[`content-type`]),typeof t!=`string`)throw TypeError(`content-type header is missing from object`);return t}function o(e){this.parameters=Object.create(null),this.type=e}}))(),1);function vs(e){if(e)try{return _s.parse(e).type}catch{let t=(e.split(`;`,1)[0]??``).trim().toLowerCase();return t===``||e.slice(t.length).includes(`,`)?void 0:t}}function ys(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function bs(e=fetch,t){return t?async(n,r)=>e(n,{...t,...r,headers:r?.headers?{...ys(t.headers),...ys(r.headers)}:t.headers}):e}var xs=new Set([301,302,303,307,308]),Ss=5;function Cs(e,t){return e.protocol===t.protocol&&e.host===t.host||e.protocol===`http:`&&t.protocol===`https:`&&e.hostname===t.hostname&&!e.port&&!t.port}function ws(e,t){let n=xs.has(t.status)?t.headers?.get(`location`):void 0;if(n)try{return new URL(n,e)}catch{return}}var Ts=new WeakSet;function Es(e){let t=(t,n)=>e(t,n);return Ts.add(t),t}function Ds(e){return Ts.has(e)?e:async(t,n)=>{if(n?.redirect===`error`||n?.redirect===`manual`)return e(t,n);let r=(n?.method??`GET`).toUpperCase(),i=t;for(let t=0;;t++){let a=await e(i,{...n,redirect:`manual`}),o=ws(i,a);if(!o||t===Ss)return a;let s=new URL(i),c=r===`GET`||a.status===307||a.status===308,l=!(o.username||o.password)||o.username===s.username&&o.password===s.password;if(!c||!l||!Cs(s,o))return a;await a.text?.().catch(()=>{}),i=o}}}function Os(e,t){if(t.type===`opaqueredirect`)return`Redirect not followed: this runtime does not expose where it points`;let n=ws(t.url||e,t);if(n)return n.username=n.password=n.search=n.hash=``,n.protocol===`http:`&&new URL(t.url||e).protocol===`https:`?(n.protocol=`https:`,`Redirect from https to plain http not followed; try ${n.href} as the endpoint`):`Redirect to ${n.href} not followed; use that URL as the endpoint if it is the intended server`}function ks(e,t){let n=typeof e;if(n!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let n=e.length;if(n!==t.length)return!1;for(let r=0;r1?t[a.href]=e:(a.hash=``,r===``?n=a:Is(e,t,n))}}else if(e!==!0&&e!==!1)return t;let i=n.href+(r?`#`+r:``);if(t[i]!==void 0)throw Error(`Duplicate schema URI "${i}".`);if(t[i]=e,e===!0||e===!1)return t;if(e.__absolute_uri__===void 0&&Object.defineProperty(e,"__absolute_uri__",{enumerable:!1,value:i}),e.$ref&&e.__absolute_ref__===void 0){let t=new URL(e.$ref,n.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_ref__",{enumerable:!1,value:t.href})}if(e.$recursiveRef&&e.__absolute_recursive_ref__===void 0){let t=new URL(e.$recursiveRef,n.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_recursive_ref__",{enumerable:!1,value:t.href})}if(e.$anchor){let r=new URL(`#`+e.$anchor,n.href);t[r.href]=e}for(let i in e){if(Ps[i])continue;let a=`${r}/${As(i)}`,o=e[i];if(Array.isArray(o)){if(Ms[i]){let e=o.length;for(let r=0;r%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,Us=/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,Ws=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,Gs=/^(?:\/(?:[^~/]|~0|~1)*)*$/,Ks=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,qs=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,Js=e=>{if(e[0]===`"`)return!1;let[t,n,...r]=e.split(`@`);return!t||!n||r.length!==0||t.length>64||n.length>253||t[0]===`.`||t.endsWith(`.`)||t.includes(`..`)||!/^[a-z0-9.-]+$/i.test(n)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t)?!1:n.split(`.`).every(e=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(e))},Ys=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,Xs=/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,Zs=e=>e.length>1&&e.length<80&&(/^P\d+([.,]\d+)?W$/.test(e)||/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(e)&&/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(e));function Qs(e){return e.test.bind(e)}var $s={date:tc,time:nc.bind(void 0,!1),"date-time":ic,duration:Zs,uri:sc,"uri-reference":Qs(Vs),"uri-template":Qs(Hs),url:Qs(Us),email:Js,hostname:Qs(Bs),ipv4:Qs(Ys),ipv6:Qs(Xs),regex:lc,uuid:Qs(Ws),"json-pointer":Qs(Gs),"json-pointer-uri-fragment":Qs(Ks),"relative-json-pointer":Qs(qs)};function ec(e){return e%4==0&&(e%100!=0||e%400==0)}function tc(e){let t=e.match(Ls);if(!t)return!1;let n=+t[1],r=+t[2],i=+t[3];return r>=1&&r<=12&&i>=1&&i<=(r==2&&ec(n)?29:Rs[r])}function nc(e,t){let n=t.match(zs);if(!n)return!1;let r=+n[1],i=+n[2],a=+n[3],o=!!n[5];return(r<=23&&i<=59&&a<=59||r==23&&i==59&&a==60)&&(!e||o)}var rc=/t|\s/i;function ic(e){let t=e.split(rc);return t.length==2&&tc(t[0])&&nc(!0,t[1])}var ac=/\/|:/,oc=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function sc(e){return ac.test(e)&&oc.test(e)}var cc=/[^\\]\\Z/;function lc(e){if(cc.test(e))return!1;try{return new RegExp(e,`u`),!0}catch{return!1}}function uc(e){let t=0,n=e.length,r=0,i;for(;r=55296&&i<=56319&&rks(e,t))||F.push({instanceLocation:o,keyword:`enum`,keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(g)}.`}):g.some(t=>e===t)||F.push({instanceLocation:o,keyword:`enum`,keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(g)}.`})),v!==void 0){let t=`${s}/not`;Q(e,v,n,r,i,a,o,t).valid&&F.push({instanceLocation:o,keyword:`not`,keywordLocation:t,error:`Instance matched "not" schema.`})}let xe=[];if(y!==void 0){let t=`${s}/anyOf`,l=F.length,u=!1;for(let s=0;s{let u=Object.create(c),d=Q(e,s,n,r,i,p===!0?a:null,o,`${t}/${l}`,u);return F.push(...d.errors),d.valid&&xe.push(u),d.valid}).length;u===1?F.length=l:F.splice(l,0,{instanceLocation:o,keyword:`oneOf`,keywordLocation:t,error:`Instance does not match exactly one subschema (${u} matches).`})}if((u===`object`||u===`array`)&&Object.assign(c,...xe),S!==void 0){let t=`${s}/if`;if(Q(e,S,n,r,i,a,o,t,c).valid){if(C!==void 0){let l=Q(e,C,n,r,i,a,o,`${s}/then`,c);l.valid||F.push({instanceLocation:o,keyword:`if`,keywordLocation:t,error:`Instance does not match "then" schema.`},...l.errors)}}else if(ee!==void 0){let l=Q(e,ee,n,r,i,a,o,`${s}/else`,c);l.valid||F.push({instanceLocation:o,keyword:`if`,keywordLocation:t,error:`Instance does not match "else" schema.`},...l.errors)}}if(u===`object`){if(_!==void 0)for(let t of _)t in e||F.push({instanceLocation:o,keyword:`required`,keywordLocation:`${s}/required`,error:`Instance does not have required property "${t}".`});let t=Object.keys(e);if(ne!==void 0&&t.lengthre&&F.push({instanceLocation:o,keyword:`maxProperties`,keywordLocation:`${s}/maxProperties`,error:`Instance does not have at least ${re} properties.`}),ie!==void 0){let t=`${s}/propertyNames`;for(let s in e){let e=`${o}/${As(s)}`,c=Q(s,ie,n,r,i,a,e,t);c.valid||F.push({instanceLocation:o,keyword:`propertyNames`,keywordLocation:t,error:`Property name "${s}" does not match schema.`},...c.errors)}}if(ae!==void 0){let t=`${s}/dependantRequired`;for(let n in ae)if(n in e){let r=ae[n];for(let i of r)i in e||F.push({instanceLocation:o,keyword:`dependentRequired`,keywordLocation:t,error:`Instance has "${n}" but does not have "${i}".`})}}if(oe!==void 0)for(let t in oe){let l=`${s}/dependentSchemas`;if(t in e){let s=Q(e,oe[t],n,r,i,a,o,`${l}/${As(t)}`,c);s.valid||F.push({instanceLocation:o,keyword:`dependentSchemas`,keywordLocation:l,error:`Instance has "${t}" but does not match dependant schema.`},...s.errors)}}if(se!==void 0){let t=`${s}/dependencies`;for(let s in se)if(s in e){let c=se[s];if(Array.isArray(c))for(let n of c)n in e||F.push({instanceLocation:o,keyword:`dependencies`,keywordLocation:t,error:`Instance has "${s}" but does not have "${n}".`});else{let l=Q(e,c,n,r,i,a,o,`${t}/${As(s)}`);l.valid||F.push({instanceLocation:o,keyword:`dependencies`,keywordLocation:t,error:`Instance has "${s}" but does not match dependant schema.`},...l.errors)}}}let l=Object.create(null),u=!1;if(T!==void 0){let t=`${s}/properties`;for(let s in T){if(!(s in e))continue;let d=`${o}/${As(s)}`,f=Q(e[s],T[s],n,r,i,a,d,`${t}/${As(s)}`);if(f.valid)c[s]=l[s]=!0;else if(u=i,F.push({instanceLocation:o,keyword:`properties`,keywordLocation:t,error:`Property "${s}" does not match schema.`},...f.errors),u)break}}if(!u&&E!==void 0){let t=`${s}/patternProperties`;for(let s in E){let d=new RegExp(s,`u`),f=E[s];for(let p in e){if(!d.test(p))continue;let m=`${o}/${As(p)}`,h=Q(e[p],f,n,r,i,a,m,`${t}/${As(s)}`);h.valid?c[p]=l[p]=!0:(u=i,F.push({instanceLocation:o,keyword:`patternProperties`,keywordLocation:t,error:`Property "${p}" matches pattern "${s}" but does not match associated schema.`},...h.errors))}}}if(!u&&te!==void 0){let t=`${s}/additionalProperties`;for(let s in e){if(l[s])continue;let d=`${o}/${As(s)}`,f=Q(e[s],te,n,r,i,a,d,t);f.valid?c[s]=!0:(u=i,F.push({instanceLocation:o,keyword:`additionalProperties`,keywordLocation:t,error:`Property "${s}" does not match additional properties schema.`},...f.errors))}}else if(!u&&D!==void 0){let t=`${s}/unevaluatedProperties`;for(let s in e)if(!c[s]){let l=`${o}/${As(s)}`,u=Q(e[s],D,n,r,i,a,l,t);u.valid?c[s]=!0:F.push({instanceLocation:o,keyword:`unevaluatedProperties`,keywordLocation:t,error:`Property "${s}" does not match unevaluated properties schema.`},...u.errors)}}}else if(u===`array`){de!==void 0&&e.length>de&&F.push({instanceLocation:o,keyword:`maxItems`,keywordLocation:`${s}/maxItems`,error:`Array has too many items (${e.length} > ${de}).`}),M!==void 0&&e.length=(A||0)&&(F.length=u),A===void 0&&j===void 0&&d===0?F.splice(u,0,{instanceLocation:o,keyword:`contains`,keywordLocation:l,error:`Array does not contain item matching schema.`}):A!==void 0&&dj&&F.push({instanceLocation:o,keyword:`maxContains`,keywordLocation:`${s}/maxContains`,error:`Array may contain at most ${j} items matching schema. ${d} items were found.`})}}if(!u&&ue!==void 0){let u=`${s}/unevaluatedItems`;for(;l=me||e>me)&&F.push({instanceLocation:o,keyword:`maximum`,keywordLocation:`${s}/maximum`,error:`${e} is greater than ${N?`or equal to `:``} ${me}.`})):(pe!==void 0&&eme&&F.push({instanceLocation:o,keyword:`maximum`,keywordLocation:`${s}/maximum`,error:`${e} is greater than ${me}.`}),he!==void 0&&e<=he&&F.push({instanceLocation:o,keyword:`exclusiveMinimum`,keywordLocation:`${s}/exclusiveMinimum`,error:`${e} is less than ${he}.`}),N!==void 0&&e>=N&&F.push({instanceLocation:o,keyword:`exclusiveMaximum`,keywordLocation:`${s}/exclusiveMaximum`,error:`${e} is greater than or equal to ${N}.`})),P!==void 0){let t=e%P;Math.abs(0-t)>=1.1920929e-7&&Math.abs(P-t)>=1.1920929e-7&&F.push({instanceLocation:o,keyword:`multipleOf`,keywordLocation:`${s}/multipleOf`,error:`${e} is not a multiple of ${P}.`})}}else if(u===`string`){let t=ge===void 0&&_e===void 0?0:uc(e);ge!==void 0&&t_e&&F.push({instanceLocation:o,keyword:`maxLength`,keywordLocation:`${s}/maxLength`,error:`String is too long (${t} > ${_e}).`}),ve!==void 0&&!new RegExp(ve,`u`).test(e)&&F.push({instanceLocation:o,keyword:`pattern`,keywordLocation:`${s}/pattern`,error:`String does not match pattern.`}),w!==void 0&&$s[w]&&!$s[w](e)&&F.push({instanceLocation:o,keyword:`format`,keywordLocation:`${s}/format`,error:`String does not match format "${w}".`})}return{valid:F.length===0,errors:F}}var dc=class{schema;draft;shortCircuit;lookup;constructor(e,t=`2019-09`,n=!0){this.schema=e,this.draft=t,this.shortCircuit=n,this.lookup=Is(e)}validate(e){return Q(e,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(e,t){t&&(e={...e,$id:t}),Is(e,this.lookup)}},fc=class{shortcircuit;draft;constructor(e){this.shortcircuit=e?.shortcircuit??!0,this.draft=e?.draft}_draftFor(e){let t=je(e,`pass an explicit { draft } to CfWorkerJsonSchemaValidator to validate other dialects.`);return t===`draft-7`?`7`:t}getValidator(e){let t=new dc(e,this.draft??this._draftFor(e),this.shortcircuit);return e=>{let n=t.validate(e);return n.valid?{valid:!0,data:e,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:n.errors.map(e=>`${e.instanceLocation}: ${e.error}`).join(`; `)}}}},pc=globalThis.crypto;async function mc(e){return(await pc).getRandomValues(new Uint8Array(e))}async function hc(e){let t=``;for(;t.length128)throw`Expected a length between 43 and 128. Received ${e}.`;let t=await gc(e);return{code_verifier:t,code_challenge:await _c(t)}}var yc=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}},bc=10,xc=13,Sc=32;function Cc(e){}function wc(e){if(typeof e==`function`)throw TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{onEvent:t=Cc,onError:n=Cc,onRetry:r=Cc,onComment:i,maxBufferSize:a}=e,o=[],s=0,c=!0,l,u=``,d=0,f,p=!1;function m(e){if(p)throw Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(c&&(c=!1,e.charCodeAt(0)===239&&e.charCodeAt(1)===187&&e.charCodeAt(2)===191&&(e=e.slice(3))),o.length===0){let t=g(e);t!==``&&(o.push(t),s=t.length),h();return}if(e.indexOf(` `)===-1&&e.indexOf(`\r`)===-1){o.push(e),s+=e.length,h();return}o.push(e);let t=o.join(``);o.length=0,s=0;let n=g(t);n!==``&&(o.push(n),s=n.length),h()}function h(){a!==void 0&&(s+u.length<=a||(p=!0,o.length=0,s=0,l=void 0,u=``,d=0,f=void 0,n(new yc(`Buffered data exceeded max buffer size of ${a} characters`,{type:`max-buffer-size-exceeded`}))))}function g(e){let n=0;if(e.indexOf(`\r`)===-1){let r=e.indexOf(` `,n);for(;r!==-1;){if(n===r){d>0&&t({id:l,event:f,data:u}),l=void 0,u=``,d=0,f=void 0,n=r+1,r=e.indexOf(` diff --git a/internal/ui/dist/assets/page-D0-Qm4dK.js b/internal/ui/dist/assets/page-vAmZFsvk.js similarity index 96% rename from internal/ui/dist/assets/page-D0-Qm4dK.js rename to internal/ui/dist/assets/page-vAmZFsvk.js index 01392c51..79a2bbee 100644 --- a/internal/ui/dist/assets/page-D0-Qm4dK.js +++ b/internal/ui/dist/assets/page-vAmZFsvk.js @@ -37,4 +37,4 @@ import{a as e,i as t,o as n,r,s as i}from"./useRouter-ByJ6_rwb.js";import{A as a `:`
`,m=l.join(p);this._showOrMove(a,function(){this._updateContentNotChangedOnAxis(e,s)?this._updatePosition(a,d,i[0],i[1],this._tooltipContent,s):this._showTooltipContent(a,m,s,Math.random()+``,i[0],i[1],d,null,u)})},t.prototype._showSeriesItemTooltip=function(e,t,n){var r=this._ecModel,i=iv(t),a=i.seriesIndex,o=r.getSeriesByIndex(a),s=i.dataModel||o,c=i.dataIndex,l=i.dataType,u=s.getData(l),d=this._renderMode,f=e.positionDefault,p=OJ([u.getItemModel(c),s,o&&(o.coordinateSystem||{}).model],this._tooltipModel,f?{position:f}:null),m=p.get(`trigger`);if(m==null||m===`item`){var h=s.getDataParams(c,l),g=new yE;h.marker=g.makeTooltipMarker(`item`,QC(h.color),d);var _=_T(s.formatTooltip(c,!1,l)),v=p.get(`order`),y=p.get(`valueFormatter`),b=_.frag,x=b?uE(y?W({valueFormatter:y},b):b,g,d,v,r.get(`useUTC`),p.get(`textStyle`)):_.text,S=`item_`+s.name+`_`+c;this._showOrMove(p,function(){this._showTooltipContent(p,x,h,S,e.offsetX,e.offsetY,e.position,e.target,g)}),n({type:`showTip`,dataIndexInside:c,dataIndex:u.getRawIndex(c),seriesIndex:a,from:this.uid})}},t.prototype._showComponentItemTooltip=function(e,t,n){var r=this._renderMode===`html`,i=iv(t),a=i.tooltipConfig.option||{},o=a.encodeHTMLContent;if(Y(a)){var s=a;a={content:s,formatter:s},o=!0}o&&r&&a.content&&(a=hl(a),a.content=WS(a.content));var c=[a],l=this._ecModel.getComponent(i.componentMainType,i.componentIndex);l&&c.push(l),c.push({formatter:a.content});var u=e.positionDefault,d=OJ(c,this._tooltipModel,u?{position:u}:null),f=d.get(`content`),p=Math.random()+``,m=new yE;this._showOrMove(d,function(){var n=hl(d.get(`formatterParams`)||{});this._showTooltipContent(d,f,n,p,e.offsetX,e.offsetY,e.position,t,m)}),n({type:`showTip`,from:this.uid})},t.prototype._showTooltipContent=function(e,t,n,r,i,a,o,s,c){if(this._ticket=``,e.get(`showContent`)&&e.get(`show`)){var l=this._tooltipContent;l.setEnterable(e.get(`enterable`));var u=e.get(`formatter`);o||=e.get(`position`);var d=t,f=this._getNearestPoint([i,a],n,e.get(`trigger`),e.get(`borderColor`),e.get(`defaultBorderColor`,!0)).color;if(u){if(Y(u)){var p=e.ecModel.get(`useUTC`),m=J(n)?n[0]:n,h=m&&m.axisType&&m.axisType.indexOf(`time`)>=0;d=u,h&&(d=EC(m.axisValue,d,p)),d=XC(d,n,!0)}else if(Al(u)){var g=q(function(t,r){t===this._ticket&&(l.setContent(r,c,e,f,o),this._updatePosition(e,o,i,a,l,n,s))},this);this._ticket=r,d=u(n,r,g)}else d=u}l.setContent(d,c,e,f,o),l.show(e,f),this._updatePosition(e,o,i,a,l,n,s)}},t.prototype._getNearestPoint=function(e,t,n,r,i){if(n===`axis`||J(t))return{color:r||i};if(!J(t))return{color:r||t.color||t.borderColor}},t.prototype._updatePosition=function(e,t,n,r,i,a,o){var s=this._api.getWidth(),c=this._api.getHeight();t||=e.get(`position`);var l=i.getSize(),u=e.get(`align`),d=e.get(`verticalAlign`),f=o&&o.getBoundingRect().clone();if(o&&f.applyTransform(o.transform),Al(t)&&(t=t([n,r],a,i.el,f,{viewSize:[s,c],contentSize:l.slice()})),J(t))n=Cu(t[0],s),r=Cu(t[1],c);else if(Nl(t)){var p=t;p.width=l[0],p.height=l[1];var m=pw(p,{width:s,height:c});n=m.x,r=m.y,u=null,d=null}else if(Y(t)&&o){var h=MJ(t,f,l,e.get(`borderWidth`));n=h[0],r=h[1]}else{var h=AJ(n,r,i,s,c,u?null:20,d?null:20);n=h[0],r=h[1]}if(u&&(n-=NJ(u)?l[0]/2:u===`right`?l[0]:0),d&&(r-=NJ(d)?l[1]/2:d===`bottom`?l[1]:0),aJ(e)){var h=jJ(n,r,i,s,c);n=h[0],r=h[1]}i.moveTo(n,r)},t.prototype._updateContentNotChangedOnAxis=function(e,t){var n=this._lastDataByCoordSys,r=this._cbParamsList,i=!!n&&n.length===e.length;return i&&G(n,function(n,a){var o=n.dataByAxis||[],s=(e[a]||{}).dataByAxis||[];i&&=o.length===s.length,i&&G(o,function(e,n){var a=s[n]||{},o=e.seriesDataIndices||[],c=a.seriesDataIndices||[];i=i&&e.value===a.value&&e.axisType===a.axisType&&e.axisId===a.axisId&&o.length===c.length,i&&G(o,function(e,t){var n=c[t];i=i&&e.seriesIndex===n.seriesIndex&&e.dataIndex===n.dataIndex}),r&&G(e.seriesDataIndices,function(e){var n=e.seriesIndex,a=t[n],o=r[n];a&&o&&o.data!==a.data&&(i=!1)})})}),this._lastDataByCoordSys=e,this._cbParamsList=t,!!i},t.prototype._hide=function(e){this._lastDataByCoordSys=null,this._cbParamsList=null,e({type:`hideTip`,from:this.uid})},t.prototype.dispose=function(e,t){!ou.node&&t.getDom()&&(MP(this,`_updatePosition`),this._tooltipContent.dispose(),XG(`itemTooltip`,t),this._tooltipContent=null,this._tooltipModel=null,this._lastDataByCoordSys=null,this._cbParamsList=null)},t.type=`tooltip`,t}(_P);function OJ(e,t,n){var r=t.ecModel,i;n?(i=new TS(n,r,r),i=new TS(t.option,i,r)):i=t;for(var a=e.length-1;a>=0;a--){var o=e[a];o&&(o instanceof TS&&(o=o.get(`tooltip`,!0)),Y(o)&&(o={formatter:o}),o&&(i=new TS(o,i,r)))}return i}function kJ(e,t){return e.dispatchAction||q(t.dispatchAction,t)}function AJ(e,t,n,r,i,a,o){var s=n.getSize(),c=s[0],l=s[1];return a!=null&&(e+c+a+2>r?e-=c+a:e+=a),o!=null&&(t+l+o>i?t-=l+o:t+=o),[e,t]}function jJ(e,t,n,r,i){var a=n.getSize(),o=a[0],s=a[1];return e=Math.min(e+o,r)-o,t=Math.min(t+s,i)-s,e=Math.max(e,0),t=Math.max(t,0),[e,t]}function MJ(e,t,n,r){var i=n[0],a=n[1],o=Math.ceil(Math.SQRT2*r)+8,s=0,c=0,l=t.width,u=t.height;switch(e){case`inside`:s=t.x+l/2-i/2,c=t.y+u/2-a/2;break;case`top`:s=t.x+l/2-i/2,c=t.y-a-o;break;case`bottom`:s=t.x+l/2-i/2,c=t.y+u+o;break;case`left`:s=t.x-i-o,c=t.y+u/2-a/2;break;case`right`:s=t.x+l+o,c=t.y+u/2-a/2}return[s,c]}function NJ(e){return e===`center`||e===`middle`}function PJ(e,t,n){var r=Od(e).queryOptionMap,i=r.keys()[0];if(i&&i!==`series`){var a=jd(t,i,r.get(i),{useDefault:!1,enableAll:!1,enableNone:!1}).models[0];if(a){var o=n.getViewOfComponentModel(a),s;if(o.group.traverse(function(t){var n=iv(t).tooltipConfig;if(n&&n.name===e.name)return s=t,!0}),s)return{componentMainType:i,componentIndex:a.componentIndex,el:s}}}}function FJ(e){aR(dK),e.registerComponentModel(iJ),e.registerComponentView(DJ),e.registerAction({type:`showTip`,event:`showTip`,update:`tooltip:manuallyShowTip`},ru),e.registerAction({type:`hideTip`,event:`hideTip`,update:`tooltip:manuallyHideTip`},ru)}var IJ=[`rect`,`polygon`,`keep`,`clear`];function LJ(e,t){var n=rd(e?e.brush:[]);if(n.length){var r=[];G(n,function(e){var t=e.hasOwnProperty(`toolbox`)?e.toolbox:[];t instanceof Array&&(r=r.concat(t))});var i=e&&e.toolbox;J(i)&&(i=i[0]),i||(i={feature:{}},e.toolbox=[i]);var a=i.feature||(i.feature={}),o=a.brush||={},s=o.type||=[];s.push.apply(s,r),Jd(s,function(e){return e+``},null),t&&!s.length&&s.push.apply(s,IJ)}}var RJ=G;function zJ(e){if(e){for(var t in e)if(e.hasOwnProperty(t))return!0}}function BJ(e,t,n){var r={};return RJ(t,function(t){var a=r[t]=i();RJ(e[t],function(e,r){if(cH.isValidType(r)){var i={type:r,visual:e};n&&n(i,t),a[r]=new cH(i),r===`opacity`&&(i=hl(i),i.type=`colorAlpha`,a.__hidden.__alphaForOpacity=new cH(i))}})}),r;function i(){var e=function(){};return e.prototype.__hidden=e.prototype,new e}}function VJ(e,t,n){var r;G(n,function(e){t.hasOwnProperty(e)&&zJ(t[e])&&(r=!0)}),r&&G(n,function(n){t.hasOwnProperty(n)&&zJ(t[n])?e[n]=hl(t[n]):delete e[n]})}function HJ(e,t,n,r,i,a){var o={};G(e,function(e){o[e]=cH.prepareVisualTypes(t[e])});var s;function c(e){return mF(n,s,e)}function l(e,t){gF(n,s,e,t)}a==null?n.each(u):n.each([a],u);function u(e,u){s=a==null?e:u;var d=n.getRawDataItem(s);if(!(d&&d.visualMap===!1))for(var f=r.call(i,e),p=t[f],m=o[f],h=0,g=m.length;ht[0][1]&&(t[0][1]=a[0]),a[1]t[1][1]&&(t[1][1]=a[1])}return t&&aY(t)}};function aY(e){return new fp(e[0][0],e[1][0],e[0][1]-e[0][0],e[1][1]-e[1][0])}var oY=function(e){U(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n}return t.prototype.init=function(e,t){this.ecModel=e,this.api=t,this.model,(this._brushController=new eU(t.getZr())).on(`brush`,q(this._onBrush,this)).mount()},t.prototype.render=function(e,t,n,r){this.model=e,this._updateController(e,t,n,r)},t.prototype.updateTransform=function(e,t,n,r){ZJ(t),this._updateController(e,t,n,r)},t.prototype.updateVisual=function(e,t,n,r){this.updateTransform(e,t,n,r)},t.prototype.updateView=function(e,t,n,r){this._updateController(e,t,n,r)},t.prototype._updateController=function(e,t,n,r){(!r||r.$from!==e.id)&&this._brushController.setPanels(e.brushTargetManager.makePanelOpts(n)).enableBrush(e.brushOption).updateCovers(e.areas.slice())},t.prototype.dispose=function(){this._brushController.dispose()},t.prototype._onBrush=function(e){var t=this.model.id,n=this.model.brushTargetManager.setOutputRanges(e.areas,this.ecModel);(!e.isEnd||e.removeOnClick)&&this.api.dispatchAction({type:`brush`,brushId:t,areas:hl(n),$from:t}),e.isEnd&&this.api.dispatchAction({type:`brushEnd`,brushId:t,areas:hl(n),$from:t})},t.type=`brush`,t}(_P),sY=function(e){U(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n.areas=[],n.brushOption={},n}return t.prototype.optionUpdated=function(e,t){var n=this.option;!t&&VJ(n,e,[`inBrush`,`outOfBrush`]);var r=n.inBrush=n.inBrush||{};n.outOfBrush=n.outOfBrush||{color:this.option.defaultOutOfBrushColor},r.hasOwnProperty(`liftZ`)||(r.liftZ=5)},t.prototype.setAreas=function(e){e&&(this.areas=K(e,function(e){return cY(this.option,e)},this))},t.prototype.setBrushOption=function(e){this.brushOption=cY(this.option,e),this.brushType=this.brushOption.brushType},t.type=`brush`,t.dependencies=[`geo`,`grid`,`xAxis`,`yAxis`,`parallel`,`series`],t.defaultOption={seriesIndex:`all`,brushType:`rect`,brushMode:`single`,transformable:!0,brushStyle:{borderWidth:1,color:Q.color.backgroundTint,borderColor:Q.color.borderTint},throttleType:`fixRate`,throttleDelay:0,removeOnClick:!0,z:1e4,defaultOutOfBrushColor:Q.color.disabled},t}(Sw);function cY(e,t){return gl({brushType:e.brushType,brushMode:e.brushMode,transformable:e.transformable,brushStyle:new TS(e.brushStyle).getItemStyle(),removeOnClick:e.removeOnClick,z:e.z},t,!0)}var lY=[`rect`,`polygon`,`lineX`,`lineY`,`keep`,`clear`],uY=function(e){U(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.render=function(e,t,n){var r,i,a;t.eachComponent({mainType:`brush`},function(e){r=e.brushType,i=e.brushOption.brushMode||`single`,a||=!!e.areas.length}),this._brushType=r,this._brushMode=i,G(e.get(`type`,!0),function(t){e.setIconStatus(t,(t===`keep`?i===`multiple`:t===`clear`?a:t===r)?`emphasis`:`normal`)})},t.prototype.updateView=function(e,t,n){this.render(e,t,n)},t.prototype.getIcons=function(){var e=this.model,t=e.get(`icon`,!0),n={};return G(e.get(`type`,!0),function(e){t[e]&&(n[e]=t[e])}),n},t.prototype.onclick=function(e,t,n){var r=this._brushType,i=this._brushMode;n===`clear`?(t.dispatchAction({type:`axisAreaSelect`,intervals:[]}),t.dispatchAction({type:`brush`,command:`clear`,areas:[]})):t.dispatchAction({type:`takeGlobalCursor`,key:`brush`,brushOption:{brushType:n===`keep`?r:r!==n&&n,brushMode:n===`keep`?i===`multiple`?`single`:`multiple`:i}})},t.getDefaultOption=function(e){return{show:!0,type:lY.slice(),icon:{rect:`M7.3,34.7 M0.4,10V-0.2h9.8 M89.6,10V-0.2h-9.8 M0.4,60v10.2h9.8 M89.6,60v10.2h-9.8 M12.3,22.4V10.5h13.1 M33.6,10.5h7.8 M49.1,10.5h7.8 M77.5,22.4V10.5h-13 M12.3,31.1v8.2 M77.7,31.1v8.2 M12.3,47.6v11.9h13.1 M33.6,59.5h7.6 M49.1,59.5 h7.7 M77.5,47.6v11.9h-13`,polygon:`M55.2,34.9c1.7,0,3.1,1.4,3.1,3.1s-1.4,3.1-3.1,3.1 s-3.1-1.4-3.1-3.1S53.5,34.9,55.2,34.9z M50.4,51c1.7,0,3.1,1.4,3.1,3.1c0,1.7-1.4,3.1-3.1,3.1c-1.7,0-3.1-1.4-3.1-3.1 C47.3,52.4,48.7,51,50.4,51z M55.6,37.1l1.5-7.8 M60.1,13.5l1.6-8.7l-7.8,4 M59,19l-1,5.3 M24,16.1l6.4,4.9l6.4-3.3 M48.5,11.6 l-5.9,3.1 M19.1,12.8L9.7,5.1l1.1,7.7 M13.4,29.8l1,7.3l6.6,1.6 M11.6,18.4l1,6.1 M32.8,41.9 M26.6,40.4 M27.3,40.2l6.1,1.6 M49.9,52.1l-5.6-7.6l-4.9-1.2`,lineX:`M15.2,30 M19.7,15.6V1.9H29 M34.8,1.9H40.4 M55.3,15.6V1.9H45.9 M19.7,44.4V58.1H29 M34.8,58.1H40.4 M55.3,44.4 V58.1H45.9 M12.5,20.3l-9.4,9.6l9.6,9.8 M3.1,29.9h16.5 M62.5,20.3l9.4,9.6L62.3,39.7 M71.9,29.9H55.4`,lineY:`M38.8,7.7 M52.7,12h13.2v9 M65.9,26.6V32 M52.7,46.3h13.2v-9 M24.9,12H11.8v9 M11.8,26.6V32 M24.9,46.3H11.8v-9 M48.2,5.1l-9.3-9l-9.4,9.2 M38.9-3.9V12 M48.2,53.3l-9.3,9l-9.4-9.2 M38.9,62.3V46.4`,keep:`M4,10.5V1h10.3 M20.7,1h6.1 M33,1h6.1 M55.4,10.5V1H45.2 M4,17.3v6.6 M55.6,17.3v6.6 M4,30.5V40h10.3 M20.7,40 h6.1 M33,40h6.1 M55.4,30.5V40H45.2 M21,18.9h62.9v48.6H21V18.9z`,clear:`M22,14.7l30.9,31 M52.9,14.7L22,45.7 M4.7,16.8V4.2h13.1 M26,4.2h7.8 M41.6,4.2h7.8 M70.3,16.8V4.2H57.2 M4.7,25.9v8.6 M70.3,25.9v8.6 M4.7,43.2v12.6h13.1 M26,55.8h7.8 M41.6,55.8h7.8 M70.3,43.2v12.6H57.2`},title:e.getLocaleModel().get([`toolbox`,`brush`,`title`])}},t}(eq);function dY(e){e.registerComponentView(oY),e.registerComponentModel(sY),e.registerPreprocessor(LJ),e.registerVisual(e.PRIORITY.VISUAL.BRUSH,QJ),e.registerAction({type:`brush`,event:`brush`,update:`updateVisual`},function(e,t){t.eachComponent({mainType:`brush`,query:e},function(t){t.setAreas(e.areas)})}),e.registerAction({type:`brushSelect`,event:`brushSelected`,update:`none`},ru),e.registerAction({type:`brushEnd`,event:`brushEnd`,update:`none`},ru),nq(`brush`,uY)}function fY(e,t){if(!e)return!1;for(var n=J(e)?e:[e],r=0;r=0&&(s[o]=+s[o].toFixed(f)),[s,d]}var yY={min:kl(vY,`min`),max:kl(vY,`max`),average:kl(vY,`average`),median:kl(vY,`median`)};function bY(e,t){if(t){var n=e.getData(),r=e.coordinateSystem,i=r&&r.dimensions;if(!_Y(t)&&!J(t.coord)&&J(i)){var a=xY(t,n,r,e);if(t=hl(t),t.type&&yY[t.type]&&a.baseAxis&&a.valueAxis){var o=bl(i,a.baseAxis.dim),s=bl(i,a.valueAxis.dim),c=yY[t.type](n,a.valueAxis.dim,a.baseDataDim,a.valueDataDim,o,s);t.coord=c[0],t.value=c[1]}else t.coord=[t.xAxis==null?t.radiusAxis:t.xAxis,t.yAxis==null?t.angleAxis:t.yAxis]}if(t.coord==null||!J(i)){t.coord=[];var l=e.getBaseAxis();if(l&&t.type&&yY[t.type]){var u=r.getOtherAxis(l);u&&(t.value=EY(n,n.mapDimension(u.dim),t.type))}}else for(var d=t.coord,f=0;f<2;f++)yY[d[f]]&&(d[f]=EY(n,n.mapDimension(i[f]),d[f]));return t}}function xY(e,t,n,r){var i={};return e.valueIndex!=null||e.valueDim!=null?(i.valueDataDim=e.valueIndex==null?e.valueDim:t.getDimension(e.valueIndex),i.valueAxis=n.getAxis(SY(r,i.valueDataDim)),i.baseAxis=n.getOtherAxis(i.valueAxis),i.baseDataDim=t.mapDimension(i.baseAxis.dim)):(i.baseAxis=r.getBaseAxis(),i.valueAxis=n.getOtherAxis(i.baseAxis),i.baseDataDim=t.mapDimension(i.baseAxis.dim),i.valueDataDim=t.mapDimension(i.valueAxis.dim)),i}function SY(e,t){var n=e.getData().getDimensionInfo(t);return n&&n.coordDim}function CY(e,t){return e&&e.containData&&t.coord&&!gY(t)?e.containData(t.coord):!0}function wY(e,t,n){return e&&e.containZone&&t.coord&&n.coord&&!gY(t)&&!gY(n)?e.containZone(t.coord,n.coord):!0}function TY(e,t){return e?function(e,n,r,i){return xT(i<2?e.coord&&e.coord[i]:e.value,t[i])}:function(e,n,r,i){return xT(e.value,t[i])}}function EY(e,t,n){if(n===`average`){var r=0,i=0;return e.each(t,function(e,t){isNaN(e)||(r+=e,i++)}),r/i}return n===`median`?e.getMedian(t):e.getDataExtent(t)[+(n===`max`)]}var DY=Td(),OY=function(e){U(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n}return t.prototype.init=function(){this.markerGroupMap=$l()},t.prototype.render=function(e,t,n){var r=this,i=this.markerGroupMap;i.each(function(e){DY(e).keep=!1}),t.eachSeries(function(e){var i=hY.getMarkerModelFromSeries(e,r.type);i&&r.renderSeries(e,i,t,n)}),i.each(function(e){!DY(e).keep&&r.group.remove(e.group)}),kY(t,i,this.type)},t.prototype.markKeep=function(e){DY(e).keep=!0},t.prototype.toggleBlurSeries=function(e,t){var n=this;G(e,function(e){var r=hY.getMarkerModelFromSeries(e,n.type);r&&r.getData().eachItemGraphicEl(function(e){e&&(t?Xv(e):Zv(e))})})},t.type=`marker`,t}(_P);function kY(e,t,n){e.eachSeries(function(e){var r=hY.getMarkerModelFromSeries(e,n),i=t.get(e.id);if(r&&i&&i.group){var a=Ux(r),o=a.z,s=a.zlevel;Gx(i.group,o,s)}})}var AY=function(e){U(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n}return t.prototype.createMarkerModelFromSeries=function(e,n,r){return new t(e,n,r)},t.type=`markLine`,t.defaultOption={z:5,symbol:[`circle`,`arrow`],symbolSize:[8,16],symbolOffset:0,precision:2,tooltip:{trigger:`item`},label:{show:!0,position:`end`,distance:5},lineStyle:{type:`dashed`},emphasis:{label:{show:!0},lineStyle:{width:3}},animationEasing:`linear`},t}(hY),jY=Td(),MY=function(e,t,n,r){var i=e.getData(),a;if(J(r))a=r;else{var o=r.type;if(o===`min`||o===`max`||o===`average`||o===`median`||r.xAxis!=null||r.yAxis!=null){var s=void 0,c=void 0;if(r.yAxis!=null||r.xAxis!=null)s=t.getAxis(r.yAxis==null?`x`:`y`),c=Bl(r.yAxis,r.xAxis);else{var l=xY(r,i,t,e);s=l.valueAxis,c=EY(i,WO(i,l.valueDataDim),o)}var u=s.dim===`x`?0:1,d=1-u,f=hl(r),p={coord:[]};f.type=null,f.coord=[],f.coord[d]=-1/0,p.coord[d]=1/0;var m=n.get(`precision`);m>=0&&Ml(c)&&(c=+c.toFixed(Math.min(m,20))),f.coord[u]=p.coord[u]=c,a=[f,p,{type:o,valueIndex:r.valueIndex,value:c}]}else a=[]}var h=[bY(e,a[0]),bY(e,a[1]),W({},a[2])];return h[2].type=h[2].type||null,gl(h[2],h[0]),gl(h[2],h[1]),h};function NY(e){return!isNaN(e)&&!isFinite(e)}function PY(e,t,n,r){var i=1-e,a=r.dimensions[e];return NY(t[i])&&NY(n[i])&&t[e]===n[e]&&r.getAxis(a).containData(t[e])}function FY(e,t){if(e.type===`cartesian2d`){var n=t[0].coord,r=t[1].coord;if(n&&r&&(PY(1,n,r,e)||PY(0,n,r,e)))return!0}return CY(e,t[0])&&CY(e,t[1])}function IY(e,t,n,r,i){var a=r.coordinateSystem,o=e.getItemModel(t),s,c=Cu(o.get(`x`),i.getWidth()),l=Cu(o.get(`y`),i.getHeight());if(!isNaN(c)&&!isNaN(l))s=[c,l];else{if(r.getMarkerPosition)s=r.getMarkerPosition(e.getValues(e.dimensions,t));else{var u=a.dimensions,d=e.get(u[0],t),f=e.get(u[1],t);s=a.dataToPoint([d,f])}if(rB(a,`cartesian2d`)){var p=a.getAxis(`x`),m=a.getAxis(`y`),u=a.dimensions;NY(e.get(u[0],t))?s[0]=p.toGlobalCoord(p.getExtent()[+!n]):NY(e.get(u[1],t))&&(s[1]=m.toGlobalCoord(m.getExtent()[+!n]))}isNaN(c)||(s[0]=c),isNaN(l)||(s[1]=l)}e.setItemLayout(t,s)}var LY=function(e){U(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n}return t.prototype.updateTransform=function(e,t,n){t.eachSeries(function(e){var t=hY.getMarkerModelFromSeries(e,`markLine`);if(t){var r=t.getData(),i=jY(t).from,a=jY(t).to;i.each(function(t){IY(i,t,!0,e,n),IY(a,t,!1,e,n)}),r.each(function(e){r.setItemLayout(e,[i.getItemLayout(e),a.getItemLayout(e)])}),this.markerGroupMap.get(e.id).updateLayout()}},this)},t.prototype.renderSeries=function(e,t,n,r){var i=e.coordinateSystem,a=e.id,o=e.getData(),s=this.markerGroupMap,c=s.get(a)||s.set(a,new PH);this.group.add(c.group);var l=RY(i,e,t),u=l.from,d=l.to,f=l.line;jY(t).from=u,jY(t).to=d,t.setData(f);var p=t.get(`symbol`),m=t.get(`symbolSize`),h=t.get(`symbolRotate`),g=t.get(`symbolOffset`);J(p)||(p=[p,p]),J(m)||(m=[m,m]),J(h)||(h=[h,h]),J(g)||(g=[g,g]),l.from.each(function(e){_(u,e,!0),_(d,e,!1)}),f.each(function(e){var t=f.getItemModel(e),n=t.getModel(`lineStyle`).getLineStyle();f.setItemLayout(e,[u.getItemLayout(e),d.getItemLayout(e)]);var r=t.get(`z2`);n.stroke??=u.getItemVisual(e,`style`).fill,f.setItemVisual(e,{z2:X(r,0),fromSymbolKeepAspect:u.getItemVisual(e,`symbolKeepAspect`),fromSymbolOffset:u.getItemVisual(e,`symbolOffset`),fromSymbolRotate:u.getItemVisual(e,`symbolRotate`),fromSymbolSize:u.getItemVisual(e,`symbolSize`),fromSymbol:u.getItemVisual(e,`symbol`),toSymbolKeepAspect:d.getItemVisual(e,`symbolKeepAspect`),toSymbolOffset:d.getItemVisual(e,`symbolOffset`),toSymbolRotate:d.getItemVisual(e,`symbolRotate`),toSymbolSize:d.getItemVisual(e,`symbolSize`),toSymbol:d.getItemVisual(e,`symbol`),style:n})}),c.updateData(f),l.line.eachItemGraphicEl(function(e){iv(e).dataModel=t,e.traverse(function(e){iv(e).dataModel=t})});function _(t,n,i){var a=t.getItemModel(n);IY(t,n,i,e,r);var s=a.getModel(`itemStyle`).getItemStyle();s.fill??=hF(o,`color`),t.setItemVisual(n,{symbolKeepAspect:a.get(`symbolKeepAspect`),symbolOffset:X(a.get(`symbolOffset`,!0),g[+!i]),symbolRotate:X(a.get(`symbolRotate`,!0),h[+!i]),symbolSize:X(a.get(`symbolSize`),m[+!i]),symbol:X(a.get(`symbol`,!0),p[+!i]),style:s})}this.markKeep(c),c.group.silent=t.get(`silent`)||e.get(`silent`)},t.type=`markLine`,t}(OY);function RY(e,t,n){var r=e?K(e&&e.dimensions,function(e){var n=t.getData();return W(W({},n.getDimensionInfo(n.mapDimension(e))||{}),{name:e,ordinalMeta:null})}):[{name:`value`,type:`float`}],i=new ER(r,n),a=new ER(r,n),o=new ER([],n),s=K(n.get(`data`),kl(MY,t,e,n));e&&(s=Tl(s,kl(FY,e)));var c=TY(!!e,r);return i.initData(K(s,function(e){return e[0]}),null,c),a.initData(K(s,function(e){return e[1]}),null,c),o.initData(K(s,function(e){return e[2]})),o.hasItemOption=!0,{from:i,to:a,line:o}}function zY(e){e.registerComponentModel(AY),e.registerComponentView(LY),e.registerPreprocessor(function(e){fY(e.series,`markLine`)&&(e.markLine=e.markLine||{})})}var BY=function(e){U(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n}return t.prototype.createMarkerModelFromSeries=function(e,n,r){return new t(e,n,r)},t.type=`markArea`,t.defaultOption={z:1,tooltip:{trigger:`item`},animation:!1,label:{show:!0,position:`top`},itemStyle:{borderWidth:0},emphasis:{label:{show:!0,position:`top`}}},t}(hY),VY=Td(),HY=function(e,t,n,r){var i=r[0],a=r[1];if(i&&a){var o=bY(e,i),s=bY(e,a),c=o.coord,l=s.coord;c[0]=Bl(c[0],-1/0),c[1]=Bl(c[1],-1/0),l[0]=Bl(l[0],1/0),l[1]=Bl(l[1],1/0);var u=_l([{},o,s]);return u.coord=[o.coord,s.coord],u.x0=o.x,u.y0=o.y,u.x1=s.x,u.y1=s.y,u}};function UY(e){return!isNaN(e)&&!isFinite(e)}function WY(e,t,n,r){var i=1-e;return UY(t[i])&&UY(n[i])}function GY(e,t){var n=t.coord[0],r=t.coord[1],i={coord:n,x:t.x0,y:t.y0},a={coord:r,x:t.x1,y:t.y1};return rB(e,`cartesian2d`)?n&&r&&(WY(1,n,r,e)||WY(0,n,r,e))?!0:wY(e,i,a):CY(e,i)||CY(e,a)}function KY(e,t,n,r,i){var a=r.coordinateSystem,o=e.getItemModel(t),s,c=Cu(o.get(n[0]),i.getWidth()),l=Cu(o.get(n[1]),i.getHeight());if(!isNaN(c)&&!isNaN(l))s=[c,l];else{if(r.getMarkerPosition){var u=e.getValues([`x0`,`y0`],t),d=e.getValues([`x1`,`y1`],t),f=a.clampData(u),p=a.clampData(d),m=[];m[0]=n[0]===`x0`?f[0]>p[0]?d[0]:u[0]:f[0]>p[0]?u[0]:d[0],m[1]=n[1]===`y0`?f[1]>p[1]?d[1]:u[1]:f[1]>p[1]?u[1]:d[1],s=r.getMarkerPosition(m,n,!0)}else{var h=e.get(n[0],t),g=e.get(n[1],t),_=[h,g];a.clampData&&a.clampData(_,_),s=a.dataToPoint(_,!0)}if(rB(a,`cartesian2d`)){var v=a.getAxis(`x`),y=a.getAxis(`y`),h=e.get(n[0],t),g=e.get(n[1],t);UY(h)?s[0]=v.toGlobalCoord(v.getExtent()[n[0]===`x0`?0:1]):UY(g)&&(s[1]=y.toGlobalCoord(y.getExtent()[n[1]===`y0`?0:1]))}isNaN(c)||(s[0]=c),isNaN(l)||(s[1]=l)}return s}var qY=[[`x0`,`y0`],[`x1`,`y0`],[`x1`,`y1`],[`x0`,`y1`]],JY=function(e){U(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n}return t.prototype.updateTransform=function(e,t,n){t.eachSeries(function(e){var t=hY.getMarkerModelFromSeries(e,`markArea`);if(t){var r=t.getData();r.each(function(t){var i=K(qY,function(i){return KY(r,t,i,e,n)});r.setItemLayout(t,i),r.getItemGraphicEl(t).setShape(`points`,i)})}},this)},t.prototype.renderSeries=function(e,t,n,r){var i=e.coordinateSystem,a=e.id,o=e.getData(),s=this.markerGroupMap,c=s.get(a)||s.set(a,{group:new Ky});this.group.add(c.group),this.markKeep(c);var l=YY(i,e,t);t.setData(l),l.each(function(t){var n=K(qY,function(n){return KY(l,t,n,e,r)}),a=i.getAxis(`x`).scale,s=i.getAxis(`y`).scale,c=a.getExtent(),u=s.getExtent(),d=[a.parse(l.get(`x0`,t)),a.parse(l.get(`x1`,t))],f=[s.parse(l.get(`y0`,t)),s.parse(l.get(`y1`,t))];Ou(d),Ou(f);var p=c[0]>d[1]||c[1]f[1]||u[1]=0},t.prototype.getOrient=function(){return this.get(`orient`)===`vertical`?{index:1,name:`vertical`}:{index:0,name:`horizontal`}},t.type=`legend.plain`,t.dependencies=[`series`],t.defaultOption={z:4,show:!0,orient:`horizontal`,left:`center`,bottom:Q.size.m,align:`auto`,backgroundColor:Q.color.transparent,borderColor:Q.color.border,borderRadius:0,borderWidth:0,padding:5,itemGap:8,itemWidth:25,itemHeight:14,symbolRotate:`inherit`,symbolKeepAspect:!0,inactiveColor:Q.color.disabled,inactiveBorderColor:Q.color.disabled,inactiveBorderWidth:`auto`,itemStyle:{color:`inherit`,opacity:`inherit`,borderColor:`inherit`,borderWidth:`auto`,borderCap:`inherit`,borderJoin:`inherit`,borderDashOffset:`inherit`,borderMiterLimit:`inherit`},lineStyle:{width:`auto`,color:`inherit`,inactiveColor:Q.color.disabled,inactiveWidth:2,opacity:`inherit`,type:`inherit`,cap:`inherit`,join:`inherit`,dashOffset:`inherit`,miterLimit:`inherit`},textStyle:{color:Q.color.secondary},selectedMode:!0,selector:!1,selectorLabel:{show:!0,borderRadius:10,padding:[3,5,3,5],fontSize:12,fontFamily:`sans-serif`,color:Q.color.tertiary,borderWidth:1,borderColor:Q.color.border},emphasis:{selectorLabel:{show:!0,color:Q.color.quaternary}},selectorPosition:`auto`,selectorItemGap:7,selectorButtonGap:10,tooltip:{show:!1},triggerEvent:!1},t}(Sw),$Y=kl,eX=G,tX=Ky,nX=function(e){U(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n.newlineDisabled=!1,n}return t.prototype.init=function(){this.group.add(this._contentGroup=new tX),this.group.add(this._selectorGroup=new tX),this._isFirstRender=!0},t.prototype.getContentGroup=function(){return this._contentGroup},t.prototype.getSelectorGroup=function(){return this._selectorGroup},t.prototype.render=function(e,t,n){var r=this._isFirstRender;if(this._isFirstRender=!1,this.resetInner(),e.get(`show`,!0)){var i=e.get(`align`),a=e.get(`orient`);(!i||i===`auto`)&&(i=e.get(`left`)===`right`&&a===`vertical`?`right`:`left`);var o=e.get(`selector`,!0),s=e.get(`selectorPosition`,!0);o&&(!s||s===`auto`)&&(s=a===`horizontal`?`end`:`start`),this.renderInner(i,e,t,n,o,a,s);var c=hw(e,n).refContainer,l=e.getBoxLayoutParams(),u=e.get(`padding`),d=pw(l,c,u),f=this.layoutInner(e,i,d,r,o,s),p=pw(yl({width:f.width,height:f.height},l),c,u);this.group.x=p.x-f.x,this.group.y=p.y-f.y,this.group.markRedraw(),this.group.add(this._backgroundEl=aq(f,e))}},t.prototype.resetInner=function(){this.getContentGroup().removeAll(),this._backgroundEl&&this.group.remove(this._backgroundEl),this.getSelectorGroup().removeAll()},t.prototype.renderInner=function(e,t,n,r,i,a,o){var s=this.getContentGroup(),c=$l(),l=t.get(`selectedMode`),u=t.get(`triggerEvent`),d=[];n.eachRawSeries(function(e){!e.get(`legendHoverLink`)&&d.push(e.id)}),eX(t.getData(),function(i,a){var o=this,f=i.get(`name`);if(!this.newlineDisabled&&(f===``||f===` `)){var p=new tX;p.newline=!0,s.add(p);return}var m=n.getSeriesByName(f)[0];if(!c.get(f)){if(m){var h=m.getData(),g=h.getVisual(`legendLineStyle`)||{},_=h.getVisual(`legendIcon`),v=h.getVisual(`style`),y=this._createItem(m,f,a,i,t,e,g,v,_,l,r);y.on(`click`,$Y(aX,f,null,r,d)).on(`mouseover`,$Y(oX,m.name,null,r,d)).on(`mouseout`,$Y(sX,m.name,null,r,d)),n.ssr&&y.eachChild(function(e){var t=iv(e);t.seriesIndex=m.seriesIndex,t.dataIndex=a,t.ssrType=`legend`}),u&&y.eachChild(function(e){o.packEventData(e,t,m,a,f)}),c.set(f,!0)}else n.eachRawSeries(function(o){var s=this;if(!c.get(f)&&o.legendVisualProvider){var p=o.legendVisualProvider;if(!p.containName(f))return;var m=p.indexOfName(f),h=p.getItemVisual(m,`style`),g=p.getItemVisual(m,`legendIcon`),_=oh(h.fill);_&&_[3]===0&&(_[3]=.2,h=W(W({},h),{fill:mh(_,`rgba`)}));var v=this._createItem(o,f,a,i,t,e,{},h,g,l,r);v.on(`click`,$Y(aX,null,f,r,d)).on(`mouseover`,$Y(oX,null,f,r,d)).on(`mouseout`,$Y(sX,null,f,r,d)),n.ssr&&v.eachChild(function(e){var t=iv(e);t.seriesIndex=o.seriesIndex,t.dataIndex=a,t.ssrType=`legend`}),u&&v.eachChild(function(e){s.packEventData(e,t,o,a,f)}),c.set(f,!0)}},this)}},this),i&&this._createSelector(i,t,r,a,o)},t.prototype.packEventData=function(e,t,n,r,i){var a={componentType:`legend`,componentIndex:t.componentIndex,dataIndex:r,value:i,seriesIndex:n.seriesIndex};iv(e).eventData=a},t.prototype._createSelector=function(e,t,n,r,i){var a=this.getSelectorGroup();eX(e,function(e){var r=e.type,i=new W_({style:{x:0,y:0,align:`center`,verticalAlign:`middle`},onclick:function(){n.dispatchAction({type:r===`all`?`legendAllSelect`:`legendInverseSelect`,legendId:t.id})}});a.add(i),eS(i,{normal:t.getModel(`selectorLabel`),emphasis:t.getModel([`emphasis`,`selectorLabel`])},{defaultText:e.title}),dy(i)})},t.prototype._createItem=function(e,t,n,r,i,a,o,s,c,l,u){var d=e.visualDrawType,f=i.get(`itemWidth`),p=i.get(`itemHeight`),m=i.isSelected(t),h=r.get(`symbolRotate`),g=r.get(`symbolKeepAspect`),_=r.get(`icon`);c=_||c||`roundRect`;var v=rX(c,r,o,s,d,m,u),y=new tX,b=r.getModel(`textStyle`);if(Al(e.getLegendIcon)&&(!_||_===`inherit`))y.add(e.getLegendIcon({itemWidth:f,itemHeight:p,icon:c,iconRotate:h,itemStyle:v.itemStyle,lineStyle:v.lineStyle,symbolKeepAspect:g}));else{var x=_===`inherit`&&e.getData().getVisual(`symbol`)?h===`inherit`?e.getData().getVisual(`symbolRotate`):h:0;y.add(iX({itemWidth:f,itemHeight:p,icon:c,iconRotate:x,itemStyle:v.itemStyle,lineStyle:v.lineStyle,symbolKeepAspect:g}))}var S=a===`left`?f+5:-5,C=a,w=i.get(`formatter`),T=t;Y(w)&&w?T=w.replace(`{name}`,t??``):Al(w)&&(T=w(t));var E=m?b.getTextColor():r.get(`inactiveColor`);y.add(new W_({style:nS(b,{text:T,x:S,y:p/2,fill:E,align:C,verticalAlign:`middle`},{inheritColor:E})}));var D=new z_({shape:y.getBoundingRect(),style:{fill:`transparent`}}),O=r.getModel(`tooltip`);return O.get(`show`)&&Ix({el:D,componentModel:i,itemName:t,itemTooltipOption:O.option}),y.add(D),y.eachChild(function(e){e.silent=!0}),D.silent=!l,this.getContentGroup().add(y),dy(y),y.__legendDataIndex=n,y},t.prototype.layoutInner=function(e,t,n,r,i,a){var o=this.getContentGroup(),s=this.getSelectorGroup();dw(e.get(`orient`),o,e.get(`itemGap`),n.width,n.height);var c=o.getBoundingRect(),l=[-c.x,-c.y];if(s.markRedraw(),o.markRedraw(),i){dw(`horizontal`,s,e.get(`selectorItemGap`,!0));var u=s.getBoundingRect(),d=[-u.x,-u.y],f=e.get(`selectorButtonGap`,!0),p=e.getOrient().index,m=p===0?`width`:`height`,h=p===0?`height`:`width`,g=p===0?`y`:`x`;a===`end`?d[p]+=c[m]+f:l[p]+=u[m]+f,d[1-p]+=c[h]/2-u[h]/2,s.x=d[0],s.y=d[1],o.x=l[0],o.y=l[1];var _={x:0,y:0};return _[m]=c[m]+f+u[m],_[h]=Math.max(c[h],u[h]),_[g]=Math.min(0,u[g]+d[1-p]),_}return o.x=l[0],o.y=l[1],this.group.getBoundingRect()},t.prototype.remove=function(){this.getContentGroup().removeAll(),this._isFirstRender=!0},t.type=`legend.plain`,t}(_P);function rX(e,t,n,r,i,a,o){function s(e,t){e.lineWidth===`auto`&&(e.lineWidth=t.lineWidth>0?2:0),eX(e,function(n,r){e[r]===`inherit`&&(e[r]=t[r])})}var c=t.getModel(`itemStyle`),l=c.getItemStyle(),u=e.lastIndexOf(`empty`,0)===0?`fill`:`stroke`,d=c.getShallow(`decal`);l.decal=!d||d===`inherit`?r.decal:gI(d,o),l.fill===`inherit`&&(l.fill=r[i]),l.stroke===`inherit`&&(l.stroke=r[u]),l.opacity===`inherit`&&(l.opacity=(i===`fill`?r:n).opacity),s(l,r);var f=t.getModel(`lineStyle`),p=f.getLineStyle();if(s(p,n),l.fill===`auto`&&(l.fill=r.fill),l.stroke===`auto`&&(l.stroke=r.fill),p.stroke===`auto`&&(p.stroke=r.fill),!a){var m=t.get(`inactiveBorderWidth`),h=l[u];l.lineWidth=m===`auto`?r.lineWidth>0&&h?2:0:l.lineWidth,l.fill=t.get(`inactiveColor`),l.stroke=t.get(`inactiveBorderColor`),p.stroke=f.get(`inactiveColor`),p.lineWidth=f.get(`inactiveWidth`)}return{itemStyle:l,lineStyle:p}}function iX(e){var t=e.icon||`roundRect`,n=TA(t,0,0,e.itemWidth,e.itemHeight,e.itemStyle.fill,e.symbolKeepAspect);return n.setStyle(e.itemStyle),n.rotation=(e.iconRotate||0)*Math.PI/180,n.setOrigin([e.itemWidth/2,e.itemHeight/2]),t.indexOf(`empty`)>-1&&(n.style.stroke=n.style.fill,n.style.fill=Q.color.neutral00,n.style.lineWidth=2),n}function aX(e,t,n,r){sX(e,t,n,r),n.dispatchAction({type:`legendToggleSelect`,name:e??t}),oX(e,t,n,r)}function oX(e,t,n,r){n.usingTHL()||n.dispatchAction({type:`highlight`,seriesName:e,name:t,excludeSeriesId:r})}function sX(e,t,n,r){n.usingTHL()||n.dispatchAction({type:`downplay`,seriesName:e,name:t,excludeSeriesId:r})}function cX(e,t,n){var r=e===`allSelect`||e===`inverseSelect`,i={},a=[];n.eachComponent({mainType:`legend`,query:t},function(n){r?n[e]():n[e](t.name),lX(n,i),a.push(n.componentIndex)});var o={};return n.eachComponent(`legend`,function(e){G(i,function(t,n){e[t?`select`:`unSelect`](n)}),lX(e,o)}),r?{selected:o,legendIndex:a}:{name:t.name,selected:o}}function lX(e,t){var n=t||{};return G(e.getData(),function(t){var r=t.get(`name`);if(r!==` `&&r!==``){var i=e.isSelected(r);n[r]=Z(n,r)?n[r]&&i:i}}),n}function uX(e){e.registerAction(`legendToggleSelect`,`legendselectchanged`,kl(cX,`toggleSelected`)),e.registerAction(`legendAllSelect`,`legendselectall`,kl(cX,`allSelect`)),e.registerAction(`legendInverseSelect`,`legendinverseselect`,kl(cX,`inverseSelect`)),e.registerAction(`legendSelect`,`legendselected`,kl(cX,`select`)),e.registerAction(`legendUnSelect`,`legendunselected`,kl(cX,`unSelect`))}var dX=$d(fX);function fX(e){var t=e.findComponents({mainType:`legend`});t&&t.length&&e.filterSeries(function(e){for(var n=0;nn[i],m=[-d.x,-d.y];t||(m[r]=c[s]);var h=[0,0],g=[-f.x,-f.y],_=X(e.get(`pageButtonGap`,!0),e.get(`itemGap`,!0));p&&(e.get(`pageButtonPosition`,!0)===`end`?g[r]+=n[i]-f[i]:h[r]+=f[i]+_),g[1-r]+=d[a]/2-f[a]/2,c.setPosition(m),l.setPosition(h),u.setPosition(g);var v={x:0,y:0};if(v[i]=p?n[i]:d[i],v[a]=Math.max(d[a],f[a]),v[o]=Math.min(0,f[o]+g[1-r]),l.__rectSize=n[i],p){var y={x:0,y:0};y[i]=Math.max(n[i]-f[i]-_,0),y[a]=v[a],l.setClipPath(new z_({shape:y})),l.__rectSize=y[i]}else u.eachChild(function(e){e.attr({invisible:!0,silent:!0})});var b=this._getPageInfo(e);return b.pageIndex!=null&&Yb(c,{x:b.contentPosition[0],y:b.contentPosition[1]},p?e:null),this._updatePageInfoView(e,b),v},t.prototype._pageGo=function(e,t,n){var r=this._getPageInfo(t)[e];r!=null&&n.dispatchAction({type:`legendScroll`,scrollDataIndex:r,legendId:t.id})},t.prototype._updatePageInfoView=function(e,t){var n=this._controllerGroup;G([`pagePrev`,`pageNext`],function(r){var i=t[r+`DataIndex`]!=null,a=n.childOfName(r);a&&(a.setStyle(`fill`,i?e.get(`pageIconColor`,!0):e.get(`pageIconInactiveColor`,!0)),a.cursor=i?`pointer`:`default`)});var r=n.childOfName(`pageText`),i=e.get(`pageFormatter`),a=t.pageIndex,o=a==null?0:a+1,s=t.pageCount;r&&i&&r.setStyle(`text`,Y(i)?i.replace(`{current}`,o==null?``:o+``).replace(`{total}`,s==null?``:s+``):i({current:o,total:s}))},t.prototype._getPageInfo=function(e){var t=e.get(`scrollDataIndex`,!0),n=this.getContentGroup(),r=this._containerGroup.__rectSize,i=e.getOrient().index,a=_X[i],o=vX[i],s=this._findTargetItemIndex(t),c=n.children(),l=c[s],u=c.length,d=+!!u,f={contentPosition:[n.x,n.y],pageCount:d,pageIndex:d-1,pagePrevDataIndex:null,pageNextDataIndex:null};if(!l)return f;var p=v(l);f.contentPosition[i]=-p.s;for(var m=s+1,h=p,g=p,_=null;m<=u;++m)_=v(c[m]),(!_&&g.e>h.s+r||_&&!y(_,h.s))&&(h=g.i>h.i?g:_,h&&(f.pageNextDataIndex??=h.i,++f.pageCount)),g=_;for(var m=s-1,h=p,g=p,_=null;m>=-1;--m)_=v(c[m]),(!_||!y(g,_.s))&&h.i=t&&e.s<=t+r}},t.prototype._findTargetItemIndex=function(e){if(!this._showController)return 0;var t,n=this.getContentGroup(),r;return n.eachChild(function(n,i){var a=n.__legendDataIndex;r==null&&a!=null&&(r=i),a===e&&(t=i)}),t??r},t.type=`legend.scroll`,t}(nX);function bX(e){e.registerAction(`legendScroll`,`legendscroll`,function(e,t){var n=e.scrollDataIndex;n!=null&&t.eachComponent({mainType:`legend`,subType:`scroll`,query:e},function(e){e.setScrollDataIndex(n)})})}function xX(e){aR(pX),e.registerComponentModel(mX),e.registerComponentView(yX),bX(e)}function SX(e){aR(pX),aR(xX)}var CX=function(e){U(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n}return t.type=`dataZoom.inside`,t.defaultOption=AS(UK.defaultOption,{disabled:!1,zoomLock:!1,zoomOnMouseWheel:!0,moveOnMouseMove:!0,moveOnMouseWheel:!1,preventDefaultMouseMove:!0}),t}(UK),wX=Td();function TX(e,t,n){wX(e).coordSysRecordMap.each(function(e){var r=e.dataZoomInfoMap.get(t.uid);r&&(r.getRange=n)})}function EX(e,t){for(var n=wX(e).coordSysRecordMap,r=n.keys(),i=0;ia[i+r]&&(r=n),o&&=t.get(`preventDefaultMouseMove`,!0),s=X(t.get(`cursorGrab`,!0),s),c=X(t.get(`cursorGrabbing`,!0),c)}),{controlType:r,opt:{zoomOnMouseWheel:!0,moveOnMouseMove:!0,moveOnMouseWheel:!0,preventDefaultMouseMove:!!o,api:n,zInfo:{component:t.model},triggerInfo:{roamTrigger:null,isInSelf:t.containsPoint},cursorGrab:s,cursorGrabbing:c}}}function MX(e){e.registerUpdateLifecycle(`coordsys:aftercreate`,function(e,t){var n=wX(t),r=n.coordSysRecordMap||=$l();r.each(function(e){e.dataZoomInfoMap=null}),e.eachComponent({mainType:`dataZoom`,subType:`inside`},function(e){G(LK(e).infoList,function(n){var i=n.model.uid,a=r.get(i)||r.set(i,OX(t,n.model));(a.dataZoomInfoMap||=$l()).set(e.uid,{dzReferCoordSysInfo:n,model:e,getRange:null})})}),r.each(function(e){var n=e.controller,i,a=e.dataZoomInfoMap;if(a){var o=a.keys()[0];o!=null&&(i=a.get(o))}if(!i){DX(r,e);return}var s=jX(a,e,t);n.enable(s.controlType,s.opt),jP(e,`dispatchAction`,i.model.get(`throttle`,!0),`fixRate`)})})}var NX=function(e){U(t,e);function t(){var t=e!==null&&e.apply(this,arguments)||this;return t.type=`dataZoom.inside`,t}return t.prototype.render=function(t,n,r){if(e.prototype.render.apply(this,arguments),t.noTarget()){this._clear();return}this.range=t.getPercentRange(),TX(r,t,{pan:q(PX.pan,this),zoom:q(PX.zoom,this),scrollMove:q(PX.scrollMove,this)})},t.prototype.dispose=function(){this._clear(),e.prototype.dispose.apply(this,arguments)},t.prototype._clear=function(){EX(this.api,this.dataZoomModel),this.range=null},t.type=`dataZoom.inside`,t}(KK),PX={zoom:function(e,t,n,r){var i=this.range,a=i.slice(),o=e.axisModels[0];if(o){var s=IX[t](null,[r.originX,r.originY],o,n,e),c=(s.signal>0?s.pixelStart+s.pixelLength-s.pixel:s.pixel-s.pixelStart)/s.pixelLength*(a[1]-a[0])+a[0],l=Math.max(1/r.scale,0);a[0]=(a[0]-c)*l+c,a[1]=(a[1]-c)*l+c;var u=this.dataZoomModel.findRepresentativeAxisProxy().getMinMaxSpan();if(zH(0,a,[0,100],0,u.minSpan,u.maxSpan),this.range=a,i[0]!==a[0]||i[1]!==a[1])return a}},pan:FX(function(e,t,n,r,i,a){var o=IX[r]([a.oldX,a.oldY],[a.newX,a.newY],t,i,n);return o.signal*(e[1]-e[0])*o.pixel/o.pixelLength}),scrollMove:FX(function(e,t,n,r,i,a){return IX[r]([0,0],[a.scrollDelta,a.scrollDelta],t,i,n).signal*(e[1]-e[0])*a.scrollDelta})};function FX(e){return function(t,n,r,i){var a=this.range,o=a.slice(),s=t.axisModels[0];if(s&&(zH(e(o,s,t,n,r,i),o,[0,100],`all`),this.range=o,a[0]!==o[0]||a[1]!==o[1]))return o}}var IX={grid:function(e,t,n,r,i){var a=n.axis,o={},s=i.model.coordinateSystem.getRect();return e||=[0,0],a.dim===`x`?(o.pixel=t[0]-e[0],o.pixelLength=s.width,o.pixelStart=s.x,o.signal=a.inverse?1:-1):(o.pixel=t[1]-e[1],o.pixelLength=s.height,o.pixelStart=s.y,o.signal=a.inverse?-1:1),o},polar:function(e,t,n,r,i){var a=n.axis,o={},s=i.model.coordinateSystem,c=s.getRadiusAxis().getExtent(),l=s.getAngleAxis().getExtent();return e=e?s.pointToCoord(e):[0,0],t=s.pointToCoord(t),n.mainType===`radiusAxis`?(o.pixel=t[0]-e[0],o.pixelLength=c[1]-c[0],o.pixelStart=c[0],o.signal=a.inverse?1:-1):(o.pixel=t[1]-e[1],o.pixelLength=l[1]-l[0],o.pixelStart=l[0],o.signal=a.inverse?-1:1),o},singleAxis:function(e,t,n,r,i){var a=n.axis,o=i.model.coordinateSystem.getRect(),s={};return e||=[0,0],a.orient===`horizontal`?(s.pixel=t[0]-e[0],s.pixelLength=o.width,s.pixelStart=o.x,s.signal=a.inverse?1:-1):(s.pixel=t[1]-e[1],s.pixelLength=o.height,s.pixelStart=o.y,s.signal=a.inverse?-1:1),s}};function LX(e){QK(e),e.registerComponentModel(CX),e.registerComponentView(NX),MX(e)}var RX=function(e){U(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n}return t.type=`dataZoom.slider`,t.layoutMode=`box`,t.defaultOption=AS(UK.defaultOption,{show:!0,right:`ph`,top:`ph`,width:`ph`,height:`ph`,left:null,bottom:null,borderColor:Q.color.accent10,borderRadius:0,backgroundColor:Q.color.transparent,dataBackground:{lineStyle:{color:Q.color.accent30,width:.5},areaStyle:{color:Q.color.accent20,opacity:.2}},selectedDataBackground:{lineStyle:{color:Q.color.accent40,width:.5},areaStyle:{color:Q.color.accent20,opacity:.3}},fillerColor:`rgba(135,175,274,0.2)`,handleIcon:`path://M-9.35,34.56V42m0-40V9.5m-2,0h4a2,2,0,0,1,2,2v21a2,2,0,0,1-2,2h-4a2,2,0,0,1-2-2v-21A2,2,0,0,1-11.35,9.5Z`,handleSize:`100%`,handleStyle:{color:Q.color.neutral00,borderColor:Q.color.accent20},moveHandleSize:7,moveHandleIcon:`path://M-320.9-50L-320.9-50c18.1,0,27.1,9,27.1,27.1V85.7c0,18.1-9,27.1-27.1,27.1l0,0c-18.1,0-27.1-9-27.1-27.1V-22.9C-348-41-339-50-320.9-50z M-212.3-50L-212.3-50c18.1,0,27.1,9,27.1,27.1V85.7c0,18.1-9,27.1-27.1,27.1l0,0c-18.1,0-27.1-9-27.1-27.1V-22.9C-239.4-41-230.4-50-212.3-50z M-103.7-50L-103.7-50c18.1,0,27.1,9,27.1,27.1V85.7c0,18.1-9,27.1-27.1,27.1l0,0c-18.1,0-27.1-9-27.1-27.1V-22.9C-130.9-41-121.8-50-103.7-50z`,moveHandleStyle:{color:Q.color.accent40,opacity:.5},showDetail:!0,showDataShadow:`auto`,realtime:!0,zoomLock:!1,textStyle:{color:Q.color.tertiary},brushSelect:!0,brushStyle:{color:Q.color.accent30,opacity:.3},emphasis:{handleLabel:{show:!0},handleStyle:{borderColor:Q.color.accent40},moveHandleStyle:{opacity:.8}},defaultLocationEdgeGap:15}),t}(UK),zX=z_,BX=1,VX=30,HX=7,UX=`horizontal`,WX=`vertical`,GX=5,KX=[`line`,`bar`,`candlestick`,`scatter`],qX={easing:`cubicOut`,duration:100,delay:0},JX=function(e){U(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n._displayables={},n}return t.prototype.init=function(e,t){this.api=t,this._onBrush=q(this._onBrush,this),this._onBrushEnd=q(this._onBrushEnd,this)},t.prototype.render=function(t,n,r,i){if(e.prototype.render.apply(this,arguments),jP(this,`_dispatchZoomAction`,t.get(`throttle`),`fixRate`),this._orient=t.getOrient(),t.get(`show`)===!1){this.group.removeAll();return}if(t.noTarget()){this._clear(),this.group.removeAll();return}(!i||i.type!==`dataZoom`||i.from!==this.uid)&&this._buildView(),this._updateView()},t.prototype.dispose=function(){this._clear(),e.prototype.dispose.apply(this,arguments)},t.prototype._clear=function(){MP(this,`_dispatchZoomAction`);var e=this.api.getZr();e.off(`mousemove`,this._onBrush),e.off(`mouseup`,this._onBrushEnd)},t.prototype._buildView=function(){var e=this.group;e.removeAll(),this._brushing=!1,this._displayables.brushRect=null,this._resetLocation(),this._resetInterval();var t=this._displayables.sliderGroup=new Ky;this._renderBackground(),this._renderHandle(),this._renderDataShadow(),e.add(t),this._positionGroup()},t.prototype._resetLocation=function(){var e=this.dataZoomModel,t=this.api,n=e.get(`brushSelect`)?HX:0,r=hw(e,t).refContainer,i=this._findCoordRect(),a=e.get(`defaultLocationEdgeGap`,!0)||0,o=this._orient===UX?{right:r.width-i.x-i.width,top:r.height-VX-a-n,width:i.width,height:VX}:{right:a,top:i.y,width:VX,height:i.height},s=yw(e.option);G([`right`,`top`,`width`,`height`],function(e){s[e]===`ph`&&(s[e]=o[e])});var c=pw(s,r);this._location={x:c.x,y:c.y},this._size=[c.width,c.height],this._orient===WX&&this._size.reverse()},t.prototype._positionGroup=function(){var e=this.group,t=this._location,n=this._orient,r=this.dataZoomModel.getFirstTargetAxisModel(),i=r&&r.get(`inverse`),a=this._displayables.sliderGroup,o=(this._dataShadowInfo||{}).otherAxisInverse;a.attr(n===UX&&!i?{scaleY:o?1:-1,scaleX:1}:n===UX&&i?{scaleY:o?1:-1,scaleX:-1}:n===WX&&!i?{scaleY:o?-1:1,scaleX:1,rotation:Math.PI/2}:{scaleY:o?-1:1,scaleX:-1,rotation:Math.PI/2});var s=e.getBoundingRect([a]),c=isNaN(s.x)?0:s.x,l=isNaN(s.y)?0:s.y;e.x=t.x-c,e.y=t.y-l,e.markRedraw()},t.prototype._getViewExtent=function(){return[0,this._size[0]]},t.prototype._renderBackground=function(){var e=this.dataZoomModel,t=this._size,n=this._displayables.sliderGroup,r=e.get(`brushSelect`);n.add(new zX({silent:!0,shape:{x:0,y:0,width:t[0],height:t[1]},style:{fill:e.get(`backgroundColor`)},z2:-40}));var i=new zX({shape:{x:0,y:0,width:t[0],height:t[1]},style:{fill:`transparent`},z2:0,onclick:q(this._onClickPanel,this)}),a=this.api.getZr();r?(i.on(`mousedown`,this._onBrushStart,this),i.cursor=`crosshair`,a.on(`mousemove`,this._onBrush),a.on(`mouseup`,this._onBrushEnd)):(a.off(`mousemove`,this._onBrush),a.off(`mouseup`,this._onBrushEnd)),n.add(i)},t.prototype._renderDataShadow=function(){var e=this._dataShadowInfo=this._prepareDataShadowInfo();if(this._displayables.dataShadowSegs=[],!e)return;var t=this._size,n=this._shadowSize||[],r=e.series,i=r.getRawData(),a=r.getShadowDim&&r.getShadowDim(),o=a&&i.getDimensionInfo(a)?r.getShadowDim():e.otherDim;if(o==null)return;var s=this._shadowPolygonPts,c=this._shadowPolylinePts;if(i!==this._shadowData||o!==this._shadowDim||t[0]!==n[0]||t[1]!==n[1]){var l=i.getDataExtent(e.thisDim),u=i.getDataExtent(o),d=(u[1]-u[0])*.3;u=[u[0]-d,u[1]+d];var f=[0,t[1]],p=[0,t[0]],m=[[t[0],0],[0,0]],h=[],g=p[1]/Math.max(1,i.count()-1),_=t[0]/(l[1]-l[0]),v=e.thisAxis.type===`time`,y=-g,b=Math.round(i.count()/t[0]),x;i.each([e.thisDim,o],function(e,t,n){if(b>0&&n%b){v||(y+=g);return}y=v?(+e-l[0])*_:y+g;var r=t==null||isNaN(t)||t===``,i=r?0:Su(t,u,f,!0);r&&!x&&n?(m.push([m[m.length-1][0],0]),h.push([h[h.length-1][0],0])):!r&&x&&(m.push([y,0]),h.push([y,0])),r||(m.push([y,i]),h.push([y,i])),x=r}),s=this._shadowPolygonPts=m,c=this._shadowPolylinePts=h}this._shadowData=i,this._shadowDim=o,this._shadowSize=[t[0],t[1]];var S=this.dataZoomModel;function C(e){var t=S.getModel(e?`selectedDataBackground`:`dataBackground`),n=new Ky,r=new yb({shape:{points:s},segmentIgnoreThreshold:1,style:t.getModel(`areaStyle`).getAreaStyle(),silent:!0,z2:-20}),i=new xb({shape:{points:c},segmentIgnoreThreshold:1,style:t.getModel(`lineStyle`).getLineStyle(),silent:!0,z2:-19});return n.add(r),n.add(i),n}for(var w=0;w<3;w++){var T=C(w===1);this._displayables.sliderGroup.add(T),this._displayables.dataShadowSegs.push(T)}},t.prototype._prepareDataShadowInfo=function(){var e=this.dataZoomModel,t=e.get(`showDataShadow`);if(t!==!1){var n,r=this.ecModel;return e.eachTargetAxis(function(i,a){G(e.getAxisProxy(i,a).getTargetSeriesModels(),function(e){if(!n&&!(t!==!0&&bl(KX,e.get(`type`))<0)){var o=r.getComponent(FK(i),a).axis,s=XX(i),c,l=e.coordinateSystem;s!=null&&l.getOtherAxis&&(c=l.getOtherAxis(o).inverse),s=e.getData().mapDimension(s),n={thisAxis:o,series:e,thisDim:e.getData().mapDimension(i),otherDim:s,otherAxisInverse:c}}},this)},this),n}},t.prototype._renderHandle=function(){var e=this.group,t=this._displayables,n=t.handles=[null,null],r=t.handleLabels=[null,null],i=this._displayables.sliderGroup,a=this._size,o=this.dataZoomModel,s=this.api,c=o.get(`borderRadius`)||0,l=o.get(`brushSelect`),u=t.filler=new zX({silent:l,style:{fill:o.get(`fillerColor`)},textConfig:{position:`inside`}});i.add(u),i.add(new zX({silent:!0,subPixelOptimize:!0,shape:{x:0,y:0,width:a[0],height:a[1],r:c},style:{stroke:o.get(`dataBackgroundColor`)||o.get(`borderColor`),lineWidth:BX,fill:Q.color.transparent}})),G([0,1],function(t){var a=o.get(`handleIcon`);!SA[a]&&a.indexOf(`path://`)<0&&a.indexOf(`image://`)<0&&(a=`path://`+a);var s=TA(a,-1,0,2,2,null,!0);s.attr({cursor:ZX(this._orient),draggable:!0,drift:q(this._onDragMove,this,t),ondragend:q(this._onDragEnd,this),onmouseover:q(this._onOverDataInfoTriggerArea,this,!0),onmouseout:q(this._onOverDataInfoTriggerArea,this,!1),z2:5});var c=s.getBoundingRect(),l=o.get(`handleSize`);this._handleHeight=Cu(l,this._size[1]),this._handleWidth=c.width/c.height*this._handleHeight,s.setStyle(o.getModel(`handleStyle`).getItemStyle()),s.style.strokeNoScale=!0,s.rectHover=!0,s.ensureState(`emphasis`).style=o.getModel([`emphasis`,`handleStyle`]).getItemStyle(),dy(s);var u=o.get(`handleColor`);u!=null&&(s.style.fill=u),i.add(n[t]=s);var d=o.getModel(`textStyle`),f=(o.get(`handleLabel`)||{}).show||!1;e.add(r[t]=new W_({silent:!0,invisible:!f,style:nS(d,{x:0,y:0,text:``,verticalAlign:`middle`,align:`center`,fill:d.getTextColor(),font:d.getFont()}),z2:10}))},this);var d=u;if(l){var f=Cu(o.get(`moveHandleSize`),a[1]),p=t.moveHandle=new z_({style:o.getModel(`moveHandleStyle`).getItemStyle(),silent:!0,shape:{r:[0,0,2,2],y:a[1]-.5,height:f}}),m=f*.8,h=t.moveHandleIcon=TA(o.get(`moveHandleIcon`),-m/2,-m/2,m,m,Q.color.neutral00,!0);h.silent=!0,h.y=a[1]+f/2-.5,p.ensureState(`emphasis`).style=o.getModel([`emphasis`,`moveHandleStyle`]).getItemStyle();var g=Math.min(a[1]/2,Math.max(f,10));d=t.moveZone=new z_({invisible:!0,shape:{y:a[1]-g,height:f+g}}),d.on(`mouseover`,function(){s.enterEmphasis(p)}).on(`mouseout`,function(){s.leaveEmphasis(p)}),i.add(p),i.add(h),i.add(d)}d.attr({draggable:!0,cursor:`grab`,drift:q(this._onActualMoveZoneDrift,this),ondragstart:q(this._onActualMoveZoneDragStart,this),ondragend:q(this._onActualMoveZoneDragEnd,this),onmouseover:q(this._onOverDataInfoTriggerArea,this,!0),onmouseout:q(this._onOverDataInfoTriggerArea,this,!1)})},t.prototype._resetInterval=function(){var e=this._range=this.dataZoomModel.getPercentRange(),t=this._getViewExtent();this._handleEnds=[Su(e[0],[0,100],t,!0),Su(e[1],[0,100],t,!0)]},t.prototype._updateInterval=function(e,t){var n=this.dataZoomModel,r=this._handleEnds,i=this._getViewExtent(),a=n.findRepresentativeAxisProxy().getMinMaxSpan(),o=[0,100];zH(t,r,i,n.get(`zoomLock`)?`all`:e,a.minSpan==null?null:Su(a.minSpan,o,i,!0),a.maxSpan==null?null:Su(a.maxSpan,o,i,!0));var s=this._range,c=this._range=Ou([Su(r[0],i,o,!0),Su(r[1],i,o,!0)]);return!s||s[0]!==c[0]||s[1]!==c[1]},t.prototype._updateView=function(e){var t=this._displayables,n=this._handleEnds,r=Ou(n.slice()),i=this._size;G([0,1],function(e){var r=t.handles[e],a=this._handleHeight;r.attr({scaleX:a/2,scaleY:a/2,x:n[e]+(e?-1:1),y:i[1]/2-a/2})},this),t.filler.setShape({x:r[0],y:0,width:r[1]-r[0],height:i[1]});var a={x:r[0],width:r[1]-r[0]};t.moveHandle&&(t.moveHandle.setShape(a),t.moveZone.setShape(a),t.moveZone.getBoundingRect(),t.moveHandleIcon&&t.moveHandleIcon.attr(`x`,a.x+a.width/2));for(var o=t.dataShadowSegs,s=[0,r[0],r[1],i[0]],c=0;ct[0]||n[1]<0||n[1]>t[1])){var r=this._handleEnds,i=(r[0]+r[1])/2,a=this._updateInterval(`all`,n[0]-i);this._updateView(),a&&this._dispatchZoomAction(!1)}},t.prototype._onBrushStart=function(e){var t=e.offsetX,n=e.offsetY;this._brushStart=new Qf(t,n),this._brushing=!0,this._brushStartTime=+new Date},t.prototype._onBrushEnd=function(e){if(this._brushing){var t=this._displayables.brushRect;if(this._brushing=!1,t){t.attr(`ignore`,!0);var n=t.shape;if(!(+new Date-this._brushStartTime<200&&Math.abs(n.width)<5)){var r=this._getViewExtent(),i=[0,100],a=this._handleEnds=[n.x,n.x+n.width],o=this.dataZoomModel.findRepresentativeAxisProxy().getMinMaxSpan();zH(0,a,r,0,o.minSpan==null?null:Su(o.minSpan,i,r,!0),o.maxSpan==null?null:Su(o.maxSpan,i,r,!0)),this._range=Ou([Su(a[0],r,i,!0),Su(a[1],r,i,!0)]),this._updateView(),this._dispatchZoomAction(!1)}}}},t.prototype._onBrush=function(e){this._brushing&&(pM(e.event),this._updateBrushRect(e.offsetX,e.offsetY))},t.prototype._updateBrushRect=function(e,t){var n=this._displayables,r=this.dataZoomModel,i=n.brushRect;i||(i=n.brushRect=new zX({silent:!0,style:r.getModel(`brushStyle`).getItemStyle()}),n.sliderGroup.add(i)),i.attr(`ignore`,!1);var a=this._brushStart,o=this._displayables.sliderGroup,s=o.transformCoordToLocal(e,t),c=o.transformCoordToLocal(a.x,a.y),l=this._size;s[0]=Math.max(Math.min(l[0],s[0]),0),i.setShape({x:c[0],y:0,width:s[0]-c[0],height:l[1]})},t.prototype._dispatchZoomAction=function(e){var t=this._range;this.api.dispatchAction({type:`dataZoom`,from:this.uid,dataZoomId:this.dataZoomModel.id,animation:e?qX:null,start:t[0],end:t[1]})},t.prototype._findCoordRect=function(){var e,t=LK(this.dataZoomModel).infoList;if(!e&&t.length){var n=t[0].model.coordinateSystem;e=n.getRect&&n.getRect()}if(!e){var r=this.api.getWidth(),i=this.api.getHeight();e={x:r*.2,y:i*.2,width:r*.6,height:i*.6}}return e},t.type=`dataZoom.slider`,t}(KK);function YX(e,t,n,r){var i=e.get(`labelFormatter`),a=e.get(`labelPrecision`);(a==null||a===`auto`)&&(a=n.valuePrecision);var o=n.value[t],s=o==null||isNaN(o)?``:tO(r)||$D(r)?r.getLabel({value:Math.round(o)}):isFinite(a)?Du(o,a,!0):o+``;return Al(i)?i(o,s):Y(i)?i.replace(`{value}`,s):s}function XX(e){return{x:`y`,y:`x`,radius:`angle`,angle:`radius`}[e]}function ZX(e){return e===`vertical`?`ns-resize`:`ew-resize`}function QX(e){e.registerComponentModel(RX),e.registerComponentView(JX),QK(e)}function $X(e){aR(LX),aR(QX)}var eZ={get:function(e,t,n){var r=hl((tZ[e]||{})[t]);return n&&J(r)?r[r.length-1]:r}},tZ={color:{active:[`#006edd`,`#e0ffff`],inactive:[Q.color.transparent]},colorHue:{active:[0,360],inactive:[0,0]},colorSaturation:{active:[.3,1],inactive:[0,0]},colorLightness:{active:[.9,.5],inactive:[0,0]},colorAlpha:{active:[.3,1],inactive:[0,0]},opacity:{active:[.3,1],inactive:[0,0]},symbol:{active:[`circle`,`roundRect`,`diamond`],inactive:[`none`]},symbolSize:{active:[10,50],inactive:[0,0]}},nZ=cH.mapVisual,rZ=cH.eachVisual,iZ=J,aZ=G,oZ=Ou,sZ=Su,cZ=function(e){U(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n.stateList=[`inRange`,`outOfRange`],n.replacableOptionKeys=[`inRange`,`outOfRange`,`target`,`controller`,`color`],n.layoutMode={type:`box`,ignoreSize:!0},n.dataBound=[-1/0,1/0],n.targetVisuals={},n.controllerVisuals={},n}return t.prototype.init=function(e,t,n){this.mergeDefaultAndTheme(e,n)},t.prototype.optionUpdated=function(e,t){var n=this.option;!t&&VJ(n,e,this.replacableOptionKeys),this.textStyleModel=this.getModel(`textStyle`),this.resetItemSize(),this.completeVisualOption()},t.prototype.resetVisual=function(e){var t=this.stateList;e=q(e,this),this.controllerVisuals=BJ(this.option.controller,t,e),this.targetVisuals=BJ(this.option.target,t,e)},t.prototype.getItemSymbol=function(){return null},t.prototype.getTargetSeriesIndices=function(){var e=this,t=this.option.seriesTargets;if(t){var n=[];return aZ(t,function(t){if(t.seriesIndex!=null)n.push(t.seriesIndex);else if(t.seriesId!=null){var r;e.ecModel.eachSeries(function(e){e.id===t.seriesId&&(r=e)}),r&&n.push(r.componentIndex)}}),n}var r=this.option.seriesId,i=this.option.seriesIndex;i==null&&r==null&&(i=`all`);var a=jd(this.ecModel,`series`,{index:i,id:r},{useDefault:!1,enableAll:!0,enableNone:!1}).models;return K(a,function(e){return e.componentIndex})},t.prototype.eachTargetSeries=function(e,t){G(this.getTargetSeriesIndices(),function(n){var r=this.ecModel.getSeriesByIndex(n);r&&e.call(t,r)},this)},t.prototype.isTargetSeries=function(e){var t=!1;return this.eachTargetSeries(function(n){n===e&&(t=!0)}),t},t.prototype.formatValueText=function(e,t,n){var r=this.option,i=r.precision,a=this.dataBound,o=r.formatter,s;n||=[`<`,`>`],J(e)&&(e=e.slice(),s=!0);var c=t?e:s?[l(e[0]),l(e[1])]:l(e);return Y(o)?o.replace(`{value}`,s?c[0]:c).replace(`{value2}`,s?c[1]:c):Al(o)?s?o(e[0],e[1]):o(e):s?e[0]===a[0]?n[0]+` `+c[1]:e[1]===a[1]?n[1]+` `+c[0]:c[0]+` - `+c[1]:c;function l(e){return e===a[0]?`min`:e===a[1]?`max`:(+e).toFixed(Math.min(i,20))}},t.prototype.resetExtent=function(){var e=this.option,t=oZ([e.min,e.max]);this._dataExtent=t},t.prototype.getDimension=function(e){var t=this,n=this.option.seriesTargets;if(n){var r=El(n,function(n){return n.seriesIndex!=null&&n.seriesIndex===e||n.seriesId!=null&&n.seriesId===t.ecModel.getSeriesByIndex(e).id});if(r)return r.dimension}return this.option.dimension},t.prototype.getDataDimensionIndex=function(e){var t=e.hostModel.seriesIndex,n=this.getDimension(t);if(n!=null)return e.getDimensionIndex(n);for(var r=e.dimensions,i=r.length-1;i>=0;i--){var a=r[i],o=e.getDimensionInfo(a);if(!o.isCalculationCoord)return o.storeDimIndex}},t.prototype.getExtent=function(){return this._dataExtent.slice()},t.prototype.completeVisualOption=function(){var e=this.ecModel,t=this.option,n={inRange:t.inRange,outOfRange:t.outOfRange},r=t.target||={},i=t.controller||={};gl(r,n),gl(i,n);var a=this.isCategory();o.call(this,r),o.call(this,i),s.call(this,r,`inRange`,`outOfRange`),c.call(this,i);function o(n){iZ(t.color)&&!n.inRange&&(n.inRange={color:t.color.slice().reverse()}),n.inRange=n.inRange||{color:e.get(`gradientColor`)}}function s(e,t,n){var r=e[t],i=e[n];r&&!i&&(i=e[n]={},aZ(r,function(e,t){if(cH.isValidType(t)){var n=eZ.get(t,`inactive`,a);n!=null&&(i[t]=n,t===`color`&&!i.hasOwnProperty(`opacity`)&&!i.hasOwnProperty(`colorAlpha`)&&(i.opacity=[0,0]))}}))}function c(e){var t=(e.inRange||{}).symbol||(e.outOfRange||{}).symbol,n=(e.inRange||{}).symbolSize||(e.outOfRange||{}).symbolSize,r=this.get(`inactiveColor`),i=this.getItemSymbol()||`roundRect`;aZ(this.stateList,function(o){var s=this.itemSize,c=e[o];c||=e[o]={color:a?r:[r]},c.symbol??(c.symbol=t&&hl(t)||(a?i:[i])),c.symbolSize??(c.symbolSize=n&&hl(n)||(a?s[0]:[s[0],s[0]])),c.symbol=nZ(c.symbol,function(e){return e===`none`?i:e});var l=c.symbolSize;if(l!=null){var u=-1/0;rZ(l,function(e){e>u&&(u=e)}),c.symbolSize=nZ(l,function(e){return sZ(e,[0,u],[0,s[0]],!0)})}},this)}},t.prototype.resetItemSize=function(){this.itemSize=[parseFloat(this.get(`itemWidth`)),parseFloat(this.get(`itemHeight`))]},t.prototype.isCategory=function(){return!!this.option.categories},t.prototype.setSelected=function(e){},t.prototype.getSelected=function(){return null},t.prototype.getValueState=function(e){return null},t.prototype.getVisualMeta=function(e){return null},t.type=`visualMap`,t.dependencies=[`series`],t.defaultOption={show:!0,z:4,min:0,max:200,left:0,right:null,top:null,bottom:0,itemWidth:null,itemHeight:null,inverse:!1,orient:`vertical`,backgroundColor:Q.color.transparent,borderColor:Q.color.borderTint,contentColor:Q.color.theme[0],inactiveColor:Q.color.disabled,borderWidth:0,padding:Q.size.m,textGap:10,precision:0,textStyle:{color:Q.color.secondary}},t}(Sw),lZ=[20,140],uZ=function(e){U(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n}return t.prototype.optionUpdated=function(t,n){e.prototype.optionUpdated.apply(this,arguments),this.resetExtent(),this.resetVisual(function(e){e.mappingMethod=`linear`,e.dataExtent=this.getExtent()}),this._resetRange()},t.prototype.resetItemSize=function(){e.prototype.resetItemSize.apply(this,arguments);var t=this.itemSize;(t[0]==null||isNaN(t[0]))&&(t[0]=lZ[0]),(t[1]==null||isNaN(t[1]))&&(t[1]=lZ[1])},t.prototype._resetRange=function(){var e=this.getExtent(),t=this.option.range;!t||t.auto?(e.auto=1,this.option.range=e):J(t)&&(t[0]>t[1]&&t.reverse(),t[0]=Math.max(t[0],e[0]),t[1]=Math.min(t[1],e[1]))},t.prototype.completeVisualOption=function(){e.prototype.completeVisualOption.apply(this,arguments),G(this.stateList,function(e){var t=this.option.controller[e].symbolSize;t&&t[0]!==t[1]&&(t[0]=t[1]/3)},this)},t.prototype.setSelected=function(e){this.option.range=e.slice(),this._resetRange()},t.prototype.getSelected=function(){var e=this.getExtent(),t=Ou((this.get(`range`)||[]).slice());return t[0]>e[1]&&(t[0]=e[1]),t[1]>e[1]&&(t[1]=e[1]),t[0]=n[1]||e<=t[1])?`inRange`:`outOfRange`},t.prototype.findTargetDataIndices=function(e){var t=[];return this.eachTargetSeries(function(n){var r=[],i=n.getData();i.each(this.getDataDimensionIndex(i),function(t,n){e[0]<=t&&t<=e[1]&&r.push(n)},this),t.push({seriesId:n.id,dataIndex:r})},this),t},t.prototype.getVisualMeta=function(e){var t=dZ(this,`outOfRange`,this.getExtent()),n=dZ(this,`inRange`,this.option.range.slice()),r=[];function i(t,n){r.push({value:t,color:e(t,n)})}for(var a=0,o=0,s=n.length,c=t.length;oe[1])break;r.push({color:this.getControllerVisual(o,`color`,t),offset:a/n})}return r.push({color:this.getControllerVisual(e[1],`color`,t),offset:1}),r},t.prototype._createBarPoints=function(e,t){var n=this.visualMapModel.itemSize;return[[n[0]-t[0],e[0]],[n[0],e[0]],[n[0],e[1]],[n[0]-t[1],e[1]]]},t.prototype._createBarGroup=function(e){var t=this._orient,n=this.visualMapModel.get(`inverse`);return new Ky(t===`horizontal`&&!n?{scaleX:e===`bottom`?1:-1,rotation:Math.PI/2}:t===`horizontal`&&n?{scaleX:e===`bottom`?-1:1,rotation:-Math.PI/2}:t===`vertical`&&!n?{scaleX:e===`left`?1:-1,scaleY:-1}:{scaleX:e===`left`?1:-1})},t.prototype._updateHandle=function(e,t){if(this._useHandle){var n=this._shapes,r=this.visualMapModel,i=n.handleThumbs,a=n.handleLabels,o=r.itemSize,s=r.getExtent(),c=this._applyTransform(`left`,n.mainGroup);_Z([0,1],function(l){var u=i[l];u.setStyle(`fill`,t.handlesColor[l]),u.y=e[l];var d=gZ(e[l],[0,o[1]],s,!0),f=this.getControllerVisual(d,`symbolSize`);u.scaleX=u.scaleY=f/o[0],u.x=o[0]-f/2;var p=bx(n.handleLabelPoints[l],yx(u,this.group));if(this._orient===`horizontal`){var m=c===`left`||c===`top`?(o[0]-f)/2:(o[0]-f)/-2;p[1]+=m}a[l].setStyle({x:p[0],y:p[1],text:r.formatValueText(this._dataInterval[l]),verticalAlign:`middle`,align:this._orient===`vertical`?this._applyTransform(`left`,n.mainGroup):`center`})},this)}},t.prototype._showIndicator=function(e,t,n,r){var i=this.visualMapModel,a=i.getExtent(),o=i.itemSize,s=[0,o[1]],c=this._shapes,l=c.indicator;if(l){l.attr(`invisible`,!1);var u=this.getControllerVisual(e,`color`,{convertOpacityToAlpha:!0}),d=this.getControllerVisual(e,`symbolSize`),f=gZ(e,a,s,!0),p=o[0]-d/2,m={x:l.x,y:l.y};l.y=f,l.x=p;var h=bx(c.indicatorLabelPoint,yx(l,this.group)),g=c.indicatorLabel;g.attr(`invisible`,!1);var _=this._applyTransform(`left`,c.mainGroup),v=this._orient===`horizontal`;g.setStyle({text:(n||``)+i.formatValueText(t),verticalAlign:v?_:`middle`,align:v?`center`:_});var y={x:p,y:f,style:{fill:u}},b={style:{x:h[0],y:h[1]}};if(i.ecModel.isAnimationEnabled()&&!this._firstShowIndicator){var x={duration:100,easing:`cubicInOut`,additive:!0};l.x=m.x,l.y=m.y,l.animateTo(y,x),g.animateTo(b,x)}else l.attr(y),g.attr(b);this._firstShowIndicator=!1;var S=this._shapes.handleLabels;if(S)for(var C=0;Ci[1]&&(l[1]=1/0),t&&(l[0]===-1/0?this._showIndicator(c,l[1],`< `,o):l[1]===1/0?this._showIndicator(c,l[0],`> `,o):this._showIndicator(c,c,`≈ `,o));var u=this._hoverLinkDataIndices,d=[];(t||TZ(n))&&(d=this._hoverLinkDataIndices=n.findTargetDataIndices(l));var f=Cd(u,d);this._dispatchHighDown(`downplay`,hZ(f[0],n)),this._dispatchHighDown(`highlight`,hZ(f[1],n))}},t.prototype._hoverLinkFromSeriesMouseOver=function(e){var t;if(yF(e.target,function(e){var n=iv(e);if(n.dataIndex!=null)return t=n,!0},!0),t){var n=this.ecModel.getSeriesByIndex(t.seriesIndex),r=this.visualMapModel;if(r.isTargetSeries(n)){var i=n.getData(t.dataType),a=i.getStore().get(r.getDataDimensionIndex(i),t.dataIndex);isNaN(a)||this._showIndicator(a,a)}}},t.prototype._hideIndicator=function(){var e=this._shapes;e.indicator&&e.indicator.attr(`invisible`,!0),e.indicatorLabel&&e.indicatorLabel.attr(`invisible`,!0);var t=this._shapes.handleLabels;if(t)for(var n=0;n=0&&(i.dimension=a,r.push(i))}}),e.getData().setVisual(`visualMeta`,r)}}];function AZ(e,t,n,r){for(var i=t.targetVisuals[r],a=cH.prepareVisualTypes(i),o={color:hF(e.getData(),`color`)},s=0,c=a.length;s0:e.splitNumber>0)||e.calculable)?`continuous`:`piecewise`}),e.registerAction(DZ,OZ),G(kZ,function(t){e.registerVisual(e.PRIORITY.VISUAL.COMPONENT,t)}),e.registerPreprocessor(MZ))}function IZ(e){e.registerComponentModel(uZ),e.registerComponentView(SZ),FZ(e)}var LZ=function(e){U(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n._pieceList=[],n}return t.prototype.optionUpdated=function(t,n){e.prototype.optionUpdated.apply(this,arguments),this.resetExtent();var r=this._mode=this._determineMode();this._pieceList=[],RZ[this._mode].call(this,this._pieceList),this._resetSelected(t,n);var i=this.option.categories;this.resetVisual(function(e,t){r===`categories`?(e.mappingMethod=`category`,e.categories=hl(i)):(e.dataExtent=this.getExtent(),e.mappingMethod=`piecewise`,e.pieceList=K(this._pieceList,function(e){return e=hl(e),t!==`inRange`&&(e.visual=null),e}))})},t.prototype.completeVisualOption=function(){var t=this.option,n={},r=cH.listVisualTypes(),i=this.isCategory();G(t.pieces,function(e){G(r,function(t){e.hasOwnProperty(t)&&(n[t]=1)})}),G(n,function(e,n){var r=!1;G(this.stateList,function(e){r=r||a(t,e,n)||a(t.target,e,n)},this),!r&&G(this.stateList,function(e){(t[e]||(t[e]={}))[n]=eZ.get(n,e===`inRange`?`active`:`inactive`,i)})},this);function a(e,t,n){return e&&e[t]&&e[t].hasOwnProperty(n)}e.prototype.completeVisualOption.apply(this,arguments)},t.prototype._resetSelected=function(e,t){var n=this.option,r=this._pieceList,i=(t?n:e).selected||{};if(n.selected=i,G(r,function(e,t){var n=this.getSelectedMapKey(e);i.hasOwnProperty(n)||(i[n]=!0)},this),n.selectedMode===`single`){var a=!1;G(r,function(e,t){var n=this.getSelectedMapKey(e);i[n]&&(a?i[n]=!1:a=!0)},this)}},t.prototype.getItemSymbol=function(){return this.get(`itemSymbol`)},t.prototype.getSelectedMapKey=function(e){return this._mode===`categories`?e.value+``:e.index+``},t.prototype.getPieceList=function(){return this._pieceList},t.prototype._determineMode=function(){var e=this.option;return e.pieces&&e.pieces.length>0?`pieces`:this.option.categories?`categories`:`splitNumber`},t.prototype.setSelected=function(e){this.option.selected=hl(e)},t.prototype.getValueState=function(e){var t=cH.findPieceIndex(e,this._pieceList);return t==null?`outOfRange`:this.option.selected[this.getSelectedMapKey(this._pieceList[t])]?`inRange`:`outOfRange`},t.prototype.findTargetDataIndices=function(e){var t=[],n=this._pieceList;return this.eachTargetSeries(function(r){var i=[],a=r.getData();a.each(this.getDataDimensionIndex(a),function(t,r){cH.findPieceIndex(t,n)===e&&i.push(r)},this),t.push({seriesId:r.id,dataIndex:i})},this),t},t.prototype.getRepresentValue=function(e){var t;if(this.isCategory())t=e.value;else if(e.value!=null)t=e.value;else{var n=e.interval||[];t=n[0]===-1/0&&n[1]===1/0?0:(n[0]+n[1])/2}return t},t.prototype.getVisualMeta=function(e){if(this.isCategory())return;var t=[],n=[``,``],r=this;function i(i,a){var o=r.getRepresentValue({interval:i});a||=r.getValueState(o);var s=e(o,a);i[0]===-1/0?n[0]=s:i[1]===1/0?n[1]=s:t.push({value:i[0],color:s},{value:i[1],color:s})}var a=this._pieceList.slice();if(!a.length)a.push({interval:[-1/0,1/0]});else{var o=a[0].interval[0];o!==-1/0&&a.unshift({interval:[-1/0,o]}),o=a[a.length-1].interval[1],o!==1/0&&a.push({interval:[o,1/0]})}var s=-1/0;return G(a,function(e){var t=e.interval;t&&(t[0]>s&&i([s,t[0]],`outOfRange`),i(t.slice()),s=t[1])},this),{stops:t,outerColors:n}},t.type=`visualMap.piecewise`,t.defaultOption=AS(cZ.defaultOption,{selected:null,minOpen:!1,maxOpen:!1,align:`auto`,itemWidth:20,itemHeight:14,itemSymbol:`roundRect`,pieces:null,categories:null,splitNumber:5,selectedMode:`multiple`,itemGap:10,hoverLink:!0}),t}(cZ),RZ={splitNumber:function(e){var t=this.option,n=Math.min(t.precision,20),r=this.getExtent(),i=t.splitNumber;i=Math.max(parseInt(i,10),1),t.splitNumber=i;for(var a=(r[1]-r[0])/i;+a.toFixed(n)!==a&&n<5;)n++;t.precision=n,a=+a.toFixed(n),t.minOpen&&e.push({interval:[-1/0,r[0]],close:[0,0]});for(var o=0,s=r[0];o`,`≥`][t[0]]];e.text=e.text||this.formatValueText(e.value==null?e.interval:e.value,!1,n)},this)}};function zZ(e,t){var n=e.inverse;(e.orient===`vertical`?!n:n)&&t.reverse()}var BZ=function(e){U(t,e);function t(){var n=e!==null&&e.apply(this,arguments)||this;return n.type=t.type,n}return t.prototype.doRender=function(){var e=this.group;e.removeAll();var t=this.visualMapModel,n=t.get(`textGap`),r=t.textStyleModel,i=this._getItemAlign(),a=t.itemSize,o=this._getViewData(),s=o.endsText,c=Bl(t.get(`showLabel`,!0),!s),l=!t.get(`selectedMode`);s&&this._renderEndsText(e,s[0],a,c,i),G(o.viewPieceList,function(o){var s=o.piece,u=new Ky;u.onclick=q(this._onItemClick,this,s),this._enableHoverLink(u,o.indexInModelPieceList);var d=t.getRepresentValue(s);if(this._createItemSymbol(u,d,[0,0,a[0],a[1]],l),c){var f=this.visualMapModel.getValueState(d),p=r.get(`align`)||i;u.add(new W_({style:nS(r,{x:p===`right`?-n:a[0]+n,y:a[1]/2,text:s.text,verticalAlign:r.get(`verticalAlign`)||`middle`,align:p,opacity:X(r.get(`opacity`),f===`outOfRange`?.5:1)}),silent:l}))}e.add(u)},this),s&&this._renderEndsText(e,s[1],a,c,i),dw(t.get(`orient`),e,t.get(`itemGap`)),this.renderBackground(e),this.positionGroup(e)},t.prototype._enableHoverLink=function(e,t){var n=this;e.on(`mouseover`,function(){return r(`highlight`)}).on(`mouseout`,function(){return r(`downplay`)});var r=function(e){var r=n.visualMapModel;r.option.hoverLink&&n.api.dispatchAction({type:e,batch:hZ(r.findTargetDataIndices(t),r)})}},t.prototype._getItemAlign=function(){var e=this.visualMapModel,t=e.option;if(t.orient===`vertical`)return mZ(e,this.api,e.itemSize);var n=t.align;return(!n||n===`auto`)&&(n=`left`),n},t.prototype._renderEndsText=function(e,t,n,r,i){if(t){var a=new Ky,o=this.visualMapModel.textStyleModel;a.add(new W_({style:nS(o,{x:r?i===`right`?n[0]:0:n[0]/2,y:n[1]/2,verticalAlign:`middle`,align:r?i:`center`,text:t})})),e.add(a)}},t.prototype._getViewData=function(){var e=this.visualMapModel,t=K(e.getPieceList(),function(e,t){return{piece:e,indexInModelPieceList:t}}),n=e.get(`text`),r=e.get(`orient`),i=e.get(`inverse`);return(r===`horizontal`?i:!i)?t.reverse():n&&=n.slice().reverse(),{viewPieceList:t,endsText:n}},t.prototype._createItemSymbol=function(e,t,n,r){var i=TA(this.getControllerVisual(t,`symbol`),n[0],n[1],n[2],n[3],this.getControllerVisual(t,`color`));i.silent=r,e.add(i)},t.prototype._onItemClick=function(e){var t=this.visualMapModel,n=t.option,r=n.selectedMode;if(r){var i=hl(n.selected),a=t.getSelectedMapKey(e);r===`single`||r===!0?(i[a]=!0,G(i,function(e,t){i[t]=t===a})):i[a]=!i[a],this.api.dispatchAction({type:`selectDataRange`,from:this.uid,visualMapId:this.visualMapModel.id,selected:i})}},t.type=`visualMap.piecewise`,t}(fZ);function VZ(e){e.registerComponentModel(LZ),e.registerComponentView(BZ),FZ(e)}function HZ(e){aR(IZ),aR(VZ)}var UZ={label:{enabled:!0},decal:{show:!1}},WZ=Td(),GZ=Td(),KZ=$d(qZ);function qZ(e,t){var n=e.getModel(`aria`);if(!n.get(`enabled`))return;var r=GZ(e).scope||(GZ(e).scope={}),i=hl(UZ);gl(i.label,e.getLocaleModel().get(`aria`),!1),gl(n.option,i,!1),a(),o();function a(){if(n.getModel(`decal`).get(`show`)){var t=$l();e.eachSeries(function(e){e.isColorBySeries()||(WZ(e).scope=t.get(e.type)||t.set(e.type,{}))}),e.eachSeries(function(t){if(Al(t.enableAriaDecal)){t.enableAriaDecal();return}var n=t.getData();if(t.isColorBySeries()){var i=Dw(t.ecModel,t.name,r,e.getSeriesCount()),a=n.getVisual(`decal`);n.setVisual(`decal`,u(a,i))}else{var o=t.getRawData(),s={},c=WZ(t).scope;n.each(function(e){var t=n.getRawIndex(e);s[t]=e});var l=o.count();o.each(function(e){var r=s[e],i=o.getName(e)||e+``,a=Dw(t.ecModel,i,c,l),d=n.getItemVisual(r,`decal`);n.setItemVisual(r,`decal`,u(d,a))})}function u(e,t){var n=e?W(W({},t),e):t;return n.dirty=!0,n}})}}function o(){var r=t.getZr().dom;if(r){var i=e.getLocaleModel().get(`aria`),a=n.getModel(`label`);if(a.option=yl(a.option,i),a.get(`enabled`)){if(r.setAttribute(`role`,`img`),a.get(`description`)){r.setAttribute(`aria-label`,a.get(`description`));return}var o=e.getSeriesCount(),u=a.get([`data`,`maxCount`])||10,d=a.get([`series`,`maxCount`])||10,f=Math.min(o,d),p;if(!(o<1)){var m=c();p=m?s(a.get([`general`,`withTitle`]),{title:m}):a.get([`general`,`withoutTitle`]);var h=[],g=o>1?a.get([`series`,`multiple`,`prefix`]):a.get([`series`,`single`,`prefix`]);p+=s(g,{seriesCount:o}),e.eachSeries(function(e,t){if(t1?a.get([`series`,`multiple`,r]):a.get([`series`,`single`,r]),n=s(n,{seriesId:e.seriesIndex,seriesName:e.get(`name`),seriesType:l(e.subType)});var i=e.getData();if(i.count()>u){var c=a.get([`data`,`partialData`]);n+=s(c,{displayCnt:u})}else n+=a.get([`data`,`allData`]);for(var d=a.get([`data`,`separator`,`middle`]),p=a.get([`data`,`separator`,`end`]),m=a.get([`data`,`excludeDimensionId`]),g=[],_=0;_=a}}}for(var l=QZ(this),u=l.startIdx;u=0)&&(a=!0)}),a||i.__dirty){var o=n._opts.useDirtyRect&&!ZZ(i)?i.createRepaintRects(e,t,n._width,n._height):null,s=n._i.layerStack[0],c=!0;if(i.__dirty){c=!1,i.__dirty=!1;var l=i.zlevel===s.zl&&i.zlevel2===s.zl2?n._backgroundColor:null;i.clear(!1,l,o)}dQ(i,function(t){var a=n._paintPerCursor(i,t,e,o,c);r&&=a})}},_Q),ou.wxa&&pQ(this._i,function(e){e&&e.ctx&&e.ctx.draw&&e.ctx.draw()}),r},e.prototype._paintPerCursor=function(e,t,n,r,i){var a=e.ctx;if(r){if(!r.length)t.drawIdx=t.endIdx;else for(var o=this.dpr,s=0;s=t.endIdx},e.prototype._paintPerCursorInRect=function(e,t,n,r,i){for(var a={inHover:!1,allClipped:!1,prevEl:null,viewWidth:this._width,viewHeight:this._height,beforeBrushParam:{contentRetained:i}},o=e.ctx,s=ZZ(e),c=s&&$c.getTime(),l=t.drawIdx,u=t.notClearIdx,d=u>=0?Math.min(u,l):l;d15){d++;break}}}dI(o,a),t.drawIdx=Math.max(d,l)},e.prototype.getLayer=function(e,t){return this._ensureLayer(e,0,t)},e.prototype._ensureLayer=function(e,t,n){t||=0;var r=this._singleCanvas;r&&!this._needsManuallyCompositing&&(e=tQ,t=0);var i=fQ(this._i,e)[t];return i||(i=sQ(`zr_`+e+`.`+t,this,e,t),this._layerConfig[e]&&gl(i,this._layerConfig[e],!0),(n||r&&e!==tQ)&&(i.virtual=!0),this._insertLayer(i,e,t,!1),i.initContext()),i},e.prototype.insertLayer=function(e,t){this._insertLayer(t,e,0,!1)},e.prototype._insertLayer=function(e,t,n,r){var i=this._i,a=i.layers,o=i.layerStack,s=this._domRoot,c=null;if(!(a[t]&&a[t][n])&&aQ(e)){for(var l=o.length,u=0;u0&&(c=fQ(i,o[u-1].zl)[o[u-1].zl2]),o.splice(u,0,{zl:t,zl2:n}),fQ(i,t)[n]=e,!r&&!e.virtual){if(c){var d=c.dom;d.nextSibling?s.insertBefore(e.dom,d.nextSibling):s.appendChild(e.dom)}else s.firstChild?s.insertBefore(e.dom,s.firstChild):s.appendChild(e.dom)}e.painter||=this}},e.prototype.eachLayer=function(e,t){return pQ(this._i,function(n,r){e.call(t,n,r)})},e.prototype.eachBuiltinLayer=function(e,t){return pQ(this._i,function(n,r){e.call(t,n,r)},mQ)},e.prototype.eachOtherLayer=function(e,t){return pQ(this._i,function(n,r){e.call(t,n,r)},hQ)},e.prototype.getLayers=function(){var e={};return pQ(this._i,function(t,n,r){e[t.id]=t}),e},e.prototype._updateLayerStatus=function(e,t){var n=this;if(n._singleCanvas)for(var r=1;r=0;a--){var o=i.get(r[a]);if(!o.used)t.__dirty=!0,i.removeKey(r[a]),r.splice(a,1);else{var s=o.endIdxNew;(ZZ(t)?s=0;r--){var i=t[r];if(i.zl===e){var a=n[e][i.zl2];if(a.__builtin__)continue;if(t.splice(r,1),n[e][i.zl2]=void 0,!a.virtual){var o=a.dom.parentNode;o&&o.removeChild(a.dom)}}}},e.prototype.resize=function(e,t){if(this._domRoot.style){var n=this._domRoot;n.style.display=`none`;var r=this._opts,i=this.root;e!=null&&(r.width=e),t!=null&&(r.height=t),e=IF(i,0,r),t=IF(i,1,r),n.style.display=``,(this._width!==e||t!==this._height)&&(n.style.width=e+`px`,n.style.height=t+`px`,pQ(this._i,function(n){n.resize(e,t)}),this.refresh({paintAll:!0})),this._width=e,this._height=t}else{if(e==null||t==null)return;this._width=e,this._height=t,this._ensureLayer(tQ).resize(e,t)}return this},e.prototype.clearLayer=function(e){G(this._i.layers[e],function(e){e&&!e.__builtin__&&e.clear()})},e.prototype.dispose=function(){this.root.innerHTML=``,this.root=this.storage=this._domRoot=this._i=null},e.prototype.getRenderedCanvas=function(e){if(e||={},this._singleCanvas&&!this._compositeManually)return this._i.layers[tQ][0].dom;var t=new $Z(`image`,this,e.pixelRatio||this.dpr);t.initContext(),t.clear(!1,e.backgroundColor||this._backgroundColor);var n=t.ctx;if(e.pixelRatio<=this.dpr){this.refresh();var r=t.dom.width,i=t.dom.height;pQ(this._i,function(e){e.__builtin__?n.drawImage(e.dom,0,0,r,i):e.renderToCanvas&&(n.save(),e.renderToCanvas(n),n.restore())})}else{for(var a={inHover:!1,viewWidth:this._width,viewHeight:this._height,beforeBrushParam:{}},o=this.storage.getDisplayList(!0),s=0,c=o.length;s{e.data&&e.interactive!==!1&&e.data.forEach((r,i)=>{let a=typeof r==`object`&&r&&!Array.isArray(r)?r:void 0,o=a?.value??r;o!=null&&t.push({series_index:n,data_index:i,label:`${e.name??`Series`} · point ${i+1}`,event:{seriesName:e.name,name:a?.name,value:o,data:r,interactive:e.interactive}})})}),t}aR([MD,yQ,AB,jV,_G,qU,Hz,fK,AK,SX,FJ,XY,zY,HZ,YZ,dY,$X,rJ]);var xQ=new Map;function SQ({option:e,optionForSize:t,height:n,label:r,onClick:i,onZoom:a,group:o,keyboard:s}){let c=(0,V.useRef)(null),l=(0,V.useRef)(null),[u,d]=(0,V.useState)(e),[f,p]=(0,V.useState)(!1),m=(0,V.useRef)(!1),h=(0,V.useRef)(e),g=(0,V.useRef)(s);g.current=s;let _=(0,V.useRef)(void 0),v=(0,V.useCallback)(e=>{_.current&&l.current?.dispatchAction({type:`downplay`,seriesIndex:_.current.series_index,dataIndex:_.current.data_index}),l.current?.dispatchAction({type:`hideTip`}),_.current=e,e&&(l.current?.dispatchAction({type:`highlight`,seriesIndex:e.series_index,dataIndex:e.data_index}),l.current?.dispatchAction({type:`showTip`,seriesIndex:e.series_index,dataIndex:e.data_index}))},[]),y=Array.isArray(u.series)?u.series:u.series?[u.series]:[],b=Array.isArray(u.xAxis)?u.xAxis[0]:u.xAxis,x=Array.isArray(u.yAxis)?u.yAxis[0]:u.yAxis,S=(0,V.useMemo)(()=>{if(!s||!f)return[];let e=Array.isArray(u.series)?u.series:u.series?[u.series]:[],t=x?.type===`category`&&e[0]?.type!==`custom`?x:b?.type===`category`?b:void 0;return bQ(e.map(e=>({...e,interactive:void 0}))).map(n=>{let r=Array.isArray(n.event.value)?n.event.value:[];return{...n,event:{...n.event,interactive:e[n.series_index]?.interactive,name:n.event.name??(e[n.series_index]?.type===`custom`?x?.data?.[Number(r[1])]:t?.data?.[n.data_index])}}}).filter(e=>e.event.value!=null&&(!Array.isArray(e.event.value)||e.event.value.at(-1)!=null))},[u,f]),C=e=>{let t=e.event.data?.selection,n=Array.isArray(e.event.value)?e.event.value:[],r=t?.from?Date.parse(t.from):t?.time??(b?.type===`time`?Number(n[0]):NaN),i=/^(\d+)(ms|s|m|h|d)$/.exec(s?.interval??``),a=i?Number(i[1])*{ms:1,s:1e3,m:6e4,h:36e5,d:864e5}[i[2]]:void 0,o=y[e.series_index]?.data?.[e.data_index+1],c=Array.isArray(o)?o:o?.value,l=typeof c?.[0]==`number`&&c[0]>r?c[0]:void 0,u=a?r+a:l??s?.bounds?.to??r,d=t?.to?Date.parse(t.to):y[e.series_index]?.type===`custom`?Number(n[3]):Math.min(u,s?.bounds?.to??u);return Number.isFinite(r)&&Number.isFinite(d)?{from:r,to:d}:void 0},w=e=>{let t=y[e.series_index],n=Array.isArray(e.event.value)?e.event.value:[e.event.value],r=t?.type===`custom`,i=C(e),a=r?x?.data?.[Number(n[1])]:e.event.name,o=r?n[2]:n.at(-1),s=typeof o==`number`?t?.tooltip?.valueFormatter?.(o)??Xs(t?.keyboard_unit,o):String(o??`No value`),c=t?.type===`scatter`?`x: ${Xs(t.keyboard_x_unit,Number(n[0]))} · y: `:``;return[e.event.seriesName??`Series`,a,i?new Date(i.from).toISOString()+(i.to===i.from?``:` – ${new Date(i.to).toISOString()}`):void 0,c+s].filter(Boolean).join(` · `)},T=(0,V.useRef)({}),E=(0,V.useRef)(i);E.current=i;let D=(0,V.useRef)(a);D.current=a;let O=!!a,k=(0,V.useRef)(void 0),A=(0,V.useRef)(0),[j,M]=(0,V.useState)(0),N=(0,V.useCallback)(()=>{let e=k.current;l.current?.dispatchAction({type:`brush`,areas:e?[{brushType:`lineX`,xAxisIndex:0,coordRange:[e.from,e.to]}]:[]},{silent:!0})},[]),P=(0,V.useCallback)(e=>{(k.current?.from!==e?.from||k.current?.to!==e?.to)&&(k.current=e,N())},[N]),F=O?`${r} Brush across the chart to zoom to that range.`:r,I=(0,V.useRef)(()=>void 0),L=(0,V.useCallback)(e=>{e!==A.current&&(A.current=e,I.current())},[]);(0,V.useRef)(null);let ee=(0,V.useRef)(void 0),R=(0,V.useRef)(!1);R.current=!!t,I.current=()=>{ee.current===void 0&&(ee.current=document.createElement(`canvas`).getContext(`2d`));let n=ee.current,r={measureText:n?(e,t)=>(n.font=t,n.measureText(e).width):void 0,width:c.current?.clientWidth??0,height:c.current?.clientHeight??0},i=t&&r.width>0&&r.height>0?t(r):e;if(A.current&&i.grid&&!Array.isArray(i.grid)){let e=i.grid;i={...i,grid:{...e,bottom:(typeof e.bottom==`number`?e.bottom:8)+A.current}}}let a=i.series??[],o=new Set(a.map(e=>e.name)),s=Object.fromEntries(Object.entries(T.current).filter(([e])=>o.has(e)));T.current=s;let u=i.legend;l.current?.setOption({...i,...u?{legend:{...u,selected:{...u.selected,...s}}}:{},...D.current?{toolbox:{show:!1},brush:{xAxisIndex:0,brushMode:`single`,removeOnClick:!0}}:{},aria:{...i.aria,enabled:!0,description:F}},{notMerge:!0});let f=l.current?.getModel?.().getComponent(`grid`)?.coordinateSystem?.getRect(),p=f?.height;if(p&&i.yAxis){let e=Array.isArray(i.yAxis)?i.yAxis:[i.yAxis],t=e.map(e=>nc(e,p));t.some((t,n)=>t.splitNumber!==e[n].splitNumber||t.interval!==e[n].interval)&&(i={...i,yAxis:Array.isArray(i.yAxis)?t:t[0]},l.current?.setOption({yAxis:i.yAxis}))}f&&i.series?.some(e=>e.endLabel?.show)&&(i=Ic(i,f,(e,t)=>{let n=l.current?.convertToPixel({seriesIndex:e},t);return Array.isArray(n)?n[1]:NaN}),l.current?.setOption({series:i.series})),_.current&&v(_.current),D.current&&l.current?.dispatchAction({type:`takeGlobalCursor`,key:`brush`,brushOption:{brushType:`lineX`,brushMode:`single`}}),D.current&&k.current&&N(),h.current=i,g.current&&m.current&&d(i)},(0,V.useEffect)(()=>{if(!c.current)return;let e=LL(c.current,void 0,{renderer:`canvas`});l.current=e,e.on(`click`,e=>{let t=e,n=h.current.series??[],r=t.seriesIndex===void 0?t.interactive:t.componentType&&t.componentType!==`series`?!1:n[t.seriesIndex]?.interactive;E.current?.({...t,...r===void 0?{}:{interactive:r}})}),e.on(`brushEnd`,t=>{let n=t.areas?.[0]?.coordRange;n?.length===2&&Number.isFinite(n[0])&&Number.isFinite(n[1])&&n[0]e+1)),e.dispatchAction({type:`brush`,areas:[]},{silent:!0}),D.current&&e.dispatchAction({type:`takeGlobalCursor`,key:`brush`,brushOption:{brushType:`lineX`,brushMode:`single`}}))}),e.on(`legendselectchanged`,e=>{T.current={...e.selected}});let t=new ResizeObserver(()=>{e.resize(),R.current&&I.current()});return t.observe(c.current),()=>{t.disconnect(),_.current&&v(void 0),e.dispose(),l.current=null}},[]),(0,V.useEffect)(()=>{I.current()},[e,t,F,O]),(0,V.useEffect)(()=>{let e=l.current;if(e&&o)return e.group=o,xQ.set(o,(xQ.get(o)??0)+1),RL(o),()=>{e.group=``;let t=(xQ.get(o)??1)-1;if(t>0){xQ.set(o,t);return}xQ.delete(o),zL(o)}},[o]);let te=(0,H.jsx)(`div`,{ref:c,role:`img`,"aria-label":F,"aria-hidden":s?!0:void 0,style:{height:s?`100%`:n,position:s?`absolute`:void 0,inset:s?0:void 0,zIndex:s?0:void 0,flex:`1 1 auto`,minHeight:0,width:`100%`,minWidth:0,cursor:i?`pointer`:void 0}}),ne=Array.isArray(e.series)?e.series:e.series?[e.series]:[],re=r+`: `+ne.length+` series`+(s?.bounds?`; `+new Date(s.bounds.from).toISOString()+` – `+new Date(s.bounds.to).toISOString():``);return s?(0,H.jsx)(pc,{height:n,rangeReset:j,onRangeChange:P,onRangeBarHeight:L,points:S,label:re,summary:w,onClick:i,canSelect:s.canSelect,onHighlight:v,onZoom:a,bounds:s.bounds,pointWindow:C,onRangePending:s.onRangePending,onActiveChange:e=>{m.current=e,p(e),e&&d(h.current)},children:te}):te}function CQ({panel:e,title:t=e.title,result:n,dark:r,height:i,onSelect:a,onPoint:o}){let s=(0,V.useMemo)(()=>t=>Uc(e,n.frame,Fc(r),t),[e,n.frame,r]),c=(0,V.useMemo)(()=>s({width:500,height:i}),[s,i]),l=(0,V.useCallback)(t=>!!Bs(e,n,t),[e,n]);return(0,H.jsx)(SQ,{keyboard:{canSelect:l},option:c,optionForSize:s,height:i,label:`${t}: bar chart`,onClick:o||a?t=>{let r=Bs(e,n,t);if(!r)return;o?.(r);let i=Object.values(r.dimensions)[0];i!==void 0&&a?.(i)}:void 0})}function wQ({panel:e,title:t=e.title,result:n,dark:r,height:i}){let a=Tc(e,n.frame),o=n.frame.columns.find(e=>e.role===`measure`)?.unit??e.unit,s=e.better??n.better,c=(0,V.useMemo)(()=>t=>Wc({...e,better:s},a,Fc(r),o,t),[e,s,a,r,o]),l=(0,V.useMemo)(()=>c({width:270,height:i}),[c,i]);return(0,H.jsx)(SQ,{option:l,optionForSize:c,height:i,label:`${t}: gauge`})}function TQ(e,t){return!t.previous||(e.reduce??`window`)===`window`&&!t.previous.totals?null:Tc(e,t.previous)}function EQ({panel:e,result:t,dark:n=!1,compare:r=!0,range:i}){let a=t.frame,s=Tc(e,a),c=a.columns.find(e=>e.role===`measure`)?.unit??e.unit,l=e.better??t.better??Oc(e.thresholds),u=kc(s,e.thresholds,l)??(a.health?.health===`healthy`?`ok`:a.health?.health===`degraded`?`warn`:a.health?.health===`unhealthy`?`bad`:null),d=TQ(e,t),f=Ec(a),p=e.thresholds?.find(e=>e.status===u&&s!==null&&(l===`higher`?s<=e.value:s>=e.value))?.label,m=Fc(n);return(0,H.jsxs)(o,{h:`100%`,style:{display:`flex`,flexDirection:`column`,justifyContent:`space-between`,gap:4},children:[(0,H.jsxs)(y,{justify:`space-between`,align:`flex-start`,wrap:`nowrap`,gap:`xs`,children:[(0,H.jsx)(T,{"data-stat-value":!0,fz:32,fw:700,lh:1.1,lts:`-0.02em`,ff:`var(--mantine-font-family-monospace)`,children:Xs(c,s)}),u&&(0,H.jsxs)(T,{"data-stat-status":!0,fz:12,fw:500,style:{borderRadius:999,padding:`1px 8px`,whiteSpace:`nowrap`,background:`${m.status[u]}22`,color:m.text},children:[(0,H.jsx)(`span`,{style:{color:m.status[u]},children:u===`bad`?`◆`:u===`warn`?`■`:`●`}),` `,p??(u===`bad`?`Unhealthy`:u===`warn`?`Degraded`:`Healthy`)]})]}),r&&d!==null&&s!==null&&(0,H.jsx)(DQ,{dark:n,value:s,previous:d,better:l,unit:c,period:OQ(i,t)}),(0,H.jsx)(kQ,{points:f,area:!0,dark:n,height:40})]})}function DQ({value:e,previous:t,better:n,unit:r,period:i,dark:a}){let o=r===`percent`,s=o?e-t:t===0?e===0?0:1/0:(e-t)/Math.abs(t)*100,c=s>=0,l=s===0||!n?null:c?n===`higher`:n===`lower`,u=Number.isFinite(s)?o?`${c?`+`:`−`}${Math.abs(s).toFixed(1)} pts`:`${c?`+`:`−`}${Math.abs(s).toFixed(0)}%`:`new`;return(0,H.jsxs)(y,{gap:6,children:[(0,H.jsxs)(T,{"data-stat-delta":!0,fz:12,fw:600,style:{color:l===null?`var(--mantine-color-dimmed)`:Pc(l?`ok`:`bad`,a)},children:[c?`▲`:`▼`,` `,u]}),(0,H.jsxs)(T,{fz:12,c:`dimmed`,children:[`vs previous `,i]})]})}function OQ(e,t){let n=t.from_ms!==void 0&&t.to_ms!==void 0?t.to_ms-t.from_ms:t.shift_ms,r=/^(\d+)(s|m|h|d|w)$/.exec(e??``),i=r?Number(r[1])*{s:1e3,m:6e4,h:36e5,d:864e5,w:6048e5}[r[2]]:n;if(!i)return`period`;let a=i>=6048e5?`week`:i>=864e5?`day`:i>=36e5?`hour`:i>=6e4?`minute`:`second`,o=i/{week:6048e5,day:864e5,hour:36e5,minute:6e4,second:1e3}[a];return o===1?a:`${Number(o.toFixed(2))} ${a}s`}function kQ({points:e,area:t=!1,dark:n=!1,height:r=32}){let i=e.filter(e=>e!==null&&Number.isFinite(e));if(i.length<2)return null;let a=Math.min(...i),o=Math.max(...i),s=r,c=t=>t/(e.length-1)*200,l=e=>s-2-(e-a)/(o-a||1)*(s-4),u=e.map((t,n)=>t===null||!Number.isFinite(t)?``:`${n===0||e[n-1]===null||!Number.isFinite(e[n-1])?`M`:`L`}${c(n).toFixed(1)},${l(t).toFixed(1)}`).join(``),d=[];return e.forEach((t,n)=>{if(t!==null&&Number.isFinite(t)){if(!n||e[n-1]===null||!Number.isFinite(e[n-1]))d.push({start:n,end:n,path:`M${c(n).toFixed(1)},${l(t).toFixed(1)}`});else{let e=d.at(-1);e.end=n,e.path+=`L${c(n).toFixed(1)},${l(t).toFixed(1)}`}}}),(0,H.jsxs)(`svg`,{viewBox:`0 0 200 ${s}`,preserveAspectRatio:`none`,width:`100%`,height:s,role:`img`,"aria-label":`Value over this panel's time range`,children:[t&&d.filter(e=>e.end>e.start).map(e=>(0,H.jsx)(`path`,{"data-sparkline-area":!0,d:`${e.path}L${c(e.end)},${s}L${c(e.start)},${s}Z`,fill:_c(0,n),opacity:.18},e.start)),(0,H.jsx)(`path`,{"data-sparkline-line":!0,d:u,fill:`none`,stroke:t?_c(0,n):`var(--mantine-primary-color-filled)`,strokeWidth:1.5,vectorEffect:`non-scaling-stroke`})]})}function AQ(e){return jQ(e)||typeof e==`function`||MQ(e)}function jQ(e){return typeof e==`function`&&(()=>{let t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}function MQ(e){return typeof e==`object`&&typeof e.$$typeof==`symbol`&&[`react.memo`,`react.forward_ref`].includes(e.$$typeof.description)}function NQ(e,t){return e==null?null:AQ(e)?V.createElement(e,t):e}function PQ(e){if(`cell`in e&&e.cell){let t=e.cell,n=t.column.columnDef,r=t,i=n;return r.getIsAggregated?.()?NQ(i.aggregatedCell??n.cell,t.getContext()):r.getIsPlaceholder?.()?null:NQ(n.cell,t.getContext())}return`header`in e&&e.header?NQ(e.header.column.columnDef.header,e.header.getContext()):`footer`in e&&e.footer?NQ(e.footer.column.columnDef.footer,e.footer.getContext()):null}function FQ(e){let t=se(e.source,e.selector,{compare:Nt});return typeof e.children==`function`?e.children(t):e.children}function IQ(e){let t=e;return Object.defineProperty(e,"state",{get(){return e.get()}}),`set`in e&&(t.setState=e.set.bind(e)),t}function LQ(e){let{createAtom:t,batch:n}=e,r=t(0);return{createOptionsStore:!1,wrapExternalAtoms:!1,addSubscription:()=>{throw Error(`Feature not supported in current reactivity implementation`)},unmount:()=>{throw Error(`Feature not supported in current reactivity implementation`)},schedule:e.schedule??(e=>queueMicrotask(e)),batch:n,untrack:e=>e(),createReadonlyAtom:(e,n)=>{let i=n?.compare??Object.is,a=!1,o,s=()=>{let t=e();return(!a||!i(o,t))&&(o=t,a=!0),o},c=t(()=>(r.get(),s()),{compare:i});return{get:s,subscribe:c.subscribe.bind(c)}},createWritableAtom:(e,n)=>t(e,{compare:n?.compare}),commit:()=>{r.set(e=>e+1)}}}function RQ(e,t=Object.is){let n=!1,r;return{get:e.get,markCommitted:e=>{r=e,n=!0},subscribe:i=>e.subscribe(e=>{(!n||!t(r,e))&&i(e)})}}function zQ(){return LQ({createAtom:Ze,batch:Ke})}function BQ(e,t){return typeof e==`function`?e(t):e}function VQ(e){if(Array.isArray(e))return e.map(VQ);if(e&&typeof e==`object`){let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)return e;let n=t===null?UQ():{},r=Object.keys(e);for(let t=0;t{(t.options.atoms?.[e]??t.baseAtoms[e]).set(e=>BQ(n,e))}}function KQ(e){if(typeof e!=`object`||!e)return!1;if(Array.isArray(e))return!0;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function qQ(e){return Reflect.ownKeys(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}var JQ=3;function YQ(e,t){return XQ(e,t,JQ)}function XQ(e,t,n){if(Object.is(e,t))return!0;if(n<=0||!KQ(e)||!KQ(t)||(Array.isArray(e)||Array.isArray(t))&&(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length))return!1;let r=qQ(e),i=qQ(t);if(r.length!==i.length)return!1;let a=e,o=t;for(let e=0;e{let t=BQ(n,e);return r(e,t)?e:t})}function QQ(e){return e instanceof Function}function $Q(e,t){let n=[],r=e=>{e.forEach(e=>{n.push(e);let i=t(e);i.length&&r(i)})};return r(e),n}var e$=({fn:e,memoDeps:t,onAfterCompare:n,onAfterUpdate:r,onBeforeCompare:i,onBeforeUpdate:a})=>{let o=[],s;return c=>{i?.();let l=t?.(c),u=!l||l.length!==o?.length;if(!u&&l){for(let e=0;e{if(!t){t=!0;return}e()}}function n$({feature:e,fnName:t,objectId:n,onAfterUpdate:r,table:i,...a}){let o=()=>{if(!r)return;let{schedule:e,untrack:t}=i._reactivity;e(()=>t(()=>r()))},s={onAfterUpdate:()=>{o()}};return e$({...a,...s})}function r$(e,t=`_`){let[n,r]=e.split(t);return{fnKey:r,fnName:`${n}.${r}`,parentName:n}}function i$(e,t,n){for(let[r,{fn:i,memoDeps:a}]of Object.entries(n)){let{fnKey:n,fnName:o}=r$(r);t[n]=a?n$({memoDeps:a,fn:i,fnName:o,table:t,feature:e}):i}}function a$(e,t,n,r){for(let[i,{fn:a,memoDeps:o}]of Object.entries(r)){let{fnKey:r,fnName:s}=r$(i);if(o){let i=`_memo_${r}`;t[r]=function(...t){if(!this[i]){let t=this;this[i]=n$({memoDeps:e=>o(t,e),fn:(...e)=>a(t,...e),fnName:s,objectId:t.id,table:n,feature:e})}return this[i](...t)}}else t[r]=function(...e){return a(this,...e)}}}function o$(e,t,n,...r){return e[t]?.(...r)??n(e,...r)}function s$(e){return e.row.getValue(e.column.id)}function c$(e){return e.getValue()??e.table.options.renderFallbackValue}function l$(e){return{table:e.table,column:e.column,row:e.row,cell:e,getValue:()=>e.getValue(),renderValue:()=>e.renderValue()}}var u$={assignCellPrototype:(e,t)=>{a$(`coreCellsFeature`,e,t,{cell_getValue:{fn:e=>s$(e)},cell_renderValue:{fn:e=>c$(e)},cell_getContext:{fn:e=>l$(e),memoDeps:e=>[e]}})}};function d$(e){if(!e._headerPrototype){e._headerPrototype={table:e};let t=Object.values(e._features);for(let n=0;no$(e,`getIsVisible`,m$)):(WQ(t,e.id)?t[e.id]:void 0)??!0}function h$(e){return e.getAllLeafColumns().filter(e=>o$(e,`getIsVisible`,m$))}function g$(e,t=1){let n=t;for(let r=0;r0&&b$(s,t-1,n,r,i,a)}function x$(e){for(let t=0;t{let n=t;for(let t=0;te[i.accessorKey]}if(!s)throw Error();let l=C$(e),u=Object.create(l);u.accessorFn=c,u.columnDef=i,u.columns=[],u.depth=n,u.id=`${String(s)}`,u.parent=r;let d=e._columnInstanceInitFns;for(let e=0;e{let r=[];if(!t?.length)r=n;else{let e=new Map;for(let t=0;t!n.includes(e.id));if(r===`remove`)return i;let a=new Map;for(let e=0;ee.getFlatColumns())]}function O$(e){if(e.columns.length){let t=e.columns.flatMap(e=>e.getLeafColumns());return o$(e.table,`getOrderColumns`,T$)(t)}return[e]}function k$(e){return{header:e=>{let t=e.header.column.columnDef;return t.accessorKey?t.accessorKey:t.accessorFn?t.id:null},cell:e=>e.renderValue()?.toString?.()??null,...Object.values(e._features).reduce((e,t)=>Object.assign(e,t.getDefaultColumnDef?.()),{}),...e.options.defaultColumn}}function A$(e,t,n,r=0){let i=Array(t.length);for(let a=0;ae.getFlatColumns())}function N$(e){let t=UQ(),n=e.getAllFlatColumns();for(let e=0;ee.getLeafColumns());return o$(e,`getOrderColumns`,T$)(t)}function F$(e){let t=UQ(),n=e.getAllLeafColumns();for(let e=0;e{a$(`coreColumnsFeature`,e,t,{column_getFlatColumns:{fn:e=>D$(e),memoDeps:e=>[e.table.options.columns]},column_getLeafColumns:{fn:e=>O$(e),memoDeps:e=>[e.table.atoms.columnOrder?.get(),e.table.atoms.grouping?.get(),e.table.options.columns,e.table.options.groupedColumnMode]}})},constructTableAPIs:e=>{i$(`coreColumnsFeature`,e,{table_getDefaultColumnDef:{fn:()=>k$(e),memoDeps:()=>[e.options.defaultColumn]},table_getAllColumns:{fn:()=>j$(e),memoDeps:()=>[e.options.columns]},table_getAllFlatColumns:{fn:()=>M$(e),memoDeps:()=>[e.options.columns]},table_getAllFlatColumnsById:{fn:()=>N$(e),memoDeps:()=>[e.options.columns]},table_getAllLeafColumns:{fn:()=>P$(e),memoDeps:()=>[e.atoms.columnOrder?.get(),e.atoms.grouping?.get(),e.options.columns,e.options.groupedColumnMode]},table_getAllLeafColumnsById:{fn:()=>F$(e),memoDeps:()=>[e.getAllLeafColumns()]},table_getColumn:{fn:t=>I$(e,t)}})}};function R$(e,t){for(let n=0;n!t.includes(e.id)&&!n.includes(e.id));return S$(r,[...o,...c,...s],e)}function H$(e){return[...e.getHeaderGroups()].reverse()}function U$(e){let t=e.getHeaderGroups(),n=[];for(let e=0;e{a$(`coreHeadersFeature`,e,t,{header_getLeafHeaders:{fn:e=>z$(e),memoDeps:e=>[e.column.table.options.columns]},header_getContext:{fn:e=>B$(e),memoDeps:e=>[e.column.table.options.columns]}})},constructTableAPIs:e=>{i$(`coreHeadersFeature`,e,{table_getHeaderGroups:{fn:()=>V$(e),memoDeps:()=>[e.options.columns,e.atoms.columnOrder?.get(),e.atoms.grouping?.get(),e.atoms.columnPinning?.get(),e.atoms.columnVisibility?.get(),e.options.groupedColumnMode]},table_getFooterGroups:{fn:()=>H$(e),memoDeps:()=>[e.getHeaderGroups()]},table_getFlatHeaders:{fn:()=>U$(e),memoDeps:()=>[e.getHeaderGroups()]},table_getLeafHeaders:{fn:()=>W$(e),memoDeps:()=>[e.getHeaderGroups()]}})}};function K$(e){if(!e._rowPrototype){e._rowPrototype={table:e};let t=Object.values(e._features);for(let n=0;n{let s=K$(e),c=Object.create(s);c._displayIndexCache=-1,c._uniqueValuesCache=UQ(),c._valuesCache=UQ(),c.depth=i,c.id=t,c.index=r,c.original=n,c.parentId=o,c.subRows=a??[];let l=e._rowInstanceInitFns;for(let e=0;e{let i=e.getValue(r),a=n.getValue(r),o=t.resolveDataValue;return o&&(i=o(i),a=o(a)),t.sort(i,a,e,n,r)},e);return t}var X$=Y$({resolveDataValue:e=>e1(e).toLowerCase(),sort:(e,t)=>t1(e,t)});Y$({resolveDataValue:e=>e1(e),sort:(e,t)=>t1(e,t)}),Y$({resolveDataValue:e=>e1(e).toLowerCase(),sort:(e,t)=>Q$(e,t)}),Y$({resolveDataValue:e=>e1(e),sort:(e,t)=>Q$(e,t)}),Y$({resolveDataValue:e=>$$(e),sort:(e,t)=>e>t?1:eQ$(e,t)});function Q$(e,t){return e===t?0:e>t?1:-1}function $$(e){return e instanceof Date?e.getTime():e}function e1(e){return typeof e==`number`?isNaN(e)||e===1/0||e===-1/0?``:String(e):typeof e==`string`?e:``}function t1(e,t){let n=0,r=0,i=e.length,a=t.length;for(;n=48&&e<=57}function r1(e,t,n){let r=t+1;for(;ro)return 1;if(o>a)return-1}return o>s?1:s>o?-1:0}function a1(e,t,n,r,i,a){let o=t;for(;oi?1:i>t?-1:0}let u=parseInt(e.slice(t,n),10),d=parseInt(r.slice(i,a),10);return u>d?1:d>u?-1:0}function o1(e,t,n){let r=0;for(let i=t;il1(e))}function d1(e){e.atoms.expanded&&(e.options.autoResetAll??e.options.autoResetExpanded??!e.options.manualExpanding)&&e._reactivity.schedule(()=>f1(e))}function f1(e,t){let n=e.initialState.expanded;ZQ(e,`expanded`,t?UQ():n===!0||Object.assign(UQ(),VQ(n??{})))}var p1=0;function m1(e){if(e.options.autoResetAll??e.options.autoResetPageIndex??!e.options.manualPagination){if((e.atoms.pagination?.get()?.pageIndex??p1)===p1)return;_1(e,!0)}}function h1(e,t){ZQ(e,`pagination`,t)}function g1(e,t){h1(e,n=>{let r=BQ(t,n.pageIndex),i=e.options.pageCount===void 0||e.options.pageCount===-1?2**53-1:e.options.pageCount-1;return r=Math.max(0,Math.min(r,i)),{...n,pageIndex:r}})}function _1(e,t){g1(e,t?p1:e.initialState.pagination?.pageIndex??p1)}function v1(){return[]}function y1(e,t){ZQ(e,`sorting`,t)}function b1(e,t){y1(e,t?[]:VQ(e.initialState.sorting??[]))}function x1(e){e.atoms.sorting&&(e.options.autoResetAll??e.options.autoResetSorting??!1)&&b1(e)}function S1(e){let t=e.table._rowModelFns.sortFns,n=e.table.getFilteredRowModel().flatRows.slice(0,10),r,i=!1;for(let t=0;t1)){r=`alphanumeric`;break}}if(!r&&i&&(r=`text`),r){let e=t?.[r];if(e||r===`alphanumeric`&&(e=t?.text),e)return e}return Z$}function C1(e){let t=e.table.getFilteredRowModel().flatRows.slice(0,10);for(let n=0;n{let o=a.findIndex(t=>t.id===e.id),s=o===-1?void 0:a[o],c=[],l,u=i?t:r===`desc`,d=!!(a.length&&k1(e)&&n);return l=d?s?`toggle`:`add`:s?`toggle`:`replace`,l===`toggle`&&(i||r||(l=`remove`)),l===`add`?(c=[...a,{id:e.id,desc:u}],c.splice(0,c.length-(e.table.options.maxMultiSortColCount??2**53-1))):c=l===`toggle`?d?a.map(t=>t.id===e.id?{...t,desc:u}:t):[{id:e.id,desc:u}]:l===`remove`?d?a.filter(t=>t.id!==e.id):[]:[{id:e.id,desc:u}],c})}function E1(e){return e.columnDef.sortDescFirst??e.table.options.sortDescFirst??C1(e)===`desc`?`desc`:`asc`}function D1(e,t){let n=E1(e),r=A1(e);return r?r!==n&&(e.table.options.enableSortingRemoval??!0)&&(!t||(e.table.options.enableMultiRemove??!0))?!1:r===`desc`?`asc`:`desc`:n}function O1(e){return(e.columnDef.enableSorting??!0)&&(e.table.options.enableSorting??!0)&&!!e.accessorFn}function k1(e){return e.columnDef.enableMultiSort??e.table.options.enableMultiSort??!!e.accessorFn}function A1(e){let t=e.table.atoms.sorting?.get()?.find(t=>t.id===e.id);return t?t.desc?`desc`:`asc`:!1}function j1(e){return e.table.atoms.sorting?.get()?.findIndex(t=>t.id===e.id)??-1}function M1(e){y1(e.table,t=>t.length?t.filter(t=>t.id!==e.id):[])}function N1(e){let t=O1(e);return n=>{t&&T1(e,void 0,k1(e)?e.table.options.isMultiSortEvent?.(n):!1)}}function P1(){return e=>n$({feature:`coreRowModelsFeature`,table:e,fnName:`table.getCoreRowModel`,memoDeps:()=>[e.options.data],fn:()=>I1(e,e.options.data),onAfterUpdate:t$(()=>{d1(e),m1(e),x1(e),u1(e)})})}function F1(e,t,n,r=0,i){let a=[];for(let o=0;o{i$(`coreRowModelsFeature`,e,{table_getCoreRowModel:{fn:()=>L1(e)},table_getPreFilteredRowModel:{fn:()=>R1(e)},table_getFilteredRowModel:{fn:()=>z1(e)},table_getPreGroupedRowModel:{fn:()=>B1(e)},table_getGroupedRowModel:{fn:()=>V1(e)},table_getPreSortedRowModel:{fn:()=>H1(e)},table_getSortedRowModel:{fn:()=>U1(e)},table_getPreExpandedRowModel:{fn:()=>W1(e)},table_getExpandedRowModel:{fn:()=>G1(e)},table_getPrePaginatedRowModel:{fn:()=>K1(e)},table_getPaginatedRowModel:{fn:()=>q1(e)},table_getRowModel:{fn:()=>J1(e)}})}};function X1(e){if(!e._cellPrototype){e._cellPrototype={table:e};let t=Object.values(e._features);for(let n=0;n{t._displayIndexCache=e.length,e.push(t),t.subRows.length&&t.getIsExpanded?.()&&t.subRows.forEach(n)};return t.forEach(n),e}for(let e=0;ee.subRows)}function i0(e){let t=e.getCoreRowModel().flatRows,n=0;for(let e=0;e{a$(`coreRowsFeature`,e,t,{row_getDisplayIndex:{fn:e=>Q1(e)},row_getAllCellsByColumnId:{fn:e=>c0(e),memoDeps:e=>[e.getAllCells()]},row_getAllCells:{fn:e=>s0(e),memoDeps:e=>[e.table.getAllLeafColumns()]},row_getLeafRows:{fn:e=>r0(e),memoDeps:e=>[e.subRows]},row_getParentRow:{fn:e=>a0(e)},row_getParentRows:{fn:e=>o0(e)},row_getUniqueValues:{fn:(e,t)=>t0(e,t)},row_getValue:{fn:(e,t)=>e0(e,t)},row_renderValue:{fn:(e,t)=>n0(e,t)}})},constructTableAPIs:e=>{i$(`coreRowsFeature`,e,{table_getRowsInDisplayOrder:{fn:()=>$1(e),memoDeps:()=>[e.getPrePaginatedRowModel().rows,e.options.paginateExpandedRows,e.options.paginateExpandedRows===!1?e.atoms.expanded?.get():void 0]},table_getRowId:{fn:(t,n,r)=>l0(t,e,n,r)},table_getRow:{fn:(t,n)=>u0(e,t,n)},table_getMaxSubRowDepth:{fn:()=>i0(e),memoDeps:()=>[e.getCoreRowModel()]}})}};function f0(e,t,n=(e,t)=>e===t){let r=t===void 0?e.options.state:t;e._reactivity.batch(()=>{if(r)for(let t in r){let i=e.baseAtoms[t];if(!i)continue;let a=r[t],o=a===void 0?e.initialState[t]:a;n(e._reactivity.untrack(()=>i.get()),o)||i.set(()=>o)}})}function p0(e,t,n=(e,t)=>e===t){e._reactivity.batch(()=>{f0(e,t,n),e._reactivity.commit?.()})}function m0(e){let t=VQ(e.initialState);e._reactivity.batch(()=>{let n=Object.keys(t);for(let r=0;rr):e.options=r,n?.syncExternalState!==!1&&p0(e,r.state??null)}var _0={coreCellsFeature:u$,coreColumnsFeature:L$,coreHeadersFeature:G$,coreRowModelsFeature:Y1,coreRowsFeature:d0,coreTablesFeature:{constructTableAPIs:e=>{i$(`coreTablesFeature`,e,{table_reset:{fn:()=>m0(e)},table_setOptions:{fn:t=>g0(e,t)}})}}};function v0(e){return e}function y0(e,t={}){return Object.values(e).forEach(e=>{t=e.getInitialState?.(t)??t}),VQ(t)}function b0(e){let t=e.features.coreReactivityFeature,{aggregationFns:n,columnMeta:r,coreRowModel:i,expandedRowModel:a,facetedMinMaxValues:o,facetedRowModel:s,facetedUniqueValues:c,filterFns:l,filterMeta:u,filteredRowModel:d,groupedRowModel:f,paginatedRowModel:p,sortFns:m,sortedRowModel:h,tableMeta:g,..._}=e.features,v={_cellInstanceInitFns:[],_columnInstanceInitFns:[],_features:{..._0,..._},_headerGroupInstanceInitFns:[],_headerInstanceInitFns:[],_reactivity:t,_rowInstanceInitFns:[],_rowModelFns:{aggregationFns:n,filterFns:l,sortFns:m},_rowModels:{},atoms:{},baseAtoms:{}},y=Object.values(v._features),b={...y.reduce((e,t)=>Object.assign(e,t.getDefaultTableOptions?.(v)),{}),...e};if(t.wrapExternalAtoms&&b.atoms)for(let[e,n]of Object.entries(b.atoms)){let r=n,i=t.createWritableAtom(r.get(),{debugName:`externalAtom/${e}`});b.atoms[e]=i;let a=!1,o=r.subscribe(e=>{a||i.set(e)}),s=i.subscribe(e=>{a=!0,r.set(e),a=!1});t.addSubscription(o),t.addSubscription(s)}t.createOptionsStore?(v.optionsStore=t.createWritableAtom(b,{debugName:`table/optionsStore`}),Object.defineProperty(v,"options",{configurable:!0,enumerable:!0,get(){return v.optionsStore.get()},set(e){v.optionsStore.set(()=>e)}})):v.options=b,v.initialState=y0(v._features,v.options.initialState);let x=Object.keys(v.initialState);for(let e=0;e{let e=v.options,t=e.atoms?.[n],r=t?t.get():v.baseAtoms[n].get();if(t)return r;let i=e.state;if(i&&WQ(i,n)){let e=i[n];return e===void 0?v.initialState[n]:e}return r},{debugName:`table/atoms/${n}`})}f0(v),v.store=IQ(t.createReadonlyAtom(()=>{let e={};for(let t=0;te.shiftKey}},assignColumnPrototype(e,t){a$(`rowSortingFeature`,e,t,{column_getAutoSortFn:{fn:e=>S1(e)},column_getAutoSortDir:{fn:e=>C1(e)},column_getSortFn:{fn:e=>w1(e)},column_toggleSorting:{fn:(e,t,n)=>T1(e,t,n)},column_getFirstSortDir:{fn:e=>E1(e)},column_getNextSortingOrder:{fn:(e,t)=>D1(e,t)},column_getCanSort:{fn:e=>O1(e)},column_getCanMultiSort:{fn:e=>k1(e)},column_getIsSorted:{fn:e=>A1(e)},column_getSortIndex:{fn:e=>j1(e)},column_clearSorting:{fn:e=>M1(e)},column_getToggleSortingHandler:{fn:e=>N1(e)}})},constructTableAPIs(e){i$(`rowSortingFeature`,e,{table_setSorting:{fn:t=>y1(e,t)},table_resetSorting:{fn:t=>b1(e,t)}})}};function S0(){return e=>{let t=e;return n$({feature:`rowSortingFeature`,table:t,fnName:`table.getSortedRowModel`,memoDeps:()=>[t.atoms.sorting?.get(),t.getPreSortedRowModel()],fn:()=>C0(t),onAfterUpdate:t$(()=>m1(t))})}}function C0(e){let t=e.getPreSortedRowModel(),n=e.atoms.sorting?.get();if(!t.rows.length||!n?.length)return t;let r=[],i=n.filter(t=>{let n=e.getColumn(t.id);return n?O1(n):!1});if(!i.length)return t;let a=[];for(let t=0;t{for(let n=0;n{let t=e.slice();t.sort(o);let n=!1;for(let i=0;i`u`?V.useEffect:V.useLayoutEffect;function T0(e,t){let[{table:n,rootSource:r}]=(0,V.useState)(()=>{let t=b0({...e,features:{coreReactivityFeature:zQ(),...e.features}});return t.Subscribe=(e=>FQ({...e,source:e.source??t.store})),t.FlexRender=PQ,{table:t,rootSource:RQ(t.store,Nt)}}),i=n;g0(i,t=>({...t,...e}),{syncExternalState:!1});let a=i.options.state,o=r.get(),s=se(r,t,{compare:Nt});return w0(()=>{r.markCommitted(o),p0(i,a??null,Nt)}),(0,V.useMemo)(()=>({...n,options:e,state:s}),[n,e,s])}function E0(e,t,n,r,i,a){e.format===`status`&&e.unit&&typeof t==`string`&&t.trim()!==``&&Number.isFinite(Number(t))&&(t=Number(t));let o=t===null?`—`:String(t),s={kind:e.format,text:o};if([`unit`,`bar`,`status`,`sparkline`].includes(e.format)&&(s.text=typeof t==`number`?Xs(e.unit,t):o),e.format===`bar`&&(s.fraction=typeof t==`number`&&n>0?Math.max(0,Math.min(1,t/n)):0),e.format===`status`&&typeof t==`number`&&(s.status=kc(Number.isFinite(t)?t:null,r?.thresholds,r?.better??i)),e.format===`service_link`&&(s.variable=e.variable),e.format===`sparkline`&&a)return s.points=a.slice(0,240),s;if(e.format===`sparkline`)try{let e=JSON.parse(o);Array.isArray(e)?s.points=e.slice(0,240).map(e=>typeof e==`number`&&Number.isFinite(e)?e:null):s.unsupported=`Sparkline requires an array column`}catch{s.unsupported=`Sparkline requires an array column`}return s}function D0({text:e,template:t=!1,highlight:n=``}){let r=lt(`light`)===`dark`,i=Xe[r?5:7],a=[1,3,5].map(e=>parseInt(i.slice(e,e+2),16)).join(`, `),o=[];if(n){let t=e.toLowerCase(),r=n.toLowerCase();for(let e=t.indexOf(r);e!==-1;e=t.indexOf(r,e+r.length))o.push(e)}let s=(t,i)=>{let s=[],c=t;for(let l of o){let o=Math.max(t,l),u=Math.min(i,l+n.length);o>=u||(s.push(e.slice(c,o),(0,H.jsx)(`mark`,{"data-highlight-match":!0,style:{background:`rgba(${a}, ${r?.22:.3})`,color:`inherit`,borderRadius:3,padding:`0 2px`},children:e.slice(o,u)},o)),c=u)}return s.push(e.slice(c,i)),s},c=[],l=0;if(t)for(let t of e.matchAll(/<\*>||||