@kition/kit-editor 0.3.0 → 0.5.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/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { KitRpcError as he, isHello as co, KIT_UI_PROTOCOL as Bt, isHandshake as uo, KitPeer as ho, parseCommentAnchor as zn, HOST_SERVICE_CAPABILITY_PREFIX as Bn, parseKitView as _n, parseWatermark as fo, parseDocumentPermissions as mo, matchesShortcut as Hr, INVALID_PARAMS_REASON as At, LEASE_HELD_REASON as fn, ORIGIN_LABEL as po, HOST_ORIGIN_LABEL as go, parsePeers as wo, parsePresence as bo } from "@kition/kit-ui-protocol";
2
2
  import { fileErrorReason as th, isOpenableUrl as nh, openErrorReason as rh } from "@kition/kit-ui-protocol";
3
3
  import { brandTokens as yo, validBrand as vo, Dialog as st, Button as me, ElementsProvider as ko, MenuItem as le, RibbonButton as we, ICON_STROKE as $e, RibbonGroup as Me, StringsProvider as So, RibbonPresentationContext as vt, RibbonFitContext as Yt, lineSize as Co, MenuButton as lt, FULL_RIBBON_FIT as mn, menuKeyDown as xo, toast as pt, IconButton as De, OverflowStrip as Et, StatusBar as $o, StatusSpacer as Io, ZoomControl as Mo, Toaster as To, RibbonStack as Fe, ColorGrid as Vt, MenuSeparator as Ae, Choice as gt, Checkbox as Xt, LineMoreLabelContext as Ao, DropPanel as Eo } from "@kition/tessera-ui";
4
- import { Badge as oh, BarChart as ah, BarSeparator as sh, Button as lh, Card as ch, CardContent as dh, CardHeader as uh, Checkbox as hh, Choice as fh, ColorGrid as mh, ColorPicker as ph, ColorWheel as gh, Command as wh, CommandEmpty as bh, CommandGroup as yh, CommandInput as vh, CommandList as kh, CommandItem as Sh, CommandSeparator as Ch, CommandShortcut as xh, ConfirmProvider as $h, ContextMenu as Ih, CurveEditor as Mh, Dialog as Th, Disclosure as Ah, DockArea as Eh, EyeButton as Oh, Field as Rh, FloatingPanels as Dh, GradientSlider as Lh, Hint as Nh, Histogram as Ph, ICON_STROKE as Fh, IconButton as Wh, KeyframeLane as zh, LevelMeter as Bh, LineChart as _h, LineMoreLabelContext as Kh, MenuButton as Hh, MenuItem as Uh, MenuSeparator as qh, Modal as jh, ModalBody as Gh, ModalClose as Yh, ModalCloseButton as Vh, ModalContent as Xh, ModalDescription as Jh, ModalFooter as Zh, ModalHeader as Qh, ModalTitle as ef, ModalTrigger as tf, NumberField as nf, OverflowStrip as rf, PALETTE_COLORS as of, Panel as af, PanelFooter as sf, PasswordInput as lf, PieChart as cf, Popover as df, PopoverAnchor as uf, PopoverClose as hf, PopoverContent as ff, PopoverTrigger as mf, PreviewDialog as pf, RGB_IDENTITY as gf, RenameField as wf, RibbonButton as bf, RibbonGroup as yf, RibbonItem as vf, RibbonPresentationContext as kf, RibbonRow as Sf, RibbonStack as Cf, SLIDER_GRADIENTS as xf, STANDARD_COLORS as $f, Segmented as If, Select as Mf, Sheet as Tf, Spinner as Af, StatusBar as Ef, StatusSpacer as Of, Switch as Rf, TableSizePicker as Df, TextInput as Lf, Textarea as Nf, Thumbnail as Pf, TimecodeField as Ff, Toaster as Wf, Tooltip as zf, TooltipContent as Bf, TooltipProvider as _f, TooltipTrigger as Kf, TransportBar as Hf, WORKSPACE_ACTIONS as Uf, WorkspaceLayout as qf, ZoomControl as jf, addCurvePoint as Gf, automaticFloatingPosition as Yf, brandTokens as Vf, clampFloatingRect as Xf, contrast as Jf, deviceScale as Zf, dockHeights as Qf, formatTimecode as em, hitCurvePoint as tm, kitStoreKey as nm, lightnessAt as rm, lineSize as im, menuKeyDown as om, meterFraction as am, meterLayout as sm, moveCurvePoint as lm, overflowOf as cm, parseHex as dm, parseTimecode as um, rankScale as hm, readKitStore as fm, removeCurvePoint as mm, removeKitStore as pm, resizeFloatingRect as gm, rgbToHex as wm, sampleCurve as bm, sliderFraction as ym, sliderValueAt as vm, smoothHistogram as km, sortCurve as Sm, storedBytes as Cm, toast as xm, useAutoSize as $m, useConfirm as Im, useDialogFocus as Mm, useDismissableLayer as Tm, useKitStore as Am, useMediaQuery as Em, useWorkspaces as Om, wheelRadius as Rm, wheelValueAt as Dm, workspaceSlug as Lm, writeKitStore as Nm } from "@kition/tessera-ui";
5
- import { useRef as R, useState as B, useCallback as H, useEffect as J, useMemo as pe, useImperativeHandle as Oo, createContext as Ot, useContext as Le, useSyncExternalStore as He, useLayoutEffect as Te, Fragment as Ro } from "react";
6
- import { jsx as u, jsxs as M, Fragment as Ce } from "react/jsx-runtime";
7
- import { CommandGenericIcon as Do, HeadingIcon as Ur, ListTreeIcon as Lo, CodeIcon as No, ArrowRightLeftIcon as Po, WaypointsIcon as qr, GaugeIcon as Fo, SlidersHorizontalIcon as _t, ClipboardIcon as Wo, DatabaseIcon as Kn, HashIcon as pn, ArrowDownToLineIcon as zo, ZapIcon as Bo, PaintbrushIcon as _o, TextCursorInputIcon as Ko, ListOrderedIcon as Hn, NetworkIcon as Ho, MousePointerClickIcon as jr, PenToolIcon as Gr, PencilIcon as tt, HighlighterIcon as Yr, WholeWordIcon as Uo, TextCursorIcon as qo, RulerIcon as Ve, ClapperboardIcon as Vr, BrushIcon as Xr, BlendIcon as Qe, PaletteIcon as Rt, TypeIcon as qe, PilcrowIcon as jo, SwatchBookIcon as Go, LayersIcon as kt, SplineIcon as gn, CameraIcon as Yo, Rows3Icon as Jr, FilmIcon as Un, BookmarkIcon as Zr, DiamondIcon as Qr, BoxIcon as ei, Grid3x3Icon as St, FrameIcon as Jt, FolderIcon as qn, ClockIcon as Vo, Volume2Icon as Xo, VideoIcon as ti, SettingsIcon as wn, ShapesIcon as _e, LightbulbIcon as Jo, SquareIcon as ct, CrosshairIcon as Zo, Grid2x2Icon as Qo, MoveUpRightIcon as ea, MessageSquareIcon as Dt, FileIcon as bn, TableIcon as yn, SquareFunctionIcon as ni, ComponentIcon as ta, WandSparklesIcon as vn, MousePointer2Icon as nt, BoldIcon as na, ItalicIcon as ri, UnderlineIcon as ra, StrikethroughIcon as ia, SubscriptIcon as oa, SuperscriptIcon as aa, SquareDashedIcon as jn, ContrastIcon as sa, HandIcon as ii, ChevronsDownUpIcon as la, ChevronsUpDownIcon as ca, LinkIcon as Ct, ShieldCheckIcon as da, LifeBuoyIcon as ua, TrashIcon as rt, BookOpenIcon as ha, ArrowLeftIcon as fa, ArrowRightIcon as Gn, ArrowUpIcon as Yn, ArrowDownIcon as Vn, ArrowLeftToLineIcon as ma, ArrowRightToLineIcon as pa, ClipLiftIcon as ga, ClipExtractIcon as wa, FastForwardIcon as ba, StepForwardIcon as Xn, EyeOffIcon as Jn, Undo2Icon as kn, Redo2Icon as oi, SaveIcon as ai, FileOutputIcon as ya, FileInputIcon as va, FolderOpenIcon as ka, XIcon as Zt, PrinterIcon as Sn, CopyIcon as Cn, ScissorsIcon as xn, ClipboardPasteIcon as si, PencilLineIcon as Sa, SearchIcon as li, ReplaceIcon as ci, AlignCenterHorizontalIcon as Ca, RotateCwIcon as $n, FlipHorizontalIcon as xa, MoveIcon as di, ScalingIcon as ui, MergeIcon as $a, SplitIcon as Ia, GroupIcon as In, UngroupIcon as Mn, LockIcon as Tn, LockOpenIcon as Ma, EyeIcon as An, ZoomInIcon as hi, PlayIcon as Ta, PauseIcon as Aa, DiscIcon as Ea, RotateCcwIcon as fi, CheckIcon as En, ToggleLeftIcon as Oa, ChevronRightIcon as On, ChevronLeftIcon as Ra, CropIcon as mi, PlusIcon as pi, ListIcon as Da, RepeatIcon as La, ArrowUpDownIcon as gi, FunnelIcon as wi, UnlinkIcon as Na, RefreshCwIcon as bi, BringToFrontIcon as Qt, MagnetIcon as Pa, PenLineIcon as it, PaintBucketIcon as xt, TablePropertiesIcon as Fa, ActivityIcon as Wa, ChartColumnIcon as je, ImageIcon as za, StickerIcon as Ba, PanelTopIcon as yi, PanelBottomIcon as _a, SigmaIcon as Ka, OmegaIcon as Ha, SquareCheckBigIcon as Ua, SignatureIcon as qa, CalendarIcon as ja, MusicIcon as Ga, QrCodeIcon as Ya, LayoutTemplateIcon as Va, FilePlusIcon as Xa, Columns2Icon as vi, SpellCheckIcon as Ja, LanguagesIcon as Za, TagIcon as ki, RulerDimensionLineIcon as Qa, RadiusIcon as es, DiameterIcon as ts, PackageIcon as ns, StickyNoteIcon as rs, MousePointerIcon as is, LassoIcon as os, MinusIcon as Si, RainbowIcon as as, ShellIcon as ss, CircleIcon as Ci, EraserIcon as xi, VectorPolygonIcon as ls, VectorSquareIcon as cs, WavesHorizontalIcon as ds, Move3dIcon as us, PipetteIcon as hs, CopyPlusIcon as fs, MoveHorizontalIcon as ms, CornerDownRightIcon as ps, UploadIcon as gs, StarIcon as $i, Share2Icon as ws, SendIcon as bs, MailIcon as ys, InfoIcon as vs, CircleQuestionMarkIcon as ks, FlagIcon as Ss, DownloadIcon as Cs, BellIcon as xs, ChevronDownIcon as Ii, ChevronsLeftIcon as $s, ChevronsRightIcon as Is, SparklesIcon as Lt, EllipsisIcon as Ms, RectangleHorizontalIcon as Mi, TriangleIcon as Ts, MoveRightIcon as As, SendToBackIcon as Es, CableIcon as Os, PenIcon as Ti, ChartColumnStackedIcon as Rs, ChartLineIcon as Zn, ChartAreaIcon as Ds, ChartPieIcon as Qn, ChartScatterIcon as Ls, RadarIcon as Ns, LayoutGridIcon as Ps, TrendingUpIcon as Fs, Table2Icon as Ws, Minimize2Icon as zs, FocusIcon as Ai, MenuIcon as Bs } from "@kition/tessera-icons/react";
4
+ import { Badge as oh, BarChart as ah, BarSeparator as sh, Button as lh, Card as ch, CardContent as dh, CardHeader as uh, Checkbox as hh, Choice as fh, ColorGrid as mh, ColorPicker as ph, ColorWheel as gh, Command as wh, CommandEmpty as bh, CommandGroup as yh, CommandInput as vh, CommandList as kh, CommandItem as Sh, CommandSeparator as Ch, CommandShortcut as xh, ConfirmProvider as $h, ContextMenu as Ih, CurveEditor as Mh, Dialog as Th, Disclosure as Ah, DockArea as Eh, EyeButton as Oh, Field as Rh, FloatingPanels as Dh, GradientSlider as Lh, Hint as Ph, Histogram as Nh, ICON_STROKE as Fh, IconButton as Wh, KeyframeLane as zh, LevelMeter as Bh, LineChart as _h, LineMoreLabelContext as Kh, MenuButton as Hh, MenuItem as qh, MenuSeparator as Uh, Modal as jh, ModalBody as Gh, ModalClose as Yh, ModalCloseButton as Vh, ModalContent as Xh, ModalDescription as Jh, ModalFooter as Zh, ModalHeader as Qh, ModalTitle as ef, ModalTrigger as tf, NumberField as nf, OverflowStrip as rf, PALETTE_COLORS as of, Panel as af, PanelFooter as sf, PasswordInput as lf, PieChart as cf, Popover as df, PopoverAnchor as uf, PopoverClose as hf, PopoverContent as ff, PopoverTrigger as mf, PreviewDialog as pf, RGB_IDENTITY as gf, RenameField as wf, RibbonButton as bf, RibbonGroup as yf, RibbonItem as vf, RibbonPresentationContext as kf, RibbonRow as Sf, RibbonStack as Cf, SLIDER_GRADIENTS as xf, STANDARD_COLORS as $f, Segmented as If, Select as Mf, Sheet as Tf, Spinner as Af, StatusBar as Ef, StatusSpacer as Of, Switch as Rf, TableSizePicker as Df, TextInput as Lf, Textarea as Pf, Thumbnail as Nf, TimecodeField as Ff, Toaster as Wf, Tooltip as zf, TooltipContent as Bf, TooltipProvider as _f, TooltipTrigger as Kf, TransportBar as Hf, WORKSPACE_ACTIONS as qf, WorkspaceLayout as Uf, ZoomControl as jf, addCurvePoint as Gf, automaticFloatingPosition as Yf, brandTokens as Vf, clampFloatingRect as Xf, contrast as Jf, deviceScale as Zf, dockHeights as Qf, formatTimecode as em, hitCurvePoint as tm, kitStoreKey as nm, lightnessAt as rm, lineSize as im, menuKeyDown as om, meterFraction as am, meterLayout as sm, moveCurvePoint as lm, overflowOf as cm, parseHex as dm, parseTimecode as um, rankScale as hm, readKitStore as fm, removeCurvePoint as mm, removeKitStore as pm, resizeFloatingRect as gm, rgbToHex as wm, sampleCurve as bm, sliderFraction as ym, sliderValueAt as vm, smoothHistogram as km, sortCurve as Sm, storedBytes as Cm, toast as xm, useAutoSize as $m, useConfirm as Im, useDialogFocus as Mm, useDismissableLayer as Tm, useKitStore as Am, useMediaQuery as Em, useWorkspaces as Om, wheelRadius as Rm, wheelValueAt as Dm, workspaceSlug as Lm, writeKitStore as Pm } from "@kition/tessera-ui";
5
+ import { useRef as R, useState as B, useCallback as K, useEffect as J, useMemo as pe, useImperativeHandle as Oo, createContext as Ot, useContext as Le, useSyncExternalStore as He, useLayoutEffect as Te, Fragment as Ro } from "react";
6
+ import { jsx as u, jsxs as T, Fragment as Ce } from "react/jsx-runtime";
7
+ import { CommandGenericIcon as Do, HeadingIcon as qr, ListTreeIcon as Lo, CodeIcon as Po, ArrowRightLeftIcon as No, WaypointsIcon as Ur, GaugeIcon as Fo, SlidersHorizontalIcon as _t, ClipboardIcon as Wo, DatabaseIcon as Kn, HashIcon as pn, ArrowDownToLineIcon as zo, ZapIcon as Bo, PaintbrushIcon as _o, TextCursorInputIcon as Ko, ListOrderedIcon as Hn, NetworkIcon as Ho, MousePointerClickIcon as jr, PenToolIcon as Gr, PencilIcon as tt, HighlighterIcon as Yr, WholeWordIcon as qo, TextCursorIcon as Uo, RulerIcon as Ve, ClapperboardIcon as Vr, BrushIcon as Xr, BlendIcon as Qe, PaletteIcon as Rt, TypeIcon as Ue, PilcrowIcon as jo, SwatchBookIcon as Go, LayersIcon as kt, SplineIcon as gn, CameraIcon as Yo, Rows3Icon as Jr, FilmIcon as qn, BookmarkIcon as Zr, DiamondIcon as Qr, BoxIcon as ei, Grid3x3Icon as St, FrameIcon as Jt, FolderIcon as Un, ClockIcon as Vo, Volume2Icon as Xo, VideoIcon as ti, SettingsIcon as wn, ShapesIcon as _e, LightbulbIcon as Jo, SquareIcon as ct, CrosshairIcon as Zo, Grid2x2Icon as Qo, MoveUpRightIcon as ea, MessageSquareIcon as Dt, FileIcon as bn, TableIcon as yn, SquareFunctionIcon as ni, ComponentIcon as ta, WandSparklesIcon as vn, MousePointer2Icon as nt, BoldIcon as na, ItalicIcon as ri, UnderlineIcon as ra, StrikethroughIcon as ia, SubscriptIcon as oa, SuperscriptIcon as aa, SquareDashedIcon as jn, ContrastIcon as sa, HandIcon as ii, ChevronsDownUpIcon as la, ChevronsUpDownIcon as ca, LinkIcon as Ct, ShieldCheckIcon as da, LifeBuoyIcon as ua, TrashIcon as rt, BookOpenIcon as ha, ArrowLeftIcon as fa, ArrowRightIcon as Gn, ArrowUpIcon as Yn, ArrowDownIcon as Vn, ArrowLeftToLineIcon as ma, ArrowRightToLineIcon as pa, ClipLiftIcon as ga, ClipExtractIcon as wa, FastForwardIcon as ba, StepForwardIcon as Xn, EyeOffIcon as Jn, Undo2Icon as kn, Redo2Icon as oi, SaveIcon as ai, FileOutputIcon as ya, FileInputIcon as va, FolderOpenIcon as ka, XIcon as Zt, PrinterIcon as Sn, CopyIcon as Cn, ScissorsIcon as xn, ClipboardPasteIcon as si, PencilLineIcon as Sa, SearchIcon as li, ReplaceIcon as ci, AlignCenterHorizontalIcon as Ca, RotateCwIcon as $n, FlipHorizontalIcon as xa, MoveIcon as di, ScalingIcon as ui, MergeIcon as $a, SplitIcon as Ia, GroupIcon as In, UngroupIcon as Mn, LockIcon as Tn, LockOpenIcon as Ma, EyeIcon as An, ZoomInIcon as hi, PlayIcon as Ta, PauseIcon as Aa, DiscIcon as Ea, RotateCcwIcon as fi, CheckIcon as En, ToggleLeftIcon as Oa, ChevronRightIcon as On, ChevronLeftIcon as Ra, CropIcon as mi, PlusIcon as pi, ListIcon as Da, RepeatIcon as La, ArrowUpDownIcon as gi, FunnelIcon as wi, UnlinkIcon as Pa, RefreshCwIcon as bi, BringToFrontIcon as Qt, MagnetIcon as Na, PenLineIcon as it, PaintBucketIcon as xt, TablePropertiesIcon as Fa, ActivityIcon as Wa, ChartColumnIcon as je, ImageIcon as za, StickerIcon as Ba, PanelTopIcon as yi, PanelBottomIcon as _a, SigmaIcon as Ka, OmegaIcon as Ha, SquareCheckBigIcon as qa, SignatureIcon as Ua, CalendarIcon as ja, MusicIcon as Ga, QrCodeIcon as Ya, LayoutTemplateIcon as Va, FilePlusIcon as Xa, Columns2Icon as vi, SpellCheckIcon as Ja, LanguagesIcon as Za, TagIcon as ki, RulerDimensionLineIcon as Qa, RadiusIcon as es, DiameterIcon as ts, PackageIcon as ns, StickyNoteIcon as rs, MousePointerIcon as is, LassoIcon as os, MinusIcon as Si, RainbowIcon as as, ShellIcon as ss, CircleIcon as Ci, EraserIcon as xi, VectorPolygonIcon as ls, VectorSquareIcon as cs, WavesHorizontalIcon as ds, Move3dIcon as us, PipetteIcon as hs, CopyPlusIcon as fs, MoveHorizontalIcon as ms, CornerDownRightIcon as ps, UploadIcon as gs, StarIcon as $i, Share2Icon as ws, SendIcon as bs, MailIcon as ys, InfoIcon as vs, CircleQuestionMarkIcon as ks, FlagIcon as Ss, DownloadIcon as Cs, BellIcon as xs, ChevronDownIcon as Ii, ChevronsLeftIcon as $s, ChevronsRightIcon as Is, SparklesIcon as Lt, EllipsisIcon as Ms, RectangleHorizontalIcon as Mi, TriangleIcon as Ts, MoveRightIcon as As, SendToBackIcon as Es, CableIcon as Os, PenIcon as Ti, ChartColumnStackedIcon as Rs, ChartLineIcon as Zn, ChartAreaIcon as Ds, ChartPieIcon as Qn, ChartScatterIcon as Ls, RadarIcon as Ps, LayoutGridIcon as Ns, TrendingUpIcon as Fs, Table2Icon as Ws, Minimize2Icon as zs, FocusIcon as Ai, MenuIcon as Bs } from "@kition/tessera-icons/react";
8
8
  import * as lu from "@kition/tessera-icons/react";
9
9
  import { w as Fm } from "./chunks/workspaceTree-CpJ2i9hy.js";
10
10
  const en = ["menus", "line", "classic", "focus"], _s = ["menus", "line", "classic"], Ks = 720;
@@ -24,7 +24,7 @@ function Hs(e) {
24
24
  return null;
25
25
  }
26
26
  }
27
- function Us(e, t) {
27
+ function qs(e, t) {
28
28
  try {
29
29
  localStorage.setItem(Oi(e), t);
30
30
  } catch {
@@ -35,7 +35,7 @@ function Ri(e) {
35
35
  const t = e.allowed;
36
36
  return t?.length ? en.filter((n) => t.includes(n)) : en;
37
37
  }
38
- function qs({ stored: e, rules: t, kit: n, readOnly: r }) {
38
+ function Us({ stored: e, rules: t, kit: n, readOnly: r }) {
39
39
  const i = Ri(t), o = t.default === "focus" ? null : t.default, a = [e, o, r ? "menus" : null, n, "line"];
40
40
  for (const s of a) if (s && i.includes(s)) return s;
41
41
  return i.find((s) => s !== "focus") ?? "menus";
@@ -192,7 +192,7 @@ function al(e, t) {
192
192
  return r.hostHidden ? [] : [r.hostDisabled ? { ...n, enabled: !1 } : n];
193
193
  });
194
194
  }
195
- function Ni(e, t, n) {
195
+ function Pi(e, t, n) {
196
196
  let r = e, i = null;
197
197
  const o = /* @__PURE__ */ new Set(), a = (s) => {
198
198
  r = i ? { ...s, personal: i } : s;
@@ -224,7 +224,7 @@ function nr(e, t = null, n = document.documentElement) {
224
224
  if (r) for (const [i, o] of Object.entries(yo(t, e.colorScheme))) n.style.setProperty(i, o);
225
225
  n.dataset.brand = r ? "kit" : "host", n.style.colorScheme = e.colorScheme, n.dataset.colorScheme = e.colorScheme;
226
226
  }
227
- const Nt = () => typeof navigator < "u" && /Mac|iPhone|iPad/i.test(navigator.platform);
227
+ const Pt = () => typeof navigator < "u" && /Mac|iPhone|iPad/i.test(navigator.platform);
228
228
  function cu(e) {
229
229
  return new Promise((t) => {
230
230
  const n = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`, r = () => window.parent.postMessage({ kitionKitUi: 1, ready: Bt, id: n }, "*"), i = (o) => {
@@ -243,16 +243,16 @@ function cu(e) {
243
243
  const p = s.capabilities.includes("replica") && (e.capabilities ?? []).includes("replica"), h = {
244
244
  read: async (m) => {
245
245
  if (l && m === s.document.path) {
246
- const I = l;
247
- return l = null, { bytes: I, stamp: s.document.version ?? null };
246
+ const M = l;
247
+ return l = null, { bytes: M, stamp: s.document.version ?? null };
248
248
  }
249
249
  const y = await a.request("host/read", { path: m });
250
250
  return { bytes: y.bytes, stamp: y.version };
251
251
  },
252
252
  stamp: async (m) => (await a.request("host/stamp", { path: m })).version,
253
- write: async (m, y, I) => {
254
- const N = y.buffer.slice(y.byteOffset, y.byteOffset + y.byteLength);
255
- return (await a.request("host/write", { path: m, bytes: N, mode: "save", ...I === void 0 ? {} : { expected: I } }, { transfer: !0 })).version || null;
253
+ write: async (m, y, M) => {
254
+ const P = y.buffer.slice(y.byteOffset, y.byteOffset + y.byteLength);
255
+ return (await a.request("host/write", { path: m, bytes: P, mode: "save", ...M === void 0 ? {} : { expected: M } }, { transfer: !0 })).version || null;
256
256
  },
257
257
  lend: () => s.document.lend ?? null
258
258
  };
@@ -264,14 +264,14 @@ function cu(e) {
264
264
  });
265
265
  const f = vo(e.brand);
266
266
  nr(s.theme, f);
267
- const g = Ni(
267
+ const g = Pi(
268
268
  tr(s.ui),
269
269
  s.capabilities.includes("customize") ? async (m) => void await a.request("host/customize", { personal: { hide: m } }) : null,
270
270
  (m) => a.notify("ui/action", m)
271
271
  );
272
272
  a.on("ui/configure", (m) => g.replace(tr(m?.ui))), document.documentElement.lang = s.locale;
273
273
  const w = s.shortcuts, b = (m) => {
274
- w.some((y) => Hr(y, m, Nt())) && (m.preventDefault(), m.stopPropagation(), a.notify("host/shortcut", { key: m.key, code: m.code, meta: m.metaKey, ctrl: m.ctrlKey, shift: m.shiftKey, alt: m.altKey }));
274
+ w.some((y) => Hr(y, m, Pt())) && (m.preventDefault(), m.stopPropagation(), a.notify("host/shortcut", { key: m.key, code: m.code, meta: m.metaKey, ctrl: m.ctrlKey, shift: m.shiftKey, alt: m.altKey }));
275
275
  };
276
276
  window.addEventListener("keydown", b, !0), a.on("ui/theme", ({ theme: m }) => nr(m, f)), a.on("ui/locale", ({ locale: m }) => {
277
277
  document.documentElement.lang = m;
@@ -286,8 +286,8 @@ function cu(e) {
286
286
  permissions: mo(s.document.permissions),
287
287
  watermark: fo(s.document.watermark),
288
288
  onReveal: (m) => a.on("document/reveal", (y) => {
289
- const I = _n(y?.view);
290
- I && m(I);
289
+ const M = _n(y?.view);
290
+ M && m(M);
291
291
  }),
292
292
  ui: g,
293
293
  brand: f,
@@ -296,14 +296,14 @@ function cu(e) {
296
296
  declaration: e.ui ?? null,
297
297
  opened: (m = []) => {
298
298
  const y = [...e.capabilities ?? ["ai"], ...e.ui ? ["ui-config"] : []];
299
- d({ kit: { id: e.id, version: e.version }, capabilities: [...y, ...m.filter((I) => !y.includes(I))] });
299
+ d({ kit: { id: e.id, version: e.version }, capabilities: [...y, ...m.filter((M) => !y.includes(M))] });
300
300
  },
301
301
  failed: (m) => c(m),
302
302
  changed: (m) => a.notify("document/changed", m),
303
303
  notify: (m) => a.notify("host/notify", m),
304
304
  exportFile: async (m, y) => {
305
- const I = y.buffer.slice(y.byteOffset, y.byteOffset + y.byteLength);
306
- return (await a.request("host/write", { path: m, bytes: I, mode: "export" }, { transfer: !0 })).path;
305
+ const M = y.buffer.slice(y.byteOffset, y.byteOffset + y.byteLength);
306
+ return (await a.request("host/write", { path: m, bytes: M, mode: "export" }, { transfer: !0 })).path;
307
307
  },
308
308
  openAgent: async (m) => {
309
309
  await a.request("host/openAgent", m ? { prompt: m } : {});
@@ -313,24 +313,24 @@ function cu(e) {
313
313
  hasService: (m) => s.capabilities.includes(`${Bn}${m}`),
314
314
  service: async (m, y) => {
315
315
  if (!s.capabilities.includes(`${Bn}${m}`)) throw new he(-32e3, `the host does not serve ${m}`, { reason: "not-allowed" });
316
- const I = m === "file.saveAs";
317
- return await a.request("host/service", { service: m, params: y }, I ? { transfer: !0 } : void 0);
316
+ const M = m === "file.saveAs";
317
+ return await a.request("host/service", { service: m, params: y }, M ? { transfer: !0 } : void 0);
318
318
  },
319
319
  commentAnchors: s.capabilities.includes("comment-anchors"),
320
320
  onComments: (m) => a.on("comments/show", (y) => {
321
- const I = Array.isArray(y?.threads) ? y.threads : [];
321
+ const M = Array.isArray(y?.threads) ? y.threads : [];
322
322
  m(
323
- I.flatMap((N) => {
324
- const E = zn(N?.anchor);
325
- return E && typeof N?.id == "string" ? [{ id: N.id, anchor: E, resolved: N.resolved === !0, count: Number.isSafeInteger(N.count) ? N.count : 0 }] : [];
323
+ M.flatMap((P) => {
324
+ const E = zn(P?.anchor);
325
+ return E && typeof P?.id == "string" ? [{ id: P.id, anchor: E, resolved: P.resolved === !0, count: Number.isSafeInteger(P.count) ? P.count : 0 }] : [];
326
326
  })
327
327
  );
328
328
  }),
329
329
  activateComment: (m) => a.notify("comments/activated", { id: m }),
330
330
  locateComments: (m) => a.handle("comments/locate", async (y) => {
331
- const N = (Array.isArray(y?.anchors) ? y.anchors : []).map((U) => zn(U)), E = await m(N.filter((U) => U !== null));
332
- let Y = 0;
333
- return { found: N.map((U) => U ? E[Y++] === !0 : !1) };
331
+ const P = (Array.isArray(y?.anchors) ? y.anchors : []).map((q) => zn(q)), E = await m(P.filter((q) => q !== null));
332
+ let G = 0;
333
+ return { found: P.map((q) => q ? E[G++] === !0 : !1) };
334
334
  }),
335
335
  close: () => {
336
336
  window.removeEventListener("keydown", b, !0), a.close();
@@ -347,7 +347,7 @@ class Je extends Error {
347
347
  super(t.message), this.data = t, this.name = "KitModelError";
348
348
  }
349
349
  }
350
- const ll = /* @__PURE__ */ new Set(["edit.undo", "undo"]), cl = /* @__PURE__ */ new Set(["edit.redo", "redo"]), Oe = "read-only", Pe = Object.freeze({
350
+ const ll = /* @__PURE__ */ new Set(["edit.undo", "undo"]), cl = /* @__PURE__ */ new Set(["edit.redo", "redo"]), Oe = "read-only", Ne = Object.freeze({
351
351
  /**
352
352
  * Families whose commands only change what the person sees (zoom, selection, the playhead,
353
353
  * playback): they run even when their kit flags them `mutates`.
@@ -431,16 +431,16 @@ const ll = /* @__PURE__ */ new Set(["edit.undo", "undo"]), cl = /* @__PURE__ */
431
431
  });
432
432
  function dl(e) {
433
433
  const { id: t } = e, n = t.split(".")[0] ?? "";
434
- return Pe.editingCommands.includes(t) || Pe.documentSettings.includes(t) ? !0 : Pe.editingGroups.includes(n) ? !Pe.fileOutputs.test(t) : Pe.viewingCommands.includes(t) || Pe.viewingGroups.includes(n) ? !1 : e.mutates === !0;
434
+ return Ne.editingCommands.includes(t) || Ne.documentSettings.includes(t) ? !0 : Ne.editingGroups.includes(n) ? !Ne.fileOutputs.test(t) : Ne.viewingCommands.includes(t) || Ne.viewingGroups.includes(n) ? !1 : e.mutates === !0;
435
435
  }
436
436
  function ul(e, t) {
437
- return !t || !e ? /* @__PURE__ */ new Set() : new Set(e.filter((n) => typeof n == "string" && !Pe.editingCommands.includes(n) && !Pe.editingGroups.includes(n.split(".")[0] ?? "")));
437
+ return !t || !e ? /* @__PURE__ */ new Set() : new Set(e.filter((n) => typeof n == "string" && !Ne.editingCommands.includes(n) && !Ne.editingGroups.includes(n.split(".")[0] ?? "")));
438
438
  }
439
- function Pi(e, t) {
439
+ function Ni(e, t) {
440
440
  return t.size === 0 ? null : ll.has(e) ? "undo" : cl.has(e) ? "redo" : null;
441
441
  }
442
442
  function It(e, t) {
443
- return dl(e) && !t.has(e.id) && Pi(e.id, t) === null;
443
+ return dl(e) && !t.has(e.id) && Ni(e.id, t) === null;
444
444
  }
445
445
  function hl(e, t) {
446
446
  return t.size > 0 && It(e, t);
@@ -467,7 +467,7 @@ class Wi extends Error {
467
467
  super(n), this.reason = t, this.name = "KitEngineRefusal";
468
468
  }
469
469
  }
470
- const Ut = { width: 0, height: 0, pinned: { left: 0, top: 0 }, revision: 0, dirty: !1, canUndo: !1, canRedo: !1, inspected: {} };
470
+ const qt = { width: 0, height: 0, pinned: { left: 0, top: 0 }, revision: 0, dirty: !1, canUndo: !1, canRedo: !1, inspected: {} };
471
471
  class ot {
472
472
  constructor(t, n) {
473
473
  this.worker = t, this.info = n;
@@ -476,6 +476,9 @@ class ot {
476
476
  pending = /* @__PURE__ */ new Map();
477
477
  nextId = 1;
478
478
  failure = null;
479
+ fontListeners = /* @__PURE__ */ new Set();
480
+ /** How many of the manifest's `lazyFonts` the engine has not been given yet. */
481
+ fontsPending = 0;
479
482
  /**
480
483
  * Starts a worker and opens the file's bytes in it with the kit's SDK; the bytes move to the
481
484
  * worker. `lent` is where the document's other files (media) are read from, if anywhere;
@@ -487,9 +490,9 @@ class ot {
487
490
  static async open(t, n, r, i = null, o = null, a = !1, s = !1) {
488
491
  const d = new Worker(new URL(
489
492
  /* @vite-ignore */
490
- "" + new URL("assets/kitEngine.worker-D-kUyohc.js", import.meta.url).href,
493
+ "" + new URL("assets/kitEngine.worker-BfM9MCRl.js", import.meta.url).href,
491
494
  import.meta.url
492
- ), { type: "module" }), c = new ot(d, Ut);
495
+ ), { type: "module" }), c = new ot(d, qt);
493
496
  d.onmessage = (l) => c.settle(l.data), d.onerror = (l) => c.fail(new Error(l.message || "the kit engine stopped"));
494
497
  try {
495
498
  const l = o?.stored;
@@ -505,9 +508,9 @@ class ot {
505
508
  static async create(t, n, r, i, o = null, a = !1) {
506
509
  const s = new Worker(new URL(
507
510
  /* @vite-ignore */
508
- "" + new URL("assets/kitEngine.worker-D-kUyohc.js", import.meta.url).href,
511
+ "" + new URL("assets/kitEngine.worker-BfM9MCRl.js", import.meta.url).href,
509
512
  import.meta.url
510
- ), { type: "module" }), d = new ot(s, Ut);
513
+ ), { type: "module" }), d = new ot(s, qt);
511
514
  s.onmessage = (c) => d.settle(c.data), s.onerror = (c) => d.fail(new Error(c.message || "the kit engine stopped"));
512
515
  try {
513
516
  return d.info = await d.call({ method: "create", manifest: t, name: n, width: r, height: i, lent: o, readOnly: a }), d;
@@ -525,6 +528,11 @@ class ot {
525
528
  return this.info.pinned;
526
529
  }
527
530
  settle(t) {
531
+ if (!("id" in t)) {
532
+ const r = t.fonts < this.fontsPending;
533
+ if (this.fontsPending = t.fonts, r) for (const i of this.fontListeners) i();
534
+ return;
535
+ }
528
536
  const n = this.pending.get(t.id);
529
537
  n && (this.pending.delete(t.id), t.ok === !0 ? n.resolve(t.value) : t.data ? n.reject(new Je(t.data)) : t.reason === Oe ? n.reject(new Mt("", t.error)) : t.reason === At ? n.reject(new Rn(t.error, t.errors ?? [])) : t.reason === rn ? n.reject(new Wi(rn, t.error)) : n.reject(new Error(t.error)));
530
538
  }
@@ -547,7 +555,7 @@ class ot {
547
555
  */
548
556
  async execute(t, n = {}, r, i) {
549
557
  const o = { method: "execute", command: t, params: n, ...r ? { origin: r } : {}, ...i ? { agent: { state: i.state.state, set: i.set } } : {} }, { result: a, info: s, state: d, closed: c } = await this.call(o);
550
- return c && (this.closed = !0, this.info = Ut), s && (this.info = s), i && d !== void 0 && (i.state.state = d), a;
558
+ return c && (this.closed = !0, this.info = qt), s && (this.info = s), i && d !== void 0 && (i.state.state = d), a;
551
559
  }
552
560
  /** RGBA8 of the area at (`x`, `y`) document pixels shown at `scale` screen pixels per pixel. */
553
561
  async render(t, n, r, i, o) {
@@ -673,6 +681,18 @@ class ot {
673
681
  async markSaved(t) {
674
682
  this.info = await this.call({ method: "markSaved", revision: t });
675
683
  }
684
+ /**
685
+ * Calls `listener` each time the engine was given one of the manifest's `lazyFonts`: what it
686
+ * draws may have changed (text it drew as missing glyphs), so the page draws again. Answers how
687
+ * to stop.
688
+ */
689
+ onFonts(t) {
690
+ return this.fontListeners.add(t), () => this.fontListeners.delete(t);
691
+ }
692
+ /** Gives the engine every one of the manifest's `lazyFonts` now; resolves once each is in (or skipped). */
693
+ async loadFonts() {
694
+ await this.call({ method: "fonts" });
695
+ }
676
696
  /** Brings `info` up to date after changes it does not follow (an `invoke` that edits, such as a merge of the file). */
677
697
  async refreshInfo() {
678
698
  return this.info = await this.call({ method: "info" }), this.info;
@@ -765,12 +785,12 @@ function kl(e, t, n, r, i, o = {}) {
765
785
  c.current = o.followFile;
766
786
  const l = R(null), p = R(i);
767
787
  p.current = i;
768
- const h = R(null), f = R(!1), [g, w] = B(null), [b, m] = B(null), [y, I] = B(null), [N, E] = B({ revision: 0, damage: null }), [Y, U] = B(!1), [V, j] = B(null), [D, Z] = B(null), [Q, fe] = B(!1), [ce, k] = B(!1), [O, q] = B(0), x = R(null);
788
+ const h = R(null), f = R(!1), [g, w] = B(null), [b, m] = B(null), [y, M] = B(null), [P, E] = B({ revision: 0, damage: null }), [G, q] = B(!1), [Y, U] = B(null), [D, Z] = B(null), [Q, fe] = B(!1), [ce, k] = B(!1), [O, H] = B(0), x = R(null);
769
789
  x.current ??= gl();
770
- const C = x.current, W = H((S = null) => {
790
+ const C = x.current, W = K((S = null) => {
771
791
  const $ = l.current;
772
- $ && (m($.info), I(p.current($.info)), U($.info.dirty), E((F) => ({ revision: F.revision + 1, damage: S })));
773
- }, []), _ = H(async (S) => {
792
+ $ && (m($.info), M(p.current($.info)), q($.info.dirty), E((F) => ({ revision: F.revision + 1, damage: S })));
793
+ }, []), V = K(async (S) => {
774
794
  f.current = !0;
775
795
  try {
776
796
  const { bytes: $, stamp: F } = await e.read(n);
@@ -783,28 +803,28 @@ function kl(e, t, n, r, i, o = {}) {
783
803
  return;
784
804
  }
785
805
  const ke = l.current;
786
- l.current = oe, h.current = F, w(oe), k(!1), j(null), W(), ke?.dispose();
806
+ l.current = oe, h.current = F, w(oe), k(!1), U(null), W(), ke?.dispose();
787
807
  } finally {
788
808
  f.current = !1;
789
809
  }
790
810
  }, [s, e, t, d, n, a, W]);
791
811
  J(() => {
792
812
  let S = !0;
793
- return _(() => S).catch(($) => {
794
- S && j(vl($));
813
+ return V(() => S).catch(($) => {
814
+ S && U(vl($));
795
815
  }), () => {
796
816
  S = !1;
797
817
  };
798
- }, [O, _]), J(() => () => {
818
+ }, [O, V]), J(() => () => {
799
819
  l.current?.dispose(), l.current = null;
800
820
  }, [n]);
801
- const T = R(/* @__PURE__ */ new Set()), K = H((S) => {
802
- T.current.add(S);
803
- const $ = () => T.current.delete(S);
821
+ const I = R(/* @__PURE__ */ new Set()), _ = K((S) => {
822
+ I.current.add(S);
823
+ const $ = () => I.current.delete(S);
804
824
  return S.then($, $), S;
805
- }, []), ne = H(async () => {
806
- for (; T.current.size; ) await Promise.allSettled([...T.current]);
807
- }, []), P = H(
825
+ }, []), ne = K(async () => {
826
+ for (; I.current.size; ) await Promise.allSettled([...I.current]);
827
+ }, []), N = K(
808
828
  async (S = () => !0) => {
809
829
  const $ = l.current;
810
830
  if (!(!$ || f.current || !h.current))
@@ -832,44 +852,44 @@ function kl(e, t, n, r, i, o = {}) {
832
852
  return;
833
853
  }
834
854
  }
835
- S() && await _(S);
855
+ S() && await V(S);
836
856
  } catch {
837
857
  }
838
858
  },
839
- [e, _, n, W, ne]
859
+ [e, V, n, W, ne]
840
860
  );
841
861
  J(() => {
842
862
  let S = !0;
843
- const $ = window.setInterval(() => void P(() => S), yl);
863
+ const $ = window.setInterval(() => void N(() => S), yl);
844
864
  return () => {
845
865
  S = !1, window.clearInterval($);
846
866
  };
847
- }, [r, P]);
848
- const G = R(null), ue = H((S) => G.current ? G.current(S) : S(), []), ye = H(
867
+ }, [r, N]);
868
+ const j = R(null), ue = K((S) => j.current ? j.current(S) : S(), []), ye = K(
849
869
  async (S, $, F, X) => {
850
870
  const ee = l.current;
851
871
  if (!ee) return null;
852
872
  const de = X.skipUnchangedPaint ? { revision: ee.info.revision, inspected: JSON.stringify(ee.info.inspected) } : null, oe = await ee.execute(S, $, X.origin, X.agent);
853
873
  if (l.current === ee) {
854
874
  if (ee.closed)
855
- return ee.dispose(), l.current = null, w(null), m(null), I(null), U(!1), k(!1), oe;
875
+ return ee.dispose(), l.current = null, w(null), m(null), M(null), q(!1), k(!1), oe;
856
876
  const ke = X.refresh ?? "all", dt = de != null && ee.info.revision === de.revision && JSON.stringify(ee.info.inspected) === de.inspected;
857
877
  ke === "all" ? W(dt ? rr : F) : ke === "repaint" && C.bump(F);
858
878
  }
859
879
  return oe;
860
880
  },
861
881
  [W, C]
862
- ), Ie = H(
863
- async (S, $ = {}, F = null, X = {}) => l.current ? K(ue(() => ye(S, $, F, X))) : null,
864
- [ue, ye, K]
865
- ), Ne = H(async (S, $ = [], F = !1) => {
882
+ ), Ie = K(
883
+ async (S, $ = {}, F = null, X = {}) => l.current ? _(ue(() => ye(S, $, F, X))) : null,
884
+ [ue, ye, _]
885
+ ), Pe = K(async (S, $ = [], F = !1) => {
866
886
  const X = l.current;
867
887
  if (!X) return null;
868
- const ee = X.info.revision, { value: de, changed: oe } = await K(X.tool(S, $, F));
888
+ const ee = X.info.revision, { value: de, changed: oe } = await _(X.tool(S, $, F));
869
889
  return l.current === X && oe && W(X.info.revision === ee ? rr : pl(de)), de;
870
- }, [W, K]);
871
- on.has(Ne) || on.set(Ne, G);
872
- const We = H(async () => l.current ? l.current.commands() : [], []), A = H(async () => ue(async () => l.current ? l.current.disabledCommands() : []), [ue]), L = H(async () => {
890
+ }, [W, _]);
891
+ on.has(Pe) || on.set(Pe, j);
892
+ const We = K(async () => l.current ? l.current.commands() : [], []), A = K(async () => ue(async () => l.current ? l.current.disabledCommands() : []), [ue]), L = K(async () => {
873
893
  const S = l.current;
874
894
  if (S) {
875
895
  if (a) throw new Mt("Save");
@@ -942,18 +962,18 @@ function kl(e, t, n, r, i, o = {}) {
942
962
  }),
943
963
  compare: ($, F) => S().replicaCompare($, F)
944
964
  };
945
- }, [e, t, ue, n, a, W]), se = H(() => q((S) => S + 1), []), ge = H(
965
+ }, [e, t, ue, n, a, W]), se = K(() => H((S) => S + 1), []), ge = K(
946
966
  async (S) => {
947
967
  if (!S) return;
948
968
  h.current = S, await e.stamp(n).catch(() => null) === S && k(!1);
949
969
  },
950
970
  [e, n]
951
- ), v = H(async () => {
971
+ ), v = K(async () => {
952
972
  k(!1);
953
973
  const S = await e.stamp(n).catch(() => null);
954
974
  S && (h.current = S);
955
975
  }, [e, n]), z = pe(() => ({ get: C.get, subscribe: C.subscribe }), [C]);
956
- return { path: n, manifest: t, doc: g, info: b, state: y, change: N, repaints: z, dirty: Y, failure: V, openMs: D, saving: Q, conflict: ce, run: Ie, tool: Ne, commands: We, disabledCommands: A, save: L, replica: re, model: ie, draft: ae, reopen: se, keepMine: v, checkFile: P, holdFile: ge };
976
+ return { path: n, manifest: t, doc: g, info: b, state: y, change: P, repaints: z, dirty: G, failure: Y, openMs: D, saving: Q, conflict: ce, run: Ie, tool: Pe, commands: We, disabledCommands: A, save: L, replica: re, model: ie, draft: ae, reopen: se, keepMine: v, checkFile: N, holdFile: ge };
957
977
  }
958
978
  async function an(e, t) {
959
979
  const n = Math.min(1, t / Math.max(1, e.width, e.height)), r = Math.max(1, Math.round(e.width * n)), i = Math.max(1, Math.round(e.height * n)), o = await e.render(0, 0, n, r, i), a = document.createElement("canvas");
@@ -1075,7 +1095,7 @@ const xl = [
1075
1095
  [/^tool-lasso/, os],
1076
1096
  [/^tool-(pen|anchor)/, Gr],
1077
1097
  [/^tool-curvature/, gn],
1078
- [/^tool-(type|touch-type)/, qe],
1098
+ [/^tool-(type|touch-type)/, Ue],
1079
1099
  [/^tool-line$/, Si],
1080
1100
  [/^tool-arc/, as],
1081
1101
  [/^tool-spiral/, ss],
@@ -1091,7 +1111,7 @@ const xl = [
1091
1111
  [/^tool-shear/, ri],
1092
1112
  [/^tool-reshape/, ls],
1093
1113
  [/^tool-free-transform/, cs],
1094
- [/^tool-puppet/, qr],
1114
+ [/^tool-puppet/, Ur],
1095
1115
  [/^tool-(width|warp|twirl|pucker|bloat|scallop|crystallize|wrinkle)/, ds],
1096
1116
  [/^tool-shape-builder/, _e],
1097
1117
  [/^tool-bucket/, xt],
@@ -1133,10 +1153,10 @@ const Il = [
1133
1153
  [/equation|formula|function/, ni],
1134
1154
  [/sum|sigma/, Ka],
1135
1155
  [/symbol|special char/, Ha],
1136
- [/check ?box|checkbox/, Ua],
1156
+ [/check ?box|checkbox/, qa],
1137
1157
  [/comment|note/, Dt],
1138
- [/text|word ?art|caption/, qe],
1139
- [/signature/, qa],
1158
+ [/text|word ?art|caption/, Ue],
1159
+ [/signature/, Ua],
1140
1160
  [/date|time/, ja],
1141
1161
  [/number|numbering/, pn],
1142
1162
  [/video|movie|media/, ti],
@@ -1250,23 +1270,23 @@ const Il = [
1250
1270
  [/^(?:sort)$/, gi],
1251
1271
  [/^(?:filter)$/, wi],
1252
1272
  [/^(?:link)$/, Ct],
1253
- [/^(?:unlink)$/, Na],
1273
+ [/^(?:unlink)$/, Pa],
1254
1274
  [/^(?:increase|grow|raise)$/, Yn],
1255
1275
  [/^(?:decrease|shrink|lower)$/, Vn],
1256
1276
  [/^(?:refresh|reload|update|sync)$/, bi],
1257
1277
  [/^(?:define|edit|modify|configure)$/, tt],
1258
1278
  [/^(?:arrange|order|bring|send)$/, Qt],
1259
- [/^(?:snap)$/, Pa],
1279
+ [/^(?:snap)$/, Na],
1260
1280
  [/^(?:smooth|simplify)$/, gn],
1261
1281
  [/^(?:stroke|outline)$/, it],
1262
1282
  [/^(?:fill)$/, xt],
1263
1283
  [/^(?:mask)$/, jn]
1264
1284
  ], or = [
1265
- [/\b(?:heading|title)\b/, Ur],
1285
+ [/\b(?:heading|title)\b/, qr],
1266
1286
  [/\b(?:level|outline|tree)\b/, Lo],
1267
- [/\b(?:code)\b/, No],
1268
- [/\b(?:direction)\b/, Po],
1269
- [/\b(?:waypoints?|bends?)\b/, qr],
1287
+ [/\b(?:code)\b/, Po],
1288
+ [/\b(?:direction)\b/, No],
1289
+ [/\b(?:waypoints?|bends?)\b/, Ur],
1270
1290
  [/\b(?:stats|statistics|performance)\b/, Fo],
1271
1291
  [/\b(?:mixer)\b/, _t],
1272
1292
  [/\b(?:clipboard)\b/, Wo],
@@ -1277,27 +1297,27 @@ const Il = [
1277
1297
  [/\b(?:painter)\b/, _o],
1278
1298
  [/\b(?:field|form)\b/, Ko],
1279
1299
  [/\b(?:tab order)\b/, Hn],
1280
- [/\b(?:smart ?art|diagram)\b/, Ho],
1300
+ [/\b(?:smart ?graphics?|diagram)\b/, Ho],
1281
1301
  [/\b(?:action button|button)\b/, jr],
1282
1302
  [/\b(?:pen)\b/, Gr],
1283
1303
  [/\b(?:pencil)\b/, tt],
1284
1304
  [/\b(?:highlighter)\b/, Yr],
1285
- [/\b(?:word)\b/, Uo],
1286
- [/\b(?:caret|cursor)\b/, qo],
1305
+ [/\b(?:word)\b/, qo],
1306
+ [/\b(?:caret|cursor)\b/, Uo],
1287
1307
  [/\b(?:distance|perimeter|area)\b/, Ve],
1288
1308
  [/\b(?:work area)\b/, Vr],
1289
1309
  [/\b(?:brush|paint)\b/, Xr],
1290
1310
  [/\b(?:gradient)\b/, Qe],
1291
1311
  [/\b(?:transparen|opacity|blend)\b/, Qe],
1292
1312
  [/\b(?:colou?rs?|swatch|palette)\b/, Rt],
1293
- [/\b(?:font|character|typograph|text|type)\b/, qe],
1313
+ [/\b(?:font|character|typograph|text|type)\b/, Ue],
1294
1314
  [/\b(?:para(graph)?)\b/, jo],
1295
1315
  [/\b(?:presets?|styles?)\b/, Go],
1296
1316
  [/\b(?:layers?)\b/, kt],
1297
1317
  [/\b(?:paths?|anchor|point|bezier|curve)\b/, gn],
1298
1318
  [/\b(?:camera)\b/, Yo],
1299
1319
  [/\b(?:track)\b/, Jr],
1300
- [/\b(?:clip|footage|sequence|timeline|multicam)\b/, Un],
1320
+ [/\b(?:clip|footage|sequence|timeline|multicam)\b/, qn],
1301
1321
  [/\b(?:markers?|bookmark)\b/, Zr],
1302
1322
  [/\b(?:keys?|keyframe)\b/, Qr],
1303
1323
  [/\b(?:channel)\b/, _t],
@@ -1306,7 +1326,7 @@ const Il = [
1306
1326
  [/\b(?:frame|artboard)\b/, Jt],
1307
1327
  [/\b(?:data|database|source)\b/, Kn],
1308
1328
  [/\b(?:queue)\b/, Hn],
1309
- [/\b(?:project)\b/, qn],
1329
+ [/\b(?:project)\b/, Un],
1310
1330
  [/\b(?:comp(osition)?)\b/, kt],
1311
1331
  [/\b(?:playhead|time|duration)\b/, Vo],
1312
1332
  [/\b(?:audio|sound|volume)\b/, Xo],
@@ -1317,8 +1337,8 @@ const Il = [
1317
1337
  [/\b(?:solid)\b/, ct],
1318
1338
  [/\b(?:null)\b/, Zo],
1319
1339
  [/\b(?:adjustment)\b/, _t],
1320
- [/\b(?:footage|media)\b/, Un],
1321
- [/\b(?:folder)\b/, qn],
1340
+ [/\b(?:footage|media)\b/, qn],
1341
+ [/\b(?:folder)\b/, Un],
1322
1342
  [/\b(?:mosaic)\b/, Qo],
1323
1343
  [/\b(?:gradient mesh|mesh)\b/, St],
1324
1344
  [/\b(?:line|arrow)\b/, ea],
@@ -1344,7 +1364,7 @@ function Ge(e) {
1344
1364
  const a = Ml.find(([s]) => s.test(r) || s.test(i))?.[1];
1345
1365
  return a || (or.find(([s]) => s.test(o))?.[1] ?? Il.find(([s]) => s.test(o))?.[1] ?? at);
1346
1366
  }
1347
- function Pt(e) {
1367
+ function Nt(e) {
1348
1368
  return Object.values(e.schema ?? {}).some((t) => t.required);
1349
1369
  }
1350
1370
  const Tl = 6, sr = (e) => typeof e == "string" ? e : JSON.stringify(e);
@@ -1378,33 +1398,33 @@ function Ol({
1378
1398
  title: o
1379
1399
  }) {
1380
1400
  const a = e.schema ?? {}, [s, d] = B(() => Object.fromEntries(Object.entries(a).map(([m, y]) => [m, Al(y, i[m])]))), c = Object.entries(a), l = c.length > Tl, p = ([m, y]) => !l || y.required || i[m] !== void 0, h = c.filter(p), f = c.filter((m) => !p(m)), g = ([m, y]) => {
1381
- const I = (E) => d((Y) => ({ ...Y, [m]: E })), N = `param-${m}`;
1401
+ const M = (E) => d((G) => ({ ...G, [m]: E })), P = `param-${m}`;
1382
1402
  return [
1383
- /* @__PURE__ */ M("label", { htmlFor: N, title: y.description, children: [
1403
+ /* @__PURE__ */ T("label", { htmlFor: P, title: y.description, children: [
1384
1404
  m,
1385
1405
  y.required ? /* @__PURE__ */ u("span", { title: r.required, children: " *" }) : null
1386
1406
  ] }, `${m}-label`),
1387
- y.enum?.length ? /* @__PURE__ */ M("select", { id: N, className: "kui-field", value: s[m], onChange: (E) => I(E.target.value), children: [
1407
+ y.enum?.length ? /* @__PURE__ */ T("select", { id: P, className: "kui-field", value: s[m], onChange: (E) => M(E.target.value), children: [
1388
1408
  y.required ? null : /* @__PURE__ */ u("option", { value: "" }),
1389
1409
  y.enum.map((E) => /* @__PURE__ */ u("option", { value: String(E), children: String(E) }, String(E)))
1390
- ] }, m) : y.type === "boolean" ? /* @__PURE__ */ u("input", { id: N, type: "checkbox", checked: s[m] === "true", onChange: (E) => I(String(E.target.checked)) }, m) : /* @__PURE__ */ u(
1410
+ ] }, m) : y.type === "boolean" ? /* @__PURE__ */ u("input", { id: P, type: "checkbox", checked: s[m] === "true", onChange: (E) => M(String(E.target.checked)) }, m) : /* @__PURE__ */ u(
1391
1411
  "input",
1392
1412
  {
1393
- id: N,
1413
+ id: P,
1394
1414
  className: "kui-field",
1395
1415
  type: y.type === "number" || y.type === "integer" ? "number" : "text",
1396
1416
  value: s[m],
1397
1417
  placeholder: y.description,
1398
- onChange: (E) => I(E.target.value)
1418
+ onChange: (E) => M(E.target.value)
1399
1419
  },
1400
1420
  m
1401
1421
  )
1402
1422
  ];
1403
1423
  }, w = Object.entries(a).some(([m, y]) => y.required && (s[m] ?? "").trim() === ""), b = () => {
1404
1424
  const m = {};
1405
- for (const [y, I] of Object.entries(a)) {
1406
- const N = El(I, s[y] ?? "");
1407
- N !== void 0 && (m[y] = N);
1425
+ for (const [y, M] of Object.entries(a)) {
1426
+ const P = El(M, s[y] ?? "");
1427
+ P !== void 0 && (m[y] = P);
1408
1428
  }
1409
1429
  t(m);
1410
1430
  };
@@ -1413,11 +1433,11 @@ function Ol({
1413
1433
  {
1414
1434
  title: o ?? e.title,
1415
1435
  onClose: n,
1416
- actions: /* @__PURE__ */ M(Ce, { children: [
1436
+ actions: /* @__PURE__ */ T(Ce, { children: [
1417
1437
  /* @__PURE__ */ u(me, { onClick: n, children: r.cancel }),
1418
1438
  /* @__PURE__ */ u(me, { variant: "primary", disabled: w, onClick: b, "data-testid": "command-dialog-run", children: r.run })
1419
1439
  ] }),
1420
- children: /* @__PURE__ */ M(
1440
+ children: /* @__PURE__ */ T(
1421
1441
  "form",
1422
1442
  {
1423
1443
  onSubmit: (m) => {
@@ -1425,7 +1445,7 @@ function Ol({
1425
1445
  },
1426
1446
  children: [
1427
1447
  /* @__PURE__ */ u("div", { className: "kui-param-grid", children: h.map(g) }),
1428
- f.length ? /* @__PURE__ */ M("details", { children: [
1448
+ f.length ? /* @__PURE__ */ T("details", { children: [
1429
1449
  /* @__PURE__ */ u("summary", { children: r.more ?? "More options" }),
1430
1450
  /* @__PURE__ */ u("div", { className: "kui-param-grid", children: f.map(g) })
1431
1451
  ] }) : null,
@@ -1500,7 +1520,7 @@ function _i(e, t) {
1500
1520
  return i ? o.replace(/\{(\w+)\}/g, (a, s) => s in i ? String(i[s]) : a) : o;
1501
1521
  };
1502
1522
  }
1503
- const Ll = /* @__PURE__ */ new Set(["Cmd+N", "Cmd+W", "Cmd+O", "Cmd+P", "Cmd+Q", "Cmd+,", "Cmd+S", "Cmd+Shift+S", "Cmd+T", "Cmd+."]), Nl = Ll, lr = {
1523
+ const Ll = /* @__PURE__ */ new Set(["Cmd+N", "Cmd+W", "Cmd+O", "Cmd+P", "Cmd+Q", "Cmd+,", "Cmd+S", "Cmd+Shift+S", "Cmd+T", "Cmd+."]), Pl = Ll, lr = {
1504
1524
  "[": "BracketLeft",
1505
1525
  "]": "BracketRight",
1506
1526
  ",": "Comma",
@@ -1520,11 +1540,11 @@ function cr(e, t, n = Ki(), r = !1) {
1520
1540
  const i = e.split("+"), o = i.length > 1 && i[i.length - 1] === "" ? "+" : i.pop() ?? "", a = new Set(i.filter(Boolean)), s = a.has("Cmd"), d = n ? t.metaKey : t.ctrlKey, c = n ? t.ctrlKey : !1;
1521
1541
  return s !== d || a.has("Ctrl") !== c || a.has("Shift") !== t.shiftKey || a.has("Alt") !== t.altKey ? !1 : /^[A-Za-z]$/.test(o) ? t.code === `Key${o.toUpperCase()}` : /^[0-9]$/.test(o) ? t.code === `Digit${o}` : lr[o] ? t.code === lr[o] : o === "Delete" ? t.key === "Delete" || !r && t.key === "Backspace" : t.key === o;
1522
1542
  }
1523
- function Pl(e) {
1524
- return !e || Nl.has(e) ? !1 : e.includes("+") || /^(Delete|Backspace|PageUp|PageDown|F[0-9]{1,2})$/.test(e);
1543
+ function Nl(e) {
1544
+ return !e || Pl.has(e) ? !1 : e.includes("+") || /^(Delete|Backspace|PageUp|PageDown|F[0-9]{1,2})$/.test(e);
1525
1545
  }
1526
1546
  function Fl(e, t, n = Ki()) {
1527
- const r = e.filter((i) => Pl(i.shortcut));
1547
+ const r = e.filter((i) => Nl(i.shortcut));
1528
1548
  return r.find((i) => cr(i.shortcut, t, n, !0)) ?? r.find((i) => cr(i.shortcut, t, n));
1529
1549
  }
1530
1550
  const Wl = 4, Re = {
@@ -1556,7 +1576,7 @@ function fu(e, t, n = !1) {
1556
1576
  const o = Math.round(Math.min(e.x, e.x + r)), a = Math.round(Math.min(e.y, e.y + i)), s = Math.round(Math.max(e.x, e.x + r)), d = Math.round(Math.max(e.y, e.y + i));
1557
1577
  return { x: o, y: a, width: s - o, height: d - a };
1558
1578
  }
1559
- const qt = 8e6, zl = 33554432, dr = 8192, Bl = [0.5, 0.25, 0], ur = 32, _l = 0.01, Kl = 64, Ee = 8;
1579
+ const Ut = 8e6, zl = 33554432, dr = 8192, Bl = [0.5, 0.25, 0], ur = 32, _l = 0.01, Kl = 64, Ee = 8;
1560
1580
  function hr(e, t, n, r) {
1561
1581
  const i = (a, s) => ({ pinned: !1, off: t, s0: a, s1: n, d0: s, d1: t + n / r });
1562
1582
  if (e <= 0) return [i(0, t)];
@@ -1592,7 +1612,7 @@ function Hl(e) {
1592
1612
  const n = t.getContext("2d");
1593
1613
  return n ? (n.fillStyle = "#ffffff", n.fillRect(0, 0, Ee * 2, Ee * 2), n.fillStyle = "#e8e8ec", n.fillRect(0, 0, Ee, Ee), n.fillRect(Ee, Ee, Ee, Ee), e.createPattern(t, "repeat")) : null;
1594
1614
  }
1595
- class Ul {
1615
+ class ql {
1596
1616
  constructor(t, n, r, i, o = !0, a = () => {
1597
1617
  }) {
1598
1618
  this.canvas = t, this.doc = n, this.backdrop = r, this.onChange = i, this.framed = o, this.onRender = a;
@@ -1813,16 +1833,16 @@ class Ul {
1813
1833
  x1: Math.min(this.doc.width, Math.ceil(t.area.x1 + b)),
1814
1834
  y1: Math.min(this.doc.height, Math.ceil(t.area.y1 + m))
1815
1835
  };
1816
- }, o = (w) => (w.x1 - w.x0) * (w.y1 - w.y0) * Math.min(1, r) ** 2 * Math.max(1, r) ** 2 <= qt, { x0: a, y0: s, x1: d, y1: c } = Bl.map(i).find((w) => o(w)) ?? i(0);
1836
+ }, o = (w) => (w.x1 - w.x0) * (w.y1 - w.y0) * Math.min(1, r) ** 2 * Math.max(1, r) ** 2 <= Ut, { x0: a, y0: s, x1: d, y1: c } = Bl.map(i).find((w) => o(w)) ?? i(0);
1817
1837
  if (d <= a || c <= s) return null;
1818
1838
  let l, p, h, f;
1819
1839
  if (r < 1) {
1820
1840
  let w = Math.max(1, Math.floor(1 / r));
1821
- for (; (d - a) / w * ((c - s) / w) > qt; ) w += 1;
1841
+ for (; (d - a) / w * ((c - s) / w) > Ut; ) w += 1;
1822
1842
  h = Math.ceil((d - a) / w), f = Math.ceil((c - s) / w), p = await this.doc.renderArea(a, s, a + h * w, s + f * w, h, f), l = { x: a, y: s, width: h * w, height: f * w, scale: 1 / w };
1823
1843
  } else {
1824
1844
  let w = r;
1825
- const b = (d - a) * (c - s) * w * w, m = i(0), y = Math.max(qt, Math.min(zl, (m.x1 - m.x0) * (m.y1 - m.y0) * r * r));
1845
+ const b = (d - a) * (c - s) * w * w, m = i(0), y = Math.max(Ut, Math.min(zl, (m.x1 - m.x0) * (m.y1 - m.y0) * r * r));
1826
1846
  b > y && (w = Math.max(1, w * Math.sqrt(y / b))), w = Math.max(1, Math.min(w, dr / (d - a), dr / (c - s))), h = Math.max(1, Math.ceil((d - a) * w)), f = Math.max(1, Math.ceil((c - s) * w)), p = await this.doc.render(a, s, w, h, f), l = { x: a, y: s, width: h / w, height: f / w, scale: w };
1827
1847
  }
1828
1848
  const g = document.createElement("canvas");
@@ -1896,15 +1916,15 @@ class Ul {
1896
1916
  return c ? [c[0], c[1], c[2]] : null;
1897
1917
  }
1898
1918
  }
1899
- const ql = "#f3f3f6";
1919
+ const Ul = "#f3f3f6";
1900
1920
  function pr() {
1901
- return getComputedStyle(document.documentElement).getPropertyValue("--kit-canvas").trim() || ql;
1921
+ return getComputedStyle(document.documentElement).getPropertyValue("--kit-canvas").trim() || Ul;
1902
1922
  }
1903
1923
  const jl = 0.01, Gl = 100;
1904
1924
  function Yl(e, t = 1) {
1905
1925
  return e.pointerType !== "pen" ? 1 : e.pressure > 0 ? e.pressure : t;
1906
1926
  }
1907
- function Ue(e, t, n = 1) {
1927
+ function qe(e, t, n = 1) {
1908
1928
  const r = t.toImage(e.clientX, e.clientY), i = t.toScreen(r.x, r.y);
1909
1929
  return {
1910
1930
  x: r.x,
@@ -1936,46 +1956,50 @@ function Vl(e, t) {
1936
1956
  };
1937
1957
  }
1938
1958
  function Xl({ doc: e, change: t, repaint: n, tool: r, onView: i, onRender: o, viewMemory: a, initialArea: s = null, panBounds: d = null, decorate: c = null, animated: l = !1, spacePans: p = !0, framed: h = !0, children: f, ref: g }) {
1939
- const w = R(null), b = R(null), m = R(null), y = R(null), [I, N] = B(!1), E = R({ doc: e, onView: i, onRender: o, initialArea: s, panBounds: d });
1959
+ const w = R(null), b = R(null), m = R(null), y = R(null), [M, P] = B(!1), E = R({ doc: e, onView: i, onRender: o, initialArea: s, panBounds: d });
1940
1960
  E.current = { doc: e, onView: i, onRender: o, initialArea: s, panBounds: d };
1941
- const Y = Vl(b, m);
1961
+ const G = Vl(b, m);
1942
1962
  J(() => {
1943
1963
  const k = w.current;
1944
1964
  if (!k) return;
1945
1965
  let O = a.current != null;
1946
- const q = new Ul(k, e, pr(), (_, T) => {
1947
- O && (a.current = _), E.current.onView({ ..._, width: k.clientWidth, height: k.clientHeight }, T);
1948
- }, h, (_) => {
1949
- E.current.doc === e && E.current.onRender?.(_);
1966
+ const H = new ql(k, e, pr(), (I, _) => {
1967
+ O && (a.current = I), E.current.onView({ ...I, width: k.clientWidth, height: k.clientHeight }, _);
1968
+ }, h, (I) => {
1969
+ E.current.doc === e && E.current.onRender?.(I);
1950
1970
  });
1951
- m.current = q, a.current && (q.view = { ...a.current }), q.setPanBounds(E.current.panBounds);
1971
+ m.current = H, a.current && (H.view = { ...a.current }), H.setPanBounds(E.current.panBounds);
1952
1972
  const x = new ResizeObserver(() => {
1953
1973
  if (!O && k.clientWidth > 0 && k.clientHeight > 0) {
1954
1974
  O = !0;
1955
- const _ = E.current.initialArea;
1956
- _ ? q.fitArea(_) : q.fit();
1975
+ const I = E.current.initialArea;
1976
+ I ? H.fitArea(I) : H.fit();
1957
1977
  }
1958
- O && q.resized(), q.render();
1978
+ O && H.resized(), H.render();
1959
1979
  });
1960
1980
  x.observe(k);
1961
- const C = (_) => {
1962
- _.preventDefault(), _.ctrlKey || _.metaKey ? q.zoomTo(q.view.zoom * Math.exp(-_.deltaY * jl), _.clientX, _.clientY) : q.panBy(-_.deltaX, -_.deltaY);
1981
+ const C = (I) => {
1982
+ I.preventDefault(), I.ctrlKey || I.metaKey ? H.zoomTo(H.view.zoom * Math.exp(-I.deltaY * jl), I.clientX, I.clientY) : H.panBy(-I.deltaX, -I.deltaY);
1963
1983
  };
1964
1984
  k.addEventListener("wheel", C, { passive: !1 });
1965
- const W = typeof MutationObserver > "u" ? null : new MutationObserver(() => q.setBackdrop(pr()));
1966
- return W?.observe(document.documentElement, { attributes: !0, attributeFilter: ["style", "data-color-scheme", "data-brand", "class"] }), () => {
1967
- W?.disconnect(), x.disconnect(), k.removeEventListener("wheel", C), q.dispose(), m.current = null;
1985
+ const W = typeof MutationObserver > "u" ? null : new MutationObserver(() => H.setBackdrop(pr()));
1986
+ W?.observe(document.documentElement, { attributes: !0, attributeFilter: ["style", "data-color-scheme", "data-brand", "class"] });
1987
+ const V = e.onFonts(() => {
1988
+ H.invalidate(), H.render();
1989
+ });
1990
+ return () => {
1991
+ V(), W?.disconnect(), x.disconnect(), k.removeEventListener("wheel", C), H.dispose(), m.current = null;
1968
1992
  };
1969
1993
  }, [e, h, a]), J(() => m.current?.setPanBounds(d), [e, d]), J(() => {
1970
1994
  const k = m.current;
1971
1995
  k && (t.damage || k.invalidate(), (t.damage ? k.patch(t.damage) : k.render()).then((O) => {
1972
- O && Y.clear();
1996
+ O && G.clear();
1973
1997
  }));
1974
1998
  }, [t]);
1975
- const U = R(n?.tick ?? 0);
1999
+ const q = R(n?.tick ?? 0);
1976
2000
  J(() => {
1977
2001
  const k = m.current;
1978
- !k || !n || n.tick === U.current || (U.current = n.tick, k.invalidate(), n.damage ? k.renderArea(n.damage) : k.render());
2002
+ !k || !n || n.tick === q.current || (q.current = n.tick, k.invalidate(), n.damage ? k.renderArea(n.damage) : k.render());
1979
2003
  }, [n]), J(() => {
1980
2004
  const k = m.current;
1981
2005
  if (!k || (k.decorate = c, k.draw(), !l || !c)) return;
@@ -1984,12 +2008,12 @@ function Xl({ doc: e, change: t, repaint: n, tool: r, onView: i, onRender: o, vi
1984
2008
  }, [l, c, e]), J(() => {
1985
2009
  if (!p) return;
1986
2010
  const k = (x) => x instanceof HTMLInputElement || x instanceof HTMLTextAreaElement, O = (x) => {
1987
- x.code === "Space" && !k(x.target) && N(!0);
1988
- }, q = (x) => {
1989
- x.code === "Space" && N(!1);
2011
+ x.code === "Space" && !k(x.target) && P(!0);
2012
+ }, H = (x) => {
2013
+ x.code === "Space" && P(!1);
1990
2014
  };
1991
- return window.addEventListener("keydown", O), window.addEventListener("keyup", q), () => {
1992
- window.removeEventListener("keydown", O), window.removeEventListener("keyup", q);
2015
+ return window.addEventListener("keydown", O), window.addEventListener("keyup", H), () => {
2016
+ window.removeEventListener("keydown", O), window.removeEventListener("keyup", H);
1993
2017
  };
1994
2018
  }, [p]), Oo(g, () => ({
1995
2019
  view: () => {
@@ -2006,62 +2030,62 @@ function Xl({ doc: e, change: t, repaint: n, tool: r, onView: i, onRender: o, vi
2006
2030
  panTo: (k, O) => m.current?.panTo(k, O),
2007
2031
  retryRender: async () => {
2008
2032
  const k = await m.current?.render() ?? !1;
2009
- return k && Y.clear(), k;
2033
+ return k && G.clear(), k;
2010
2034
  }
2011
2035
  }), []);
2012
- const V = () => m.current ? { viewport: m.current, overlay: Y } : null, j = R(1), D = (k) => {
2013
- const O = V();
2036
+ const Y = () => m.current ? { viewport: m.current, overlay: G } : null, U = R(1), D = (k) => {
2037
+ const O = Y();
2014
2038
  if (!O || k.button === 2) return;
2015
2039
  k.preventDefault();
2016
- const q = k.currentTarget.closest("[tabindex]");
2017
- q && document.activeElement !== q && q.focus({ preventScroll: !0 }), k.currentTarget.setPointerCapture(k.pointerId);
2018
- const x = I || k.button === 1 ? Re : r, C = Ue(k, O.viewport);
2019
- j.current = C.pressure, y.current = x.begin(C, O) || null;
2040
+ const H = k.currentTarget.closest("[tabindex]");
2041
+ H && document.activeElement !== H && H.focus({ preventScroll: !0 }), k.currentTarget.setPointerCapture(k.pointerId);
2042
+ const x = M || k.button === 1 ? Re : r, C = qe(k, O.viewport);
2043
+ U.current = C.pressure, y.current = x.begin(C, O) || null;
2020
2044
  }, Z = (k) => {
2021
- const O = V(), q = y.current;
2022
- if (O && r.track?.(Ue(k, O.viewport), O), O && !q && !I && k.buttons === 0 && r.hover?.(Ue(k, O.viewport), O), !(!O || !q?.move))
2045
+ const O = Y(), H = y.current;
2046
+ if (O && r.track?.(qe(k, O.viewport), O), O && !H && !M && k.buttons === 0 && r.hover?.(qe(k, O.viewport), O), !(!O || !H?.move))
2023
2047
  for (const x of k.nativeEvent.getCoalescedEvents?.() ?? [k.nativeEvent]) {
2024
- const C = Ue(x, O.viewport, j.current);
2025
- j.current = C.pressure, q.move(C, O);
2048
+ const C = qe(x, O.viewport, U.current);
2049
+ U.current = C.pressure, H.move(C, O);
2026
2050
  }
2027
2051
  }, Q = (k) => {
2028
- const O = V(), q = y.current;
2029
- y.current = null, O && q && q.end?.(Ue(k, O.viewport, j.current), O);
2052
+ const O = Y(), H = y.current;
2053
+ y.current = null, O && H && H.end?.(qe(k, O.viewport, U.current), O);
2030
2054
  }, fe = R(() => {
2031
2055
  });
2032
2056
  fe.current = (k) => {
2033
2057
  const O = y.current;
2034
2058
  if (!O || k.key !== "Escape" || k.isComposing || k.metaKey || k.ctrlKey || k.altKey || k.shiftKey) return;
2035
2059
  y.current = null;
2036
- const q = V();
2037
- q && O.cancel?.(q), Y.clear(), k.preventDefault(), k.stopPropagation();
2060
+ const H = Y();
2061
+ H && O.cancel?.(H), G.clear(), k.preventDefault(), k.stopPropagation();
2038
2062
  }, J(() => {
2039
2063
  const k = (O) => fe.current(O);
2040
2064
  return window.addEventListener("keydown", k, !0), () => window.removeEventListener("keydown", k, !0);
2041
2065
  }, []);
2042
2066
  const ce = () => {
2043
- const k = V(), O = y.current;
2044
- O && (y.current = null, k && O.cancel?.(k), Y.clear());
2067
+ const k = Y(), O = y.current;
2068
+ O && (y.current = null, k && O.cancel?.(k), G.clear());
2045
2069
  };
2046
- return /* @__PURE__ */ M("div", { className: "kui-canvas", "data-testid": "kit-canvas", children: [
2070
+ return /* @__PURE__ */ T("div", { className: "kui-canvas", "data-testid": "kit-canvas", children: [
2047
2071
  /* @__PURE__ */ u(
2048
2072
  "canvas",
2049
2073
  {
2050
2074
  ref: w,
2051
2075
  className: "kui-canvas-surface",
2052
- style: { cursor: I ? Re.cursor : r.cursor },
2076
+ style: { cursor: M ? Re.cursor : r.cursor },
2053
2077
  onPointerDown: D,
2054
2078
  onPointerMove: Z,
2055
2079
  onPointerUp: Q,
2056
2080
  onPointerCancel: ce,
2057
2081
  onLostPointerCapture: ce,
2058
2082
  onPointerLeave: () => {
2059
- const k = V();
2083
+ const k = Y();
2060
2084
  k && !y.current && r.leave?.(k);
2061
2085
  },
2062
2086
  onDoubleClick: (k) => {
2063
- const O = V();
2064
- O && r.doubleClick?.(Ue({ ...k, clientX: k.clientX, clientY: k.clientY, pressure: 1 }, O.viewport), O);
2087
+ const O = Y();
2088
+ O && r.doubleClick?.(qe({ ...k, clientX: k.clientX, clientY: k.clientY, pressure: 1 }, O.viewport), O);
2065
2089
  },
2066
2090
  onContextMenu: (k) => k.preventDefault(),
2067
2091
  "data-testid": "kit-canvas-surface"
@@ -2079,8 +2103,8 @@ function Jl(e) {
2079
2103
  return t;
2080
2104
  }
2081
2105
  const Hi = /* @__PURE__ */ new WeakMap();
2082
- function Ui(e) {
2083
- return [e, ...(Hi.get(e) ?? []).flatMap(Ui)];
2106
+ function qi(e) {
2107
+ return [e, ...(Hi.get(e) ?? []).flatMap(qi)];
2084
2108
  }
2085
2109
  function gr(e, t) {
2086
2110
  if (!e || !t) return e ?? t ?? null;
@@ -2091,7 +2115,7 @@ function gr(e, t) {
2091
2115
  } finally {
2092
2116
  r.restore();
2093
2117
  }
2094
- const a = Ui(e).filter((s) => !wt.has(s));
2118
+ const a = qi(e).filter((s) => !wt.has(s));
2095
2119
  for (const s of a) wt.add(s);
2096
2120
  r.save();
2097
2121
  try {
@@ -2107,7 +2131,7 @@ const Ke = "kit:";
2107
2131
  function Ft(e) {
2108
2132
  return e.startsWith(Ke) ? `control:${e.slice(Ke.length)}` : `command:${e}`;
2109
2133
  }
2110
- function qi(e) {
2134
+ function Ui(e) {
2111
2135
  const t = [], n = /* @__PURE__ */ new Set();
2112
2136
  for (const r of e) {
2113
2137
  for (let o = 1; o <= r.path.length; o += 1) {
@@ -2134,7 +2158,7 @@ const ji = [
2134
2158
  function Zl(e) {
2135
2159
  if (!e) return null;
2136
2160
  const t = Object.keys(sn).flatMap((n) => (e[n] ?? []).map((r) => r.id));
2137
- return /* @__PURE__ */ new Set([...qi(e.menus ?? []).map((n) => n.id), ...t, ...ji.map((n) => n.id)]);
2161
+ return /* @__PURE__ */ new Set([...Ui(e.menus ?? []).map((n) => n.id), ...t, ...ji.map((n) => n.id)]);
2138
2162
  }
2139
2163
  function Gi({ commands: e, declaration: t, engineTools: n, agent: r, t: i, phrase: o, config: a }) {
2140
2164
  const s = [], d = /* @__PURE__ */ new Set(), c = (l, p, h, f, g = []) => {
@@ -2143,7 +2167,7 @@ function Gi({ commands: e, declaration: t, engineTools: n, agent: r, t: i, phras
2143
2167
  const w = Se(a, l, g);
2144
2168
  s.push({ id: l, kind: p, label: h, parent: f, hidden: w.hidden, disabled: w.disabled });
2145
2169
  };
2146
- for (const l of qi(t?.menus ?? [])) c(l.id, l.kind, o(l.label), l.parent, l.menu);
2170
+ for (const l of Ui(t?.menus ?? [])) c(l.id, l.kind, o(l.label), l.parent, l.menu);
2147
2171
  for (const l of e) {
2148
2172
  for (let p = 1; p <= l.menu.length; p += 1) {
2149
2173
  const h = p > 1 ? `menu:${l.menu.slice(0, p - 1).join("/")}` : null;
@@ -2157,7 +2181,7 @@ function Gi({ commands: e, declaration: t, engineTools: n, agent: r, t: i, phras
2157
2181
  for (const l of ji) (r || l.id !== "action:agent") && c(l.id, "action", i(l.label), null);
2158
2182
  return s;
2159
2183
  }
2160
- const Ql = () => !1, Wt = Ot(null), ec = Ni(nn, null, () => {
2184
+ const Ql = () => !1, Wt = Ot(null), ec = Pi(nn, null, () => {
2161
2185
  });
2162
2186
  function be() {
2163
2187
  const e = Le(Wt), t = e?.store ?? ec, n = He(t.subscribe, t.get);
@@ -2241,7 +2265,7 @@ function zt({ place: e, as: t }) {
2241
2265
  const n = be();
2242
2266
  return /* @__PURE__ */ u(Ce, { children: n.buttons(e).map((r) => {
2243
2267
  const i = il(r, n.locale), o = rc(r.icon), a = `host:${r.id}`;
2244
- return t === "menu" ? /* @__PURE__ */ u(le, { icon: o, label: i, shortcut: r.shortcut, disabled: r.disabled, onSelect: () => n.press(r.id), uiId: a }, r.id) : t === "ribbon" ? /* @__PURE__ */ u(we, { icon: o, label: i, pressed: r.pressed, disabled: r.disabled, onClick: () => n.press(r.id), "data-kit-ui-id": a }, r.id) : /* @__PURE__ */ M(me, { variant: "ghost", "aria-pressed": r.pressed, disabled: r.disabled, onClick: () => n.press(r.id), "data-kit-ui-id": a, children: [
2268
+ return t === "menu" ? /* @__PURE__ */ u(le, { icon: o, label: i, shortcut: r.shortcut, disabled: r.disabled, onSelect: () => n.press(r.id), uiId: a }, r.id) : t === "ribbon" ? /* @__PURE__ */ u(we, { icon: o, label: i, pressed: r.pressed, disabled: r.disabled, onClick: () => n.press(r.id), "data-kit-ui-id": a }, r.id) : /* @__PURE__ */ T(me, { variant: "ghost", "aria-pressed": r.pressed, disabled: r.disabled, onClick: () => n.press(r.id), "data-kit-ui-id": a, children: [
2245
2269
  o ? /* @__PURE__ */ u(o, { size: 15, strokeWidth: $e, "aria-hidden": "true" }) : null,
2246
2270
  i
2247
2271
  ] }, r.id);
@@ -2306,20 +2330,20 @@ function ic(e, t) {
2306
2330
  function oc({ catalog: e, personal: t, labels: n, onSave: r, onClose: i }) {
2307
2331
  const [o, a] = B([...t]), [s, d] = B(""), c = pe(() => ic(e, s), [e, s]), l = (h) => a((f) => f.includes(h) ? f.filter((g) => g !== h) : [...f, h]), p = (h, f) => {
2308
2332
  const g = o.includes(h.element.id);
2309
- return /* @__PURE__ */ M("li", { children: [
2310
- /* @__PURE__ */ M("label", { className: "kui-customize-row", children: [
2333
+ return /* @__PURE__ */ T("li", { children: [
2334
+ /* @__PURE__ */ T("label", { className: "kui-customize-row", children: [
2311
2335
  /* @__PURE__ */ u("input", { type: "checkbox", checked: !g, disabled: f, onChange: () => l(h.element.id), "data-element": h.element.id }),
2312
2336
  /* @__PURE__ */ u("span", { children: h.element.label })
2313
2337
  ] }),
2314
2338
  h.children.length ? /* @__PURE__ */ u("ul", { children: h.children.map((w) => p(w, f || g)) }) : null
2315
2339
  ] }, h.element.id);
2316
2340
  };
2317
- return /* @__PURE__ */ M(
2341
+ return /* @__PURE__ */ T(
2318
2342
  st,
2319
2343
  {
2320
2344
  title: n.title,
2321
2345
  onClose: i,
2322
- actions: /* @__PURE__ */ M(Ce, { children: [
2346
+ actions: /* @__PURE__ */ T(Ce, { children: [
2323
2347
  /* @__PURE__ */ u(me, { variant: "ghost", onClick: () => a([]), "data-action": "restore", children: n.restore }),
2324
2348
  /* @__PURE__ */ u("span", { style: { flex: 1 } }),
2325
2349
  /* @__PURE__ */ u(me, { variant: "ghost", onClick: i, children: n.cancel }),
@@ -2333,8 +2357,8 @@ function oc({ catalog: e, personal: t, labels: n, onSave: r, onClose: i }) {
2333
2357
  );
2334
2358
  }
2335
2359
  function ac({ message: e, title: t, retryLabel: n, onRetry: r }) {
2336
- return /* @__PURE__ */ M("div", { className: "kui-render-failure", role: "alert", "data-testid": "kit-render-failure", children: [
2337
- /* @__PURE__ */ M("div", { children: [
2360
+ return /* @__PURE__ */ T("div", { className: "kui-render-failure", role: "alert", "data-testid": "kit-render-failure", children: [
2361
+ /* @__PURE__ */ T("div", { children: [
2338
2362
  /* @__PURE__ */ u("strong", { children: t }),
2339
2363
  /* @__PURE__ */ u("div", { className: "kui-muted", children: e })
2340
2364
  ] }),
@@ -2846,93 +2870,93 @@ const yr = { "edit.undo": "undo", "edit.redo": "redo" };
2846
2870
  function wu(e, t, n, r, i = (s) => s, o, a = {}) {
2847
2871
  const s = R(a.report);
2848
2872
  s.current = a.report;
2849
- const d = H((T, K) => s.current ? s.current(T, K) : pt("error", T, Dn(K)), []), { doc: c, change: l } = e, [p, h] = B([]), [f, g] = B(/* @__PURE__ */ new Set()), [w, b] = B(null), m = R(o);
2873
+ const d = K((I, _) => s.current ? s.current(I, _) : pt("error", I, Dn(_)), []), { doc: c, change: l } = e, [p, h] = B([]), [f, g] = B(/* @__PURE__ */ new Set()), [w, b] = B(null), m = R(o);
2850
2874
  m.current = o;
2851
- const y = H(
2852
- (T, K = {}) => b(T ? { command: T, values: { ...m.current?.(T), ...K } } : null),
2875
+ const y = K(
2876
+ (I, _ = {}) => b(I ? { command: I, values: { ...m.current?.(I), ..._ } } : null),
2853
2877
  []
2854
- ), I = R(e);
2855
- I.current = e;
2856
- const N = He(t.ui.subscribe, t.ui.get), E = a.history ?? null, [, Y] = B(0);
2857
- J(() => E?.subscribe(() => Y((T) => T + 1)), [E]);
2858
- const U = R(E);
2859
- U.current = E;
2860
- const V = t.readOnly === !0, j = e.comments ?? Xi, D = H((T) => V && It(T, j), [j, V]);
2878
+ ), M = R(e);
2879
+ M.current = e;
2880
+ const P = He(t.ui.subscribe, t.ui.get), E = a.history ?? null, [, G] = B(0);
2881
+ J(() => E?.subscribe(() => G((I) => I + 1)), [E]);
2882
+ const q = R(E);
2883
+ q.current = E;
2884
+ const Y = t.readOnly === !0, U = e.comments ?? Xi, D = K((I) => Y && It(I, U), [U, Y]);
2861
2885
  J(() => {
2862
2886
  c && c.commands().then(h);
2863
2887
  }, [c]), J(() => {
2864
2888
  if (!c) return;
2865
- let T = !1;
2866
- return c.disabledCommands().catch(() => []).then((K) => {
2867
- T || g(new Set(K));
2889
+ let I = !1;
2890
+ return c.disabledCommands().catch(() => []).then((_) => {
2891
+ I || g(new Set(_));
2868
2892
  }), () => {
2869
- T = !0;
2893
+ I = !0;
2870
2894
  };
2871
2895
  }, [l.revision, c]);
2872
- const Z = H(async (T, K = {}) => {
2873
- const ne = I.current.doc;
2896
+ const Z = K(async (I, _ = {}) => {
2897
+ const ne = M.current.doc;
2874
2898
  if (!ne) return null;
2875
- const P = fe.current.get(T);
2876
- if (P?.mutates && Se(t.ui.get(), `command:${T}`, P.menu).denied || P && D(P)) return null;
2899
+ const N = fe.current.get(I);
2900
+ if (N?.mutates && Se(t.ui.get(), `command:${I}`, N.menu).denied || N && D(N)) return null;
2877
2901
  try {
2878
- return JSON.parse(await ne.execute(T, K));
2902
+ return JSON.parse(await ne.execute(I, _));
2879
2903
  } catch {
2880
2904
  return null;
2881
2905
  }
2882
- }, [t, D]), Q = pe(() => new Map(p.map((T) => [T.id, T])), [p]), fe = R(Q);
2906
+ }, [t, D]), Q = pe(() => new Map(p.map((I) => [I.id, I])), [p]), fe = R(Q);
2883
2907
  fe.current = Q;
2884
- const ce = H(
2885
- async (T, K) => {
2886
- const ne = Q.get(T), P = U.current, G = P ? yr[T] : void 0;
2887
- if (P && G) {
2888
- if (Se(t.ui.get(), `command:${T}`, ne?.menu).denied || Se(t.ui.get(), `action:${G}`).denied) return null;
2908
+ const ce = K(
2909
+ async (I, _) => {
2910
+ const ne = Q.get(I), N = q.current, j = N ? yr[I] : void 0;
2911
+ if (N && j) {
2912
+ if (Se(t.ui.get(), `command:${I}`, ne?.menu).denied || Se(t.ui.get(), `action:${j}`).denied) return null;
2889
2913
  try {
2890
- return JSON.stringify({ done: await P[G]() !== !1 });
2914
+ return JSON.stringify({ done: await N[j]() !== !1 });
2891
2915
  } catch (ue) {
2892
2916
  return d(n("commandFailed"), ue), null;
2893
2917
  }
2894
2918
  }
2895
- if (!K && ne && Pt(ne) && !Se(t.ui.get(), `command:${T}`, ne.menu).denied && !D(ne))
2919
+ if (!_ && ne && Nt(ne) && !Se(t.ui.get(), `command:${I}`, ne.menu).denied && !D(ne))
2896
2920
  return y(ne), null;
2897
2921
  try {
2898
- return await I.current.run(T, K ?? {});
2922
+ return await M.current.run(I, _ ?? {});
2899
2923
  } catch (ue) {
2900
- return V && sc(ue) ? pt("info", n(j.size ? "commentOnlyRefused" : "viewOnlyRefused")) : d(n("commandFailed"), ue), null;
2924
+ return Y && sc(ue) ? pt("info", n(U.size ? "commentOnlyRefused" : "viewOnlyRefused")) : d(n("commandFailed"), ue), null;
2901
2925
  }
2902
2926
  },
2903
- [Q, j, t, V, D, d, y, n]
2904
- ), k = E ? E.canUndo() : c?.info?.canUndo ?? !1, O = E ? E.canRedo() : c?.info?.canRedo ?? !1, q = H(
2905
- (T, K) => {
2906
- const ne = Q.get(T);
2907
- if (!ne || Se(N, `command:${T}`, ne.menu).denied) return !1;
2908
- const P = E ? yr[T] : void 0;
2909
- if (P) return P === "undo" ? k : O;
2910
- if (K.has(T) || D(ne)) return !1;
2911
- const G = V ? Pi(T, j) : null;
2912
- return G === null || (G === "undo" ? k : O);
2927
+ [Q, U, t, Y, D, d, y, n]
2928
+ ), k = E ? E.canUndo() : c?.info?.canUndo ?? !1, O = E ? E.canRedo() : c?.info?.canRedo ?? !1, H = K(
2929
+ (I, _) => {
2930
+ const ne = Q.get(I);
2931
+ if (!ne || Se(P, `command:${I}`, ne.menu).denied) return !1;
2932
+ const N = E ? yr[I] : void 0;
2933
+ if (N) return N === "undo" ? k : O;
2934
+ if (_.has(I) || D(ne)) return !1;
2935
+ const j = Y ? Ni(I, U) : null;
2936
+ return j === null || (j === "undo" ? k : O);
2913
2937
  },
2914
- [Q, O, k, j, E, V, D, N]
2915
- ), x = H((T) => q(T, f), [f, q]), C = H(
2916
- async (T) => {
2917
- const K = I.current.doc;
2918
- if (!K) return !1;
2919
- const ne = await I.current.disabledCommands().catch(() => null);
2920
- return ne != null && I.current.doc === K && q(T, new Set(ne));
2938
+ [Q, O, k, U, E, Y, D, P]
2939
+ ), x = K((I) => H(I, f), [f, H]), C = K(
2940
+ async (I) => {
2941
+ const _ = M.current.doc;
2942
+ if (!_) return !1;
2943
+ const ne = await M.current.disabledCommands().catch(() => null);
2944
+ return ne != null && M.current.doc === _ && H(I, new Set(ne));
2921
2945
  },
2922
- [q]
2923
- ), W = H(async () => {
2946
+ [H]
2947
+ ), W = K(async () => {
2924
2948
  try {
2925
- await I.current.save(), pt("success", n("saved"));
2926
- } catch (T) {
2927
- d(n("saveFailed"), T);
2949
+ await M.current.save(), pt("success", n("saved"));
2950
+ } catch (I) {
2951
+ d(n("saveFailed"), I);
2928
2952
  }
2929
- }, [d, n]), _ = H(
2930
- (T, K) => {
2931
- Se(t.ui.get(), `command:${T}`, Q.get(T)?.menu).denied ? ce(T, K ?? {}) : y(Q.get(T) ?? null, K);
2953
+ }, [d, n]), V = K(
2954
+ (I, _) => {
2955
+ Se(t.ui.get(), `command:${I}`, Q.get(I)?.menu).denied ? ce(I, _ ?? {}) : y(Q.get(I) ?? null, _);
2932
2956
  },
2933
2957
  [Q, t, ce, y]
2934
2958
  );
2935
- return { session: e, host: t, t: n, phrase: i, testId: r, commands: p, byId: Q, enabled: x, enabledNow: C, run: ce, ask: _, query: Z, save: W, report: d, dialog: w, setDialog: y, comments: j, canUndo: k, canRedo: O };
2959
+ return { session: e, host: t, t: n, phrase: i, testId: r, commands: p, byId: Q, enabled: x, enabledNow: C, run: ce, ask: V, query: Z, save: W, report: d, dialog: w, setDialog: y, comments: U, canUndo: k, canRedo: O };
2936
2960
  }
2937
2961
  const Ln = Ot(null);
2938
2962
  function bu({ editor: e, tools: t = null, children: n }) {
@@ -2994,7 +3018,7 @@ function lc({ command: e, params: t, ask: n, onRun: r, ...i }) {
2994
3018
  label: i.label ?? c(h?.title ?? e),
2995
3019
  disabled: i.disabled || !a(e),
2996
3020
  onClick: () => {
2997
- n ? o.ask(e) : r && t === void 0 && !(h && Pt(h)) ? r(e) : o.run(e, t);
3021
+ n ? o.ask(e) : r && t === void 0 && !(h && Nt(h)) ? r(e) : o.run(e, t);
2998
3022
  },
2999
3023
  onContextMenu: p ?? i.onContextMenu,
3000
3024
  "data-testid": `${d}-cmd-${e}`,
@@ -3025,7 +3049,7 @@ function xe({ icon: e, label: t, size: n = "small", children: r, disabled: i, sw
3025
3049
  return /* @__PURE__ */ u(
3026
3050
  lt,
3027
3051
  {
3028
- trigger: ({ toggle: h, open: f }) => /* @__PURE__ */ M("span", { style: { display: "inline-flex", alignItems: "center" }, "data-primary": s || void 0, children: [
3052
+ trigger: ({ toggle: h, open: f }) => /* @__PURE__ */ T("span", { style: { display: "inline-flex", alignItems: "center" }, "data-primary": s || void 0, children: [
3029
3053
  /* @__PURE__ */ u(we, { icon: e, label: t, size: p, disabled: i, pressed: f, swatch: o, onClick: h, "data-testid": a, primary: s, lineLabel: d }),
3030
3054
  p !== "large" ? /* @__PURE__ */ u(Ii, { size: 11, strokeWidth: $e, "aria-hidden": "true", style: { marginLeft: -4, opacity: 0.6 }, onClick: h }) : null
3031
3055
  ] }),
@@ -3056,7 +3080,7 @@ function cc({
3056
3080
  disabled: !l(e) || !!b?.disabled,
3057
3081
  checked: a,
3058
3082
  onSelect: () => {
3059
- i ? c.ask(e) : d && t === void 0 && !(m && Pt(m)) ? d(e) : c.run(e, t);
3083
+ i ? c.ask(e) : d && t === void 0 && !(m && Nt(m)) ? d(e) : c.run(e, t);
3060
3084
  },
3061
3085
  testId: `${h}-cmd-${e}`,
3062
3086
  uiId: `command:${e}`
@@ -3120,12 +3144,12 @@ function Cu({
3120
3144
  decorateUnder: l,
3121
3145
  children: p
3122
3146
  }) {
3123
- const h = te(), f = Xe(), g = R(null), { doc: w, change: b, failure: m, repaints: y } = h.session, [I, N] = B(null), E = He(y.subscribe, y.get), { t: Y } = h, U = f?.decorate ?? null, V = pe(() => gr(gr(l, U), c), [c, l, U]);
3124
- return /* @__PURE__ */ M("div", { className: "kui-canvas-region", "data-testid": s ?? `${h.testId}-canvas-region`, children: [
3125
- m ? /* @__PURE__ */ M("div", { className: "kui-message", role: "alert", children: [
3126
- /* @__PURE__ */ u("strong", { children: Y("openFailed") }),
3147
+ const h = te(), f = Xe(), g = R(null), { doc: w, change: b, failure: m, repaints: y } = h.session, [M, P] = B(null), E = He(y.subscribe, y.get), { t: G } = h, q = f?.decorate ?? null, Y = pe(() => gr(gr(l, q), c), [c, l, q]);
3148
+ return /* @__PURE__ */ T("div", { className: "kui-canvas-region", "data-testid": s ?? `${h.testId}-canvas-region`, children: [
3149
+ m ? /* @__PURE__ */ T("div", { className: "kui-message", role: "alert", children: [
3150
+ /* @__PURE__ */ u("strong", { children: G("openFailed") }),
3127
3151
  /* @__PURE__ */ u("span", { className: "kui-muted", children: m })
3128
- ] }) : w ? /* @__PURE__ */ M(
3152
+ ] }) : w ? /* @__PURE__ */ T(
3129
3153
  Xl,
3130
3154
  {
3131
3155
  ref: e,
@@ -3134,32 +3158,32 @@ function Cu({
3134
3158
  change: b,
3135
3159
  repaint: E,
3136
3160
  tool: d ?? f?.canvasTool ?? Re,
3137
- decorate: V,
3161
+ decorate: Y,
3138
3162
  spacePans: !f?.wantsText,
3139
3163
  initialArea: n,
3140
3164
  panBounds: r,
3141
3165
  framed: i,
3142
3166
  animated: o,
3143
- onView: (j, D) => {
3144
- f?.viewZoom?.(j.zoom), a?.(j, D);
3167
+ onView: (U, D) => {
3168
+ f?.viewZoom?.(U.zoom), a?.(U, D);
3145
3169
  },
3146
- onRender: (j) => N(j === null ? null : { doc: w, message: Dn(j) }),
3170
+ onRender: (U) => P(U === null ? null : { doc: w, message: Dn(U) }),
3147
3171
  children: [
3148
3172
  p,
3149
- I?.doc === w ? /* @__PURE__ */ u(ac, { message: I.message, title: Y("renderFailed"), retryLabel: Y("retryRender"), onRetry: () => {
3173
+ M?.doc === w ? /* @__PURE__ */ u(ac, { message: M.message, title: G("renderFailed"), retryLabel: G("retryRender"), onRetry: () => {
3150
3174
  e.current?.retryRender();
3151
3175
  } }) : null
3152
3176
  ]
3153
3177
  }
3154
- ) : /* @__PURE__ */ u("div", { className: "kui-message kui-muted", children: Y("opening") }),
3155
- f ? /* @__PURE__ */ u(Dl, { active: f.wantsText, onText: f.typeText, onKey: (j) => f.keyDown(j) }) : null
3178
+ ) : /* @__PURE__ */ u("div", { className: "kui-message kui-muted", children: G("opening") }),
3179
+ f ? /* @__PURE__ */ u(Dl, { active: f.wantsText, onText: f.typeText, onKey: (U) => f.keyDown(U) }) : null
3156
3180
  ] });
3157
3181
  }
3158
3182
  const vr = 1.25, hc = /* @__PURE__ */ new Set(["checkbox", "radio", "button", "submit", "reset", "range", "color", "file", "image"]);
3159
3183
  function kr(e) {
3160
3184
  return e instanceof HTMLInputElement ? !hc.has(e.type) : e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement && !e.classList.contains("kui-text-sink");
3161
3185
  }
3162
- function Nn() {
3186
+ function Pn() {
3163
3187
  const e = te(), t = be(), n = e.host.readOnly === !0, r = n && (e.comments?.size ?? 0) > 0, i = (o, a, s) => {
3164
3188
  const d = t.state(`action:${o}`), c = t.state(`command:${a}`);
3165
3189
  return { hidden: d.hidden || c.hostHidden || n && !r, disabled: !s || d.disabled || c.denied };
@@ -3167,19 +3191,19 @@ function Nn() {
3167
3191
  return { undo: i("undo", "edit.undo", e.canUndo), redo: i("redo", "edit.redo", e.canRedo), readOnly: n, commenting: r };
3168
3192
  }
3169
3193
  function fc({ before: e, mode: t }) {
3170
- const n = te(), r = be(), { session: i, host: o, t: a, testId: s } = n, { dirty: d } = i, c = (g) => r.state(`action:${g}`), { undo: l, redo: p, readOnly: h, commenting: f } = Nn();
3171
- return /* @__PURE__ */ M(Ce, { children: [
3194
+ const n = te(), r = be(), { session: i, host: o, t: a, testId: s } = n, { dirty: d } = i, c = (g) => r.state(`action:${g}`), { undo: l, redo: p, readOnly: h, commenting: f } = Pn();
3195
+ return /* @__PURE__ */ T(Ce, { children: [
3172
3196
  e,
3173
3197
  /* @__PURE__ */ u(zt, { place: "action", as: "action" }),
3174
3198
  h ? /* @__PURE__ */ u("span", { className: "kui-view-only", "data-testid": `${s}-view-only`, "data-comment-only": f ? "true" : void 0, children: a(f ? "commentOnly" : "viewOnly") }) : null,
3175
3199
  l.hidden ? null : /* @__PURE__ */ u(De, { icon: kn, label: a("undo"), disabled: l.disabled, onClick: () => void n.run("edit.undo", {}), "data-testid": `${s}-undo`, "data-kit-ui-id": "action:undo" }),
3176
3200
  p.hidden ? null : /* @__PURE__ */ u(De, { icon: oi, label: a("redo"), disabled: p.disabled, onClick: () => void n.run("edit.redo", {}), "data-testid": `${s}-redo`, "data-kit-ui-id": "action:redo" }),
3177
- o.init.capabilities.includes("agent") && !c("agent").hidden ? /* @__PURE__ */ M(me, { variant: "ghost", disabled: c("agent").disabled, onClick: () => void o.openAgent(), "data-testid": `${s}-ask-agent`, "data-kit-ui-id": "action:agent", children: [
3201
+ o.init.capabilities.includes("agent") && !c("agent").hidden ? /* @__PURE__ */ T(me, { variant: "ghost", disabled: c("agent").disabled, onClick: () => void o.openAgent(), "data-testid": `${s}-ask-agent`, "data-kit-ui-id": "action:agent", children: [
3178
3202
  /* @__PURE__ */ u(Lt, { size: 15, strokeWidth: $e, "aria-hidden": "true" }),
3179
3203
  a("askAgent")
3180
3204
  ] }) : null,
3181
3205
  t,
3182
- c("save").hidden || h ? null : /* @__PURE__ */ M(me, { variant: "primary", disabled: !d || i.saving || c("save").disabled, onClick: () => void n.save(), "data-testid": `${s}-save`, "data-kit-ui-id": "action:save", children: [
3206
+ c("save").hidden || h ? null : /* @__PURE__ */ T(me, { variant: "primary", disabled: !d || i.saving || c("save").disabled, onClick: () => void n.save(), "data-testid": `${s}-save`, "data-kit-ui-id": "action:save", children: [
3183
3207
  /* @__PURE__ */ u(ai, { size: 15, strokeWidth: $e, "aria-hidden": "true" }),
3184
3208
  a("save")
3185
3209
  ] }),
@@ -3199,38 +3223,38 @@ function mc({ x: e, y: t, label: n, testId: r, onHide: i, onClose: o }) {
3199
3223
  }, [o]), /* @__PURE__ */ u("div", { className: "kui-dialog-backdrop kui-hide-menu-backdrop", onPointerDown: o, children: /* @__PURE__ */ u("div", { ref: a, className: "kui-popover kui-hide-menu", role: "menu", style: s ?? { left: e, top: t, visibility: "hidden" }, onPointerDown: (c) => c.stopPropagation(), children: /* @__PURE__ */ u(le, { label: n, onSelect: i, testId: r }) }) });
3200
3224
  }
3201
3225
  function pc({ top: e, status: t, statusEnd: n, onStatusClick: r, canvas: i, zoom: o, onKeyDown: a, statusBar: s = !0, hiddenCommands: d, fileChangedBar: c = !0, frame: l, children: p }) {
3202
- const h = te(), f = Xe(), { session: g, t: w, testId: b } = h, { dirty: m } = g, y = Le(Wt), I = be(), [N, E] = B(null), [Y, U] = B(null), V = H(() => U(null), []), j = R(async () => {
3226
+ const h = te(), f = Xe(), { session: g, t: w, testId: b } = h, { dirty: m } = g, y = Le(Wt), M = be(), [P, E] = B(null), [G, q] = B(null), Y = K(() => q(null), []), U = R(async () => {
3203
3227
  });
3204
- j.current = async (x) => {
3228
+ U.current = async (x) => {
3205
3229
  try {
3206
- await I.store.setPersonal(x);
3230
+ await M.store.setPersonal(x);
3207
3231
  } catch (C) {
3208
3232
  ln(h, w("customizeFailed"), C);
3209
3233
  }
3210
3234
  };
3211
3235
  const D = R(() => []);
3212
- D.current = () => Gi({ commands: h.commands, declaration: h.host.declaration, engineTools: f?.tools ?? [], agent: h.host.init.capabilities.includes("agent"), t: w, phrase: h.phrase, config: { ...I.store.get(), personal: [] } });
3213
- const { store: Z } = I, Q = Z.customizable && h.host.declaration !== null, fe = pe(
3236
+ D.current = () => Gi({ commands: h.commands, declaration: h.host.declaration, engineTools: f?.tools ?? [], agent: h.host.init.capabilities.includes("agent"), t: w, phrase: h.phrase, config: { ...M.store.get(), personal: [] } });
3237
+ const { store: Z } = M, Q = Z.customizable && h.host.declaration !== null, fe = pe(
3214
3238
  () => y && Q ? {
3215
3239
  ...y,
3216
- offerHide: (x, C, W) => U({ id: x, x: C, y: W }),
3240
+ offerHide: (x, C, W) => q({ id: x, x: C, y: W }),
3217
3241
  openCustomize: () => E(D.current()),
3218
- hide: (x) => void j.current([...Z.get().personal, x])
3242
+ hide: (x) => void U.current([...Z.get().personal, x])
3219
3243
  } : y,
3220
3244
  [Q, y, Z]
3221
3245
  ), ce = (x) => x.currentTarget.ownerDocument.querySelector(".kui-dialog-backdrop") != null || x.target instanceof Element && x.target.closest(".kui-dialog") != null, k = (x) => {
3222
3246
  !l || x.nativeEvent.isComposing || ce(x) || l.keyDown(x) && (x.preventDefault(), x.stopPropagation());
3223
3247
  }, O = (x) => {
3224
- q(x);
3248
+ H(x);
3225
3249
  const C = !x.metaKey && !x.ctrlKey && !x.altKey && !x.shiftKey;
3226
3250
  l && C && x.key === "Escape" && !x.defaultPrevented && !x.nativeEvent.isComposing && !ce(x) && !kr(x.target) && l.escape() && x.preventDefault();
3227
- }, q = (x) => {
3251
+ }, H = (x) => {
3228
3252
  if (ce(x)) return;
3229
3253
  const C = x.target, W = kr(C);
3230
3254
  if (W && !((x.metaKey || x.ctrlKey) && !x.altKey && x.key.toLowerCase() === "s")) return;
3231
- const _ = C instanceof HTMLTextAreaElement;
3232
- if (_ && x.defaultPrevented || !x.metaKey && !x.ctrlKey && !x.altKey && !x.shiftKey && (x.key === " " || x.key === "Enter") && C instanceof Element && C.matches('button, [role="menuitem"], input[type="checkbox"], input[type="radio"]')) return;
3233
- if (!W && !_ && f?.keyDown(x)) {
3255
+ const V = C instanceof HTMLTextAreaElement;
3256
+ if (V && x.defaultPrevented || !x.metaKey && !x.ctrlKey && !x.altKey && !x.shiftKey && (x.key === " " || x.key === "Enter") && C instanceof Element && C.matches('button, [role="menuitem"], input[type="checkbox"], input[type="radio"]')) return;
3257
+ if (!W && !V && f?.keyDown(x)) {
3234
3258
  x.preventDefault();
3235
3259
  return;
3236
3260
  }
@@ -3238,35 +3262,35 @@ function pc({ top: e, status: t, statusEnd: n, onStatusClick: r, canvas: i, zoom
3238
3262
  x.preventDefault();
3239
3263
  return;
3240
3264
  }
3241
- const K = I.config.add.find((ye) => ye.shortcut && !ye.disabled && Hr(ye.shortcut, x, Nt()));
3242
- if (K) {
3243
- x.preventDefault(), I.press(K.id);
3265
+ const _ = M.config.add.find((ye) => ye.shortcut && !ye.disabled && Hr(ye.shortcut, x, Pt()));
3266
+ if (_) {
3267
+ x.preventDefault(), M.press(_.id);
3244
3268
  return;
3245
3269
  }
3246
- const ne = x.metaKey || x.ctrlKey, P = x.key.toLowerCase();
3247
- if (ne && P === "s") {
3248
- x.preventDefault(), !I.state("action:save").denied && !h.host.readOnly && h.save();
3270
+ const ne = x.metaKey || x.ctrlKey, N = x.key.toLowerCase();
3271
+ if (ne && N === "s") {
3272
+ x.preventDefault(), !M.state("action:save").denied && !h.host.readOnly && h.save();
3249
3273
  return;
3250
3274
  }
3251
- if (i?.current && ne && (P === "0" || P === "=" || P === "+" || P === "-")) {
3252
- x.preventDefault(), P === "0" ? i.current.fit() : i.current.zoomBy(P === "-" ? 1 / vr : vr);
3275
+ if (i?.current && ne && (N === "0" || N === "=" || N === "+" || N === "-")) {
3276
+ x.preventDefault(), N === "0" ? i.current.fit() : i.current.zoomBy(N === "-" ? 1 / vr : vr);
3253
3277
  return;
3254
3278
  }
3255
- const G = Fl(d ? h.commands.filter((ye) => !d(ye.id)) : h.commands, x);
3256
- if (G && h.enabled(G.id)) {
3257
- x.preventDefault(), h.run(G.id, {});
3279
+ const j = Fl(d ? h.commands.filter((ye) => !d(ye.id)) : h.commands, x);
3280
+ if (j && h.enabled(j.id)) {
3281
+ x.preventDefault(), h.run(j.id, {});
3258
3282
  return;
3259
3283
  }
3260
- if (G && !ne && !(x.key.length === 1 && f?.toolForKey(x.key, x.shiftKey))) {
3284
+ if (j && !ne && !(x.key.length === 1 && f?.toolForKey(x.key, x.shiftKey))) {
3261
3285
  x.preventDefault();
3262
- const ye = G.id;
3286
+ const ye = j.id;
3263
3287
  h.enabledNow(ye).then((Ie) => Ie ? h.run(ye, {}) : void 0);
3264
3288
  return;
3265
3289
  }
3266
- const ue = !ne && !x.altKey && x.key.length === 1 && !_ ? f?.toolForKey(x.key, x.shiftKey) : null;
3267
- ue && !I.state(`tool:${ue}`).denied && (x.preventDefault(), f?.select(ue));
3290
+ const ue = !ne && !x.altKey && x.key.length === 1 && !V ? f?.toolForKey(x.key, x.shiftKey) : null;
3291
+ ue && !M.state(`tool:${ue}`).denied && (x.preventDefault(), f?.select(ue));
3268
3292
  };
3269
- return /* @__PURE__ */ u(Yi, { value: fe, children: /* @__PURE__ */ M(
3293
+ return /* @__PURE__ */ u(Yi, { value: fe, children: /* @__PURE__ */ T(
3270
3294
  "div",
3271
3295
  {
3272
3296
  ref: l?.ref,
@@ -3280,16 +3304,16 @@ function pc({ top: e, status: t, statusEnd: n, onStatusClick: r, canvas: i, zoom
3280
3304
  tabIndex: -1,
3281
3305
  children: [
3282
3306
  e,
3283
- c && g.conflict && g.doc ? /* @__PURE__ */ M("div", { className: "kui-file-changed", role: "alert", "data-testid": `${b}-file-changed`, children: [
3307
+ c && g.conflict && g.doc ? /* @__PURE__ */ T("div", { className: "kui-file-changed", role: "alert", "data-testid": `${b}-file-changed`, children: [
3284
3308
  /* @__PURE__ */ u("span", { children: w("fileChanged") }),
3285
3309
  /* @__PURE__ */ u(me, { variant: "ghost", size: "sm", onClick: () => void g.keepMine().catch((x) => ln(h, w("saveFailed"), x)), "data-testid": `${b}-keep-mine`, children: w("keepMine") }),
3286
3310
  /* @__PURE__ */ u(me, { variant: "primary", size: "sm", onClick: () => g.reopen(), "data-testid": `${b}-reload`, children: w("reloadFile") })
3287
3311
  ] }) : null,
3288
3312
  p,
3289
- s ? /* @__PURE__ */ M($o, { onClick: r ? (x) => !(x.target instanceof Element && x.target.closest('button, input, select, [role="menuitem"]')) && r() : void 0, children: [
3313
+ s ? /* @__PURE__ */ T($o, { onClick: r ? (x) => !(x.target instanceof Element && x.target.closest('button, input, select, [role="menuitem"]')) && r() : void 0, children: [
3290
3314
  t,
3291
3315
  m ? /* @__PURE__ */ u("span", { "data-testid": `${b}-unsaved`, children: w("unsaved") }) : null,
3292
- g.editedBy?.by === "agent" ? /* @__PURE__ */ M("span", { className: "kui-agent-edited", "data-testid": `${b}-agent-edited`, children: [
3316
+ g.editedBy?.by === "agent" ? /* @__PURE__ */ T("span", { className: "kui-agent-edited", "data-testid": `${b}-agent-edited`, children: [
3293
3317
  /* @__PURE__ */ u(Lt, { size: 12, strokeWidth: $e, "aria-hidden": "true" }),
3294
3318
  w("agentEdited")
3295
3319
  ] }) : g.editedBy?.by === "system" ? (
@@ -3315,29 +3339,29 @@ function pc({ top: e, status: t, statusEnd: n, onStatusClick: r, canvas: i, zoom
3315
3339
  },
3316
3340
  h.dialog.command.id
3317
3341
  ) : null,
3318
- N ? /* @__PURE__ */ u(
3342
+ P ? /* @__PURE__ */ u(
3319
3343
  oc,
3320
3344
  {
3321
- catalog: N,
3322
- personal: I.config.personal,
3345
+ catalog: P,
3346
+ personal: M.config.personal,
3323
3347
  labels: { title: w("customizeTitle"), search: w("customizeSearch"), restore: w("customizeRestore"), cancel: w("cancel"), save: w("customizeSave") },
3324
3348
  onSave: (x) => {
3325
- E(null), j.current(x);
3349
+ E(null), U.current(x);
3326
3350
  },
3327
3351
  onClose: () => E(null)
3328
3352
  }
3329
3353
  ) : null,
3330
- Y ? /* @__PURE__ */ u(
3354
+ G ? /* @__PURE__ */ u(
3331
3355
  mc,
3332
3356
  {
3333
- x: Y.x,
3334
- y: Y.y,
3357
+ x: G.x,
3358
+ y: G.y,
3335
3359
  label: w("hideElement"),
3336
3360
  testId: `${b}-hide-element`,
3337
3361
  onHide: () => {
3338
- U(null), j.current([...I.store.get().personal, Y.id]);
3362
+ q(null), U.current([...M.store.get().personal, G.id]);
3339
3363
  },
3340
- onClose: V
3364
+ onClose: Y
3341
3365
  }
3342
3366
  ) : null,
3343
3367
  /* @__PURE__ */ u(To, {})
@@ -3362,11 +3386,11 @@ function wc({ label: e, path: t, children: n, uiId: r, testId: i }) {
3362
3386
  m && p({ left: m.right - 2, top: m.top - 4, maxHeight: Math.max(0, window.innerHeight - 16) });
3363
3387
  }, g = () => {
3364
3388
  c.current?.contains(document.activeElement) && d.current?.focus(), p(null);
3365
- }, w = H(() => {
3389
+ }, w = K(() => {
3366
3390
  const m = s.current?.getBoundingClientRect(), y = c.current;
3367
3391
  if (!m || !y) return;
3368
- const I = Math.max(0, window.innerHeight - 16), N = Math.min(y.scrollHeight, I), E = y.offsetWidth, Y = m.right - 2, U = Y + E <= window.innerWidth - 4 ? Y : m.left + 2 - E >= 4 ? m.left + 2 - E : Y, V = Math.max(4, Math.min(U, window.innerWidth - E - 4)), j = Math.max(8, Math.min(m.top - 4, window.innerHeight - 8 - N));
3369
- p((D) => !D || D.left === V && D.top === j && D.maxHeight === I ? D : { left: V, top: j, maxHeight: I });
3392
+ const M = Math.max(0, window.innerHeight - 16), P = Math.min(y.scrollHeight, M), E = y.offsetWidth, G = m.right - 2, q = G + E <= window.innerWidth - 4 ? G : m.left + 2 - E >= 4 ? m.left + 2 - E : G, Y = Math.max(4, Math.min(q, window.innerWidth - E - 4)), U = Math.max(8, Math.min(m.top - 4, window.innerHeight - 8 - P));
3393
+ p((D) => !D || D.left === Y && D.top === U && D.maxHeight === M ? D : { left: Y, top: U, maxHeight: M });
3370
3394
  }, []), b = l != null;
3371
3395
  return Te(() => {
3372
3396
  if (!b) return;
@@ -3375,12 +3399,12 @@ function wc({ label: e, path: t, children: n, uiId: r, testId: i }) {
3375
3399
  if (!m || typeof ResizeObserver > "u") return;
3376
3400
  const y = new ResizeObserver(() => w());
3377
3401
  y.observe(m);
3378
- for (const I of m.children) y.observe(I);
3402
+ for (const M of m.children) y.observe(M);
3379
3403
  return () => y.disconnect();
3380
3404
  }, [b, w]), Te(() => {
3381
3405
  !l || !h.current || !c.current || (h.current = !1, c.current.querySelector('[role^="menuitem"]:not(:disabled)')?.focus());
3382
- }, [l]), /* @__PURE__ */ M("div", { ref: s, className: "kui-submenu", onPointerEnter: f, onPointerLeave: g, children: [
3383
- /* @__PURE__ */ M(
3406
+ }, [l]), /* @__PURE__ */ T("div", { ref: s, className: "kui-submenu", onPointerEnter: f, onPointerLeave: g, children: [
3407
+ /* @__PURE__ */ T(
3384
3408
  "div",
3385
3409
  {
3386
3410
  ref: d,
@@ -3401,7 +3425,7 @@ function wc({ label: e, path: t, children: n, uiId: r, testId: i }) {
3401
3425
  ]
3402
3426
  }
3403
3427
  ),
3404
- l ? /* @__PURE__ */ M(
3428
+ l ? /* @__PURE__ */ T(
3405
3429
  "div",
3406
3430
  {
3407
3431
  ref: c,
@@ -3444,7 +3468,7 @@ function vc({ tools: e, shown: t, active: n, onSelect: r, rail: i, pressMs: o })
3444
3468
  return window.addEventListener("pointerdown", b, !0), () => window.removeEventListener("pointerdown", b, !0);
3445
3469
  }, [c]);
3446
3470
  const w = t.shortcut ? `${t.label} (${t.shortcut})` : t.label;
3447
- return /* @__PURE__ */ M(
3471
+ return /* @__PURE__ */ T(
3448
3472
  "span",
3449
3473
  {
3450
3474
  ref: p,
@@ -3477,8 +3501,8 @@ function vc({ tools: e, shown: t, active: n, onSelect: r, rail: i, pressMs: o })
3477
3501
  "data-kit-ui-id": `tool:${t.id}`
3478
3502
  }
3479
3503
  ),
3480
- c ? /* @__PURE__ */ M("div", { className: "kui-popover kui-tool-flyout", role: "menu", style: { left: c.left, top: c.top }, children: [
3481
- e.map((b) => /* @__PURE__ */ M(
3504
+ c ? /* @__PURE__ */ T("div", { className: "kui-popover kui-tool-flyout", role: "menu", style: { left: c.left, top: c.top }, children: [
3505
+ e.map((b) => /* @__PURE__ */ T(
3482
3506
  "button",
3483
3507
  {
3484
3508
  type: "button",
@@ -3499,7 +3523,7 @@ function vc({ tools: e, shown: t, active: n, onSelect: r, rail: i, pressMs: o })
3499
3523
  },
3500
3524
  b.id
3501
3525
  )),
3502
- d.hide ? /* @__PURE__ */ M(
3526
+ d.hide ? /* @__PURE__ */ T(
3503
3527
  "button",
3504
3528
  {
3505
3529
  type: "button",
@@ -3535,17 +3559,17 @@ function Ic({ tools: e, active: t, onSelect: n, columns: r = 1, onColumns: i, co
3535
3559
  J(() => {
3536
3560
  h != null && p((D) => D.get(h) === t ? D : new Map(D).set(h, t));
3537
3561
  }, [t, h]);
3538
- const [f, g] = B(!1), w = R(null), b = be(), m = e.filter((D) => !b.state(`tool:${D.id}`).hidden), y = b.state(`tool:${t}`).denied ? m.find((D) => !b.state(`tool:${D.id}`).denied)?.id : void 0, I = R(n);
3539
- I.current = n, Te(() => {
3540
- y && I.current(y);
3562
+ const [f, g] = B(!1), w = R(null), b = be(), m = e.filter((D) => !b.state(`tool:${D.id}`).hidden), y = b.state(`tool:${t}`).denied ? m.find((D) => !b.state(`tool:${D.id}`).denied)?.id : void 0, M = R(n);
3563
+ M.current = n, Te(() => {
3564
+ y && M.current(y);
3541
3565
  }, [y]);
3542
- const N = [];
3566
+ const P = [];
3543
3567
  for (const D of m) {
3544
- const Z = N.at(-1);
3545
- Z && D.group != null && Z[0].group === D.group ? Z.push(D) : N.push([D]);
3568
+ const Z = P.at(-1);
3569
+ Z && D.group != null && Z[0].group === D.group ? Z.push(D) : P.push([D]);
3546
3570
  }
3547
3571
  const E = [];
3548
- for (const D of N) {
3572
+ for (const D of P) {
3549
3573
  const Z = E.at(-1);
3550
3574
  Z && Z[0][0].section === D[0].section ? Z.push(D) : E.push([D]);
3551
3575
  }
@@ -3553,33 +3577,33 @@ function Ic({ tools: e, active: t, onSelect: n, columns: r = 1, onColumns: i, co
3553
3577
  if (r !== "auto" || typeof ResizeObserver > "u") return;
3554
3578
  const D = w.current, Z = D?.parentElement;
3555
3579
  if (!D || !Z) return;
3556
- const Q = () => g(xc(N.length, E.length, Z.getBoundingClientRect().bottom - D.getBoundingClientRect().top)), fe = new ResizeObserver(Q);
3580
+ const Q = () => g(xc(P.length, E.length, Z.getBoundingClientRect().bottom - D.getBoundingClientRect().top)), fe = new ResizeObserver(Q);
3557
3581
  return fe.observe(Z), () => fe.disconnect();
3558
- }, [r, N.length, E.length]);
3559
- const Y = r === 2 || r === "auto" && f ? 2 : 1, U = o ? b.state(o) : { hidden: !1, disabled: !1 }, V = (D) => {
3582
+ }, [r, P.length, E.length]);
3583
+ const G = r === 2 || r === "auto" && f ? 2 : 1, q = o ? b.state(o) : { hidden: !1, disabled: !1 }, Y = (D) => {
3560
3584
  b.state(`tool:${D}`).denied || n(D);
3561
- }, j = (D) => {
3585
+ }, U = (D) => {
3562
3586
  const Z = (ce) => !b.state(`tool:${ce.id}`).denied, Q = D[0].group == null || !a ? void 0 : l.get(D[0].group), fe = D.find((ce) => ce.id === t) ?? D.find((ce) => ce.id === Q && Z(ce)) ?? D.find(Z) ?? D[0];
3563
- return /* @__PURE__ */ u(vc, { tools: D, shown: fe, active: t, onSelect: V, rail: w, pressMs: s }, D[0].id);
3587
+ return /* @__PURE__ */ u(vc, { tools: D, shown: fe, active: t, onSelect: Y, rail: w, pressMs: s }, D[0].id);
3564
3588
  };
3565
- return /* @__PURE__ */ M("div", { className: "kui-tool-rail", role: "toolbar", "aria-orientation": "vertical", "data-testid": `${d}-tool-rail`, "data-columns": Y, ref: w, children: [
3566
- i && r !== "auto" && !U.hidden ? /* @__PURE__ */ u(
3589
+ return /* @__PURE__ */ T("div", { className: "kui-tool-rail", role: "toolbar", "aria-orientation": "vertical", "data-testid": `${d}-tool-rail`, "data-columns": G, ref: w, children: [
3590
+ i && r !== "auto" && !q.hidden ? /* @__PURE__ */ u(
3567
3591
  "button",
3568
3592
  {
3569
3593
  type: "button",
3570
3594
  className: "kui-tool-rail-columns",
3571
3595
  "aria-label": c(r === 2 ? "railOneColumn" : "railTwoColumns"),
3572
3596
  title: c(r === 2 ? "railOneColumn" : "railTwoColumns"),
3573
- disabled: U.disabled,
3597
+ disabled: q.disabled,
3574
3598
  onClick: () => i(r === 2 ? 1 : 2),
3575
3599
  "data-testid": `${d}-tool-rail-columns`,
3576
3600
  "data-kit-ui-id": o,
3577
3601
  children: r === 2 ? /* @__PURE__ */ u($s, { size: 12, strokeWidth: $e, "aria-hidden": "true" }) : /* @__PURE__ */ u(Is, { size: 12, strokeWidth: $e, "aria-hidden": "true" })
3578
3602
  }
3579
3603
  ) : null,
3580
- E.map((D, Z) => /* @__PURE__ */ M(Ro, { children: [
3604
+ E.map((D, Z) => /* @__PURE__ */ T(Ro, { children: [
3581
3605
  Z > 0 ? /* @__PURE__ */ u("div", { className: "kui-tool-rail-divider", "aria-hidden": "true" }) : null,
3582
- Y === 2 ? $c(D, 2).map((Q) => /* @__PURE__ */ u("div", { className: "kui-tool-rail-row", children: Q.map(j) }, Q[0][0].id)) : D.map(j)
3606
+ G === 2 ? $c(D, 2).map((Q) => /* @__PURE__ */ u("div", { className: "kui-tool-rail-row", children: Q.map(U) }, Q[0][0].id)) : D.map(U)
3583
3607
  ] }, D[0][0].id))
3584
3608
  ] });
3585
3609
  }
@@ -3593,9 +3617,9 @@ function $u({ id: e, title: t, children: n, defaultOpen: r = !0, actions: i, tes
3593
3617
  const [a, s] = B(r), d = be();
3594
3618
  e && (d.declared, void 0);
3595
3619
  const c = e ? d.state(e) : null;
3596
- return c?.hidden ? null : /* @__PURE__ */ M("section", { className: "kui-panel-section", "data-open": a, "data-testid": o, "data-kit-ui-id": e, children: [
3597
- /* @__PURE__ */ M("div", { className: "kui-panel-section-header", children: [
3598
- /* @__PURE__ */ M("button", { type: "button", className: "kui-panel-section-toggle", "aria-expanded": a, onClick: () => s((l) => !l), children: [
3620
+ return c?.hidden ? null : /* @__PURE__ */ T("section", { className: "kui-panel-section", "data-open": a, "data-testid": o, "data-kit-ui-id": e, children: [
3621
+ /* @__PURE__ */ T("div", { className: "kui-panel-section-header", children: [
3622
+ /* @__PURE__ */ T("button", { type: "button", className: "kui-panel-section-toggle", "aria-expanded": a, onClick: () => s((l) => !l), children: [
3599
3623
  /* @__PURE__ */ u(On, { size: 13, strokeWidth: $e, "aria-hidden": "true", className: "kui-panel-section-chevron" }),
3600
3624
  t
3601
3625
  ] }),
@@ -3612,7 +3636,7 @@ function Iu(e) {
3612
3636
  }
3613
3637
  const Mu = ["png", "jpg", "jpeg", "gif", "webp", "svg", "bmp"];
3614
3638
  function Tu() {
3615
- const e = te(), { host: t, t: n } = e, r = t.init.capabilities.includes("pick-file"), i = H(
3639
+ const e = te(), { host: t, t: n } = e, r = t.init.capabilities.includes("pick-file"), i = K(
3616
3640
  async (o, a) => {
3617
3641
  try {
3618
3642
  const s = await t.pick(o, a);
@@ -3699,7 +3723,7 @@ function Ac() {
3699
3723
  return pe(() => ({ ...e, leases: t }), [e, t]);
3700
3724
  }
3701
3725
  function Eu(e) {
3702
- const { leases: t, acquire: n, release: r } = Ac(), i = e ? eo(t, e)?.holder ?? null : null, o = e ? t.some((d) => d.holder.self && d.scope === e) : !1, a = H((d) => e ? n(e, d) : Promise.resolve({ granted: !0, lease: null }), [n, e]), s = H(() => e ? r(e) : Promise.resolve(), [r, e]);
3726
+ const { leases: t, acquire: n, release: r } = Ac(), i = e ? eo(t, e)?.holder ?? null : null, o = e ? t.some((d) => d.holder.self && d.scope === e) : !1, a = K((d) => e ? n(e, d) : Promise.resolve({ granted: !0, lease: null }), [n, e]), s = K(() => e ? r(e) : Promise.resolve(), [r, e]);
3703
3727
  return { heldBy: i, mine: o, acquire: a, release: s };
3704
3728
  }
3705
3729
  function mt(e, t) {
@@ -3750,11 +3774,11 @@ function Lc(e, t) {
3750
3774
  schema: r.schema ?? null
3751
3775
  }));
3752
3776
  }
3753
- function Nc(e, t, n, r) {
3777
+ function Pc(e, t, n, r) {
3754
3778
  const i = r?.name || "another session";
3755
3779
  return new he(-32e3, `step ${t} (\`${e}\`) is not allowed: ${i} holds the lease on \`${n}\``, { reason: fn, command: e, step: t, scope: n, ...r ? { holder: r } : {} });
3756
3780
  }
3757
- async function Pc(e, t, n, r, i, o) {
3781
+ async function Nc(e, t, n, r, i, o) {
3758
3782
  if (!t) {
3759
3783
  const s = n ? e.list().find((d) => !d.holder.self && d.scope === "*") : void 0;
3760
3784
  if (s) throw o("*", s.holder);
@@ -3775,53 +3799,53 @@ async function Pc(e, t, n, r, i, o) {
3775
3799
  function Ou(e, t, n, r = {}) {
3776
3800
  const i = e.init.document.path, o = e.readOnly === !0, a = o && e.init.document.comments?.canComment === !0, s = t.commentCommands, d = pe(() => ul(s, a), [a, s]), c = kl(e.files, t, i, !0, n, { readOnly: o, canComment: a, replicaMergesFile: r.replicaMergesFile, followFile: r.followFile }), { doc: l, failure: p } = c, h = l?.info.revision ?? null, f = l?.info.dirty ?? !1, g = R(c);
3777
3801
  g.current = c;
3778
- const w = R({ doc: null, map: null, commands: null, loading: null }), b = H((C) => {
3802
+ const w = R({ doc: null, map: null, commands: null, loading: null }), b = K((C) => {
3779
3803
  const W = w.current;
3780
3804
  if (W.doc === C && W.loading) return W.loading;
3781
- const _ = C.commands().then((T) => {
3782
- const K = new Map(T.map((ne) => [ne.id, ne.menu]));
3783
- return w.current.loading === _ && (w.current = { doc: C, map: K, commands: new Map(T.map((ne) => [ne.id, ne])), loading: _ }), K;
3805
+ const V = C.commands().then((I) => {
3806
+ const _ = new Map(I.map((ne) => [ne.id, ne.menu]));
3807
+ return w.current.loading === V && (w.current = { doc: C, map: _, commands: new Map(I.map((ne) => [ne.id, ne])), loading: V }), _;
3784
3808
  });
3785
- return _.catch(() => {
3786
- w.current.loading === _ && (w.current = { doc: null, map: null, commands: null, loading: null });
3787
- }), w.current = { doc: C, map: null, commands: null, loading: _ }, _;
3809
+ return V.catch(() => {
3810
+ w.current.loading === V && (w.current = { doc: null, map: null, commands: null, loading: null });
3811
+ }), w.current = { doc: C, map: null, commands: null, loading: V }, V;
3788
3812
  }, []);
3789
3813
  J(() => {
3790
3814
  l && b(l).catch(() => {
3791
3815
  });
3792
3816
  }, [l, b]);
3793
- const m = H(
3817
+ const m = K(
3794
3818
  (C) => {
3795
3819
  const W = w.current.commands?.get(C);
3796
3820
  return It(W ?? { id: C }, d);
3797
3821
  },
3798
3822
  [d]
3799
- ), y = H(
3800
- async (C, W = {}, _ = null, T = {}) => {
3801
- const K = g.current.doc;
3802
- if (!K) return null;
3803
- const ne = w.current, P = ne.doc === K && ne.map ? ne.map : await b(K);
3804
- if (Se(e.ui.get(), `command:${C}`, P.get(C) ?? []).denied) throw ht(C);
3823
+ ), y = K(
3824
+ async (C, W = {}, V = null, I = {}) => {
3825
+ const _ = g.current.doc;
3826
+ if (!_) return null;
3827
+ const ne = w.current, N = ne.doc === _ && ne.map ? ne.map : await b(_);
3828
+ if (Se(e.ui.get(), `command:${C}`, N.get(C) ?? []).denied) throw ht(C);
3805
3829
  if (o && m(C)) throw mt(C);
3806
3830
  try {
3807
- return await c.run(C, W, _, T);
3808
- } catch (G) {
3809
- throw Fi(G) ? mt(C) : G;
3831
+ return await c.run(C, W, V, I);
3832
+ } catch (j) {
3833
+ throw Fi(j) ? mt(C) : j;
3810
3834
  }
3811
3835
  },
3812
3836
  [m, e, b, o, c.run]
3813
- ), I = r.agentSkipsUnchangedPaint === !0, N = R(r);
3814
- N.current = r;
3815
- const E = pe(() => _i(Vi, e.init.locale), [e]), Y = r.agentLeaseScope != null;
3837
+ ), M = r.agentSkipsUnchangedPaint === !0, P = R(r);
3838
+ P.current = r;
3839
+ const E = pe(() => _i(Vi, e.init.locale), [e]), G = r.agentLeaseScope != null;
3816
3840
  J(() => {
3817
- Y && dn(e);
3818
- }, [e, Y]);
3819
- const U = R(Promise.resolve()), V = R(null), j = R(null), [D, Z] = B(null), Q = H((C, W) => {
3820
- j.current = { edit: C, revision: W }, Z(C);
3841
+ G && dn(e);
3842
+ }, [e, G]);
3843
+ const q = R(Promise.resolve()), Y = R(null), U = R(null), [D, Z] = B(null), Q = K((C, W) => {
3844
+ U.current = { edit: C, revision: W }, Z(C);
3821
3845
  }, []), fe = R(!1), ce = R({ doc: null, version: null }), k = R(null);
3822
3846
  k.current ??= new Cl({
3823
3847
  open: () => g.current.draft.open(),
3824
- merge: (C, W, _, T) => g.current.draft.merge(C, W, _, T),
3848
+ merge: (C, W, V, I) => g.current.draft.merge(C, W, V, I),
3825
3849
  compare: (C, W) => g.current.draft.compare(C, W),
3826
3850
  preview: async (C) => {
3827
3851
  const W = g.current.doc;
@@ -3835,18 +3859,18 @@ function Ou(e, t, n, r = {}) {
3835
3859
  fe.current || (l ? (fe.current = !0, e.opened([...l.info.model ? ["model", "draft", "draft-model", "check"] : ["check"], ...l.info.context ? ["context"] : [], ...l.info.changes ? ["changes"] : [], ...l.info.premises ? ["premises"] : []])) : p && (fe.current = !0, e.failed(new Error(p))));
3836
3860
  }, [l, p, e]), J(() => {
3837
3861
  if (!l) return;
3838
- const C = V.current ?? (j.current?.revision === l.info.revision ? j.current.edit : { by: "person" });
3839
- C.by === "person" && j.current && (j.current = null, Z(null)), e.changed({ dirty: l.info.dirty, revision: l.info.revision, title: e.init.document.name, ...C });
3862
+ const C = Y.current ?? (U.current?.revision === l.info.revision ? U.current.edit : { by: "person" });
3863
+ C.by === "person" && U.current && (U.current = null, Z(null)), e.changed({ dirty: l.info.dirty, revision: l.info.revision, title: e.init.document.name, ...C });
3840
3864
  }, [l, e, h, f]);
3841
- const O = l?.info.schema?.reads ?? null, q = l?.info.schema?.newestAuthor ?? null, x = R(null);
3865
+ const O = l?.info.schema?.reads ?? null, H = l?.info.schema?.newestAuthor ?? null, x = R(null);
3842
3866
  return J(() => {
3843
- if (O === null || q === null || q <= O) return;
3844
- const C = `${O}:${q}`;
3845
- x.current !== C && (x.current = C, e.peer.notify("document/schema", { reads: O, newestAuthor: q }));
3846
- }, [e, q, O]), J(() => {
3867
+ if (O === null || H === null || H <= O) return;
3868
+ const C = `${O}:${H}`;
3869
+ x.current !== C && (x.current = C, e.peer.notify("document/schema", { reads: O, newestAuthor: H }));
3870
+ }, [e, H, O]), J(() => {
3847
3871
  if (!e.replica || !l) return;
3848
- const C = l.info.replica ?? null, W = C ? C.join(",") : null, _ = ce.current;
3849
- ce.current = { doc: l, version: W }, !(_.doc !== l || !C || W === _.version) && e.peer.notify("replica/changed", { version: C.slice().buffer });
3872
+ const C = l.info.replica ?? null, W = C ? C.join(",") : null, V = ce.current;
3873
+ ce.current = { doc: l, version: W }, !(V.doc !== l || !C || W === V.version) && e.peer.notify("replica/changed", { version: C.slice().buffer });
3850
3874
  }, [l, e, h]), J(() => {
3851
3875
  const { peer: C } = e;
3852
3876
  C.handle("document/state", () => {
@@ -3860,15 +3884,15 @@ function Ou(e, t, n, r = {}) {
3860
3884
  const A = g.current.doc;
3861
3885
  if (!A) throw new Error("the document is still opening");
3862
3886
  return A;
3863
- }, _ = k.current, T = (A) => {
3887
+ }, V = k.current, I = (A) => {
3864
3888
  if (o) throw new he(-32e3, "a draft is not allowed: the document is read-only", { reason: Oe });
3865
- return _.engine(A);
3889
+ return V.engine(A);
3866
3890
  };
3867
3891
  C.handle("ai/inspect", async (A) => {
3868
- const L = A?.draft === !0, re = L ? await T(!1) : W(), { width: ie, height: ae, dirty: se, canUndo: ge, canRedo: v, inspected: z } = re.info, S = `${ie} × ${ae}${L ? ", draft" : se ? ", unsaved" : ""}`, $ = A.context ? await re.inspectAt(A.context, A.part) : { details: z };
3869
- return re.agentReply({ path: i, kit: t.kitId, revision: re.info.revision, summary: S, dirty: L ? !1 : se, canUndo: ge, canRedo: v, ...$, ...L ? { draft: _.info() } : {} });
3892
+ const L = A?.draft === !0, re = L ? await I(!1) : W(), { width: ie, height: ae, dirty: se, canUndo: ge, canRedo: v, inspected: z } = re.info, S = `${ie} × ${ae}${L ? ", draft" : se ? ", unsaved" : ""}`, $ = A.context ? await re.inspectAt(A.context, A.part) : { details: z };
3893
+ return re.agentReply({ path: i, kit: t.kitId, revision: re.info.revision, summary: S, dirty: L ? !1 : se, canUndo: ge, canRedo: v, ...$, ...L ? { draft: V.info() } : {} });
3870
3894
  }), C.handle("document/check", async (A) => {
3871
- const L = A?.draft === !0 ? await T(!1) : W();
3895
+ const L = A?.draft === !0 ? await I(!1) : W();
3872
3896
  return L.agentReply({ diagnostics: await L.check() });
3873
3897
  }), C.handle("ai/commands", async ({ query: A }) => {
3874
3898
  const L = al(e.ui.get(), await W().commands());
@@ -3878,20 +3902,20 @@ function Ou(e, t, n, r = {}) {
3878
3902
  if (v >= 0) throw ht(L[v].command, v);
3879
3903
  const z = o ? L.findIndex(($) => m($.command)) : -1;
3880
3904
  if (z >= 0) throw mt(L[z].command, z);
3881
- if (ie === !0) return ue(await T(!0), L);
3905
+ if (ie === !0) return ue(await I(!0), L);
3882
3906
  const S = se.info.context === !0 ? -1 : L.findIndex(($) => $.context != null);
3883
3907
  if (S >= 0) throw Dc(L[S].command, S);
3884
- return P(() => K(se, L, re, ae));
3908
+ return N(() => _(se, L, re, ae));
3885
3909
  });
3886
- const K = async (A, L, re, ie) => {
3887
- const ae = [], se = ie.by === "system" ? { kind: "system", principal: "kdm", label: ie.originLabel } : { kind: "agent", principal: e.init.document.comments?.me ?? "agent", label: "ai/run" }, ge = { last: null, meanwhile: !1 }, v = A.info.context === !0 ? { state: null } : null, z = ($) => ({ ...I ? { skipUnchangedPaint: !0 } : {}, origin: se, ...v ? { agent: { state: v, set: $ } } : {} });
3888
- V.current = ie;
3910
+ const _ = async (A, L, re, ie) => {
3911
+ const ae = [], se = ie.by === "system" ? { kind: "system", principal: "kdm", label: ie.originLabel } : { kind: "agent", principal: e.init.document.comments?.me ?? "agent", label: "ai/run" }, ge = { last: null, meanwhile: !1 }, v = A.info.context === !0 ? { state: null } : null, z = ($) => ({ ...M ? { skipUnchangedPaint: !0 } : {}, origin: se, ...v ? { agent: { state: v, set: $ } } : {} });
3912
+ Y.current = ie;
3889
3913
  try {
3890
3914
  for (const [$, F] of L.entries()) {
3891
3915
  let X = A.info.revision, ee;
3892
3916
  try {
3893
3917
  const oe = () => (X = A.info.revision, ge.last !== null && X !== ge.last && (ge.meanwhile = !0), y(F.command, F.params ?? {}, null, z(F.context ?? null)));
3894
- ee = await G(A, F.command, F.params ?? {}, $, oe, ie);
3918
+ ee = await j(A, F.command, F.params ?? {}, $, oe, ie);
3895
3919
  } catch (oe) {
3896
3920
  if (oe instanceof he && oe.data?.reason === fn) throw oe;
3897
3921
  const ke = oe instanceof he && oe.data?.reason === "not-allowed" ? ht(F.command, $) : oe instanceof he && oe.data?.reason === Oe ? mt(F.command, $) : Oc(oe, F.command, $);
@@ -3906,7 +3930,7 @@ function Ou(e, t, n, r = {}) {
3906
3930
  return { completed: ae, closed: !0, saved: !1, notRun: L.length - ae.length };
3907
3931
  }
3908
3932
  } finally {
3909
- V.current = null;
3933
+ Y.current = null;
3910
3934
  }
3911
3935
  ae.some(($) => $.changed) && Q(ie, A.info.revision);
3912
3936
  const S = !o && !Se(e.ui.get(), "action:save").denied;
@@ -3924,7 +3948,7 @@ function Ou(e, t, n, r = {}) {
3924
3948
  const oe = A.info.revision;
3925
3949
  se.last !== null && oe !== se.last && (se.meanwhile = !0);
3926
3950
  try {
3927
- await G(A, "edit.undo", $r, ae, () => y("edit.undo", $r, null, ge), v);
3951
+ await j(A, "edit.undo", $r, ae, () => y("edit.undo", $r, null, ge), v);
3928
3952
  } catch (ke) {
3929
3953
  de = un(ke);
3930
3954
  break;
@@ -3946,16 +3970,16 @@ function Ou(e, t, n, r = {}) {
3946
3970
  [],
3947
3971
  L
3948
3972
  ) : $(` The ${L.length} step(s) before it were rolled back: the document is as it was before the run.`, [], L);
3949
- }, P = (A) => {
3950
- const L = U.current.then(A, A);
3951
- return U.current = L.then(
3973
+ }, N = (A) => {
3974
+ const L = q.current.then(A, A);
3975
+ return q.current = L.then(
3952
3976
  () => {
3953
3977
  },
3954
3978
  () => {
3955
3979
  }
3956
3980
  ), L;
3957
- }, G = async (A, L, re, ie, ae, se) => {
3958
- const ge = N.current.agentLeaseScope, v = ge ? dn(e) : null;
3981
+ }, j = async (A, L, re, ie, ae, se) => {
3982
+ const ge = P.current.agentLeaseScope, v = ge ? dn(e) : null;
3959
3983
  if (!ge || !v?.available) return ae();
3960
3984
  let z = "";
3961
3985
  try {
@@ -3964,9 +3988,9 @@ function Ou(e, t, n, r = {}) {
3964
3988
  z = "";
3965
3989
  }
3966
3990
  const S = w.current.commands?.get(L)?.mutates ?? !0;
3967
- return Pc(v, z, S, N.current.agentLeaseTtl, ae, ($, F) => (se.by === "agent" && e.notify({ level: "warning", title: E("agentLeaseHeld", { name: F?.name || E("someone") }) }), Nc(L, ie, $, F)));
3991
+ return Nc(v, z, S, P.current.agentLeaseTtl, ae, ($, F) => (se.by === "agent" && e.notify({ level: "warning", title: E("agentLeaseHeld", { name: F?.name || E("someone") }) }), Pc(L, ie, $, F)));
3968
3992
  };
3969
- C.handle("ai/preview", async ({ maxSize: A, draft: L }) => ({ png: await an(L === !0 ? await T(!1) : W(), A) }));
3993
+ C.handle("ai/preview", async ({ maxSize: A, draft: L }) => ({ png: await an(L === !0 ? await I(!1) : W(), A) }));
3970
3994
  const ue = async (A, L) => {
3971
3995
  const re = [];
3972
3996
  let ie = !1;
@@ -3988,23 +4012,23 @@ function Ou(e, t, n, r = {}) {
3988
4012
  return ie = !0, { completed: re, closed: !0, saved: !1, notRun: L.length - re.length };
3989
4013
  }
3990
4014
  } finally {
3991
- !ie && re.some((ae) => ae.changed) && _.edited();
4015
+ !ie && re.some((ae) => ae.changed) && V.edited();
3992
4016
  }
3993
4017
  return { completed: re, saved: !1 };
3994
4018
  };
3995
- C.handle("draft/state", () => _.info()), C.handle("draft/ready", () => _.ready()), C.handle("draft/reopen", () => _.reopen()), C.handle("draft/compare", (A) => _.compare(Math.max(1, Number(A?.maxSize) || 1024), A?.schema ?? null)), C.handle("draft/merge", async ({ origin: A, schema: L = null }) => {
4019
+ C.handle("draft/state", () => V.info()), C.handle("draft/ready", () => V.ready()), C.handle("draft/reopen", () => V.reopen()), C.handle("draft/compare", (A) => V.compare(Math.max(1, Number(A?.maxSize) || 1024), A?.schema ?? null)), C.handle("draft/merge", async ({ origin: A, schema: L = null }) => {
3996
4020
  if (o) throw new he(-32e3, "the document is read-only", { reason: Oe });
3997
4021
  const re = { kind: "agent", principal: String(A?.principal ?? ""), ...A?.label ? { label: String(A.label) } : {} };
3998
- V.current = { by: "agent" };
4022
+ Y.current = { by: "agent" };
3999
4023
  try {
4000
- const ie = await _.merge(re, L), ae = g.current.doc;
4001
- return ae && Q({ by: "agent" }, ae.info.revision), ie.merged && N.current.draftMerged?.({ summary: ie.summary }), ie;
4024
+ const ie = await V.merge(re, L), ae = g.current.doc;
4025
+ return ae && Q({ by: "agent" }, ae.info.revision), ie.merged && P.current.draftMerged?.({ summary: ie.summary }), ie;
4002
4026
  } catch (ie) {
4003
4027
  throw ie instanceof Je ? xr(ie.data) : ie;
4004
4028
  } finally {
4005
- V.current = null;
4029
+ Y.current = null;
4006
4030
  }
4007
- }), C.handle("draft/discard", () => _.discard());
4031
+ }), C.handle("draft/discard", () => V.discard());
4008
4032
  const ye = async (A) => {
4009
4033
  if (!W().info.model) throw new he(-32601, "the kit's engine does not answer the object model");
4010
4034
  try {
@@ -4028,17 +4052,17 @@ function Ou(e, t, n, r = {}) {
4028
4052
  if (z?.op === "command" && typeof z.id == "string" && Se(e.ui.get(), `command:${z.id}`, se.get(z.id) ?? []).denied)
4029
4053
  throw new Je({ code: "command-failed", index: S, message: ht(z.id).message });
4030
4054
  }), re !== !0) return g.current.model.batch(ie, L);
4031
- const v = await (await T(ae.length > 0)).modelBatch(ie, L);
4032
- return ae.length && _.edited(), v;
4055
+ const v = await (await I(ae.length > 0)).modelBatch(ie, L);
4056
+ return ae.length && V.edited(), v;
4033
4057
  })
4034
4058
  );
4035
- const Ne = C.on("document/fileChanged", () => void g.current.checkFile()), We = C.on("document/held", (A) => {
4059
+ const Pe = C.on("document/fileChanged", () => void g.current.checkFile()), We = C.on("document/held", (A) => {
4036
4060
  typeof A?.version == "string" && g.current.holdFile(A.version);
4037
4061
  });
4038
4062
  return e.replica && (C.handle("replica/version", async () => ({ version: await g.current.replica.version() })), C.handle("replica/export", ({ since: A }) => g.current.replica.exportChanges(A)), C.handle("replica/import", async ({ changes: A, blobs: L }) => ({ damage: await g.current.replica.importChanges(A, L) })), C.handle("replica/info", async () => ({ docId: await g.current.replica.docId() }))), () => {
4039
- Ne(), We();
4063
+ Pe(), We();
4040
4064
  };
4041
- }, [d, Q, m, e, t.kitId, b, i, o, y, I, E]), { ...c, run: y, editedBy: D, comments: d };
4065
+ }, [d, Q, m, e, t.kitId, b, i, o, y, M, E]), { ...c, run: y, editedBy: D, comments: d };
4042
4066
  }
4043
4067
  const to = [
4044
4068
  { preset: "rect", icon: ct, label: "drawingRect" },
@@ -4052,9 +4076,9 @@ const to = [
4052
4076
  ], Fc = ["Shape", "Shapes", "Text Box", "Textbox"], Wc = [0.5, 0.75, 1, 1.5, 2.25, 3, 4.5, 6];
4053
4077
  function Ru({ testId: e = "drawing", label: t, merge: n, exclude: r, primary: i }) {
4054
4078
  const o = te(), { t: a } = o, s = !o.enabled("drawing.insert"), d = (p) => void o.run("drawing.insert", p), c = o.byId.has("draw.shape"), l = (p) => c ? void o.run("draw.shape", { preset: p }) : d({ geometry: { preset: p } });
4055
- return /* @__PURE__ */ M(Me, { label: t ?? a("drawingIllustrations"), icon: _e, children: [
4079
+ return /* @__PURE__ */ T(Me, { label: t ?? a("drawingIllustrations"), icon: _e, children: [
4056
4080
  /* @__PURE__ */ u(xe, { icon: _e, label: a("drawingShapes"), size: "large", disabled: s, testId: `${e}-shapes`, primary: !0, children: to.map((p) => /* @__PURE__ */ u(le, { icon: p.icon, label: a(p.label), testId: `${e}-shape-${p.preset}`, onSelect: () => l(p.preset) }, p.preset)) }),
4057
- /* @__PURE__ */ u(we, { icon: qe, label: a("drawingTextBox"), size: "large", disabled: s, onClick: () => d({ kind: "textBox", text: "" }), "data-testid": `${e}-text-box`, primary: !0 }),
4081
+ /* @__PURE__ */ u(we, { icon: Ue, label: a("drawingTextBox"), size: "large", disabled: s, onClick: () => d({ kind: "textBox", text: "" }), "data-testid": `${e}-text-box`, primary: !0 }),
4058
4082
  n ? /* @__PURE__ */ u(uc, { path: n, titles: Fc, exclude: r, primary: i?.length ? i : void 0 }) : null
4059
4083
  ] });
4060
4084
  }
@@ -4102,11 +4126,11 @@ function Hc(e) {
4102
4126
  };
4103
4127
  }, [t, o, n]), r;
4104
4128
  }
4105
- const Uc = [
4129
+ const qc = [
4106
4130
  { id: "bottomRight", label: "drawingShadowBottomRight", shadow: { blur: 4, distance: 3, angle: 45 } },
4107
4131
  { id: "bottom", label: "drawingShadowBottom", shadow: { blur: 4, distance: 3, angle: 90 } },
4108
4132
  { id: "around", label: "drawingShadowAround", shadow: { blur: 8, distance: 0, angle: 0 } }
4109
- ], qc = [
4133
+ ], Uc = [
4110
4134
  { preset: "textArchUp", label: "drawingWarpArchUp" },
4111
4135
  { preset: "textArchDown", label: "drawingWarpArchDown" },
4112
4136
  { preset: "textCircle", label: "drawingWarpCircle" },
@@ -4124,8 +4148,8 @@ const Uc = [
4124
4148
  ];
4125
4149
  function jc({ disabled: e, testId: t = "drawing", onPick: n }) {
4126
4150
  const { t: r } = te();
4127
- return /* @__PURE__ */ M(xe, { icon: vn, label: r("drawingTransform"), disabled: e, testId: `${t}-transform`, children: [
4128
- qc.map((i) => /* @__PURE__ */ u(le, { label: r(i.label), testId: `${t}-warp-${i.preset}`, onSelect: () => n(i.preset) }, i.preset)),
4151
+ return /* @__PURE__ */ T(xe, { icon: vn, label: r("drawingTransform"), disabled: e, testId: `${t}-transform`, children: [
4152
+ Uc.map((i) => /* @__PURE__ */ u(le, { label: r(i.label), testId: `${t}-warp-${i.preset}`, onSelect: () => n(i.preset) }, i.preset)),
4129
4153
  /* @__PURE__ */ u(Ae, {}),
4130
4154
  /* @__PURE__ */ u(le, { label: r("drawingNoTransform"), testId: `${t}-no-warp`, onSelect: () => n(null) })
4131
4155
  ] });
@@ -4134,24 +4158,24 @@ function Du({ ids: e, testId: t = "drawing", effects: n = !0 }) {
4134
4158
  const r = te(), { t: i } = r, o = e.length === 0 || !r.enabled("drawing.format"), a = (f) => void r.run("drawing.format", { ids: e, ...f }), s = e.length === 0 || !r.enabled("drawing.arrange"), d = (f) => void r.run("drawing.arrange", { ids: e, order: f }), c = Hc(e), l = e.length === 0 || !r.enabled("drawing.text"), p = (f) => {
4135
4159
  for (const g of e) r.run("drawing.text", { id: g, warp: f });
4136
4160
  }, h = Kc(e) ?? "#5645D4";
4137
- return /* @__PURE__ */ M(Ce, { children: [
4138
- /* @__PURE__ */ u(Me, { label: i("drawingShapeStyles"), icon: xt, children: /* @__PURE__ */ M(Fe, { children: [
4139
- /* @__PURE__ */ M(xe, { icon: xt, label: i("drawingFill"), disabled: o, testId: `${t}-fill`, primary: !0, children: [
4161
+ return /* @__PURE__ */ T(Ce, { children: [
4162
+ /* @__PURE__ */ u(Me, { label: i("drawingShapeStyles"), icon: xt, children: /* @__PURE__ */ T(Fe, { children: [
4163
+ /* @__PURE__ */ T(xe, { icon: xt, label: i("drawingFill"), disabled: o, testId: `${t}-fill`, primary: !0, children: [
4140
4164
  /* @__PURE__ */ u(Vt, { onPick: (f) => a({ fill: { color: f } }), testId: `${t}-fill-colors` }),
4141
4165
  /* @__PURE__ */ u(Ae, {}),
4142
4166
  Bc.map((f) => /* @__PURE__ */ u(le, { label: i(f.label), testId: `${t}-gradient-${f.id}`, onSelect: () => a({ fill: _c(h, f) }) }, f.id)),
4143
4167
  /* @__PURE__ */ u(Ae, {}),
4144
4168
  /* @__PURE__ */ u(le, { label: i("drawingNoFill"), testId: `${t}-no-fill`, onSelect: () => a({ fill: { none: !0 } }) })
4145
4169
  ] }),
4146
- n ? /* @__PURE__ */ M(xe, { icon: Lt, label: i("drawingEffects"), disabled: o, testId: `${t}-effects`, children: [
4147
- Uc.map((f) => /* @__PURE__ */ u(le, { label: i(f.label), testId: `${t}-shadow-${f.id}`, onSelect: () => a({ effects: { shadow: { color: { rgb: "#000000", alpha: 0.4 }, ...f.shadow } } }) }, f.id)),
4170
+ n ? /* @__PURE__ */ T(xe, { icon: Lt, label: i("drawingEffects"), disabled: o, testId: `${t}-effects`, children: [
4171
+ qc.map((f) => /* @__PURE__ */ u(le, { label: i(f.label), testId: `${t}-shadow-${f.id}`, onSelect: () => a({ effects: { shadow: { color: { rgb: "#000000", alpha: 0.4 }, ...f.shadow } } }) }, f.id)),
4148
4172
  /* @__PURE__ */ u(le, { label: i("drawingNoShadow"), testId: `${t}-no-shadow`, onSelect: () => a({ effects: { shadow: null } }) }),
4149
4173
  /* @__PURE__ */ u(Ae, {}),
4150
4174
  /* @__PURE__ */ u(le, { label: i("drawingGlow"), testId: `${t}-glow`, onSelect: () => a({ effects: { glow: { color: { rgb: h, alpha: 0.6 }, size: 5 } } }) }),
4151
4175
  /* @__PURE__ */ u(le, { label: i("drawingNoGlow"), testId: `${t}-no-glow`, onSelect: () => a({ effects: { glow: null } }) })
4152
4176
  ] }) : null,
4153
4177
  /* @__PURE__ */ u(jc, { disabled: l, testId: t, onPick: p }),
4154
- /* @__PURE__ */ M(xe, { icon: it, label: i("drawingOutline"), disabled: o, testId: `${t}-outline`, primary: !0, children: [
4178
+ /* @__PURE__ */ T(xe, { icon: it, label: i("drawingOutline"), disabled: o, testId: `${t}-outline`, primary: !0, children: [
4155
4179
  /* @__PURE__ */ u(Vt, { onPick: (f) => a({ stroke: { color: f } }), testId: `${t}-outline-colors` }),
4156
4180
  /* @__PURE__ */ u(Ae, {}),
4157
4181
  Wc.map((f) => /* @__PURE__ */ u(le, { label: i("drawingWeight", { value: f }), testId: `${t}-weight-${f}`, onSelect: () => a({ stroke: { width: f } }) }, f)),
@@ -4159,19 +4183,19 @@ function Du({ ids: e, testId: t = "drawing", effects: n = !0 }) {
4159
4183
  /* @__PURE__ */ u(le, { label: i("drawingNoOutline"), testId: `${t}-no-outline`, onSelect: () => a({ stroke: { none: !0 } }) })
4160
4184
  ] })
4161
4185
  ] }) }),
4162
- /* @__PURE__ */ M(Me, { label: i("drawingArrange"), icon: Qt, children: [
4186
+ /* @__PURE__ */ T(Me, { label: i("drawingArrange"), icon: Qt, children: [
4163
4187
  /* @__PURE__ */ u(Fe, { children: /* @__PURE__ */ u(xe, { icon: _e, label: i("drawingChangeShape"), disabled: o, testId: `${t}-change-shape`, children: to.map((f) => /* @__PURE__ */ u(le, { icon: f.icon, label: i(f.label), onSelect: () => a({ geometry: { preset: f.preset } }) }, f.preset)) }) }),
4164
- /* @__PURE__ */ M(Fe, { children: [
4165
- /* @__PURE__ */ M(xe, { icon: Qt, label: i("drawingBringForward"), disabled: s, testId: `${t}-bring`, primary: !0, children: [
4188
+ /* @__PURE__ */ T(Fe, { children: [
4189
+ /* @__PURE__ */ T(xe, { icon: Qt, label: i("drawingBringForward"), disabled: s, testId: `${t}-bring`, primary: !0, children: [
4166
4190
  /* @__PURE__ */ u(le, { label: i("drawingBringForward"), testId: `${t}-bring-forward`, onSelect: () => d("forward") }),
4167
4191
  /* @__PURE__ */ u(le, { label: i("drawingBringToFront"), testId: `${t}-bring-front`, onSelect: () => d("front") })
4168
4192
  ] }),
4169
- /* @__PURE__ */ M(xe, { icon: Es, label: i("drawingSendBackward"), disabled: s, testId: `${t}-send`, primary: !0, children: [
4193
+ /* @__PURE__ */ T(xe, { icon: Es, label: i("drawingSendBackward"), disabled: s, testId: `${t}-send`, primary: !0, children: [
4170
4194
  /* @__PURE__ */ u(le, { label: i("drawingSendBackward"), testId: `${t}-send-backward`, onSelect: () => d("backward") }),
4171
4195
  /* @__PURE__ */ u(le, { label: i("drawingSendToBack"), testId: `${t}-send-back`, onSelect: () => d("back") })
4172
4196
  ] })
4173
4197
  ] }),
4174
- /* @__PURE__ */ M(Fe, { children: [
4198
+ /* @__PURE__ */ T(Fe, { children: [
4175
4199
  /* @__PURE__ */ u(
4176
4200
  we,
4177
4201
  {
@@ -4235,7 +4259,7 @@ const Gc = [
4235
4259
  { tool: "eraser", icon: xi, label: "inkEraser" }
4236
4260
  ], Yc = [0.5, 1, 1.5, 2, 3, 4.5, 6, 12], Vc = ["pen", "pencil", "highlighter"];
4237
4261
  function Lu({ testId: e = "ink" }) {
4238
- const t = te(), n = Xe(), { t: r } = t, i = t.session.change?.revision, [o, a] = B(null), s = H(() => {
4262
+ const t = te(), n = Xe(), { t: r } = t, i = t.session.change?.revision, [o, a] = B(null), s = K(() => {
4239
4263
  t.query("draw.state").then((g) => {
4240
4264
  g && a(g);
4241
4265
  });
@@ -4250,7 +4274,7 @@ function Lu({ testId: e = "ink" }) {
4250
4274
  }, l = n && d(o?.tool ?? "select") && n.tools.some((g) => g.id === n.active) ? n.active : o?.tool, p = o && Vc.includes(o.tool) ? o.tool : null, h = async (g) => {
4251
4275
  p && (await t.run(`draw.${p}`, g), s());
4252
4276
  }, f = !t.enabled("draw.pen");
4253
- return /* @__PURE__ */ M(Ce, { children: [
4277
+ return /* @__PURE__ */ T(Ce, { children: [
4254
4278
  /* @__PURE__ */ u(Me, { label: r("inkTools"), icon: Ti, children: Gc.map((g) => /* @__PURE__ */ u(
4255
4279
  we,
4256
4280
  {
@@ -4265,7 +4289,7 @@ function Lu({ testId: e = "ink" }) {
4265
4289
  },
4266
4290
  g.tool
4267
4291
  )) }),
4268
- /* @__PURE__ */ u(Me, { label: r("inkPens"), icon: it, children: /* @__PURE__ */ M(Fe, { children: [
4292
+ /* @__PURE__ */ u(Me, { label: r("inkPens"), icon: it, children: /* @__PURE__ */ T(Fe, { children: [
4269
4293
  /* @__PURE__ */ u(
4270
4294
  xe,
4271
4295
  {
@@ -4363,7 +4387,7 @@ function ed(e) {
4363
4387
  function ro(e) {
4364
4388
  return e === "line" || e === "lineMarkers" || e === "stackedLine" || e === "scatter" || e === "radar";
4365
4389
  }
4366
- const Pn = [
4390
+ const Nn = [
4367
4391
  { kind: "column", icon: je, label: "chartColumn" },
4368
4392
  {
4369
4393
  kind: "stackedColumn",
@@ -4377,9 +4401,9 @@ const Pn = [
4377
4401
  { kind: "pie", icon: Qn, label: "chartPie" },
4378
4402
  { kind: "doughnut", icon: Qn, label: "chartDoughnut" },
4379
4403
  { kind: "scatter", icon: Ls, label: "chartScatter" },
4380
- { kind: "radar", icon: Ns, label: "chartRadar" }
4404
+ { kind: "radar", icon: Ps, label: "chartRadar" }
4381
4405
  ], td = ["top", "bottom", "left", "right"];
4382
- function Nu({
4406
+ function Pu({
4383
4407
  testId: e = "chart",
4384
4408
  size: t = "large",
4385
4409
  primary: n
@@ -4394,7 +4418,7 @@ function Nu({
4394
4418
  disabled: !r.enabled("drawing.insert"),
4395
4419
  testId: `${e}-insert`,
4396
4420
  primary: n,
4397
- children: Pn.map((o) => /* @__PURE__ */ u(
4421
+ children: Nn.map((o) => /* @__PURE__ */ u(
4398
4422
  le,
4399
4423
  {
4400
4424
  icon: o.icon,
@@ -4427,14 +4451,14 @@ function nd(e) {
4427
4451
  };
4428
4452
  }, [t, e, n]), r;
4429
4453
  }
4430
- function Pu({
4454
+ function Nu({
4431
4455
  id: e,
4432
4456
  testId: t = "chart",
4433
4457
  dataEditable: n = !0,
4434
4458
  formats: r = no
4435
4459
  }) {
4436
- const i = te(), { t: o } = i, a = nd(e), [s, d] = B(!1), [c, l] = B(null), p = !a || !i.enabled("drawing.chart"), h = (m) => void i.run("drawing.chart", { id: e, ...m }), f = typeof a?.kind == "object", g = a?.kind === "pie" || a?.kind === "doughnut", w = g || a?.kind === "radar" || f, b = (m) => h({ seriesFormat: (a?.series ?? []).map((y, I) => ({ index: I, ...m })) });
4437
- return /* @__PURE__ */ M(Ce, { children: [
4460
+ const i = te(), { t: o } = i, a = nd(e), [s, d] = B(!1), [c, l] = B(null), p = !a || !i.enabled("drawing.chart"), h = (m) => void i.run("drawing.chart", { id: e, ...m }), f = typeof a?.kind == "object", g = a?.kind === "pie" || a?.kind === "doughnut", w = g || a?.kind === "radar" || f, b = (m) => h({ seriesFormat: (a?.series ?? []).map((y, M) => ({ index: M, ...m })) });
4461
+ return /* @__PURE__ */ T(Ce, { children: [
4438
4462
  /* @__PURE__ */ u(Me, { label: o("chartType"), icon: je, children: /* @__PURE__ */ u(
4439
4463
  xe,
4440
4464
  {
@@ -4444,7 +4468,7 @@ function Pu({
4444
4468
  disabled: p || f,
4445
4469
  testId: `${t}-type`,
4446
4470
  primary: !0,
4447
- children: Pn.map((m) => /* @__PURE__ */ u(
4471
+ children: Nn.map((m) => /* @__PURE__ */ u(
4448
4472
  le,
4449
4473
  {
4450
4474
  icon: m.icon,
@@ -4459,12 +4483,12 @@ function Pu({
4459
4483
  ))
4460
4484
  }
4461
4485
  ) }),
4462
- /* @__PURE__ */ M(Me, { label: o("chartElements"), icon: Ps, children: [
4463
- /* @__PURE__ */ M(Fe, { children: [
4486
+ /* @__PURE__ */ T(Me, { label: o("chartElements"), icon: Ns, children: [
4487
+ /* @__PURE__ */ T(Fe, { children: [
4464
4488
  /* @__PURE__ */ u(
4465
4489
  we,
4466
4490
  {
4467
- icon: Ur,
4491
+ icon: qr,
4468
4492
  label: o("chartTitle"),
4469
4493
  pressed: a?.title != null,
4470
4494
  disabled: p,
@@ -4475,10 +4499,10 @@ function Pu({
4475
4499
  primary: !0
4476
4500
  }
4477
4501
  ),
4478
- /* @__PURE__ */ M(
4502
+ /* @__PURE__ */ T(
4479
4503
  xe,
4480
4504
  {
4481
- icon: qe,
4505
+ icon: Ue,
4482
4506
  label: o("chartLegend"),
4483
4507
  disabled: p,
4484
4508
  testId: `${t}-legend`,
@@ -4520,7 +4544,7 @@ function Pu({
4520
4544
  }
4521
4545
  )
4522
4546
  ] }),
4523
- /* @__PURE__ */ M(Fe, { children: [
4547
+ /* @__PURE__ */ T(Fe, { children: [
4524
4548
  /* @__PURE__ */ u(
4525
4549
  we,
4526
4550
  {
@@ -4532,13 +4556,13 @@ function Pu({
4532
4556
  "data-testid": `${t}-gridlines`
4533
4557
  }
4534
4558
  ),
4535
- r.includes("trends") ? /* @__PURE__ */ M(Ce, { children: [
4536
- /* @__PURE__ */ M(xe, { icon: Fs, label: o("chartTrendline"), disabled: p || w, testId: `${t}-trendline`, children: [
4559
+ r.includes("trends") ? /* @__PURE__ */ T(Ce, { children: [
4560
+ /* @__PURE__ */ T(xe, { icon: Fs, label: o("chartTrendline"), disabled: p || w, testId: `${t}-trendline`, children: [
4537
4561
  Jc.map((m) => /* @__PURE__ */ u(le, { label: o(m.label), testId: `${t}-trendline-${m.id}`, onSelect: () => b({ trendline: m.trendline }) }, m.id)),
4538
4562
  /* @__PURE__ */ u(Ae, {}),
4539
4563
  /* @__PURE__ */ u(le, { label: o("chartNone"), testId: `${t}-trendline-none`, onSelect: () => b({ trendline: null }) })
4540
4564
  ] }),
4541
- /* @__PURE__ */ M(xe, { icon: Ve, label: o("chartErrorBars"), disabled: p || w, testId: `${t}-error-bars`, children: [
4565
+ /* @__PURE__ */ T(xe, { icon: Ve, label: o("chartErrorBars"), disabled: p || w, testId: `${t}-error-bars`, children: [
4542
4566
  Zc.map((m) => /* @__PURE__ */ u(le, { label: o(m.label), testId: `${t}-error-bars-${m.id}`, onSelect: () => b({ errorBars: m.errorBars }) }, m.id)),
4543
4567
  /* @__PURE__ */ u(Ae, {}),
4544
4568
  /* @__PURE__ */ u(le, { label: o("chartNone"), testId: `${t}-error-bars-none`, onSelect: () => b({ errorBars: null }) })
@@ -4547,7 +4571,7 @@ function Pu({
4547
4571
  /* @__PURE__ */ u(
4548
4572
  we,
4549
4573
  {
4550
- icon: qe,
4574
+ icon: Ue,
4551
4575
  label: o("chartAxisTitles"),
4552
4576
  pressed: a?.xTitle != null || a?.yTitle != null,
4553
4577
  disabled: p || g,
@@ -4624,7 +4648,7 @@ function rd({
4624
4648
  const { t: a } = te(), s = e?.kind === "pie" || e?.kind === "doughnut", d = typeof e?.kind == "object", c = ed(e?.kind), l = n.filter(
4625
4649
  (h) => h === "lineWidth" || h === "marker" || h === "smooth" || h === "combo"
4626
4650
  ), p = l.includes("lineWidth") || ro(e?.kind) && l.length > 0 || l.includes("combo") && typeof e?.kind == "string" && !["pie", "doughnut", "radar", "scatter"].includes(e.kind);
4627
- return !n.includes("axes") && !n.includes("labelPosition") && l.length === 0 ? null : /* @__PURE__ */ u(Me, { label: a("chartFormat"), icon: Rt, children: /* @__PURE__ */ M(Fe, { children: [
4651
+ return !n.includes("axes") && !n.includes("labelPosition") && l.length === 0 ? null : /* @__PURE__ */ u(Me, { label: a("chartFormat"), icon: Rt, children: /* @__PURE__ */ T(Fe, { children: [
4628
4652
  n.includes("axes") ? /* @__PURE__ */ u(
4629
4653
  we,
4630
4654
  {
@@ -4686,20 +4710,20 @@ function id({
4686
4710
  hidden: !d.shown
4687
4711
  };
4688
4712
  l && Object.assign(y, { min: p, max: h, major: f }), t({ [o]: y }), n();
4689
- }, m = (y, I, N) => {
4690
- const E = d[y], Y = N && E.trim() !== "" && !Number.isFinite(Number(E));
4713
+ }, m = (y, M, P) => {
4714
+ const E = d[y], G = P && E.trim() !== "" && !Number.isFinite(Number(E));
4691
4715
  return [
4692
- /* @__PURE__ */ u("label", { htmlFor: `chart-axis-${y}`, children: I }, `${y}-label`),
4716
+ /* @__PURE__ */ u("label", { htmlFor: `chart-axis-${y}`, children: M }, `${y}-label`),
4693
4717
  /* @__PURE__ */ u(
4694
4718
  "input",
4695
4719
  {
4696
4720
  id: `chart-axis-${y}`,
4697
4721
  className: "kui-field",
4698
- inputMode: N ? "decimal" : void 0,
4722
+ inputMode: P ? "decimal" : void 0,
4699
4723
  placeholder: i("chartAxisAuto"),
4700
- "aria-invalid": Y,
4724
+ "aria-invalid": G,
4701
4725
  value: E,
4702
- onChange: (U) => c((V) => ({ ...V, [y]: U.target.value })),
4726
+ onChange: (q) => c((Y) => ({ ...Y, [y]: q.target.value })),
4703
4727
  "data-testid": `${r}-axis-${y}`
4704
4728
  },
4705
4729
  y
@@ -4712,7 +4736,7 @@ function id({
4712
4736
  title: i("chartFormatAxis"),
4713
4737
  onClose: n,
4714
4738
  testId: `${r}-axis`,
4715
- actions: /* @__PURE__ */ M(Ce, { children: [
4739
+ actions: /* @__PURE__ */ T(Ce, { children: [
4716
4740
  /* @__PURE__ */ u(me, { onClick: n, children: i("cancel") }),
4717
4741
  /* @__PURE__ */ u(
4718
4742
  me,
@@ -4725,7 +4749,7 @@ function id({
4725
4749
  }
4726
4750
  )
4727
4751
  ] }),
4728
- children: /* @__PURE__ */ M("div", { className: "kui-param-grid", children: [
4752
+ children: /* @__PURE__ */ T("div", { className: "kui-param-grid", children: [
4729
4753
  /* @__PURE__ */ u("span", { children: i("chartAxis") }),
4730
4754
  /* @__PURE__ */ u(
4731
4755
  gt,
@@ -4753,7 +4777,7 @@ function id({
4753
4777
  {
4754
4778
  label: i("chartAxisShow"),
4755
4779
  checked: d.shown,
4756
- onChange: (y) => c((I) => ({ ...I, shown: y })),
4780
+ onChange: (y) => c((M) => ({ ...M, shown: y })),
4757
4781
  testId: `${r}-axis-shown`
4758
4782
  }
4759
4783
  )
@@ -4796,7 +4820,7 @@ function od({
4796
4820
  title: o("chartFormatSeries"),
4797
4821
  onClose: r,
4798
4822
  testId: `${i}-series`,
4799
- actions: /* @__PURE__ */ M(Ce, { children: [
4823
+ actions: /* @__PURE__ */ T(Ce, { children: [
4800
4824
  /* @__PURE__ */ u(me, { onClick: r, children: o("cancel") }),
4801
4825
  /* @__PURE__ */ u(
4802
4826
  me,
@@ -4809,7 +4833,7 @@ function od({
4809
4833
  }
4810
4834
  )
4811
4835
  ] }),
4812
- children: /* @__PURE__ */ M("div", { className: "kui-param-grid", children: [
4836
+ children: /* @__PURE__ */ T("div", { className: "kui-param-grid", children: [
4813
4837
  /* @__PURE__ */ u("span", { children: o("chartSeries") }),
4814
4838
  /* @__PURE__ */ u(
4815
4839
  gt,
@@ -4871,7 +4895,7 @@ function od({
4871
4895
  value: p.kind,
4872
4896
  choices: [
4873
4897
  ["", o("chartSeriesTypeChart")],
4874
- ...Xc.map((b) => [b, o(Pn.find((m) => m.kind === b)?.label ?? b)])
4898
+ ...Xc.map((b) => [b, o(Nn.find((m) => m.kind === b)?.label ?? b)])
4875
4899
  ],
4876
4900
  onChange: (b) => h((m) => ({ ...m, kind: b })),
4877
4901
  testId: `${i}-series-kind`
@@ -4937,16 +4961,16 @@ function sd({
4937
4961
  }), n();
4938
4962
  }, g = (w, b, m) => l(
4939
4963
  (y) => y.map(
4940
- (I, N) => N === w ? I.map((E, Y) => Y === b ? m : E) : I
4964
+ (M, P) => P === w ? M.map((E, G) => G === b ? m : E) : M
4941
4965
  )
4942
4966
  );
4943
- return /* @__PURE__ */ M(
4967
+ return /* @__PURE__ */ T(
4944
4968
  st,
4945
4969
  {
4946
4970
  title: i("chartEditData"),
4947
4971
  onClose: n,
4948
4972
  testId: `${r}-data`,
4949
- actions: /* @__PURE__ */ M(Ce, { children: [
4973
+ actions: /* @__PURE__ */ T(Ce, { children: [
4950
4974
  /* @__PURE__ */ u(me, { onClick: n, children: i("cancel") }),
4951
4975
  /* @__PURE__ */ u(
4952
4976
  me,
@@ -4960,8 +4984,8 @@ function sd({
4960
4984
  )
4961
4985
  ] }),
4962
4986
  children: [
4963
- /* @__PURE__ */ u("div", { style: { maxHeight: 360, overflow: "auto" }, children: /* @__PURE__ */ M("table", { className: "kui-chart-data", children: [
4964
- /* @__PURE__ */ u("thead", { children: /* @__PURE__ */ M("tr", { children: [
4987
+ /* @__PURE__ */ u("div", { style: { maxHeight: 360, overflow: "auto" }, children: /* @__PURE__ */ T("table", { className: "kui-chart-data", children: [
4988
+ /* @__PURE__ */ u("thead", { children: /* @__PURE__ */ T("tr", { children: [
4965
4989
  /* @__PURE__ */ u("th", {}),
4966
4990
  s.map((w, b) => /* @__PURE__ */ u("th", { children: /* @__PURE__ */ u(
4967
4991
  "input",
@@ -4969,20 +4993,20 @@ function sd({
4969
4993
  "aria-label": i("chartSeriesName", { n: b + 1 }),
4970
4994
  value: w,
4971
4995
  onChange: (m) => d(
4972
- (y) => y.map((I, N) => N === b ? m.target.value : I)
4996
+ (y) => y.map((M, P) => P === b ? m.target.value : M)
4973
4997
  ),
4974
4998
  "data-testid": `${r}-data-series-${b}`
4975
4999
  }
4976
5000
  ) }, b))
4977
5001
  ] }) }),
4978
- /* @__PURE__ */ u("tbody", { children: o.map((w, b) => /* @__PURE__ */ M("tr", { children: [
5002
+ /* @__PURE__ */ u("tbody", { children: o.map((w, b) => /* @__PURE__ */ T("tr", { children: [
4979
5003
  /* @__PURE__ */ u("th", { children: /* @__PURE__ */ u(
4980
5004
  "input",
4981
5005
  {
4982
5006
  "aria-label": i("chartCategoryName", { n: b + 1 }),
4983
5007
  value: w,
4984
5008
  onChange: (m) => a(
4985
- (y) => y.map((I, N) => N === b ? m.target.value : I)
5009
+ (y) => y.map((M, P) => P === b ? m.target.value : M)
4986
5010
  ),
4987
5011
  "data-testid": `${r}-data-category-${b}`
4988
5012
  }
@@ -4997,13 +5021,13 @@ function sd({
4997
5021
  }),
4998
5022
  "aria-invalid": c[y][b].trim() !== "" && !Number.isFinite(Number(c[y][b])),
4999
5023
  value: c[y][b],
5000
- onChange: (I) => g(y, b, I.target.value),
5024
+ onChange: (M) => g(y, b, M.target.value),
5001
5025
  "data-testid": `${r}-data-cell-${y}-${b}`
5002
5026
  }
5003
5027
  ) }, y))
5004
5028
  ] }, b)) })
5005
5029
  ] }) }),
5006
- /* @__PURE__ */ M("div", { style: { display: "flex", gap: 8, marginTop: 8 }, children: [
5030
+ /* @__PURE__ */ T("div", { style: { display: "flex", gap: 8, marginTop: 8 }, children: [
5007
5031
  /* @__PURE__ */ u(
5008
5032
  me,
5009
5033
  {
@@ -5060,19 +5084,19 @@ function sd({
5060
5084
  }
5061
5085
  const ld = 4e3;
5062
5086
  function cd({ tool: e, onExit: t }) {
5063
- const n = te(), r = Xe(), i = be(), { undo: o } = Nn(), { host: a, t: s, testId: d, phrase: c } = n, l = r?.tools.find((b) => b.id === r.active), p = e ?? (l ? { label: c(l.label), icon: zi(l.icon, l.id) } : null), h = i.state("action:agent"), f = p?.icon, [g, w] = B(!0);
5087
+ const n = te(), r = Xe(), i = be(), { undo: o } = Pn(), { host: a, t: s, testId: d, phrase: c } = n, l = r?.tools.find((b) => b.id === r.active), p = e ?? (l ? { label: c(l.label), icon: zi(l.icon, l.id) } : null), h = i.state("action:agent"), f = p?.icon, [g, w] = B(!0);
5064
5088
  return J(() => {
5065
5089
  const b = setTimeout(() => w(!1), ld);
5066
5090
  return () => clearTimeout(b);
5067
- }, []), /* @__PURE__ */ M("div", { className: "kui-focus-bar", role: "toolbar", "aria-label": s("focusBar"), "data-fresh": g || void 0, "data-testid": `${d}-focus-bar`, children: [
5068
- /* @__PURE__ */ M(me, { variant: "ghost", className: "kui-focus-exit", title: `${s("exitFocus")} (Esc)`, onClick: t, "data-testid": `${d}-focus-exit`, "data-kit-ui-id": "action:mode", children: [
5091
+ }, []), /* @__PURE__ */ T("div", { className: "kui-focus-bar", role: "toolbar", "aria-label": s("focusBar"), "data-fresh": g || void 0, "data-testid": `${d}-focus-bar`, children: [
5092
+ /* @__PURE__ */ T(me, { variant: "ghost", className: "kui-focus-exit", title: `${s("exitFocus")} (Esc)`, onClick: t, "data-testid": `${d}-focus-exit`, "data-kit-ui-id": "action:mode", children: [
5069
5093
  /* @__PURE__ */ u(zs, { size: 16, strokeWidth: $e, "aria-hidden": "true" }),
5070
5094
  s("exitFocus"),
5071
5095
  /* @__PURE__ */ u("kbd", { children: "Esc" })
5072
5096
  ] }),
5073
5097
  o.hidden ? null : /* @__PURE__ */ u(De, { icon: kn, label: s("undo"), disabled: o.disabled, onClick: () => void n.run("edit.undo", {}), "data-testid": `${d}-focus-undo`, "data-kit-ui-id": "action:undo" }),
5074
5098
  a.init.capabilities.includes("agent") && !h.hidden ? /* @__PURE__ */ u(De, { icon: Lt, label: s("askAgent"), disabled: h.disabled, onClick: () => void a.openAgent(), "data-testid": `${d}-focus-ask`, "data-kit-ui-id": "action:agent" }) : null,
5075
- p && f ? /* @__PURE__ */ M("span", { className: "kui-focus-tool", "data-testid": `${d}-focus-tool`, children: [
5099
+ p && f ? /* @__PURE__ */ T("span", { className: "kui-focus-tool", "data-testid": `${d}-focus-tool`, children: [
5076
5100
  /* @__PURE__ */ u(f, { size: 16, strokeWidth: $e, "aria-hidden": "true" }),
5077
5101
  p.label
5078
5102
  ] }) : null
@@ -5130,7 +5154,7 @@ function oo({ nodes: e, checked: t, onKitCommand: n, onCommand: r }) {
5130
5154
  }) });
5131
5155
  }
5132
5156
  function md({ tree: e, nodes: t }) {
5133
- return /* @__PURE__ */ M(Ce, { children: [
5157
+ return /* @__PURE__ */ T(Ce, { children: [
5134
5158
  e.before?.map((n) => /* @__PURE__ */ u(le, { icon: n.icon, label: n.label, onSelect: n.onSelect, testId: n.testId }, n.label)),
5135
5159
  e.before?.length && t.length ? /* @__PURE__ */ u(Ae, {}) : null,
5136
5160
  /* @__PURE__ */ u(oo, { nodes: t, checked: e.checked, onKitCommand: e.onKitCommand, onCommand: e.onCommand })
@@ -5188,7 +5212,7 @@ function Mr({ row: e, tree: t, primary: n }) {
5188
5212
  pressed: t.checked?.(e.command),
5189
5213
  disabled: !r.enabled(e.command) || l.disabled,
5190
5214
  onClick: () => {
5191
- t.onCommand && !(c && Pt(c)) ? t.onCommand(e.command) : r.run(e.command);
5215
+ t.onCommand && !(c && Nt(c)) ? t.onCommand(e.command) : r.run(e.command);
5192
5216
  },
5193
5217
  "data-testid": `${s}-cmd-${e.command}`,
5194
5218
  "data-kit-ui-id": `command:${e.command}`
@@ -5196,14 +5220,14 @@ function Mr({ row: e, tree: t, primary: n }) {
5196
5220
  );
5197
5221
  }
5198
5222
  function wd({ tab: e, nodes: t }) {
5199
- const { byId: n, phrase: r } = te(), i = Nn(), o = /* @__PURE__ */ new Set([...i.undo.hidden ? [] : ["edit.undo"], ...i.redo.hidden ? [] : ["edit.redo"]]), a = (f) => f.filter((g) => !o.has(g.command)), s = (f) => {
5223
+ const { byId: n, phrase: r } = te(), i = Pn(), o = /* @__PURE__ */ new Set([...i.undo.hidden ? [] : ["edit.undo"], ...i.redo.hidden ? [] : ["edit.redo"]]), a = (f) => f.filter((g) => !o.has(g.command)), s = (f) => {
5200
5224
  const g = f.find((w) => w.command !== "---");
5201
5225
  return g ? Ge(n.get(g.command) ?? { id: g.command.replace(Ke, ""), title: g.label }) : void 0;
5202
5226
  }, d = e.menu;
5203
5227
  if (!d) return null;
5204
5228
  const c = a(t.flatMap((f) => f.kind === "row" ? [f.row] : [])), l = t.flatMap((f) => f.kind === "submenu" && a(Ze(f.children)).length ? [f] : []), p = d.primary ? null : new Set([...c, ...l.flatMap((f) => a(Ze(f.children)))].filter((f) => f.command !== "---").slice(0, gd).map((f) => f.command)), h = (f) => p ? p.has(f.command) : d.primary?.includes(f.command);
5205
- return /* @__PURE__ */ M(Ce, { children: [
5206
- c.length || d.before?.length ? /* @__PURE__ */ u(Me, { id: `menu:${e.id}`, label: e.label, icon: s(c), children: /* @__PURE__ */ M("div", { className: "kui-command-grid", children: [
5229
+ return /* @__PURE__ */ T(Ce, { children: [
5230
+ c.length || d.before?.length ? /* @__PURE__ */ u(Me, { id: `menu:${e.id}`, label: e.label, icon: s(c), children: /* @__PURE__ */ T("div", { className: "kui-command-grid", children: [
5207
5231
  d.before?.map((f) => {
5208
5232
  const g = f.icon ?? Ge({ id: f.testId ?? f.label, title: f.label });
5209
5233
  return /* @__PURE__ */ u(we, { icon: g, lineLabel: !f.icon && g === at, primary: f.primary, label: f.label, onClick: f.onSelect, "data-testid": f.testId }, f.label);
@@ -5213,7 +5237,7 @@ function wd({ tab: e, nodes: t }) {
5213
5237
  l.map((f) => /* @__PURE__ */ u(Me, { id: `menu:${f.path}`, label: r(f.label), icon: s(a(Ze(f.children))), children: /* @__PURE__ */ u("div", { className: "kui-command-grid", children: a(Ze(f.children)).map((g, w) => /* @__PURE__ */ u(Mr, { row: g, tree: d, primary: h(g) }, `${g.command}@${w}`)) }) }, f.path))
5214
5238
  ] });
5215
5239
  }
5216
- const Tr = { menus: Bs, line: Mi, classic: yi, focus: Ai }, Ar = () => Nt() ? "Cmd+\\" : "Ctrl+\\";
5240
+ const Tr = { menus: Bs, line: Mi, classic: yi, focus: Ai }, Ar = () => Pt() ? "Cmd+\\" : "Ctrl+\\";
5217
5241
  function bd({ display: e, shown: t, areas: n = !0 }) {
5218
5242
  const { t: r, testId: i } = te(), a = be().state("action:mode");
5219
5243
  if (a.hidden || e.allowed.length < 2) return null;
@@ -5273,16 +5297,16 @@ function Fu(e, { order: t, exclude: n = [], ...r }) {
5273
5297
  return vd(kd(e, t, n), r);
5274
5298
  }
5275
5299
  function Sd(e, t = !0) {
5276
- const { modes: n } = He(e.ui.subscribe, e.ui.get), r = e.kit.id, [i, o] = B(() => Hs(r)), [a, s] = B(() => n.default === "focus"), d = Ri(n), c = t ? d : d.filter((g) => g === "menus" || g === "focus"), l = t ? qs({ stored: i, rules: n, kit: e.display, readOnly: e.readOnly === !0 }) : "menus", p = H(
5300
+ const { modes: n } = He(e.ui.subscribe, e.ui.get), r = e.kit.id, [i, o] = B(() => Hs(r)), [a, s] = B(() => n.default === "focus"), d = Ri(n), c = t ? d : d.filter((g) => g === "menus" || g === "focus"), l = t ? Us({ stored: i, rules: n, kit: e.display, readOnly: e.readOnly === !0 }) : "menus", p = K(
5277
5301
  (g) => {
5278
5302
  if (g === "focus") {
5279
5303
  s(!0);
5280
5304
  return;
5281
5305
  }
5282
- Us(r, g), o(g), s(!1);
5306
+ qs(r, g), o(g), s(!1);
5283
5307
  },
5284
5308
  [r]
5285
- ), h = H(() => s((g) => !g), []), f = H(() => s(!1), []);
5309
+ ), h = K(() => s((g) => !g), []), f = K(() => s(!1), []);
5286
5310
  return { chosen: l, focus: a && c.includes("focus"), allowed: c, choose: p, toggleFocus: h, exitFocus: f };
5287
5311
  }
5288
5312
  function Cd(e, t, n, r) {
@@ -5296,7 +5320,7 @@ function Cd(e, t, n, r) {
5296
5320
  });
5297
5321
  return p.observe(l), () => p.disconnect();
5298
5322
  }, [e]);
5299
- const d = js(t, i, { classic: a.get(`classic:${n}`), line: a.get(`line:${n}`) }, r), c = H(
5323
+ const d = js(t, i, { classic: a.get(`classic:${n}`), line: a.get(`line:${n}`) }, r), c = K(
5300
5324
  (l, p) => {
5301
5325
  const h = e.current;
5302
5326
  if (!p || !h || typeof ResizeObserver > "u") return;
@@ -5373,7 +5397,7 @@ ${f.label}`;
5373
5397
  return p.observe(l), () => p.disconnect();
5374
5398
  }, []);
5375
5399
  const c = a === null ? [] : e.filter((l) => !a.has(l.id));
5376
- return /* @__PURE__ */ M("div", { ref: i, className: "kui-frame-tabs", children: [
5400
+ return /* @__PURE__ */ T("div", { ref: i, className: "kui-frame-tabs", children: [
5377
5401
  /* @__PURE__ */ u("div", { className: "kui-ribbon-tabs", role: "tablist", children: e.map((l) => /* @__PURE__ */ u("button", { type: "button", role: "tab", className: "kui-ribbon-tab", "aria-selected": l.id === t, hidden: a !== null && !a.has(l.id), onClick: () => n(l.id), "data-tab": l.id, "data-testid": `ribbon-tab-${l.id}`, "data-kit-ui-id": Ye(l), children: l.label }, l.id)) }),
5378
5402
  c.length > 0 ? /* @__PURE__ */ u(
5379
5403
  lt,
@@ -5390,7 +5414,7 @@ function Ad(e, t) {
5390
5414
  }
5391
5415
  function Ed({ tab: e }) {
5392
5416
  const [t, n] = B(!1), r = R(null), i = be(), { t: o } = te(), a = i.state(Ye(e));
5393
- return /* @__PURE__ */ M("span", { ref: r, style: { display: "inline-flex" }, children: [
5417
+ return /* @__PURE__ */ T("span", { ref: r, style: { display: "inline-flex" }, children: [
5394
5418
  /* @__PURE__ */ u("button", { type: "button", className: "kui-menu-bar-item", "aria-expanded": t, "aria-haspopup": "dialog", onClick: () => n((s) => !s), "data-testid": `ribbon-tab-${e.id}`, "data-kit-ui-id": Ye(e), children: e.label }),
5395
5419
  /* @__PURE__ */ u(Eo, { open: t, anchor: r, onClose: () => n(!1), label: e.label, className: "kui-drop-ribbon", testId: `ribbon-drop-${e.id}`, children: /* @__PURE__ */ u(Et, { className: "kui-drop-ribbon-strip", panelClassName: "kui-ribbon-panel", resetKey: e.id, labels: { start: o("ribbonScrollStart"), end: o("ribbonScrollEnd") }, testId: `ribbon-drop-${e.id}-scroll`, children: /* @__PURE__ */ u("fieldset", { className: "kui-element", disabled: a.disabled, children: /* @__PURE__ */ u(vt.Provider, { value: "full", children: e.ribbon }) }) }) })
5396
5420
  ] });
@@ -5398,7 +5422,7 @@ function Ed({ tab: e }) {
5398
5422
  function Od({ tabs: e, menus: t }) {
5399
5423
  const { t: n, testId: r } = te();
5400
5424
  return /* @__PURE__ */ u("nav", { className: "kui-menu-nav", "aria-label": n("menuBar"), "data-testid": `${r}-menu-bar`, children: /* @__PURE__ */ u(Et, { className: "kui-menu-strip", panelClassName: "kui-menu-bar", labels: { start: n("menusScrollStart"), end: n("menusScrollEnd") }, testId: `${r}-menu-bar-scroll`, children: e.map(
5401
- (i) => i.menu ? /* @__PURE__ */ M(
5425
+ (i) => i.menu ? /* @__PURE__ */ T(
5402
5426
  lt,
5403
5427
  {
5404
5428
  trigger: ({ toggle: o, open: a }) => /* @__PURE__ */ u("button", { type: "button", className: "kui-menu-bar-item", "aria-expanded": a, onClick: o, "data-testid": `${r}-menu-${i.id}`, "data-kit-ui-id": `menu:${i.id}`, children: i.label }),
@@ -5428,76 +5452,76 @@ function Ld(e) {
5428
5452
  function Lr(e) {
5429
5453
  return Fn(e).reduce((t, n) => t + n.offsetWidth, 0);
5430
5454
  }
5431
- function Nd({ mode: e, tab: t, nodes: n, panel: r, measure: i }) {
5432
- const { t: o } = te(), a = be(), s = t.ribbon ?? (t.menu ? /* @__PURE__ */ u(wd, { tab: t, nodes: n }) : null), d = H((y) => o("lineMore", { group: y }), [o]), c = e === "line", l = `${e}:${t.id}`, [p, h] = B({ key: l, level: 0, groups: [], fresh: 0 }), f = p.key === l ? p.level : 0, g = p.key === l ? p.groups : [], w = pe(() => c ? mn : Rd(f, g), [g, f, c]), b = R({ width: 0, content: 0 }), m = R(null);
5455
+ function Pd({ mode: e, tab: t, nodes: n, panel: r, measure: i }) {
5456
+ const { t: o } = te(), a = be(), s = t.ribbon ?? (t.menu ? /* @__PURE__ */ u(wd, { tab: t, nodes: n }) : null), d = K((y) => o("lineMore", { group: y }), [o]), c = e === "line", l = `${e}:${t.id}`, [p, h] = B({ key: l, level: 0, groups: [], fresh: 0 }), f = p.key === l ? p.level : 0, g = p.key === l ? p.groups : [], w = pe(() => c ? mn : Rd(f, g), [g, f, c]), b = R({ width: 0, content: 0 }), m = R(null);
5433
5457
  return Te(() => {
5434
5458
  const y = r.current;
5435
5459
  if (!c && y) {
5436
- const I = Ld(y);
5437
- if (y.scrollWidth - y.clientWidth > 1 && f < Dd(I.length)) {
5438
- h((Y) => ({ key: l, level: f + 1, groups: I, fresh: Y.fresh }));
5460
+ const M = Ld(y);
5461
+ if (y.scrollWidth - y.clientWidth > 1 && f < Dd(M.length)) {
5462
+ h((G) => ({ key: l, level: f + 1, groups: M, fresh: G.fresh }));
5439
5463
  return;
5440
5464
  }
5441
5465
  b.current = { width: y.clientWidth, content: Lr(y) };
5442
5466
  const E = m.current;
5443
5467
  if (E) {
5444
5468
  E.disconnect(), E.observe(y);
5445
- for (const Y of Fn(y)) E.observe(Y);
5469
+ for (const G of Fn(y)) E.observe(G);
5446
5470
  }
5447
5471
  }
5448
5472
  i(e, y);
5449
5473
  }), Te(() => {
5450
5474
  const y = r.current;
5451
5475
  if (c || !y || typeof ResizeObserver > "u") return;
5452
- const I = new ResizeObserver(() => {
5453
- const N = b.current;
5454
- (y.clientWidth > N.width + 1 || Math.abs(Lr(y) - N.content) > 1) && h((E) => ({ key: l, level: 0, groups: E.groups, fresh: E.fresh + 1 }));
5476
+ const M = new ResizeObserver(() => {
5477
+ const P = b.current;
5478
+ (y.clientWidth > P.width + 1 || Math.abs(Lr(y) - P.content) > 1) && h((E) => ({ key: l, level: 0, groups: E.groups, fresh: E.fresh + 1 }));
5455
5479
  });
5456
- return m.current = I, I.observe(y), () => {
5457
- I.disconnect(), m.current = null;
5480
+ return m.current = M, M.observe(y), () => {
5481
+ M.disconnect(), m.current = null;
5458
5482
  };
5459
5483
  }, [l, c, r]), s ? /* @__PURE__ */ u(Et, { className: c ? "kui-line" : "kui-ribbon-body", panelClassName: c ? "kui-line-panel" : "kui-ribbon-panel", role: "tabpanel", resetKey: t.id, labels: { start: o("ribbonScrollStart"), end: o("ribbonScrollEnd") }, testId: "ribbon-scroll", panelRef: r, children: /* @__PURE__ */ u("fieldset", { className: "kui-element", disabled: a.state(Ye(t)).disabled, children: /* @__PURE__ */ u(Ao.Provider, { value: d, children: /* @__PURE__ */ u(vt.Provider, { value: c ? "line" : "full", children: /* @__PURE__ */ u(Yt.Provider, { value: w, children: s }) }) }) }) }) : null;
5460
5484
  }
5461
5485
  function Bu({ tabs: e, tab: t, onTab: n, defaultTab: r, title: i, actions: o, options: a, rail: s, sidebar: d, panels: c, focusTool: l, statusBar: p = !0, children: h, ...f }) {
5462
- const g = te(), { host: w, phrase: b, testId: m } = g, y = be(), I = R(null), N = R(null), E = w.readOnly === !0, Y = xd(), U = y.config.add, V = pe(() => {
5463
- if (!e.some((G) => G.menu)) return e;
5464
- const P = U.map((G) => G.place).filter((G) => G.startsWith("menu:") && !G.includes("/")).map((G) => G.slice(5)).filter((G, ue, ye) => ye.indexOf(G) === ue && !e.some((Ie) => Ie.id === G));
5465
- return P.length ? [...e, ...P.map((G) => ({ id: G, label: b(G), menu: { rows: [] } }))] : e;
5466
- }, [U, b, e]), j = pd(V), D = V.filter((P) => y.state(Ye(P)).hidden || E && !P.view ? !1 : !P.menu || P.ribbon ? !0 : (j.get(P.id)?.length ?? 0) > 0 || (P.menu.before?.length ?? 0) > 0 || y.buttons(`menu:${P.id}`).length > 0), Z = Sd(w, D.length > 0), [Q, fe] = B(r ?? null), ce = t ?? Q, k = D.find((P) => P.id === ce) ?? D.find((P) => P.id === r) ?? D.find((P) => P.id.toLowerCase() !== "file") ?? D[0] ?? null, O = k?.id ?? null, q = H(
5467
- (P) => {
5468
- fe(P), n?.(P);
5486
+ const g = te(), { host: w, phrase: b, testId: m } = g, y = be(), M = R(null), P = R(null), E = w.readOnly === !0, G = xd(), q = y.config.add, Y = pe(() => {
5487
+ if (!e.some((j) => j.menu)) return e;
5488
+ const N = q.map((j) => j.place).filter((j) => j.startsWith("menu:") && !j.includes("/")).map((j) => j.slice(5)).filter((j, ue, ye) => ye.indexOf(j) === ue && !e.some((Ie) => Ie.id === j));
5489
+ return N.length ? [...e, ...N.map((j) => ({ id: j, label: b(j), menu: { rows: [] } }))] : e;
5490
+ }, [q, b, e]), U = pd(Y), D = Y.filter((N) => y.state(Ye(N)).hidden || E && !N.view ? !1 : !N.menu || N.ribbon ? !0 : (U.get(N.id)?.length ?? 0) > 0 || (N.menu.before?.length ?? 0) > 0 || y.buttons(`menu:${N.id}`).length > 0), Z = Sd(w, D.length > 0), [Q, fe] = B(r ?? null), ce = t ?? Q, k = D.find((N) => N.id === ce) ?? D.find((N) => N.id === r) ?? D.find((N) => N.id.toLowerCase() !== "file") ?? D[0] ?? null, O = k?.id ?? null, H = K(
5491
+ (N) => {
5492
+ fe(N), n?.(N);
5469
5493
  },
5470
5494
  [n]
5471
5495
  );
5472
5496
  Te(() => {
5473
5497
  t !== void 0 && O !== null && O !== t && n?.(O);
5474
5498
  }, [O, n, t]);
5475
- const x = Cd(I, Z.chosen, O ?? "", Z.allowed), C = Z.focus ? "focus" : x.effective, W = (P) => (Nt() ? P.metaKey : P.ctrlKey) && !P.shiftKey && !P.altKey && P.code === "Backslash" ? !Z.allowed.includes("focus") || y.state("action:mode").denied ? !1 : (Z.toggleFocus(), !0) : !1, _ = () => Z.focus ? (Z.exitFocus(), !0) : !1, T = C === "focus", K = R(T);
5499
+ const x = Cd(M, Z.chosen, O ?? "", Z.allowed), C = Z.focus ? "focus" : x.effective, W = (N) => (Pt() ? N.metaKey : N.ctrlKey) && !N.shiftKey && !N.altKey && N.code === "Backslash" ? !Z.allowed.includes("focus") || y.state("action:mode").denied ? !1 : (Z.toggleFocus(), !0) : !1, V = () => Z.focus ? (Z.exitFocus(), !0) : !1, I = C === "focus", _ = R(I);
5476
5500
  Te(() => {
5477
- if (K.current === T) return;
5478
- K.current = T;
5479
- const P = document.activeElement;
5480
- if (P && P !== document.body && P.isConnected) return;
5481
- ((T ? null : I.current?.querySelector(".kui-mode-button")) ?? I.current)?.focus({ preventScroll: !0 });
5482
- }, [T]);
5483
- const ne = T ? /* @__PURE__ */ u(cd, { tool: l, onExit: Z.exitFocus }) : /* @__PURE__ */ M(Ce, { children: [
5484
- /* @__PURE__ */ M("div", { className: "kui-frame-top", "data-testid": `${m}-top-bar`, children: [
5501
+ if (_.current === I) return;
5502
+ _.current = I;
5503
+ const N = document.activeElement;
5504
+ if (N && N !== document.body && N.isConnected) return;
5505
+ ((I ? null : M.current?.querySelector(".kui-mode-button")) ?? M.current)?.focus({ preventScroll: !0 });
5506
+ }, [I]);
5507
+ const ne = I ? /* @__PURE__ */ u(cd, { tool: l, onExit: Z.exitFocus }) : /* @__PURE__ */ T(Ce, { children: [
5508
+ /* @__PURE__ */ T("div", { className: "kui-frame-top", "data-testid": `${m}-top-bar`, children: [
5485
5509
  i ? /* @__PURE__ */ u("div", { className: "kui-frame-title", children: i }) : null,
5486
- C === "menus" ? /* @__PURE__ */ u(Od, { tabs: D, menus: j }) : /* @__PURE__ */ u(Td, { tabs: D, active: O, onTab: q }),
5510
+ C === "menus" ? /* @__PURE__ */ u(Od, { tabs: D, menus: U }) : /* @__PURE__ */ u(Td, { tabs: D, active: O, onTab: H }),
5487
5511
  /* @__PURE__ */ u("div", { className: "kui-ribbon-end", children: /* @__PURE__ */ u(fc, { before: o, mode: /* @__PURE__ */ u(bd, { display: Z, shown: C, areas: D.length > 0 }) }) })
5488
5512
  ] }),
5489
- (C === "line" || C === "classic") && k ? /* @__PURE__ */ u(Nd, { mode: C, tab: k, nodes: j.get(k.id) ?? [], panel: N, measure: x.measure }) : null,
5513
+ (C === "line" || C === "classic") && k ? /* @__PURE__ */ u(Pd, { mode: C, tab: k, nodes: U.get(k.id) ?? [], panel: P, measure: x.measure }) : null,
5490
5514
  a ? /* @__PURE__ */ u(bc, { children: a }) : null
5491
5515
  ] });
5492
- return /* @__PURE__ */ u(ao.Provider, { value: C, children: /* @__PURE__ */ u(so.Provider, { value: Z, children: /* @__PURE__ */ u(pc, { ...f, statusBar: p && !T, top: ne, frame: { ref: I, mode: C, chosen: Z.chosen, touch: Y, viewOnly: E, keyDown: W, escape: _ }, children: /* @__PURE__ */ M("div", { className: "kui-frame-body", children: [
5493
- s && !E && !T ? s : null,
5494
- d && !T ? d : null,
5516
+ return /* @__PURE__ */ u(ao.Provider, { value: C, children: /* @__PURE__ */ u(so.Provider, { value: Z, children: /* @__PURE__ */ u(pc, { ...f, statusBar: p && !I, top: ne, frame: { ref: M, mode: C, chosen: Z.chosen, touch: G, viewOnly: E, keyDown: W, escape: V }, children: /* @__PURE__ */ T("div", { className: "kui-frame-body", children: [
5517
+ s && !E && !I ? s : null,
5518
+ d && !I ? d : null,
5495
5519
  /* @__PURE__ */ u("div", { className: "kui-frame-main", children: h }),
5496
- c && !T ? c : null
5520
+ c && !I ? c : null
5497
5521
  ] }) }) }) });
5498
5522
  }
5499
- const Pd = new ArrayBuffer(0);
5500
- function Nr(e) {
5523
+ const Nd = new ArrayBuffer(0);
5524
+ function Pr(e) {
5501
5525
  return e.slice().buffer;
5502
5526
  }
5503
5527
  function Fd(e) {
@@ -5519,13 +5543,13 @@ class _u {
5519
5543
  push() {
5520
5544
  this.enqueue(async () => {
5521
5545
  const t = this.page.replica(), n = t.version();
5522
- this.pushed.includes(n) || (await this.engine.importChanges(Nr(t.exportChanges(this.pushed)), Pd), this.pushed = n);
5546
+ this.pushed.includes(n) || (await this.engine.importChanges(Pr(t.exportChanges(this.pushed)), Nd), this.pushed = n);
5523
5547
  });
5524
5548
  }
5525
5549
  /** Takes the worker's changes the page does not have yet. */
5526
5550
  pull() {
5527
5551
  this.enqueue(async () => {
5528
- const t = this.page.replica(), { changes: n } = await this.engine.exportChanges(Nr(t.version().encode()));
5552
+ const t = this.page.replica(), { changes: n } = await this.engine.exportChanges(Pr(t.version().encode()));
5529
5553
  if (this.closed || this.page.replica() !== t) return;
5530
5554
  const r = t.version(), i = this.pushed.includes(r), o = new Uint8Array(n);
5531
5555
  this.page.importChanges ? this.page.importChanges(o) : t.importChanges(o), i && (this.pushed = t.version()), t.version().equals(r) || this.pulled();
@@ -5587,7 +5611,7 @@ function Bd(e, t, n, r, i) {
5587
5611
  const d = e.measureText(r).width + o.padX * 2, c = o.height ?? Math.round(zd(a) * 1.2) + o.padY * 2, l = o.align === "center" ? t - d / 2 : t;
5588
5612
  e.fillStyle = s, e.beginPath(), e.roundRect(l, n, d, c, o.radius), e.fill(), e.fillStyle = o.color ?? (s === i.surface ? i.ink : i.surface), e.textBaseline = "middle", e.fillText(r, l + o.padX, n + c / 2);
5589
5613
  }
5590
- function Pr(e, t, n, r, i) {
5614
+ function Nr(e, t, n, r, i) {
5591
5615
  switch (r.kind) {
5592
5616
  case "marquee": {
5593
5617
  const o = i.marquee, a = t(r.x0, r.y0), s = t(r.x1, r.y1);
@@ -5663,11 +5687,11 @@ function _d(e, t = hn, n) {
5663
5687
  n && (l = n(s, { context: r, toScreen: i, view: o, style: t, overlays: e, index: d, frame: a, drawDefault: (h = s) => {
5664
5688
  r.save();
5665
5689
  try {
5666
- c(), Pr(r, i, o, h, t);
5690
+ c(), Nr(r, i, o, h, t);
5667
5691
  } finally {
5668
5692
  r.restore();
5669
5693
  }
5670
- } }) === !0), l || (r.restore(), r.save(), c(), Pr(r, i, o, s, t));
5694
+ } }) === !0), l || (r.restore(), r.save(), c(), Nr(r, i, o, s, t));
5671
5695
  } finally {
5672
5696
  r.restore();
5673
5697
  }
@@ -5684,35 +5708,35 @@ function Ku(e, t, n, r) {
5684
5708
  g.current = r;
5685
5709
  const w = R(d);
5686
5710
  w.current = d;
5687
- const b = R(0), m = R(null), [y, I] = B(0), N = R(r.initial), E = R(null), Y = Object.keys(r.hostTools ?? {}).find((v) => r.hostTools?.[v] === Re) ?? Re.id;
5688
- let U = a;
5689
- d(a) && (U = i.find((v) => !r.hidden?.has(v.id) && !d(v.id))?.id ?? Y, i.length && U !== a && s(U));
5690
- const V = r.hostTools?.[U] ?? (U === Re.id && !i.some((v) => v.id === U) ? Re : void 0);
5691
- N.current = U;
5692
- const j = R(/* @__PURE__ */ new Set());
5693
- j.current = new Set(Object.keys(r.hostTools ?? {})), i.some((v) => v.id === Re.id) || j.current.add(Re.id);
5694
- const D = H((v) => {
5711
+ const b = R(0), m = R(null), [y, M] = B(0), P = R(r.initial), E = R(null), G = Object.keys(r.hostTools ?? {}).find((v) => r.hostTools?.[v] === Re) ?? Re.id;
5712
+ let q = a;
5713
+ d(a) && (q = i.find((v) => !r.hidden?.has(v.id) && !d(v.id))?.id ?? G, i.length && q !== a && s(q));
5714
+ const Y = r.hostTools?.[q] ?? (q === Re.id && !i.some((v) => v.id === q) ? Re : void 0);
5715
+ P.current = q;
5716
+ const U = R(/* @__PURE__ */ new Set());
5717
+ U.current = new Set(Object.keys(r.hostTools ?? {})), i.some((v) => v.id === Re.id) || U.current.add(Re.id);
5718
+ const D = K((v) => {
5695
5719
  if (w.current(v)) return;
5696
5720
  const z = ++b.current;
5697
- m.current = z, N.current = v, I(z), s(v);
5698
- }, []), Z = H((v) => c(() => v), []), Q = R(1), fe = R(null), ce = R(!1), k = R([]), O = R(null), q = H((v, z) => {
5721
+ m.current = z, P.current = v, M(z), s(v);
5722
+ }, []), Z = K((v) => c(() => v), []), Q = R(1), fe = R(null), ce = R(!1), k = R([]), O = R(null), H = K((v, z) => {
5699
5723
  if (!v) return;
5700
5724
  O.current = v, p(v);
5701
5725
  let S = null;
5702
5726
  for (const $ of v.requests)
5703
5727
  $.kind === "switchTool" ? (m.current === null || z === m.current) && !w.current($.id) && (S = $.id) : $.kind === "status" ? f($.text) : g.current.onDialog?.($.name, $.params);
5704
- S !== null && S !== N.current && (N.current = S, E.current = { id: S, serial: b.current }, j.current.has(S) || k.current.unshift({ name: "selectTool", args: [S, Q.current], settled: !0, coalesce: !1, selection: z }), s(S));
5705
- }, []), x = R(!1), C = R(null), W = H((v, z) => {
5728
+ S !== null && S !== P.current && (P.current = S, E.current = { id: S, serial: b.current }, U.current.has(S) || k.current.unshift({ name: "selectTool", args: [S, Q.current], settled: !0, coalesce: !1, selection: z }), s(S));
5729
+ }, []), x = R(!1), C = R(null), W = K((v, z) => {
5706
5730
  const S = document.activeElement ?? document.body;
5707
5731
  x.current = !0, C.current = 0;
5708
5732
  try {
5709
- S.dispatchEvent(new KeyboardEvent("keydown", { key: v, code: Ud(v), shiftKey: z, bubbles: !0, cancelable: !0 }));
5733
+ S.dispatchEvent(new KeyboardEvent("keydown", { key: v, code: qd(v), shiftKey: z, bubbles: !0, cancelable: !0 }));
5710
5734
  } finally {
5711
5735
  x.current = !1, C.current = null;
5712
5736
  }
5713
- }, []), _ = H((v) => {
5737
+ }, []), V = K((v) => {
5714
5738
  C.current === null ? k.current.push(v) : k.current.splice(C.current++, 0, v);
5715
- }, []), T = H(async () => {
5739
+ }, []), I = K(async () => {
5716
5740
  if (!ce.current) {
5717
5741
  ce.current = !0;
5718
5742
  try {
@@ -5722,91 +5746,91 @@ function Ku(e, t, n, r) {
5722
5746
  continue;
5723
5747
  }
5724
5748
  if ("key" in v) {
5725
- v.key.length > 1 ? W(v.key, v.shift) : O.current?.wantsText ? q(await e("toolText", [v.key, Q.current], !0).catch(() => null)) : g.current.onDeferredKey ? g.current.onDeferredKey(v.key, v.shift) : W(v.key, v.shift);
5749
+ v.key.length > 1 ? W(v.key, v.shift) : O.current?.wantsText ? H(await e("toolText", [v.key, Q.current], !0).catch(() => null)) : g.current.onDeferredKey ? g.current.onDeferredKey(v.key, v.shift) : W(v.key, v.shift);
5726
5750
  continue;
5727
5751
  }
5728
- q(await e(v.name, v.args, v.settled).catch(() => null), v.selection), v.selection === m.current && (m.current = null);
5752
+ H(await e(v.name, v.args, v.settled).catch(() => null), v.selection), v.selection === m.current && (m.current = null);
5729
5753
  }
5730
5754
  } finally {
5731
5755
  ce.current = !1;
5732
5756
  }
5733
5757
  }
5734
- }, [q, W, e]), K = H((v, z, S, $ = !1, F) => {
5758
+ }, [H, W, e]), _ = K((v, z, S, $ = !1, F) => {
5735
5759
  const X = k.current[k.current.length - 1];
5736
- $ && C.current === null && X && "name" in X && X.coalesce && X.name === v ? k.current[k.current.length - 1] = { name: v, args: z, settled: S, coalesce: $, selection: F } : _({ name: v, args: z, settled: S, coalesce: $, selection: F }), T();
5737
- }, [_, T]), ne = H((v) => !ce.current && !k.current.length ? v() : new Promise((z, S) => {
5738
- _({ work: () => v().then(z, S) }), T();
5739
- }), [_, T]);
5760
+ $ && C.current === null && X && "name" in X && X.coalesce && X.name === v ? k.current[k.current.length - 1] = { name: v, args: z, settled: S, coalesce: $, selection: F } : V({ name: v, args: z, settled: S, coalesce: $, selection: F }), I();
5761
+ }, [V, I]), ne = K((v) => !ce.current && !k.current.length ? v() : new Promise((z, S) => {
5762
+ V({ work: () => v().then(z, S) }), I();
5763
+ }), [V, I]);
5740
5764
  J(() => wl(e, ne), [ne, e]), J(() => {
5741
5765
  t && e("tools").then((v) => o(v ?? []));
5742
5766
  }, [t, e]);
5743
- const P = !!V;
5767
+ const N = !!Y;
5744
5768
  J(() => {
5745
5769
  if (!t) {
5746
5770
  E.current = null;
5747
5771
  return;
5748
5772
  }
5749
- if (P) return;
5773
+ if (N) return;
5750
5774
  const v = E.current;
5751
- E.current = null, !(v?.id === U && v.serial === y) && K("selectTool", [U, Q.current], !0, !1, y);
5752
- }, [U, P, t, y, K]), J(() => {
5753
- if (!t || P) return;
5775
+ E.current = null, !(v?.id === q && v.serial === y) && _("selectTool", [q, Q.current], !0, !1, y);
5776
+ }, [q, N, t, y, _]), J(() => {
5777
+ if (!t || N) return;
5754
5778
  const v = fe.current ?? { x: 0, y: 0 };
5755
- K("toolState", [v.x, v.y, "{}", Q.current], !1, !0);
5779
+ _("toolState", [v.x, v.y, "{}", Q.current], !1, !0);
5756
5780
  }, [n.revision, t]);
5757
- const G = H((v, z, S, $, F = !1) => {
5758
- Q.current = S, fe.current = { x: z.x, y: z.y }, K("pointer", [JSON.stringify({ action: v, x: z.x, y: z.y, mods: Gt(z), pressure: z.pressure, zoom: S })], $, F);
5759
- }, [K]), ue = pe(() => V ?? {
5760
- id: U,
5781
+ const j = K((v, z, S, $, F = !1) => {
5782
+ Q.current = S, fe.current = { x: z.x, y: z.y }, _("pointer", [JSON.stringify({ action: v, x: z.x, y: z.y, mods: Gt(z), pressure: z.pressure, zoom: S })], $, F);
5783
+ }, [_]), ue = pe(() => Y ?? {
5784
+ id: q,
5761
5785
  cursor: l?.cursor || "default",
5762
- begin: (v, { viewport: z }) => (G("down", v, z.view.zoom, !1), {
5763
- move: (S, $) => G("drag", S, $.viewport.view.zoom, !1, !0),
5764
- end: (S, $) => G("up", S, $.viewport.view.zoom, !0),
5786
+ begin: (v, { viewport: z }) => (j("down", v, z.view.zoom, !1), {
5787
+ move: (S, $) => j("drag", S, $.viewport.view.zoom, !1, !0),
5788
+ end: (S, $) => j("up", S, $.viewport.view.zoom, !0),
5765
5789
  // An interrupted pointer must not commit the press as a click. Keep cancellation
5766
5790
  // in the same queue as its pending press/moves and the person's next gesture.
5767
- cancel: (S) => K("toolKey", ["Escape", "{}", S.viewport.view.zoom], !0)
5791
+ cancel: (S) => _("toolKey", ["Escape", "{}", S.viewport.view.zoom], !0)
5768
5792
  }),
5769
- hover: (v, { viewport: z }) => G("move", v, z.view.zoom, !1, !0),
5770
- doubleClick: (v, { viewport: z }) => G("doubleClick", v, z.view.zoom, !0)
5771
- }, [U, V, G, l?.cursor, K]), ye = l?.overlays, { overlayStyle: Ie, drawOverlay: Ne } = r, We = qd(), A = pe(() => {
5793
+ hover: (v, { viewport: z }) => j("move", v, z.view.zoom, !1, !0),
5794
+ doubleClick: (v, { viewport: z }) => j("doubleClick", v, z.view.zoom, !0)
5795
+ }, [q, Y, j, l?.cursor, _]), ye = l?.overlays, { overlayStyle: Ie, drawOverlay: Pe } = r, We = Ud(), A = pe(() => {
5772
5796
  const v = Wd(Ie);
5773
5797
  return We && !Ie?.accent ? { ...v, accent: We } : v;
5774
5798
  }, [We, Ie]), L = pe(
5775
- () => ye?.length && !V ? Jl(_d(ye, A, Ne)) : null,
5776
- [Ne, V, ye, A]
5777
- ), re = H((v) => {
5778
- if (V || !v.shiftKey && !v.altKey && !v.metaKey && !v.ctrlKey && v.key === "Escape" && g.current.escapable && !g.current.escapable()) return !1;
5799
+ () => ye?.length && !Y ? Jl(_d(ye, A, Pe)) : null,
5800
+ [Pe, Y, ye, A]
5801
+ ), re = K((v) => {
5802
+ if (Y || !v.shiftKey && !v.altKey && !v.metaKey && !v.ctrlKey && v.key === "Escape" && g.current.escapable && !g.current.escapable()) return !1;
5779
5803
  const S = v.metaKey || v.ctrlKey, $ = v.key.length === 1 || Hd.has(v.key);
5780
5804
  if (!S && !v.altKey && $ && !x.current && (ce.current || k.current.length))
5781
- return k.current.push({ key: v.key, shift: v.shiftKey }), T(), !0;
5805
+ return k.current.push({ key: v.key, shift: v.shiftKey }), I(), !0;
5782
5806
  const F = O.current;
5783
5807
  if (!F) return !1;
5784
5808
  if (F.wantsText && !S) {
5785
- if (v.key.length === 1) K("toolText", [v.key, Q.current], !0);
5786
- else if (Fr.has(v.key)) K("toolKey", [v.key, JSON.stringify(Gt({ shift: v.shiftKey, alt: v.altKey, meta: !1 })), Q.current], !0);
5809
+ if (v.key.length === 1) _("toolText", [v.key, Q.current], !0);
5810
+ else if (Fr.has(v.key)) _("toolKey", [v.key, JSON.stringify(Gt({ shift: v.shiftKey, alt: v.altKey, meta: !1 })), Q.current], !0);
5787
5811
  else return !1;
5788
5812
  return !0;
5789
5813
  }
5790
- return F.busy && Fr.has(v.key) ? (K("toolKey", [v.key, JSON.stringify(Gt({ shift: v.shiftKey, alt: v.altKey, meta: S })), Q.current], !0), !0) : !1;
5791
- }, [V, T, K]), ie = H((v, z) => {
5814
+ return F.busy && Fr.has(v.key) ? (_("toolKey", [v.key, JSON.stringify(Gt({ shift: v.shiftKey, alt: v.altKey, meta: S })), Q.current], !0), !0) : !1;
5815
+ }, [Y, I, _]), ie = K((v, z) => {
5792
5816
  const S = (z ? `Shift+${v}` : v).toLowerCase(), F = i.filter((ee) => !g.current.hidden?.has(ee.id)).filter((ee) => ee.shortcut?.toLowerCase() === S);
5793
5817
  if (!F.length) return null;
5794
- const X = F.findIndex((ee) => ee.id === U);
5818
+ const X = F.findIndex((ee) => ee.id === q);
5795
5819
  return F[(X + 1) % F.length].id;
5796
- }, [U, i]), ae = H(() => {
5797
- if (P) return;
5820
+ }, [q, i]), ae = K(() => {
5821
+ if (N) return;
5798
5822
  const v = fe.current ?? { x: 0, y: 0 };
5799
- K("toolState", [v.x, v.y, "{}", Q.current], !1, !0);
5800
- }, [P, K]), se = H((v) => {
5801
- if (!Number.isFinite(v) || v <= 0 || Math.abs(v - Q.current) < 1e-9 || (Q.current = v, !t || P || !O.current)) return;
5823
+ _("toolState", [v.x, v.y, "{}", Q.current], !1, !0);
5824
+ }, [N, _]), se = K((v) => {
5825
+ if (!Number.isFinite(v) || v <= 0 || Math.abs(v - Q.current) < 1e-9 || (Q.current = v, !t || N || !O.current)) return;
5802
5826
  const z = fe.current ?? { x: 0, y: 0 };
5803
- K("toolState", [z.x, z.y, "{}", v], !1, !0);
5804
- }, [P, t, K]), ge = H((v) => {
5805
- v && K("toolText", [v, Q.current], !0);
5806
- }, [K]);
5827
+ _("toolState", [z.x, z.y, "{}", v], !1, !0);
5828
+ }, [N, t, _]), ge = K((v) => {
5829
+ v && _("toolText", [v, Q.current], !0);
5830
+ }, [_]);
5807
5831
  return {
5808
5832
  tools: i,
5809
- active: U,
5833
+ active: q,
5810
5834
  select: D,
5811
5835
  setDenied: Z,
5812
5836
  refresh: ae,
@@ -5815,18 +5839,18 @@ function Ku(e, t, n, r) {
5815
5839
  canvasTool: ue,
5816
5840
  decorate: L,
5817
5841
  status: h,
5818
- wantsText: !!l?.wantsText && !V,
5842
+ wantsText: !!l?.wantsText && !Y,
5819
5843
  keyDown: re,
5820
5844
  toolForKey: ie
5821
5845
  };
5822
5846
  }
5823
- function Ud(e) {
5847
+ function qd(e) {
5824
5848
  if (/^[a-z]$/i.test(e)) return `Key${e.toUpperCase()}`;
5825
5849
  if (/^[0-9]$/.test(e)) return `Digit${e}`;
5826
5850
  const t = { ".": "Period", ",": "Comma", "/": "Slash", ";": "Semicolon", "'": "Quote", "[": "BracketLeft", "]": "BracketRight", "-": "Minus", "=": "Equal", "`": "Backquote", "\\": "Backslash", " ": "Space" };
5827
5851
  return e === "Delete" || e === "Backspace" ? e : t[e] ?? "";
5828
5852
  }
5829
- function qd() {
5853
+ function Ud() {
5830
5854
  const e = () => typeof document > "u" ? null : getComputedStyle(document.documentElement).getPropertyValue("--kit-primary").trim() || null, [t, n] = B(e);
5831
5855
  return J(() => {
5832
5856
  if (typeof MutationObserver > "u") return;
@@ -5866,7 +5890,7 @@ function Gd(e, t) {
5866
5890
  const n = JSON.stringify(t.map((r) => r.id));
5867
5891
  (Wr.get(e) ?? "[]") !== n && (Wr.set(e, n), e.peer.notify("document/conflicts", { conflicts: t }));
5868
5892
  }
5869
- function Uu(e, t, n) {
5893
+ function qu(e, t, n) {
5870
5894
  J(() => {
5871
5895
  if (!t) return;
5872
5896
  let r = !1;
@@ -5924,7 +5948,7 @@ function Xd(e) {
5924
5948
  let t = Br.get(e);
5925
5949
  return t || Br.set(e, t = Vd(e)), t;
5926
5950
  }
5927
- function qu(e, t) {
5951
+ function Uu(e, t) {
5928
5952
  const n = Xd(e), r = He(n.subscribe, n.peers, n.peers), i = t ? JSON.stringify(t) : null;
5929
5953
  return J(() => {
5930
5954
  i !== null && n.set(JSON.parse(i));
@@ -6022,7 +6046,7 @@ function Kr({ placeholder: e, submit: t, cancel: n, labels: r, autoFocus: i, tes
6022
6046
  const p = a.trim();
6023
6047
  p && (t(p), s(""));
6024
6048
  };
6025
- return /* @__PURE__ */ M("form", { onSubmit: c, style: { display: "flex", flexDirection: "column", gap: 6 }, "data-testid": o, children: [
6049
+ return /* @__PURE__ */ T("form", { onSubmit: c, style: { display: "flex", flexDirection: "column", gap: 6 }, "data-testid": o, children: [
6026
6050
  /* @__PURE__ */ u(
6027
6051
  "textarea",
6028
6052
  {
@@ -6038,7 +6062,7 @@ function Kr({ placeholder: e, submit: t, cancel: n, labels: r, autoFocus: i, tes
6038
6062
  }
6039
6063
  }
6040
6064
  ),
6041
- /* @__PURE__ */ M("div", { style: ve.actions, children: [
6065
+ /* @__PURE__ */ T("div", { style: ve.actions, children: [
6042
6066
  n ? /* @__PURE__ */ u(me, { onClick: n, children: r.cancel }) : null,
6043
6067
  /* @__PURE__ */ u(me, { type: "submit", variant: "primary", disabled: !a.trim(), "data-testid": `${o}-send`, children: e === r.replyPlaceholder ? r.reply : r.comment })
6044
6068
  ] })
@@ -6050,12 +6074,12 @@ function Vu(e) {
6050
6074
  e.activeThread && a.current?.querySelector(`[data-thread="${CSS.escape(e.activeThread)}"]`)?.scrollIntoView({ block: "nearest" });
6051
6075
  }, [e.activeThread]);
6052
6076
  const s = e.formatTime ?? ((c) => c.replace("T", " ").replace(/(:\d\d)(\.\d+)?Z$/, "$1")), d = (c, l) => r !== null && c === r ? t.you : l || c;
6053
- return /* @__PURE__ */ M("div", { style: ve.panel, "data-testid": n, ref: a, children: [
6054
- /* @__PURE__ */ M("div", { style: ve.header, children: [
6077
+ return /* @__PURE__ */ T("div", { style: ve.panel, "data-testid": n, ref: a, children: [
6078
+ /* @__PURE__ */ T("div", { style: ve.header, children: [
6055
6079
  /* @__PURE__ */ u(Dt, { size: 16, strokeWidth: $e, "aria-hidden": "true" }),
6056
6080
  /* @__PURE__ */ u("span", { children: t.title })
6057
6081
  ] }),
6058
- e.pendingAnchor && i ? /* @__PURE__ */ M("div", { style: ve.card, children: [
6082
+ e.pendingAnchor && i ? /* @__PURE__ */ T("div", { style: ve.card, children: [
6059
6083
  e.anchorLabel?.(e.pendingAnchor) ? /* @__PURE__ */ u("div", { style: ve.muted, children: e.anchorLabel(e.pendingAnchor) }) : null,
6060
6084
  /* @__PURE__ */ u(
6061
6085
  Kr,
@@ -6072,7 +6096,7 @@ function Vu(e) {
6072
6096
  e.threads.length === 0 && !e.pendingAnchor ? /* @__PURE__ */ u("div", { style: ve.muted, children: t.empty }) : null,
6073
6097
  e.threads.map((c) => {
6074
6098
  const l = c.comments[0]?.author, p = r !== null && l === r, h = i && (!o || p), f = c.anchor && e.anchorLabel ? e.anchorLabel(c.anchor) : null;
6075
- return /* @__PURE__ */ M(
6099
+ return /* @__PURE__ */ T(
6076
6100
  "div",
6077
6101
  {
6078
6102
  "data-thread": c.id,
@@ -6082,8 +6106,8 @@ function Vu(e) {
6082
6106
  onClick: () => e.onActivate?.(c.id),
6083
6107
  children: [
6084
6108
  f ? /* @__PURE__ */ u("div", { style: ve.muted, children: f }) : null,
6085
- c.comments.map((g) => /* @__PURE__ */ M("div", { style: ve.comment, "data-testid": `${n}-comment`, "data-author": g.author, children: [
6086
- /* @__PURE__ */ M("div", { style: ve.byline, children: [
6109
+ c.comments.map((g) => /* @__PURE__ */ T("div", { style: ve.comment, "data-testid": `${n}-comment`, "data-author": g.author, children: [
6110
+ /* @__PURE__ */ T("div", { style: ve.byline, children: [
6087
6111
  /* @__PURE__ */ u("span", { style: ve.author, children: d(g.author, g.name) }),
6088
6112
  /* @__PURE__ */ u("span", { style: ve.muted, children: s(g.created) }),
6089
6113
  /* @__PURE__ */ u("span", { style: { flex: 1 } }),
@@ -6093,7 +6117,7 @@ function Vu(e) {
6093
6117
  ] }),
6094
6118
  /* @__PURE__ */ u("div", { style: ve.body, children: g.body })
6095
6119
  ] }, g.id)),
6096
- /* @__PURE__ */ M("div", { style: ve.actions, children: [
6120
+ /* @__PURE__ */ T("div", { style: ve.actions, children: [
6097
6121
  c.resolved ? /* @__PURE__ */ u("span", { style: { ...ve.muted, marginRight: "auto" }, children: t.resolved }) : null,
6098
6122
  !h && o && !p ? /* @__PURE__ */ u("span", { style: { ...ve.muted, marginRight: "auto" }, "data-testid": `${n}-history`, children: t.readOnlyHistory }) : null,
6099
6123
  h ? /* @__PURE__ */ u(
@@ -6166,7 +6190,7 @@ export {
6166
6190
  sh as BarSeparator,
6167
6191
  lh as Button,
6168
6192
  no as CHART_FORMATS,
6169
- Pn as CHART_KINDS,
6193
+ Nn as CHART_KINDS,
6170
6194
  Qc as CHART_MARKERS,
6171
6195
  at as COMMAND_FALLBACK_ICON,
6172
6196
  Qd as COMMENTS_PANEL_LABELS,
@@ -6175,8 +6199,8 @@ export {
6175
6199
  uh as CardHeader,
6176
6200
  id as ChartAxisDialog,
6177
6201
  sd as ChartDataDialog,
6178
- Pu as ChartDesignGroups,
6179
- Nu as ChartInsertMenu,
6202
+ Nu as ChartDesignGroups,
6203
+ Pu as ChartInsertMenu,
6180
6204
  od as ChartSeriesDialog,
6181
6205
  hh as Checkbox,
6182
6206
  fh as Choice,
@@ -6203,7 +6227,7 @@ export {
6203
6227
  hn as DEFAULT_OVERLAY_STYLE,
6204
6228
  en as DISPLAY_MODES,
6205
6229
  to as DRAWING_SHAPES,
6206
- qc as DRAWING_WARPS,
6230
+ Uc as DRAWING_WARPS,
6207
6231
  Wc as DRAWING_WEIGHTS,
6208
6232
  Th as Dialog,
6209
6233
  Ah as Disclosure,
@@ -6222,8 +6246,8 @@ export {
6222
6246
  Lh as GradientSlider,
6223
6247
  Re as HAND_TOOL,
6224
6248
  wr as HOST_ICONS,
6225
- Nh as Hint,
6226
- Ph as Histogram,
6249
+ Ph as Hint,
6250
+ Nh as Histogram,
6227
6251
  zt as HostButtons,
6228
6252
  Fh as ICON_STROKE,
6229
6253
  Gc as INK_TOOLS,
@@ -6242,8 +6266,8 @@ export {
6242
6266
  _h as LineChart,
6243
6267
  Kh as LineMoreLabelContext,
6244
6268
  Hh as MenuButton,
6245
- Uh as MenuItem,
6246
- qh as MenuSeparator,
6269
+ qh as MenuItem,
6270
+ Uh as MenuSeparator,
6247
6271
  jh as Modal,
6248
6272
  Gh as ModalBody,
6249
6273
  Yh as ModalClose,
@@ -6271,7 +6295,7 @@ export {
6271
6295
  mf as PopoverTrigger,
6272
6296
  pf as PreviewDialog,
6273
6297
  Oe as READ_ONLY_REASON,
6274
- Pe as READ_ONLY_RULES,
6298
+ Ne as READ_ONLY_RULES,
6275
6299
  Ll as RESERVED_SHORTCUTS,
6276
6300
  gf as RGB_IDENTITY,
6277
6301
  Mt as ReadOnlyError,
@@ -6297,8 +6321,8 @@ export {
6297
6321
  lu as TesseraIcons,
6298
6322
  Lf as TextInput,
6299
6323
  Dl as TextSink,
6300
- Nf as Textarea,
6301
- Pf as Thumbnail,
6324
+ Pf as Textarea,
6325
+ Nf as Thumbnail,
6302
6326
  Ff as TimecodeField,
6303
6327
  Wf as Toaster,
6304
6328
  vu as ToolButton,
@@ -6308,16 +6332,16 @@ export {
6308
6332
  _f as TooltipProvider,
6309
6333
  Kf as TooltipTrigger,
6310
6334
  Hf as TransportBar,
6311
- Uf as WORKSPACE_ACTIONS,
6335
+ qf as WORKSPACE_ACTIONS,
6312
6336
  _u as WorkerRelay,
6313
- qf as WorkspaceLayout,
6337
+ Uf as WorkspaceLayout,
6314
6338
  hu as ZOOM_TOOL,
6315
6339
  jf as ZoomControl,
6316
6340
  Gf as addCurvePoint,
6317
6341
  nr as applyTheme,
6318
6342
  Yf as automaticFloatingPosition,
6319
6343
  Iu as base64,
6320
- Pl as bindableShortcut,
6344
+ Nl as bindableShortcut,
6321
6345
  Vf as brandTokens,
6322
6346
  hd as catalogMenuTree,
6323
6347
  lo as catalogNames,
@@ -6340,14 +6364,14 @@ export {
6340
6364
  Qf as dockHeights,
6341
6365
  fu as dragRect,
6342
6366
  _d as drawEngineOverlays,
6343
- Pr as drawOverlayInStyle,
6367
+ Nr as drawOverlayInStyle,
6344
6368
  Yu as drawPresence,
6345
6369
  dl as editsDocument,
6346
6370
  th as fileErrorReason,
6347
6371
  em as formatTimecode,
6348
6372
  tm as hitCurvePoint,
6349
6373
  du as isFileChangedError,
6350
- Nt as isMac,
6374
+ Pt as isMac,
6351
6375
  nh as isOpenableUrl,
6352
6376
  Fi as isReadOnlyError,
6353
6377
  dn as kitLeases,
@@ -6364,7 +6388,7 @@ export {
6364
6388
  sm as meterLayout,
6365
6389
  Oi as modeStorageKey,
6366
6390
  lm as moveCurvePoint,
6367
- Pt as needsParams,
6391
+ Nt as needsParams,
6368
6392
  Hu as oneInFlight,
6369
6393
  rh as openErrorReason,
6370
6394
  cm as overflowOf,
@@ -6402,7 +6426,7 @@ export {
6402
6426
  nd as useChartSpec,
6403
6427
  Xu as useCommentAnchors,
6404
6428
  Im as useConfirm,
6405
- Uu as useConflictReport,
6429
+ qu as useConflictReport,
6406
6430
  Mm as useDialogFocus,
6407
6431
  Tm as useDismissableLayer,
6408
6432
  Au as useEngineQuery,
@@ -6418,7 +6442,7 @@ export {
6418
6442
  Eu as useLease,
6419
6443
  Ac as useLeases,
6420
6444
  Em as useMediaQuery,
6421
- qu as usePresence,
6445
+ Uu as usePresence,
6422
6446
  yu as useReadOnly,
6423
6447
  Gu as useRemoteCarets,
6424
6448
  ju as useRemoteSelections,
@@ -6430,5 +6454,5 @@ export {
6430
6454
  Zu as withPhrases,
6431
6455
  Lm as workspaceSlug,
6432
6456
  Fm as workspaceTree,
6433
- Nm as writeKitStore
6457
+ Pm as writeKitStore
6434
6458
  };