@mcurcio/patchbay 0.4.0 → 0.6.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.
Files changed (55) hide show
  1. package/README.md +8 -7
  2. package/dist/composites.css +1 -1
  3. package/dist/composites.js +573 -53
  4. package/dist/composites.js.map +1 -1
  5. package/dist/graph.css +1 -0
  6. package/dist/graph.js +696 -0
  7. package/dist/graph.js.map +1 -0
  8. package/dist/hooks.js +433 -28
  9. package/dist/hooks.js.map +1 -1
  10. package/dist/primitives.css +1 -1
  11. package/dist/primitives.js +34 -16
  12. package/dist/primitives.js.map +1 -1
  13. package/dist/tokens.css +22 -2
  14. package/dist/types/composites/command-palette/CommandPalette.d.ts +68 -0
  15. package/dist/types/composites/command-palette/index.d.ts +4 -0
  16. package/dist/types/composites/command-palette/rank.d.ts +39 -0
  17. package/dist/types/composites/index.d.ts +3 -0
  18. package/dist/types/composites/shortcut-sheet/ShortcutSheet.d.ts +41 -0
  19. package/dist/types/composites/shortcut-sheet/index.d.ts +2 -0
  20. package/dist/types/composites/toaster/Toaster.d.ts +38 -0
  21. package/dist/types/composites/toaster/index.d.ts +2 -0
  22. package/dist/types/graph/add-at/index.d.ts +2 -0
  23. package/dist/types/graph/add-at/useAddAt.d.ts +32 -0
  24. package/dist/types/graph/canvas-tools/CanvasTools.d.ts +40 -0
  25. package/dist/types/graph/canvas-tools/index.d.ts +2 -0
  26. package/dist/types/graph/canvas-tools/motion.d.ts +2 -0
  27. package/dist/types/graph/connect-hints/index.d.ts +4 -0
  28. package/dist/types/graph/connect-hints/mergeFlowProps.d.ts +10 -0
  29. package/dist/types/graph/connect-hints/useConnectHints.d.ts +48 -0
  30. package/dist/types/graph/follow-fit/index.d.ts +2 -0
  31. package/dist/types/graph/follow-fit/useFollowFit.d.ts +21 -0
  32. package/dist/types/graph/ghost-wire/GhostWire.d.ts +16 -0
  33. package/dist/types/graph/ghost-wire/index.d.ts +2 -0
  34. package/dist/types/graph/index.d.ts +9 -1
  35. package/dist/types/graph/meter/Meter.d.ts +56 -0
  36. package/dist/types/graph/meter/index.d.ts +2 -0
  37. package/dist/types/graph/node-box/NodeBox.d.ts +53 -0
  38. package/dist/types/graph/node-box/geometry.d.ts +47 -0
  39. package/dist/types/graph/node-box/index.d.ts +4 -0
  40. package/dist/types/graph/port-row/PortRow.d.ts +31 -0
  41. package/dist/types/graph/port-row/index.d.ts +2 -0
  42. package/dist/types/graph/wire/Wire.d.ts +27 -0
  43. package/dist/types/graph/wire/index.d.ts +2 -0
  44. package/dist/types/hooks/index.d.ts +4 -0
  45. package/dist/types/hooks/use-live-value/index.d.ts +2 -0
  46. package/dist/types/hooks/use-live-value/useLiveValue.d.ts +9 -0
  47. package/dist/types/hooks/use-media-breakpoint/index.d.ts +2 -0
  48. package/dist/types/hooks/use-media-breakpoint/useMediaBreakpoint.d.ts +25 -0
  49. package/dist/types/hooks/use-shortcuts/index.d.ts +2 -0
  50. package/dist/types/hooks/use-shortcuts/useShortcuts.d.ts +58 -0
  51. package/dist/types/hooks/use-toasts/index.d.ts +4 -0
  52. package/dist/types/hooks/use-toasts/toastQueue.d.ts +76 -0
  53. package/dist/types/hooks/use-toasts/useToasts.d.ts +31 -0
  54. package/dist/types/primitives/button/Button.d.ts +4 -1
  55. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"composites.js","names":["Banner","rest","tone","className","actions","onDismiss","IconButton","dismissLabel","diffLineKind","line","baseName","path","part","lines","all","text","DiffBody","index","DiffView","base","useId","ownCollapsed","setOwnCollapsed","useState","folded","collapsed","Heading","level","toggle","open","was","other","onToggle","files","diff","file","bodyId","StatusWords","items","item"],"sources":["../src/composites/banner/Banner.tsx","../src/composites/diff-view/DiffView.tsx","../src/composites/status-words/StatusWords.tsx"],"sourcesContent":["// A banner: a line of news across the top of a pane or page (a conflict, a lost connection, a refused edit), drawn in\n// its tone, with the app's actions at its end and, if the app lets it go, a close button. An error is an alert, so a\n// screen reader reads it at once; every other tone is a status, read when the reader is free. A tone it does not know\n// is drawn neutrally.\nimport type { ComponentPropsWithRef, ReactNode } from \"react\";\nimport { IconButton } from \"../../primitives\";\nimport \"./Banner.css\";\n\n/** The tones a banner draws; any other string is drawn neutrally. */\nexport type BannerTone = \"ok\" | \"warn\" | \"err\" | \"quiet\" | \"off\" | (string & {});\n\nexport type BannerProps = Omit<ComponentPropsWithRef<\"div\">, \"role\"> & {\n /** What the news is, by colour: the stripe's, and the surface's for warn and err. */\n tone: BannerTone;\n /** The news, in words. */\n children: ReactNode;\n /** A slot at the end: the buttons that act on the news. */\n actions?: ReactNode;\n /** Shows a close button, which asks the app to take the banner away. */\n onDismiss?: () => void;\n /** The close button's name, \"Dismiss\" by default. */\n dismissLabel?: string;\n};\n\nexport function Banner({\n tone,\n children,\n actions,\n onDismiss,\n dismissLabel = \"Dismiss\",\n className,\n ...rest\n}: BannerProps) {\n return (\n <div\n {...rest}\n role={tone === \"err\" ? \"alert\" : \"status\"}\n className={className === undefined ? \"pb-banner\" : `pb-banner ${className}`}\n data-tone={tone}\n >\n <div className=\"pb-banner-text\">{children}</div>\n {actions !== undefined && <div className=\"pb-banner-actions\">{actions}</div>}\n {onDismiss !== undefined && (\n <IconButton className=\"pb-banner-dismiss\" size=\"sm\" label={dismissLabel} onClick={onDismiss}>\n <svg viewBox=\"0 0 16 16\" width=\"12\" height=\"12\" aria-hidden=\"true\">\n <path d=\"M3 3l10 10M13 3L3 13\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.75\" />\n </svg>\n </IconButton>\n )}\n </div>\n );\n}\n","// A diff: unified diff text drawn line by line, added lines in the added tone and removed ones in the removed tone,\n// each keeping its \"+\" or \"-\" so the change never rests on colour alone. Given files, each is a section of its own\n// under a heading, labelled by its file name with its whole path on hover, that the person can fold away.\nimport { useId, useState, type ComponentPropsWithRef } from \"react\";\nimport \"./DiffView.css\";\n\nexport type DiffFile = {\n /** The file's path; the section is labelled by its last part. Unique among the files. */\n path: string;\n /** The file's unified diff text. */\n diff: string;\n};\n\n/** What a line of unified diff text is, by its start. */\nexport type DiffLineKind = \"add\" | \"del\" | \"hunk\" | \"meta\" | \"note\" | \"context\";\n\ntype DiffSource =\n | {\n /** One unified diff, drawn whole without a heading. */\n diff: string;\n files?: never;\n }\n | {\n /** One section per file, in this order. */\n files: readonly DiffFile[];\n diff?: never;\n };\n\nexport type DiffViewProps = Omit<ComponentPropsWithRef<\"div\">, \"children\" | \"onToggle\"> &\n DiffSource & {\n /** The files' headings' level, h2 to h6 (h3 by default). */\n level?: 2 | 3 | 4 | 5 | 6;\n /**\n * The paths of the files folded away. Given, the app holds them and onToggle asks it to change them; left out,\n * the view keeps its own, every file open at first.\n */\n collapsed?: readonly string[];\n /** Called when the person opens (true) or folds (false) a file's section. */\n onToggle?: (path: string, open: boolean) => void;\n };\n\n/** The kind of one line of unified diff text. */\nexport function diffLineKind(line: string): DiffLineKind {\n if (line.startsWith(\"+++ \") || line.startsWith(\"--- \")) return \"meta\";\n if (line.startsWith(\"@@\")) return \"hunk\";\n if (line.startsWith(\"+\")) return \"add\";\n if (line.startsWith(\"-\")) return \"del\";\n if (line.startsWith(\"\\\\\")) return \"note\";\n if (line === \"\" || line.startsWith(\" \")) return \"context\";\n // A git header line: diff --git, index, new file mode, rename from, similarity index and the like.\n return \"meta\";\n}\n\n/** A path's last part: \"src/app/main.ts\" is \"main.ts\". */\nexport function baseName(path: string): string {\n const parts = path.split(\"/\").filter((part) => part !== \"\");\n return parts.at(-1) ?? path;\n}\n\nfunction lines(text: string): string[] {\n const all = text.split(/\\r?\\n/);\n // A diff ends with a newline, which starts no line of its own.\n if (all.length > 0 && all.at(-1) === \"\") all.pop();\n return all;\n}\n\nfunction DiffBody({ text, id, hidden }: { text: string; id?: string; hidden?: boolean }) {\n return (\n // Focusable, so a wide diff can be scrolled sideways from the keyboard.\n <pre className=\"pb-diff-body\" id={id} hidden={hidden} tabIndex={0}>\n <code className=\"pb-diff-code\">\n {lines(text).map((line, index) => (\n <span key={index} className=\"pb-diff-line\" data-kind={diffLineKind(line)}>\n {line === \"\" ? \" \" : line}\n </span>\n ))}\n </code>\n </pre>\n );\n}\n\nexport function DiffView({ diff, files, level = 3, collapsed, onToggle, className, ...rest }: DiffViewProps) {\n const base = useId();\n const [ownCollapsed, setOwnCollapsed] = useState<readonly string[]>([]);\n const folded = collapsed ?? ownCollapsed;\n const Heading = `h${String(level)}` as \"h3\";\n const toggle = (path: string, open: boolean) => {\n if (collapsed === undefined) {\n setOwnCollapsed((was) => (open ? was.filter((other) => other !== path) : [...was, path]));\n }\n onToggle?.(path, open);\n };\n return (\n <div {...rest} className={className === undefined ? \"pb-diff\" : `pb-diff ${className}`}>\n {files === undefined ? (\n <DiffBody text={diff} />\n ) : (\n files.map((file, index) => {\n const open = !folded.includes(file.path);\n const bodyId = `${base}-${String(index)}`;\n return (\n <div key={file.path} className=\"pb-diff-file\" data-open={open || undefined}>\n <Heading className=\"pb-diff-file-title\">\n <button\n type=\"button\"\n className=\"pb-diff-toggle\"\n aria-expanded={open}\n aria-controls={bodyId}\n title={file.path}\n onClick={() => {\n toggle(file.path, !open);\n }}\n >\n <svg className=\"pb-diff-chevron\" viewBox=\"0 0 16 16\" width=\"10\" height=\"10\" aria-hidden=\"true\">\n <path d=\"M5 3l5 5-5 5\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" />\n </svg>\n {baseName(file.path)}\n </button>\n </Heading>\n <DiffBody text={file.diff} id={bodyId} hidden={!open} />\n </div>\n );\n })\n )}\n </div>\n );\n}\n","// Status words: a short row of states, each a word in its tone (a pane's \"3 errors · 1 warning · saved\"), in the order\n// the app gives, which is most urgent first. The row is one polite live region, so a screen reader reads a change\n// when it is free. A tone it does not know is drawn neutrally.\nimport type { ComponentPropsWithRef } from \"react\";\nimport \"./StatusWords.css\";\n\n/** The tones a word draws; any other string is drawn neutrally. */\nexport type StatusWordTone = \"ok\" | \"warn\" | \"err\" | \"quiet\" | \"off\" | (string & {});\n\nexport type StatusWord = {\n tone: StatusWordTone;\n /** The state in words. */\n label: string;\n /** Shown on hover: what the state means or why it is so. */\n title?: string;\n};\n\nexport type StatusWordsProps = Omit<ComponentPropsWithRef<\"ul\">, \"children\"> & {\n /** The states, most urgent first; drawn in this order. */\n items: readonly StatusWord[];\n};\n\nexport function StatusWords({ items, className, ...rest }: StatusWordsProps) {\n return (\n <ul\n aria-live=\"polite\"\n {...rest}\n className={className === undefined ? \"pb-status-words\" : `pb-status-words ${className}`}\n >\n {items.map((item, index) => (\n <li key={`${String(index)}:${item.label}`} className=\"pb-status-word\" data-tone={item.tone} title={item.title}>\n {item.label}\n </li>\n ))}\n </ul>\n );\n}\n"],"mappings":";;;;AAwBA,SAAgBA,EAAO,EACrB,SACA,aACA,YACA,cACA,kBAAe,WACf,cACA,GAAGC,KACW;CACd,OACE,kBAAC,OAAD;EACE,GAAIA;EACJ,MAAMC,MAAS,QAAQ,UAAU;EACjC,WAAWC,MAAc,KAAA,IAAY,cAAc,aAAaA;EAChE,aAAWD;EAJb,UAAA;GAME,kBAAC,OAAD;IAAK,WAAU;IAAkB;GAAc,CAAA;GAC9CE,MAAY,KAAA,KAAa,kBAAC,OAAD;IAAK,WAAU;IAAqB,UAAAA;GAAa,CAAA;GAC1EC,MAAc,KAAA,KACb,kBAACC,GAAD;IAAY,WAAU;IAAoB,MAAK;IAAK,OAAOC;IAAc,SAASF;IAChF,UAAA,kBAAC,OAAD;KAAK,SAAQ;KAAY,OAAM;KAAK,QAAO;KAAK,eAAY;KAC1D,UAAA,kBAAC,QAAD;MAAM,GAAE;MAAuB,MAAK;MAAO,QAAO;MAAe,aAAY;KAAQ,CAAA;IAClF,CAAA;GACK,CAAA;EAEX;;AAET;;ACTA,SAAgBG,EAAa,GAA4B;CAQvD,OAPIC,EAAK,WAAW,MAAM,KAAKA,EAAK,WAAW,MAAM,IAAU,SAC3DA,EAAK,WAAW,IAAI,IAAU,SAC9BA,EAAK,WAAW,GAAG,IAAU,QAC7BA,EAAK,WA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","Banner","rest","tone","className","actions","onDismiss","IconButton","dismissLabel","wordStart","at","before","text","here","fold","lower","unit","startBonus","wordBonus","nextBonus","gapCost","gapCostMost","lateCost","matchSubsequence","squeezed","query","wanted","n","m","bonus","best","from","j","row","back","letter","i","own","previous","k","joined","score","last","end","indices","rankCommands","groups","match","command","group","order","byScore","b","a","sorted","items","markRuns","marked","runs","label","isMarked","PALETTE_WIDTH","PALETTE_HEIGHT","PALETTE_GUTTER","placePalette","width","window","height","clamp","value","room","size","defaultNoMatch","fallbackPage","useWindowSize","read","setSize","useState","useEffect","watch","onResize","OpenPalette","ids","useId","listId","setQuery","useMemo","commands","flat","item","enabled","chosen","setChosen","queried","setQueried","active","optionId","box","useRef","field","list","onCloseRef","onClose","useLayoutEffect","owned","now","option","run","pageSize","rows","onKeyDown","event","modified","move","next","to","windowSize","placed","anchored","body","emptyLabel","noMatchLabel","headingId","index","id","keys","selected","ariaKeyShortcuts","platform","part","keyLabel","one","keyNames","CommandPalette","open","createPortal","diffLineKind","line","baseName","path","lines","all","DiffBody","DiffView","base","ownCollapsed","setOwnCollapsed","folded","collapsed","Heading","level","toggle","was","other","onToggle","files","diff","file","bodyId","groupShortcuts","shortcuts","ShortcutSheet","Dialog","orLabel","children","StatusWords","placements","defaultMoreLabel","more","defaultCountLabel","count","heardLimit","Toaster","drawn","placement","top","ordered","toasts","empty","heard","sequence","said","setSaid","news","toast","shown","fresh","kept","shownIds","say","alert","countLabel","regions","hovered","setHovered","focused","setFocused","held","latestHold","onHold","cameFrom","focusNext","dismiss","moreLine","moreLabel","Fragment","onPointerEnter","onPointerLeave","onBlur","textId","Button"],"sources":["../src/composites/banner/Banner.tsx","../src/composites/command-palette/rank.ts","../src/composites/command-palette/CommandPalette.tsx","../src/composites/diff-view/DiffView.tsx","../src/composites/shortcut-sheet/ShortcutSheet.tsx","../src/composites/status-words/StatusWords.tsx","../src/composites/toaster/Toaster.tsx"],"sourcesContent":["// A banner: a line of news across the top of a pane or page (a conflict, a lost connection, a refused edit), drawn in\n// its tone, with the app's actions at its end and, if the app lets it go, a close button. An error is an alert, so a\n// screen reader reads it at once; every other tone is a status, read when the reader is free. A tone it does not know\n// is drawn neutrally.\nimport type { ComponentPropsWithRef, ReactNode } from \"react\";\nimport { IconButton } from \"../../primitives\";\nimport \"./Banner.css\";\n\n/** The tones a banner draws; any other string is drawn neutrally. */\nexport type BannerTone = \"ok\" | \"warn\" | \"err\" | \"quiet\" | \"off\" | (string & {});\n\nexport type BannerProps = Omit<ComponentPropsWithRef<\"div\">, \"role\"> & {\n /** What the news is, by colour: the stripe's, and the surface's for warn and err. */\n tone: BannerTone;\n /** The news, in words. */\n children: ReactNode;\n /** A slot at the end: the buttons that act on the news. */\n actions?: ReactNode;\n /** Shows a close button, which asks the app to take the banner away. */\n onDismiss?: () => void;\n /** The close button's name, \"Dismiss\" by default. */\n dismissLabel?: string;\n};\n\nexport function Banner({\n tone,\n children,\n actions,\n onDismiss,\n dismissLabel = \"Dismiss\",\n className,\n ...rest\n}: BannerProps) {\n return (\n <div\n {...rest}\n role={tone === \"err\" ? \"alert\" : \"status\"}\n className={className === undefined ? \"pb-banner\" : `pb-banner ${className}`}\n data-tone={tone}\n >\n <div className=\"pb-banner-text\">{children}</div>\n {actions !== undefined && <div className=\"pb-banner-actions\">{actions}</div>}\n {onDismiss !== undefined && (\n <IconButton className=\"pb-banner-dismiss\" size=\"sm\" label={dismissLabel} onClick={onDismiss}>\n <svg viewBox=\"0 0 16 16\" width=\"12\" height=\"12\" aria-hidden=\"true\">\n <path d=\"M3 3l10 10M13 3L3 13\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.75\" />\n </svg>\n </IconButton>\n )}\n </div>\n );\n}\n","// The command palette's ranking (docs/components.md#commands-and-keys): a query matches a label when its letters appear\n// in the label in order, in any case, not necessarily together (\"adn\" matches \"Add a node\"). Of the ways the letters\n// can be found, the best is kept: letters at the start of a word and letters next to each other score more, gaps and\n// a late start score less. Pure, so the palette and an app's tests share it.\n\n/** Where a query's letters fell in a label, and how good the match is. */\nexport type SubsequenceMatch = {\n /** The indices (UTF-16 code units) of the label's matched characters, ascending. */\n indices: number[];\n /** Higher is better; an empty query scores 0. */\n score: number;\n};\n\n/** A word starts at the label's start, after a character that is not a letter or digit, or at a capital after a small letter. */\nfunction wordStart(text: string, at: number): boolean {\n if (at === 0) return true;\n const before = text.charAt(at - 1);\n const here = text.charAt(at);\n if (!/[\\p{L}\\p{N}]/u.test(before)) return true;\n return before !== before.toUpperCase() && here !== here.toLowerCase() && here === here.toUpperCase();\n}\n\n/** A code unit in lower case, unless lowering it makes more than one (\"İ\"), which is then compared as it is. */\nfunction fold(unit: string): string {\n const lower = unit.toLowerCase();\n return lower.length === 1 ? lower : unit;\n}\n\nconst startBonus = 3;\nconst wordBonus = 2;\nconst nextBonus = 2;\nconst gapCost = 0.1;\nconst gapCostMost = 1;\nconst lateCost = 0.02;\n\n/**\n * Finds the query's letters in the text, in order and in any case (white space in the query is ignored), the best\n * way it can; undefined when they are not all there.\n */\nexport function matchSubsequence(text: string, query: string): SubsequenceMatch | undefined {\n const squeezed = query.replace(/\\s+/g, \"\");\n if (squeezed === \"\") return { indices: [], score: 0 };\n // Compared one UTF-16 code unit at a time, each folded the same way, so an index is a place in the label.\n const wanted = Array.from({ length: squeezed.length }, (_, at) => fold(squeezed.charAt(at)));\n const lower = Array.from({ length: text.length }, (_, at) => fold(text.charAt(at)));\n const n = text.length;\n const m = wanted.length;\n if (m > n) return undefined;\n const bonus = lower.map((_, at) => (at === 0 ? startBonus : wordStart(text, at) ? wordBonus : 0));\n // best[j][i]: the best score with the query's letter j at the text's index i; from[j][i]: where letter j-1 was.\n const best: number[][] = [];\n const from: number[][] = [];\n for (let j = 0; j < m; j += 1) {\n const row = new Array<number>(n).fill(-Infinity);\n const back = new Array<number>(n).fill(-1);\n const letter = wanted[j];\n for (let i = j; i < n; i += 1) {\n if (lower[i] !== letter) continue;\n const own = 1 + (bonus[i] ?? 0);\n if (j === 0) {\n row[i] = own - i * lateCost;\n continue;\n }\n const previous = best[j - 1] ?? [];\n for (let k = j - 1; k < i; k += 1) {\n const before = previous[k] ?? -Infinity;\n if (before === -Infinity) continue;\n const joined = k === i - 1 ? nextBonus : -Math.min((i - k - 1) * gapCost, gapCostMost);\n const score = before + own + joined;\n if (score > (row[i] ?? -Infinity)) {\n row[i] = score;\n back[i] = k;\n }\n }\n }\n best.push(row);\n from.push(back);\n }\n const last = best[m - 1] ?? [];\n let end = -1;\n for (let i = 0; i < n; i += 1) if ((last[i] ?? -Infinity) > (end < 0 ? -Infinity : (last[end] ?? -Infinity))) end = i;\n if (end < 0 || last[end] === -Infinity) return undefined;\n const indices: number[] = [];\n for (let j = m - 1, at = end; j >= 0; j -= 1) {\n indices.unshift(at);\n at = from[j]?.[at] ?? -1;\n }\n return { indices, score: last[end] ?? 0 };\n}\n\n/** What ranking needs of a command. */\nexport type Rankable = { label: string; group: string };\n\n/** A command that matched, with where its letters fell. */\nexport type RankedCommand<C extends Rankable> = { command: C; indices: number[]; score: number };\n\n/** One group's matching commands. */\nexport type RankedGroup<C extends Rankable> = { group: string; items: RankedCommand<C>[] };\n\n/**\n * The commands whose labels match the query, in groups. With an empty query every command is kept, in the order given\n * and its groups in the order they first appear; with one, each group's commands go best first and the groups by\n * their best command, ties kept in the order given. Groups with no match are left out.\n */\nexport function rankCommands<C extends Rankable>(commands: readonly C[], query: string): RankedGroup<C>[] {\n const groups = new Map<string, { first: number; items: (RankedCommand<C> & { order: number })[] }>();\n commands.forEach((command, order) => {\n const match = matchSubsequence(command.label, query);\n if (match === undefined) return;\n let group = groups.get(command.group);\n if (group === undefined) {\n group = { first: order, items: [] };\n groups.set(command.group, group);\n }\n group.items.push({ command, indices: match.indices, score: match.score, order });\n });\n const byScore = (a: { score: number; order: number }, b: { score: number; order: number }) =>\n b.score - a.score || a.order - b.order;\n return [...groups.entries()]\n .map(([group, { first, items }]) => {\n const sorted = [...items].sort(byScore);\n return { group, first, items: sorted, top: sorted[0]?.score ?? 0 };\n })\n .sort((a, b) => b.top - a.top || a.first - b.first)\n .map(({ group, items }) => ({\n group,\n items: items.map(({ command, indices, score }) => ({ command, indices, score })),\n }));\n}\n\n/** The label cut into runs, each marked or not, so the matched letters can be drawn in <mark>. */\nexport function markRuns(label: string, indices: readonly number[]): { text: string; marked: boolean }[] {\n const marked = new Set(indices);\n const runs: { text: string; marked: boolean }[] = [];\n for (let at = 0; at < label.length; at += 1) {\n const isMarked = marked.has(at);\n const last = runs[runs.length - 1];\n if (last !== undefined && last.marked === isMarked) last.text += label.charAt(at);\n else runs.push({ text: label.charAt(at), marked: isMarked });\n }\n return runs;\n}\n","// A command palette (docs/components.md#commands-and-keys): a search field over a list of the app's commands, drawn in a\n// portal on <body>, centred near the top of the window or anchored at a point and kept inside it. Typing ranks the\n// commands by their labels (rank.ts), the matched letters in <mark>; the arrows, Page Up and Page Down, Home and End\n// move the active command and Enter runs it. The field is a combobox and the list a listbox, so the focus stays in the\n// field the whole time. Escape, Tab, a press outside and the focus leaving ask the app to close it; closing gives the\n// focus back to what had it before.\nimport {\n type KeyboardEvent,\n type ReactNode,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { type Platform, ariaKeyShortcuts, keyLabel } from \"../../hooks\";\nimport { markRuns, rankCommands } from \"./rank\";\nimport \"./CommandPalette.css\";\n\n/** One command in the palette. */\nexport type Command = {\n /** Unique among the commands; the active command is kept by it while the list changes. */\n id: string;\n /** What the command is called; the query is matched against it. */\n label: string;\n /** The heading it is listed under; groups are shown in the order they first appear. */\n group: string;\n /** Its key string, or several, shown through keyLabel (\"Mod+K\"); the palette does not bind them. */\n keys?: string | readonly string[];\n /** A second, quieter line: what it does, or what it acts on. Not matched. */\n hint?: string;\n /** Runs the command; the palette asks to close first. */\n run: () => void;\n /** Shown but skipped by the keys, and does nothing when pressed. */\n disabled?: boolean;\n};\n\n/** A point in the window's coordinates (client px), such as where a press happened. */\nexport type PalettePoint = { x: number; y: number };\n\nexport type CommandPaletteProps = {\n /** Whether the palette is shown; the app holds it. */\n open: boolean;\n /** Asked for on Escape, Tab, a press outside, the focus leaving, and before a command runs. */\n onClose: () => void;\n commands: readonly Command[];\n /** Anchors the palette's top-left corner at this point, kept inside the window; centred near the top without it. */\n at?: PalettePoint;\n /** The field's placeholder, \"Type a command\" by default. */\n placeholder?: string;\n /** The palette's name for screen readers, \"Commands\" by default. */\n label?: string;\n /** Shown when there are no commands at all, \"No commands\" by default. */\n emptyLabel?: ReactNode;\n /** Shown when the query matches none, \"No command matches “query”\" by default. */\n noMatchLabel?: (query: string) => ReactNode;\n /** The platform keys are drawn for; the browser's by default. */\n platform?: Platform;\n /** Replaces keyLabel's words for keys and modifiers (\"Escape\", \"Ctrl\"). */\n keyNames?: Readonly<Record<string, string>>;\n /** A class added to the palette's box. */\n className?: string;\n};\n\n/** The anchored palette's size, held inside the window less the gutter. */\nexport const PALETTE_WIDTH = 320;\nexport const PALETTE_HEIGHT = 360;\n/** How far the anchored palette stays from the window's edges. */\nexport const PALETTE_GUTTER = 8;\n\n/**\n * Where an anchored palette goes: its top-left corner at the point, moved back inside the window (less the gutter)\n * where it would cross an edge, and made smaller when the window is smaller than the palette. The height is the\n * most it may take; a short list takes less.\n */\nexport function placePalette(\n at: PalettePoint,\n window: { width: number; height: number },\n): { left: number; top: number; width: number; height: number } {\n const width = Math.max(0, Math.min(PALETTE_WIDTH, window.width - 2 * PALETTE_GUTTER));\n const height = Math.max(0, Math.min(PALETTE_HEIGHT, window.height - 2 * PALETTE_GUTTER));\n const clamp = (value: number, size: number, room: number) =>\n Math.min(Math.max(value, PALETTE_GUTTER), Math.max(PALETTE_GUTTER, room - size - PALETTE_GUTTER));\n return { left: clamp(at.x, width, window.width), top: clamp(at.y, height, window.height), width, height };\n}\n\nconst defaultNoMatch = (query: string) => `No command matches “${query}”`;\n\n/** How many rows Page Up and Page Down move when the list's rows cannot be measured. */\nconst fallbackPage = 8;\n\nfunction useWindowSize(watch: boolean) {\n const read = () => ({ width: window.innerWidth, height: window.innerHeight });\n const [size, setSize] = useState(read);\n useEffect(() => {\n if (!watch) return undefined;\n const onResize = () => {\n setSize(read());\n };\n window.addEventListener(\"resize\", onResize);\n return () => {\n window.removeEventListener(\"resize\", onResize);\n };\n }, [watch]);\n return size;\n}\n\nfunction OpenPalette({\n onClose,\n commands,\n at,\n placeholder = \"Type a command\",\n label = \"Commands\",\n emptyLabel = \"No commands\",\n noMatchLabel = defaultNoMatch,\n platform,\n keyNames,\n className,\n}: Omit<CommandPaletteProps, \"open\">) {\n const ids = useId();\n const listId = `${ids}-list`;\n const [query, setQuery] = useState(\"\");\n const groups = useMemo(() => rankCommands(commands, query), [commands, query]);\n const flat = useMemo(() => groups.flatMap((group) => group.items.map((item) => item.command)), [groups]);\n const enabled = useMemo(() => flat.filter((command) => command.disabled !== true), [flat]);\n\n // The active command, by id; when it is gone (filtered out, disabled) the first enabled one takes its place.\n const [chosen, setChosen] = useState<string | undefined>(undefined);\n const [queried, setQueried] = useState(query);\n if (queried !== query) {\n setQueried(query);\n setChosen(undefined);\n }\n const active = enabled.find((command) => command.id === chosen) ?? enabled[0];\n const optionId = (command: Command) => `${ids}-option-${flat.indexOf(command)}`;\n\n const box = useRef<HTMLDivElement>(null);\n const field = useRef<HTMLInputElement>(null);\n const list = useRef<HTMLDivElement>(null);\n const onCloseRef = useRef(onClose);\n useLayoutEffect(() => {\n onCloseRef.current = onClose;\n });\n\n // Focus the field on opening; give the focus back on closing, unless it already went somewhere else on purpose.\n useLayoutEffect(() => {\n const before = document.activeElement instanceof HTMLElement ? document.activeElement : null;\n field.current?.focus();\n const owned = box.current;\n return () => {\n const now = document.activeElement;\n const lost = now === null || now === document.body || (owned?.contains(now) ?? false) || !now.isConnected;\n if (lost && before?.isConnected === true) before.focus();\n };\n }, []);\n\n useEffect(() => {\n if (active === undefined) return;\n const option = document.getElementById(optionId(active));\n // jsdom has no scrollIntoView.\n if (typeof option?.scrollIntoView === \"function\") option.scrollIntoView({ block: \"nearest\" });\n // optionId reads the list, which changes with active.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [active]);\n\n const run = (command: Command) => {\n if (command.disabled === true) return;\n onCloseRef.current();\n command.run();\n };\n\n const pageSize = () => {\n const option = list.current?.querySelector<HTMLElement>('[role=\"option\"]');\n const rows =\n option && option.offsetHeight > 0 ? Math.floor((list.current?.clientHeight ?? 0) / option.offsetHeight) : 0;\n return Math.max(1, rows || fallbackPage);\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.defaultPrevented || event.nativeEvent.isComposing) return;\n const modified = event.altKey || event.ctrlKey || event.metaKey;\n const at = active === undefined ? -1 : enabled.indexOf(active);\n const last = enabled.length - 1;\n const move = (to: number) => {\n event.preventDefault();\n const next = enabled[Math.min(Math.max(to, 0), last)];\n if (next !== undefined) setChosen(next.id);\n };\n switch (event.key) {\n case \"Escape\":\n event.preventDefault();\n event.stopPropagation();\n onCloseRef.current();\n return;\n case \"Tab\":\n // A combobox's popup closes on Tab; the focus goes back to where it came from.\n event.preventDefault();\n onCloseRef.current();\n return;\n case \"Enter\":\n if (modified) return;\n event.preventDefault();\n if (active !== undefined) run(active);\n return;\n case \"ArrowDown\":\n if (modified) return;\n move(at >= last ? 0 : at + 1);\n return;\n case \"ArrowUp\":\n if (modified) return;\n move(at <= 0 ? last : at - 1);\n return;\n case \"PageDown\":\n if (modified) return;\n move(at + pageSize());\n return;\n case \"PageUp\":\n if (modified) return;\n move(at - pageSize());\n return;\n case \"Home\":\n // Shift+Home and Shift+End stay with the field, to select its text.\n if (modified || event.shiftKey) return;\n move(0);\n return;\n case \"End\":\n if (modified || event.shiftKey) return;\n move(last);\n return;\n default:\n return;\n }\n };\n\n const windowSize = useWindowSize(at !== undefined);\n const placed = at === undefined ? undefined : placePalette(at, windowSize);\n const anchored = placed !== undefined;\n\n let body: ReactNode;\n if (commands.length === 0) body = emptyLabel;\n else if (flat.length === 0) body = noMatchLabel(query.trim());\n\n return (\n <div\n className=\"pb-palette-layer\"\n data-anchored={anchored ? \"\" : undefined}\n onMouseDown={(event) => {\n // Only a press that starts outside the palette.\n if (event.target === event.currentTarget) onCloseRef.current();\n }}\n >\n <div\n ref={box}\n className={className === undefined ? \"pb-palette\" : `pb-palette ${className}`}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={label}\n style={\n placed === undefined\n ? undefined\n : { position: \"fixed\", left: placed.left, top: placed.top, width: placed.width, maxHeight: placed.height }\n }\n onBlur={(event) => {\n const to = event.relatedTarget;\n if (to instanceof Node && !event.currentTarget.contains(to)) onCloseRef.current();\n }}\n >\n <input\n ref={field}\n className=\"pb-palette-field\"\n type=\"text\"\n role=\"combobox\"\n aria-label={label}\n aria-expanded=\"true\"\n aria-controls={listId}\n aria-autocomplete=\"list\"\n aria-activedescendant={active === undefined ? undefined : optionId(active)}\n autoComplete=\"off\"\n autoCapitalize=\"off\"\n autoCorrect=\"off\"\n spellCheck={false}\n placeholder={placeholder}\n value={query}\n onChange={(event) => {\n setQuery(event.target.value);\n }}\n onKeyDown={onKeyDown}\n />\n <div\n ref={list}\n className=\"pb-palette-list\"\n id={listId}\n role=\"listbox\"\n aria-label={label}\n hidden={flat.length === 0}\n >\n {groups.map((group, index) => {\n const headingId = `${ids}-group-${index}`;\n return (\n <div key={group.group} role=\"group\" aria-labelledby={headingId} className=\"pb-palette-group\">\n <div id={headingId} className=\"pb-palette-heading\" role=\"presentation\">\n {group.group}\n </div>\n {group.items.map(({ command, indices }) => {\n const id = optionId(command);\n const keys =\n command.keys === undefined ? [] : typeof command.keys === \"string\" ? [command.keys] : command.keys;\n const selected = command === active;\n return (\n <div\n key={command.id}\n id={id}\n role=\"option\"\n aria-selected={selected}\n aria-disabled={command.disabled === true ? true : undefined}\n aria-keyshortcuts={keys.length === 0 ? undefined : ariaKeyShortcuts(keys, platform)}\n className=\"pb-palette-option\"\n data-command-id={command.id}\n onMouseDown={(event) => {\n // Keep the focus in the field.\n event.preventDefault();\n }}\n onPointerMove={() => {\n if (command.disabled !== true && !selected) setChosen(command.id);\n }}\n onClick={() => {\n run(command);\n }}\n >\n <span className=\"pb-palette-text\">\n <span className=\"pb-palette-label\">\n {markRuns(command.label, indices).map((part, at) =>\n part.marked ? <mark key={at}>{part.text}</mark> : part.text,\n )}\n </span>\n {command.hint !== undefined && <span className=\"pb-palette-hint\">{command.hint}</span>}\n </span>\n {keys.length > 0 && (\n <span className=\"pb-palette-keys\">\n {keys.map((one) => (\n <kbd key={one}>{keyLabel(one, { platform, names: keyNames })}</kbd>\n ))}\n </span>\n )}\n </div>\n );\n })}\n </div>\n );\n })}\n </div>\n {/* There from the start, so a screen reader hears the words when the list empties. */}\n <p className=\"pb-palette-empty\" role=\"status\">\n {body}\n </p>\n </div>\n </div>\n );\n}\n\nexport function CommandPalette({ open, ...rest }: CommandPaletteProps) {\n if (!open) return null;\n return createPortal(<OpenPalette {...rest} />, document.body);\n}\n","// A diff: unified diff text drawn line by line, added lines in the added tone and removed ones in the removed tone,\n// each keeping its \"+\" or \"-\" so the change never rests on colour alone. Given files, each is a section of its own\n// under a heading, labelled by its file name with its whole path on hover, that the person can fold away.\nimport { useId, useState, type ComponentPropsWithRef } from \"react\";\nimport \"./DiffView.css\";\n\nexport type DiffFile = {\n /** The file's path; the section is labelled by its last part. Unique among the files. */\n path: string;\n /** The file's unified diff text. */\n diff: string;\n};\n\n/** What a line of unified diff text is, by its start. */\nexport type DiffLineKind = \"add\" | \"del\" | \"hunk\" | \"meta\" | \"note\" | \"context\";\n\ntype DiffSource =\n | {\n /** One unified diff, drawn whole without a heading. */\n diff: string;\n files?: never;\n }\n | {\n /** One section per file, in this order. */\n files: readonly DiffFile[];\n diff?: never;\n };\n\nexport type DiffViewProps = Omit<ComponentPropsWithRef<\"div\">, \"children\" | \"onToggle\"> &\n DiffSource & {\n /** The files' headings' level, h2 to h6 (h3 by default). */\n level?: 2 | 3 | 4 | 5 | 6;\n /**\n * The paths of the files folded away. Given, the app holds them and onToggle asks it to change them; left out,\n * the view keeps its own, every file open at first.\n */\n collapsed?: readonly string[];\n /** Called when the person opens (true) or folds (false) a file's section. */\n onToggle?: (path: string, open: boolean) => void;\n };\n\n/** The kind of one line of unified diff text. */\nexport function diffLineKind(line: string): DiffLineKind {\n if (line.startsWith(\"+++ \") || line.startsWith(\"--- \")) return \"meta\";\n if (line.startsWith(\"@@\")) return \"hunk\";\n if (line.startsWith(\"+\")) return \"add\";\n if (line.startsWith(\"-\")) return \"del\";\n if (line.startsWith(\"\\\\\")) return \"note\";\n if (line === \"\" || line.startsWith(\" \")) return \"context\";\n // A git header line: diff --git, index, new file mode, rename from, similarity index and the like.\n return \"meta\";\n}\n\n/** A path's last part: \"src/app/main.ts\" is \"main.ts\". */\nexport function baseName(path: string): string {\n const parts = path.split(\"/\").filter((part) => part !== \"\");\n return parts.at(-1) ?? path;\n}\n\nfunction lines(text: string): string[] {\n const all = text.split(/\\r?\\n/);\n // A diff ends with a newline, which starts no line of its own.\n if (all.length > 0 && all.at(-1) === \"\") all.pop();\n return all;\n}\n\nfunction DiffBody({ text, id, hidden }: { text: string; id?: string; hidden?: boolean }) {\n return (\n // Focusable, so a wide diff can be scrolled sideways from the keyboard.\n <pre className=\"pb-diff-body\" id={id} hidden={hidden} tabIndex={0}>\n <code className=\"pb-diff-code\">\n {lines(text).map((line, index) => (\n <span key={index} className=\"pb-diff-line\" data-kind={diffLineKind(line)}>\n {line === \"\" ? \" \" : line}\n </span>\n ))}\n </code>\n </pre>\n );\n}\n\nexport function DiffView({ diff, files, level = 3, collapsed, onToggle, className, ...rest }: DiffViewProps) {\n const base = useId();\n const [ownCollapsed, setOwnCollapsed] = useState<readonly string[]>([]);\n const folded = collapsed ?? ownCollapsed;\n const Heading = `h${String(level)}` as \"h3\";\n const toggle = (path: string, open: boolean) => {\n if (collapsed === undefined) {\n setOwnCollapsed((was) => (open ? was.filter((other) => other !== path) : [...was, path]));\n }\n onToggle?.(path, open);\n };\n return (\n <div {...rest} className={className === undefined ? \"pb-diff\" : `pb-diff ${className}`}>\n {files === undefined ? (\n <DiffBody text={diff} />\n ) : (\n files.map((file, index) => {\n const open = !folded.includes(file.path);\n const bodyId = `${base}-${String(index)}`;\n return (\n <div key={file.path} className=\"pb-diff-file\" data-open={open || undefined}>\n <Heading className=\"pb-diff-file-title\">\n <button\n type=\"button\"\n className=\"pb-diff-toggle\"\n aria-expanded={open}\n aria-controls={bodyId}\n title={file.path}\n onClick={() => {\n toggle(file.path, !open);\n }}\n >\n <svg className=\"pb-diff-chevron\" viewBox=\"0 0 16 16\" width=\"10\" height=\"10\" aria-hidden=\"true\">\n <path d=\"M5 3l5 5-5 5\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" />\n </svg>\n {baseName(file.path)}\n </button>\n </Heading>\n <DiffBody text={file.diff} id={bodyId} hidden={!open} />\n </div>\n );\n })\n )}\n </div>\n );\n}\n","// The keys an app binds, listed in a Dialog (docs/components.md#commands-and-keys): one section per group, in the order\n// the groups first appear, each a list of what a key does and the key as people read it (keyLabel). The sheet draws\n// the list it is given and binds nothing; the app's useShortcuts table is usually where the list comes from.\nimport { type ReactNode, Fragment, useId } from \"react\";\nimport { type Platform, ariaKeyShortcuts, keyLabel } from \"../../hooks\";\nimport { Dialog } from \"../../primitives\";\nimport \"./ShortcutSheet.css\";\n\n/** One line of the sheet. */\nexport type ShortcutLine = {\n /** The key string, or several that do the same (\"Mod+K\", [\"Delete\", \"Backspace\"]). */\n keys: string | readonly string[];\n /** What the key does. */\n label: string;\n /** The heading it is listed under. */\n group: string;\n};\n\nexport type ShortcutSheetProps = {\n /** Whether the sheet is shown; the app holds it. */\n open: boolean;\n /** Asked for on Escape, the close button and a press on the scrim. */\n onClose: () => void;\n shortcuts: readonly ShortcutLine[];\n /** The dialog's title, \"Keyboard shortcuts\" by default. */\n title?: ReactNode;\n /** A note under the lists (where the keys do not act, say). */\n children?: ReactNode;\n /** Between two keys that do the same, \"or\" by default. */\n orLabel?: string;\n /** Shown when there are no shortcuts, \"No shortcuts\" by default. */\n emptyLabel?: ReactNode;\n /** The close button's name, \"Close\" by default. */\n closeLabel?: string;\n /** The platform keys are drawn for; the browser's by default. */\n platform?: Platform;\n /** Replaces keyLabel's words for keys and modifiers (\"Escape\", \"Ctrl\"). */\n keyNames?: Readonly<Record<string, string>>;\n /** A class added to the dialog's box. */\n className?: string;\n};\n\n/** The lines in groups, the groups in the order they first appear and each group's lines in the order given. */\nexport function groupShortcuts(shortcuts: readonly ShortcutLine[]): { group: string; lines: ShortcutLine[] }[] {\n const groups = new Map<string, ShortcutLine[]>();\n for (const line of shortcuts) {\n const lines = groups.get(line.group);\n if (lines === undefined) groups.set(line.group, [line]);\n else lines.push(line);\n }\n return [...groups.entries()].map(([group, lines]) => ({ group, lines }));\n}\n\nexport function ShortcutSheet({\n open,\n onClose,\n shortcuts,\n title = \"Keyboard shortcuts\",\n children,\n orLabel = \"or\",\n emptyLabel = \"No shortcuts\",\n closeLabel = \"Close\",\n platform,\n keyNames,\n className,\n}: ShortcutSheetProps) {\n const ids = useId();\n const groups = groupShortcuts(shortcuts);\n return (\n <Dialog\n open={open}\n onClose={onClose}\n title={title}\n closeLabel={closeLabel}\n className={className === undefined ? \"pb-shortcut-sheet\" : `pb-shortcut-sheet ${className}`}\n >\n {groups.length === 0 && <p className=\"pb-shortcut-sheet-empty\">{emptyLabel}</p>}\n {groups.map(({ group, lines }, index) => {\n const headingId = `${ids}-${index}`;\n return (\n <section key={group} className=\"pb-shortcut-sheet-group\" aria-labelledby={headingId}>\n <h3 id={headingId} className=\"pb-shortcut-sheet-heading\">\n {group}\n </h3>\n <dl className=\"pb-shortcut-sheet-list\">\n {lines.map((line, at) => {\n const keys = typeof line.keys === \"string\" ? [line.keys] : line.keys;\n return (\n <div key={`${line.label}-${at}`} className=\"pb-shortcut-sheet-line\">\n <dt>{line.label}</dt>\n <dd aria-keyshortcuts={keys.length === 0 ? undefined : ariaKeyShortcuts(keys, platform)}>\n {keys.map((one, n) => (\n <Fragment key={one}>\n {n > 0 && <span className=\"pb-shortcut-sheet-or\"> {orLabel} </span>}\n <kbd>{keyLabel(one, { platform, names: keyNames })}</kbd>\n </Fragment>\n ))}\n </dd>\n </div>\n );\n })}\n </dl>\n </section>\n );\n })}\n {children !== undefined && <div className=\"pb-shortcut-sheet-note\">{children}</div>}\n </Dialog>\n );\n}\n","// Status words: a short row of states, each a word in its tone (a pane's \"3 errors · 1 warning · saved\"), in the order\n// the app gives, which is most urgent first. The row is one polite live region, so a screen reader reads a change\n// when it is free. A tone it does not know is drawn neutrally.\nimport type { ComponentPropsWithRef } from \"react\";\nimport \"./StatusWords.css\";\n\n/** The tones a word draws; any other string is drawn neutrally. */\nexport type StatusWordTone = \"ok\" | \"warn\" | \"err\" | \"quiet\" | \"off\" | (string & {});\n\nexport type StatusWord = {\n tone: StatusWordTone;\n /** The state in words. */\n label: string;\n /** Shown on hover: what the state means or why it is so. */\n title?: string;\n};\n\nexport type StatusWordsProps = Omit<ComponentPropsWithRef<\"ul\">, \"children\"> & {\n /** The states, most urgent first; drawn in this order. */\n items: readonly StatusWord[];\n};\n\nexport function StatusWords({ items, className, ...rest }: StatusWordsProps) {\n return (\n <ul\n aria-live=\"polite\"\n {...rest}\n className={className === undefined ? \"pb-status-words\" : `pb-status-words ${className}`}\n >\n {items.map((item, index) => (\n <li key={`${String(index)}:${item.label}`} className=\"pb-status-word\" data-tone={item.tone} title={item.title}>\n {item.label}\n </li>\n ))}\n </ul>\n );\n}\n","// A stack of toasts: short news that comes and goes (a refused edit, a lost connection, a saved file), each in its\n// tone, with an optional action and a Dismiss button. The queue is the app's (useToasts holds one): the toaster draws\n// the toasts it is given and says when the person dismisses one or holds the stack by hovering over or focusing in it.\n// Its news is said through two live regions that are there before any toast is (a region added with its words is not\n// reliably read): a toast's words, and its count, are put into the alert region for an err toast and the status\n// region for every other when it first shows and when its count goes up, without its buttons; the toasts themselves\n// are not live, so nothing is read twice. Escape on a focused toast dismisses it, and the focus moves to the toast\n// beside it, or back to where it came from when none is left.\nimport { type ComponentPropsWithRef, type ReactNode, useEffect, useId, useLayoutEffect, useRef, useState } from \"react\";\nimport type { ToastAction, ToastTone } from \"../../hooks\";\nimport { Button } from \"../../primitives\";\nimport \"./Toaster.css\";\n\n/** Where the stack sits; any other string is drawn inline. */\nexport type ToasterPlacement =\n \"top-start\" | \"top\" | \"top-end\" | \"bottom-start\" | \"bottom\" | \"bottom-end\" | \"inline\" | (string & {});\n\n/** A toast as the toaster draws it; useToasts' toasts are these. */\nexport type ToasterToast = {\n id: number;\n tone: ToastTone;\n text: ReactNode;\n /** How many times it was shown, coalesced; above 1 it shows \"×n\". */\n count?: number;\n action?: ToastAction;\n};\n\nexport type ToasterProps = Omit<ComponentPropsWithRef<\"section\">, \"children\"> & {\n /** The toasts shown, oldest first. */\n toasts: readonly ToasterToast[];\n /** How many older toasts are folded away, shown as \"and n more\". */\n more?: number;\n /** The person dismissed a toast (its button, its action, or Escape on it). */\n onDismiss: (id: number) => void;\n /** True while the person hovers over or is focused in the toasts, so the app holds their expiry. */\n onHold?: (held: boolean) => void;\n /**\n * A corner or edge of the nearest positioned container (\"bottom-end\" by default; start and end follow the text's\n * direction), or \"inline\": in the flow, where the app put it (in a canvas's own panel).\n */\n placement?: ToasterPlacement;\n /** The region's name, \"Notifications\" by default. */\n label?: string;\n /** The words on each Dismiss button, \"Dismiss\" by default. */\n dismissLabel?: string;\n /** The words for the folded toasts, \"and n more\" by default. */\n moreLabel?: (more: number) => ReactNode;\n /** What a screen reader reads for a count in place of \"×n\", \"n times\" by default. */\n countLabel?: (count: number) => string;\n};\n\nconst placements = new Set([\"top-start\", \"top\", \"top-end\", \"bottom-start\", \"bottom\", \"bottom-end\", \"inline\"]);\nconst defaultMoreLabel = (more: number) => `and ${more} more`;\nconst defaultCountLabel = (count: number) => `${count} times`;\n\n/** News put into a live region: a toast's words, and its count, when it first shows or its count goes up. */\ntype Said = { seq: number; id: number; alert: boolean; text: ReactNode; count: number };\n\n/** How many ids the toaster remembers having said, beyond those shown, before it forgets the rest. */\nconst heardLimit = 256;\n\nexport function Toaster({\n toasts,\n more = 0,\n onDismiss,\n onHold,\n placement = \"bottom-end\",\n label = \"Notifications\",\n dismissLabel = \"Dismiss\",\n moreLabel = defaultMoreLabel,\n countLabel = defaultCountLabel,\n className,\n onPointerEnter,\n onPointerLeave,\n onFocus,\n onBlur,\n ...rest\n}: ToasterProps) {\n const ids = useId();\n const drawn = placements.has(placement) ? placement : \"inline\";\n const top = drawn.startsWith(\"top\");\n // Nearest the edge is newest: at the top the newest comes first, in the reading order as on screen.\n const ordered = top ? [...toasts].reverse() : toasts;\n const empty = toasts.length === 0 && more <= 0;\n\n // What has been said, by id and count, so a toast is said once when it shows and again only when its count goes up\n // (not when it unfolds from \"and n more\" or the list is drawn again).\n const heard = useRef(new Map<number, number>());\n const sequence = useRef(0);\n const [said, setSaid] = useState<readonly Said[]>([]);\n useEffect(() => {\n const news: Said[] = [];\n for (const toast of toasts) {\n const count = toast.count ?? 1;\n const before = heard.current.get(toast.id);\n if (before !== undefined && count <= before) continue;\n heard.current.set(toast.id, count);\n sequence.current += 1;\n news.push({ seq: sequence.current, id: toast.id, alert: toast.tone === \"err\", text: toast.text, count });\n }\n const shown = new Set(toasts.map((toast) => toast.id));\n if (heard.current.size > heardLimit) {\n for (const id of heard.current.keys()) if (!shown.has(id)) heard.current.delete(id);\n }\n // A toast gone is no longer news: its words go (taking words away is not read), so a toast that comes back from\n // \"and n more\" is not said again. Set from an effect on purpose: the words must reach the regions in a commit\n // after the regions are there, or a toaster mounted with a toast would add a region with its words at once.\n const fresh = new Set(news.map((one) => one.id));\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setSaid((all) => {\n const kept = all.filter((one) => shown.has(one.id) && !fresh.has(one.id));\n return news.length === 0 && kept.length === all.length ? all : [...kept, ...news];\n });\n }, [toasts]);\n // Filtered here too, so a dismissed toast's words go in the same render as the toast.\n const shownIds = new Set(toasts.map((toast) => toast.id));\n const say = (alert: boolean) =>\n said\n .filter((one) => shownIds.has(one.id))\n .filter((one) => one.alert === alert)\n .map((one) => (\n <p key={one.seq}>\n {one.text}\n {one.count > 1 && `, ${countLabel(one.count)}`}\n </p>\n ));\n const regions = (\n <div className=\"pb-toaster-announce\">\n <div role=\"status\">{say(false)}</div>\n <div role=\"alert\">{say(true)}</div>\n </div>\n );\n\n const [hovered, setHovered] = useState(false);\n const [focused, setFocused] = useState(false);\n // A toast taken away under the pointer or the focus fires no leave or blur; with none left, the hold is let go.\n if (empty && (hovered || focused)) {\n setHovered(false);\n setFocused(false);\n }\n const held = hovered || focused;\n const latestHold = useRef(onHold);\n useLayoutEffect(() => {\n latestHold.current = onHold;\n });\n useLayoutEffect(() => {\n latestHold.current?.(held);\n }, [held]);\n useLayoutEffect(\n () => () => {\n latestHold.current?.(false);\n },\n [],\n );\n\n const list = useRef<HTMLOListElement>(null);\n // Where the focus came from into the toasts, so it goes back there when the last focused toast is dismissed.\n const cameFrom = useRef<HTMLElement | null>(null);\n // After a dismissal that held the focus: the toast to focus next, or null to send it back.\n const focusNext = useRef<number | null | undefined>(undefined);\n useLayoutEffect(() => {\n const next = focusNext.current;\n if (next === undefined) return;\n focusNext.current = undefined;\n // The toast beside the dismissed one, else any still shown (one unfolded from \"and n more\"), else back.\n const item =\n (next === null ? null : list.current?.querySelector<HTMLElement>(`[data-toast-id=\"${next}\"]`)) ??\n list.current?.querySelector<HTMLElement>(\".pb-toast\");\n if (item !== null && item !== undefined) {\n item.focus();\n return;\n }\n const back = cameFrom.current;\n cameFrom.current = null;\n if (back?.isConnected === true) back.focus();\n });\n\n const dismiss = (id: number) => {\n if (list.current?.contains(document.activeElement) === true) {\n const at = ordered.findIndex((toast) => toast.id === id);\n focusNext.current = (ordered[at + 1] ?? ordered[at - 1])?.id ?? null;\n }\n onDismiss(id);\n };\n\n if (empty) return regions;\n\n const moreLine = more > 0 && <p className=\"pb-toaster-more\">{moreLabel(more)}</p>;\n return (\n <>\n {regions}\n <section\n {...rest}\n aria-label={rest[\"aria-label\"] ?? label}\n className={className === undefined ? \"pb-toaster\" : `pb-toaster ${className}`}\n data-placement={drawn}\n onPointerEnter={(event) => {\n onPointerEnter?.(event);\n if (event.pointerType !== \"touch\") setHovered(true);\n }}\n onPointerLeave={(event) => {\n onPointerLeave?.(event);\n setHovered(false);\n }}\n onFocus={(event) => {\n onFocus?.(event);\n const from = event.relatedTarget;\n if (!focused && from instanceof HTMLElement && !event.currentTarget.contains(from)) cameFrom.current = from;\n setFocused(true);\n }}\n onBlur={(event) => {\n onBlur?.(event);\n if (!event.currentTarget.contains(event.relatedTarget)) setFocused(false);\n }}\n >\n {!top && moreLine}\n <ol className=\"pb-toaster-list\" ref={list}>\n {ordered.map((toast) => {\n const textId = `${ids}-${toast.id}`;\n const count = toast.count ?? 1;\n return (\n <li\n key={toast.id}\n className=\"pb-toast\"\n data-tone={toast.tone}\n data-toast-id={toast.id}\n tabIndex={-1}\n onKeyDown={(event) => {\n // Escape here is the toast's alone, so a sheet or dialog behind it does not also close.\n if (event.key !== \"Escape\" || event.defaultPrevented) return;\n event.preventDefault();\n event.stopPropagation();\n dismiss(toast.id);\n }}\n >\n <div className=\"pb-toast-text\" id={textId}>\n {toast.text}\n {count > 1 && (\n <span className=\"pb-toast-count\">\n <span aria-hidden=\"true\"> ×{count}</span>\n <span className=\"pb-toast-hidden\">, {countLabel(count)}</span>\n </span>\n )}\n </div>\n <div className=\"pb-toast-actions\">\n {toast.action !== undefined && (\n <Button\n size=\"sm\"\n onClick={() => {\n toast.action?.run();\n dismiss(toast.id);\n }}\n >\n {toast.action.label}\n </Button>\n )}\n <Button\n size=\"sm\"\n aria-describedby={textId}\n onClick={() => {\n dismiss(toast.id);\n }}\n >\n {dismissLabel}\n </Button>\n </div>\n </li>\n );\n })}\n </ol>\n {top && moreLine}\n </section>\n </>\n );\n}\n"],"mappings":";;;;;;AAwBA,SAAgBG,EAAO,EACrB,SAC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border:1px solid var(--pb-line);border-radius:var(--pb-radius-box);box-shadow:var(--pb-shadow);overflow:hidden}@media (forced-colors:active){.pb-canvas-minimap{border-color:canvastext}}.pb-ghost-wire{--pb-ghost-wire-color:var(--pb-quiet);pointer-events:none;opacity:.6}.pb-ghost-wire[data-tone=refused]{--pb-ghost-wire-color:var(--pb-err);opacity:1}.pb-ghost-wire .react-flow__edge-path.pb-ghost-wire-path{stroke:var(--pb-ghost-wire-color);stroke-width:1.5px;stroke-dasharray:4 4;pointer-events:none;transition:stroke var(--pb-motion-fast)}.pb-ghost-wire-label{pointer-events:none;padding:0 var(--pb-space-2);border:1px dashed var(--pb-quiet);border-radius:var(--pb-radius-pill);background:var(--pb-raised);color:var(--pb-muted);font-family:var(--pb-font-ui);font-size:var(--pb-text-sm);white-space:nowrap;line-height:16px;position:absolute}.pb-ghost-wire-label[data-tone=refused]{border-color:var(--pb-err);color:var(--pb-err)}@media (forced-colors:active){.pb-ghost-wire .react-flow__edge-path.pb-ghost-wire-path{stroke:graytext}.pb-ghost-wire[data-tone=refused] .react-flow__edge-path.pb-ghost-wire-path{stroke:canvastext}.pb-ghost-wire-label{border-color:graytext}}.pb-meter{--pb-meter-level:0;--pb-meter-tick:0;--pb-meter-mid-at:.7;--pb-meter-hot-at:.9;--pb-meter-thickness:6px;box-sizing:border-box;align-items:stretch;gap:var(--pb-space-1);width:100%;min-width:48px;height:var(--pb-meter-thickness);flex-shrink:0;display:flex}.pb-meter-track{background:var(--pb-sunken);border-radius:0;flex:auto;min-width:0;min-height:0;position:relative;overflow:hidden}.pb-meter-bar{background:linear-gradient(to right, var(--pb-meter-low) calc(var(--pb-meter-mid-at) * 100%), var(--pb-meter-mid) 0 calc(var(--pb-meter-hot-at) * 100%), var(--pb-meter-hot) 0);clip-path:inset(0 calc((1 - var(--pb-meter-level)) * 100%) 0 0);position:absolute;inset:0}.pb-meter-peak{top:0;bottom:0;left:calc(var(--pb-meter-tick) * (100% - 2px));background:var(--pb-meter-peak);width:2px;position:absolute}.pb-meter[data-peak=hidden] .pb-meter-peak{visibility:hidden}.pb-meter-lamp{flex:0 0 var(--pb-meter-thickness);background:var(--pb-sunken);border-radius:0}.pb-meter[data-clipped=true] .pb-meter-lamp{background:var(--pb-meter-hot)}.pb-meter[data-orientation=vertical]{width:var(--pb-meter-thickness);flex-direction:column-reverse;min-width:0;height:100%;min-height:48px}.pb-meter[data-orientation=vertical] .pb-meter-bar{background:linear-gradient(to top, var(--pb-meter-low) calc(var(--pb-meter-mid-at) * 100%), var(--pb-meter-mid) 0 calc(var(--pb-meter-hot-at) * 100%), var(--pb-meter-hot) 0);clip-path:inset(calc((1 - var(--pb-meter-level)) * 100%) 0 0 0)}.pb-meter[data-orientation=vertical] .pb-meter-peak{top:auto;right:0;bottom:calc(var(--pb-meter-tick) * (100% - 2px));width:auto;height:2px;left:0}@media (forced-colors:active){.pb-meter-track,.pb-meter-lamp{forced-color-adjust:none;outline-offset:-1px;background:canvas;outline:1px solid canvastext}.pb-meter-bar,.pb-meter[data-orientation=vertical] .pb-meter-bar{forced-color-adjust:none;background:highlight}.pb-meter-peak,.pb-meter[data-clipped=true] .pb-meter-lamp{forced-color-adjust:none;background:canvastext}}.pb-port-row{box-sizing:border-box;align-items:center;gap:var(--pb-space-2);height:var(--pb-node-row);min-width:0;padding:0 var(--pb-space-3) 0 calc(var(--pb-node-handle) / 2 + var(--pb-space-3));color:var(--pb-text);font-family:var(--pb-font-ui);font-size:var(--pb-text-sm);line-height:var(--pb-node-row);display:flex;position:relative}.pb-port-row[data-side=output]{padding:0 calc(var(--pb-node-handle) / 2 + var(--pb-space-3)) 0 var(--pb-space-3);flex-direction:row-reverse}.pb-port-row[data-side=input]:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){flex-direction:row-reverse}.pb-port-row[data-side=output]:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){flex-direction:row}.pb-port-words{align-items:center;gap:var(--pb-space-2);white-space:nowrap;flex:0 auto;min-width:0;display:inline-flex;overflow:hidden}.pb-port-label{text-overflow:ellipsis;min-width:0;overflow:hidden}.pb-port-type{color:var(--pb-muted);font-family:var(--pb-font-code);font-size:var(--pb-text-sm);flex:none}.pb-port-trailing{flex:1 1 0;justify-content:flex-end;align-items:center;min-width:0;display:flex}.pb-port-row[data-side=output] .pb-port-trailing{justify-content:flex-start}.react-flow__handle.pb-port-handle{width:var(--pb-node-handle-hit);min-width:0;height:var(--pb-node-handle-hit);background:0 0;border:0;border-radius:0;justify-content:center;align-items:center;min-height:0;display:flex}.react-flow__handle.pb-port-handle:after{content:"";box-sizing:border-box;width:var(--pb-node-handle);height:var(--pb-node-handle);border:1px solid var(--xy-handle-border-color,var(--pb-raised));border-radius:var(--pb-radius-pill);background:var(--xy-handle-background-color,var(--pb-text));pointer-events:none;transition:width var(--pb-motion-fast), height var(--pb-motion-fast), background-color var(--pb-motion-fast), outline-color var(--pb-motion-fast)}.react-flow__handle.pb-port-handle[data-hint=origin]:after{outline:2px solid var(--pb-accent);outline-offset:1px}.react-flow__handle.pb-port-handle[data-hint=ok]:after{background:var(--pb-ok);width:12px;height:12px}.react-flow__handle.pb-port-handle[data-hint=no]:after{background:var(--pb-off)}.react-flow__handle.pb-port-handle[data-hint=no]{cursor:not-allowed}.pb-port-row[data-hint=no],.pb-port-row[data-hint=no] .pb-port-type{color:var(--pb-muted)}@media (forced-colors:active){.react-flow__handle.pb-port-handle:after{forced-color-adjust:none;background:canvastext;border-color:canvastext}.react-flow__handle.pb-port-handle[data-hint=ok]:after,.react-flow__handle.pb-port-handle[data-hint=origin]:after{border:2px solid highlight;outline:none}.react-flow__handle.pb-port-handle[data-hint=no]:after{background:canvas;border:2px solid graytext}}.pb-node-box{--_pb-node-stripe:var(--pb-line-strong);--_pb-node-border:var(--pb-line);box-sizing:border-box;width:var(--pb-node-width);border-radius:var(--pb-radius-box);background:var(--pb-raised);box-shadow:var(--pb-shadow);color:var(--pb-text);font-family:var(--pb-font-ui);font-size:var(--pb-text-md);outline-offset:0;transition:outline-color var(--pb-motion-fast);outline:2px solid #0000;flex-direction:column;display:flex;position:relative}.pb-node-box:after{content:"";box-sizing:border-box;border:1px solid var(--_pb-node-border);border-radius:var(--pb-radius-box);pointer-events:none;position:absolute;inset:0}.pb-node-box:before{content:"";background:var(--_pb-node-stripe);pointer-events:none;border-start-start-radius:var(--pb-radius-box);border-end-start-radius:var(--pb-radius-box);width:4px;position:absolute;inset-block:0;inset-inline-start:0}.pb-node-box[data-tone=ok]{--_pb-node-stripe:var(--pb-ok)}.pb-node-box[data-tone=warn]{--_pb-node-stripe:var(--pb-warn)}.pb-node-box[data-tone=err]{--_pb-node-stripe:var(--pb-err)}.pb-node-box[data-tone=quiet]{--_pb-node-stripe:var(--pb-quiet)}.pb-node-box[data-tone=off]{--_pb-node-stripe:var(--pb-off)}.pb-node-box[data-tone=accent]{--_pb-node-stripe:var(--pb-accent)}.pb-node-box[data-tone=muted]{--_pb-node-stripe:var(--pb-muted)}.pb-node-box[data-selected]{outline-color:var(--pb-accent)}.react-flow__node:focus-visible>.pb-node-box{outline:2px solid var(--pb-accent);outline-offset:2px}.pb-node-header{box-sizing:border-box;align-items:center;gap:var(--pb-space-3);height:var(--pb-node-header);padding-inline:calc(4px + var(--pb-space-3)) var(--pb-space-3);border-start-start-radius:var(--pb-radius-box);border-start-end-radius:var(--pb-radius-box);flex:none;display:flex}.pb-node-heading{flex-direction:column;flex:auto;justify-content:center;min-width:0;display:flex}.pb-node-title,.pb-node-subtitle,.pb-node-line{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.pb-node-title{font-weight:600;line-height:1.3}.pb-node-subtitle{color:var(--pb-muted);font-size:var(--pb-text-sm);line-height:1.3}.pb-node-change,.pb-node-status{flex:none}.pb-node-line{box-sizing:border-box;height:var(--pb-node-line);padding-inline:calc(4px + var(--pb-space-3)) var(--pb-space-3);color:var(--pb-muted);font-size:var(--pb-text-sm);line-height:var(--pb-node-line);flex:none}.pb-node-ports{box-sizing:border-box;padding-block:var(--pb-node-pad);flex-direction:column;flex:none;display:flex}.pb-node-ports[data-ports=side-by-side]{flex-direction:row;align-items:flex-start}.pb-node-column{flex-direction:column;flex:1 1 0;min-width:0;display:flex}.pb-node-ports[data-ports=side-by-side]:is(:lang(ae),:lang(ar),:lang(arc),:lang(bcc),:lang(bqi),:lang(ckb),:lang(dv),:lang(fa),:lang(glk),:lang(he),:lang(ku),:lang(mzn),:lang(nqo),:lang(pnb),:lang(ps),:lang(sd),:lang(ug),:lang(ur),:lang(yi)){flex-direction:row-reverse}.pb-node-footer{box-sizing:border-box;align-items:center;gap:var(--pb-space-2);height:var(--pb-node-footer);padding-inline:calc(4px + var(--pb-space-3)) var(--pb-space-3);border-top:1px solid var(--pb-line);flex:none;display:flex;overflow:hidden}.pb-node-box[data-failed]{--_pb-node-border:var(--pb-err)}.pb-node-box[data-failed] .pb-node-header{background:var(--pb-err-soft)}.pb-node-box[data-failed] .pb-node-line{color:var(--pb-err)}.pb-node-box[data-disabled]:after{border-style:dashed}.pb-node-box[data-disabled]:before{background:repeating-linear-gradient(-45deg, var(--_pb-node-stripe) 0 3px, var(--pb-raised) 3px 6px)}.pb-node-box[data-disabled],.pb-node-box[data-disabled] .pb-port-row{color:var(--pb-muted)}.pb-node-box[data-change]:after{border-width:2px;border-color:var(--pb-line-strong)}.pb-node-box[data-change=added]:after{border-color:var(--pb-added)}.pb-node-box[data-change=removed]:after{border-color:var(--pb-removed)}.pb-node-box[data-change=renamed]:after{border-color:var(--pb-renamed)}.pb-node-box[data-change=changed]:after{border-color:var(--pb-warn)}.pb-node-box[data-change=removed] .pb-node-title{text-decoration:line-through}@media (forced-colors:active){.pb-node-box:before{forced-color-adjust:none;background:canvastext}.pb-node-box[data-disabled]:before{background:repeating-linear-gradient(-45deg,canvastext 0 3px,canvas 3px 6px)}.pb-node-box:after,.pb-node-box[data-change]:after{border-color:canvastext}.pb-node-box[data-selected]{outline-color:highlight}}.pb-wire{--pb-wire-color:var(--xy-edge-stroke)}.pb-wire[data-tone=ok]{--pb-wire-color:var(--pb-ok)}.pb-wire[data-tone=warn],.pb-wire[data-tone=changed]{--pb-wire-color:var(--pb-warn)}.pb-wire[data-tone=err],.pb-wire[data-tone=refused]{--pb-wire-color:var(--pb-err)}.pb-wire[data-tone=quiet],.pb-wire[data-tone=pending]{--pb-wire-color:var(--pb-quiet)}.pb-wire[data-tone=off]{--pb-wire-color:var(--pb-off)}.pb-wire[data-tone=accent]{--pb-wire-color:var(--pb-accent)}.pb-wire[data-tone=muted]{--pb-wire-color:var(--pb-muted)}.pb-wire[data-tone=added]{--pb-wire-color:var(--pb-added)}.pb-wire[data-tone=removed]{--pb-wire-color:var(--pb-removed)}.pb-wire[data-selected]{--pb-wire-color:var(--pb-accent)}.pb-wire .react-flow__edge-path.pb-wire-path{stroke:var(--pb-wire-color);stroke-width:1.5px;transition:stroke-width var(--pb-motion-fast), stroke-opacity var(--pb-motion-fast)}.pb-wire[data-emphasis] .react-flow__edge-path.pb-wire-path{stroke-width:calc(1.5px + 2px * var(--pb-wire-emphasis));stroke-opacity:calc(.45 + .55 * var(--pb-wire-emphasis))}.pb-wire[data-dashed] .react-flow__edge-path.pb-wire-path{stroke-dasharray:6 4}.pb-wire-flow{stroke:var(--pb-raised);stroke-width:2px;stroke-linecap:round;stroke-dasharray:0 12;pointer-events:none;animation:pb-wire-flow var(--pb-motion-flow) linear infinite}@keyframes pb-wire-flow{to{stroke-dashoffset:-12px}}.pb-wire-arrow{fill:var(--pb-wire-color);stroke:none;pointer-events:none}.pb-wire-label{pointer-events:none;padding:0 var(--pb-space-2);border:1px solid var(--pb-line);border-radius:var(--pb-radius-pill);background:var(--pb-raised);color:var(--pb-text);font-family:var(--pb-font-ui);font-size:var(--pb-text-sm);white-space:nowrap;line-height:16px;position:absolute}@media (prefers-reduced-motion:reduce){.pb-wire-flow{display:none}}@media (forced-colors:active){.pb-wire .react-flow__edge-path.pb-wire-path{stroke:canvastext}.pb-wire-arrow{fill:canvastext}.pb-wire[data-selected] .react-flow__edge-path.pb-wire-path{stroke:highlight}.pb-wire[data-selected] .pb-wire-arrow{fill:highlight}.pb-wire-label{border-color:canvastext}}