@tangle-network/agent-app 0.57.19 → 0.58.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/VaultPane-UHLJSIND.js +7 -0
- package/dist/assistant/index.js +5 -4
- package/dist/assistant/index.js.map +1 -1
- package/dist/channels/index.js +1 -1
- package/dist/chunk-3NVVBQ2U.js +131 -0
- package/dist/chunk-3NVVBQ2U.js.map +1 -0
- package/dist/{chunk-EPZYYWCT.js → chunk-6ZIC6OG5.js} +8 -2
- package/dist/{chunk-EPZYYWCT.js.map → chunk-6ZIC6OG5.js.map} +1 -1
- package/dist/{chunk-OGFDE4IR.js → chunk-E2HFIKIZ.js} +2 -2
- package/dist/{chunk-Q3ZHNN5X.js → chunk-LSUELMHY.js} +2 -2
- package/dist/chunk-LSUELMHY.js.map +1 -0
- package/dist/chunk-M6WST7ZH.js +265 -0
- package/dist/chunk-M6WST7ZH.js.map +1 -0
- package/dist/{chunk-IOUPOUYB.js → chunk-XADC73A7.js} +2 -2
- package/dist/chunk-XADC73A7.js.map +1 -0
- package/dist/copy-quality/index.d.ts +88 -0
- package/dist/copy-quality/index.js +22 -0
- package/dist/copy-quality/index.js.map +1 -0
- package/dist/integrations-react/index.js +1 -1
- package/dist/legibility/cli.js +1 -1
- package/dist/legibility/index.js +1 -1
- package/dist/profile/agent-prompt.d.ts +91 -0
- package/dist/profile/index.d.ts +15 -49
- package/dist/profile/index.js +316 -10
- package/dist/profile/index.js.map +1 -1
- package/dist/profile/model-input.d.ts +94 -0
- package/dist/profile/operating-contract.d.ts +44 -0
- package/dist/profile/quality-skills.d.ts +33 -0
- package/dist/vault/index.js +1 -1
- package/dist/vault/lazy.js +1 -1
- package/dist/web-react/async/index.js +1 -1
- package/dist/web-react/async/state.d.ts +1 -1
- package/dist/web-react/index.js +2 -2
- package/dist/work-product/index.js +12 -118
- package/dist/work-product/index.js.map +1 -1
- package/package.json +6 -1
- package/dist/VaultPane-SDNMDGFC.js +0 -7
- package/dist/chunk-IOUPOUYB.js.map +0 -1
- package/dist/chunk-Q3ZHNN5X.js.map +0 -1
- /package/dist/{VaultPane-SDNMDGFC.js.map → VaultPane-UHLJSIND.js.map} +0 -0
- /package/dist/{chunk-OGFDE4IR.js.map → chunk-E2HFIKIZ.js.map} +0 -0
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
} from "./chunk-SJWIZT7B.js";
|
|
31
31
|
import {
|
|
32
32
|
AsyncView
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-LSUELMHY.js";
|
|
34
34
|
import {
|
|
35
35
|
attachmentPartsFromMessageParts
|
|
36
36
|
} from "./chunk-WTGSLW5X.js";
|
|
@@ -7541,4 +7541,4 @@ export {
|
|
|
7541
7541
|
useThinkingSeconds,
|
|
7542
7542
|
ChatMessages
|
|
7543
7543
|
};
|
|
7544
|
-
//# sourceMappingURL=chunk-
|
|
7544
|
+
//# sourceMappingURL=chunk-E2HFIKIZ.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/web-react/async/state.ts
|
|
2
|
-
var DEFAULT_ASYNC_ERROR_MESSAGE = "
|
|
2
|
+
var DEFAULT_ASYNC_ERROR_MESSAGE = "This did not load. Try again.";
|
|
3
3
|
function defaultIsEmpty(value) {
|
|
4
4
|
if (value === null || value === void 0) return true;
|
|
5
5
|
if (Array.isArray(value)) return value.length === 0;
|
|
@@ -314,4 +314,4 @@ export {
|
|
|
314
314
|
AsyncView,
|
|
315
315
|
MutationStatus
|
|
316
316
|
};
|
|
317
|
-
//# sourceMappingURL=chunk-
|
|
317
|
+
//# sourceMappingURL=chunk-LSUELMHY.js.map
|
|
@@ -0,0 +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 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 {/* The ring is the brand colour, not `border-border`. A divider token is\n tuned to be barely there, which is the opposite of what a busy\n indicator needs: measured on this block it painted 1.10:1 in light and\n 1.20:1 in dark against its own panel — below the 3:1 a meaningful\n graphic needs, and this spinner is the only signal that a fetch is in\n flight. `border-primary` is also what the composer's send spinner\n already uses, so this stops being the one that reads differently. */}\n <span\n className=\"h-4 w-4 animate-spin rounded-full border-2 border-primary border-t-transparent\"\n aria-hidden=\"true\"\n />\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\n type=\"button\"\n onClick={retry}\n className=\"h-8 rounded-md border border-border px-3 text-xs font-medium text-foreground transition hover:bg-accent\"\n >\n {retryLabel}\n </button>\n </div>\n )\n}\n\nfunction EmptyBlock({ spec }: { spec: AsyncEmptySpec }): ReactElement {\n return (\n <div className={BLOCK_CLASS}>\n <p className=\"text-sm font-medium text-foreground\">{spec.title}</p>\n {spec.description ? <p className=\"max-w-md text-sm text-muted-foreground\">{spec.description}</p> : null}\n {spec.action ? (\n isValidElement(spec.action) ? (\n spec.action\n ) : (\n <button\n type=\"button\"\n onClick={(spec.action as AsyncEmptyAction).onClick}\n className=\"h-8 rounded-md border border-border px-3 text-xs font-medium text-foreground transition hover:bg-accent\"\n >\n {(spec.action as AsyncEmptyAction).label}\n </button>\n )\n ) : null}\n </div>\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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from "./chunk-3NVVBQ2U.js";
|
|
5
|
+
|
|
6
|
+
// src/copy-quality/index.ts
|
|
7
|
+
var BAN_WORDS = [
|
|
8
|
+
"delve",
|
|
9
|
+
"tapestry",
|
|
10
|
+
"testament to",
|
|
11
|
+
"realm",
|
|
12
|
+
"embark",
|
|
13
|
+
"beacon",
|
|
14
|
+
"multifaceted",
|
|
15
|
+
"paradigm",
|
|
16
|
+
"synergy",
|
|
17
|
+
"myriad",
|
|
18
|
+
"plethora",
|
|
19
|
+
"meticulous",
|
|
20
|
+
"intricate",
|
|
21
|
+
"utilize",
|
|
22
|
+
"leverage",
|
|
23
|
+
"supercharge",
|
|
24
|
+
"turbocharge",
|
|
25
|
+
"game-changer",
|
|
26
|
+
"game-changing",
|
|
27
|
+
"ever-evolving landscape",
|
|
28
|
+
"plays a crucial role"
|
|
29
|
+
];
|
|
30
|
+
var CAP_WORDS = [
|
|
31
|
+
"seamless",
|
|
32
|
+
"robust",
|
|
33
|
+
"streamline",
|
|
34
|
+
"empower",
|
|
35
|
+
"elevate",
|
|
36
|
+
"unlock",
|
|
37
|
+
"unleash",
|
|
38
|
+
"harness",
|
|
39
|
+
"foster",
|
|
40
|
+
"enhance",
|
|
41
|
+
"optimize",
|
|
42
|
+
"cutting-edge",
|
|
43
|
+
"innovative",
|
|
44
|
+
"revolutionary",
|
|
45
|
+
"transformative",
|
|
46
|
+
"holistic",
|
|
47
|
+
"comprehensive",
|
|
48
|
+
"pivotal",
|
|
49
|
+
"crucial",
|
|
50
|
+
"vital",
|
|
51
|
+
"powerful",
|
|
52
|
+
"next-level",
|
|
53
|
+
"world-class",
|
|
54
|
+
"best-in-class",
|
|
55
|
+
"landscape",
|
|
56
|
+
"navigate",
|
|
57
|
+
"ecosystem",
|
|
58
|
+
"journey",
|
|
59
|
+
"truly",
|
|
60
|
+
"genuinely",
|
|
61
|
+
"incredibly",
|
|
62
|
+
"deeply",
|
|
63
|
+
"fundamentally",
|
|
64
|
+
"significantly",
|
|
65
|
+
"simply",
|
|
66
|
+
"actually",
|
|
67
|
+
"literally",
|
|
68
|
+
"quietly"
|
|
69
|
+
];
|
|
70
|
+
var rule = (category, fix) => (pattern) => ({ pattern, category, fix });
|
|
71
|
+
var CONTRAST_FIX = "State the real point directly with its reason; do not stage a denial first.";
|
|
72
|
+
var PHRASE_RULES = [
|
|
73
|
+
...[
|
|
74
|
+
/\bin today'?s (?:fast-paced |digital |modern )?(?:world|landscape|market|age)\b/i,
|
|
75
|
+
/\bwhether you'?re an? [^,.]{1,40},? or an? /i,
|
|
76
|
+
/(?:^|[.!?]\s+)imagine\b/i,
|
|
77
|
+
/\bwhen it comes to\b/i,
|
|
78
|
+
/\bhere'?s the thing\b|\bthe truth is\b|\blet me be clear\b|\bhere'?s what nobody tells you\b/i,
|
|
79
|
+
/\bin this (?:guide|post|article),? we'?ll\b|\blet'?s dive in(?:to)?\b/i,
|
|
80
|
+
/\bin conclusion\b|\bat the end of the day\b/i,
|
|
81
|
+
/(?:^|[.!?]\s+)(?:it'?s worth noting|moreover|additionally|importantly|ultimately)\b/i
|
|
82
|
+
].map(rule("opener-closer", "Delete the wind-up and start with the point.")),
|
|
83
|
+
...[
|
|
84
|
+
/\bsay (?:goodbye|hello) to\b/i,
|
|
85
|
+
/\b(?:unlock|unleash) the (?:full )?power of\b/i,
|
|
86
|
+
/\b\w+, (?:reimagined|redefined)\b/i,
|
|
87
|
+
/\bto the next level\b/i,
|
|
88
|
+
/\btransform the way you\b/i,
|
|
89
|
+
/\bthe \w+ you deserve\b/i,
|
|
90
|
+
/\bthe future of [\w ]{1,30} is here\b/i,
|
|
91
|
+
/\bbuilt for teams (?:who|that) move fast\b/i,
|
|
92
|
+
/\beverything you need to\b|\ball-in-one\b/i,
|
|
93
|
+
/\beffortless(?:ly)?\b|\bin just a few clicks\b/i,
|
|
94
|
+
/\bjoin (?:thousands|millions|hundreds) of\b/i,
|
|
95
|
+
/\bchanges everything\b/i,
|
|
96
|
+
/\bexperience the power of\b/i
|
|
97
|
+
].map(rule("marketing-phrase", "Replace with the concrete outcome, number or workflow.")),
|
|
98
|
+
rule("puffery", "State the fact; let the reader judge it.")(/\b(?:marks|represents) a pivotal moment\b|\bredefines the category\b/i),
|
|
99
|
+
rule("weasel-source", "Name the source or the customer, or cut the claim.")(/\bexperts agree\b|\bstudies show\b|\btrusted by (?:industry )?leaders\b/i),
|
|
100
|
+
rule("chummy-opener", "Cut the chummy opener.")(/^(?:great question|let'?s be honest|we get it)\b/im),
|
|
101
|
+
rule("contrast-reveal", CONTRAST_FIX)(
|
|
102
|
+
/\bit'?s not (?:just )?[^.,;!?]{1,60}[,;.]\s*it'?s\b|\b(?:this|that) isn'?t [^.;!?]{1,60}\.\s*(?:this|that|it) is\b|\bnot just [^.;!?]{1,60},? but\b|\bnot because [^.;!?]{1,60}\.\s*because\b|\bless [a-z]+, more [a-z]+\b|\bthe question isn'?t\b|\?\s*think again\b/i
|
|
103
|
+
),
|
|
104
|
+
rule("contrast-reveal", CONTRAST_FIX)(/(?:^|[.!?]\s+)Not [^.;!?]{1,40}\.\s+[A-Z][^.;!?]{1,60}\./),
|
|
105
|
+
rule("negation-list", 'Say what does happen. One plain "No card required" beside the CTA is fine.')(
|
|
106
|
+
/\bno [a-z-]+(?: [a-z-]+)?[,.]\s*no [a-z-]+/i
|
|
107
|
+
),
|
|
108
|
+
rule("question-reveal", "Delete the question and keep the answer.")(
|
|
109
|
+
/\bthe (?:result|catch|best part|secret|kicker|twist|answer|difference|outcome|upshot)\?\s+\S/i
|
|
110
|
+
),
|
|
111
|
+
rule("colon-reveal", "Write it as a normal sentence.")(
|
|
112
|
+
/\b(?:the best part|here'?s the (?:secret|thing|kicker|catch)|one word|the result|the truth|the secret)\s*:\s/i
|
|
113
|
+
),
|
|
114
|
+
rule("hype-punctuation", "Remove the stacked punctuation.")(/[!?]{2,}/),
|
|
115
|
+
rule("decoration", "Remove decorative unicode letters and emoji bullets.")(
|
|
116
|
+
/[\u{1D400}-\u{1D7FF}]|^\s*(?:[-*•]\s*)?[\u{1F300}-\u{1FAFF}\u{2600}-\u{27BF}]/mu
|
|
117
|
+
)
|
|
118
|
+
];
|
|
119
|
+
var CHAT_WRAPPERS = [
|
|
120
|
+
/^\s*(?:sure|certainly|absolutely|of course|great)[!,.]/i,
|
|
121
|
+
/^\s*here(?:'s| is| are) (?:a|an|the|your|my) (?:draft|version|post|email|ad|headline|copy|subject|options?|revised)/i,
|
|
122
|
+
/\bi hope (?:this|that) helps\b/i,
|
|
123
|
+
/\blet me know if you(?:'d like| want| need)\b/i,
|
|
124
|
+
/\b(?:want|would you like) me to\b/i,
|
|
125
|
+
/\bfeel free to (?:adjust|tweak|edit)\b/i
|
|
126
|
+
];
|
|
127
|
+
var DASH = /—|(?<=\S)[ \t]+(?:–|--?)[ \t]+(?=\S)/g;
|
|
128
|
+
var CURLY = /[‘’“”]/;
|
|
129
|
+
function escapeRegExp(value) {
|
|
130
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
131
|
+
}
|
|
132
|
+
function inflected(word) {
|
|
133
|
+
const stem = escapeRegExp(word);
|
|
134
|
+
if (/e$/.test(word)) return `${stem.slice(0, -1)}(?:e|es|ed|ing|ely)`;
|
|
135
|
+
if (/[^aeiou]y$/.test(word)) return `${stem.slice(0, -1)}(?:y|ies|ied|ying|ily)`;
|
|
136
|
+
return `${stem}(?:s|es|ed|ing|ly)?`;
|
|
137
|
+
}
|
|
138
|
+
function termRegex(term) {
|
|
139
|
+
const body = /\s/.test(term.trim()) ? escapeRegExp(term.trim()) : inflected(term.trim());
|
|
140
|
+
return new RegExp(`(?<![\\w-])${body.replace(/-|\s+/g, "[-\\s]+")}(?![\\w-])`, "gi");
|
|
141
|
+
}
|
|
142
|
+
var BAN_REGEXES = BAN_WORDS.map((word) => ({ word, regex: termRegex(word) }));
|
|
143
|
+
var CAP_REGEXES = CAP_WORDS.map((word) => ({ word, regex: termRegex(word) }));
|
|
144
|
+
function proseOf(text) {
|
|
145
|
+
return text.replace(/```[\s\S]*?```/g, "\n\n").replace(/`[^`\n]*`/g, "code").replace(/https?:\/\/\S+/g, "link").replace(/[‘’]/g, "'").replace(/[“”]/g, '"');
|
|
146
|
+
}
|
|
147
|
+
function paragraphsOf(prose) {
|
|
148
|
+
return prose.split(/\n\s*\n/).map((p) => p.trim()).filter(Boolean);
|
|
149
|
+
}
|
|
150
|
+
function wordCount(text) {
|
|
151
|
+
return (text.match(/[A-Za-z0-9][\w'-]*/g) ?? []).length;
|
|
152
|
+
}
|
|
153
|
+
function repeatedTrigramRate(prose) {
|
|
154
|
+
const words = prose.toLowerCase().match(/[a-z0-9][a-z0-9'-]*/g) ?? [];
|
|
155
|
+
if (words.length < 12) return 0;
|
|
156
|
+
const seen = /* @__PURE__ */ new Map();
|
|
157
|
+
for (let i = 0; i + 2 < words.length; i += 1) {
|
|
158
|
+
const key = `${words[i]} ${words[i + 1]} ${words[i + 2]}`;
|
|
159
|
+
seen.set(key, (seen.get(key) ?? 0) + 1);
|
|
160
|
+
}
|
|
161
|
+
let repeats = 0;
|
|
162
|
+
for (const count of seen.values()) if (count > 1) repeats += count - 1;
|
|
163
|
+
return repeats / (words.length - 2);
|
|
164
|
+
}
|
|
165
|
+
function scanCopy(text, options = {}) {
|
|
166
|
+
const surface = options.surface ?? "long";
|
|
167
|
+
const prose = proseOf(text);
|
|
168
|
+
const paragraphs = paragraphsOf(prose);
|
|
169
|
+
const extras = [...new Set((options.extraBanned ?? []).map((word) => word.toLowerCase()))].filter((word) => !BAN_WORDS.includes(word));
|
|
170
|
+
const banned = [...BAN_REGEXES, ...extras.map((word) => ({ word, regex: termRegex(word) }))];
|
|
171
|
+
const findings = [];
|
|
172
|
+
let contrastParagraphs = 0;
|
|
173
|
+
let tellWords = 0;
|
|
174
|
+
paragraphs.forEach((paragraph, index) => {
|
|
175
|
+
for (const { word, regex } of banned) {
|
|
176
|
+
for (const match of paragraph.matchAll(regex)) {
|
|
177
|
+
tellWords += 1;
|
|
178
|
+
findings.push({ tier: "ban", category: "banned-word", match: match[0], paragraph: index, fix: `Replace "${word}" with the fact it stands in for.` });
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
const capMatches = CAP_REGEXES.flatMap(({ regex }) => [...paragraph.matchAll(regex)].map((match) => match[0]));
|
|
182
|
+
tellWords += capMatches.length;
|
|
183
|
+
if (capMatches.length >= 2) {
|
|
184
|
+
findings.push({ tier: "cap", category: "cap-words", match: capMatches.join(", "), paragraph: index, fix: "Two cap-tier words in one paragraph: rewrite it from the facts." });
|
|
185
|
+
}
|
|
186
|
+
let contrast = false;
|
|
187
|
+
for (const { pattern, category, fix } of PHRASE_RULES) {
|
|
188
|
+
const match = paragraph.match(pattern);
|
|
189
|
+
if (!match) continue;
|
|
190
|
+
if (category === "contrast-reveal") {
|
|
191
|
+
if (contrast) continue;
|
|
192
|
+
contrast = true;
|
|
193
|
+
}
|
|
194
|
+
findings.push({ tier: "ban", category, match: match[0].trim(), paragraph: index, fix });
|
|
195
|
+
}
|
|
196
|
+
if (contrast) contrastParagraphs += 1;
|
|
197
|
+
let run = 0;
|
|
198
|
+
for (const sentence of paragraph.split(/(?<=[.!?])\s+/)) {
|
|
199
|
+
const count = wordCount(sentence);
|
|
200
|
+
run = count > 0 && count <= 3 ? run + 1 : 0;
|
|
201
|
+
if (run === 3) {
|
|
202
|
+
findings.push({ tier: "cap", category: "fragment-drumbeat", match: sentence, paragraph: index, fix: "Merge the fragments into one sentence that carries a fact." });
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
const dashes = prose.match(DASH)?.length ?? 0;
|
|
208
|
+
if (dashes > 0) {
|
|
209
|
+
const tier = surface === "short" ? "ban" : dashes > 2 ? "cap" : "weak";
|
|
210
|
+
const fix = surface === "short" ? "Short copy uses no dashes between words: use a period, comma or colon." : "Long copy allows two dashes per page at most; prefer a period or comma.";
|
|
211
|
+
findings.push({ tier, category: "dash", match: `${dashes} dash${dashes === 1 ? "" : "es"}`, paragraph: -1, fix });
|
|
212
|
+
}
|
|
213
|
+
if (CURLY.test(text)) {
|
|
214
|
+
findings.push({ tier: "weak", category: "decoration", match: "curly quotes", paragraph: -1, fix: "Weak alone: use the quote style the target format uses." });
|
|
215
|
+
}
|
|
216
|
+
const wrapper = chatWrapperIn(text);
|
|
217
|
+
if (wrapper !== null) {
|
|
218
|
+
findings.push({ tier: "ban", category: "chat-wrapper", match: wrapper, paragraph: -1, fix: "Return only the deliverable, with no chat around it." });
|
|
219
|
+
}
|
|
220
|
+
const counts = { ban: 0, cap: 0, weak: 0 };
|
|
221
|
+
for (const finding of findings) counts[finding.tier] += 1;
|
|
222
|
+
const words = wordCount(prose);
|
|
223
|
+
const wordRate = Math.min(1, tellWords * 1e3 / Math.max(1, words) / 40);
|
|
224
|
+
const contrastRate = paragraphs.length === 0 ? 0 : contrastParagraphs / paragraphs.length;
|
|
225
|
+
const trigramRate = Math.min(1, repeatedTrigramRate(prose) * 10);
|
|
226
|
+
const slopScore = Math.round(100 * (0.6 * wordRate + 0.25 * contrastRate + 0.15 * trigramRate));
|
|
227
|
+
return { pass: counts.ban === 0 && counts.cap === 0, findings, counts, slopScore, words };
|
|
228
|
+
}
|
|
229
|
+
function chatWrapperIn(text) {
|
|
230
|
+
const prose = proseOf(text);
|
|
231
|
+
for (const pattern of CHAT_WRAPPERS) {
|
|
232
|
+
const match = prose.match(pattern);
|
|
233
|
+
if (match) return match[0].trim();
|
|
234
|
+
}
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
function bannedCopyVocabulary(extra = []) {
|
|
238
|
+
return [...new Set([...extra, ...BAN_WORDS].map((word) => word.toLowerCase()))];
|
|
239
|
+
}
|
|
240
|
+
var METRIC = /[$€£¥₹]\s?\d[\d,]*(?:\.\d+)?(?:\s?[kKmMbB]\b)?|\b\d[\d,]*(?:\.\d+)?\s?(?:%|x\b|×|ms\b|s\b|sec\b|secs\b|seconds?\b|mins?\b|minutes?\b|hrs?\b|hours?\b|days?\b|[kKmMbB]\+?(?=\s|$|[.,;])|[KMGT]B\b|rps\b|qps\b|tokens?\b)|\b\d{1,3}(?:,\d{3})+(?:\.\d+)?\b/g;
|
|
241
|
+
function metricClaims(text) {
|
|
242
|
+
const claims = [];
|
|
243
|
+
for (const match of proseOf(text).matchAll(METRIC)) {
|
|
244
|
+
const numeric = match[0].match(/[$€£¥₹]?\s?\d[\d,]*(?:\.\d+)?/)?.[0];
|
|
245
|
+
const value = numeric ? canonicalizeValue(numeric) : null;
|
|
246
|
+
if (value !== null) claims.push({ text: match[0].trim(), value });
|
|
247
|
+
}
|
|
248
|
+
return claims;
|
|
249
|
+
}
|
|
250
|
+
function unsourcedMetrics(copy, sources) {
|
|
251
|
+
const known = new Set(sources.flatMap((source) => valuesInText(source)));
|
|
252
|
+
return metricClaims(copy).filter((claim) => !known.has(claim.value));
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export {
|
|
256
|
+
BAN_WORDS,
|
|
257
|
+
CAP_WORDS,
|
|
258
|
+
proseOf,
|
|
259
|
+
scanCopy,
|
|
260
|
+
chatWrapperIn,
|
|
261
|
+
bannedCopyVocabulary,
|
|
262
|
+
metricClaims,
|
|
263
|
+
unsourcedMetrics
|
|
264
|
+
};
|
|
265
|
+
//# sourceMappingURL=chunk-M6WST7ZH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/copy-quality/index.ts"],"sourcesContent":["/**\n * `@tangle-network/agent-app/copy-quality` — deterministic checks for copy an\n * agent writes for a reader: ads, posts, subject lines, emails, landing pages.\n *\n * No model call. A scan returns findings an agent can fix before a person sees\n * the draft, and the same findings feed a product's outcome checks, so the\n * in-run feedback and the scored episode never disagree.\n *\n * Tiers follow the \"AI tells\" list in coreyhaines31/marketingskills (MIT,\n * revision f719a8079c694e3267d47b6b60a62aa926055f2c,\n * skills/copywriting/references/ai-tells.md):\n * - ban: a tell on one sighting.\n * - cap: fine once; a tell when two land in one paragraph.\n * - weak: reported, never failing on its own.\n * Weighting follows blader/humanizer (MIT, revision\n * 225a6f39ac85f76ee48dbad772ea4abe4ed6c9d8): staged contrasts, negation lists\n * and staged reveals count on one sighting; a dash or a curly quote in long\n * copy is weak alone. The density score mirrors the EQ-Bench Slop Score mix:\n * 60% tell-word rate, 25% contrast constructions, 15% repeated trigrams.\n *\n * Code blocks, inline code and URLs are removed before scanning: an SDK\n * snippet in a post is the product, not prose.\n */\n\nimport { canonicalizeValue, valuesInText } from '../work-product/claim-support'\n\nexport type CopySurface = 'short' | 'long'\n\nexport type CopyTellTier = 'ban' | 'cap' | 'weak'\n\nexport type CopyTellCategory =\n | 'banned-word'\n | 'cap-words'\n | 'contrast-reveal'\n | 'negation-list'\n | 'question-reveal'\n | 'colon-reveal'\n | 'opener-closer'\n | 'marketing-phrase'\n | 'puffery'\n | 'weasel-source'\n | 'chummy-opener'\n | 'hype-punctuation'\n | 'decoration'\n | 'fragment-drumbeat'\n | 'dash'\n | 'chat-wrapper'\n\nexport interface CopyTellFinding {\n tier: CopyTellTier\n category: CopyTellCategory\n /** The text that triggered the finding. */\n match: string\n /** Zero-based paragraph index, or -1 for a whole-text finding. */\n paragraph: number\n /** What to do instead, written for the agent that will fix it. */\n fix: string\n}\n\nexport interface CopyScanOptions {\n /**\n * `short` = headline, subject line, ad, social post, SMS, hero, CTA: no\n * dashes at all. `long` = article, email body, page: two dashes allowed.\n * Default `long`.\n */\n surface?: CopySurface\n /** Product-specific banned words or phrases (case-insensitive, whole word). */\n extraBanned?: readonly string[]\n}\n\nexport interface CopyScanResult {\n /** No ban-tier and no cap-tier findings. Weak findings never fail alone. */\n pass: boolean\n findings: CopyTellFinding[]\n counts: Record<CopyTellTier, number>\n /** 0 (clean) to 100 (dense with tells). Informational; `pass` is the gate. */\n slopScore: number\n words: number\n}\n\n/**\n * Ban-tier vocabulary: ai-tells.md \"Vocabulary → Ban\". Base forms; the scanner\n * also matches inflections (\"leveraging\", \"synergies\") and a hyphen written as\n * a space (\"game changer\"), so prompts can list each word once.\n */\nexport const BAN_WORDS: readonly string[] = [\n 'delve', 'tapestry', 'testament to', 'realm', 'embark', 'beacon', 'multifaceted',\n 'paradigm', 'synergy', 'myriad', 'plethora', 'meticulous', 'intricate', 'utilize',\n 'leverage', 'supercharge', 'turbocharge', 'game-changer', 'game-changing',\n 'ever-evolving landscape', 'plays a crucial role',\n]\n\n/** Cap-tier vocabulary: ai-tells.md \"Vocabulary → Cap\" plus empty intensifiers. Base forms. */\nexport const CAP_WORDS: readonly string[] = [\n 'seamless', 'robust', 'streamline', 'empower', 'elevate', 'unlock', 'unleash',\n 'harness', 'foster', 'enhance', 'optimize', 'cutting-edge', 'innovative',\n 'revolutionary', 'transformative', 'holistic', 'comprehensive', 'pivotal', 'crucial',\n 'vital', 'powerful', 'next-level', 'world-class', 'best-in-class', 'landscape',\n 'navigate', 'ecosystem', 'journey',\n 'truly', 'genuinely', 'incredibly', 'deeply', 'fundamentally', 'significantly',\n 'simply', 'actually', 'literally', 'quietly',\n]\n\ninterface PhraseRule {\n readonly pattern: RegExp\n readonly category: CopyTellCategory\n readonly fix: string\n}\n\nconst rule = (category: CopyTellCategory, fix: string) => (pattern: RegExp): PhraseRule => ({ pattern, category, fix })\n\nconst CONTRAST_FIX = 'State the real point directly with its reason; do not stage a denial first.'\n\nconst PHRASE_RULES: readonly PhraseRule[] = [\n ...[\n /\\bin today'?s (?:fast-paced |digital |modern )?(?:world|landscape|market|age)\\b/i,\n /\\bwhether you'?re an? [^,.]{1,40},? or an? /i,\n /(?:^|[.!?]\\s+)imagine\\b/i,\n /\\bwhen it comes to\\b/i,\n /\\bhere'?s the thing\\b|\\bthe truth is\\b|\\blet me be clear\\b|\\bhere'?s what nobody tells you\\b/i,\n /\\bin this (?:guide|post|article),? we'?ll\\b|\\blet'?s dive in(?:to)?\\b/i,\n /\\bin conclusion\\b|\\bat the end of the day\\b/i,\n /(?:^|[.!?]\\s+)(?:it'?s worth noting|moreover|additionally|importantly|ultimately)\\b/i,\n ].map(rule('opener-closer', 'Delete the wind-up and start with the point.')),\n ...[\n /\\bsay (?:goodbye|hello) to\\b/i,\n /\\b(?:unlock|unleash) the (?:full )?power of\\b/i,\n /\\b\\w+, (?:reimagined|redefined)\\b/i,\n /\\bto the next level\\b/i,\n /\\btransform the way you\\b/i,\n /\\bthe \\w+ you deserve\\b/i,\n /\\bthe future of [\\w ]{1,30} is here\\b/i,\n /\\bbuilt for teams (?:who|that) move fast\\b/i,\n /\\beverything you need to\\b|\\ball-in-one\\b/i,\n /\\beffortless(?:ly)?\\b|\\bin just a few clicks\\b/i,\n /\\bjoin (?:thousands|millions|hundreds) of\\b/i,\n /\\bchanges everything\\b/i,\n /\\bexperience the power of\\b/i,\n ].map(rule('marketing-phrase', 'Replace with the concrete outcome, number or workflow.')),\n rule('puffery', 'State the fact; let the reader judge it.')(/\\b(?:marks|represents) a pivotal moment\\b|\\bredefines the category\\b/i),\n rule('weasel-source', 'Name the source or the customer, or cut the claim.')(/\\bexperts agree\\b|\\bstudies show\\b|\\btrusted by (?:industry )?leaders\\b/i),\n rule('chummy-opener', 'Cut the chummy opener.')(/^(?:great question|let'?s be honest|we get it)\\b/im),\n rule('contrast-reveal', CONTRAST_FIX)(\n /\\bit'?s not (?:just )?[^.,;!?]{1,60}[,;.]\\s*it'?s\\b|\\b(?:this|that) isn'?t [^.;!?]{1,60}\\.\\s*(?:this|that|it) is\\b|\\bnot just [^.;!?]{1,60},? but\\b|\\bnot because [^.;!?]{1,60}\\.\\s*because\\b|\\bless [a-z]+, more [a-z]+\\b|\\bthe question isn'?t\\b|\\?\\s*think again\\b/i,\n ),\n rule('contrast-reveal', CONTRAST_FIX)(/(?:^|[.!?]\\s+)Not [^.;!?]{1,40}\\.\\s+[A-Z][^.;!?]{1,60}\\./),\n rule('negation-list', 'Say what does happen. One plain \"No card required\" beside the CTA is fine.')(\n /\\bno [a-z-]+(?: [a-z-]+)?[,.]\\s*no [a-z-]+/i,\n ),\n rule('question-reveal', 'Delete the question and keep the answer.')(\n /\\bthe (?:result|catch|best part|secret|kicker|twist|answer|difference|outcome|upshot)\\?\\s+\\S/i,\n ),\n rule('colon-reveal', 'Write it as a normal sentence.')(\n /\\b(?:the best part|here'?s the (?:secret|thing|kicker|catch)|one word|the result|the truth|the secret)\\s*:\\s/i,\n ),\n rule('hype-punctuation', 'Remove the stacked punctuation.')(/[!?]{2,}/),\n rule('decoration', 'Remove decorative unicode letters and emoji bullets.')(\n /[\\u{1D400}-\\u{1D7FF}]|^\\s*(?:[-*•]\\s*)?[\\u{1F300}-\\u{1FAFF}\\u{2600}-\\u{27BF}]/mu,\n ),\n]\n\nconst CHAT_WRAPPERS: readonly RegExp[] = [\n /^\\s*(?:sure|certainly|absolutely|of course|great)[!,.]/i,\n /^\\s*here(?:'s| is| are) (?:a|an|the|your|my) (?:draft|version|post|email|ad|headline|copy|subject|options?|revised)/i,\n /\\bi hope (?:this|that) helps\\b/i,\n /\\blet me know if you(?:'d like| want| need)\\b/i,\n /\\b(?:want|would you like) me to\\b/i,\n /\\bfeel free to (?:adjust|tweak|edit)\\b/i,\n]\n\n// An em dash anywhere; an en dash, double hyphen or single hyphen used as a\n// dash between words. A range like 10–20 has no spaces and is not a dash.\nconst DASH = /—|(?<=\\S)[ \\t]+(?:–|--?)[ \\t]+(?=\\S)/g\nconst CURLY = /[‘’“”]/\n\nfunction escapeRegExp(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n}\n\n/** Inflections of one word: \"leverage\" → leverages, leveraged, leveraging. */\nfunction inflected(word: string): string {\n const stem = escapeRegExp(word)\n if (/e$/.test(word)) return `${stem.slice(0, -1)}(?:e|es|ed|ing|ely)`\n if (/[^aeiou]y$/.test(word)) return `${stem.slice(0, -1)}(?:y|ies|ied|ying|ily)`\n return `${stem}(?:s|es|ed|ing|ly)?`\n}\n\n/**\n * A whole-word matcher for a term. A single word (hyphenated or not) also\n * matches its inflections; a phrase matches as written. Hyphens and spaces in\n * a term match either, and a space matches any run of whitespace.\n */\nfunction termRegex(term: string): RegExp {\n const body = /\\s/.test(term.trim())\n ? escapeRegExp(term.trim())\n : inflected(term.trim())\n return new RegExp(`(?<![\\\\w-])${body.replace(/-|\\s+/g, '[-\\\\s]+')}(?![\\\\w-])`, 'gi')\n}\n\nconst BAN_REGEXES = BAN_WORDS.map((word) => ({ word, regex: termRegex(word) }))\nconst CAP_REGEXES = CAP_WORDS.map((word) => ({ word, regex: termRegex(word) }))\n\n/** The prose a reader reads: code, URLs and quote styles normalized away. */\nexport function proseOf(text: string): string {\n return text\n .replace(/```[\\s\\S]*?```/g, '\\n\\n')\n .replace(/`[^`\\n]*`/g, 'code')\n .replace(/https?:\\/\\/\\S+/g, 'link')\n .replace(/[‘’]/g, \"'\")\n .replace(/[“”]/g, '\"')\n}\n\nfunction paragraphsOf(prose: string): string[] {\n return prose.split(/\\n\\s*\\n/).map((p) => p.trim()).filter(Boolean)\n}\n\nfunction wordCount(text: string): number {\n return (text.match(/[A-Za-z0-9][\\w'-]*/g) ?? []).length\n}\n\nfunction repeatedTrigramRate(prose: string): number {\n const words = prose.toLowerCase().match(/[a-z0-9][a-z0-9'-]*/g) ?? []\n if (words.length < 12) return 0\n const seen = new Map<string, number>()\n for (let i = 0; i + 2 < words.length; i += 1) {\n const key = `${words[i]} ${words[i + 1]} ${words[i + 2]}`\n seen.set(key, (seen.get(key) ?? 0) + 1)\n }\n let repeats = 0\n for (const count of seen.values()) if (count > 1) repeats += count - 1\n return repeats / (words.length - 2)\n}\n\n/** Scan copy for AI tells. Deterministic and cheap; run it on every draft. */\nexport function scanCopy(text: string, options: CopyScanOptions = {}): CopyScanResult {\n const surface = options.surface ?? 'long'\n const prose = proseOf(text)\n const paragraphs = paragraphsOf(prose)\n // An extra already in the Ban tier (or listed twice) must not count twice.\n const extras = [...new Set((options.extraBanned ?? []).map((word) => word.toLowerCase()))]\n .filter((word) => !BAN_WORDS.includes(word))\n const banned = [...BAN_REGEXES, ...extras.map((word) => ({ word, regex: termRegex(word) }))]\n const findings: CopyTellFinding[] = []\n let contrastParagraphs = 0\n let tellWords = 0\n\n paragraphs.forEach((paragraph, index) => {\n for (const { word, regex } of banned) {\n for (const match of paragraph.matchAll(regex)) {\n tellWords += 1\n findings.push({ tier: 'ban', category: 'banned-word', match: match[0], paragraph: index, fix: `Replace \"${word}\" with the fact it stands in for.` })\n }\n }\n const capMatches = CAP_REGEXES.flatMap(({ regex }) => [...paragraph.matchAll(regex)].map((match) => match[0]))\n tellWords += capMatches.length\n if (capMatches.length >= 2) {\n findings.push({ tier: 'cap', category: 'cap-words', match: capMatches.join(', '), paragraph: index, fix: 'Two cap-tier words in one paragraph: rewrite it from the facts.' })\n }\n let contrast = false\n for (const { pattern, category, fix } of PHRASE_RULES) {\n const match = paragraph.match(pattern)\n if (!match) continue\n if (category === 'contrast-reveal') {\n if (contrast) continue\n contrast = true\n }\n findings.push({ tier: 'ban', category, match: match[0].trim(), paragraph: index, fix })\n }\n if (contrast) contrastParagraphs += 1\n let run = 0\n for (const sentence of paragraph.split(/(?<=[.!?])\\s+/)) {\n const count = wordCount(sentence)\n run = count > 0 && count <= 3 ? run + 1 : 0\n if (run === 3) {\n findings.push({ tier: 'cap', category: 'fragment-drumbeat', match: sentence, paragraph: index, fix: 'Merge the fragments into one sentence that carries a fact.' })\n break\n }\n }\n })\n\n const dashes = prose.match(DASH)?.length ?? 0\n if (dashes > 0) {\n const tier: CopyTellTier = surface === 'short' ? 'ban' : dashes > 2 ? 'cap' : 'weak'\n const fix = surface === 'short'\n ? 'Short copy uses no dashes between words: use a period, comma or colon.'\n : 'Long copy allows two dashes per page at most; prefer a period or comma.'\n findings.push({ tier, category: 'dash', match: `${dashes} dash${dashes === 1 ? '' : 'es'}`, paragraph: -1, fix })\n }\n if (CURLY.test(text)) {\n findings.push({ tier: 'weak', category: 'decoration', match: 'curly quotes', paragraph: -1, fix: 'Weak alone: use the quote style the target format uses.' })\n }\n const wrapper = chatWrapperIn(text)\n if (wrapper !== null) {\n findings.push({ tier: 'ban', category: 'chat-wrapper', match: wrapper, paragraph: -1, fix: 'Return only the deliverable, with no chat around it.' })\n }\n\n const counts: Record<CopyTellTier, number> = { ban: 0, cap: 0, weak: 0 }\n for (const finding of findings) counts[finding.tier] += 1\n const words = wordCount(prose)\n // Saturates at 40 tell words per 1,000, a contrast in every paragraph, and 10% repeated trigrams.\n const wordRate = Math.min(1, (tellWords * 1000) / Math.max(1, words) / 40)\n const contrastRate = paragraphs.length === 0 ? 0 : contrastParagraphs / paragraphs.length\n const trigramRate = Math.min(1, repeatedTrigramRate(prose) * 10)\n const slopScore = Math.round(100 * (0.6 * wordRate + 0.25 * contrastRate + 0.15 * trigramRate))\n return { pass: counts.ban === 0 && counts.cap === 0, findings, counts, slopScore, words }\n}\n\n/** The chat wrapper around a deliverable (\"Here's a draft…\", \"Hope this helps\"), or null. */\nexport function chatWrapperIn(text: string): string | null {\n const prose = proseOf(text)\n for (const pattern of CHAT_WRAPPERS) {\n const match = prose.match(pattern)\n if (match) return match[0].trim()\n }\n return null\n}\n\n/**\n * Banned words and phrases for prompts that list them: base forms, lowercased,\n * deduplicated, product extras first. The scanner matches their inflections.\n */\nexport function bannedCopyVocabulary(extra: readonly string[] = []): string[] {\n return [...new Set([...extra, ...BAN_WORDS].map((word) => word.toLowerCase()))]\n}\n\nexport interface MetricClaim {\n /** The figure as written, e.g. \"$0.02/hr\", \"40%\", \"10x\", \"300ms\". */\n text: string\n /** Canonical value used to match it against sources (claim-support rules). */\n value: string\n}\n\n// A figure a reader takes as a measured fact: money, a percentage, a multiple,\n// a duration or size with its unit, a scaled count, or a grouped number.\n// Bare small integers (\"3 steps\") and years are not metrics.\nconst METRIC =\n /[$€£¥₹]\\s?\\d[\\d,]*(?:\\.\\d+)?(?:\\s?[kKmMbB]\\b)?|\\b\\d[\\d,]*(?:\\.\\d+)?\\s?(?:%|x\\b|×|ms\\b|s\\b|sec\\b|secs\\b|seconds?\\b|mins?\\b|minutes?\\b|hrs?\\b|hours?\\b|days?\\b|[kKmMbB]\\+?(?=\\s|$|[.,;])|[KMGT]B\\b|rps\\b|qps\\b|tokens?\\b)|\\b\\d{1,3}(?:,\\d{3})+(?:\\.\\d+)?\\b/g\n\n/** Every figure in `text` a reader would take as a measured fact. */\nexport function metricClaims(text: string): MetricClaim[] {\n const claims: MetricClaim[] = []\n for (const match of proseOf(text).matchAll(METRIC)) {\n const numeric = match[0].match(/[$€£¥₹]?\\s?\\d[\\d,]*(?:\\.\\d+)?/)?.[0]\n const value = numeric ? canonicalizeValue(numeric) : null\n if (value !== null) claims.push({ text: match[0].trim(), value })\n }\n return claims\n}\n\n/**\n * Metric claims in `copy` whose value appears in none of `sources`: figures\n * the writer cannot point to. Values match with claim-support's\n * canonicalization, so \"$1,200\" in copy matches \"1200.00\" in a source.\n */\nexport function unsourcedMetrics(copy: string, sources: readonly string[]): MetricClaim[] {\n const known = new Set(sources.flatMap((source) => valuesInText(source)))\n return metricClaims(copy).filter((claim) => !known.has(claim.value))\n}\n"],"mappings":";;;;;;AAqFO,IAAM,YAA+B;AAAA,EAC1C;AAAA,EAAS;AAAA,EAAY;AAAA,EAAgB;AAAA,EAAS;AAAA,EAAU;AAAA,EAAU;AAAA,EAClE;AAAA,EAAY;AAAA,EAAW;AAAA,EAAU;AAAA,EAAY;AAAA,EAAc;AAAA,EAAa;AAAA,EACxE;AAAA,EAAY;AAAA,EAAe;AAAA,EAAe;AAAA,EAAgB;AAAA,EAC1D;AAAA,EAA2B;AAC7B;AAGO,IAAM,YAA+B;AAAA,EAC1C;AAAA,EAAY;AAAA,EAAU;AAAA,EAAc;AAAA,EAAW;AAAA,EAAW;AAAA,EAAU;AAAA,EACpE;AAAA,EAAW;AAAA,EAAU;AAAA,EAAW;AAAA,EAAY;AAAA,EAAgB;AAAA,EAC5D;AAAA,EAAiB;AAAA,EAAkB;AAAA,EAAY;AAAA,EAAiB;AAAA,EAAW;AAAA,EAC3E;AAAA,EAAS;AAAA,EAAY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,SACJ;AAGK,SAAS,aAAa,MAA6B;AACxD,QAAM,SAAwB,CAAC;AAC/B,aAAW,SAAS,QAAQ,IAAI,EAAE,SAAS,MAAM,GAAG;AAClD,UAAM,UAAU,MAAM,CAAC,EAAE,MAAM,+BAA+B,IAAI,CAAC;AACnE,UAAM,QAAQ,UAAU,kBAAkB,OAAO,IAAI;AACrD,QAAI,UAAU,KAAM,QAAO,KAAK,EAAE,MAAM,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;AAAA,EAClE;AACA,SAAO;AACT;AAOO,SAAS,iBAAiB,MAAc,SAA2C;AACxF,QAAM,QAAQ,IAAI,IAAI,QAAQ,QAAQ,CAAC,WAAW,aAAa,MAAM,CAAC,CAAC;AACvE,SAAO,aAAa,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,MAAM,IAAI,MAAM,KAAK,CAAC;AACrE;","names":[]}
|
|
@@ -193,7 +193,7 @@ var EditorErrorBoundary = class extends Component {
|
|
|
193
193
|
}
|
|
194
194
|
render() {
|
|
195
195
|
if (this.state.error) {
|
|
196
|
-
const msg = this.state.error instanceof Error ? this.state.error.message : typeof this.state.error === "string" ? this.state.error :
|
|
196
|
+
const msg = this.state.error instanceof Error ? this.state.error.message : typeof this.state.error === "string" ? this.state.error : `${this.props.label} did not load. Reload the page to try again.`;
|
|
197
197
|
return /* @__PURE__ */ jsxs2("div", { className: "flex h-full flex-1 flex-col items-center justify-center p-8 text-center", children: [
|
|
198
198
|
/* @__PURE__ */ jsxs2("h3", { className: "mb-1 text-sm font-medium text-foreground", children: [
|
|
199
199
|
this.props.label,
|
|
@@ -1142,4 +1142,4 @@ export {
|
|
|
1142
1142
|
ConfirmDialog,
|
|
1143
1143
|
VaultPane
|
|
1144
1144
|
};
|
|
1145
|
-
//# sourceMappingURL=chunk-
|
|
1145
|
+
//# sourceMappingURL=chunk-XADC73A7.js.map
|