@tangle-network/agent-app 0.60.183 → 0.60.185

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/dist/agent-profiles/d1.js +3 -3
  2. package/dist/agent-profiles/index.js +3 -3
  3. package/dist/assistant/index.js +9 -9
  4. package/dist/channels/index.js +1 -1
  5. package/dist/chat-react/index.js +4 -4
  6. package/dist/chat-routes/index.js +4 -4
  7. package/dist/{chunk-YXLN4PXK.js → chunk-2RCPPOQ4.js} +2 -2
  8. package/dist/{chunk-YESFGM56.js → chunk-5IS3GCMR.js} +3 -3
  9. package/dist/{chunk-3RHAF2P5.js → chunk-A3CUVYRZ.js} +3 -3
  10. package/dist/{chunk-LN5RBVGP.js → chunk-AVP5SNIG.js} +4 -4
  11. package/dist/{chunk-LN5RBVGP.js.map → chunk-AVP5SNIG.js.map} +1 -1
  12. package/dist/{chunk-7BYY7QKC.js → chunk-E65YV7VV.js} +5 -5
  13. package/dist/{chunk-7BYY7QKC.js.map → chunk-E65YV7VV.js.map} +1 -1
  14. package/dist/chunk-EZFBGW23.js +179 -0
  15. package/dist/chunk-EZFBGW23.js.map +1 -0
  16. package/dist/{chunk-UDLA3NGY.js → chunk-GNBBY3KN.js} +3 -3
  17. package/dist/{chunk-KOTNMTHV.js → chunk-HCFVEJQL.js} +3 -3
  18. package/dist/{chunk-YGBEGBJY.js → chunk-HEPEGY6Q.js} +2 -2
  19. package/dist/{chunk-AJZ3EJB5.js → chunk-IJAXOQJU.js} +2 -2
  20. package/dist/{chunk-EQRVOMMS.js → chunk-KMIDRUUH.js} +2 -2
  21. package/dist/{chunk-BBHVV37T.js → chunk-MSAGTFN4.js} +4 -4
  22. package/dist/chunk-OBKVNZPH.js +70 -0
  23. package/dist/chunk-OBKVNZPH.js.map +1 -0
  24. package/dist/{chunk-75ZIWV4U.js → chunk-QAF7ZTO3.js} +4 -4
  25. package/dist/{chunk-TJ4DYKF2.js → chunk-XG6FODYO.js} +3 -2
  26. package/dist/chunk-XG6FODYO.js.map +1 -0
  27. package/dist/{chunk-6O2NQ7WD.js → chunk-Y2SOQOJE.js} +3 -3
  28. package/dist/integrations-react/index.js +1 -1
  29. package/dist/{mention-editor-ZJAOUDEE.js → mention-editor-NOS5R3AU.js} +2 -2
  30. package/dist/preset-cloudflare/index.js +2 -2
  31. package/dist/sandbox/index.js +4 -4
  32. package/dist/settings-react/confirm-action.d.ts +51 -0
  33. package/dist/settings-react/delete-workspace-section.d.ts +31 -0
  34. package/dist/settings-react/export-section.d.ts +26 -0
  35. package/dist/settings-react/index.d.ts +20 -0
  36. package/dist/settings-react/index.js +1438 -0
  37. package/dist/settings-react/index.js.map +1 -0
  38. package/dist/settings-react/members-section.d.ts +66 -0
  39. package/dist/settings-react/save-status.d.ts +24 -0
  40. package/dist/settings-react/setting-outcome.d.ts +33 -0
  41. package/dist/settings-react/settings-layout.d.ts +71 -0
  42. package/dist/settings-react/settings-save-bar.d.ts +26 -0
  43. package/dist/settings-react/timezone-picker.d.ts +17 -0
  44. package/dist/settings-react/use-setting-field.d.ts +70 -0
  45. package/dist/stories/settings/settings-backend.d.ts +66 -0
  46. package/dist/stories/settings/settings-demo.d.ts +16 -0
  47. package/dist/stories/settings/team-panels-demo.d.ts +21 -0
  48. package/dist/studio-react/index.js +2 -2
  49. package/dist/teams-react/components/InviteForm.d.ts +2 -2
  50. package/dist/teams-react/components/MembersPanel.d.ts +9 -5
  51. package/dist/teams-react/components/RoleSelect.d.ts +10 -8
  52. package/dist/teams-react/components/invitation-detail.d.ts +8 -0
  53. package/dist/teams-react/components/member-access.d.ts +17 -0
  54. package/dist/teams-react/contracts.d.ts +2 -0
  55. package/dist/teams-react/index.js +119 -242
  56. package/dist/teams-react/index.js.map +1 -1
  57. package/dist/theme/tokens.css +43 -2
  58. package/dist/tools/index.js +4 -4
  59. package/dist/web-react/agent-profile-editor.js +4 -4
  60. package/dist/web-react/async/index.js +1 -1
  61. package/dist/web-react/controls.d.ts +4 -5
  62. package/dist/web-react/index.js +12 -12
  63. package/dist/work-product/index.js +2 -2
  64. package/dist/work-product-react/index.js +3 -3
  65. package/dist/work-product-react/index.js.map +1 -1
  66. package/dist/workspace-export/react.d.ts +26 -0
  67. package/dist/workspace-export/react.js +6 -169
  68. package/dist/workspace-export/react.js.map +1 -1
  69. package/dist/workspace-react/index.js +3 -3
  70. package/package.json +11 -6
  71. package/dist/chunk-TJ4DYKF2.js.map +0 -1
  72. /package/dist/{chunk-YXLN4PXK.js.map → chunk-2RCPPOQ4.js.map} +0 -0
  73. /package/dist/{chunk-YESFGM56.js.map → chunk-5IS3GCMR.js.map} +0 -0
  74. /package/dist/{chunk-3RHAF2P5.js.map → chunk-A3CUVYRZ.js.map} +0 -0
  75. /package/dist/{chunk-UDLA3NGY.js.map → chunk-GNBBY3KN.js.map} +0 -0
  76. /package/dist/{chunk-KOTNMTHV.js.map → chunk-HCFVEJQL.js.map} +0 -0
  77. /package/dist/{chunk-YGBEGBJY.js.map → chunk-HEPEGY6Q.js.map} +0 -0
  78. /package/dist/{chunk-AJZ3EJB5.js.map → chunk-IJAXOQJU.js.map} +0 -0
  79. /package/dist/{chunk-EQRVOMMS.js.map → chunk-KMIDRUUH.js.map} +0 -0
  80. /package/dist/{chunk-BBHVV37T.js.map → chunk-MSAGTFN4.js.map} +0 -0
  81. /package/dist/{chunk-75ZIWV4U.js.map → chunk-QAF7ZTO3.js.map} +0 -0
  82. /package/dist/{chunk-6O2NQ7WD.js.map → chunk-Y2SOQOJE.js.map} +0 -0
  83. /package/dist/{mention-editor-ZJAOUDEE.js.map → mention-editor-NOS5R3AU.js.map} +0 -0
@@ -2,11 +2,11 @@ import {
2
2
  ProfileConflictError,
3
3
  parseProfileRevisionDiff,
4
4
  serializeProfileRevisionDiff
5
- } from "../chunk-KOTNMTHV.js";
5
+ } from "../chunk-HCFVEJQL.js";
6
6
  import "../chunk-I6BZVIRH.js";
7
- import "../chunk-AJZ3EJB5.js";
7
+ import "../chunk-IJAXOQJU.js";
8
8
  import "../chunk-UGWQLQDS.js";
9
- import "../chunk-7BYY7QKC.js";
9
+ import "../chunk-E65YV7VV.js";
10
10
 
11
11
  // src/agent-profiles/d1.ts
12
12
  import { snapshotAgentProfile } from "@tangle-network/agent-interface";
@@ -31,14 +31,14 @@ import {
31
31
  selfMountTable,
32
32
  serializeProfileRevisionDiff,
33
33
  switchProfile
34
- } from "../chunk-KOTNMTHV.js";
34
+ } from "../chunk-HCFVEJQL.js";
35
35
  import {
36
36
  normalizeProfileName,
37
37
  parseProfileSwitch
38
38
  } from "../chunk-I6BZVIRH.js";
39
- import "../chunk-AJZ3EJB5.js";
39
+ import "../chunk-IJAXOQJU.js";
40
40
  import "../chunk-UGWQLQDS.js";
41
- import "../chunk-7BYY7QKC.js";
41
+ import "../chunk-E65YV7VV.js";
42
42
  export {
43
43
  PERMITTED_SELF_MOUNT_DIMENSIONS,
44
44
  PROFILE_CHANGE_POLICY,
@@ -1,32 +1,32 @@
1
1
  import {
2
2
  ReasoningRow,
3
3
  chatToolCallPart
4
- } from "../chunk-6O2NQ7WD.js";
5
- import "../chunk-EQRVOMMS.js";
4
+ } from "../chunk-Y2SOQOJE.js";
6
5
  import "../chunk-3HUFJ5LO.js";
6
+ import "../chunk-KMIDRUUH.js";
7
7
  import "../chunk-FBVLEGEG.js";
8
8
  import "../chunk-Y6PRDUFJ.js";
9
9
  import {
10
10
  ChatComposer
11
- } from "../chunk-BBHVV37T.js";
11
+ } from "../chunk-MSAGTFN4.js";
12
12
  import "../chunk-L7MB2LLM.js";
13
- import "../chunk-UDLA3NGY.js";
13
+ import "../chunk-GNBBY3KN.js";
14
14
  import "../chunk-A2GG4D4A.js";
15
15
  import "../chunk-E4AY62T2.js";
16
16
  import "../chunk-SJWIZT7B.js";
17
- import "../chunk-3RHAF2P5.js";
18
- import "../chunk-YESFGM56.js";
19
- import "../chunk-YGBEGBJY.js";
17
+ import "../chunk-A3CUVYRZ.js";
18
+ import "../chunk-5IS3GCMR.js";
19
+ import "../chunk-HEPEGY6Q.js";
20
20
  import {
21
21
  ModelPicker
22
- } from "../chunk-TJ4DYKF2.js";
22
+ } from "../chunk-XG6FODYO.js";
23
23
  import "../chunk-GEYACSFW.js";
24
24
  import "../chunk-ATQQCG4I.js";
25
25
  import "../chunk-WSEXFTN4.js";
26
26
  import "../chunk-RASGKEAL.js";
27
27
  import {
28
28
  AsyncView
29
- } from "../chunk-LN5RBVGP.js";
29
+ } from "../chunk-AVP5SNIG.js";
30
30
  import "../chunk-FQYAJYPW.js";
31
31
  import "../chunk-WTC6AOPL.js";
32
32
  import "../chunk-VBRUG4N5.js";
@@ -4,7 +4,7 @@ import {
4
4
  confirmWrite,
5
5
  useAsyncResource,
6
6
  useConfirmedMutation
7
- } from "../chunk-LN5RBVGP.js";
7
+ } from "../chunk-AVP5SNIG.js";
8
8
 
9
9
  // src/channels/context.tsx
10
10
  import { createContext, useContext } from "react";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  ComposerModeControls,
3
3
  EntryComposer
4
- } from "../chunk-BBHVV37T.js";
4
+ } from "../chunk-MSAGTFN4.js";
5
5
  import "../chunk-L7MB2LLM.js";
6
6
  import "../chunk-SJWIZT7B.js";
7
- import "../chunk-YESFGM56.js";
8
- import "../chunk-YGBEGBJY.js";
9
- import "../chunk-TJ4DYKF2.js";
7
+ import "../chunk-5IS3GCMR.js";
8
+ import "../chunk-HEPEGY6Q.js";
9
+ import "../chunk-XG6FODYO.js";
10
10
  import "../chunk-RASGKEAL.js";
11
11
  import "../chunk-WTC6AOPL.js";
12
12
  import "../chunk-VBRUG4N5.js";
@@ -46,13 +46,13 @@ import {
46
46
  } from "../chunk-63EKFZOE.js";
47
47
  import "../chunk-VBRUG4N5.js";
48
48
  import "../chunk-LWSJK546.js";
49
- import "../chunk-75ZIWV4U.js";
49
+ import "../chunk-QAF7ZTO3.js";
50
50
  import "../chunk-6A7MYOUI.js";
51
51
  import "../chunk-S5SRJJQG.js";
52
- import "../chunk-YXLN4PXK.js";
53
- import "../chunk-AJZ3EJB5.js";
52
+ import "../chunk-2RCPPOQ4.js";
53
+ import "../chunk-IJAXOQJU.js";
54
54
  import "../chunk-UGWQLQDS.js";
55
- import "../chunk-7BYY7QKC.js";
55
+ import "../chunk-E65YV7VV.js";
56
56
  import {
57
57
  runProtectedRouterTurn
58
58
  } from "../chunk-XJEIGVMQ.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ToolInputError,
3
3
  validateOpenUIJsonNode
4
- } from "./chunk-7BYY7QKC.js";
4
+ } from "./chunk-E65YV7VV.js";
5
5
 
6
6
  // src/tools/render-ui-schema.ts
7
7
  function assertRenderUiSchema(value) {
@@ -14,4 +14,4 @@ function assertRenderUiSchema(value) {
14
14
  export {
15
15
  assertRenderUiSchema
16
16
  };
17
- //# sourceMappingURL=chunk-YXLN4PXK.js.map
17
+ //# sourceMappingURL=chunk-2RCPPOQ4.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  usePopoverDialog
3
- } from "./chunk-YGBEGBJY.js";
3
+ } from "./chunk-HEPEGY6Q.js";
4
4
  import {
5
5
  CheckGlyph,
6
6
  EffortPicker,
@@ -11,7 +11,7 @@ import {
11
11
  pickerRootClass,
12
12
  quietPickerTriggerClass,
13
13
  usePopover
14
- } from "./chunk-TJ4DYKF2.js";
14
+ } from "./chunk-XG6FODYO.js";
15
15
  import {
16
16
  snapHarnessToModel,
17
17
  snapModelToHarness
@@ -576,4 +576,4 @@ export {
576
576
  HarnessPicker,
577
577
  AgentSessionControls
578
578
  };
579
- //# sourceMappingURL=chunk-YESFGM56.js.map
579
+ //# sourceMappingURL=chunk-5IS3GCMR.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  HarnessPicker,
3
3
  filterAcceptedFiles
4
- } from "./chunk-YESFGM56.js";
4
+ } from "./chunk-5IS3GCMR.js";
5
5
  import {
6
6
  EffortPicker,
7
7
  ModelPicker,
@@ -9,7 +9,7 @@ import {
9
9
  POPOVER_OPTION_FOCUS,
10
10
  PopoverSurface,
11
11
  effortLevelsFromIds
12
- } from "./chunk-TJ4DYKF2.js";
12
+ } from "./chunk-XG6FODYO.js";
13
13
  import {
14
14
  isModelCompatibleWithHarness,
15
15
  snapModelToHarness
@@ -2212,4 +2212,4 @@ export {
2212
2212
  AGENT_PROFILE_EDITOR_SECTIONS,
2213
2213
  AgentProfileEditor
2214
2214
  };
2215
- //# sourceMappingURL=chunk-3RHAF2P5.js.map
2215
+ //# sourceMappingURL=chunk-A3CUVYRZ.js.map
@@ -260,12 +260,12 @@ function EmptyBlock({ spec }) {
260
260
  function MutationStatus({ state, labels, className }) {
261
261
  if (state.status === "idle") return null;
262
262
  if (state.status === "pending") {
263
- return /* @__PURE__ */ jsx("span", { role: "status", "aria-live": "polite", "aria-busy": true, className: className ?? "text-xs text-muted-foreground", children: labels?.pending ?? "Saving\u2026" });
263
+ return /* @__PURE__ */ jsx("span", { role: "status", "aria-live": "polite", "aria-busy": true, className: className ?? "text-sm text-muted-foreground", children: labels?.pending ?? "Saving\u2026" });
264
264
  }
265
265
  if (state.status === "succeeded") {
266
- return /* @__PURE__ */ jsx("span", { role: "status", "aria-live": "polite", "aria-busy": false, className: className ?? "text-xs text-muted-foreground", children: labels?.succeeded ?? "Saved" });
266
+ return /* @__PURE__ */ jsx("span", { role: "status", "aria-live": "polite", "aria-busy": false, className: className ?? "text-sm text-muted-foreground", children: labels?.succeeded ?? "Saved" });
267
267
  }
268
- return /* @__PURE__ */ jsx("span", { role: "alert", className: className ?? "text-xs text-destructive", children: state.message });
268
+ return /* @__PURE__ */ jsx("span", { role: "alert", className: className ?? "text-sm text-destructive", children: state.message });
269
269
  }
270
270
 
271
271
  export {
@@ -287,4 +287,4 @@ export {
287
287
  AsyncView,
288
288
  MutationStatus
289
289
  };
290
- //# sourceMappingURL=chunk-LN5RBVGP.js.map
290
+ //# sourceMappingURL=chunk-AVP5SNIG.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/web-react/async/state.ts","../src/web-react/async/use-async-resource.ts","../src/web-react/async/use-confirmed-mutation.ts","../src/web-react/async/async-view.tsx"],"sourcesContent":["/**\n * The fetch-state contract: a failed load cannot render as empty data.\n *\n * Three shapes produce that defect, and two audited verticals shipped dozens of\n * each: a `catch` handler that only clears a loading flag, an early return on a\n * non-ok response, and a bare `null` returned while loading. All three end with\n * the same pixels a successful-but-empty load produces — \"No templates\n * available\", an empty member list, a blank conversation — so the reader cannot\n * tell \"we asked and there is nothing\" from \"we could not ask\", and the retry\n * that would fix it is never offered.\n *\n * `AsyncResourceState` makes the two outcomes separate variants: `error` is the\n * only one carrying a message and it is never reachable with a value, `empty` is\n * the only one carrying a resolved-but-empty value and it never carries a\n * message. A component rendering one is structurally not rendering the other.\n *\n * This file is React-free so the state model, the emptiness rule and the\n * Response readers can be unit-tested and reused outside a component.\n */\n\n/**\n * - `idle` — no load has been attempted (the hook is disabled, or its inputs\n * are not resolved yet). Distinct from `loading`: nothing is in flight.\n * - `loading` — a load is in flight and no value is held.\n * - `error` — the load failed. Carries the message and never a value.\n * - `empty` — the load succeeded and the value is empty. Never carries a message.\n * - `ready` — the load succeeded and the value is non-empty.\n */\nexport type AsyncResourceStatus = 'idle' | 'loading' | 'error' | 'empty' | 'ready'\n\n/** Re-runs the load. Present on every variant so the error branch can never be\n * rendered without the action that recovers from it. */\nexport interface AsyncRetryable {\n readonly retry: () => void\n}\n\nexport type AsyncResourceState<T> =\n | ({ readonly status: 'idle' } & AsyncRetryable)\n | ({ readonly status: 'loading' } & AsyncRetryable)\n | ({ readonly status: 'error'; readonly message: string; readonly error: unknown } & AsyncRetryable)\n | ({ readonly status: 'empty'; readonly value: T } & AsyncRetryable)\n | ({ readonly status: 'ready'; readonly value: T } & AsyncRetryable)\n\n/** The state model without the retry action — what a reducer produces. */\nexport type AsyncResolution<T> =\n | { readonly status: 'idle' }\n | { readonly status: 'loading' }\n | { readonly status: 'error'; readonly message: string; readonly error: unknown }\n | { readonly status: 'empty'; readonly value: T }\n | { readonly status: 'ready'; readonly value: T }\n\nexport const DEFAULT_ASYNC_ERROR_MESSAGE = 'This did not load. Try again.'\n\n/**\n * Default emptiness rule: `null`/`undefined`, an empty array, an empty `Map` or\n * `Set`. A string, a number and a plain object are `ready` — `''` and `{}` are\n * legitimate values for the resources that produce them, and guessing otherwise\n * would route a real answer into the empty branch. Pass `isEmpty` for a shape\n * this cannot see into (`{ items: [] }`, a paged envelope, a count).\n */\nexport function defaultIsEmpty(value: unknown): boolean {\n if (value === null || value === undefined) return true\n if (Array.isArray(value)) return value.length === 0\n if (value instanceof Map || value instanceof Set) return value.size === 0\n return false\n}\n\nfunction hasMessage(value: object): value is { message: unknown } {\n return 'message' in value\n}\n\n/** Best available human-readable message for a thrown value. Never returns an\n * empty string — a blank error block reads as a rendering bug. */\nexport function asyncErrorMessage(error: unknown, fallback: string = DEFAULT_ASYNC_ERROR_MESSAGE): string {\n if (typeof error === 'string' && error.trim() !== '') return error\n if (typeof error === 'object' && error !== null && hasMessage(error)) {\n const message = error.message\n if (typeof message === 'string' && message.trim() !== '') return message\n }\n return fallback\n}\n\n/** Classifies a successfully loaded value into `ready` or `empty`. */\nexport function resolveAsyncValue<T>(value: T, isEmpty: (value: T) => boolean = defaultIsEmpty): AsyncResolution<T> {\n return isEmpty(value) ? { status: 'empty', value } : { status: 'ready', value }\n}\n\n/**\n * A non-ok HTTP response, as a throwable. `requireOk`/`readOkJson` raise this so\n * a non-ok response reaches the `error` branch instead of an early `return` that\n * leaves the caller rendering the empty branch.\n */\nexport class AsyncRequestError extends Error {\n readonly status: number\n readonly statusText: string\n readonly url: string\n /** First 200 characters of the response body when it could be read, else `''`.\n * Kept off `message` so a server's HTML error page never becomes UI copy. */\n readonly body: string\n\n constructor(response: { status: number; statusText?: string; url?: string }, body = '') {\n const statusText = response.statusText ?? ''\n super(`Request failed (${response.status}${statusText ? ` ${statusText}` : ''})`)\n this.name = 'AsyncRequestError'\n this.status = response.status\n this.statusText = statusText\n this.url = response.url ?? ''\n this.body = body\n }\n}\n\nasync function readBodySnippet(response: Response): Promise<string> {\n try {\n return (await response.text()).slice(0, 200)\n } catch {\n // An already-consumed or unreadable body is a missing diagnostic, not a\n // second failure — the status is what the error reports.\n return ''\n }\n}\n\n/** Returns the response when ok; throws `AsyncRequestError` otherwise. Reads the\n * body only on the failure path, so the caller keeps an unconsumed stream. */\nexport async function requireOk(response: Response): Promise<Response> {\n if (response.ok) return response\n throw new AsyncRequestError(response, await readBodySnippet(response))\n}\n\n/**\n * `requireOk` + `response.json()`. Without `parse` the result is `unknown`, so a\n * caller narrows at the JSON boundary rather than inheriting an unchecked shape;\n * with `parse` the validator runs inside the load and a rejection lands in the\n * `error` branch.\n */\nexport async function readOkJson(response: Response): Promise<unknown>\nexport async function readOkJson<T>(response: Response, parse: (data: unknown) => T): Promise<T>\nexport async function readOkJson<T>(response: Response, parse?: (data: unknown) => T): Promise<T | unknown> {\n await requireOk(response)\n let data: unknown\n try {\n data = await response.json()\n } catch (error) {\n throw new Error('The response was not valid JSON.', { cause: error })\n }\n return parse ? parse(data) : data\n}\n","import { useCallback, useEffect, useMemo, useRef, useState } from 'react'\n\nimport {\n asyncErrorMessage,\n defaultIsEmpty,\n resolveAsyncValue,\n type AsyncResolution,\n type AsyncResourceState,\n} from './state'\n\nexport interface AsyncLoadContext {\n /** Aborted when the inputs change, a retry supersedes this load, or the\n * component unmounts. Forward it to `fetch` so a superseded request stops. */\n readonly signal: AbortSignal\n}\n\nexport interface UseAsyncResourceOptions<T> {\n /**\n * The one load. Reject (or throw) to reach the `error` branch — a non-ok\n * response must reject too, which is what `requireOk`/`readOkJson` are for.\n * Read from a ref internally, so an inline arrow does not re-trigger; `deps`\n * is what declares when the load must run again.\n */\n load: (context: AsyncLoadContext) => Promise<T>\n /** Re-runs the load when any entry changes by `Object.is`, like `useEffect`. */\n deps?: readonly unknown[]\n /** `false` holds the resource at `idle` and runs nothing — for inputs that are\n * not resolved yet. Flipping it to `true` starts the load. */\n enabled?: boolean\n /** First-render seed (an SSR/loader page). The hook starts resolved and skips\n * the first load. Read once — later identity changes are ignored, so a\n * revalidating loader belongs in `deps`, not here. */\n initialValue?: T\n /** Splits a successful load into `empty` vs `ready`. Default: `defaultIsEmpty`. */\n isEmpty?: (value: T) => boolean\n /** Maps a thrown value to the message the `error` branch renders. */\n errorMessage?: (error: unknown) => string\n}\n\n/** Bumps a token when any dependency changes identity, so the effect's own\n * dependency list stays a fixed length whatever the caller passes. */\nfunction useChangeToken(deps: readonly unknown[]): number {\n const ref = useRef<{ deps: readonly unknown[]; token: number }>({ deps, token: 0 })\n const changed =\n ref.current.deps.length !== deps.length || deps.some((dep, index) => !Object.is(dep, ref.current.deps[index]))\n if (changed) ref.current = { deps, token: ref.current.token + 1 }\n return ref.current.token\n}\n\nconst NO_DEPS: readonly unknown[] = []\n\n/**\n * The five-state fetch machine: `idle | loading | error | empty | ready`.\n *\n * What it guarantees, and what the hand-rolled versions it replaces did not:\n *\n * - a rejected load lands on `error` with a message and a `retry`, never on an\n * empty list;\n * - `empty` is only reachable from a load that actually succeeded;\n * - a superseded load (inputs changed, retry pressed, component unmounted) is\n * aborted and its late result is discarded; resolutions are bound to their\n * input identity, including the render before the next effect runs.\n */\nexport function useAsyncResource<T>({\n load,\n deps = NO_DEPS,\n enabled = true,\n initialValue,\n isEmpty,\n errorMessage,\n}: UseAsyncResourceOptions<T>): AsyncResourceState<T> {\n // Include enablement and retries in the identity: stale data must not be\n // returned during the render before an effect clears the previous request.\n const [reloadKey, setReloadKey] = useState(0)\n const token = useChangeToken([enabled, reloadKey, ...deps])\n const options = useRef({ load, isEmpty, errorMessage })\n options.current = { load, isEmpty, errorMessage }\n const [settled, setSettled] = useState<{ token: number; resolution: AsyncResolution<T> }>(() => ({\n token,\n resolution: initialValue === undefined\n ? { status: 'loading' }\n : resolveAsyncValue(initialValue, isEmpty ?? defaultIsEmpty),\n }))\n // A seed belongs only to its first identity. Effect replay does not consume\n // it, but a dependency change, re-enable, or explicit retry does.\n const seededToken = useRef(initialValue === undefined ? null : token)\n\n useEffect(() => {\n if (!enabled || seededToken.current === token) return\n const controller = new AbortController()\n const commit = (resolution: AsyncResolution<T>) => {\n if (!controller.signal.aborted) setSettled({ token, resolution })\n }\n commit({ status: 'loading' })\n void (async () => {\n try {\n const value = await options.current.load({ signal: controller.signal })\n if (!controller.signal.aborted) commit(resolveAsyncValue(value, options.current.isEmpty ?? defaultIsEmpty))\n } catch (error) {\n if (!controller.signal.aborted) commit({\n status: 'error',\n message: options.current.errorMessage?.(error) ?? asyncErrorMessage(error),\n error,\n })\n }\n })()\n return () => controller.abort()\n }, [token, enabled])\n\n const retry = useCallback(() => setReloadKey(key => key + 1), [])\n return useMemo<AsyncResourceState<T>>(() => ({\n ...(!enabled ? { status: 'idle' as const }\n : settled.token === token ? settled.resolution : { status: 'loading' as const }),\n retry,\n }), [enabled, settled, token, retry])\n}\n","import { useCallback, useMemo, useRef, useState } from 'react'\n\nimport { asyncErrorMessage, readOkJson, requireOk } from './state'\nimport type { AsyncLoadContext } from './use-async-resource'\n\n/**\n * The brand that makes \"Saved\" unreachable without a confirmed write.\n *\n * A resolved promise is not a success: `fetch` resolves on a 404, and the\n * shipped defect this closes is a save button that rendered \"Saved\" because the\n * only thing awaited was that the request came back at all. The success variant\n * therefore carries a symbol no object literal can spell, so the only way into\n * `succeeded` is `confirmWrite` / `confirmResponse` / `confirmJson` — each of\n * which has already checked that the write landed.\n */\nexport const CONFIRMED_WRITE: unique symbol = Symbol('agent-app.confirmed-write')\n\nexport interface MutationConfirmed<T> {\n readonly succeeded: true\n readonly value: T\n readonly [CONFIRMED_WRITE]: true\n}\n\nexport interface MutationRejected {\n readonly succeeded: false\n /** Safe to render: what the user is told the write did not do. */\n readonly message: string\n readonly error?: unknown\n}\n\nexport type MutationOutcome<T> = MutationConfirmed<T> | MutationRejected\n\n/** Confirms a write whose success is already established (an SDK call that\n * throws on failure, a store returning its own typed outcome). The deliberate\n * act is the point — this call is what an audit greps for. */\nexport function confirmWrite<T>(value: T): MutationConfirmed<T> {\n return { succeeded: true, value, [CONFIRMED_WRITE]: true }\n}\n\n/** A write that did not land. Constructible by hand: failing loud is never the\n * direction that needs guarding. */\nexport function rejectWrite(message: string, error?: unknown): MutationRejected {\n return error === undefined ? { succeeded: false, message } : { succeeded: false, message, error }\n}\n\n/** Confirms only a 2xx response. A 404/500 becomes a rejection carrying the\n * status — never a success, whatever the promise did. */\nexport async function confirmResponse(response: Response): Promise<MutationOutcome<Response>> {\n try {\n return confirmWrite(await requireOk(response))\n } catch (error) {\n return rejectWrite(asyncErrorMessage(error), error)\n }\n}\n\n/** `confirmResponse` + a JSON body. A non-ok status, an unreadable body and a\n * throwing `parse` are all rejections. */\nexport async function confirmJson<T>(response: Response, parse: (data: unknown) => T): Promise<MutationOutcome<T>> {\n try {\n return confirmWrite(await readOkJson(response, parse))\n } catch (error) {\n return rejectWrite(asyncErrorMessage(error), error)\n }\n}\n\n/** True only for a value built by one of the confirm helpers. Takes `unknown`\n * because an untyped consumer can return anything from `mutate`. */\nexport function isConfirmedWrite<T>(outcome: unknown): outcome is MutationConfirmed<T> {\n if (typeof outcome !== 'object' || outcome === null) return false\n return (outcome as { readonly [CONFIRMED_WRITE]?: unknown })[CONFIRMED_WRITE] === true\n}\n\nfunction asRejection(outcome: unknown): MutationRejected | null {\n if (typeof outcome !== 'object' || outcome === null) return null\n const candidate = outcome as { succeeded?: unknown; message?: unknown; error?: unknown }\n if (candidate.succeeded !== false) return null\n const message = typeof candidate.message === 'string' && candidate.message.trim() !== ''\n ? candidate.message\n : UNCONFIRMED_MESSAGE\n return rejectWrite(message, candidate.error)\n}\n\nexport type MutationState<T> =\n | { readonly status: 'idle' }\n | { readonly status: 'pending' }\n | { readonly status: 'succeeded'; readonly value: T }\n | { readonly status: 'failed'; readonly message: string; readonly error: unknown }\n\nexport interface UseConfirmedMutationOptions<TInput, TValue> {\n /** Default replaces the observed run. `reject` keeps the current request\n * and refuses another invocation before any second write can start. */\n concurrency?: 'replace' | 'reject'\n /**\n * Performs the write and returns a confirmation. Anything else — including a\n * hand-written `{ succeeded: true }` — is treated as a failed write, because\n * an unbranded object is exactly the shape produced by code that never\n * checked the response.\n *\n * The context signal aborts only when a later `run` supersedes this one. It is\n * NOT aborted on unmount: a write the user asked for must not be cancelled by\n * navigating away.\n */\n mutate: (input: TInput, context: AsyncLoadContext) => Promise<MutationOutcome<TValue>>\n /** Fires after the state reaches `succeeded` (latest run only). */\n onSucceeded?: (value: TValue) => void\n /** Fires after the state reaches `failed` (latest run only). */\n onFailed?: (message: string, error: unknown) => void\n /** Maps a thrown value to the message the `failed` state renders. */\n errorMessage?: (error: unknown) => string\n}\n\nexport interface ConfirmedMutation<TInput, TValue> {\n readonly state: MutationState<TValue>\n /** Runs the write. Never rejects — the outcome is returned and mirrored into\n * `state`. Concurrent runs are last-write-wins unless `concurrency: 'reject'`\n * is configured. Server-side idempotency is still required. */\n readonly run: (input: TInput) => Promise<MutationOutcome<TValue>>\n /** Back to `idle` (dismisses a \"Saved\" or error affordance). */\n readonly reset: () => void\n}\n\nconst UNCONFIRMED_MESSAGE = 'The write could not be confirmed.'\n\nconst UNCONFIRMED_CONTRACT =\n 'mutate() resolved without a confirmation. Return confirmWrite(value), confirmResponse(response) or confirmJson(response, parse) so the success state proves the write landed.'\n\n/**\n * `idle | pending | succeeded | failed` over a write that must confirm itself.\n *\n * `succeeded` is reachable only through a branded confirmation, so the audited\n * \"Saved on a 404\" bug cannot be written with this hook: the 404 path produces\n * `failed` carrying the status, and a `mutate` that forgot to check produces\n * `failed` carrying the contract violation rather than a success it never\n * earned.\n */\nexport function useConfirmedMutation<TInput, TValue>({\n mutate,\n onSucceeded,\n onFailed,\n errorMessage,\n concurrency = 'replace',\n}: UseConfirmedMutationOptions<TInput, TValue>): ConfirmedMutation<TInput, TValue> {\n const options = useRef({ mutate, onSucceeded, onFailed, errorMessage, concurrency })\n options.current = { mutate, onSucceeded, onFailed, errorMessage, concurrency }\n\n const [state, setState] = useState<MutationState<TValue>>({ status: 'idle' })\n const seqRef = useRef(0)\n const inFlightRef = useRef<{ controller: AbortController; pending: boolean } | null>(null)\n\n const run = useCallback(async (input: TInput): Promise<MutationOutcome<TValue>> => {\n if (options.current.concurrency === 'reject' && inFlightRef.current?.pending)\n return rejectWrite('Another operation is still in progress.')\n inFlightRef.current?.controller.abort()\n const controller = new AbortController()\n inFlightRef.current = { controller, pending: true }\n const seq = ++seqRef.current\n\n setState({ status: 'pending' })\n\n let outcome: MutationOutcome<TValue>\n try {\n const returned: unknown = await options.current.mutate(input, { signal: controller.signal })\n outcome = isConfirmedWrite<TValue>(returned)\n ? returned\n : asRejection(returned) ?? rejectWrite(UNCONFIRMED_MESSAGE, new Error(UNCONFIRMED_CONTRACT))\n } catch (error) {\n outcome = rejectWrite(options.current.errorMessage?.(error) ?? asyncErrorMessage(error), error)\n }\n\n // A superseded run reports its own outcome to its own caller and never\n // repaints the state a newer run owns.\n if (seq !== seqRef.current) return outcome\n if (inFlightRef.current) inFlightRef.current.pending = false\n\n if (outcome.succeeded) {\n setState({ status: 'succeeded', value: outcome.value })\n options.current.onSucceeded?.(outcome.value)\n } else {\n setState({ status: 'failed', message: outcome.message, error: outcome.error })\n options.current.onFailed?.(outcome.message, outcome.error)\n }\n return outcome\n }, [])\n\n const reset = useCallback(() => {\n seqRef.current += 1\n inFlightRef.current?.controller.abort()\n inFlightRef.current = null\n setState({ status: 'idle' })\n }, [])\n\n return useMemo(() => ({ state, run, reset }), [state, run, reset])\n}\n","import { isValidElement, type ReactElement, type ReactNode } from 'react'\n\nimport { Button, EmptyState } from '@tangle-network/ui/primitives'\n\nimport type { AsyncResourceState } from './state'\nimport type { MutationState } from './use-confirmed-mutation'\n\nexport interface AsyncEmptyAction {\n label: string\n onClick: () => void\n}\n\nexport interface AsyncEmptySpec {\n /** What is not there, in the reader's words (\"No templates yet\"). Required:\n * an empty state with nothing to say is the state this module exists to\n * stop being mistaken for a failure. */\n title: string\n description?: string\n /** The next action. An element is rendered as supplied (a link, a dialog\n * trigger); the object form renders the standard button. */\n action?: AsyncEmptyAction | ReactElement\n}\n\nexport interface AsyncErrorRenderProps {\n message: string\n retry: () => void\n}\n\nexport interface AsyncViewProps<T> {\n state: AsyncResourceState<T>\n /** Rendered only for `ready`, with the loaded value — the branch cannot be\n * entered without one. */\n children: (value: T) => ReactNode\n /** Required: `empty` must name what is missing and what to do about it. */\n empty: AsyncEmptySpec | ReactElement\n /** Must return an element. Returning nothing is what produced the blank\n * screens this component replaces, so a nullish return falls back to the\n * built-in block rather than rendering nothing. */\n renderLoading?: () => ReactElement\n renderError?: (props: AsyncErrorRenderProps) => ReactElement\n /** `idle` renders the loading block by default — from the reader's side,\n * \"not started\" and \"in flight\" are the same wait. */\n renderIdle?: () => ReactElement\n loadingLabel?: string\n retryLabel?: string\n /** Applied to the wrapper around the non-`ready` branches. `ready` renders the\n * children with no wrapper element, so grids and lists keep their layout. */\n className?: string\n}\n\nconst BLOCK_CLASS = 'flex flex-col items-center justify-center gap-2 px-4 py-10 text-center'\n\n/**\n * Renders the branch the state is actually in.\n *\n * The three anti-patterns this replaces (`catch` that only clears a loading\n * flag, early return on a non-ok response, bare `null` while loading) all end at\n * the same rendered output as a successful-but-empty load. Here every branch is\n * reached from a different variant and each renders visibly: `loading` and\n * `idle` render a labelled busy block, `error` renders the message plus the\n * retry, `empty` renders the caller's copy and next action, and `ready` is the\n * only branch with a value to hand to `children`.\n */\nexport function AsyncView<T>({\n state,\n children,\n empty,\n renderLoading,\n renderError,\n renderIdle,\n loadingLabel = 'Loading…',\n retryLabel = 'Retry',\n className,\n}: AsyncViewProps<T>): ReactElement {\n if (state.status === 'ready') return <>{children(state.value)}</>\n\n // Every `??` here is the guarantee: a custom renderer that returns nothing\n // leaves the reader with the built-in block, never a blank region.\n const branch = (): ReactNode => {\n switch (state.status) {\n case 'idle':\n return renderIdle?.() ?? <LoadingBlock label={loadingLabel} />\n case 'loading':\n return renderLoading?.() ?? <LoadingBlock label={loadingLabel} />\n case 'error':\n return (\n renderError?.({ message: state.message, retry: state.retry }) ?? (\n <ErrorBlock message={state.message} retry={state.retry} retryLabel={retryLabel} />\n )\n )\n case 'empty':\n if (isValidElement(empty)) return empty\n return typeof empty === 'object' && empty !== null && typeof empty.title === 'string' ? (\n <EmptyBlock spec={empty} />\n ) : (\n <EmptyBlock spec={{ title: 'Nothing here yet.' }} />\n )\n }\n }\n\n // The busy signal lives on the WRAPPER, not inside the loading block, for the\n // same reason every `??` above exists: `renderLoading` is an escape hatch, and\n // a caller filling it with their own spinner would otherwise take the\n // announcement with them — a screen reader would hear nothing for exactly the\n // products that styled their wait state. The wrapper wraps every non-`ready`\n // branch, so it cannot be opted out of.\n //\n // `aria-busy` is emitted in BOTH states rather than only while loading: a\n // region that gains the attribute at the moment it goes busy, and drops it on\n // arrival, gives assistive tech no transition to report. The `error` branch\n // keeps its own `role=\"alert\"` and takes no live region here, because nesting\n // one inside another is what produces a doubled announcement.\n const busy = state.status === 'loading' || state.status === 'idle'\n const failed = state.status === 'error'\n return (\n <div\n data-async-state={state.status}\n className={className}\n role={failed ? undefined : 'status'}\n aria-live={failed ? undefined : 'polite'}\n aria-busy={busy}\n >\n {branch()}\n </div>\n )\n}\n\nfunction LoadingBlock({ label }: { label: string }): ReactElement {\n return (\n <div className={BLOCK_CLASS}>\n <span className=\"text-sm text-muted-foreground\">{label}</span>\n </div>\n )\n}\n\nfunction ErrorBlock({\n message,\n retry,\n retryLabel,\n}: {\n message: string\n retry: () => void\n retryLabel: string\n}): ReactElement {\n return (\n <div role=\"alert\" className={BLOCK_CLASS}>\n <p className=\"max-w-md text-sm text-muted-foreground\">{message}</p>\n <Button type=\"button\" variant=\"outline\" size=\"sm\" onClick={retry}>{retryLabel}</Button>\n </div>\n )\n}\n\nfunction EmptyBlock({ spec }: { spec: AsyncEmptySpec }): ReactElement {\n const action = spec.action\n return <EmptyState title={spec.title} description={spec.description} action={\n isValidElement(action) ? action : action ? <Button type=\"button\" variant=\"outline\" size=\"sm\" onClick={(action as AsyncEmptyAction).onClick}>{(action as AsyncEmptyAction).label}</Button> : undefined\n } />\n}\n\nexport interface MutationStatusLabels {\n pending?: string\n succeeded?: string\n}\n\nexport interface MutationStatusProps<T> {\n state: MutationState<T>\n labels?: MutationStatusLabels\n className?: string\n}\n\n/**\n * The write's own status line. \"Saved\" renders only from `succeeded`, which\n * `useConfirmedMutation` can only reach through a confirmed write, so the label\n * cannot appear over a failed request.\n */\nexport function MutationStatus<T>({ state, labels, className }: MutationStatusProps<T>): ReactElement | null {\n if (state.status === 'idle') return null\n if (state.status === 'pending') {\n return (\n <span role=\"status\" aria-live=\"polite\" aria-busy={true} className={className ?? 'text-xs text-muted-foreground'}>\n {labels?.pending ?? 'Saving…'}\n </span>\n )\n }\n if (state.status === 'succeeded') {\n return (\n <span role=\"status\" aria-live=\"polite\" aria-busy={false} className={className ?? 'text-xs text-muted-foreground'}>\n {labels?.succeeded ?? 'Saved'}\n </span>\n )\n }\n return (\n <span role=\"alert\" className={className ?? 'text-xs text-destructive'}>\n {state.message}\n </span>\n )\n}\n"],"mappings":";AAmDO,IAAM,8BAA8B;AASpC,SAAS,eAAe,OAAyB;AACtD,MAAI,UAAU,QAAQ,UAAU,OAAW,QAAO;AAClD,MAAI,MAAM,QAAQ,KAAK,EAAG,QAAO,MAAM,WAAW;AAClD,MAAI,iBAAiB,OAAO,iBAAiB,IAAK,QAAO,MAAM,SAAS;AACxE,SAAO;AACT;AAEA,SAAS,WAAW,OAA8C;AAChE,SAAO,aAAa;AACtB;AAIO,SAAS,kBAAkB,OAAgB,WAAmB,6BAAqC;AACxG,MAAI,OAAO,UAAU,YAAY,MAAM,KAAK,MAAM,GAAI,QAAO;AAC7D,MAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,WAAW,KAAK,GAAG;AACpE,UAAM,UAAU,MAAM;AACtB,QAAI,OAAO,YAAY,YAAY,QAAQ,KAAK,MAAM,GAAI,QAAO;AAAA,EACnE;AACA,S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AQ,WAAU,MAAK,MAAK,SAAU,OAA4B,SAAW,iBAA4B,OAAM,IAAY,QAC5L;AACJ;AAkBO,SAAS,eAAkB,EAAE,OAAO,QAAQ,UAAU,GAAgD;AAC3G,MAAI,MAAM,WAAW,OAAQ,QAAO;AACpC,MAAI,MAAM,WAAW,WAAW;AAC9B,WACE,oBAAC,UAAK,MAAK,UAAS,aAAU,UAAS,aAAW,MAAM,WAAW,aAAa,iCAC7E,kBAAQ,WAAW,gBACtB;AAAA,EAEJ;AACA,MAAI,MAAM,WAAW,aAAa;AAChC,WACE,oBAAC,UAAK,MAAK,UAAS,aAAU,UAAS,aAAW,OAAO,WAAW,aAAa,iCAC9E,kBAAQ,aAAa,SACxB;AAAA,EAEJ;AACA,SACE,oBAAC,UAAK,MAAK,SAAQ,WAAW,aAAa,4BACxC,gBAAM,SACT;AAEJ;","names":["useCallback","useMemo","useRef","useState","useRef","useState","useCallback","useMemo"]}
1
+ {"version":3,"sources":["../src/web-react/async/state.ts","../src/web-react/async/use-async-resource.ts","../src/web-react/async/use-confirmed-mutation.ts","../src/web-react/async/async-view.tsx"],"sourcesContent":["/**\n * The fetch-state contract: a failed load cannot render as empty data.\n *\n * Three shapes produce that defect, and two audited verticals shipped dozens of\n * each: a `catch` handler that only clears a loading flag, an early return on a\n * non-ok response, and a bare `null` returned while loading. All three end with\n * the same pixels a successful-but-empty load produces — \"No templates\n * available\", an empty member list, a blank conversation — so the reader cannot\n * tell \"we asked and there is nothing\" from \"we could not ask\", and the retry\n * that would fix it is never offered.\n *\n * `AsyncResourceState` makes the two outcomes separate variants: `error` is the\n * only one carrying a message and it is never reachable with a value, `empty` is\n * the only one carrying a resolved-but-empty value and it never carries a\n * message. A component rendering one is structurally not rendering the other.\n *\n * This file is React-free so the state model, the emptiness rule and the\n * Response readers can be unit-tested and reused outside a component.\n */\n\n/**\n * - `idle` — no load has been attempted (the hook is disabled, or its inputs\n * are not resolved yet). Distinct from `loading`: nothing is in flight.\n * - `loading` — a load is in flight and no value is held.\n * - `error` — the load failed. Carries the message and never a value.\n * - `empty` — the load succeeded and the value is empty. Never carries a message.\n * - `ready` — the load succeeded and the value is non-empty.\n */\nexport type AsyncResourceStatus = 'idle' | 'loading' | 'error' | 'empty' | 'ready'\n\n/** Re-runs the load. Present on every variant so the error branch can never be\n * rendered without the action that recovers from it. */\nexport interface AsyncRetryable {\n readonly retry: () => void\n}\n\nexport type AsyncResourceState<T> =\n | ({ readonly status: 'idle' } & AsyncRetryable)\n | ({ readonly status: 'loading' } & AsyncRetryable)\n | ({ readonly status: 'error'; readonly message: string; readonly error: unknown } & AsyncRetryable)\n | ({ readonly status: 'empty'; readonly value: T } & AsyncRetryable)\n | ({ readonly status: 'ready'; readonly value: T } & AsyncRetryable)\n\n/** The state model without the retry action — what a reducer produces. */\nexport type AsyncResolution<T> =\n | { readonly status: 'idle' }\n | { readonly status: 'loading' }\n | { readonly status: 'error'; readonly message: string; readonly error: unknown }\n | { readonly status: 'empty'; readonly value: T }\n | { readonly status: 'ready'; readonly value: T }\n\nexport const DEFAULT_ASYNC_ERROR_MESSAGE = 'This did not load. Try again.'\n\n/**\n * Default emptiness rule: `null`/`undefined`, an empty array, an empty `Map` or\n * `Set`. A string, a number and a plain object are `ready` — `''` and `{}` are\n * legitimate values for the resources that produce them, and guessing otherwise\n * would route a real answer into the empty branch. Pass `isEmpty` for a shape\n * this cannot see into (`{ items: [] }`, a paged envelope, a count).\n */\nexport function defaultIsEmpty(value: unknown): boolean {\n if (value === null || value === undefined) return true\n if (Array.isArray(value)) return value.length === 0\n if (value instanceof Map || value instanceof Set) return value.size === 0\n return false\n}\n\nfunction hasMessage(value: object): value is { message: unknown } {\n return 'message' in value\n}\n\n/** Best available human-readable message for a thrown value. Never returns an\n * empty string — a blank error block reads as a rendering bug. */\nexport function asyncErrorMessage(error: unknown, fallback: string = DEFAULT_ASYNC_ERROR_MESSAGE): string {\n if (typeof error === 'string' && error.trim() !== '') return error\n if (typeof error === 'object' && error !== null && hasMessage(error)) {\n const message = error.message\n if (typeof message === 'string' && message.trim() !== '') return message\n }\n return fallback\n}\n\n/** Classifies a successfully loaded value into `ready` or `empty`. */\nexport function resolveAsyncValue<T>(value: T, isEmpty: (value: T) => boolean = defaultIsEmpty): AsyncResolution<T> {\n return isEmpty(value) ? { status: 'empty', value } : { status: 'ready', value }\n}\n\n/**\n * A non-ok HTTP response, as a throwable. `requireOk`/`readOkJson` raise this so\n * a non-ok response reaches the `error` branch instead of an early `return` that\n * leaves the caller rendering the empty branch.\n */\nexport class AsyncRequestError extends Error {\n readonly status: number\n readonly statusText: string\n readonly url: string\n /** First 200 characters of the response body when it could be read, else `''`.\n * Kept off `message` so a server's HTML error page never becomes UI copy. */\n readonly body: string\n\n constructor(response: { status: number; statusText?: string; url?: string }, body = '') {\n const statusText = response.statusText ?? ''\n super(`Request failed (${response.status}${statusText ? ` ${statusText}` : ''})`)\n this.name = 'AsyncRequestError'\n this.status = response.status\n this.statusText = statusText\n this.url = response.url ?? ''\n this.body = body\n }\n}\n\nasync function readBodySnippet(response: Response): Promise<string> {\n try {\n return (await response.text()).slice(0, 200)\n } catch {\n // An already-consumed or unreadable body is a missing diagnostic, not a\n // second failure — the status is what the error reports.\n return ''\n }\n}\n\n/** Returns the response when ok; throws `AsyncRequestError` otherwise. Reads the\n * body only on the failure path, so the caller keeps an unconsumed stream. */\nexport async function requireOk(response: Response): Promise<Response> {\n if (response.ok) return response\n throw new AsyncRequestError(response, await readBodySnippet(response))\n}\n\n/**\n * `requireOk` + `response.json()`. Without `parse` the result is `unknown`, so a\n * caller narrows at the JSON boundary rather than inheriting an unchecked shape;\n * with `parse` the validator runs inside the load and a rejection lands in the\n * `error` branch.\n */\nexport async function readOkJson(response: Response): Promise<unknown>\nexport async function readOkJson<T>(response: Response, parse: (data: unknown) => T): Promise<T>\nexport async function readOkJson<T>(response: Response, parse?: (data: unknown) => T): Promise<T | unknown> {\n await requireOk(response)\n let data: unknown\n try {\n data = await response.json()\n } catch (error) {\n throw new Error('The response was not valid JSON.', { cause: error })\n }\n return parse ? parse(data) : data\n}\n","import { useCallback, useEffect, useMemo, useRef, useState } from 'react'\n\nimport {\n asyncErrorMessage,\n defaultIsEmpty,\n resolveAsyncValue,\n type AsyncResolution,\n type AsyncResourceState,\n} from './state'\n\nexport interface AsyncLoadContext {\n /** Aborted when the inputs change, a retry supersedes this load, or the\n * component unmounts. Forward it to `fetch` so a superseded request stops. */\n readonly signal: AbortSignal\n}\n\nexport interface UseAsyncResourceOptions<T> {\n /**\n * The one load. Reject (or throw) to reach the `error` branch — a non-ok\n * response must reject too, which is what `requireOk`/`readOkJson` are for.\n * Read from a ref internally, so an inline arrow does not re-trigger; `deps`\n * is what declares when the load must run again.\n */\n load: (context: AsyncLoadContext) => Promise<T>\n /** Re-runs the load when any entry changes by `Object.is`, like `useEffect`. */\n deps?: readonly unknown[]\n /** `false` holds the resource at `idle` and runs nothing — for inputs that are\n * not resolved yet. Flipping it to `true` starts the load. */\n enabled?: boolean\n /** First-render seed (an SSR/loader page). The hook starts resolved and skips\n * the first load. Read once — later identity changes are ignored, so a\n * revalidating loader belongs in `deps`, not here. */\n initialValue?: T\n /** Splits a successful load into `empty` vs `ready`. Default: `defaultIsEmpty`. */\n isEmpty?: (value: T) => boolean\n /** Maps a thrown value to the message the `error` branch renders. */\n errorMessage?: (error: unknown) => string\n}\n\n/** Bumps a token when any dependency changes identity, so the effect's own\n * dependency list stays a fixed length whatever the caller passes. */\nfunction useChangeToken(deps: readonly unknown[]): number {\n const ref = useRef<{ deps: readonly unknown[]; token: number }>({ deps, token: 0 })\n const changed =\n ref.current.deps.length !== deps.length || deps.some((dep, index) => !Object.is(dep, ref.current.deps[index]))\n if (changed) ref.current = { deps, token: ref.current.token + 1 }\n return ref.current.token\n}\n\nconst NO_DEPS: readonly unknown[] = []\n\n/**\n * The five-state fetch machine: `idle | loading | error | empty | ready`.\n *\n * What it guarantees, and what the hand-rolled versions it replaces did not:\n *\n * - a rejected load lands on `error` with a message and a `retry`, never on an\n * empty list;\n * - `empty` is only reachable from a load that actually succeeded;\n * - a superseded load (inputs changed, retry pressed, component unmounted) is\n * aborted and its late result is discarded; resolutions are bound to their\n * input identity, including the render before the next effect runs.\n */\nexport function useAsyncResource<T>({\n load,\n deps = NO_DEPS,\n enabled = true,\n initialValue,\n isEmpty,\n errorMessage,\n}: UseAsyncResourceOptions<T>): AsyncResourceState<T> {\n // Include enablement and retries in the identity: stale data must not be\n // returned during the render before an effect clears the previous request.\n const [reloadKey, setReloadKey] = useState(0)\n const token = useChangeToken([enabled, reloadKey, ...deps])\n const options = useRef({ load, isEmpty, errorMessage })\n options.current = { load, isEmpty, errorMessage }\n const [settled, setSettled] = useState<{ token: number; resolution: AsyncResolution<T> }>(() => ({\n token,\n resolution: initialValue === undefined\n ? { status: 'loading' }\n : resolveAsyncValue(initialValue, isEmpty ?? defaultIsEmpty),\n }))\n // A seed belongs only to its first identity. Effect replay does not consume\n // it, but a dependency change, re-enable, or explicit retry does.\n const seededToken = useRef(initialValue === undefined ? null : token)\n\n useEffect(() => {\n if (!enabled || seededToken.current === token) return\n const controller = new AbortController()\n const commit = (resolution: AsyncResolution<T>) => {\n if (!controller.signal.aborted) setSettled({ token, resolution })\n }\n commit({ status: 'loading' })\n void (async () => {\n try {\n const value = await options.current.load({ signal: controller.signal })\n if (!controller.signal.aborted) commit(resolveAsyncValue(value, options.current.isEmpty ?? defaultIsEmpty))\n } catch (error) {\n if (!controller.signal.aborted) commit({\n status: 'error',\n message: options.current.errorMessage?.(error) ?? asyncErrorMessage(error),\n error,\n })\n }\n })()\n return () => controller.abort()\n }, [token, enabled])\n\n const retry = useCallback(() => setReloadKey(key => key + 1), [])\n return useMemo<AsyncResourceState<T>>(() => ({\n ...(!enabled ? { status: 'idle' as const }\n : settled.token === token ? settled.resolution : { status: 'loading' as const }),\n retry,\n }), [enabled, settled, token, retry])\n}\n","import { useCallback, useMemo, useRef, useState } from 'react'\n\nimport { asyncErrorMessage, readOkJson, requireOk } from './state'\nimport type { AsyncLoadContext } from './use-async-resource'\n\n/**\n * The brand that makes \"Saved\" unreachable without a confirmed write.\n *\n * A resolved promise is not a success: `fetch` resolves on a 404, and the\n * shipped defect this closes is a save button that rendered \"Saved\" because the\n * only thing awaited was that the request came back at all. The success variant\n * therefore carries a symbol no object literal can spell, so the only way into\n * `succeeded` is `confirmWrite` / `confirmResponse` / `confirmJson` — each of\n * which has already checked that the write landed.\n */\nexport const CONFIRMED_WRITE: unique symbol = Symbol('agent-app.confirmed-write')\n\nexport interface MutationConfirmed<T> {\n readonly succeeded: true\n readonly value: T\n readonly [CONFIRMED_WRITE]: true\n}\n\nexport interface MutationRejected {\n readonly succeeded: false\n /** Safe to render: what the user is told the write did not do. */\n readonly message: string\n readonly error?: unknown\n}\n\nexport type MutationOutcome<T> = MutationConfirmed<T> | MutationRejected\n\n/** Confirms a write whose success is already established (an SDK call that\n * throws on failure, a store returning its own typed outcome). The deliberate\n * act is the point — this call is what an audit greps for. */\nexport function confirmWrite<T>(value: T): MutationConfirmed<T> {\n return { succeeded: true, value, [CONFIRMED_WRITE]: true }\n}\n\n/** A write that did not land. Constructible by hand: failing loud is never the\n * direction that needs guarding. */\nexport function rejectWrite(message: string, error?: unknown): MutationRejected {\n return error === undefined ? { succeeded: false, message } : { succeeded: false, message, error }\n}\n\n/** Confirms only a 2xx response. A 404/500 becomes a rejection carrying the\n * status — never a success, whatever the promise did. */\nexport async function confirmResponse(response: Response): Promise<MutationOutcome<Response>> {\n try {\n return confirmWrite(await requireOk(response))\n } catch (error) {\n return rejectWrite(asyncErrorMessage(error), error)\n }\n}\n\n/** `confirmResponse` + a JSON body. A non-ok status, an unreadable body and a\n * throwing `parse` are all rejections. */\nexport async function confirmJson<T>(response: Response, parse: (data: unknown) => T): Promise<MutationOutcome<T>> {\n try {\n return confirmWrite(await readOkJson(response, parse))\n } catch (error) {\n return rejectWrite(asyncErrorMessage(error), error)\n }\n}\n\n/** True only for a value built by one of the confirm helpers. Takes `unknown`\n * because an untyped consumer can return anything from `mutate`. */\nexport function isConfirmedWrite<T>(outcome: unknown): outcome is MutationConfirmed<T> {\n if (typeof outcome !== 'object' || outcome === null) return false\n return (outcome as { readonly [CONFIRMED_WRITE]?: unknown })[CONFIRMED_WRITE] === true\n}\n\nfunction asRejection(outcome: unknown): MutationRejected | null {\n if (typeof outcome !== 'object' || outcome === null) return null\n const candidate = outcome as { succeeded?: unknown; message?: unknown; error?: unknown }\n if (candidate.succeeded !== false) return null\n const message = typeof candidate.message === 'string' && candidate.message.trim() !== ''\n ? candidate.message\n : UNCONFIRMED_MESSAGE\n return rejectWrite(message, candidate.error)\n}\n\nexport type MutationState<T> =\n | { readonly status: 'idle' }\n | { readonly status: 'pending' }\n | { readonly status: 'succeeded'; readonly value: T }\n | { readonly status: 'failed'; readonly message: string; readonly error: unknown }\n\nexport interface UseConfirmedMutationOptions<TInput, TValue> {\n /** Default replaces the observed run. `reject` keeps the current request\n * and refuses another invocation before any second write can start. */\n concurrency?: 'replace' | 'reject'\n /**\n * Performs the write and returns a confirmation. Anything else — including a\n * hand-written `{ succeeded: true }` — is treated as a failed write, because\n * an unbranded object is exactly the shape produced by code that never\n * checked the response.\n *\n * The context signal aborts only when a later `run` supersedes this one. It is\n * NOT aborted on unmount: a write the user asked for must not be cancelled by\n * navigating away.\n */\n mutate: (input: TInput, context: AsyncLoadContext) => Promise<MutationOutcome<TValue>>\n /** Fires after the state reaches `succeeded` (latest run only). */\n onSucceeded?: (value: TValue) => void\n /** Fires after the state reaches `failed` (latest run only). */\n onFailed?: (message: string, error: unknown) => void\n /** Maps a thrown value to the message the `failed` state renders. */\n errorMessage?: (error: unknown) => string\n}\n\nexport interface ConfirmedMutation<TInput, TValue> {\n readonly state: MutationState<TValue>\n /** Runs the write. Never rejects — the outcome is returned and mirrored into\n * `state`. Concurrent runs are last-write-wins unless `concurrency: 'reject'`\n * is configured. Server-side idempotency is still required. */\n readonly run: (input: TInput) => Promise<MutationOutcome<TValue>>\n /** Back to `idle` (dismisses a \"Saved\" or error affordance). */\n readonly reset: () => void\n}\n\nconst UNCONFIRMED_MESSAGE = 'The write could not be confirmed.'\n\nconst UNCONFIRMED_CONTRACT =\n 'mutate() resolved without a confirmation. Return confirmWrite(value), confirmResponse(response) or confirmJson(response, parse) so the success state proves the write landed.'\n\n/**\n * `idle | pending | succeeded | failed` over a write that must confirm itself.\n *\n * `succeeded` is reachable only through a branded confirmation, so the audited\n * \"Saved on a 404\" bug cannot be written with this hook: the 404 path produces\n * `failed` carrying the status, and a `mutate` that forgot to check produces\n * `failed` carrying the contract violation rather than a success it never\n * earned.\n */\nexport function useConfirmedMutation<TInput, TValue>({\n mutate,\n onSucceeded,\n onFailed,\n errorMessage,\n concurrency = 'replace',\n}: UseConfirmedMutationOptions<TInput, TValue>): ConfirmedMutation<TInput, TValue> {\n const options = useRef({ mutate, onSucceeded, onFailed, errorMessage, concurrency })\n options.current = { mutate, onSucceeded, onFailed, errorMessage, concurrency }\n\n const [state, setState] = useState<MutationState<TValue>>({ status: 'idle' })\n const seqRef = useRef(0)\n const inFlightRef = useRef<{ controller: AbortController; pending: boolean } | null>(null)\n\n const run = useCallback(async (input: TInput): Promise<MutationOutcome<TValue>> => {\n if (options.current.concurrency === 'reject' && inFlightRef.current?.pending)\n return rejectWrite('Another operation is still in progress.')\n inFlightRef.current?.controller.abort()\n const controller = new AbortController()\n inFlightRef.current = { controller, pending: true }\n const seq = ++seqRef.current\n\n setState({ status: 'pending' })\n\n let outcome: MutationOutcome<TValue>\n try {\n const returned: unknown = await options.current.mutate(input, { signal: controller.signal })\n outcome = isConfirmedWrite<TValue>(returned)\n ? returned\n : asRejection(returned) ?? rejectWrite(UNCONFIRMED_MESSAGE, new Error(UNCONFIRMED_CONTRACT))\n } catch (error) {\n outcome = rejectWrite(options.current.errorMessage?.(error) ?? asyncErrorMessage(error), error)\n }\n\n // A superseded run reports its own outcome to its own caller and never\n // repaints the state a newer run owns.\n if (seq !== seqRef.current) return outcome\n if (inFlightRef.current) inFlightRef.current.pending = false\n\n if (outcome.succeeded) {\n setState({ status: 'succeeded', value: outcome.value })\n options.current.onSucceeded?.(outcome.value)\n } else {\n setState({ status: 'failed', message: outcome.message, error: outcome.error })\n options.current.onFailed?.(outcome.message, outcome.error)\n }\n return outcome\n }, [])\n\n const reset = useCallback(() => {\n seqRef.current += 1\n inFlightRef.current?.controller.abort()\n inFlightRef.current = null\n setState({ status: 'idle' })\n }, [])\n\n return useMemo(() => ({ state, run, reset }), [state, run, reset])\n}\n","import { isValidElement, type ReactElement, type ReactNode } from 'react'\n\nimport { Button, EmptyState } from '@tangle-network/ui/primitives'\n\nimport type { AsyncResourceState } from './state'\nimport type { MutationState } from './use-confirmed-mutation'\n\nexport interface AsyncEmptyAction {\n label: string\n onClick: () => void\n}\n\nexport interface AsyncEmptySpec {\n /** What is not there, in the reader's words (\"No templates yet\"). Required:\n * an empty state with nothing to say is the state this module exists to\n * stop being mistaken for a failure. */\n title: string\n description?: string\n /** The next action. An element is rendered as supplied (a link, a dialog\n * trigger); the object form renders the standard button. */\n action?: AsyncEmptyAction | ReactElement\n}\n\nexport interface AsyncErrorRenderProps {\n message: string\n retry: () => void\n}\n\nexport interface AsyncViewProps<T> {\n state: AsyncResourceState<T>\n /** Rendered only for `ready`, with the loaded value — the branch cannot be\n * entered without one. */\n children: (value: T) => ReactNode\n /** Required: `empty` must name what is missing and what to do about it. */\n empty: AsyncEmptySpec | ReactElement\n /** Must return an element. Returning nothing is what produced the blank\n * screens this component replaces, so a nullish return falls back to the\n * built-in block rather than rendering nothing. */\n renderLoading?: () => ReactElement\n renderError?: (props: AsyncErrorRenderProps) => ReactElement\n /** `idle` renders the loading block by default — from the reader's side,\n * \"not started\" and \"in flight\" are the same wait. */\n renderIdle?: () => ReactElement\n loadingLabel?: string\n retryLabel?: string\n /** Applied to the wrapper around the non-`ready` branches. `ready` renders the\n * children with no wrapper element, so grids and lists keep their layout. */\n className?: string\n}\n\nconst BLOCK_CLASS = 'flex flex-col items-center justify-center gap-2 px-4 py-10 text-center'\n\n/**\n * Renders the branch the state is actually in.\n *\n * The three anti-patterns this replaces (`catch` that only clears a loading\n * flag, early return on a non-ok response, bare `null` while loading) all end at\n * the same rendered output as a successful-but-empty load. Here every branch is\n * reached from a different variant and each renders visibly: `loading` and\n * `idle` render a labelled busy block, `error` renders the message plus the\n * retry, `empty` renders the caller's copy and next action, and `ready` is the\n * only branch with a value to hand to `children`.\n */\nexport function AsyncView<T>({\n state,\n children,\n empty,\n renderLoading,\n renderError,\n renderIdle,\n loadingLabel = 'Loading…',\n retryLabel = 'Retry',\n className,\n}: AsyncViewProps<T>): ReactElement {\n if (state.status === 'ready') return <>{children(state.value)}</>\n\n // Every `??` here is the guarantee: a custom renderer that returns nothing\n // leaves the reader with the built-in block, never a blank region.\n const branch = (): ReactNode => {\n switch (state.status) {\n case 'idle':\n return renderIdle?.() ?? <LoadingBlock label={loadingLabel} />\n case 'loading':\n return renderLoading?.() ?? <LoadingBlock label={loadingLabel} />\n case 'error':\n return (\n renderError?.({ message: state.message, retry: state.retry }) ?? (\n <ErrorBlock message={state.message} retry={state.retry} retryLabel={retryLabel} />\n )\n )\n case 'empty':\n if (isValidElement(empty)) return empty\n return typeof empty === 'object' && empty !== null && typeof empty.title === 'string' ? (\n <EmptyBlock spec={empty} />\n ) : (\n <EmptyBlock spec={{ title: 'Nothing here yet.' }} />\n )\n }\n }\n\n // The busy signal lives on the WRAPPER, not inside the loading block, for the\n // same reason every `??` above exists: `renderLoading` is an escape hatch, and\n // a caller filling it with their own spinner would otherwise take the\n // announcement with them — a screen reader would hear nothing for exactly the\n // products that styled their wait state. The wrapper wraps every non-`ready`\n // branch, so it cannot be opted out of.\n //\n // `aria-busy` is emitted in BOTH states rather than only while loading: a\n // region that gains the attribute at the moment it goes busy, and drops it on\n // arrival, gives assistive tech no transition to report. The `error` branch\n // keeps its own `role=\"alert\"` and takes no live region here, because nesting\n // one inside another is what produces a doubled announcement.\n const busy = state.status === 'loading' || state.status === 'idle'\n const failed = state.status === 'error'\n return (\n <div\n data-async-state={state.status}\n className={className}\n role={failed ? undefined : 'status'}\n aria-live={failed ? undefined : 'polite'}\n aria-busy={busy}\n >\n {branch()}\n </div>\n )\n}\n\nfunction LoadingBlock({ label }: { label: string }): ReactElement {\n return (\n <div className={BLOCK_CLASS}>\n <span className=\"text-sm text-muted-foreground\">{label}</span>\n </div>\n )\n}\n\nfunction ErrorBlock({\n message,\n retry,\n retryLabel,\n}: {\n message: string\n retry: () => void\n retryLabel: string\n}): ReactElement {\n return (\n <div role=\"alert\" className={BLOCK_CLASS}>\n <p className=\"max-w-md text-sm text-muted-foreground\">{message}</p>\n <Button type=\"button\" variant=\"outline\" size=\"sm\" onClick={retry}>{retryLabel}</Button>\n </div>\n )\n}\n\nfunction EmptyBlock({ spec }: { spec: AsyncEmptySpec }): ReactElement {\n const action = spec.action\n return <EmptyState title={spec.title} description={spec.description} action={\n isValidElement(action) ? action : action ? <Button type=\"button\" variant=\"outline\" size=\"sm\" onClick={(action as AsyncEmptyAction).onClick}>{(action as AsyncEmptyAction).label}</Button> : undefined\n } />\n}\n\nexport interface MutationStatusLabels {\n pending?: string\n succeeded?: string\n}\n\nexport interface MutationStatusProps<T> {\n state: MutationState<T>\n labels?: MutationStatusLabels\n className?: string\n}\n\n/**\n * The write's own status line. \"Saved\" renders only from `succeeded`, which\n * `useConfirmedMutation` can only reach through a confirmed write, so the label\n * cannot appear over a failed request.\n */\nexport function MutationStatus<T>({ state, labels, className }: MutationStatusProps<T>): ReactElement | null {\n if (state.status === 'idle') return null\n if (state.status === 'pending') {\n return (\n <span role=\"status\" aria-live=\"polite\" aria-busy={true} className={className ?? 'text-sm text-muted-foreground'}>\n {labels?.pending ?? 'Saving…'}\n </span>\n )\n }\n if (state.status === 'succeeded') {\n return (\n <span role=\"status\" aria-live=\"polite\" aria-busy={false} className={className ?? 'text-sm text-muted-foreground'}>\n {labels?.succeeded ?? 'Saved'}\n </span>\n )\n }\n return (\n <span role=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A,MAEV,iBAAO;AAAA;AAAA,EACV;AAEJ;AAEA,SAAS,aAAa,EAAE,MAAM,GAAoC;AAChE,SACE,oBAAC,SAAI,WAAW,aACd,8BAAC,UAAK,WAAU,iCAAiC,iBAAM,GACzD;AAEJ;AAEA,SAAS,WAAW;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AACF,GAIiB;AACf,SACE,qBAAC,SAAI,MAAK,SAAQ,WAAW,aAC3B;AAAA,wBAAC,OAAE,WAAU,0CAA0C,mBAAQ;AAAA,IAC/D,oBAAC,UAAO,MAAK,UAAS,SAAQ,WAAU,MAAK,MAAK,SAAS,OAAQ,sBAAW;AAAA,KAChF;AAEJ;AAEA,SAAS,WAAW,EAAE,KAAK,GAA2C;AACpE,QAAM,SAAS,KAAK;AACpB,SAAO,oBAAC,cAAW,OAAO,KAAK,OAAO,aAAa,KAAK,aAAa,QACnE,eAAe,MAAM,IAAI,SAAS,SAAS,oBAAC,UAAO,MAAK,UAAS,SAAQ,WAAU,MAAK,MAAK,SAAU,OAA4B,SAAW,iBAA4B,OAAM,IAAY,QAC5L;AACJ;AAkBO,SAAS,eAAkB,EAAE,OAAO,QAAQ,UAAU,GAAgD;AAC3G,MAAI,MAAM,WAAW,OAAQ,QAAO;AACpC,MAAI,MAAM,WAAW,WAAW;AAC9B,WACE,oBAAC,UAAK,MAAK,UAAS,aAAU,UAAS,aAAW,MAAM,WAAW,aAAa,iCAC7E,kBAAQ,WAAW,gBACtB;AAAA,EAEJ;AACA,MAAI,MAAM,WAAW,aAAa;AAChC,WACE,oBAAC,UAAK,MAAK,UAAS,aAAU,UAAS,aAAW,OAAO,WAAW,aAAa,iCAC9E,kBAAQ,aAAa,SACxB;AAAA,EAEJ;AACA,SACE,oBAAC,UAAK,MAAK,SAAQ,WAAW,aAAa,4BACxC,gBAAM,SACT;AAEJ;","names":["useCallback","useMemo","useRef","useState","useRef","useState","useCallback","useMemo"]}
@@ -10,7 +10,7 @@ var ToolInputError = class extends Error {
10
10
  status;
11
11
  };
12
12
 
13
- // node_modules/.pnpm/@tangle-network+ui@11.38.1_@hocuspocus+provider@4.6.0_y-protocols@1.0.7_yjs@13.6.32__yj_412d2170601eeae6020bcb5d4ab26de5/node_modules/@tangle-network/ui/dist/openui/schema-data.js
13
+ // node_modules/.pnpm/@tangle-network+ui@11.40.0_@hocuspocus+provider@4.6.0_y-protocols@1.0.7_yjs@13.6.32__yj_69daae7c6e2342474551d1d2ed174464/node_modules/@tangle-network/ui/dist/openui/schema-data.js
14
14
  var OPENUI_NODE_TYPES = [
15
15
  "heading",
16
16
  "text",
@@ -209,7 +209,7 @@ var OPENUI_NODE_JSON_SCHEMA = {
209
209
  }
210
210
  };
211
211
 
212
- // node_modules/.pnpm/@tangle-network+ui@11.38.1_@hocuspocus+provider@4.6.0_y-protocols@1.0.7_yjs@13.6.32__yj_412d2170601eeae6020bcb5d4ab26de5/node_modules/@tangle-network/ui/dist/_virtual/_rolldown/runtime.js
212
+ // node_modules/.pnpm/@tangle-network+ui@11.40.0_@hocuspocus+provider@4.6.0_y-protocols@1.0.7_yjs@13.6.32__yj_69daae7c6e2342474551d1d2ed174464/node_modules/@tangle-network/ui/dist/_virtual/_rolldown/runtime.js
213
213
  var __defProp = Object.defineProperty;
214
214
  var __exportAll = (all, no_symbols) => {
215
215
  let target = {};
@@ -221,7 +221,7 @@ var __exportAll = (all, no_symbols) => {
221
221
  return target;
222
222
  };
223
223
 
224
- // node_modules/.pnpm/@tangle-network+ui@11.38.1_@hocuspocus+provider@4.6.0_y-protocols@1.0.7_yjs@13.6.32__yj_412d2170601eeae6020bcb5d4ab26de5/node_modules/@tangle-network/ui/dist/openui/schema-compiled.js
224
+ // node_modules/.pnpm/@tangle-network+ui@11.40.0_@hocuspocus+provider@4.6.0_y-protocols@1.0.7_yjs@13.6.32__yj_69daae7c6e2342474551d1d2ed174464/node_modules/@tangle-network/ui/dist/openui/schema-compiled.js
225
225
  var schema_compiled_exports = /* @__PURE__ */ __exportAll({
226
226
  actions: () => actions2,
227
227
  badge: () => badge,
@@ -9520,7 +9520,7 @@ function validate44(data, { instancePath = "", parentData, parentDataProperty, r
9520
9520
  return errors === 0;
9521
9521
  }
9522
9522
 
9523
- // node_modules/.pnpm/@tangle-network+ui@11.38.1_@hocuspocus+provider@4.6.0_y-protocols@1.0.7_yjs@13.6.32__yj_412d2170601eeae6020bcb5d4ab26de5/node_modules/@tangle-network/ui/dist/openui-schema.js
9523
+ // node_modules/.pnpm/@tangle-network+ui@11.40.0_@hocuspocus+provider@4.6.0_y-protocols@1.0.7_yjs@13.6.32__yj_69daae7c6e2342474551d1d2ed174464/node_modules/@tangle-network/ui/dist/openui-schema.js
9524
9524
  var nodeTypes = new Set(OPENUI_NODE_TYPES);
9525
9525
  function findUnsupportedOpenUINode(value) {
9526
9526
  const seen = /* @__PURE__ */ new WeakSet();
@@ -9634,4 +9634,4 @@ export {
9634
9634
  OPENUI_NODE_JSON_SCHEMA,
9635
9635
  validateOpenUIJsonNode
9636
9636
  };
9637
- //# sourceMappingURL=chunk-7BYY7QKC.js.map
9637
+ //# sourceMappingURL=chunk-E65YV7VV.js.map