@june-ai/june-ui 0.2.10 → 0.2.12

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.
@@ -224,9 +224,16 @@ function createActionHandler(options) {
224
224
  };
225
225
  }
226
226
 
227
+ // src/features/document-editor/document-bridge.tsx
228
+
229
+
227
230
  // src/features/document-editor/document-context.ts
228
231
 
229
232
  var JuneDocumentContext = _react.createContext.call(void 0, {});
233
+ var DocumentEditorConfigContext = _react.createContext.call(void 0, {});
234
+ function useDocumentEditorConfig() {
235
+ return _react.useContext.call(void 0, DocumentEditorConfigContext);
236
+ }
230
237
  function useDocumentOptions() {
231
238
  return _react.useContext.call(void 0, JuneDocumentContext);
232
239
  }
@@ -608,9 +615,16 @@ function useDocumentBridge(options) {
608
615
 
609
616
  // src/features/document-editor/document-bridge.tsx
610
617
 
611
- function DocumentBridge({ children, ...options }) {
618
+ function DocumentBridge({
619
+ children,
620
+ documentEditor,
621
+ ...options
622
+ }) {
612
623
  const value = useDocumentBridge(options);
613
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, JuneDocumentContext.Provider, { value, children });
624
+ const presentation = _optionalChain([documentEditor, 'optionalAccess', _38 => _38.presentation]);
625
+ const width = _optionalChain([documentEditor, 'optionalAccess', _39 => _39.width]);
626
+ const config = _react.useMemo.call(void 0, () => ({ presentation, width }), [presentation, width]);
627
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, JuneDocumentContext.Provider, { value, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DocumentEditorConfigContext.Provider, { value: config, children }) });
614
628
  }
615
629
 
616
630
  // src/themes/theme-provider.tsx
@@ -663,7 +677,7 @@ function subscribe(onChange) {
663
677
  }
664
678
  function getSnapshot() {
665
679
  if (typeof window === "undefined") return "light";
666
- return _optionalChain([window, 'access', _38 => _38.matchMedia, 'optionalCall', _39 => _39(QUERY), 'optionalAccess', _40 => _40.matches]) ? "dark" : "light";
680
+ return _optionalChain([window, 'access', _40 => _40.matchMedia, 'optionalCall', _41 => _41(QUERY), 'optionalAccess', _42 => _42.matches]) ? "dark" : "light";
667
681
  }
668
682
  function getServerSnapshot() {
669
683
  return "light";
@@ -894,7 +908,7 @@ function attachOrphans(source) {
894
908
  if (!root) return `root = Card([${names.join(", ")}])
895
909
  ${text}`;
896
910
  const rawRhs = text.slice(root.rhsStart, root.end);
897
- const lead = _nullishCoalesce(_optionalChain([/^\s*/, 'access', _41 => _41.exec, 'call', _42 => _42(rawRhs), 'optionalAccess', _43 => _43[0]]), () => ( ""));
911
+ const lead = _nullishCoalesce(_optionalChain([/^\s*/, 'access', _43 => _43.exec, 'call', _44 => _44(rawRhs), 'optionalAccess', _45 => _45[0]]), () => ( ""));
898
912
  const spliced = spliceFirstArray(rawRhs.trim(), names);
899
913
  if (spliced !== null) {
900
914
  return text.slice(0, root.rhsStart) + lead + spliced + text.slice(root.end);
@@ -1242,8 +1256,8 @@ function resolveMixedContent(response, options = {}) {
1242
1256
  const parts = mixedContent && response ? splitResponse(response, { streaming: isStreaming, markdown }) : null;
1243
1257
  const raw = parts && !parts.pure ? parts.ui : typeof response === "string" ? foldMultilineStrings(response) : response;
1244
1258
  const ui = !repair || !mixedContent || isStreaming || typeof raw !== "string" || raw.length === 0 ? raw : normalizeProgram(raw);
1245
- const before = _nullishCoalesce(_optionalChain([parts, 'optionalAccess', _44 => _44.before]), () => ( []));
1246
- const after = _nullishCoalesce(_optionalChain([parts, 'optionalAccess', _45 => _45.after]), () => ( []));
1259
+ const before = _nullishCoalesce(_optionalChain([parts, 'optionalAccess', _46 => _46.before]), () => ( []));
1260
+ const after = _nullishCoalesce(_optionalChain([parts, 'optionalAccess', _47 => _47.after]), () => ( []));
1247
1261
  return {
1248
1262
  before,
1249
1263
  ui,
@@ -1271,7 +1285,7 @@ var JuneErrorBoundary = class extends _react.Component {
1271
1285
  return { error };
1272
1286
  }
1273
1287
  componentDidCatch(error, info) {
1274
- _optionalChain([this, 'access', _46 => _46.props, 'access', _47 => _47.onError, 'optionalCall', _48 => _48(error, info)]);
1288
+ _optionalChain([this, 'access', _48 => _48.props, 'access', _49 => _49.onError, 'optionalCall', _50 => _50(error, info)]);
1275
1289
  }
1276
1290
  componentDidUpdate(prev) {
1277
1291
  if (this.state.error && keysChanged(prev.resetKeys, this.props.resetKeys)) {
@@ -1320,6 +1334,7 @@ function JuneRenderer(props) {
1320
1334
  onError,
1321
1335
  onJuneError,
1322
1336
  documents,
1337
+ documentEditor,
1323
1338
  onResponseChange,
1324
1339
  responseChangeDelay,
1325
1340
  loadingFallback = null,
@@ -1332,37 +1347,37 @@ function JuneRenderer(props) {
1332
1347
  latest.current = { actions, confirmAction, parseActionEvent, onAction, onError, onJuneError };
1333
1348
  const handleAction = _react.useCallback.call(void 0, (event) => {
1334
1349
  const l = latest.current;
1335
- _optionalChain([l, 'access', _49 => _49.onAction, 'optionalCall', _50 => _50(event)]);
1350
+ _optionalChain([l, 'access', _51 => _51.onAction, 'optionalCall', _52 => _52(event)]);
1336
1351
  if (l.actions) {
1337
1352
  void runAction(event, {
1338
1353
  actions: l.actions,
1339
1354
  parseEvent: l.parseActionEvent,
1340
1355
  confirm: l.confirmAction,
1341
- onError: (e) => _optionalChain([l, 'access', _51 => _51.onJuneError, 'optionalCall', _52 => _52(e)])
1356
+ onError: (e) => _optionalChain([l, 'access', _53 => _53.onJuneError, 'optionalCall', _54 => _54(e)])
1342
1357
  });
1343
1358
  }
1344
1359
  }, []);
1345
1360
  const handleParserErrors = _react.useCallback.call(void 0, (errors) => {
1346
1361
  const list2 = Array.isArray(errors) ? errors : [];
1347
1362
  const l = latest.current;
1348
- _optionalChain([l, 'access', _53 => _53.onError, 'optionalCall', _54 => _54(list2)]);
1349
- const real = list2.filter((e) => _optionalChain([e, 'optionalAccess', _55 => _55.severity]) !== "warning");
1363
+ _optionalChain([l, 'access', _55 => _55.onError, 'optionalCall', _56 => _56(list2)]);
1364
+ const real = list2.filter((e) => _optionalChain([e, 'optionalAccess', _57 => _57.severity]) !== "warning");
1350
1365
  if (real.length > 0) {
1351
- _optionalChain([l, 'access', _56 => _56.onJuneError, 'optionalCall', _57 => _57(new (0, _chunkG6YPSE6Jcjs.JuneError)("PARSE_ERROR", `OpenUI reported ${real.length} error(s)`, { details: real }))]);
1366
+ _optionalChain([l, 'access', _58 => _58.onJuneError, 'optionalCall', _59 => _59(new (0, _chunkG6YPSE6Jcjs.JuneError)("PARSE_ERROR", `OpenUI reported ${real.length} error(s)`, { details: real }))]);
1352
1367
  }
1353
1368
  if (list2.length > 0 && !l.onError && !l.onJuneError) {
1354
1369
  console.warn("[june-ui] OpenUI reported errors:", list2);
1355
1370
  }
1356
1371
  }, []);
1357
1372
  const handleBoundaryError = _react.useCallback.call(void 0, (error, info) => {
1358
- _optionalChain([latest, 'access', _58 => _58.current, 'access', _59 => _59.onJuneError, 'optionalCall', _60 => _60(
1373
+ _optionalChain([latest, 'access', _60 => _60.current, 'access', _61 => _61.onJuneError, 'optionalCall', _62 => _62(
1359
1374
  new (0, _chunkG6YPSE6Jcjs.JuneError)("RENDER_ERROR", error.message, {
1360
1375
  cause: error,
1361
1376
  details: { componentStack: info.componentStack }
1362
1377
  })
1363
1378
  )]);
1364
1379
  }, []);
1365
- const handleDocumentError = _react.useCallback.call(void 0, (error) => _optionalChain([latest, 'access', _61 => _61.current, 'access', _62 => _62.onJuneError, 'optionalCall', _63 => _63(error)]), []);
1380
+ const handleDocumentError = _react.useCallback.call(void 0, (error) => _optionalChain([latest, 'access', _63 => _63.current, 'access', _64 => _64.onJuneError, 'optionalCall', _65 => _65(error)]), []);
1366
1381
  const runtime = _react.useMemo.call(void 0, () => ({ isStreaming }), [isStreaming]);
1367
1382
  const content = _react.useMemo.call(void 0,
1368
1383
  () => resolveMixedContent(response, { mixedContent, isStreaming, repair, markdown: textFormat === "markdown" }),
@@ -1376,6 +1391,7 @@ function JuneRenderer(props) {
1376
1391
  DocumentBridge,
1377
1392
  {
1378
1393
  documents,
1394
+ documentEditor,
1379
1395
  response,
1380
1396
  onResponseChange,
1381
1397
  responseChangeDelay,
@@ -1408,8 +1424,8 @@ function JuneRenderer(props) {
1408
1424
 
1409
1425
  var NAME = /^[A-Z][A-Za-z0-9_]*$/;
1410
1426
  function isZodObject(value) {
1411
- const def = _optionalChain([value, 'optionalAccess', _64 => _64._zod, 'optionalAccess', _65 => _65.def]);
1412
- return _optionalChain([def, 'optionalAccess', _66 => _66.type]) === "object";
1427
+ const def = _optionalChain([value, 'optionalAccess', _66 => _66._zod, 'optionalAccess', _67 => _67.def]);
1428
+ return _optionalChain([def, 'optionalAccess', _68 => _68.type]) === "object";
1413
1429
  }
1414
1430
  function validateComponentDefinition(definition) {
1415
1431
  const { name } = definition;
@@ -1472,7 +1488,7 @@ function isJuneComponent(value) {
1472
1488
  // src/engine/registry/component-registry.ts
1473
1489
 
1474
1490
  function nameOf(component) {
1475
- const name = _optionalChain([component, 'optionalAccess', _67 => _67.name]);
1491
+ const name = _optionalChain([component, 'optionalAccess', _69 => _69.name]);
1476
1492
  if (typeof name !== "string" || name.length === 0) {
1477
1493
  throw new (0, _chunkG6YPSE6Jcjs.JuneError)("LIBRARY_ERROR", "Every component needs a non-empty string name");
1478
1494
  }
@@ -1481,7 +1497,7 @@ function nameOf(component) {
1481
1497
  function slotsOf(component) {
1482
1498
  return isJuneComponent(component) ? component.june.slots : void 0;
1483
1499
  }
1484
- var isDev = () => typeof process !== "undefined" && _optionalChain([process, 'access', _68 => _68.env, 'optionalAccess', _69 => _69.NODE_ENV]) === "development";
1500
+ var isDev = () => typeof process !== "undefined" && _optionalChain([process, 'access', _70 => _70.env, 'optionalAccess', _71 => _71.NODE_ENV]) === "development";
1485
1501
  var ComponentRegistry = class {
1486
1502
  constructor(options = {}) {
1487
1503
  this.added = /* @__PURE__ */ new Map();
@@ -1594,7 +1610,7 @@ var ComponentRegistry = class {
1594
1610
  if (!inBase || this.removed.has(name)) {
1595
1611
  throw new (0, _chunkG6YPSE6Jcjs.JuneError)("LIBRARY_ERROR", `Cannot remove "${name}": no component with that name.`);
1596
1612
  }
1597
- if (_optionalChain([this, 'access', _70 => _70.base, 'optionalAccess', _71 => _71.root]) === name) {
1613
+ if (_optionalChain([this, 'access', _72 => _72.base, 'optionalAccess', _73 => _73.root]) === name) {
1598
1614
  throw new (0, _chunkG6YPSE6Jcjs.JuneError)("LIBRARY_ERROR", `Cannot remove "${name}": it is the root component.`);
1599
1615
  }
1600
1616
  this.removed.add(name);
@@ -1648,7 +1664,7 @@ var ComponentRegistry = class {
1648
1664
  try {
1649
1665
  return base.extend(extension(true));
1650
1666
  } catch (first) {
1651
- if (added.some((c) => _optionalChain([slotsOf, 'call', _72 => _72(c), 'optionalAccess', _73 => _73.length]))) {
1667
+ if (added.some((c) => _optionalChain([slotsOf, 'call', _74 => _74(c), 'optionalAccess', _75 => _75.length]))) {
1652
1668
  try {
1653
1669
  const library = base.extend(extension(false));
1654
1670
  if (isDev()) console.warn("[june-ui] Component slots were skipped (they need Zod 4.1+):", first);
@@ -1667,7 +1683,7 @@ var ComponentRegistry = class {
1667
1683
  const base = this.base;
1668
1684
  const replace = new Map(overrides.map((c) => [nameOf(c), c]));
1669
1685
  const components = Object.values(base.components).filter((c) => !this.removed.has(c.name)).map((c) => _nullishCoalesce(replace.get(c.name), () => ( c))).concat(added);
1670
- const componentGroups = _optionalChain([base, 'access', _74 => _74.componentGroups, 'optionalAccess', _75 => _75.map, 'call', _76 => _76((g) => ({ ...g, components: g.components.filter((n) => !this.removed.has(n)) })), 'access', _77 => _77.filter, 'call', _78 => _78((g) => g.components.length > 0)]);
1686
+ const componentGroups = _optionalChain([base, 'access', _76 => _76.componentGroups, 'optionalAccess', _77 => _77.map, 'call', _78 => _78((g) => ({ ...g, components: g.components.filter((n) => !this.removed.has(n)) })), 'access', _79 => _79.filter, 'call', _80 => _80((g) => g.components.length > 0)]);
1671
1687
  return _reactlang.createLibrary.call(void 0, {
1672
1688
  components,
1673
1689
  componentGroups,
@@ -1698,7 +1714,7 @@ function createJuneLibrary(options) {
1698
1714
  const components = _nullishCoalesce(raw.components, () => ( []));
1699
1715
  const names = /* @__PURE__ */ new Set();
1700
1716
  for (const component of components) {
1701
- if (typeof _optionalChain([component, 'optionalAccess', _79 => _79.name]) !== "string" || component.name.length === 0) {
1717
+ if (typeof _optionalChain([component, 'optionalAccess', _81 => _81.name]) !== "string" || component.name.length === 0) {
1702
1718
  throw new (0, _chunkG6YPSE6Jcjs.JuneError)("LIBRARY_ERROR", "Every component needs a non-empty string name");
1703
1719
  }
1704
1720
  if (names.has(component.name)) {
@@ -1751,7 +1767,7 @@ async function* iterateReadable(stream, signal) {
1751
1767
  void reader.cancel().catch(() => {
1752
1768
  });
1753
1769
  };
1754
- _optionalChain([signal, 'optionalAccess', _80 => _80.addEventListener, 'call', _81 => _81("abort", onAbort, { once: true })]);
1770
+ _optionalChain([signal, 'optionalAccess', _82 => _82.addEventListener, 'call', _83 => _83("abort", onAbort, { once: true })]);
1755
1771
  try {
1756
1772
  while (true) {
1757
1773
  const { done, value } = await reader.read();
@@ -1759,7 +1775,7 @@ async function* iterateReadable(stream, signal) {
1759
1775
  yield value;
1760
1776
  }
1761
1777
  } finally {
1762
- _optionalChain([signal, 'optionalAccess', _82 => _82.removeEventListener, 'call', _83 => _83("abort", onAbort)]);
1778
+ _optionalChain([signal, 'optionalAccess', _84 => _84.removeEventListener, 'call', _85 => _85("abort", onAbort)]);
1763
1779
  try {
1764
1780
  reader.releaseLock();
1765
1781
  } catch (e6) {
@@ -1774,7 +1790,7 @@ function abortedError(partial) {
1774
1790
  }
1775
1791
  async function consumeStream(source, options = {}) {
1776
1792
  const { signal, onText, allowEmpty = false } = options;
1777
- if (_optionalChain([signal, 'optionalAccess', _84 => _84.aborted])) throw abortedError("");
1793
+ if (_optionalChain([signal, 'optionalAccess', _86 => _86.aborted])) throw abortedError("");
1778
1794
  const decoder = new TextDecoder();
1779
1795
  let text = "";
1780
1796
  let received = false;
@@ -1782,23 +1798,23 @@ async function consumeStream(source, options = {}) {
1782
1798
  if (!delta) return;
1783
1799
  received = true;
1784
1800
  text += delta;
1785
- _optionalChain([onText, 'optionalCall', _85 => _85(delta, text)]);
1801
+ _optionalChain([onText, 'optionalCall', _87 => _87(delta, text)]);
1786
1802
  };
1787
1803
  try {
1788
1804
  for await (const chunk of toAsyncIterable(source, signal)) {
1789
- if (_optionalChain([signal, 'optionalAccess', _86 => _86.aborted])) break;
1805
+ if (_optionalChain([signal, 'optionalAccess', _88 => _88.aborted])) break;
1790
1806
  push(typeof chunk === "string" ? chunk : decoder.decode(chunk, { stream: true }));
1791
1807
  }
1792
1808
  push(decoder.decode());
1793
1809
  } catch (error) {
1794
- if (_optionalChain([signal, 'optionalAccess', _87 => _87.aborted])) throw abortedError(text);
1810
+ if (_optionalChain([signal, 'optionalAccess', _89 => _89.aborted])) throw abortedError(text);
1795
1811
  if (error instanceof _chunkG6YPSE6Jcjs.JuneError) throw error;
1796
1812
  throw new (0, _chunkG6YPSE6Jcjs.JuneError)("STREAM_ERROR", "Stream was interrupted", {
1797
1813
  cause: error,
1798
1814
  details: { partial: text }
1799
1815
  });
1800
1816
  }
1801
- if (_optionalChain([signal, 'optionalAccess', _88 => _88.aborted])) throw abortedError(text);
1817
+ if (_optionalChain([signal, 'optionalAccess', _90 => _90.aborted])) throw abortedError(text);
1802
1818
  if (!received && !allowEmpty) {
1803
1819
  throw new (0, _chunkG6YPSE6Jcjs.JuneError)("STREAM_EMPTY", "Stream completed without any content");
1804
1820
  }
@@ -1880,7 +1896,7 @@ async function fetchStream(input, options = {}) {
1880
1896
  try {
1881
1897
  response = await fetch(input, init);
1882
1898
  } catch (error) {
1883
- if (_optionalChain([init, 'access', _89 => _89.signal, 'optionalAccess', _90 => _90.aborted])) {
1899
+ if (_optionalChain([init, 'access', _91 => _91.signal, 'optionalAccess', _92 => _92.aborted])) {
1884
1900
  throw new (0, _chunkG6YPSE6Jcjs.JuneError)("STREAM_ABORTED", "Request was aborted", { cause: error });
1885
1901
  }
1886
1902
  throw new (0, _chunkG6YPSE6Jcjs.JuneError)("NETWORK_ERROR", "Network request failed", { cause: error });
@@ -1937,7 +1953,7 @@ function useJuneStream(options = {}) {
1937
1953
  }, []);
1938
1954
  const start = _react.useCallback.call(void 0,
1939
1955
  async (input) => {
1940
- _optionalChain([controllerRef, 'access', _91 => _91.current, 'optionalAccess', _92 => _92.abort, 'call', _93 => _93()]);
1956
+ _optionalChain([controllerRef, 'access', _93 => _93.current, 'optionalAccess', _94 => _94.abort, 'call', _95 => _95()]);
1941
1957
  const controller = new AbortController();
1942
1958
  controllerRef.current = controller;
1943
1959
  const runId = ++runIdRef.current;
@@ -1960,7 +1976,7 @@ function useJuneStream(options = {}) {
1960
1976
  if (stale()) return null;
1961
1977
  clearTimer();
1962
1978
  setState({ response: text, isStreaming: false, status: "done", error: null });
1963
- _optionalChain([optionsRef, 'access', _94 => _94.current, 'access', _95 => _95.onComplete, 'optionalCall', _96 => _96(text)]);
1979
+ _optionalChain([optionsRef, 'access', _96 => _96.current, 'access', _97 => _97.onComplete, 'optionalCall', _98 => _98(text)]);
1964
1980
  return text;
1965
1981
  } catch (caught) {
1966
1982
  if (stale()) return null;
@@ -1974,7 +1990,7 @@ function useJuneStream(options = {}) {
1974
1990
  status: aborted ? "aborted" : "error",
1975
1991
  error: aborted ? null : error
1976
1992
  });
1977
- if (!aborted) _optionalChain([optionsRef, 'access', _97 => _97.current, 'access', _98 => _98.onError, 'optionalCall', _99 => _99(error)]);
1993
+ if (!aborted) _optionalChain([optionsRef, 'access', _99 => _99.current, 'access', _100 => _100.onError, 'optionalCall', _101 => _101(error)]);
1978
1994
  return null;
1979
1995
  }
1980
1996
  },
@@ -1985,10 +2001,10 @@ function useJuneStream(options = {}) {
1985
2001
  [start]
1986
2002
  );
1987
2003
  const abort = _react.useCallback.call(void 0, () => {
1988
- _optionalChain([controllerRef, 'access', _100 => _100.current, 'optionalAccess', _101 => _101.abort, 'call', _102 => _102()]);
2004
+ _optionalChain([controllerRef, 'access', _102 => _102.current, 'optionalAccess', _103 => _103.abort, 'call', _104 => _104()]);
1989
2005
  }, []);
1990
2006
  const reset = _react.useCallback.call(void 0, () => {
1991
- _optionalChain([controllerRef, 'access', _103 => _103.current, 'optionalAccess', _104 => _104.abort, 'call', _105 => _105()]);
2007
+ _optionalChain([controllerRef, 'access', _105 => _105.current, 'optionalAccess', _106 => _106.abort, 'call', _107 => _107()]);
1992
2008
  runIdRef.current++;
1993
2009
  textRef.current = "";
1994
2010
  clearTimer();
@@ -1997,7 +2013,7 @@ function useJuneStream(options = {}) {
1997
2013
  _react.useEffect.call(void 0,
1998
2014
  () => () => {
1999
2015
  runIdRef.current++;
2000
- _optionalChain([controllerRef, 'access', _106 => _106.current, 'optionalAccess', _107 => _107.abort, 'call', _108 => _108()]);
2016
+ _optionalChain([controllerRef, 'access', _108 => _108.current, 'optionalAccess', _109 => _109.abort, 'call', _110 => _110()]);
2001
2017
  clearTimer();
2002
2018
  },
2003
2019
  [clearTimer]
@@ -2281,7 +2297,7 @@ function Dropdown({ trigger, children, align = "start", className, onOpen }) {
2281
2297
  return () => document.removeEventListener("mousedown", onDown);
2282
2298
  }, [open]);
2283
2299
  const toggle = () => setOpen((v) => {
2284
- if (!v) _optionalChain([onOpen, 'optionalCall', _109 => _109()]);
2300
+ if (!v) _optionalChain([onOpen, 'optionalCall', _111 => _111()]);
2285
2301
  return !v;
2286
2302
  });
2287
2303
  const close = () => setOpen(false);
@@ -2415,7 +2431,7 @@ function ColorPicker({ label, icon, colors, current, disabled, resetLabel, onPic
2415
2431
  style: { background: c },
2416
2432
  "aria-label": c,
2417
2433
  title: c,
2418
- "data-active": _optionalChain([current, 'optionalAccess', _110 => _110.toLowerCase, 'call', _111 => _111()]) === c ? true : void 0,
2434
+ "data-active": _optionalChain([current, 'optionalAccess', _112 => _112.toLowerCase, 'call', _113 => _113()]) === c ? true : void 0,
2419
2435
  onMouseDown: (e) => e.preventDefault(),
2420
2436
  onClick: () => {
2421
2437
  onPick(c);
@@ -2529,7 +2545,7 @@ function ImagePanel({ editor, close, onNotice }) {
2529
2545
  {
2530
2546
  type: "button",
2531
2547
  className: "june-doc__dropzone",
2532
- onClick: () => _optionalChain([file, 'access', _112 => _112.current, 'optionalAccess', _113 => _113.click, 'call', _114 => _114()]),
2548
+ onClick: () => _optionalChain([file, 'access', _114 => _114.current, 'optionalAccess', _115 => _115.click, 'call', _116 => _116()]),
2533
2549
  onDragOver: (e) => e.preventDefault(),
2534
2550
  onDrop: (e) => {
2535
2551
  e.preventDefault();
@@ -2548,7 +2564,7 @@ function ImagePanel({ editor, close, onNotice }) {
2548
2564
  type: "file",
2549
2565
  accept: "image/*",
2550
2566
  hidden: true,
2551
- onChange: (e) => fromFile(_optionalChain([e, 'access', _115 => _115.target, 'access', _116 => _116.files, 'optionalAccess', _117 => _117[0]]))
2567
+ onChange: (e) => fromFile(_optionalChain([e, 'access', _117 => _117.target, 'access', _118 => _118.files, 'optionalAccess', _119 => _119[0]]))
2552
2568
  }
2553
2569
  ),
2554
2570
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "june-doc__or", children: "or" }),
@@ -2653,9 +2669,9 @@ function DocumentToolbar(props) {
2653
2669
  };
2654
2670
  }
2655
2671
  });
2656
- const run = () => _optionalChain([editor, 'optionalAccess', _118 => _118.chain, 'call', _119 => _119(), 'access', _120 => _120.focus, 'call', _121 => _121()]);
2672
+ const run = () => _optionalChain([editor, 'optionalAccess', _120 => _120.chain, 'call', _121 => _121(), 'access', _122 => _122.focus, 'call', _123 => _123()]);
2657
2673
  const off = !editor || !editable;
2658
- const style = _optionalChain([s, 'optionalAccess', _122 => _122.codeBlock]) ? "code" : _optionalChain([s, 'optionalAccess', _123 => _123.h1]) ? "1" : _optionalChain([s, 'optionalAccess', _124 => _124.h2]) ? "2" : _optionalChain([s, 'optionalAccess', _125 => _125.h3]) ? "3" : _optionalChain([s, 'optionalAccess', _126 => _126.quote]) ? "quote" : "p";
2674
+ const style = _optionalChain([s, 'optionalAccess', _124 => _124.codeBlock]) ? "code" : _optionalChain([s, 'optionalAccess', _125 => _125.h1]) ? "1" : _optionalChain([s, 'optionalAccess', _126 => _126.h2]) ? "2" : _optionalChain([s, 'optionalAccess', _127 => _127.h3]) ? "3" : _optionalChain([s, 'optionalAccess', _128 => _128.quote]) ? "quote" : "p";
2659
2675
  const setStyle = (v) => {
2660
2676
  if (!editor || !s) return;
2661
2677
  let c = editor.chain().focus();
@@ -2669,35 +2685,35 @@ function DocumentToolbar(props) {
2669
2685
  }
2670
2686
  c.run();
2671
2687
  };
2672
- const fontKnown = FONT_FAMILIES.some((f) => f.value === _optionalChain([s, 'optionalAccess', _127 => _127.fontFamily]));
2673
- const sizes = _optionalChain([s, 'optionalAccess', _128 => _128.fontSize]) && !FONT_SIZES.includes(Number(s.fontSize)) ? [...FONT_SIZES, Number(s.fontSize)].sort((a, b) => a - b) : FONT_SIZES;
2688
+ const fontKnown = FONT_FAMILIES.some((f) => f.value === _optionalChain([s, 'optionalAccess', _129 => _129.fontFamily]));
2689
+ const sizes = _optionalChain([s, 'optionalAccess', _130 => _130.fontSize]) && !FONT_SIZES.includes(Number(s.fontSize)) ? [...FONT_SIZES, Number(s.fontSize)].sort((a, b) => a - b) : FONT_SIZES;
2674
2690
  if (!editable) return null;
2675
2691
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "june-doc__ribbon", role: "toolbar", "aria-label": "Document formatting", children: [
2676
2692
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "june-doc__row", children: [
2677
2693
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Group, { label: "History", children: [
2678
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Undo", icon: "undo", disabled: off || !_optionalChain([s, 'optionalAccess', _129 => _129.canUndo]), onClick: () => _optionalChain([run, 'call', _130 => _130(), 'optionalAccess', _131 => _131.undo, 'call', _132 => _132(), 'access', _133 => _133.run, 'call', _134 => _134()]) }),
2679
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Redo", icon: "redo", disabled: off || !_optionalChain([s, 'optionalAccess', _135 => _135.canRedo]), onClick: () => _optionalChain([run, 'call', _136 => _136(), 'optionalAccess', _137 => _137.redo, 'call', _138 => _138(), 'access', _139 => _139.run, 'call', _140 => _140()]) })
2694
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Undo", icon: "undo", disabled: off || !_optionalChain([s, 'optionalAccess', _131 => _131.canUndo]), onClick: () => _optionalChain([run, 'call', _132 => _132(), 'optionalAccess', _133 => _133.undo, 'call', _134 => _134(), 'access', _135 => _135.run, 'call', _136 => _136()]) }),
2695
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Redo", icon: "redo", disabled: off || !_optionalChain([s, 'optionalAccess', _137 => _137.canRedo]), onClick: () => _optionalChain([run, 'call', _138 => _138(), 'optionalAccess', _139 => _139.redo, 'call', _140 => _140(), 'access', _141 => _141.run, 'call', _142 => _142()]) })
2680
2696
  ] }),
2681
2697
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Group, { label: "Format", children: [
2682
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Bold", icon: "bold", toggle: true, active: _optionalChain([s, 'optionalAccess', _141 => _141.bold]), disabled: off, onClick: () => _optionalChain([run, 'call', _142 => _142(), 'optionalAccess', _143 => _143.toggleBold, 'call', _144 => _144(), 'access', _145 => _145.run, 'call', _146 => _146()]) }),
2683
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Italic", icon: "italic", toggle: true, active: _optionalChain([s, 'optionalAccess', _147 => _147.italic]), disabled: off, onClick: () => _optionalChain([run, 'call', _148 => _148(), 'optionalAccess', _149 => _149.toggleItalic, 'call', _150 => _150(), 'access', _151 => _151.run, 'call', _152 => _152()]) }),
2684
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Underline", icon: "underline", toggle: true, active: _optionalChain([s, 'optionalAccess', _153 => _153.underline]), disabled: off, onClick: () => _optionalChain([run, 'call', _154 => _154(), 'optionalAccess', _155 => _155.toggleUnderline, 'call', _156 => _156(), 'access', _157 => _157.run, 'call', _158 => _158()]) }),
2685
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Strikethrough", icon: "strike", toggle: true, active: _optionalChain([s, 'optionalAccess', _159 => _159.strike]), disabled: off, onClick: () => _optionalChain([run, 'call', _160 => _160(), 'optionalAccess', _161 => _161.toggleStrike, 'call', _162 => _162(), 'access', _163 => _163.run, 'call', _164 => _164()]) }),
2686
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Inline code", icon: "code", toggle: true, active: _optionalChain([s, 'optionalAccess', _165 => _165.code]), disabled: off, onClick: () => _optionalChain([run, 'call', _166 => _166(), 'optionalAccess', _167 => _167.toggleCode, 'call', _168 => _168(), 'access', _169 => _169.run, 'call', _170 => _170()]) }),
2687
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Superscript", icon: "superscript", toggle: true, active: _optionalChain([s, 'optionalAccess', _171 => _171.sup]), disabled: off, onClick: () => _optionalChain([run, 'call', _172 => _172(), 'optionalAccess', _173 => _173.toggleSuperscript, 'call', _174 => _174(), 'access', _175 => _175.run, 'call', _176 => _176()]) }),
2688
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Subscript", icon: "subscript", toggle: true, active: _optionalChain([s, 'optionalAccess', _177 => _177.sub]), disabled: off, onClick: () => _optionalChain([run, 'call', _178 => _178(), 'optionalAccess', _179 => _179.toggleSubscript, 'call', _180 => _180(), 'access', _181 => _181.run, 'call', _182 => _182()]) })
2698
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Bold", icon: "bold", toggle: true, active: _optionalChain([s, 'optionalAccess', _143 => _143.bold]), disabled: off, onClick: () => _optionalChain([run, 'call', _144 => _144(), 'optionalAccess', _145 => _145.toggleBold, 'call', _146 => _146(), 'access', _147 => _147.run, 'call', _148 => _148()]) }),
2699
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Italic", icon: "italic", toggle: true, active: _optionalChain([s, 'optionalAccess', _149 => _149.italic]), disabled: off, onClick: () => _optionalChain([run, 'call', _150 => _150(), 'optionalAccess', _151 => _151.toggleItalic, 'call', _152 => _152(), 'access', _153 => _153.run, 'call', _154 => _154()]) }),
2700
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Underline", icon: "underline", toggle: true, active: _optionalChain([s, 'optionalAccess', _155 => _155.underline]), disabled: off, onClick: () => _optionalChain([run, 'call', _156 => _156(), 'optionalAccess', _157 => _157.toggleUnderline, 'call', _158 => _158(), 'access', _159 => _159.run, 'call', _160 => _160()]) }),
2701
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Strikethrough", icon: "strike", toggle: true, active: _optionalChain([s, 'optionalAccess', _161 => _161.strike]), disabled: off, onClick: () => _optionalChain([run, 'call', _162 => _162(), 'optionalAccess', _163 => _163.toggleStrike, 'call', _164 => _164(), 'access', _165 => _165.run, 'call', _166 => _166()]) }),
2702
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Inline code", icon: "code", toggle: true, active: _optionalChain([s, 'optionalAccess', _167 => _167.code]), disabled: off, onClick: () => _optionalChain([run, 'call', _168 => _168(), 'optionalAccess', _169 => _169.toggleCode, 'call', _170 => _170(), 'access', _171 => _171.run, 'call', _172 => _172()]) }),
2703
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Superscript", icon: "superscript", toggle: true, active: _optionalChain([s, 'optionalAccess', _173 => _173.sup]), disabled: off, onClick: () => _optionalChain([run, 'call', _174 => _174(), 'optionalAccess', _175 => _175.toggleSuperscript, 'call', _176 => _176(), 'access', _177 => _177.run, 'call', _178 => _178()]) }),
2704
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Subscript", icon: "subscript", toggle: true, active: _optionalChain([s, 'optionalAccess', _179 => _179.sub]), disabled: off, onClick: () => _optionalChain([run, 'call', _180 => _180(), 'optionalAccess', _181 => _181.toggleSubscript, 'call', _182 => _182(), 'access', _183 => _183.run, 'call', _184 => _184()]) })
2689
2705
  ] }),
2690
2706
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Group, { label: "Align", children: [
2691
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Align left", icon: "alignLeft", toggle: true, active: _optionalChain([s, 'optionalAccess', _183 => _183.left]), disabled: off, onClick: () => _optionalChain([run, 'call', _184 => _184(), 'optionalAccess', _185 => _185.setTextAlign, 'call', _186 => _186("left"), 'access', _187 => _187.run, 'call', _188 => _188()]) }),
2692
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Align center", icon: "alignCenter", toggle: true, active: _optionalChain([s, 'optionalAccess', _189 => _189.center]), disabled: off, onClick: () => _optionalChain([run, 'call', _190 => _190(), 'optionalAccess', _191 => _191.setTextAlign, 'call', _192 => _192("center"), 'access', _193 => _193.run, 'call', _194 => _194()]) }),
2693
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Align right", icon: "alignRight", toggle: true, active: _optionalChain([s, 'optionalAccess', _195 => _195.right]), disabled: off, onClick: () => _optionalChain([run, 'call', _196 => _196(), 'optionalAccess', _197 => _197.setTextAlign, 'call', _198 => _198("right"), 'access', _199 => _199.run, 'call', _200 => _200()]) }),
2694
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Justify", icon: "alignJustify", toggle: true, active: _optionalChain([s, 'optionalAccess', _201 => _201.justify]), disabled: off, onClick: () => _optionalChain([run, 'call', _202 => _202(), 'optionalAccess', _203 => _203.setTextAlign, 'call', _204 => _204("justify"), 'access', _205 => _205.run, 'call', _206 => _206()]) })
2707
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Align left", icon: "alignLeft", toggle: true, active: _optionalChain([s, 'optionalAccess', _185 => _185.left]), disabled: off, onClick: () => _optionalChain([run, 'call', _186 => _186(), 'optionalAccess', _187 => _187.setTextAlign, 'call', _188 => _188("left"), 'access', _189 => _189.run, 'call', _190 => _190()]) }),
2708
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Align center", icon: "alignCenter", toggle: true, active: _optionalChain([s, 'optionalAccess', _191 => _191.center]), disabled: off, onClick: () => _optionalChain([run, 'call', _192 => _192(), 'optionalAccess', _193 => _193.setTextAlign, 'call', _194 => _194("center"), 'access', _195 => _195.run, 'call', _196 => _196()]) }),
2709
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Align right", icon: "alignRight", toggle: true, active: _optionalChain([s, 'optionalAccess', _197 => _197.right]), disabled: off, onClick: () => _optionalChain([run, 'call', _198 => _198(), 'optionalAccess', _199 => _199.setTextAlign, 'call', _200 => _200("right"), 'access', _201 => _201.run, 'call', _202 => _202()]) }),
2710
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Justify", icon: "alignJustify", toggle: true, active: _optionalChain([s, 'optionalAccess', _203 => _203.justify]), disabled: off, onClick: () => _optionalChain([run, 'call', _204 => _204(), 'optionalAccess', _205 => _205.setTextAlign, 'call', _206 => _206("justify"), 'access', _207 => _207.run, 'call', _208 => _208()]) })
2695
2711
  ] }),
2696
2712
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Group, { label: "Lists", children: [
2697
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Bullet list", icon: "list", toggle: true, active: _optionalChain([s, 'optionalAccess', _207 => _207.bullet]), disabled: off, onClick: () => _optionalChain([run, 'call', _208 => _208(), 'optionalAccess', _209 => _209.toggleBulletList, 'call', _210 => _210(), 'access', _211 => _211.run, 'call', _212 => _212()]) }),
2698
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Numbered list", icon: "listOrdered", toggle: true, active: _optionalChain([s, 'optionalAccess', _213 => _213.ordered]), disabled: off, onClick: () => _optionalChain([run, 'call', _214 => _214(), 'optionalAccess', _215 => _215.toggleOrderedList, 'call', _216 => _216(), 'access', _217 => _217.run, 'call', _218 => _218()]) }),
2699
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Decrease indent", icon: "outdent", disabled: off || !_optionalChain([s, 'optionalAccess', _219 => _219.canLift]), onClick: () => _optionalChain([run, 'call', _220 => _220(), 'optionalAccess', _221 => _221.liftListItem, 'call', _222 => _222("listItem"), 'access', _223 => _223.run, 'call', _224 => _224()]) }),
2700
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Increase indent", icon: "indent", disabled: off || !_optionalChain([s, 'optionalAccess', _225 => _225.canSink]), onClick: () => _optionalChain([run, 'call', _226 => _226(), 'optionalAccess', _227 => _227.sinkListItem, 'call', _228 => _228("listItem"), 'access', _229 => _229.run, 'call', _230 => _230()]) })
2713
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Bullet list", icon: "list", toggle: true, active: _optionalChain([s, 'optionalAccess', _209 => _209.bullet]), disabled: off, onClick: () => _optionalChain([run, 'call', _210 => _210(), 'optionalAccess', _211 => _211.toggleBulletList, 'call', _212 => _212(), 'access', _213 => _213.run, 'call', _214 => _214()]) }),
2714
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Numbered list", icon: "listOrdered", toggle: true, active: _optionalChain([s, 'optionalAccess', _215 => _215.ordered]), disabled: off, onClick: () => _optionalChain([run, 'call', _216 => _216(), 'optionalAccess', _217 => _217.toggleOrderedList, 'call', _218 => _218(), 'access', _219 => _219.run, 'call', _220 => _220()]) }),
2715
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Decrease indent", icon: "outdent", disabled: off || !_optionalChain([s, 'optionalAccess', _221 => _221.canLift]), onClick: () => _optionalChain([run, 'call', _222 => _222(), 'optionalAccess', _223 => _223.liftListItem, 'call', _224 => _224("listItem"), 'access', _225 => _225.run, 'call', _226 => _226()]) }),
2716
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Increase indent", icon: "indent", disabled: off || !_optionalChain([s, 'optionalAccess', _227 => _227.canSink]), onClick: () => _optionalChain([run, 'call', _228 => _228(), 'optionalAccess', _229 => _229.sinkListItem, 'call', _230 => _230("listItem"), 'access', _231 => _231.run, 'call', _232 => _232()]) })
2701
2717
  ] }),
2702
2718
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
2703
2719
  "button",
@@ -2731,15 +2747,15 @@ function DocumentToolbar(props) {
2731
2747
  className: "june-doc__select june-doc__select--font",
2732
2748
  "aria-label": "Font family",
2733
2749
  disabled: off,
2734
- value: _nullishCoalesce(_optionalChain([s, 'optionalAccess', _231 => _231.fontFamily]), () => ( "")),
2750
+ value: _nullishCoalesce(_optionalChain([s, 'optionalAccess', _233 => _233.fontFamily]), () => ( "")),
2735
2751
  onChange: (e) => {
2736
2752
  const v = e.target.value;
2737
- if (v) _optionalChain([run, 'call', _232 => _232(), 'optionalAccess', _233 => _233.setFontFamily, 'call', _234 => _234(v), 'access', _235 => _235.run, 'call', _236 => _236()]);
2738
- else _optionalChain([run, 'call', _237 => _237(), 'optionalAccess', _238 => _238.unsetFontFamily, 'call', _239 => _239(), 'access', _240 => _240.run, 'call', _241 => _241()]);
2753
+ if (v) _optionalChain([run, 'call', _234 => _234(), 'optionalAccess', _235 => _235.setFontFamily, 'call', _236 => _236(v), 'access', _237 => _237.run, 'call', _238 => _238()]);
2754
+ else _optionalChain([run, 'call', _239 => _239(), 'optionalAccess', _240 => _240.unsetFontFamily, 'call', _241 => _241(), 'access', _242 => _242.run, 'call', _243 => _243()]);
2739
2755
  },
2740
2756
  children: [
2741
2757
  FONT_FAMILIES.map((f) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "option", { value: f.value, style: { fontFamily: f.value || void 0 }, children: f.label }, f.label)),
2742
- !fontKnown && _optionalChain([s, 'optionalAccess', _242 => _242.fontFamily]) ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "option", { value: s.fontFamily, children: s.fontFamily.split(",")[0].replace(/['"]/g, "") }) : null
2758
+ !fontKnown && _optionalChain([s, 'optionalAccess', _244 => _244.fontFamily]) ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "option", { value: s.fontFamily, children: s.fontFamily.split(",")[0].replace(/['"]/g, "") }) : null
2743
2759
  ]
2744
2760
  }
2745
2761
  ) }),
@@ -2749,11 +2765,11 @@ function DocumentToolbar(props) {
2749
2765
  className: "june-doc__select june-doc__select--size",
2750
2766
  "aria-label": "Font size",
2751
2767
  disabled: off,
2752
- value: _nullishCoalesce(_optionalChain([s, 'optionalAccess', _243 => _243.fontSize]), () => ( "")),
2768
+ value: _nullishCoalesce(_optionalChain([s, 'optionalAccess', _245 => _245.fontSize]), () => ( "")),
2753
2769
  onChange: (e) => {
2754
2770
  const v = e.target.value;
2755
- if (v) _optionalChain([run, 'call', _244 => _244(), 'optionalAccess', _245 => _245.setFontSize, 'call', _246 => _246(`${v}px`), 'access', _247 => _247.run, 'call', _248 => _248()]);
2756
- else _optionalChain([run, 'call', _249 => _249(), 'optionalAccess', _250 => _250.unsetFontSize, 'call', _251 => _251(), 'access', _252 => _252.run, 'call', _253 => _253()]);
2771
+ if (v) _optionalChain([run, 'call', _246 => _246(), 'optionalAccess', _247 => _247.setFontSize, 'call', _248 => _248(`${v}px`), 'access', _249 => _249.run, 'call', _250 => _250()]);
2772
+ else _optionalChain([run, 'call', _251 => _251(), 'optionalAccess', _252 => _252.unsetFontSize, 'call', _253 => _253(), 'access', _254 => _254.run, 'call', _255 => _255()]);
2757
2773
  },
2758
2774
  children: [
2759
2775
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "option", { value: "", children: "Auto" }),
@@ -2764,8 +2780,8 @@ function DocumentToolbar(props) {
2764
2780
  ] }),
2765
2781
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Show formatting marks", icon: "pilcrow", toggle: true, active: showMarks, onClick: onToggleMarks, text: true, className: "june-doc__btn--marks", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Paragraph" }) }),
2766
2782
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Group, { label: "Document", children: [
2767
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Insert page break", icon: "pageBreak", disabled: off, onClick: () => _optionalChain([run, 'call', _254 => _254(), 'optionalAccess', _255 => _255.setPageBreak, 'call', _256 => _256(), 'access', _257 => _257.run, 'call', _258 => _258()]) }),
2768
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Insert divider", icon: "divider", disabled: off, onClick: () => _optionalChain([run, 'call', _259 => _259(), 'optionalAccess', _260 => _260.setHorizontalRule, 'call', _261 => _261(), 'access', _262 => _262.run, 'call', _263 => _263()]) }),
2783
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Insert page break", icon: "pageBreak", disabled: off, onClick: () => _optionalChain([run, 'call', _256 => _256(), 'optionalAccess', _257 => _257.setPageBreak, 'call', _258 => _258(), 'access', _259 => _259.run, 'call', _260 => _260()]) }),
2784
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Insert divider", icon: "divider", disabled: off, onClick: () => _optionalChain([run, 'call', _261 => _261(), 'optionalAccess', _262 => _262.setHorizontalRule, 'call', _263 => _263(), 'access', _264 => _264.run, 'call', _265 => _265()]) }),
2769
2785
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: layout === "page" ? "Switch to full-width layout" : "Switch to page layout", icon: "layout", toggle: true, active: layout === "fluid", onClick: onToggleLayout }),
2770
2786
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Find and replace", icon: "search", toggle: true, active: findOpen, onClick: onToggleFind })
2771
2787
  ] }),
@@ -2776,11 +2792,11 @@ function DocumentToolbar(props) {
2776
2792
  label: "Text color",
2777
2793
  icon: "palette",
2778
2794
  colors: TEXT_COLORS,
2779
- current: _nullishCoalesce(_optionalChain([s, 'optionalAccess', _264 => _264.color]), () => ( null)),
2795
+ current: _nullishCoalesce(_optionalChain([s, 'optionalAccess', _266 => _266.color]), () => ( null)),
2780
2796
  disabled: off,
2781
2797
  resetLabel: "Default color",
2782
- onPick: (c) => _optionalChain([run, 'call', _265 => _265(), 'optionalAccess', _266 => _266.setColor, 'call', _267 => _267(c), 'access', _268 => _268.run, 'call', _269 => _269()]),
2783
- onReset: () => _optionalChain([run, 'call', _270 => _270(), 'optionalAccess', _271 => _271.unsetColor, 'call', _272 => _272(), 'access', _273 => _273.run, 'call', _274 => _274()])
2798
+ onPick: (c) => _optionalChain([run, 'call', _267 => _267(), 'optionalAccess', _268 => _268.setColor, 'call', _269 => _269(c), 'access', _270 => _270.run, 'call', _271 => _271()]),
2799
+ onReset: () => _optionalChain([run, 'call', _272 => _272(), 'optionalAccess', _273 => _273.unsetColor, 'call', _274 => _274(), 'access', _275 => _275.run, 'call', _276 => _276()])
2784
2800
  }
2785
2801
  ),
2786
2802
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
@@ -2789,11 +2805,11 @@ function DocumentToolbar(props) {
2789
2805
  label: "Highlight",
2790
2806
  icon: "highlighter",
2791
2807
  colors: HIGHLIGHT_COLORS,
2792
- current: _nullishCoalesce(_optionalChain([s, 'optionalAccess', _275 => _275.highlight]), () => ( null)),
2808
+ current: _nullishCoalesce(_optionalChain([s, 'optionalAccess', _277 => _277.highlight]), () => ( null)),
2793
2809
  disabled: off,
2794
2810
  resetLabel: "No highlight",
2795
- onPick: (c) => _optionalChain([run, 'call', _276 => _276(), 'optionalAccess', _277 => _277.setHighlight, 'call', _278 => _278({ color: c }), 'access', _279 => _279.run, 'call', _280 => _280()]),
2796
- onReset: () => _optionalChain([run, 'call', _281 => _281(), 'optionalAccess', _282 => _282.unsetHighlight, 'call', _283 => _283(), 'access', _284 => _284.run, 'call', _285 => _285()])
2811
+ onPick: (c) => _optionalChain([run, 'call', _278 => _278(), 'optionalAccess', _279 => _279.setHighlight, 'call', _280 => _280({ color: c }), 'access', _281 => _281.run, 'call', _282 => _282()]),
2812
+ onReset: () => _optionalChain([run, 'call', _283 => _283(), 'optionalAccess', _284 => _284.unsetHighlight, 'call', _285 => _285(), 'access', _286 => _286.run, 'call', _287 => _287()])
2797
2813
  }
2798
2814
  )
2799
2815
  ] }),
@@ -2801,24 +2817,24 @@ function DocumentToolbar(props) {
2801
2817
  editor ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2802
2818
  Dropdown,
2803
2819
  {
2804
- trigger: ({ open, toggle }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Link", icon: "link", toggle: true, active: _optionalChain([s, 'optionalAccess', _286 => _286.link]) || open, disabled: off, onClick: toggle }),
2805
- children: (close) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, LinkPanel, { editor, href: _nullishCoalesce(_optionalChain([s, 'optionalAccess', _287 => _287.linkHref]), () => ( "")), isLink: !!_optionalChain([s, 'optionalAccess', _288 => _288.link]), close })
2820
+ trigger: ({ open, toggle }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Link", icon: "link", toggle: true, active: _optionalChain([s, 'optionalAccess', _288 => _288.link]) || open, disabled: off, onClick: toggle }),
2821
+ children: (close) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, LinkPanel, { editor, href: _nullishCoalesce(_optionalChain([s, 'optionalAccess', _289 => _289.linkHref]), () => ( "")), isLink: !!_optionalChain([s, 'optionalAccess', _290 => _290.link]), close })
2806
2822
  }
2807
2823
  ) : null,
2808
2824
  editor ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Dropdown, { trigger: ({ open, toggle }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Insert image", icon: "image", active: open, disabled: off, onClick: toggle }), children: (close) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ImagePanel, { editor, close, onNotice }) }) : null,
2809
2825
  editor ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Dropdown, { trigger: ({ open, toggle }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Insert table", icon: "table", active: open, disabled: off, onClick: toggle }), children: (close) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TablePanel, { editor, close }) }) : null
2810
2826
  ] }),
2811
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Group, { label: "Actions", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Clear formatting", icon: "eraser", disabled: off, onClick: () => _optionalChain([run, 'call', _289 => _289(), 'optionalAccess', _290 => _290.unsetAllMarks, 'call', _291 => _291(), 'access', _292 => _292.clearNodes, 'call', _293 => _293(), 'access', _294 => _294.run, 'call', _295 => _295()]) }) })
2827
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Group, { label: "Actions", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Clear formatting", icon: "eraser", disabled: off, onClick: () => _optionalChain([run, 'call', _291 => _291(), 'optionalAccess', _292 => _292.unsetAllMarks, 'call', _293 => _293(), 'access', _294 => _294.clearNodes, 'call', _295 => _295(), 'access', _296 => _296.run, 'call', _297 => _297()]) }) })
2812
2828
  ] }) : null,
2813
- _optionalChain([s, 'optionalAccess', _296 => _296.inTable]) ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "june-doc__row june-doc__row--context", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Group, { label: "Table", children: [
2814
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Add row below", disabled: off, onClick: () => _optionalChain([run, 'call', _297 => _297(), 'optionalAccess', _298 => _298.addRowAfter, 'call', _299 => _299(), 'access', _300 => _300.run, 'call', _301 => _301()]), children: "+ Row" }),
2815
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Add column right", disabled: off, onClick: () => _optionalChain([run, 'call', _302 => _302(), 'optionalAccess', _303 => _303.addColumnAfter, 'call', _304 => _304(), 'access', _305 => _305.run, 'call', _306 => _306()]), children: "+ Column" }),
2816
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Delete row", disabled: off, onClick: () => _optionalChain([run, 'call', _307 => _307(), 'optionalAccess', _308 => _308.deleteRow, 'call', _309 => _309(), 'access', _310 => _310.run, 'call', _311 => _311()]), children: "\u2212 Row" }),
2817
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Delete column", disabled: off, onClick: () => _optionalChain([run, 'call', _312 => _312(), 'optionalAccess', _313 => _313.deleteColumn, 'call', _314 => _314(), 'access', _315 => _315.run, 'call', _316 => _316()]), children: "\u2212 Column" }),
2818
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Merge cells", disabled: off || !_optionalChain([s, 'optionalAccess', _317 => _317.canMerge]), onClick: () => _optionalChain([run, 'call', _318 => _318(), 'optionalAccess', _319 => _319.mergeCells, 'call', _320 => _320(), 'access', _321 => _321.run, 'call', _322 => _322()]), children: "Merge" }),
2819
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Split cell", disabled: off || !_optionalChain([s, 'optionalAccess', _323 => _323.canSplit]), onClick: () => _optionalChain([run, 'call', _324 => _324(), 'optionalAccess', _325 => _325.splitCell, 'call', _326 => _326(), 'access', _327 => _327.run, 'call', _328 => _328()]), children: "Split" }),
2820
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Toggle header row", disabled: off, onClick: () => _optionalChain([run, 'call', _329 => _329(), 'optionalAccess', _330 => _330.toggleHeaderRow, 'call', _331 => _331(), 'access', _332 => _332.run, 'call', _333 => _333()]), children: "Header row" }),
2821
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Delete table", disabled: off, onClick: () => _optionalChain([run, 'call', _334 => _334(), 'optionalAccess', _335 => _335.deleteTable, 'call', _336 => _336(), 'access', _337 => _337.run, 'call', _338 => _338()]), className: "june-doc__btn--danger", children: "Delete table" })
2829
+ _optionalChain([s, 'optionalAccess', _298 => _298.inTable]) ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "june-doc__row june-doc__row--context", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Group, { label: "Table", children: [
2830
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Add row below", disabled: off, onClick: () => _optionalChain([run, 'call', _299 => _299(), 'optionalAccess', _300 => _300.addRowAfter, 'call', _301 => _301(), 'access', _302 => _302.run, 'call', _303 => _303()]), children: "+ Row" }),
2831
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Add column right", disabled: off, onClick: () => _optionalChain([run, 'call', _304 => _304(), 'optionalAccess', _305 => _305.addColumnAfter, 'call', _306 => _306(), 'access', _307 => _307.run, 'call', _308 => _308()]), children: "+ Column" }),
2832
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Delete row", disabled: off, onClick: () => _optionalChain([run, 'call', _309 => _309(), 'optionalAccess', _310 => _310.deleteRow, 'call', _311 => _311(), 'access', _312 => _312.run, 'call', _313 => _313()]), children: "\u2212 Row" }),
2833
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Delete column", disabled: off, onClick: () => _optionalChain([run, 'call', _314 => _314(), 'optionalAccess', _315 => _315.deleteColumn, 'call', _316 => _316(), 'access', _317 => _317.run, 'call', _318 => _318()]), children: "\u2212 Column" }),
2834
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Merge cells", disabled: off || !_optionalChain([s, 'optionalAccess', _319 => _319.canMerge]), onClick: () => _optionalChain([run, 'call', _320 => _320(), 'optionalAccess', _321 => _321.mergeCells, 'call', _322 => _322(), 'access', _323 => _323.run, 'call', _324 => _324()]), children: "Merge" }),
2835
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Split cell", disabled: off || !_optionalChain([s, 'optionalAccess', _325 => _325.canSplit]), onClick: () => _optionalChain([run, 'call', _326 => _326(), 'optionalAccess', _327 => _327.splitCell, 'call', _328 => _328(), 'access', _329 => _329.run, 'call', _330 => _330()]), children: "Split" }),
2836
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Toggle header row", disabled: off, onClick: () => _optionalChain([run, 'call', _331 => _331(), 'optionalAccess', _332 => _332.toggleHeaderRow, 'call', _333 => _333(), 'access', _334 => _334.run, 'call', _335 => _335()]), children: "Header row" }),
2837
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Btn, { label: "Delete table", disabled: off, onClick: () => _optionalChain([run, 'call', _336 => _336(), 'optionalAccess', _337 => _337.deleteTable, 'call', _338 => _338(), 'access', _339 => _339.run, 'call', _340 => _340()]), className: "june-doc__btn--danger", children: "Delete table" })
2822
2838
  ] }) }) : null
2823
2839
  ] });
2824
2840
  }
@@ -2959,7 +2975,7 @@ function DocumentContent({ editor, layout = "page", zoom = 1, showMarks = false,
2959
2975
  const page = paged ? Math.min(total, Math.max(1, Math.floor(y / stride) + 1)) : 1;
2960
2976
  if (last.current.page !== page || last.current.pages !== total) {
2961
2977
  last.current = { page, pages: total };
2962
- _optionalChain([metricsRef, 'access', _339 => _339.current, 'optionalCall', _340 => _340({ page, pages: total })]);
2978
+ _optionalChain([metricsRef, 'access', _341 => _341.current, 'optionalCall', _342 => _342({ page, pages: total })]);
2963
2979
  }
2964
2980
  };
2965
2981
  report();
@@ -2968,12 +2984,12 @@ function DocumentContent({ editor, layout = "page", zoom = 1, showMarks = false,
2968
2984
  const onLoad = () => _chunkG6YPSE6Jcjs.remeasurePagination.call(void 0, editor);
2969
2985
  prose.addEventListener("load", onLoad, true);
2970
2986
  const ro = typeof ResizeObserver !== "undefined" ? new ResizeObserver(report) : null;
2971
- _optionalChain([ro, 'optionalAccess', _341 => _341.observe, 'call', _342 => _342(s)]);
2987
+ _optionalChain([ro, 'optionalAccess', _343 => _343.observe, 'call', _344 => _344(s)]);
2972
2988
  return () => {
2973
2989
  editor.off("transaction", report);
2974
2990
  c.removeEventListener("scroll", report);
2975
2991
  prose.removeEventListener("load", onLoad, true);
2976
- _optionalChain([ro, 'optionalAccess', _343 => _343.disconnect, 'call', _344 => _344()]);
2992
+ _optionalChain([ro, 'optionalAccess', _345 => _345.disconnect, 'call', _346 => _346()]);
2977
2993
  };
2978
2994
  }, [editor, paged, zoom, stride]);
2979
2995
  const minHeight = paged ? pages * g.height + (pages - 1) * PAGE_GAP : void 0;
@@ -3014,12 +3030,12 @@ function DocumentFindBar({ editor, editable, onClose, onNotice }) {
3014
3030
  editor,
3015
3031
  selector: ({ editor: ed }) => {
3016
3032
  const s = _chunkG6YPSE6Jcjs.getSearchState.call(void 0, ed);
3017
- return { count: _nullishCoalesce(_optionalChain([s, 'optionalAccess', _345 => _345.matches, 'access', _346 => _346.length]), () => ( 0)), current: _nullishCoalesce(_optionalChain([s, 'optionalAccess', _347 => _347.current]), () => ( -1)) };
3033
+ return { count: _nullishCoalesce(_optionalChain([s, 'optionalAccess', _347 => _347.matches, 'access', _348 => _348.length]), () => ( 0)), current: _nullishCoalesce(_optionalChain([s, 'optionalAccess', _349 => _349.current]), () => ( -1)) };
3018
3034
  }
3019
3035
  });
3020
3036
  _react.useEffect.call(void 0, () => {
3021
- _optionalChain([input, 'access', _348 => _348.current, 'optionalAccess', _349 => _349.focus, 'call', _350 => _350()]);
3022
- _optionalChain([input, 'access', _351 => _351.current, 'optionalAccess', _352 => _352.select, 'call', _353 => _353()]);
3037
+ _optionalChain([input, 'access', _350 => _350.current, 'optionalAccess', _351 => _351.focus, 'call', _352 => _352()]);
3038
+ _optionalChain([input, 'access', _353 => _353.current, 'optionalAccess', _354 => _354.select, 'call', _355 => _355()]);
3023
3039
  }, []);
3024
3040
  _react.useEffect.call(void 0, () => {
3025
3041
  _chunkG6YPSE6Jcjs.setSearch.call(void 0, editor, { term, caseSensitive, current: 0 });
@@ -3027,8 +3043,8 @@ function DocumentFindBar({ editor, editable, onClose, onNotice }) {
3027
3043
  _react.useEffect.call(void 0, () => () => {
3028
3044
  if (!editor.isDestroyed) _chunkG6YPSE6Jcjs.setSearch.call(void 0, editor, { term: "" });
3029
3045
  }, [editor]);
3030
- const count = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _354 => _354.count]), () => ( 0));
3031
- const current = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _355 => _355.current]), () => ( -1));
3046
+ const count = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _356 => _356.count]), () => ( 0));
3047
+ const current = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _357 => _357.current]), () => ( -1));
3032
3048
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
3033
3049
  "div",
3034
3050
  {
@@ -3306,12 +3322,12 @@ function toHalfPoints(value) {
3306
3322
  if (!m) return void 0;
3307
3323
  const n = Number(m[1]);
3308
3324
  if (!Number.isFinite(n) || n <= 0) return void 0;
3309
- const pt = _optionalChain([m, 'access', _356 => _356[2], 'optionalAccess', _357 => _357.toLowerCase, 'call', _358 => _358()]) === "pt" ? n : n * 0.75;
3325
+ const pt = _optionalChain([m, 'access', _358 => _358[2], 'optionalAccess', _359 => _359.toLowerCase, 'call', _360 => _360()]) === "pt" ? n : n * 0.75;
3310
3326
  return Math.round(pt * 2);
3311
3327
  }
3312
3328
  function firstFontFamily(value) {
3313
3329
  if (typeof value !== "string") return void 0;
3314
- const first = _optionalChain([value, 'access', _359 => _359.split, 'call', _360 => _360(","), 'access', _361 => _361[0], 'optionalAccess', _362 => _362.trim, 'call', _363 => _363(), 'access', _364 => _364.replace, 'call', _365 => _365(/^['"]|['"]$/g, "")]);
3330
+ const first = _optionalChain([value, 'access', _361 => _361.split, 'call', _362 => _362(","), 'access', _363 => _363[0], 'optionalAccess', _364 => _364.trim, 'call', _365 => _365(), 'access', _366 => _366.replace, 'call', _367 => _367(/^['"]|['"]$/g, "")]);
3315
3331
  return first || void 0;
3316
3332
  }
3317
3333
  var ORDERED_REF = "june-ordered";
@@ -3327,9 +3343,9 @@ function runs(d, node, fmt) {
3327
3343
  const marks = _nullishCoalesce(child.marks, () => ( []));
3328
3344
  const has = (type) => marks.some((m) => m.type === type);
3329
3345
  const link = marks.find((m) => m.type === "link");
3330
- const style = _nullishCoalesce(_optionalChain([marks, 'access', _366 => _366.find, 'call', _367 => _367((m) => m.type === "textStyle"), 'optionalAccess', _368 => _368.attrs]), () => ( {}));
3346
+ const style = _nullishCoalesce(_optionalChain([marks, 'access', _368 => _368.find, 'call', _369 => _369((m) => m.type === "textStyle"), 'optionalAccess', _370 => _370.attrs]), () => ( {}));
3331
3347
  const highlight = marks.find((m) => m.type === "highlight");
3332
- const fill = highlight ? _nullishCoalesce(toDocxColor(_optionalChain([highlight, 'access', _369 => _369.attrs, 'optionalAccess', _370 => _370.color])), () => ( "FFF59D")) : void 0;
3348
+ const fill = highlight ? _nullishCoalesce(toDocxColor(_optionalChain([highlight, 'access', _371 => _371.attrs, 'optionalAccess', _372 => _372.color])), () => ( "FFF59D")) : void 0;
3333
3349
  const run = new d.TextRun({
3334
3350
  text: child.text,
3335
3351
  bold: fmt.bold || has("bold") || void 0,
@@ -3343,13 +3359,13 @@ function runs(d, node, fmt) {
3343
3359
  color: _nullishCoalesce(toDocxColor(style.color), () => ( (link ? "0563C1" : void 0))),
3344
3360
  shading: fill ? { type: d.ShadingType.CLEAR, fill, color: "auto" } : void 0
3345
3361
  });
3346
- const href = typeof _optionalChain([link, 'optionalAccess', _371 => _371.attrs, 'optionalAccess', _372 => _372.href]) === "string" ? _chunkG6YPSE6Jcjs.sanitizeHref.call(void 0, link.attrs.href) : null;
3362
+ const href = typeof _optionalChain([link, 'optionalAccess', _373 => _373.attrs, 'optionalAccess', _374 => _374.href]) === "string" ? _chunkG6YPSE6Jcjs.sanitizeHref.call(void 0, link.attrs.href) : null;
3347
3363
  out.push(href ? new d.ExternalHyperlink({ link: href, children: [run] }) : run);
3348
3364
  }
3349
3365
  return out;
3350
3366
  }
3351
3367
  function paragraph(d, node, fmt, extra = {}) {
3352
- const align = _optionalChain([node, 'access', _373 => _373.attrs, 'optionalAccess', _374 => _374.textAlign]);
3368
+ const align = _optionalChain([node, 'access', _375 => _375.attrs, 'optionalAccess', _376 => _376.textAlign]);
3353
3369
  return new d.Paragraph({
3354
3370
  children: runs(d, node, fmt),
3355
3371
  alignment: align === "center" ? d.AlignmentType.CENTER : align === "right" ? d.AlignmentType.RIGHT : align === "justify" ? d.AlignmentType.JUSTIFIED : void 0,
@@ -3411,8 +3427,8 @@ function table(d, node, state) {
3411
3427
  return new d.Table({ rows, width: { size: 100, type: d.WidthType.PERCENTAGE } });
3412
3428
  }
3413
3429
  function image(d, node, state) {
3414
- const src = typeof _optionalChain([node, 'access', _375 => _375.attrs, 'optionalAccess', _376 => _376.src]) === "string" ? node.attrs.src : "";
3415
- const alt = typeof _optionalChain([node, 'access', _377 => _377.attrs, 'optionalAccess', _378 => _378.alt]) === "string" ? node.attrs.alt : "";
3430
+ const src = typeof _optionalChain([node, 'access', _377 => _377.attrs, 'optionalAccess', _378 => _378.src]) === "string" ? node.attrs.src : "";
3431
+ const alt = typeof _optionalChain([node, 'access', _379 => _379.attrs, 'optionalAccess', _380 => _380.alt]) === "string" ? node.attrs.alt : "";
3416
3432
  const img = state.images.get(src);
3417
3433
  if (img) {
3418
3434
  return [
@@ -3444,7 +3460,7 @@ function image(d, node, state) {
3444
3460
  }
3445
3461
  function collectImages(nodes, out) {
3446
3462
  for (const node of _nullishCoalesce(nodes, () => ( []))) {
3447
- const src = _optionalChain([node, 'access', _379 => _379.attrs, 'optionalAccess', _380 => _380.src]);
3463
+ const src = _optionalChain([node, 'access', _381 => _381.attrs, 'optionalAccess', _382 => _382.src]);
3448
3464
  if (node.type === "image" && typeof src === "string" && src && !out.has(src)) out.set(src, node.attrs);
3449
3465
  if (node.content) collectImages(node.content, out);
3450
3466
  }
@@ -3481,8 +3497,8 @@ async function loadImage(src, attrs) {
3481
3497
  const type = IMAGE_TYPES[blob.type.toLowerCase()];
3482
3498
  if (!type) return null;
3483
3499
  const natural = await naturalSize(blob);
3484
- let width = Number(_optionalChain([attrs, 'optionalAccess', _381 => _381.width])) || natural.width;
3485
- let height = Number(_optionalChain([attrs, 'optionalAccess', _382 => _382.height])) || natural.height * width / natural.width;
3500
+ let width = Number(_optionalChain([attrs, 'optionalAccess', _383 => _383.width])) || natural.width;
3501
+ let height = Number(_optionalChain([attrs, 'optionalAccess', _384 => _384.height])) || natural.height * width / natural.width;
3486
3502
  if (width > MAX_IMAGE_WIDTH) {
3487
3503
  height = height * MAX_IMAGE_WIDTH / width;
3488
3504
  width = MAX_IMAGE_WIDTH;
@@ -3513,7 +3529,7 @@ function blocks(d, nodes, fmt, state) {
3513
3529
  out.push(paragraph(d, node, fmt));
3514
3530
  break;
3515
3531
  case "heading": {
3516
- const level = Math.min(Math.max(Number(_optionalChain([node, 'access', _383 => _383.attrs, 'optionalAccess', _384 => _384.level])) || 1, 1), 3);
3532
+ const level = Math.min(Math.max(Number(_optionalChain([node, 'access', _385 => _385.attrs, 'optionalAccess', _386 => _386.level])) || 1, 1), 3);
3517
3533
  out.push(paragraph(d, node, fmt, { heading: headings[level - 1] }));
3518
3534
  break;
3519
3535
  }
@@ -3647,7 +3663,7 @@ async function copyDocumentToClipboard(doc) {
3647
3663
 
3648
3664
  ${docToText(doc.json)}`;
3649
3665
  try {
3650
- if (typeof ClipboardItem !== "undefined" && _optionalChain([navigator, 'access', _385 => _385.clipboard, 'optionalAccess', _386 => _386.write])) {
3666
+ if (typeof ClipboardItem !== "undefined" && _optionalChain([navigator, 'access', _387 => _387.clipboard, 'optionalAccess', _388 => _388.write])) {
3651
3667
  await navigator.clipboard.write([
3652
3668
  new ClipboardItem({
3653
3669
  "text/html": new Blob([html], { type: "text/html" }),
@@ -3720,12 +3736,12 @@ function DocumentEditorImpl(props) {
3720
3736
  }
3721
3737
  }, [contentKey]);
3722
3738
  _react.useEffect.call(void 0, () => {
3723
- if (parsed.error) _optionalChain([optionsRef, 'access', _387 => _387.current, 'access', _388 => _388.onError, 'optionalCall', _389 => _389(parsed.error)]);
3739
+ if (parsed.error) _optionalChain([optionsRef, 'access', _389 => _389.current, 'access', _390 => _390.onError, 'optionalCall', _391 => _391(parsed.error)]);
3724
3740
  }, [parsed.error]);
3725
- const title = useDocumentValue(store, documentId, (r) => _nullishCoalesce(_optionalChain([r, 'optionalAccess', _390 => _390.title]), () => ( titleProp)));
3726
- const pending = useDocumentValue(store, documentId, (r) => _nullishCoalesce(_optionalChain([r, 'optionalAccess', _391 => _391.pending]), () => ( null)));
3741
+ const title = useDocumentValue(store, documentId, (r) => _nullishCoalesce(_optionalChain([r, 'optionalAccess', _392 => _392.title]), () => ( titleProp)));
3742
+ const pending = useDocumentValue(store, documentId, (r) => _nullishCoalesce(_optionalChain([r, 'optionalAccess', _393 => _393.pending]), () => ( null)));
3727
3743
  const words = useDocumentValue(store, documentId, (r) => r ? _chunkG6YPSE6Jcjs.wordCountOf.call(void 0, r.json) : 0);
3728
- const recordStatus = useDocumentValue(store, documentId, (r) => _nullishCoalesce(_optionalChain([r, 'optionalAccess', _392 => _392.status]), () => ( status)));
3744
+ const recordStatus = useDocumentValue(store, documentId, (r) => _nullishCoalesce(_optionalChain([r, 'optionalAccess', _394 => _394.status]), () => ( status)));
3729
3745
  const [saveState, setSaveState] = _react.useState.call(void 0, "idle");
3730
3746
  const [notice, setNotice] = _react.useState.call(void 0, null);
3731
3747
  const [fullscreen, setFullscreen] = _react.useState.call(void 0, false);
@@ -3744,7 +3760,7 @@ function DocumentEditorImpl(props) {
3744
3760
  };
3745
3761
  }, [fullscreen]);
3746
3762
  const lastSavedKey = _react.useRef.call(void 0, "");
3747
- const seenRevision = _react.useRef.call(void 0, _nullishCoalesce(_optionalChain([store, 'access', _393 => _393.get, 'call', _394 => _394(documentId), 'optionalAccess', _395 => _395.revision]), () => ( 0)));
3763
+ const seenRevision = _react.useRef.call(void 0, _nullishCoalesce(_optionalChain([store, 'access', _395 => _395.get, 'call', _396 => _396(documentId), 'optionalAccess', _397 => _397.revision]), () => ( 0)));
3748
3764
  const readyRef = _react.useRef.call(void 0, false);
3749
3765
  const flash = _react.useCallback.call(void 0, (message) => {
3750
3766
  setNotice(message);
@@ -3757,7 +3773,7 @@ function DocumentEditorImpl(props) {
3757
3773
  const emitChange = _react.useCallback.call(void 0,
3758
3774
  (source) => {
3759
3775
  const record = store.get(documentId);
3760
- if (record) _optionalChain([optionsRef, 'access', _396 => _396.current, 'access', _397 => _397.onDocumentChange, 'optionalCall', _398 => _398({ ...snapshotOf(record), source })]);
3776
+ if (record) _optionalChain([optionsRef, 'access', _398 => _398.current, 'access', _399 => _399.onDocumentChange, 'optionalCall', _400 => _400({ ...snapshotOf(record), source })]);
3761
3777
  },
3762
3778
  [store, documentId]
3763
3779
  );
@@ -3767,7 +3783,7 @@ function DocumentEditorImpl(props) {
3767
3783
  const delay = _nullishCoalesce(options.autosaveDelay, () => ( 1500));
3768
3784
  return delay > 0 ? _chunkG6YPSE6Jcjs.debounce.call(void 0, () => void saveRef.current(), delay) : null;
3769
3785
  }, [options.autosaveDelay]);
3770
- _react.useEffect.call(void 0, () => () => _optionalChain([autosave, 'optionalAccess', _399 => _399.flush, 'call', _400 => _400()]), [autosave]);
3786
+ _react.useEffect.call(void 0, () => () => _optionalChain([autosave, 'optionalAccess', _401 => _401.flush, 'call', _402 => _402()]), [autosave]);
3771
3787
  saveRef.current = async () => {
3772
3788
  const record = store.get(documentId);
3773
3789
  const onSave = optionsRef.current.onSave;
@@ -3795,7 +3811,7 @@ function DocumentEditorImpl(props) {
3795
3811
  setSaveState(latestKey === key ? "saved" : "dirty");
3796
3812
  } catch (error) {
3797
3813
  setSaveState("error");
3798
- _optionalChain([optionsRef, 'access', _401 => _401.current, 'access', _402 => _402.onError, 'optionalCall', _403 => _403(_chunkG6YPSE6Jcjs.toJuneError.call(void 0, error, "DOCUMENT_ERROR", "Saving the document failed"))]);
3814
+ _optionalChain([optionsRef, 'access', _403 => _403.current, 'access', _404 => _404.onError, 'optionalCall', _405 => _405(_chunkG6YPSE6Jcjs.toJuneError.call(void 0, error, "DOCUMENT_ERROR", "Saving the document failed"))]);
3799
3815
  }
3800
3816
  };
3801
3817
  const markDirty = _react.useCallback.call(void 0,
@@ -3805,7 +3821,7 @@ function DocumentEditorImpl(props) {
3805
3821
  return;
3806
3822
  }
3807
3823
  setSaveState("dirty");
3808
- _optionalChain([autosave, 'optionalCall', _404 => _404()]);
3824
+ _optionalChain([autosave, 'optionalCall', _406 => _406()]);
3809
3825
  },
3810
3826
  [autosave]
3811
3827
  );
@@ -3814,7 +3830,7 @@ function DocumentEditorImpl(props) {
3814
3830
  const t = setTimeout(() => setSaveState((s) => s === "saved" ? "idle" : s), 2500);
3815
3831
  return () => clearTimeout(t);
3816
3832
  }, [saveState, options.onSave]);
3817
- const [initialJson] = _react.useState.call(void 0, () => _nullishCoalesce(_nullishCoalesce(_optionalChain([store, 'access', _405 => _405.get, 'call', _406 => _406(documentId), 'optionalAccess', _407 => _407.json]), () => ( parsed.json)), () => ( _chunkG6YPSE6Jcjs.emptyDoc.call(void 0, ))));
3833
+ const [initialJson] = _react.useState.call(void 0, () => _nullishCoalesce(_nullishCoalesce(_optionalChain([store, 'access', _407 => _407.get, 'call', _408 => _408(documentId), 'optionalAccess', _409 => _409.json]), () => ( parsed.json)), () => ( _chunkG6YPSE6Jcjs.emptyDoc.call(void 0, ))));
3818
3834
  const extensions = _react.useMemo.call(void 0, () => _chunkG6YPSE6Jcjs.createDocumentExtensions.call(void 0, ), []);
3819
3835
  const onUpdateRef = _react.useRef.call(void 0, () => {
3820
3836
  });
@@ -3857,10 +3873,10 @@ function DocumentEditorImpl(props) {
3857
3873
  markDirty(false);
3858
3874
  } else if (outcome === "conflict") {
3859
3875
  const record = store.get(documentId);
3860
- _optionalChain([optionsRef, 'access', _408 => _408.current, 'access', _409 => _409.onConflict, 'optionalCall', _410 => _410({
3876
+ _optionalChain([optionsRef, 'access', _410 => _410.current, 'access', _411 => _411.onConflict, 'optionalCall', _412 => _412({
3861
3877
  documentId,
3862
- title: _nullishCoalesce(_optionalChain([record, 'optionalAccess', _411 => _411.title]), () => ( titleProp)),
3863
- conflicts: _nullishCoalesce(_optionalChain([record, 'optionalAccess', _412 => _412.pending, 'optionalAccess', _413 => _413.conflicts]), () => ( 1))
3878
+ title: _nullishCoalesce(_optionalChain([record, 'optionalAccess', _413 => _413.title]), () => ( titleProp)),
3879
+ conflicts: _nullishCoalesce(_optionalChain([record, 'optionalAccess', _414 => _414.pending, 'optionalAccess', _415 => _415.conflicts]), () => ( 1))
3864
3880
  })]);
3865
3881
  }
3866
3882
  }, [store, documentId, titleProp, parsed.json, documentType, status, emitChange, markDirty]);
@@ -3887,7 +3903,7 @@ function DocumentEditorImpl(props) {
3887
3903
  if (!record) return;
3888
3904
  readyRef.current = true;
3889
3905
  lastSavedKey.current = JSON.stringify([record.title, _chunkG6YPSE6Jcjs.docKey.call(void 0, record.json)]);
3890
- _optionalChain([optionsRef, 'access', _414 => _414.current, 'access', _415 => _415.onDocumentReady, 'optionalCall', _416 => _416(snapshotOf(record))]);
3906
+ _optionalChain([optionsRef, 'access', _416 => _416.current, 'access', _417 => _417.onDocumentReady, 'optionalCall', _418 => _418(snapshotOf(record))]);
3891
3907
  }, [editor, store, documentId, title]);
3892
3908
  const handleTitle = (value) => {
3893
3909
  store.setTitle(documentId, value);
@@ -3912,9 +3928,9 @@ function DocumentEditorImpl(props) {
3912
3928
  // always the latest editor content
3913
3929
  });
3914
3930
  if (result.blob) downloadResult(result);
3915
- _optionalChain([optionsRef, 'access', _417 => _417.current, 'access', _418 => _418.onExport, 'optionalCall', _419 => _419({ documentId, format: format2, ...result })]);
3931
+ _optionalChain([optionsRef, 'access', _419 => _419.current, 'access', _420 => _420.onExport, 'optionalCall', _421 => _421({ documentId, format: format2, ...result })]);
3916
3932
  } catch (error) {
3917
- _optionalChain([optionsRef, 'access', _420 => _420.current, 'access', _421 => _421.onError, 'optionalCall', _422 => _422(_chunkG6YPSE6Jcjs.toJuneError.call(void 0, error, "EXPORT_ERROR"))]);
3933
+ _optionalChain([optionsRef, 'access', _422 => _422.current, 'access', _423 => _423.onError, 'optionalCall', _424 => _424(_chunkG6YPSE6Jcjs.toJuneError.call(void 0, error, "EXPORT_ERROR"))]);
3918
3934
  flash("Export failed");
3919
3935
  }
3920
3936
  };
@@ -4044,49 +4060,149 @@ function DocumentEditorImpl(props) {
4044
4060
 
4045
4061
  var _reactdom = require('react-dom');
4046
4062
 
4063
+ // src/features/document-editor/document-presentation.ts
4064
+ function resolveDocumentPresentation(documentPresentation, configured) {
4065
+ if (documentPresentation === "inline" || documentPresentation === "side-panel") return documentPresentation;
4066
+ if (configured === "inline" || configured === "side-panel") return configured;
4067
+ return "inline";
4068
+ }
4069
+ function documentPanelWidth(width) {
4070
+ if (typeof width === "number" && Number.isFinite(width)) return `${width}px`;
4071
+ if (typeof width === "string" && width.trim()) return width.trim();
4072
+ return void 0;
4073
+ }
4074
+
4075
+ // src/features/document-editor/document-preview.tsx
4076
+
4077
+ var FORMAT_LABEL = {
4078
+ docx: "Word document",
4079
+ pdf: "PDF",
4080
+ html: "Web page",
4081
+ markdown: "Markdown",
4082
+ txt: "Plain text"
4083
+ };
4047
4084
  function DocumentPreview(props) {
4048
- const { documentId, title = "Untitled document", content, editable = true } = props;
4085
+ const { documentId, title = "Untitled document", content, editable = true, exportFormats } = props;
4049
4086
  const { theme: contextTheme } = useJuneTheme();
4050
4087
  const resolvedTheme = props.theme && props.theme !== "auto" ? props.theme : contextTheme;
4051
4088
  const ctxOptions = useDocumentOptions();
4052
- const store = _react.useMemo.call(void 0, () => _nullishCoalesce(_nullishCoalesce(_optionalChain([props, 'access', _423 => _423.options, 'optionalAccess', _424 => _424.store]), () => ( ctxOptions.store)), () => ( getDefaultDocumentStore())), [_optionalChain([props, 'access', _425 => _425.options, 'optionalAccess', _426 => _426.store]), ctxOptions.store]);
4053
- const storedJson = useDocumentValue(store, documentId, (record) => _optionalChain([record, 'optionalAccess', _427 => _427.json]));
4089
+ const editorConfig = useDocumentEditorConfig();
4090
+ const presentation = resolveDocumentPresentation(props.presentation, editorConfig.presentation);
4091
+ const panelWidth = documentPanelWidth(editorConfig.width);
4092
+ const store = _react.useMemo.call(void 0, () => _nullishCoalesce(_nullishCoalesce(_optionalChain([props, 'access', _425 => _425.options, 'optionalAccess', _426 => _426.store]), () => ( ctxOptions.store)), () => ( getDefaultDocumentStore())), [_optionalChain([props, 'access', _427 => _427.options, 'optionalAccess', _428 => _428.store]), ctxOptions.store]);
4093
+ const storedJson = useDocumentValue(store, documentId, (record) => _optionalChain([record, 'optionalAccess', _429 => _429.json]));
4054
4094
  const [open, setOpen] = _react.useState.call(void 0, false);
4055
4095
  const [preferStore, setPreferStore] = _react.useState.call(void 0, false);
4096
+ const [notice, setNotice] = _react.useState.call(void 0, null);
4056
4097
  const contentKey = typeof content === "string" ? content : content ? JSON.stringify(content) : "";
4098
+ const options = _nullishCoalesce(props.options, () => ( ctxOptions));
4057
4099
  _react.useEffect.call(void 0, () => {
4058
4100
  setPreferStore(false);
4059
4101
  }, [contentKey]);
4060
- const html = _react.useMemo.call(void 0, () => {
4102
+ const doc = _react.useMemo.call(void 0, () => {
4061
4103
  try {
4062
4104
  const fromContent = contentKey ? _chunkG6YPSE6Jcjs.parseDocumentContent.call(void 0, contentKey) : null;
4063
- const doc = preferStore && storedJson ? storedJson : fromContent;
4064
- return doc ? _chunkG6YPSE6Jcjs.docToHtml.call(void 0, doc) : "";
4105
+ return preferStore && storedJson ? storedJson : fromContent;
4065
4106
  } catch (e10) {
4066
- return "";
4107
+ return null;
4067
4108
  }
4068
4109
  }, [contentKey, preferStore, storedJson]);
4110
+ const html = _react.useMemo.call(void 0, () => doc ? _chunkG6YPSE6Jcjs.docToHtml.call(void 0, doc) : "", [doc]);
4111
+ const formats = (_nullishCoalesce(exportFormats, () => ( [...ALL_EXPORT_FORMATS]))).filter((format2) => listDocumentExporters().includes(format2));
4112
+ _react.useEffect.call(void 0, () => {
4113
+ if (!notice) return;
4114
+ const timer = setTimeout(() => setNotice(null), 2e3);
4115
+ return () => clearTimeout(timer);
4116
+ }, [notice]);
4069
4117
  _react.useEffect.call(void 0, () => {
4070
- if (!open || typeof document === "undefined") return;
4118
+ if (!open || presentation !== "side-panel" || typeof document === "undefined") return;
4071
4119
  const prev = document.body.style.overflow;
4072
4120
  document.body.style.overflow = "hidden";
4073
4121
  return () => {
4074
4122
  document.body.style.overflow = prev;
4075
4123
  };
4076
- }, [open]);
4124
+ }, [open, presentation]);
4077
4125
  const close = () => {
4078
4126
  setPreferStore(true);
4079
4127
  setOpen(false);
4080
4128
  };
4129
+ const handleExport = async (format2) => {
4130
+ if (!doc) return;
4131
+ try {
4132
+ const result = await exportDocument(format2, { documentId, title, json: doc });
4133
+ if (result.blob) downloadResult(result);
4134
+ _optionalChain([options, 'access', _430 => _430.onExport, 'optionalCall', _431 => _431({ documentId, format: format2, ...result })]);
4135
+ } catch (error) {
4136
+ _optionalChain([options, 'access', _432 => _432.onError, 'optionalCall', _433 => _433(_chunkG6YPSE6Jcjs.toJuneError.call(void 0, error, "EXPORT_ERROR"))]);
4137
+ setNotice("Export failed");
4138
+ }
4139
+ };
4140
+ const handleCopy = async () => {
4141
+ if (!doc) return;
4142
+ setNotice(await copyDocumentToClipboard({ title, json: doc }) ? "Copied" : "Copy failed");
4143
+ };
4144
+ const editor = /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
4145
+ DocumentEditorImpl,
4146
+ {
4147
+ documentId: props.documentId,
4148
+ title: props.title,
4149
+ content: props.content,
4150
+ documentType: props.documentType,
4151
+ status: props.status,
4152
+ editable: props.editable,
4153
+ exportFormats: props.exportFormats,
4154
+ theme: props.theme,
4155
+ generating: props.generating,
4156
+ options: props.options
4157
+ }
4158
+ );
4159
+ const closeBar = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "june-doc-editor__bar", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "button", { type: "button", className: "june-doc__btn june-doc__btn--ghost", "aria-label": "Close document", onClick: close, children: [
4160
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, { name: "close", size: 16 }),
4161
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Close" })
4162
+ ] }) });
4081
4163
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
4082
4164
  !open ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "section", { className: "june-doc june-doc-card", "data-theme": resolvedTheme, "aria-label": title, children: [
4083
4165
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "june-doc-card__bar", children: [
4084
4166
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "june-doc-card__title", children: title }),
4085
- editable ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "june-doc__btn june-doc__btn--icon june-doc__btn--ghost", "aria-label": "Edit document", title: "Edit", onClick: () => setOpen(true), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, { name: "pencil", size: 16 }) }) : null
4167
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "june-doc-card__actions", children: [
4168
+ notice ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "june-doc-card__notice", children: notice }) : null,
4169
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "june-doc__btn june-doc__btn--icon june-doc__btn--ghost", "aria-label": "Copy document", title: "Copy", onClick: () => void handleCopy(), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, { name: "copy", size: 16 }) }),
4170
+ editable ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "june-doc__btn june-doc__btn--icon june-doc__btn--ghost", "aria-label": "Edit document", title: "Edit", onClick: () => setOpen(true), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, { name: "pencil", size: 16 }) }) : null,
4171
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
4172
+ Dropdown,
4173
+ {
4174
+ align: "end",
4175
+ className: "june-doc__menu",
4176
+ trigger: ({ open: menuOpen, toggle }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "june-doc__btn june-doc__btn--icon june-doc__btn--ghost", "aria-label": "Download", title: "Download", "aria-haspopup": "menu", "aria-expanded": menuOpen, onClick: toggle, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, { name: "download", size: 16 }) }),
4177
+ children: (dismiss) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { role: "menu", "aria-label": "Download options", children: formats.map((format2) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
4178
+ "button",
4179
+ {
4180
+ type: "button",
4181
+ role: "menuitem",
4182
+ className: "june-doc__menu-item",
4183
+ onClick: () => {
4184
+ dismiss();
4185
+ void handleExport(format2);
4186
+ },
4187
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "june-doc__menu-label", children: _nullishCoalesce(FORMAT_LABEL[format2], () => ( format2.toUpperCase())) })
4188
+ },
4189
+ format2
4190
+ )) })
4191
+ }
4192
+ )
4193
+ ] })
4086
4194
  ] }),
4087
4195
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "june-doc-card__canvas", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "june-doc-card__sheet", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "june-doc__prose", dangerouslySetInnerHTML: { __html: html } }) }) })
4088
4196
  ] }) : null,
4089
- open && typeof document !== "undefined" ? _reactdom.createPortal.call(void 0,
4197
+ open && presentation === "inline" ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "section", { className: "june-doc june-doc-inline", "data-theme": resolvedTheme, "aria-label": title, onKeyDown: (event) => {
4198
+ if (event.key !== "Escape" || event.defaultPrevented) return;
4199
+ if (event.currentTarget.querySelector(".june-doc--fullscreen")) return;
4200
+ close();
4201
+ }, children: [
4202
+ closeBar,
4203
+ editor
4204
+ ] }) : null,
4205
+ open && presentation === "side-panel" && typeof document !== "undefined" ? _reactdom.createPortal.call(void 0,
4090
4206
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "june-doc-modal", "data-theme": resolvedTheme, onMouseDown: close, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
4091
4207
  "div",
4092
4208
  {
@@ -4096,6 +4212,7 @@ function DocumentPreview(props) {
4096
4212
  "aria-label": title,
4097
4213
  tabIndex: -1,
4098
4214
  "data-theme": resolvedTheme,
4215
+ style: panelWidth ? { width: panelWidth, maxWidth: "100vw" } : void 0,
4099
4216
  onMouseDown: (event) => event.stopPropagation(),
4100
4217
  onKeyDown: (event) => {
4101
4218
  if (event.key !== "Escape" || event.defaultPrevented) return;
@@ -4103,25 +4220,8 @@ function DocumentPreview(props) {
4103
4220
  close();
4104
4221
  },
4105
4222
  children: [
4106
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "june-doc-modal__bar", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "button", { type: "button", className: "june-doc__btn june-doc__btn--ghost", "aria-label": "Close document", onClick: close, children: [
4107
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, { name: "close", size: 16 }),
4108
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Close" })
4109
- ] }) }),
4110
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "june-doc-modal__body", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
4111
- DocumentEditorImpl,
4112
- {
4113
- documentId: props.documentId,
4114
- title: props.title,
4115
- content: props.content,
4116
- documentType: props.documentType,
4117
- status: props.status,
4118
- editable: props.editable,
4119
- exportFormats: props.exportFormats,
4120
- theme: props.theme,
4121
- generating: props.generating,
4122
- options: props.options
4123
- }
4124
- ) })
4223
+ closeBar,
4224
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "june-doc-modal__body", children: editor })
4125
4225
  ]
4126
4226
  }
4127
4227
  ) }),
@@ -4132,7 +4232,7 @@ function DocumentPreview(props) {
4132
4232
 
4133
4233
  // src/features/document-editor/document-component.tsx
4134
4234
 
4135
- var DOCUMENT_COMPONENT_DESCRIPTION = 'Custom component. An editable document. DocumentEditor(documentId, title, content, documentType?, status?, editable?, exportFormats?). Place it in the root container (Card or Stack). "content" is the full document body as one Markdown string. Reuse documentId when revising the same document. Use it only when the user asks to create or revise a document.';
4235
+ var DOCUMENT_COMPONENT_DESCRIPTION = 'Custom component. An editable document. DocumentEditor(documentId, title, content, documentType?, status?, editable?, exportFormats?, presentation?). Place it in the root container (Card or Stack). "content" is the full document body as one Markdown string. Reuse documentId when revising the same document. Use it only when the user asks to create or revise a document. presentation is "inline" or "side-panel"; omit it to use the app default.';
4136
4236
  var documentProps = _v4.z.object({
4137
4237
  documentId: _v4.z.string().describe("Stable id. Reuse it when revising the same document."),
4138
4238
  title: _v4.z.string().describe("Document title. Do not repeat it as a heading in content."),
@@ -4140,7 +4240,8 @@ var documentProps = _v4.z.object({
4140
4240
  documentType: _v4.z.string().optional().describe("Kind of document, such as proposal, contract or invoice."),
4141
4241
  status: _v4.z.string().optional().describe('Use "draft" for generated documents.'),
4142
4242
  editable: _v4.z.boolean().optional().describe("Whether the user can edit. Defaults to true."),
4143
- exportFormats: _v4.z.array(_v4.z.string()).optional().describe("Export formats to offer, such as html, markdown, docx.")
4243
+ exportFormats: _v4.z.array(_v4.z.string()).optional().describe("Export formats to offer, such as html, markdown, docx."),
4244
+ presentation: _v4.z.enum(["inline", "side-panel"]).optional().describe('Where Edit opens the editor: "inline" in the chat, or "side-panel". Omit to use the app default.')
4144
4245
  });
4145
4246
  function DocumentEditor(props) {
4146
4247
  const { isStreaming } = useJuneRuntime();
@@ -4158,10 +4259,10 @@ function OpenUIDocument({ props }) {
4158
4259
  documentType: props.documentType,
4159
4260
  status: props.status,
4160
4261
  editable: props.editable,
4161
- exportFormats: props.exportFormats
4262
+ exportFormats: props.exportFormats,
4263
+ presentation: props.presentation
4162
4264
  };
4163
4265
  if (isStreaming) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DocumentDraft, { title: props.title, state: "drafting" });
4164
- if (props.editable === false) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DocumentEditor, { ...shared });
4165
4266
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DocumentPreview, { ...shared });
4166
4267
  }
4167
4268
  var JuneDocumentEditorComponent = _reactlang.defineComponent.call(void 0, {
@@ -4200,7 +4301,7 @@ function getDocumentEditorRules(options = {}) {
4200
4301
  return [
4201
4302
  `WHEN TO USE ${name}: use it only when the user asks you to create, draft, write, prepare, generate or revise an editable document (${types}, or similar). Put the finished document inside ${name}.`,
4202
4303
  `WHEN NOT TO USE ${name}: for explanations ("explain what an NDA is"), factual answers, comparisons, brainstorming and general questions, answer with normal text and the other components. Never open ${name} for those.`,
4203
- `${name}(documentId, title, content, documentType?, status?, editable?, exportFormats?): "content" is the whole document body as Markdown inside ONE double-quoted string. Write line breaks as \\n and escape double quotes as \\". Supported Markdown: headings (#, ##, ###), paragraphs, **bold**, *italic*, lists, > quotes, [links](https://...), and tables.`,
4304
+ `${name}(documentId, title, content, documentType?, status?, editable?, exportFormats?, presentation?): "content" is the whole document body as Markdown inside ONE double-quoted string. Write line breaks as \\n and escape double quotes as \\". Supported Markdown: headings (#, ##, ###), paragraphs, **bold**, *italic*, lists, > quotes, [links](https://...), and tables. presentation is optional: "inline" or "side-panel". Omit it to use the app default.`,
4204
4305
  `Do not repeat the title as a heading inside "content"; the title is shown separately. Structure the document with headings, short paragraphs and tables where useful. Keep a professional tone.`,
4205
4306
  `EDITING: when the user asks to change an existing document (add a section, rewrite a part, change the title), write ${name} again with the SAME documentId and the COMPLETE updated content, starting from the current document text you were given. Copy every unchanged section exactly as it was. Change only what was requested. The app merges your version with the user's own edits.`,
4206
4307
  `If the user asks for a document but leaves out details, write the document anyway and use clear placeholders such as [CLIENT NAME], [DATE], [AMOUNT]. Do not stop to ask unless the request is impossible to interpret.`,
@@ -4273,13 +4374,13 @@ function ToolApproval({
4273
4374
  className
4274
4375
  }) {
4275
4376
  const labels = { ...defaultToolApprovalLabels, ...labelOverrides };
4276
- const options = _optionalChain([request, 'access', _428 => _428.options, 'optionalAccess', _429 => _429.length]) ? request.options : ["approve", "reject"];
4377
+ const options = _optionalChain([request, 'access', _434 => _434.options, 'optionalAccess', _435 => _435.length]) ? request.options : ["approve", "reject"];
4277
4378
  const [draft, setDraft] = _react.useState.call(void 0, null);
4278
4379
  const [draftError, setDraftError] = _react.useState.call(void 0, null);
4279
4380
  const titleId = _react.useId.call(void 0, );
4280
4381
  const pending = status === "pending";
4281
4382
  const decide = (decision) => {
4282
- if (!disabled && pending) _optionalChain([onDecide, 'optionalCall', _430 => _430(decision)]);
4383
+ if (!disabled && pending) _optionalChain([onDecide, 'optionalCall', _436 => _436(decision)]);
4283
4384
  };
4284
4385
  const saveEdit = () => {
4285
4386
  let editedArguments;
@@ -4374,7 +4475,7 @@ function useToolApproval() {
4374
4475
  const settle = _react.useCallback.call(void 0, (id, decision) => {
4375
4476
  const resolve = waiters.current.get(id);
4376
4477
  waiters.current.delete(id);
4377
- _optionalChain([resolve, 'optionalCall', _431 => _431(decision)]);
4478
+ _optionalChain([resolve, 'optionalCall', _437 => _437(decision)]);
4378
4479
  }, []);
4379
4480
  const request = _react.useCallback.call(void 0, (input) => {
4380
4481
  const id = _nullishCoalesce(input.id, () => ( nextId()));
@@ -4463,7 +4564,7 @@ function createLangGraphExtractor(options = {}) {
4463
4564
  if (!Array.isArray(parsed)) return null;
4464
4565
  const [chunk, metadata] = parsed;
4465
4566
  if (!chunk || typeof chunk !== "object" || !isAiMessage(chunk)) return null;
4466
- if (nodes && !(typeof _optionalChain([metadata, 'optionalAccess', _432 => _432.langgraph_node]) === "string" && nodes.has(metadata.langgraph_node))) return null;
4567
+ if (nodes && !(typeof _optionalChain([metadata, 'optionalAccess', _438 => _438.langgraph_node]) === "string" && nodes.has(metadata.langgraph_node))) return null;
4467
4568
  return messageContentToText(chunk.content) || null;
4468
4569
  }
4469
4570
  if (base === "messages/partial" || base === "messages/complete") {
@@ -4502,8 +4603,8 @@ function interruptToApprovalRequests(value, idPrefix = "interrupt") {
4502
4603
  const configs = Array.isArray(hitl.review_configs) ? hitl.review_configs : [];
4503
4604
  return hitl.action_requests.flatMap((action, index) => {
4504
4605
  if (!action || typeof action.name !== "string") return [];
4505
- const config = configs.find((c) => _optionalChain([c, 'optionalAccess', _433 => _433.action_name]) === action.name);
4506
- const allowed = Array.isArray(_optionalChain([config, 'optionalAccess', _434 => _434.allowed_decisions])) ? config.allowed_decisions.filter(
4606
+ const config = configs.find((c) => _optionalChain([c, 'optionalAccess', _439 => _439.action_name]) === action.name);
4607
+ const allowed = Array.isArray(_optionalChain([config, 'optionalAccess', _440 => _440.allowed_decisions])) ? config.allowed_decisions.filter(
4507
4608
  (d) => d === "approve" || d === "reject" || d === "edit"
4508
4609
  ) : void 0;
4509
4610
  return [
@@ -4587,4 +4688,8 @@ function interruptToApprovalRequests(value, idPrefix = "interrupt") {
4587
4688
 
4588
4689
 
4589
4690
 
4590
- exports.useJuneTheme = useJuneTheme; exports.JuneRuntimeContext = JuneRuntimeContext; exports.useJuneRuntime = useJuneRuntime; exports.defaultParseActionEvent = defaultParseActionEvent; exports.runAction = runAction; exports.createActionHandler = createActionHandler; exports.JuneDocumentContext = JuneDocumentContext; exports.useDocumentOptions = useDocumentOptions; exports.mergeDocuments = mergeDocuments; exports.createDocumentStore = createDocumentStore; exports.rememberDocumentEcho = rememberDocumentEcho; exports.isDocumentEcho = isDocumentEcho; exports.getDefaultDocumentStore = getDefaultDocumentStore; exports.updateDocumentInProgram = updateDocumentInProgram; exports.readDocumentFromProgram = readDocumentFromProgram; exports.useDocumentBridge = useDocumentBridge; exports.DocumentBridge = DocumentBridge; exports.darkTheme = darkTheme; exports.lightTheme = lightTheme; exports.isThemeSet = isThemeSet; exports.resolveThemeVars = resolveThemeVars; exports.createTheme = createTheme; exports.useResolvedTheme = useResolvedTheme; exports.JuneThemeProvider = JuneThemeProvider; exports.normalizeProgram = normalizeProgram; exports.splitResponse = splitResponse; exports.resolveMixedContent = resolveMixedContent; exports.JuneErrorBoundary = JuneErrorBoundary; exports.MarkdownText = MarkdownText; exports.JuneRenderer = JuneRenderer; exports.validateComponentDefinition = validateComponentDefinition; exports.defineComponent = defineComponent; exports.isJuneComponent = isJuneComponent; exports.ComponentRegistry = ComponentRegistry; exports.createComponentRegistry = createComponentRegistry; exports.useRegistryLibrary = useRegistryLibrary; exports.defineJuneComponent = defineJuneComponent; exports.createJuneLibrary = createJuneLibrary; exports.defineJuneAction = defineJuneAction; exports.toAsyncIterable = toAsyncIterable; exports.consumeStream = consumeStream; exports.sseToText = sseToText; exports.jsonFieldExtractor = jsonFieldExtractor; exports.fetchStream = fetchStream; exports.useJuneStream = useJuneStream; exports.registerDocumentExporter = registerDocumentExporter; exports.listDocumentExporters = listDocumentExporters; exports.exportDocument = exportDocument; exports.downloadResult = downloadResult; exports.copyDocumentToClipboard = copyDocumentToClipboard; exports.ALL_EXPORT_FORMATS = ALL_EXPORT_FORMATS; exports.DOCUMENT_COMPONENT_DESCRIPTION = DOCUMENT_COMPONENT_DESCRIPTION; exports.DocumentEditor = DocumentEditor; exports.JuneDocumentEditorComponent = JuneDocumentEditorComponent; exports.withDocumentEditor = withDocumentEditor; exports.getDocumentEditorRules = getDocumentEditorRules; exports.getDocumentEditorInstructions = getDocumentEditorInstructions; exports.documentPromptOptions = documentPromptOptions; exports.serializeDocumentsForAgent = serializeDocumentsForAgent; exports.defaultToolApprovalLabels = defaultToolApprovalLabels; exports.ToolApproval = ToolApproval; exports.ToolApprovalList = ToolApprovalList; exports.useToolApproval = useToolApproval; exports.messageContentToText = messageContentToText; exports.createLangGraphExtractor = createLangGraphExtractor; exports.langGraphStreamOptions = langGraphStreamOptions; exports.readLangGraphInterrupts = readLangGraphInterrupts; exports.interruptToApprovalRequests = interruptToApprovalRequests;
4691
+
4692
+
4693
+
4694
+
4695
+ exports.useJuneTheme = useJuneTheme; exports.JuneRuntimeContext = JuneRuntimeContext; exports.useJuneRuntime = useJuneRuntime; exports.defaultParseActionEvent = defaultParseActionEvent; exports.runAction = runAction; exports.createActionHandler = createActionHandler; exports.JuneDocumentContext = JuneDocumentContext; exports.DocumentEditorConfigContext = DocumentEditorConfigContext; exports.useDocumentEditorConfig = useDocumentEditorConfig; exports.useDocumentOptions = useDocumentOptions; exports.mergeDocuments = mergeDocuments; exports.createDocumentStore = createDocumentStore; exports.rememberDocumentEcho = rememberDocumentEcho; exports.isDocumentEcho = isDocumentEcho; exports.getDefaultDocumentStore = getDefaultDocumentStore; exports.updateDocumentInProgram = updateDocumentInProgram; exports.readDocumentFromProgram = readDocumentFromProgram; exports.useDocumentBridge = useDocumentBridge; exports.DocumentBridge = DocumentBridge; exports.darkTheme = darkTheme; exports.lightTheme = lightTheme; exports.isThemeSet = isThemeSet; exports.resolveThemeVars = resolveThemeVars; exports.createTheme = createTheme; exports.useResolvedTheme = useResolvedTheme; exports.JuneThemeProvider = JuneThemeProvider; exports.normalizeProgram = normalizeProgram; exports.splitResponse = splitResponse; exports.resolveMixedContent = resolveMixedContent; exports.JuneErrorBoundary = JuneErrorBoundary; exports.MarkdownText = MarkdownText; exports.JuneRenderer = JuneRenderer; exports.validateComponentDefinition = validateComponentDefinition; exports.defineComponent = defineComponent; exports.isJuneComponent = isJuneComponent; exports.ComponentRegistry = ComponentRegistry; exports.createComponentRegistry = createComponentRegistry; exports.useRegistryLibrary = useRegistryLibrary; exports.defineJuneComponent = defineJuneComponent; exports.createJuneLibrary = createJuneLibrary; exports.defineJuneAction = defineJuneAction; exports.toAsyncIterable = toAsyncIterable; exports.consumeStream = consumeStream; exports.sseToText = sseToText; exports.jsonFieldExtractor = jsonFieldExtractor; exports.fetchStream = fetchStream; exports.useJuneStream = useJuneStream; exports.registerDocumentExporter = registerDocumentExporter; exports.listDocumentExporters = listDocumentExporters; exports.exportDocument = exportDocument; exports.downloadResult = downloadResult; exports.copyDocumentToClipboard = copyDocumentToClipboard; exports.ALL_EXPORT_FORMATS = ALL_EXPORT_FORMATS; exports.resolveDocumentPresentation = resolveDocumentPresentation; exports.documentPanelWidth = documentPanelWidth; exports.DOCUMENT_COMPONENT_DESCRIPTION = DOCUMENT_COMPONENT_DESCRIPTION; exports.DocumentEditor = DocumentEditor; exports.JuneDocumentEditorComponent = JuneDocumentEditorComponent; exports.withDocumentEditor = withDocumentEditor; exports.getDocumentEditorRules = getDocumentEditorRules; exports.getDocumentEditorInstructions = getDocumentEditorInstructions; exports.documentPromptOptions = documentPromptOptions; exports.serializeDocumentsForAgent = serializeDocumentsForAgent; exports.defaultToolApprovalLabels = defaultToolApprovalLabels; exports.ToolApproval = ToolApproval; exports.ToolApprovalList = ToolApprovalList; exports.useToolApproval = useToolApproval; exports.messageContentToText = messageContentToText; exports.createLangGraphExtractor = createLangGraphExtractor; exports.langGraphStreamOptions = langGraphStreamOptions; exports.readLangGraphInterrupts = readLangGraphInterrupts; exports.interruptToApprovalRequests = interruptToApprovalRequests;