@datalking/begonia-react 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/binding/BrowserPaginatedEditorSurface.d.ts +44 -0
- package/dist/binding/HeaderFooterScratchMount.d.ts +25 -0
- package/dist/binding/PaginatedLayoutView.d.ts +21 -2
- package/dist/binding/PaginatedPageOverlayView.d.ts +44 -0
- package/dist/binding/VirtualPagedPreview.d.ts +36 -2
- package/dist/binding/browser-header-footer-bands.d.ts +98 -0
- package/dist/binding/browser-header-footer-format-bar.d.ts +21 -0
- package/dist/binding/browser-paginated-preview-drag-state.d.ts +2 -0
- package/dist/binding/headless.d.ts +1 -1
- package/dist/binding/index.d.ts +2 -0
- package/dist/binding/paginated-preview-doc-style.d.ts +40 -0
- package/dist/binding/paginated-preview-font-family.d.ts +19 -0
- package/dist/binding/paginated-scroll-axis-host.d.ts +32 -0
- package/dist/binding/preview-link-activation.d.ts +71 -0
- package/dist/binding/resolve-snapshot-comment-state.d.ts +32 -0
- package/dist/binding/use-browser-header-footer-editing.d.ts +114 -0
- package/dist/binding/use-header-footer-scratch-surface.d.ts +48 -0
- package/dist/binding/use-owned-destroyable.d.ts +9 -0
- package/dist/binding/use-undo-redo-hotkeys.d.ts +45 -0
- package/dist/binding/useVirtualPagedPreviewState.d.ts +13 -3
- package/dist/binding/v1.d.ts +16 -0
- package/dist/binding/virtual-paged-preview-comment-highlight.d.ts +33 -0
- package/dist/binding/virtual-paged-preview-drag-session.d.ts +1 -1
- package/dist/binding/virtual-paged-preview-interaction.d.ts +2 -2
- package/dist/binding/virtual-paged-preview-list-marker.d.ts +42 -0
- package/dist/binding/virtual-paged-preview-renderers/virtual-paged-preview-block-text.d.ts +21 -6
- package/dist/binding/virtual-paged-preview-renderers/virtual-paged-preview-block-views.d.ts +18 -2
- package/dist/binding/virtual-paged-preview-review-attributes.d.ts +78 -0
- package/dist/binding/virtual-paged-preview-text-lines.d.ts +4 -0
- package/dist/chunk-LIAB6VEG.js +1 -0
- package/dist/editor-surface.css +236 -12
- package/dist/index.d.ts +6 -0
- package/dist/index.js +1 -1
- package/dist/v1.d.ts +4 -2
- package/dist/v1.js +1 -1
- package/package.json +15 -13
- package/dist/binding/paginated-preview-defaults.d.ts +0 -3
- package/dist/binding/virtual-paged-preview-table-metrics.d.ts +0 -1
- package/dist/chunk-ORLGCG23.js +0 -1
package/dist/v1.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as $t,B as Ut,C as jt,D as Ht,E as zt,F as Kt,G as Vt,H as Xt,I as qt,J as Gt,K as ue,L,M as _t,N as Yt,O as Jt,P as Qt,Q as Zt,R as er,S as tr,T as rr,U as or,V as pe,W as ar,a as vt,b as V,c as X,d as le,e as ht,f as wt,g as yt,h as Bt,i as kt,j as Pt,k as Nt,l as St,m as Ct,n as Et,o as At,p as Ot,q as de,r as Rt,s as Mt,t as ce,u as Dt,v as It,w as Tt,x as Ft,y as Wt,z as Lt}from"./chunk-ORLGCG23.js";import{useEffect as oe,useMemo as ae,useState as qe}from"react";import{createBrowserEditorBackendAdapter as Ge,resolveBrowserEditorUiController as _e}from"@datalking/begonia-browser/v1";import{useEffect as We,useMemo as Le}from"react";import{summarizeReviewTimeline as $e}from"@datalking/begonia-document-api/review";import{createBrowserAdvancedOoxmlInspectorController as Ue}from"@datalking/begonia-browser/ooxml";import{emptyBrowserAdvancedOoxmlInspectorSnapshot as je}from"@datalking/begonia-browser/ooxml";import{useState as F}from"react";import{appendEmptyAxisDraft as Oe,appendEmptySeriesDraft as Re,axisDraftsFromModel as Me,legendDraftFromModel as De,mergeChartModelWithDrafts as Ie,seriesDraftsFromModel as Te}from"@datalking/begonia-browser/ooxml";import{jsx as c,jsxs as v}from"react/jsx-runtime";function me({controller:e,selection:t}){let[r,a]=F(t.model.title??""),[i,l]=F(t.model.chartType??""),[o,n]=F(t.model.textBody?.plainText??""),[x,u]=F(Te(t.model)),[g,S]=F(Me(t.model)),[w,y]=F(De(t.model)),f=(s,p)=>u(d=>d.map((k,P)=>P===s?{...k,...p}:k)),h=(s,p)=>S(d=>d.map((k,P)=>P===s?{...k,...p}:k));return v("div",{className:"grid gap-3",children:[v("div",{className:"grid gap-1",children:[c("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Chart Title"}),c("input",{value:r,onChange:s=>a(s.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),v("div",{className:"grid gap-1 md:grid-cols-2",children:[v("div",{className:"grid gap-1",children:[c("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Chart Type"}),c("input",{value:i,onChange:s=>l(s.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),v("div",{className:"grid gap-1",children:[c("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Coverage"}),v("div",{className:"flex flex-wrap gap-2",children:[v("span",{className:"rounded-full bg-slate-100 px-2 py-1 text-[11px] font-semibold text-slate-700",children:[t.seriesCount," series"]}),v("span",{className:"rounded-full bg-slate-100 px-2 py-1 text-[11px] font-semibold text-slate-700",children:[t.categoryCount," categories"]})]})]})]}),v("div",{className:"grid gap-1",children:[c("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Text Body"}),c("textarea",{value:o,onChange:s=>n(s.target.value),rows:3,className:"min-h-20 rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),v("div",{className:"grid gap-2",children:[v("div",{className:"flex items-center justify-between gap-3",children:[c("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Series"}),c("button",{type:"button",className:"rounded-full border border-slate-200 px-3 py-1.5 text-xs font-semibold text-slate-700",onClick:()=>u(s=>Re(s)),children:"Add series"})]}),x.length===0?c("div",{className:"rounded-2xl border border-dashed border-slate-200 bg-slate-50 px-3 py-4 text-sm text-slate-500",children:"No chart series yet."}):null,x.map((s,p)=>v("div",{className:"grid gap-2 rounded-2xl border border-slate-200 bg-slate-50 p-3",children:[v("div",{className:"grid gap-2 md:grid-cols-3",children:[c("input",{value:s.name,onChange:d=>f(p,{name:d.target.value}),placeholder:"Series name",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"}),c("input",{value:s.id,onChange:d=>f(p,{id:d.target.value}),placeholder:"Series id",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"}),c("input",{value:s.order,onChange:d=>f(p,{order:d.target.value}),placeholder:"Order",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),c("input",{value:s.categories,onChange:d=>f(p,{categories:d.target.value}),placeholder:"Categories, comma separated",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"}),c("input",{value:s.values,onChange:d=>f(p,{values:d.target.value}),placeholder:"Values, comma separated",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"}),c("div",{className:"flex justify-end",children:c("button",{type:"button",className:"rounded-full border border-rose-200 bg-rose-50 px-3 py-1.5 text-xs font-semibold text-rose-700",onClick:()=>u(d=>d.filter((k,P)=>P!==p)),children:"Remove row"})})]},`${t.record.objectId}-${p}`))]}),v("div",{className:"grid gap-2",children:[v("div",{className:"flex items-center justify-between gap-3",children:[c("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Axes"}),c("button",{type:"button",className:"rounded-full border border-slate-200 px-3 py-1.5 text-xs font-semibold text-slate-700",onClick:()=>S(s=>Oe(s)),children:"Add axis"})]}),g.length===0?c("div",{className:"rounded-2xl border border-dashed border-slate-200 bg-slate-50 px-3 py-4 text-sm text-slate-500",children:"No chart axes yet."}):null,g.map((s,p)=>v("div",{className:"grid gap-2 rounded-2xl border border-slate-200 bg-slate-50 p-3",children:[v("div",{className:"grid gap-2 md:grid-cols-2",children:[c("input",{value:s.id,onChange:d=>h(p,{id:d.target.value}),placeholder:"Axis id",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"}),c("input",{value:s.title,onChange:d=>h(p,{title:d.target.value}),placeholder:"Axis title",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),v("div",{className:"grid gap-2 md:grid-cols-3",children:[v("select",{value:s.kind,onChange:d=>h(p,{kind:d.target.value}),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300",children:[c("option",{value:"category",children:"Category"}),c("option",{value:"value",children:"Value"}),c("option",{value:"series",children:"Series"}),c("option",{value:"date",children:"Date"}),c("option",{value:"unknown",children:"Unknown"})]}),v("select",{value:s.orientation,onChange:d=>h(p,{orientation:d.target.value}),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300",children:[c("option",{value:"unknown",children:"Orientation"}),c("option",{value:"minMax",children:"Min to Max"}),c("option",{value:"maxMin",children:"Max to Min"})]}),c("input",{value:s.formatCode,onChange:d=>h(p,{formatCode:d.target.value}),placeholder:"Format code",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),c("div",{className:"flex justify-end",children:c("button",{type:"button",className:"rounded-full border border-rose-200 bg-rose-50 px-3 py-1.5 text-xs font-semibold text-rose-700",onClick:()=>S(d=>d.filter((k,P)=>P!==p)),children:"Remove axis"})})]},`${t.record.objectId}-axis-${p}`))]}),v("div",{className:"grid gap-2",children:[c("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Legend"}),v("div",{className:"grid gap-2 md:grid-cols-2",children:[v("select",{value:w.enabled,onChange:s=>y(p=>({...p,enabled:s.target.value})),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300",children:[c("option",{value:"true",children:"Enabled"}),c("option",{value:"false",children:"Absent"})]}),v("select",{value:w.visible,disabled:w.enabled==="false",onChange:s=>y(p=>({...p,visible:s.target.value})),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300 disabled:cursor-not-allowed disabled:bg-slate-100",children:[c("option",{value:"true",children:"Visible"}),c("option",{value:"false",children:"Hidden"})]})]}),v("div",{className:"grid gap-2 md:grid-cols-2",children:[v("select",{value:w.position,disabled:w.enabled==="false",onChange:s=>y(p=>({...p,position:s.target.value})),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300 disabled:cursor-not-allowed disabled:bg-slate-100",children:[c("option",{value:"unknown",children:"Position"}),c("option",{value:"left",children:"Left"}),c("option",{value:"right",children:"Right"}),c("option",{value:"top",children:"Top"}),c("option",{value:"bottom",children:"Bottom"}),c("option",{value:"topRight",children:"Top Right"})]}),v("select",{value:w.overlay,disabled:w.enabled==="false",onChange:s=>y(p=>({...p,overlay:s.target.value})),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300 disabled:cursor-not-allowed disabled:bg-slate-100",children:[c("option",{value:"unknown",children:"Overlay"}),c("option",{value:"true",children:"Overlay"}),c("option",{value:"false",children:"No overlay"})]})]})]}),c("button",{type:"button",className:"rounded-full border border-teal-200 bg-teal-50 px-3 py-2 text-sm font-semibold text-teal-700",onClick:()=>e.replaceSelectedChartModel(Ie(t.model,r,i,o,x,{axes:g,legend:w})),children:"Apply chart"})]})}import{useState as be}from"react";import{jsx as R,jsxs as $}from"react/jsx-runtime";function xe({controller:e,selection:t}){let[r,a]=be(t.plainText),[i,l]=be(t.displayMode);return $("div",{className:"grid gap-3",children:[$("div",{className:"grid gap-1",children:[R("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Equation Text"}),R("textarea",{value:r,onChange:o=>a(o.target.value),rows:4,className:"min-h-24 rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),$("div",{className:"grid gap-1",children:[R("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Display Mode"}),$("select",{value:i,onChange:o=>l(o.target.value==="block"?"block":"inline"),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300",children:[R("option",{value:"inline",children:"Inline"}),R("option",{value:"block",children:"Block"})]})]}),$("div",{className:"grid gap-1",children:[R("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Detected Structures"}),R("div",{className:"flex flex-wrap gap-2",children:t.structures.length===0?R("span",{className:"rounded-full bg-slate-100 px-2 py-1 text-[11px] font-medium text-slate-500",children:"Plain text"}):t.structures.map(o=>R("span",{className:"rounded-full bg-sky-100 px-2 py-1 text-[11px] font-semibold text-sky-700",children:o},o))})]}),R("button",{type:"button",className:"rounded-full border border-teal-200 bg-teal-50 px-3 py-2 text-sm font-semibold text-teal-700",onClick:()=>e.setSelectedMathPlainText(r,i),children:"Apply equation"})]})}import{useState as A}from"react";import{mergeShapeModelWithDrafts as Fe}from"@datalking/begonia-browser/ooxml";import{jsx as m,jsxs as B}from"react/jsx-runtime";function ge({controller:e,selection:t}){let[r,a]=A(t.model.label??""),[i,l]=A(t.model.shapeType??""),[o,n]=A(t.model.textBody?.plainText??""),[x,u]=A(t.model.geometry?.preset??""),[g,S]=A(t.model.fill?.kind??"unknown"),[w,y]=A(t.model.fill?.color??""),[f,h]=A(t.model.stroke?.color??""),[s,p]=A(t.model.stroke?.widthEmu==null?"":String(t.model.stroke.widthEmu)),[d,k]=A(t.model.stroke?.dash??""),[P,D]=A(t.model.transform?.widthEmu==null?"":String(t.model.transform.widthEmu)),[M,E]=A(t.model.transform?.heightEmu==null?"":String(t.model.transform.heightEmu)),[O,Z]=A(t.model.transform?.rotation==null?"":String(t.model.transform.rotation)),[T,ee]=A(t.model.anchor?.kind??"unknown"),[z,te]=A(t.model.anchor?.wrap??"unknown");return B("div",{className:"grid gap-3",children:[B("div",{className:"grid gap-2 md:grid-cols-2",children:[B("div",{className:"grid gap-1",children:[m("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Shape Label"}),m("input",{value:r,onChange:b=>a(b.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),B("div",{className:"grid gap-1",children:[m("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Shape Type"}),m("input",{value:i,onChange:b=>l(b.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]})]}),B("div",{className:"grid gap-1",children:[m("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Text Body"}),m("textarea",{value:o,onChange:b=>n(b.target.value),rows:3,className:"min-h-20 rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),B("div",{className:"grid gap-2 md:grid-cols-2",children:[B("div",{className:"grid gap-1",children:[m("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Geometry Preset"}),m("input",{value:x,onChange:b=>u(b.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),B("div",{className:"grid gap-1",children:[m("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Fill Color"}),m("input",{value:w,onChange:b=>y(b.target.value),placeholder:"FFF2CC",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]})]}),B("div",{className:"grid gap-2 md:grid-cols-3",children:[B("div",{className:"grid gap-1",children:[m("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Fill Kind"}),B("select",{value:g,onChange:b=>S(b.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300",children:[m("option",{value:"unknown",children:"Unknown"}),m("option",{value:"solid",children:"Solid"}),m("option",{value:"scheme",children:"Scheme"}),m("option",{value:"none",children:"None"})]})]}),B("div",{className:"grid gap-1",children:[m("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Stroke Color"}),m("input",{value:f,onChange:b=>h(b.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),B("div",{className:"grid gap-1",children:[m("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Stroke Dash"}),m("input",{value:d,onChange:b=>k(b.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]})]}),B("div",{className:"grid gap-2 md:grid-cols-3",children:[B("div",{className:"grid gap-1",children:[m("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Stroke Width (EMU)"}),m("input",{value:s,onChange:b=>p(b.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),B("div",{className:"grid gap-1",children:[m("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Width (EMU)"}),m("input",{value:P,onChange:b=>D(b.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),B("div",{className:"grid gap-1",children:[m("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Height (EMU)"}),m("input",{value:M,onChange:b=>E(b.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]})]}),B("div",{className:"grid gap-2 md:grid-cols-3",children:[B("div",{className:"grid gap-1",children:[m("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Rotation"}),m("input",{value:O,onChange:b=>Z(b.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),B("div",{className:"grid gap-1",children:[m("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Anchor Kind"}),B("select",{value:T,onChange:b=>ee(b.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300",children:[m("option",{value:"unknown",children:"Unknown"}),m("option",{value:"inline",children:"Inline"}),m("option",{value:"anchor",children:"Anchor"})]})]}),B("div",{className:"grid gap-1",children:[m("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Wrap"}),B("select",{value:z,onChange:b=>te(b.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300",children:[m("option",{value:"unknown",children:"Unknown"}),m("option",{value:"none",children:"None"}),m("option",{value:"square",children:"Square"}),m("option",{value:"tight",children:"Tight"}),m("option",{value:"through",children:"Through"}),m("option",{value:"topAndBottom",children:"Top and Bottom"})]})]})]}),m("button",{type:"button",className:"rounded-full border border-teal-200 bg-teal-50 px-3 py-2 text-sm font-semibold text-teal-700",onClick:()=>e.replaceSelectedShapeModel(Fe(t.model,{label:r,shapeType:i,textBody:o,geometryPreset:x,fillKind:g,fillColor:w,strokeColor:f,strokeWidthEmu:s,strokeDash:d,widthEmu:P,heightEmu:M,rotation:O,anchorKind:T,anchorWrap:z})),children:"Apply shape"})]})}import{jsx as C,jsxs as N}from"react/jsx-runtime";function q(...e){return e.filter(Boolean).join(" ")}function He(e){return`${e.family}:${e.record.objectId}:${JSON.stringify(e.model)}`}function ze(e){return e==="math"?"bg-sky-100 text-sky-700":e==="chart"?"bg-amber-100 text-amber-700":"bg-emerald-100 text-emerald-700"}function Ke(e){return e.kind==="revision"?e.relatedKinds.includes("insert")&&e.relatedKinds.includes("delete")?"bg-amber-100 text-amber-700":e.revision.kind==="insert"?"bg-emerald-100 text-emerald-700":e.revision.kind==="delete"?"bg-rose-100 text-rose-700":"bg-sky-100 text-sky-700":e.kind==="revision-decision"?e.decision==="accept"?"bg-emerald-100 text-emerald-700":"bg-rose-100 text-rose-700":e.kind==="comment-status"?"bg-sky-100 text-sky-700":e.kind==="comment-visibility"?"bg-cyan-100 text-cyan-700":e.kind==="comment-removal"?"bg-rose-100 text-rose-700":e.kind==="comment-edit"?"bg-violet-100 text-violet-700":e.kind==="comment-reply"?"bg-slate-100 text-slate-700":"bg-amber-100 text-amber-700"}function Ve(e){if(e.kind==="revision")return e.relatedKinds.includes("insert")&&e.relatedKinds.includes("delete")?"Replace":e.revision.kind==="insert"?"Insert":e.revision.kind==="delete"?"Delete":"Format";if(e.kind==="revision-decision"){let t=e.decision==="accept"?"Accepted":"Rejected";return e.relatedKinds.includes("format")?`${t} format`:e.relatedKinds.includes("insert")&&e.relatedKinds.includes("delete")?`${t} replace`:e.revisionKind==="insert"?`${t} insert`:e.revisionKind==="delete"?`${t} delete`:`${t} format`}return e.kind==="comment-thread"?"Comment":e.kind==="comment-reply"?"Reply":e.kind==="comment-status"?"Status":e.kind==="comment-visibility"?"Visibility":e.kind==="comment-removal"?"Removal":"Edit"}function Xe(e){if(e.kind==="revision")return e.revision.prompt??e.excerpt??e.authorName??e.authorId??"Tracked change";if(e.kind==="revision-decision"){let t=e.decision==="accept"?"Accepted":"Rejected";return e.relatedKinds.includes("format")?`${t} format`:e.relatedKinds.includes("insert")&&e.relatedKinds.includes("delete")?`${t} replace`:e.revisionKind==="insert"?`${t} insert`:e.revisionKind==="delete"?`${t} delete`:`${t} format`}return e.kind==="comment-status"?e.status==="resolved"?"Resolved thread":e.status==="open"?"Reopened thread":"Status change":e.kind==="comment-visibility"?e.internalAfter?"Made internal":"Made external":e.kind==="comment-removal"?e.activityKind==="thread-removed"?"Removed thread":"Removed reply":e.authorName??e.authorId??"Review activity"}function re({editor:e,className:t}){let r=Le(()=>e?Ue(e):null,[e]),a=V(r)??je();We(()=>()=>{r?.destroy()},[r]);let i=a.selected,l=i?He(i):null,o=r&&i?r.documentApi.review.timelineByObject(i.record.objectId,{actor:r.actor??void 0,enforceVisibilityPolicy:!0,sort:"desc"}):[],n=$e(o),x=o.slice(0,4);return N("aside",{className:q("grid gap-3",t),"aria-label":"Advanced OOXML inspector",children:[C("header",{className:"grid gap-1",children:N("div",{className:"flex items-center justify-between gap-3",children:[N("div",{children:[C("h2",{className:"text-sm font-semibold text-slate-900",children:"Advanced OOXML"}),C("p",{className:"text-xs text-slate-500",children:"Structured editor for selected math, chart, and shape nodes."})]}),C("span",{className:q("rounded-full px-2 py-1 text-[11px] font-semibold",a.trackingEnabled?"bg-amber-100 text-amber-700":"bg-slate-100 text-slate-600"),children:a.trackingEnabled?"Tracking On":"Direct Edit"})]})}),!i||!r?C("div",{className:"rounded-3xl border border-dashed border-slate-200 bg-slate-50 px-4 py-6 text-sm text-slate-500",children:"Select an equation, chart, or shape in the editor to inspect and edit its structured OOXML model."}):N("section",{className:"grid gap-4 rounded-3xl border border-slate-200 bg-white px-4 py-4 shadow-sm",children:[N("div",{className:"grid gap-2",children:[N("div",{className:"flex items-center justify-between gap-3",children:[N("div",{className:"flex items-center gap-2",children:[C("span",{className:q("rounded-full px-2 py-1 text-[11px] font-semibold",ze(i.family)),children:i.family}),C("span",{className:"rounded-full bg-slate-100 px-2 py-1 text-[11px] font-semibold text-slate-600",children:i.documentMode})]}),C("button",{type:"button",className:"rounded-full border border-rose-200 bg-rose-50 px-3 py-1.5 text-xs font-semibold text-rose-700",onClick:()=>r.removeSelected(),children:"Remove"})]}),N("div",{className:"grid gap-1 text-[11px] text-slate-500",children:[N("span",{children:["Object: ",i.record.objectId]}),N("span",{children:["Path: ",i.record.path.join(".")]})]})]}),i.family==="math"?C(xe,{controller:r,selection:i},l??void 0):null,i.family==="chart"?C(me,{controller:r,selection:i},l??void 0):null,i.family==="shape"?C(ge,{controller:r,selection:i},l??void 0):null,C("p",{className:"text-[11px] text-slate-500",children:a.trackingEnabled?"Inspector edits flow through tracked OOXML replacements so accept/reject stays available.":"Inspector edits apply directly to the selected OOXML object."}),N("section",{className:"grid gap-3 rounded-2xl border border-slate-200 bg-slate-50 p-3",children:[N("div",{className:"flex items-end justify-between gap-3",children:[N("div",{children:[C("h3",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-slate-600",children:"Object Review"}),N("p",{className:"text-xs text-slate-500",children:[n.total," linked item",n.total===1?"":"s"]})]}),N("div",{className:"flex flex-wrap justify-end gap-2 text-[11px] text-slate-500",children:[N("span",{children:[n.revisions," revision",n.revisions===1?"":"s"]}),N("span",{children:[n.commentThreads," thread",n.commentThreads===1?"":"s"]}),N("span",{children:[n.commentReplies," repl",n.commentReplies===1?"y":"ies"]})]})]}),x.length===0?C("div",{className:"rounded-2xl border border-dashed border-slate-200 bg-white px-3 py-4 text-xs text-slate-500",children:"No tracked review activity is currently linked to this OOXML object."}):C("div",{className:"grid gap-2",children:x.map(u=>N("div",{className:"grid gap-1 rounded-2xl border border-slate-200 bg-white px-3 py-3",children:[N("div",{className:"flex items-center justify-between gap-3",children:[C("span",{className:q("rounded-full px-2 py-1 text-[11px] font-semibold",Ke(u)),children:Ve(u)}),C("span",{className:"text-[11px] text-slate-400",children:u.authorName??u.authorId??"Unknown"})]}),C("p",{className:"text-xs text-slate-700",children:u.text||"Formatting change"}),C("p",{className:"text-[11px] text-slate-500",children:Xe(u)})]},u.id))})]})]})]})}import{jsx as fe}from"react/jsx-runtime";function Ye(e){return _e(e)}function Je({room:e,actor:t,collaborative:r,collaborationSession:a,documentMode:i,enableEmbeddedAdvancedOoxmlEditors:l=!0,features:o,fitWidthOptions:n,flowMode:x,initialContent:u,layoutMode:g,modules:S,onEditorChange:w,onTransaction:y,onUpdate:f,participant:h,permissionResolver:s,onControllerChange:p,onStateChange:d,schema:k,showAdvancedOoxmlInspector:P=!0,trackingEnabled:D=!0,viewSelect:M=!0,zoomMode:E,zoomPercent:O,...Z}){let[T,ee]=qe(null),z=ae(()=>Ge(),[]),te=ae(()=>({room:e,actor:t,collaborative:r,collaborationSession:a,documentMode:i,enableEmbeddedAdvancedOoxmlEditors:l,features:o,fitWidthOptions:n,flowMode:x,initialContent:u,layoutMode:g,modules:S,onTransaction:y,onUpdate:f,participant:h,permissionResolver:s,schema:k,trackingEnabled:D,viewSelect:M,zoomMode:E,zoomPercent:O}),[e,t,r,a,i,l,o,n,x,u,g,S,y,f,h,s,k,D,M,E,O]),b=ae(()=>Ye(T),[T]);return oe(()=>{p?.(b)},[b,p]),oe(()=>{if(d){if(!b){d(null);return}return d(b.getState()),b.subscribe(K=>{d(K)})}},[b,d]),oe(()=>()=>{p?.(null),d?.(null)},[p,d]),fe(pe,{...Z,backend:z,backendInput:te,sidebarStart:P?fe(re,{editor:T}):null,onEditorChange:K=>{ee(K),w?.(K)}})}import{jsx as _,jsxs as Ze}from"react/jsx-runtime";function ne(e,t){return typeof window<"u"?window.prompt(e,t):null}function G(e,t){return e?.commands[t]??null}function Qe({editor:e,snapshot:t}){if(!e||!t||!t.selection)return null;let r=t.selection.formatting,a=!t.editable,i=(y,f)=>{a||e.execute(y,f)},l=G(t,"text-color"),o=G(t,"highlight-color"),n=G(t,"font-size"),x=G(t,"font-family"),u=a?"Document is read-only in the current document mode.":void 0,g=(y,f,h)=>{let s=ne(`${y}. Enter a CSS color value or "none" to clear.`,f??"");if(s==null)return;let p=s.trim(),d=p.length===0||p.toLowerCase()==="none"?null:p;i(h,d)},S=()=>{let y=ne('Set font size in points. Enter "none" to clear.',r.fontSize==null?"":String(r.fontSize));if(y==null)return;let f=y.trim();if(!f||f.toLowerCase()==="none"){i("font-size",null);return}let h=Number(f.replace(/pt$/i,"").trim());Number.isFinite(h)&&h>0&&i("font-size",h)},w=()=>{let y=ne('Set font family. Enter "none" to clear.',r.fontFamily??"");if(y==null)return;let f=y.trim();i("font-family",!f||f.toLowerCase()==="none"?null:f)};return Ze("div",{className:"flex flex-wrap gap-2 rounded-[var(--ald-control-group-radius,20px)] border border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-toolbar-bg,#f8fafc)] p-2",children:[_(L,{active:l?.active??r.color!=null,mixed:l?.mixed??r.mixed?.color===!0,disabled:a||l?.disabled,label:r.color?`Text ${r.color}`:"Text Color",title:u,onClick:()=>g("Set text color",r.color,"text-color")}),_(L,{active:o?.active??r.highlight!=null,mixed:o?.mixed??r.mixed?.highlight===!0,disabled:a||o?.disabled,label:r.highlight?`Highlight ${r.highlight}`:"Highlight",title:u,onClick:()=>g("Set highlight color",r.highlight,"highlight-color")}),_(L,{active:n?.active??r.fontSize!=null,mixed:n?.mixed??r.mixed?.fontSize===!0,disabled:a||n?.disabled,label:r.fontSize!=null?`Size ${r.fontSize}`:"Font Size",title:u,onClick:S}),_(L,{active:x?.active??r.fontFamily!=null,mixed:x?.mixed??r.mixed?.fontFamily===!0,disabled:a||x?.disabled,label:r.fontFamily?`Font ${r.fontFamily}`:"Font Family",title:u,onClick:w})]})}import{useEffect as U,useRef as se}from"react";import{createDocumentSurface as at}from"@datalking/begonia-engine";import{useRef as et}from"react";var tt=Object.freeze([]);function rt(e){return e?.length?e:tt}function ot(e,t){return e.length===t.length&&e.every((r,a)=>Object.is(r,t[a]))}function Y(e){let t=rt(e),r=et(t);return ot(r.current,t)||(r.current=t),r.current}import{jsx as ve}from"react/jsx-runtime";function he({room:e,collaborative:t,participant:r,schema:a,trackingEnabled:i=!0,editable:l=!0,features:o,onSurfaceReady:n}){let x=se(null),u=se(null),g=se(n),S=Y(o);return U(()=>{g.current=n},[n]),U(()=>{if(!x.current)return;let w=at({element:x.current,participant:r,schema:a,collaborative:t??e,trackingEnabled:i,editable:l,features:S});return u.current=w,g.current?.(w),()=>{u.current=null,g.current?.(null),w.destroy()}},[t,e,a,S]),U(()=>{u.current?.setParticipant(r)},[r.color,r.id,r.name]),U(()=>{u.current?.setTrackingEnabled(i)},[i]),U(()=>{u.current?.setEditable(l)},[l]),ve("div",{className:"editor-frame",children:ve("div",{ref:x,className:"editor-host"})})}import{createBrowserEditorUiFromController as nt}from"@datalking/begonia-browser/v1";import{jsx as st}from"react/jsx-runtime";function we({editor:e,...t}){let r=ce(()=>e?nt(e):null,[e]);return st(ue,{...t,editor:r})}import{useRef as it}from"react";import{jsx as j,jsxs as Be}from"react/jsx-runtime";function J(e,t){let r=t.getBoundingClientRect();return{x:Math.min(1,Math.max(0,(e.clientX-r.left)/Math.max(1,r.width))),y:Math.min(1,Math.max(0,(e.clientY-r.top)/Math.max(1,r.height)))}}function lt(e,t){return{position:"absolute",zIndex:2,left:`${e.x*100}%`,top:`${e.y*100}%`,width:`${e.width*100}%`,minHeight:`${e.minHeight*100}%`,color:e.color,fontSize:`calc(${e.fontSize*100}% + 10px)`,lineHeight:1.2,padding:"4px 6px",borderRadius:10,background:t?"rgba(255,255,255,0.86)":"rgba(255,255,255,0.72)",border:t?"1px solid rgba(14, 116, 144, 0.45)":"1px solid rgba(148, 163, 184, 0.28)",boxShadow:t?"0 6px 18px rgba(14, 116, 144, 0.16)":"0 4px 12px rgba(15, 23, 42, 0.08)",cursor:"move",userSelect:"none",whiteSpace:"pre-wrap",overflowWrap:"anywhere"}}function dt(e,t){return{position:"absolute",zIndex:2,left:`${e.x*100}%`,top:`${e.y*100}%`,width:`${e.width*100}%`,height:`${e.height*100}%`,borderRadius:12,boxShadow:t?"0 10px 20px rgba(14, 116, 144, 0.18)":"0 4px 10px rgba(15, 23, 42, 0.10)",outline:t?"2px solid rgba(14, 116, 144, 0.48)":"none",cursor:"move",userSelect:"none",objectFit:"contain"}}function ct(e,t){return{position:"absolute",zIndex:0,left:`${e.x*100}%`,top:`${e.y*100}%`,width:`${e.width*100}%`,height:`${e.height*100}%`,borderRadius:8,background:e.color,opacity:e.opacity,boxShadow:t?"0 0 0 2px rgba(14, 116, 144, 0.4)":"inset 0 0 0 1px rgba(120, 53, 15, 0.08)",mixBlendMode:"multiply",cursor:"move",userSelect:"none"}}function ut(e){return e.points.map((t,r)=>`${r===0?"M":"L"} ${t.x*100} ${t.y*100}`).join(" ")}function pt(e,t){return e.annotations.filter(r=>r.pageNumber===t)}function ye(e,t,r){return e.kind==="stroke"?j("path",{"data-annotation-kind":e.kind,d:ut(e),stroke:e.color,strokeOpacity:e.opacity,strokeWidth:e.width*100,strokeLinecap:"round",strokeLinejoin:"round",fill:"none",vectorEffect:"non-scaling-stroke",onPointerDown:a=>{a.stopPropagation(),r(e,a)}},e.id):e.kind==="text"?j("div",{"data-annotation-id":e.id,"data-annotation-kind":e.kind,style:lt(e,t),onPointerDown:a=>{a.stopPropagation(),r(e,a)},children:e.text},e.id):e.kind==="highlight"?j("div",{"data-annotation-id":e.id,"data-annotation-kind":e.kind,style:ct(e,t),onPointerDown:a=>{a.stopPropagation(),r(e,a)}},e.id):j("img",{"data-annotation-id":e.id,"data-annotation-kind":e.kind,alt:e.label,src:e.src,style:dt(e,t),onPointerDown:a=>{a.stopPropagation(),r(e,a)}},e.id)}function Q({pageNumber:e,controller:t,snapshot:r}){let a=it(null),i=pt(r,e),l=r.activeStroke?.pageNumber===e?r.activeStroke:null;return Be("div",{style:{position:"absolute",inset:0,pointerEvents:r.enabled?"auto":"none",opacity:r.opacity},onPointerDown:o=>{if(!r.enabled)return;let n=J(o,o.currentTarget);if(r.tool==="draw"){o.currentTarget.setPointerCapture(o.pointerId),t.beginStroke(e,n);return}if(r.tool==="erase"){o.currentTarget.setPointerCapture(o.pointerId),t.eraseAt(e,n);return}if(r.tool==="text"){t.addText(e,n);return}if(r.tool==="highlight"){t.addHighlight(e,n);return}t.selectAnnotation(null)},onPointerMove:o=>{if(!r.enabled)return;let n=J(o,o.currentTarget);if(r.tool==="draw"&&r.activeStroke&&o.buttons===1){t.appendStroke(n);return}if(r.tool==="erase"&&o.buttons===1){t.eraseAt(e,n);return}a.current&&a.current.pageNumber===e&&o.buttons===1&&(t.moveAnnotation(a.current.annotationId,{x:n.x-a.current.lastPoint.x,y:n.y-a.current.lastPoint.y}),a.current={...a.current,lastPoint:n})},onPointerUp:o=>{r.tool==="draw"&&t.commitStroke(),a.current=null,o.currentTarget.hasPointerCapture(o.pointerId)&&o.currentTarget.releasePointerCapture(o.pointerId)},onDragOver:o=>{r.enabled&&o.preventDefault()},onDrop:o=>{if(!r.enabled)return;o.preventDefault();let n=J(o,o.currentTarget),x=o.dataTransfer.getData("application/sticker"),u=o.dataTransfer.getData("application/comment");if(x){t.placeSticker(e,n,x);return}if(u){let g=r.comments.find(S=>S.id===u);g&&t.addText(e,n,g.text)}},children:[Be("svg",{viewBox:"0 0 100 100",preserveAspectRatio:"none",style:{position:"absolute",inset:0,zIndex:1,width:"100%",height:"100%",overflow:"visible"},children:[i.filter(o=>o.kind==="stroke").map(o=>ye(o,o.id===r.selectedAnnotationId,n=>t.selectAnnotation(n.id))),l?j("path",{d:l.points.map((o,n)=>`${n===0?"M":"L"} ${o.x*100} ${o.y*100}`).join(" "),stroke:l.color,strokeOpacity:l.opacity,strokeWidth:l.width*100,strokeLinecap:"round",strokeLinejoin:"round",fill:"none",vectorEffect:"non-scaling-stroke"}):null]}),i.filter(o=>o.kind!=="stroke").map(o=>ye(o,o.id===r.selectedAnnotationId,(n,x)=>{t.selectAnnotation(n.id);let u=x.currentTarget.parentElement,g=u instanceof HTMLElement?J(x,u):n.kind==="text"||n.kind==="sticker"||n.kind==="highlight"?{x:n.x,y:n.y}:{x:0,y:0};a.current={annotationId:n.id,pageNumber:e,lastPoint:g}}))]})}import{jsx as ke}from"react/jsx-runtime";function Pe({viewer:e,controller:t,...r}){X(t,i=>i.version);let a=t.getSnapshot();return ke(le,{controller:e,...r,renderPageOverlay:i=>ke(Q,{pageNumber:i.pageNumber,controller:t,snapshot:a})})}import{jsx as ie}from"react/jsx-runtime";function Ne({projection:e,controller:t,height:r=720,scrollHost:a=null,scale:i=.52,pageGap:l=28,windowPages:o=5,overscan:n=2,virtualize:x=!0,layoutMode:u="vertical",flowMode:g,anchorPageNumber:S=null,pinnedPageNumbers:w,emptyLabel:y="No paginated preview available yet.",onViewportChange:f,className:h,style:s}){X(t,d=>d.version);let p=t.getSnapshot();return ie("div",{className:h,style:s,children:ie(de,{projection:e,version:p.version,height:r,scrollHost:a,scale:i,pageGap:l,windowPages:o,overscan:n,virtualize:x,layoutMode:u,flowMode:g,anchorPageNumber:S,pinnedPageNumbers:w,emptyLabel:y,onViewportChange:f,renderPageOverlay:d=>ie(Q,{pageNumber:d.page.pageNumber,controller:t,snapshot:p})})})}import{useEffect as H,useLayoutEffect as Se,useMemo as Ce,useReducer as mt,useRef as I}from"react";import{createBrowserEditorMountController as bt}from"@datalking/begonia-browser/v1";var W=Symbol("browser-editor-callback-unset");function xt(e,t){return{...e,features:t}}function Ee({zoomPercent:e,zoomMode:t,fitWidthOptions:r,onControllerChange:a,onStateChange:i,...l}){let o=Y(l.features),n=Ce(()=>xt({...l,zoomPercent:e,zoomMode:t,fitWidthOptions:r},o),[l.actor,l.collaborative,l.collaborationSession,l.documentMode,l.enableEmbeddedAdvancedOoxmlEditors,l.flowMode,r,l.initialContent,l.layoutMode,l.modules,l.onTransaction,l.onUpdate,l.participant,l.permissionResolver,l.room,l.schema,l.surfaceFactory,l.trackingEnabled,l.viewSelect,o,t,e]),x=I(null);x.current||(x.current=bt(n));let u=x.current,g=I(null),[S,w]=mt(E=>E+1,0),y=Ce(()=>({getSnapshot:()=>u.getSnapshot(),subscribe:E=>u.subscribe(E)}),[u,S]),f=V(y)??u.getSnapshot(),h=f.controller,s=f.state,p=I(a),d=I(i),k=I(W),P=I(W),D=I(null),M=I(null);if(!M.current){let E=(O=>{D.current!==O&&(D.current=O,u.setHost(O),w())});Object.defineProperty(E,"current",{configurable:!0,enumerable:!0,get(){return D.current},set(O){E(O)}}),M.current=E}return Se(()=>{g.current!==null&&(clearTimeout(g.current),g.current=null)},[u]),H(()=>{p.current=a},[a]),H(()=>{d.current=i},[i]),Se(()=>{u.setInput(n)},[u,n]),H(()=>{if(k.current===h||k.current===W&&h==null){k.current=h;return}k.current=h,p.current?.(h)},[h]),H(()=>{if(P.current===s||P.current===W&&s==null){P.current=s;return}P.current=s,d.current?.(s)},[s]),H(()=>()=>{let E=setTimeout(()=>{g.current===E&&(g.current=null,k.current!==W&&k.current!==null&&p.current?.(null),P.current!==W&&P.current!==null&&d.current?.(null),k.current=null,P.current=null,u.destroy())},0);g.current=E},[u]),{hostRef:M.current,controller:h,state:s}}import{useSyncExternalStore as gt}from"react";import{readBrowserEditorDocument as ft}from"@datalking/begonia-browser/v1";function Ae(e){return gt(t=>e?.subscribe(t)??(()=>{}),()=>ft(e),()=>null)}export{Je as BegoniaBrowserEditor,le as BegoniaPdfViewer,re as BrowserAdvancedOoxmlInspector,_t as BrowserCommentsDisplayControls,Qt as BrowserContextMenu,Zt as BrowserLinkPopover,we as BrowserPaginatedPreview,er as BrowserReviewDisplayControls,Qe as BrowserRichFormatControls,tr as BrowserViewControls,Pe as BrowserWhiteboardPdfPreview,Ne as BrowserWhiteboardPreview,Yt as CommentsSidebar,ht as DEFAULT_VIRTUAL_PAGED_PREVIEW_SCALE,wt as DEFAULT_WEB_FLOW_PAGE_HEIGHT_PX,he as DocumentReactMount,Jt as EditorToolbar,Et as PREVIEW_TABLE_CELL_HORIZONTAL_PADDING,At as PREVIEW_TABLE_CELL_VERTICAL_PADDING,Rt as PaginatedLayoutView,rr as ReviewPanel,or as ReviewTimelinePanel,Ct as VIRTUAL_PAGED_PREVIEW_FRAME_DATA_ATTRIBUTE,de as VirtualPagedPreview,yt as WEB_VIRTUAL_PAGED_PREVIEW_HORIZONTAL_PADDING_PX,Ft as applyVirtualPagedPreviewAutoscroll,vt as begoniaThemeRootProps,Ot as bindVirtualPagedPreviewWindowDragListeners,Ut as cloneVirtualPagedPreviewMetrics,ar as createPdfViewerController,Wt as createVirtualPagedPreviewAutoscrollController,Nt as createVirtualPagedPreviewDragSession,Xt as createVirtualPagedPreviewSessionState,St as isVirtualPagedPreviewFrameTarget,jt as normalizeVirtualPagedPreviewPinnedPageIndexes,Ht as normalizeVirtualPagedPreviewRequestKey,Bt as resolvePaginatedLayoutViewOptions,kt as resolvePaginatedPreviewFlowMode,Pt as resolveRequestedPaginatedLayoutFlowMode,Lt as resolveVirtualPagedPreviewAutoscrollDelta,zt as resolveVirtualPagedPreviewHostMeasurement,It as resolveVirtualPagedPreviewPositionHit,Tt as resolveVirtualPagedPreviewPositionHitInMountedFrames,$t as resolveVirtualPagedPreviewRenderState,Kt as resolveVirtualPagedPreviewResizeObserver,qt as resolveVirtualPagedPreviewSessionCommit,Gt as resolveVirtualPagedPreviewSessionViewportEmission,Vt as sameVirtualPagedPreviewMetrics,Ee as useBrowserEditorController,Ae as useBrowserEditorDocument,Mt as useBrowserEditorUi,V as useControllerSnapshot,X as useControllerSnapshotSignal,Dt as useEditorUiController};
|
|
1
|
+
import{$ as cn,A as zo,B as Vo,C as _o,D as Go,E as Xo,F as Yo,G as qo,H as Jo,I as Qo,J as Zo,K as en,L as ie,M as Me,N as Y,O as se,P as V,Q as Oe,R as tn,S as rn,T as on,U as nn,V as Le,W as ye,X as an,Y as sn,Z as ln,_ as dn,a as Po,aa as un,b as ne,ba as pn,c as ae,ca as Ue,d as De,da as mn,e as ko,f as Co,g as Eo,h as Fo,i as Ho,j as No,k as To,l as Ao,m as Do,n as Ro,o as Io,p as Mo,q as Re,r as Oo,s as Ie,t as Lo,u as X,v as Uo,w as Wo,x as Ko,y as $o,z as jo}from"./chunk-LIAB6VEG.js";import{useEffect as Be,useMemo as Pe,useState as $t}from"react";import{createBrowserEditorBackendAdapter as jt,resolveBrowserEditorUiController as zt}from"@datalking/begonia-browser/v1";import{useEffect as At,useMemo as Dt}from"react";import{summarizeReviewTimeline as Rt}from"@datalking/begonia-document-api/review";import{createBrowserAdvancedOoxmlInspectorController as It}from"@datalking/begonia-browser/ooxml";import{emptyBrowserAdvancedOoxmlInspectorSnapshot as Mt}from"@datalking/begonia-browser/ooxml";import{useState as _}from"react";import{appendEmptyAxisDraft as kt,appendEmptySeriesDraft as Ct,axisDraftsFromModel as Et,legendDraftFromModel as Ft,mergeChartModelWithDrafts as Ht,seriesDraftsFromModel as Nt}from"@datalking/begonia-browser/ooxml";import{jsx as g,jsxs as E}from"react/jsx-runtime";function We({controller:e,selection:t}){let[r,n]=_(t.model.title??""),[o,s]=_(t.model.chartType??""),[i,a]=_(t.model.textBody?.plainText??""),[l,d]=_(Nt(t.model)),[p,k]=_(Et(t.model)),[u,b]=_(Ft(t.model)),h=(c,f)=>d(m=>m.map((C,v)=>v===c?{...C,...f}:C)),S=(c,f)=>k(m=>m.map((C,v)=>v===c?{...C,...f}:C));return E("div",{className:"grid gap-3",children:[E("div",{className:"grid gap-1",children:[g("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Chart Title"}),g("input",{value:r,onChange:c=>n(c.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),E("div",{className:"grid gap-1 md:grid-cols-2",children:[E("div",{className:"grid gap-1",children:[g("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Chart Type"}),g("input",{value:o,onChange:c=>s(c.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),E("div",{className:"grid gap-1",children:[g("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Coverage"}),E("div",{className:"flex flex-wrap gap-2",children:[E("span",{className:"rounded-full bg-slate-100 px-2 py-1 text-[11px] font-semibold text-slate-700",children:[t.seriesCount," series"]}),E("span",{className:"rounded-full bg-slate-100 px-2 py-1 text-[11px] font-semibold text-slate-700",children:[t.categoryCount," categories"]})]})]})]}),E("div",{className:"grid gap-1",children:[g("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Text Body"}),g("textarea",{value:i,onChange:c=>a(c.target.value),rows:3,className:"min-h-20 rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),E("div",{className:"grid gap-2",children:[E("div",{className:"flex items-center justify-between gap-3",children:[g("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Series"}),g("button",{type:"button",className:"rounded-full border border-slate-200 px-3 py-1.5 text-xs font-semibold text-slate-700",onClick:()=>d(c=>Ct(c)),children:"Add series"})]}),l.length===0?g("div",{className:"rounded-2xl border border-dashed border-slate-200 bg-slate-50 px-3 py-4 text-sm text-slate-500",children:"No chart series yet."}):null,l.map((c,f)=>E("div",{className:"grid gap-2 rounded-2xl border border-slate-200 bg-slate-50 p-3",children:[E("div",{className:"grid gap-2 md:grid-cols-3",children:[g("input",{value:c.name,onChange:m=>h(f,{name:m.target.value}),placeholder:"Series name",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"}),g("input",{value:c.id,onChange:m=>h(f,{id:m.target.value}),placeholder:"Series id",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"}),g("input",{value:c.order,onChange:m=>h(f,{order:m.target.value}),placeholder:"Order",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),g("input",{value:c.categories,onChange:m=>h(f,{categories:m.target.value}),placeholder:"Categories, comma separated",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"}),g("input",{value:c.values,onChange:m=>h(f,{values:m.target.value}),placeholder:"Values, comma separated",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"}),g("div",{className:"flex justify-end",children:g("button",{type:"button",className:"rounded-full border border-rose-200 bg-rose-50 px-3 py-1.5 text-xs font-semibold text-rose-700",onClick:()=>d(m=>m.filter((C,v)=>v!==f)),children:"Remove row"})})]},`${t.record.objectId}-${f}`))]}),E("div",{className:"grid gap-2",children:[E("div",{className:"flex items-center justify-between gap-3",children:[g("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Axes"}),g("button",{type:"button",className:"rounded-full border border-slate-200 px-3 py-1.5 text-xs font-semibold text-slate-700",onClick:()=>k(c=>kt(c)),children:"Add axis"})]}),p.length===0?g("div",{className:"rounded-2xl border border-dashed border-slate-200 bg-slate-50 px-3 py-4 text-sm text-slate-500",children:"No chart axes yet."}):null,p.map((c,f)=>E("div",{className:"grid gap-2 rounded-2xl border border-slate-200 bg-slate-50 p-3",children:[E("div",{className:"grid gap-2 md:grid-cols-2",children:[g("input",{value:c.id,onChange:m=>S(f,{id:m.target.value}),placeholder:"Axis id",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"}),g("input",{value:c.title,onChange:m=>S(f,{title:m.target.value}),placeholder:"Axis title",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),E("div",{className:"grid gap-2 md:grid-cols-3",children:[E("select",{value:c.kind,onChange:m=>S(f,{kind:m.target.value}),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300",children:[g("option",{value:"category",children:"Category"}),g("option",{value:"value",children:"Value"}),g("option",{value:"series",children:"Series"}),g("option",{value:"date",children:"Date"}),g("option",{value:"unknown",children:"Unknown"})]}),E("select",{value:c.orientation,onChange:m=>S(f,{orientation:m.target.value}),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300",children:[g("option",{value:"unknown",children:"Orientation"}),g("option",{value:"minMax",children:"Min to Max"}),g("option",{value:"maxMin",children:"Max to Min"})]}),g("input",{value:c.formatCode,onChange:m=>S(f,{formatCode:m.target.value}),placeholder:"Format code",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),g("div",{className:"flex justify-end",children:g("button",{type:"button",className:"rounded-full border border-rose-200 bg-rose-50 px-3 py-1.5 text-xs font-semibold text-rose-700",onClick:()=>k(m=>m.filter((C,v)=>v!==f)),children:"Remove axis"})})]},`${t.record.objectId}-axis-${f}`))]}),E("div",{className:"grid gap-2",children:[g("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Legend"}),E("div",{className:"grid gap-2 md:grid-cols-2",children:[E("select",{value:u.enabled,onChange:c=>b(f=>({...f,enabled:c.target.value})),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300",children:[g("option",{value:"true",children:"Enabled"}),g("option",{value:"false",children:"Absent"})]}),E("select",{value:u.visible,disabled:u.enabled==="false",onChange:c=>b(f=>({...f,visible:c.target.value})),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300 disabled:cursor-not-allowed disabled:bg-slate-100",children:[g("option",{value:"true",children:"Visible"}),g("option",{value:"false",children:"Hidden"})]})]}),E("div",{className:"grid gap-2 md:grid-cols-2",children:[E("select",{value:u.position,disabled:u.enabled==="false",onChange:c=>b(f=>({...f,position:c.target.value})),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300 disabled:cursor-not-allowed disabled:bg-slate-100",children:[g("option",{value:"unknown",children:"Position"}),g("option",{value:"left",children:"Left"}),g("option",{value:"right",children:"Right"}),g("option",{value:"top",children:"Top"}),g("option",{value:"bottom",children:"Bottom"}),g("option",{value:"topRight",children:"Top Right"})]}),E("select",{value:u.overlay,disabled:u.enabled==="false",onChange:c=>b(f=>({...f,overlay:c.target.value})),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300 disabled:cursor-not-allowed disabled:bg-slate-100",children:[g("option",{value:"unknown",children:"Overlay"}),g("option",{value:"true",children:"Overlay"}),g("option",{value:"false",children:"No overlay"})]})]})]}),g("button",{type:"button",className:"rounded-full border border-teal-200 bg-teal-50 px-3 py-2 text-sm font-semibold text-teal-700",onClick:()=>e.replaceSelectedChartModel(Ht(t.model,r,o,i,l,{axes:p,legend:u})),children:"Apply chart"})]})}import{useState as Ke}from"react";import{jsx as O,jsxs as q}from"react/jsx-runtime";function $e({controller:e,selection:t}){let[r,n]=Ke(t.plainText),[o,s]=Ke(t.displayMode);return q("div",{className:"grid gap-3",children:[q("div",{className:"grid gap-1",children:[O("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Equation Text"}),O("textarea",{value:r,onChange:i=>n(i.target.value),rows:4,className:"min-h-24 rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),q("div",{className:"grid gap-1",children:[O("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Display Mode"}),q("select",{value:o,onChange:i=>s(i.target.value==="block"?"block":"inline"),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300",children:[O("option",{value:"inline",children:"Inline"}),O("option",{value:"block",children:"Block"})]})]}),q("div",{className:"grid gap-1",children:[O("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Detected Structures"}),O("div",{className:"flex flex-wrap gap-2",children:t.structures.length===0?O("span",{className:"rounded-full bg-slate-100 px-2 py-1 text-[11px] font-medium text-slate-500",children:"Plain text"}):t.structures.map(i=>O("span",{className:"rounded-full bg-sky-100 px-2 py-1 text-[11px] font-semibold text-sky-700",children:i},i))})]}),O("button",{type:"button",className:"rounded-full border border-teal-200 bg-teal-50 px-3 py-2 text-sm font-semibold text-teal-700",onClick:()=>e.setSelectedMathPlainText(r,o),children:"Apply equation"})]})}import{useState as R}from"react";import{mergeShapeModelWithDrafts as Tt}from"@datalking/begonia-browser/ooxml";import{jsx as w,jsxs as H}from"react/jsx-runtime";function je({controller:e,selection:t}){let[r,n]=R(t.model.label??""),[o,s]=R(t.model.shapeType??""),[i,a]=R(t.model.textBody?.plainText??""),[l,d]=R(t.model.geometry?.preset??""),[p,k]=R(t.model.fill?.kind??"unknown"),[u,b]=R(t.model.fill?.color??""),[h,S]=R(t.model.stroke?.color??""),[c,f]=R(t.model.stroke?.widthEmu==null?"":String(t.model.stroke.widthEmu)),[m,C]=R(t.model.stroke?.dash??""),[v,N]=R(t.model.transform?.widthEmu==null?"":String(t.model.transform.widthEmu)),[P,T]=R(t.model.transform?.heightEmu==null?"":String(t.model.transform.heightEmu)),[x,y]=R(t.model.transform?.rotation==null?"":String(t.model.transform.rotation)),[F,I]=R(t.model.anchor?.kind??"unknown"),[W,K]=R(t.model.anchor?.wrap??"unknown");return H("div",{className:"grid gap-3",children:[H("div",{className:"grid gap-2 md:grid-cols-2",children:[H("div",{className:"grid gap-1",children:[w("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Shape Label"}),w("input",{value:r,onChange:B=>n(B.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),H("div",{className:"grid gap-1",children:[w("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Shape Type"}),w("input",{value:o,onChange:B=>s(B.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]})]}),H("div",{className:"grid gap-1",children:[w("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Text Body"}),w("textarea",{value:i,onChange:B=>a(B.target.value),rows:3,className:"min-h-20 rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),H("div",{className:"grid gap-2 md:grid-cols-2",children:[H("div",{className:"grid gap-1",children:[w("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Geometry Preset"}),w("input",{value:l,onChange:B=>d(B.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),H("div",{className:"grid gap-1",children:[w("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Fill Color"}),w("input",{value:u,onChange:B=>b(B.target.value),placeholder:"FFF2CC",className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]})]}),H("div",{className:"grid gap-2 md:grid-cols-3",children:[H("div",{className:"grid gap-1",children:[w("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Fill Kind"}),H("select",{value:p,onChange:B=>k(B.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300",children:[w("option",{value:"unknown",children:"Unknown"}),w("option",{value:"solid",children:"Solid"}),w("option",{value:"scheme",children:"Scheme"}),w("option",{value:"none",children:"None"})]})]}),H("div",{className:"grid gap-1",children:[w("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Stroke Color"}),w("input",{value:h,onChange:B=>S(B.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),H("div",{className:"grid gap-1",children:[w("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Stroke Dash"}),w("input",{value:m,onChange:B=>C(B.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]})]}),H("div",{className:"grid gap-2 md:grid-cols-3",children:[H("div",{className:"grid gap-1",children:[w("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Stroke Width (EMU)"}),w("input",{value:c,onChange:B=>f(B.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),H("div",{className:"grid gap-1",children:[w("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Width (EMU)"}),w("input",{value:v,onChange:B=>N(B.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),H("div",{className:"grid gap-1",children:[w("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Height (EMU)"}),w("input",{value:P,onChange:B=>T(B.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]})]}),H("div",{className:"grid gap-2 md:grid-cols-3",children:[H("div",{className:"grid gap-1",children:[w("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Rotation"}),w("input",{value:x,onChange:B=>y(B.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300"})]}),H("div",{className:"grid gap-1",children:[w("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Anchor Kind"}),H("select",{value:F,onChange:B=>I(B.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300",children:[w("option",{value:"unknown",children:"Unknown"}),w("option",{value:"inline",children:"Inline"}),w("option",{value:"anchor",children:"Anchor"})]})]}),H("div",{className:"grid gap-1",children:[w("label",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500",children:"Wrap"}),H("select",{value:W,onChange:B=>K(B.target.value),className:"rounded-2xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-800 shadow-sm outline-none transition focus:border-teal-300",children:[w("option",{value:"unknown",children:"Unknown"}),w("option",{value:"none",children:"None"}),w("option",{value:"square",children:"Square"}),w("option",{value:"tight",children:"Tight"}),w("option",{value:"through",children:"Through"}),w("option",{value:"topAndBottom",children:"Top and Bottom"})]})]})]}),w("button",{type:"button",className:"rounded-full border border-teal-200 bg-teal-50 px-3 py-2 text-sm font-semibold text-teal-700",onClick:()=>e.replaceSelectedShapeModel(Tt(t.model,{label:r,shapeType:o,textBody:i,geometryPreset:l,fillKind:p,fillColor:u,strokeColor:h,strokeWidthEmu:c,strokeDash:m,widthEmu:v,heightEmu:P,rotation:x,anchorKind:F,anchorWrap:W})),children:"Apply shape"})]})}import{jsx as D,jsxs as A}from"react/jsx-runtime";function le(...e){return e.filter(Boolean).join(" ")}function Ot(e){return`${e.family}:${e.record.objectId}:${JSON.stringify(e.model)}`}function Lt(e){return e==="math"?"bg-sky-100 text-sky-700":e==="chart"?"bg-amber-100 text-amber-700":"bg-emerald-100 text-emerald-700"}function Ut(e){return e.kind==="revision"?e.relatedKinds.includes("insert")&&e.relatedKinds.includes("delete")?"bg-amber-100 text-amber-700":e.revision.kind==="insert"?"bg-emerald-100 text-emerald-700":e.revision.kind==="delete"?"bg-rose-100 text-rose-700":"bg-sky-100 text-sky-700":e.kind==="revision-decision"?e.decision==="accept"?"bg-emerald-100 text-emerald-700":"bg-rose-100 text-rose-700":e.kind==="comment-status"?"bg-sky-100 text-sky-700":e.kind==="comment-visibility"?"bg-cyan-100 text-cyan-700":e.kind==="comment-removal"?"bg-rose-100 text-rose-700":e.kind==="comment-edit"?"bg-violet-100 text-violet-700":e.kind==="comment-reply"?"bg-slate-100 text-slate-700":"bg-amber-100 text-amber-700"}function Wt(e){if(e.kind==="revision")return e.relatedKinds.includes("insert")&&e.relatedKinds.includes("delete")?"Replace":e.revision.kind==="insert"?"Insert":e.revision.kind==="delete"?"Delete":"Format";if(e.kind==="revision-decision"){let t=e.decision==="accept"?"Accepted":"Rejected";return e.relatedKinds.includes("format")?`${t} format`:e.relatedKinds.includes("insert")&&e.relatedKinds.includes("delete")?`${t} replace`:e.revisionKind==="insert"?`${t} insert`:e.revisionKind==="delete"?`${t} delete`:`${t} format`}return e.kind==="comment-thread"?"Comment":e.kind==="comment-reply"?"Reply":e.kind==="comment-status"?"Status":e.kind==="comment-visibility"?"Visibility":e.kind==="comment-removal"?"Removal":"Edit"}function Kt(e){if(e.kind==="revision")return e.revision.prompt??e.excerpt??e.authorName??e.authorId??"Tracked change";if(e.kind==="revision-decision"){let t=e.decision==="accept"?"Accepted":"Rejected";return e.relatedKinds.includes("format")?`${t} format`:e.relatedKinds.includes("insert")&&e.relatedKinds.includes("delete")?`${t} replace`:e.revisionKind==="insert"?`${t} insert`:e.revisionKind==="delete"?`${t} delete`:`${t} format`}return e.kind==="comment-status"?e.status==="resolved"?"Resolved thread":e.status==="open"?"Reopened thread":"Status change":e.kind==="comment-visibility"?e.internalAfter?"Made internal":"Made external":e.kind==="comment-removal"?e.activityKind==="thread-removed"?"Removed thread":"Removed reply":e.authorName??e.authorId??"Review activity"}function Se({editor:e,className:t}){let r=Dt(()=>e?It(e):null,[e]),n=ne(r)??Mt();At(()=>()=>{r?.destroy()},[r]);let o=n.selected,s=o?Ot(o):null,i=r&&o?r.documentApi.review.timelineByObject(o.record.objectId,{actor:r.actor??void 0,enforceVisibilityPolicy:!0,sort:"desc"}):[],a=Rt(i),l=i.slice(0,4);return A("aside",{className:le("grid gap-3",t),"aria-label":"Advanced OOXML inspector",children:[D("header",{className:"grid gap-1",children:A("div",{className:"flex items-center justify-between gap-3",children:[A("div",{children:[D("h2",{className:"text-sm font-semibold text-slate-900",children:"Advanced OOXML"}),D("p",{className:"text-xs text-slate-500",children:"Structured editor for selected math, chart, and shape nodes."})]}),D("span",{className:le("rounded-full px-2 py-1 text-[11px] font-semibold",n.trackingEnabled?"bg-amber-100 text-amber-700":"bg-slate-100 text-slate-600"),children:n.trackingEnabled?"Tracking On":"Direct Edit"})]})}),!o||!r?D("div",{className:"rounded-3xl border border-dashed border-slate-200 bg-slate-50 px-4 py-6 text-sm text-slate-500",children:"Select an equation, chart, or shape in the editor to inspect and edit its structured OOXML model."}):A("section",{className:"grid gap-4 rounded-3xl border border-slate-200 bg-white px-4 py-4 shadow-sm",children:[A("div",{className:"grid gap-2",children:[A("div",{className:"flex items-center justify-between gap-3",children:[A("div",{className:"flex items-center gap-2",children:[D("span",{className:le("rounded-full px-2 py-1 text-[11px] font-semibold",Lt(o.family)),children:o.family}),D("span",{className:"rounded-full bg-slate-100 px-2 py-1 text-[11px] font-semibold text-slate-600",children:o.documentMode})]}),D("button",{type:"button",className:"rounded-full border border-rose-200 bg-rose-50 px-3 py-1.5 text-xs font-semibold text-rose-700",onClick:()=>r.removeSelected(),children:"Remove"})]}),A("div",{className:"grid gap-1 text-[11px] text-slate-500",children:[A("span",{children:["Object: ",o.record.objectId]}),A("span",{children:["Path: ",o.record.path.join(".")]})]})]}),o.family==="math"?D($e,{controller:r,selection:o},s??void 0):null,o.family==="chart"?D(We,{controller:r,selection:o},s??void 0):null,o.family==="shape"?D(je,{controller:r,selection:o},s??void 0):null,D("p",{className:"text-[11px] text-slate-500",children:n.trackingEnabled?"Inspector edits flow through tracked OOXML replacements so accept/reject stays available.":"Inspector edits apply directly to the selected OOXML object."}),A("section",{className:"grid gap-3 rounded-2xl border border-slate-200 bg-slate-50 p-3",children:[A("div",{className:"flex items-end justify-between gap-3",children:[A("div",{children:[D("h3",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-slate-600",children:"Object Review"}),A("p",{className:"text-xs text-slate-500",children:[a.total," linked item",a.total===1?"":"s"]})]}),A("div",{className:"flex flex-wrap justify-end gap-2 text-[11px] text-slate-500",children:[A("span",{children:[a.revisions," revision",a.revisions===1?"":"s"]}),A("span",{children:[a.commentThreads," thread",a.commentThreads===1?"":"s"]}),A("span",{children:[a.commentReplies," repl",a.commentReplies===1?"y":"ies"]})]})]}),l.length===0?D("div",{className:"rounded-2xl border border-dashed border-slate-200 bg-white px-3 py-4 text-xs text-slate-500",children:"No tracked review activity is currently linked to this OOXML object."}):D("div",{className:"grid gap-2",children:l.map(d=>A("div",{className:"grid gap-1 rounded-2xl border border-slate-200 bg-white px-3 py-3",children:[A("div",{className:"flex items-center justify-between gap-3",children:[D("span",{className:le("rounded-full px-2 py-1 text-[11px] font-semibold",Ut(d)),children:Wt(d)}),D("span",{className:"text-[11px] text-slate-400",children:d.authorName??d.authorId??"Unknown"})]}),D("p",{className:"text-xs text-slate-700",children:d.text||"Formatting change"}),D("p",{className:"text-[11px] text-slate-500",children:Kt(d)})]},d.id))})]})]})]})}import{jsx as ze}from"react/jsx-runtime";function Vt(e){return zt(e)}function _t({room:e,actor:t,collaborative:r,collaborationSession:n,documentMode:o,enableEmbeddedAdvancedOoxmlEditors:s=!0,features:i,fitWidthOptions:a,flowMode:l,initialContent:d,layoutMode:p,modules:k,onEditorChange:u,onTransaction:b,onUpdate:h,participant:S,permissionResolver:c,onControllerChange:f,onStateChange:m,schema:C,showAdvancedOoxmlInspector:v=!0,trackingEnabled:N=!0,viewSelect:P=!0,zoomMode:T,zoomPercent:x,...y}){let[F,I]=$t(null),W=Pe(()=>jt(),[]),K=Pe(()=>({room:e,actor:t,collaborative:r,collaborationSession:n,documentMode:o,enableEmbeddedAdvancedOoxmlEditors:s,features:i,fitWidthOptions:a,flowMode:l,initialContent:d,layoutMode:p,modules:k,onTransaction:b,onUpdate:h,participant:S,permissionResolver:c,schema:C,trackingEnabled:N,viewSelect:P,zoomMode:T,zoomPercent:x}),[e,t,r,n,o,s,i,a,l,d,p,k,b,h,S,c,C,N,P,T,x]),B=Pe(()=>Vt(F),[F]);return Be(()=>{f?.(B)},[B,f]),Be(()=>{if(m){if(!B){m(null);return}return m(B.getState()),B.subscribe(oe=>{m(oe)})}},[B,m]),Be(()=>()=>{f?.(null),m?.(null)},[f,m]),ze(Ue,{...y,backend:W,backendInput:K,sidebarStart:v?ze(Se,{editor:F}):null,onEditorChange:oe=>{I(oe),u?.(oe)}})}import{jsx as ce,jsxs as Xt}from"react/jsx-runtime";function ke(e,t){return typeof window<"u"?window.prompt(e,t):null}function de(e,t){return e?.commands[t]??null}function Gt({editor:e,snapshot:t}){if(!e||!t||!t.selection)return null;let r=t.selection.formatting,n=!t.editable,o=(b,h)=>{n||e.execute(b,h)},s=de(t,"text-color"),i=de(t,"highlight-color"),a=de(t,"font-size"),l=de(t,"font-family"),d=n?"Document is read-only in the current document mode.":void 0,p=(b,h,S)=>{let c=ke(`${b}. Enter a CSS color value or "none" to clear.`,h??"");if(c==null)return;let f=c.trim(),m=f.length===0||f.toLowerCase()==="none"?null:f;o(S,m)},k=()=>{let b=ke('Set font size in points. Enter "none" to clear.',r.fontSize==null?"":String(r.fontSize));if(b==null)return;let h=b.trim();if(!h||h.toLowerCase()==="none"){o("font-size",null);return}let S=Number(h.replace(/pt$/i,"").trim());Number.isFinite(S)&&S>0&&o("font-size",S)},u=()=>{let b=ke('Set font family. Enter "none" to clear.',r.fontFamily??"");if(b==null)return;let h=b.trim();o("font-family",!h||h.toLowerCase()==="none"?null:h)};return Xt("div",{className:"flex flex-wrap gap-2 rounded-[var(--ald-control-group-radius,20px)] border border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-toolbar-bg,#f8fafc)] p-2",children:[ce(Y,{active:s?.active??r.color!=null,mixed:s?.mixed??r.mixed?.color===!0,disabled:n||s?.disabled,label:r.color?`Text ${r.color}`:"Text Color",title:d,onClick:()=>p("Set text color",r.color,"text-color")}),ce(Y,{active:i?.active??r.highlight!=null,mixed:i?.mixed??r.mixed?.highlight===!0,disabled:n||i?.disabled,label:r.highlight?`Highlight ${r.highlight}`:"Highlight",title:d,onClick:()=>p("Set highlight color",r.highlight,"highlight-color")}),ce(Y,{active:a?.active??r.fontSize!=null,mixed:a?.mixed??r.mixed?.fontSize===!0,disabled:n||a?.disabled,label:r.fontSize!=null?`Size ${r.fontSize}`:"Font Size",title:d,onClick:k}),ce(Y,{active:l?.active??r.fontFamily!=null,mixed:l?.mixed??r.mixed?.fontFamily===!0,disabled:n||l?.disabled,label:r.fontFamily?`Font ${r.fontFamily}`:"Font Family",title:d,onClick:u})]})}import{useEffect as J,useRef as Ce}from"react";import{createDocumentSurface as Zt}from"@datalking/begonia-engine";import{useRef as Yt}from"react";var qt=Object.freeze([]);function Jt(e){return e?.length?e:qt}function Qt(e,t){return e.length===t.length&&e.every((r,n)=>Object.is(r,t[n]))}function ue(e){let t=Jt(e),r=Yt(t);return Qt(r.current,t)||(r.current=t),r.current}import{jsx as Ve}from"react/jsx-runtime";function _e({room:e,collaborative:t,participant:r,schema:n,trackingEnabled:o=!0,editable:s=!0,features:i,onSurfaceReady:a}){let l=Ce(null),d=Ce(null),p=Ce(a),k=ue(i);return J(()=>{p.current=a},[a]),J(()=>{if(!l.current)return;let u=Zt({element:l.current,participant:r,schema:n,collaborative:t??e,trackingEnabled:o,editable:s,features:k});return d.current=u,p.current?.(u),()=>{d.current=null,p.current?.(null),u.destroy()}},[t,e,n,k]),J(()=>{d.current?.setParticipant(r)},[r.color,r.id,r.name]),J(()=>{d.current?.setTrackingEnabled(o)},[o]),J(()=>{d.current?.setEditable(s)},[s]),Ve("div",{className:"editor-frame",children:Ve("div",{ref:l,className:"editor-host"})})}import{createBrowserEditorUiFromController as er}from"@datalking/begonia-browser/v1";import{jsx as tr}from"react/jsx-runtime";function Ge({editor:e,...t}){let r=X(()=>e?er(e):null,[e]);return tr(ie,{...t,editor:r})}import{useCallback as j,useEffect as Ee,useMemo as vr,useRef as Fe,useState as wr,useSyncExternalStore as tt}from"react";import{createBrowserEditorUiFromController as yr}from"@datalking/begonia-browser/v1";import{createPaginatedEditingSession as Sr,installPaginatedColumnKeyboard as Br,installPaginatedTableBoundaryKeyboard as Pr,isSameLayoutDocument as kr}from"@datalking/begonia-browser-sdk";import{PAGINATED_EDITING_HOST_CLASS as Cr,resolvePaginatedEditingHostStyle as Er}from"@datalking/begonia-layout-renderer";import{useCallback as Q,useRef as Xe,useState as Ye}from"react";import{initialBandPressTracker as rr,resolveBandPress as or,resolveFooterBand as nr,resolveHeaderBand as ar}from"@datalking/begonia-browser-sdk";import{Fragment as xr,jsx as $,jsxs as pe}from"react/jsx-runtime";var ir=500,sr=400,lr="var(--ald-band-accent, #4472c4)",dr={position:"absolute",inset:0,pointerEvents:"none"};function cr(e,t,r,n){let o=r?{...e.kind==="footer"?{top:void 0,bottom:(n-e.top-e.height)*t}:{top:e.top*t},height:"auto",minHeight:e.height*t,display:"flex",flexDirection:"column",justifyContent:e.kind==="footer"?"flex-end":"flex-start"}:{};return{position:"absolute",left:e.left*t,top:e.top*t,width:e.width*t,height:e.height*t,...o,pointerEvents:"auto"}}function ur(e,t){return{position:"relative",width:"100%",...e.kind==="header"?{marginTop:e.contentTop*t}:{},minHeight:e.contentHeight*t,cursor:"auto"}}function pr(e){return{position:"absolute",left:0,right:0,...e.kind==="header"?{bottom:"100%",marginBottom:4}:{top:"100%",marginTop:4},display:"flex",justifyContent:"flex-end",pointerEvents:"none",zIndex:2}}function mr(e,t){return{position:"absolute",left:0,right:0,[e.kind==="header"?"bottom":"top"]:0,height:1,background:t?lr:"rgba(68, 114, 196, 0.35)",opacity:t?1:.9,pointerEvents:"none"}}function fr(e,t){return{position:"absolute",left:0,right:0,top:0,height:e.height*t,border:"var(--ald-band-hover-border, 1px dashed rgba(51, 102, 255, 0.8))",borderRadius:2,pointerEvents:"none"}}function gr(e,t){let r=e.height*t,n=4*t,o=22*t,s=28*t,i=-n-o,a=r+n;return{position:"absolute",left:0,...e.top*t>=s?{top:i}:{top:a},padding:"3px 7px",borderRadius:2,fontSize:12,lineHeight:"16px",whiteSpace:"nowrap",color:"var(--ald-band-hint-fg, #ffffff)",background:"var(--ald-band-hint-bg, rgba(18, 22, 33, 0.85))",pointerEvents:"none"}}function br(e,t){let r=e.kind==="header"?e.top:e.marginDistance,n=r*t>=28*t?{top:-(23*t+4*t)}:{top:e.height*t+4*t};return{position:"absolute",left:0,...e.kind==="footer"&&r*t>=28*t?{bottom:-(23*t+4*t)}:n,padding:"3px 10px",borderRadius:6,fontSize:13*t,lineHeight:"17px",whiteSpace:"nowrap",color:"var(--ald-band-banner-fg, #ffffff)",background:"var(--ald-band-banner-bg, #1b3fbf)",pointerEvents:"none"}}function Qe(e){return e?.activeTarget!=null}function qe(e,t,r){return e==null||e.kind!==r||e.sectionIndex!==t.sectionIndex?!1:e.pageNumber==null||e.pageNumber===t.pageNumber}function Je({band:e,page:t,scale:r,open:n,props:o}){let s=e.kind==="header"?"Edit page header":"Edit page footer",i=o.disabled===!0,[a,l]=Ye(!1),[d,p]=Ye(!1),k=Xe(rr),u=Xe(0),b=o.doublePressIntervalMs??ir,h=Q(()=>{if(o.disabled===!0)return;let P=Date.now();P-u.current<sr||(u.current=P,o.onActivateBand?.(e.kind,t))},[e.kind,t,o]),S=Q(P=>{P.stopPropagation();let T=or(k.current,{primary:P.button===0,detail:P.detail,time:Date.now(),x:P.clientX,y:P.clientY,intervalMs:b});k.current=T.tracker,!(!T.open||n)&&(P.preventDefault(),h())},[h,b,n]),c=Q(P=>{P.stopPropagation()},[]),f=Q(P=>{P.stopPropagation(),n||h()},[h,n]),m=Q(P=>{o.disabled!==!0&&(n||(P.key==="Enter"||P.key===" ")&&(P.preventDefault(),P.stopPropagation(),h()))},[h,n,o.disabled]),C=(a||d)&&!n&&!i,v=d?e.kind==="header"?"Press Enter to edit header":"Press Enter to edit footer":e.kind==="header"?"Double-click to edit header":"Double-click to edit footer",N=n;return pe("div",{role:"button",tabIndex:i?-1:0,"aria-label":s,"aria-disabled":i?!0:void 0,"data-begonia-header-footer-band":e.kind,"data-begonia-header-footer-page":t.pageNumber,"data-begonia-header-footer-band-open":n?"true":void 0,onPointerDown:S,onMouseDown:c,onDoubleClick:f,onKeyDown:m,onPointerEnter:()=>l(!0),onPointerLeave:()=>l(!1),onFocus:()=>p(!0),onBlur:()=>p(!1),className:se("transition-colors duration-150 outline-none","cursor-default"),style:{...cr(e,r,n,t.pageSize.height),background:n?"var(--ald-band-active-bg, var(--ald-page-bg, #fffdfa))":"transparent"},children:[N?$("div",{"data-begonia-header-footer-rule":"true",style:mr(e,n),"aria-hidden":"true"}):null,C?pe(xr,{children:[$("div",{"data-begonia-header-footer-hover":"true",style:fr(e,r),"aria-hidden":"true"}),$("div",{"data-begonia-header-footer-hint":"true",style:gr(e,r),"aria-hidden":"true",children:v})]}):null,n?pe("div",{"data-begonia-header-footer-banner":"true",style:br(e,r),"aria-hidden":"true",children:[e.kind==="header"?"Editing Header":"Editing Footer"," (",o.activeTarget?.slot??"default",") Page ",t.pageNumber," \u2013 Press Esc to return"]}):null,n&&o.activeBandContent?$("div",{"data-begonia-header-footer-editor":"true",style:ur(e,r),children:o.activeBandContent}):null,n&&o.activeBandToolbar?$("div",{"data-begonia-header-footer-toolbar":"true",style:pr(e),children:o.activeBandToolbar}):null]})}var hr={header:!0,footer:!0};function me(e){let{frame:t,activeTarget:r}=e,n=t.page,o=e.resolveSlots?.(n)??hr,s=o.header?ar(n):null,i=o.footer?nr(n):null;return!s&&!i?null:pe("div",{style:dr,"data-begonia-header-footer-bands":"true",children:[s?$(Je,{band:s,page:n,scale:e.scale,open:qe(r,n,"header"),props:e}):null,i?$(Je,{band:i,page:n,scale:e.scale,open:qe(r,n,"footer"),props:e}):null]})}import{Fragment as Ze,jsx as Z,jsxs as et}from"react/jsx-runtime";function Fr(e,t){let r=Fe(null),n=j(()=>{let o=t?.preview.readLayoutSource()??null,s=r.current;return o&&s&&kr(s,o)?s:(r.current=o,o)},[t]);return tt(j(o=>e?e.subscribe(o):()=>{},[e]),n,()=>null)}var Hr=Er(),Nr=Hr;function Tr({hostRef:e,hostClassName:t}){return Z("div",{ref:e,className:[Cr,t].filter(Boolean).join(" "),style:Nr})}function rt({editor:e,hostRef:t,hostClassName:r,surfaceId:n,...o}){let s=Fe(null),i=j(v=>{s.current=v,t(v)},[t]),a=X(()=>e?yr(e):null,[e]),l=X(()=>a&&e?Sr({editor:{selection:a.selection,preview:a.preview},focus:()=>{e.surface.focus()},getEditorHost:()=>s.current,editorId:n}):null,[e,a]);Ee(()=>{if(e)return Pr({getView:()=>{try{return e.surface.view??null}catch{return null}},ownerDocument:s.current?.ownerDocument??null})},[e]),Ee(()=>{if(!(!e||!a))return Br({getView:()=>{try{return e.surface.view??null}catch{return null}},getProjection:()=>{try{return a.preview.getResolvedProjection?.()??null}catch{return null}},getMeasurement:()=>{try{return a.preview.getResolvedProjectionGeometryOptions?.()??null}catch{return null}},ownerDocument:s.current?.ownerDocument??null})},[e,a]);let d=Fr(e,a),p=a?.preview.readLayoutAdapter()??o.adapter??void 0,k=a?d:o.source??null,u=tt(j(v=>l?l.subscribe(v):()=>{},[l]),()=>l?.getSnapshot()??null,()=>null),[b,h]=wr(null);Ee(()=>{if(!e){h(null);return}let v=()=>{let N=e.getState();h({comments:{items:N.comments,activeCommentIds:N.activeCommentIds??[]}})};return v(),e.subscribe(v)},[e]);let S=Fe(null),c=j(v=>{!l||S.current===v||(S.current=v,l.attachScrollHost(v),l.reveal())},[l]),f=j(v=>{l?.attachPreviewHost(v)},[l]),m=j(()=>{l?.releaseComposition()},[l]),C=vr(()=>l?(v,N)=>et(Ze,{children:[o.headerFooter?Z(me,{...o.headerFooter,frame:v,scale:N}):null,Z(Ie,{frame:v,scale:N,overlay:u?.overlay??null,flowMode:o.flowMode??"paginated",composing:u?.composing??!1,compositionText:u?.compositionText??"",caretVisible:(u?.focused??!1)&&!Qe(o.headerFooter)})]}):void 0,[o.flowMode,o.headerFooter,l,u?.composing,u?.compositionText,u?.focused,u?.overlay]);return et(Ze,{children:[Z(Tr,{hostRef:i,hostClassName:r}),Z(ie,{...o,deferLayout:u?.compositionHeld??!1,onDeferralRelease:m,resolveCommentState:o.resolveCommentState??Me(b,null),editor:a,adapter:p,source:k,renderPageOverlay:C,onResolvedScrollHostChange:c,onResolvedPreviewHostChange:f,onProjectionContextMenu:(v,N)=>e?.openContextMenuAt(N)===!0})]})}import{useRef as Ar}from"react";import{jsx as ee,jsxs as nt}from"react/jsx-runtime";function fe(e,t){let r=t.getBoundingClientRect();return{x:Math.min(1,Math.max(0,(e.clientX-r.left)/Math.max(1,r.width))),y:Math.min(1,Math.max(0,(e.clientY-r.top)/Math.max(1,r.height)))}}function Dr(e,t){return{position:"absolute",zIndex:2,left:`${e.x*100}%`,top:`${e.y*100}%`,width:`${e.width*100}%`,minHeight:`${e.minHeight*100}%`,color:e.color,fontSize:`calc(${e.fontSize*100}% + 10px)`,lineHeight:1.2,padding:"4px 6px",borderRadius:10,background:t?"rgba(255,255,255,0.86)":"rgba(255,255,255,0.72)",border:t?"1px solid rgba(14, 116, 144, 0.45)":"1px solid rgba(148, 163, 184, 0.28)",boxShadow:t?"0 6px 18px rgba(14, 116, 144, 0.16)":"0 4px 12px rgba(15, 23, 42, 0.08)",cursor:"move",userSelect:"none",whiteSpace:"pre-wrap",overflowWrap:"anywhere"}}function Rr(e,t){return{position:"absolute",zIndex:2,left:`${e.x*100}%`,top:`${e.y*100}%`,width:`${e.width*100}%`,height:`${e.height*100}%`,borderRadius:12,boxShadow:t?"0 10px 20px rgba(14, 116, 144, 0.18)":"0 4px 10px rgba(15, 23, 42, 0.10)",outline:t?"2px solid rgba(14, 116, 144, 0.48)":"none",cursor:"move",userSelect:"none",objectFit:"contain"}}function Ir(e,t){return{position:"absolute",zIndex:0,left:`${e.x*100}%`,top:`${e.y*100}%`,width:`${e.width*100}%`,height:`${e.height*100}%`,borderRadius:8,background:e.color,opacity:e.opacity,boxShadow:t?"0 0 0 2px rgba(14, 116, 144, 0.4)":"inset 0 0 0 1px rgba(120, 53, 15, 0.08)",mixBlendMode:"multiply",cursor:"move",userSelect:"none"}}function Mr(e){return e.points.map((t,r)=>`${r===0?"M":"L"} ${t.x*100} ${t.y*100}`).join(" ")}function Or(e,t){return e.annotations.filter(r=>r.pageNumber===t)}function ot(e,t,r){return e.kind==="stroke"?ee("path",{"data-annotation-kind":e.kind,d:Mr(e),stroke:e.color,strokeOpacity:e.opacity,strokeWidth:e.width*100,strokeLinecap:"round",strokeLinejoin:"round",fill:"none",vectorEffect:"non-scaling-stroke",onPointerDown:n=>{n.stopPropagation(),r(e,n)}},e.id):e.kind==="text"?ee("div",{"data-annotation-id":e.id,"data-annotation-kind":e.kind,style:Dr(e,t),onPointerDown:n=>{n.stopPropagation(),r(e,n)},children:e.text},e.id):e.kind==="highlight"?ee("div",{"data-annotation-id":e.id,"data-annotation-kind":e.kind,style:Ir(e,t),onPointerDown:n=>{n.stopPropagation(),r(e,n)}},e.id):ee("img",{"data-annotation-id":e.id,"data-annotation-kind":e.kind,alt:e.label,src:e.src,style:Rr(e,t),onPointerDown:n=>{n.stopPropagation(),r(e,n)}},e.id)}function ge({pageNumber:e,controller:t,snapshot:r}){let n=Ar(null),o=Or(r,e),s=r.activeStroke?.pageNumber===e?r.activeStroke:null;return nt("div",{style:{position:"absolute",inset:0,pointerEvents:r.enabled?"auto":"none",opacity:r.opacity},onPointerDown:i=>{if(!r.enabled)return;let a=fe(i,i.currentTarget);if(r.tool==="draw"){i.currentTarget.setPointerCapture(i.pointerId),t.beginStroke(e,a);return}if(r.tool==="erase"){i.currentTarget.setPointerCapture(i.pointerId),t.eraseAt(e,a);return}if(r.tool==="text"){t.addText(e,a);return}if(r.tool==="highlight"){t.addHighlight(e,a);return}t.selectAnnotation(null)},onPointerMove:i=>{if(!r.enabled)return;let a=fe(i,i.currentTarget);if(r.tool==="draw"&&r.activeStroke&&i.buttons===1){t.appendStroke(a);return}if(r.tool==="erase"&&i.buttons===1){t.eraseAt(e,a);return}n.current&&n.current.pageNumber===e&&i.buttons===1&&(t.moveAnnotation(n.current.annotationId,{x:a.x-n.current.lastPoint.x,y:a.y-n.current.lastPoint.y}),n.current={...n.current,lastPoint:a})},onPointerUp:i=>{r.tool==="draw"&&t.commitStroke(),n.current=null,i.currentTarget.hasPointerCapture(i.pointerId)&&i.currentTarget.releasePointerCapture(i.pointerId)},onDragOver:i=>{r.enabled&&i.preventDefault()},onDrop:i=>{if(!r.enabled)return;i.preventDefault();let a=fe(i,i.currentTarget),l=i.dataTransfer.getData("application/sticker"),d=i.dataTransfer.getData("application/comment");if(l){t.placeSticker(e,a,l);return}if(d){let p=r.comments.find(k=>k.id===d);p&&t.addText(e,a,p.text)}},children:[nt("svg",{viewBox:"0 0 100 100",preserveAspectRatio:"none",style:{position:"absolute",inset:0,zIndex:1,width:"100%",height:"100%",overflow:"visible"},children:[o.filter(i=>i.kind==="stroke").map(i=>ot(i,i.id===r.selectedAnnotationId,a=>t.selectAnnotation(a.id))),s?ee("path",{d:s.points.map((i,a)=>`${a===0?"M":"L"} ${i.x*100} ${i.y*100}`).join(" "),stroke:s.color,strokeOpacity:s.opacity,strokeWidth:s.width*100,strokeLinecap:"round",strokeLinejoin:"round",fill:"none",vectorEffect:"non-scaling-stroke"}):null]}),o.filter(i=>i.kind!=="stroke").map(i=>ot(i,i.id===r.selectedAnnotationId,(a,l)=>{t.selectAnnotation(a.id);let d=l.currentTarget.parentElement,p=d instanceof HTMLElement?fe(l,d):a.kind==="text"||a.kind==="sticker"||a.kind==="highlight"?{x:a.x,y:a.y}:{x:0,y:0};n.current={annotationId:a.id,pageNumber:e,lastPoint:p}}))]})}import{jsx as at}from"react/jsx-runtime";function it({viewer:e,controller:t,...r}){ae(t,o=>o.version);let n=t.getSnapshot();return at(De,{controller:e,...r,renderPageOverlay:o=>at(ge,{pageNumber:o.pageNumber,controller:t,snapshot:n})})}import{jsx as He}from"react/jsx-runtime";function st({projection:e,controller:t,height:r=720,scrollHost:n=null,scale:o=.52,pageGap:s=28,windowPages:i=5,overscan:a=2,virtualize:l=!0,layoutMode:d="vertical",flowMode:p,anchorPageNumber:k=null,pinnedPageNumbers:u,emptyLabel:b="No paginated preview available yet.",onViewportChange:h,className:S,style:c}){ae(t,m=>m.version);let f=t.getSnapshot();return He("div",{className:S,style:c,children:He(Re,{projection:e,version:f.version,height:r,scrollHost:n,scale:o,pageGap:s,windowPages:i,overscan:a,virtualize:l,layoutMode:d,flowMode:p,anchorPageNumber:k,pinnedPageNumbers:u,emptyLabel:b,onViewportChange:h,renderPageOverlay:m=>He(ge,{pageNumber:m.page.pageNumber,controller:t,snapshot:f})})})}import{useEffect as Lr,useRef as Ur}from"react";import{createDocumentSurface as Wr}from"@datalking/begonia-engine";import{toHeaderFooterParagraphAlignment as Kr}from"@datalking/begonia-browser-sdk";import{documentWideMutationEffect as $r}from"@datalking/begonia-editor-contracts";var jr={position:"absolute",left:"-10000px",top:"0",width:"600px",height:"200px",overflow:"hidden",pointerEvents:"none"};function zr(e){let t=e[0]?.type.schema;return t?t.nodes.doc.create(null,e):null}function be(e,t){let r=document.createElement("div");Object.assign(r.style,jr),document.body.appendChild(r);let n=zr(t),o=Wr({element:r,participant:e,...n?{initialContent:n}:{},trackingEnabled:!1,editable:!0}),s=!1,i=()=>{s||(s=!0,o.destroy(),r.remove())};return{element:r,runtime:o,surface:{readDocument:()=>o.document,replaceDocument:a=>o.replaceDocument(a,{origin:"editor",intent:"replace-header-footer-scratch-document",effects:[$r("content")]}),focus:()=>o.focus(),destroy:i,subscribe:a=>o.subscribe(a),toggleInlineFormat:a=>{switch(a){case"bold":return o.toggleBold();case"italic":return o.toggleItalic();case"underline":return o.toggleUnderline();case"strike":return o.toggleStrike();default:return!1}},readInlineFormat:()=>{let{bold:a,italic:l,underline:d,strike:p}=o.describeSelection().formatting;return{bold:a,italic:l,underline:d,strike:p}},applyTextColor:a=>o.setTextStyle({color:a}),readTextColor:()=>o.describeSelection().formatting.color,setParagraphAlignment:a=>o.setAlignment(a),readParagraphAlignment:()=>Kr(o.describeSelection().block?.align)},destroy:i}}function lt(e){let t=Ur(null);return Lr(()=>{if(e)return t.current=e(),()=>{t.current?.destroy(),t.current=null}},[e]),t}import{Fragment as ct,jsx as M,jsxs as he}from"react/jsx-runtime";var Vr=[{key:"bold",label:"B",title:"Bold",style:{fontWeight:700}},{key:"italic",label:"I",title:"Italic",style:{fontStyle:"italic"}},{key:"underline",label:"U",title:"Underline",style:{textDecoration:"underline"}},{key:"strike",label:"S",title:"Strikethrough",style:{textDecoration:"line-through"}}],_r=[{align:"left",title:"Align left",rules:[[0,12],[0,7],[0,12]]},{align:"center",title:"Align center",rules:[[0,12],[2.5,7],[0,12]]},{align:"right",title:"Align right",rules:[[0,12],[5,7],[0,12]]},{align:"justify",title:"Justify",rules:[[0,12],[0,12],[0,12]]}],Gr={display:"flex",alignItems:"center",gap:2,padding:2,borderRadius:4,background:"var(--ald-band-toolbar-bg, rgba(255, 255, 255, 0.92))",boxShadow:"0 1px 2px rgba(15, 23, 42, 0.16)",pointerEvents:"auto",zIndex:2};function ut(e){e.preventDefault(),e.stopPropagation()}function pt(e,t){return{minWidth:18,height:18,padding:"0 4px",border:"1px solid "+(e?"var(--ald-band-accent, #4472c4)":"transparent"),borderRadius:3,background:e?"rgba(68, 114, 196, 0.14)":"transparent",color:e?"var(--ald-band-accent, #4472c4)":"#334155",font:"600 11px/1 ui-sans-serif, system-ui, sans-serif",cursor:t?"default":"pointer",opacity:t?.5:1,pointerEvents:"auto"}}var Xr={display:"inline-flex",alignItems:"center",gap:2},dt={width:1,height:12,margin:"0 2px",background:"var(--ald-band-border, #cbd5e1)"},Yr={display:"inline-flex",alignItems:"center",gap:3,height:18,padding:"0 3px",border:"1px solid var(--ald-band-border, #cbd5e1)",borderRadius:3,background:"var(--ald-surface, #ffffff)",pointerEvents:"auto"},qr={width:9,height:9,flexShrink:0,borderRadius:2,border:"1px solid rgba(15, 23, 42, 0.25)"},Jr={height:16,maxWidth:62,border:"none",background:"transparent",color:"#334155",font:"600 11px/1 ui-sans-serif, system-ui, sans-serif",cursor:"pointer",outline:"none"};function mt(e){let{format:t,onToggle:r,alignment:n=null,onAlignmentChange:o,textColor:s=null,onTextColorChange:i,disabled:a=!1,scale:l=1}=e;return he("div",{"data-begonia-header-footer-format":"true",role:"toolbar","aria-label":"Header and footer text style",style:{...Gr,transform:l!==1?`scale(${l})`:void 0},onMouseDown:d=>d.stopPropagation(),children:[Vr.map(({key:d,label:p,style:k,title:u})=>M("button",{type:"button",title:u,"aria-label":u,"aria-pressed":t[d],"data-begonia-header-footer-format-key":d,disabled:a,style:{...pt(t[d],a),...k},onMouseDown:ut,onClick:()=>r(d),children:p},d)),i?he(ct,{children:[M("span",{"aria-hidden":!0,style:dt}),M(Qr,{value:s??"",disabled:a,onChange:i})]}):null,o?he(ct,{children:[M("span",{"aria-hidden":!0,style:dt}),M(Zr,{alignment:n,disabled:a,onAlignmentChange:o})]}):null]})}function Qr(e){let{value:t,disabled:r,onChange:n}=e,o=ye(t)??"",s=Le(o),i=s.find(l=>l.value===o),a=i?.label??"Automatic";return he("label",{title:`Text color: ${a}`,style:{...Yr,opacity:r?.5:1},children:[M("span",{"aria-hidden":!0,style:{...qr,background:i?.swatch??"transparent"}}),M("select",{"aria-label":"Text color",title:`Text color: ${a}`,disabled:r,value:o,onChange:l=>n(ye(l.target.value)),style:Jr,children:s.map(l=>M("option",{value:l.value,children:l.label},l.value))})]})}function Zr(e){let{alignment:t,disabled:r,onAlignmentChange:n}=e;return M("span",{role:"group","aria-label":"Paragraph alignment",style:Xr,children:_r.map(({align:o,title:s,rules:i})=>{let a=t===o;return M("button",{type:"button",title:s,"aria-label":s,"aria-pressed":a,"data-begonia-header-footer-align":o,disabled:r,style:pt(a,r),onMouseDown:ut,onClick:()=>n(o),children:M("svg",{"aria-hidden":!0,viewBox:"0 0 12 12",width:11,height:11,style:{display:"block"},children:i.map(([l,d],p)=>M("rect",{x:l,y:1+p*3.6,width:d,height:1.4,rx:.7,fill:"currentColor"},p))})},o)})})}import{headerFooterSlotLabel as Te}from"@datalking/begonia-browser-sdk";import{Fragment as oo,jsx as L,jsxs as xe}from"react/jsx-runtime";var eo=["default","first","even"],to=["header","footer"];function Ne(){}function ro(e){return e.target?Te(e.target.kind,e.target.slot):null}function ft({editState:e,availableSlots:t,variants:r=null,linkState:n=null,disabled:o=!1,onOpen:s,onClose:i,onToggleTitlePage:a,onToggleOddEven:l,onToggleLinkToPrevious:d}){let p=e.phase==="editing"||e.phase==="saving",k=ro(e);return xe(oo,{children:[L(Oe,{}),r?xe("span",{role:"group","aria-label":"Page variants",className:"flex items-center gap-0.5",children:[L(V,{ariaLabel:"Different first page",title:"Different first page",pressed:r.titlePage,disabled:o||!a,onClick:a??Ne,children:"1st"}),L(V,{ariaLabel:"Different odd and even pages",title:"Different odd and even pages",pressed:r.oddEven,disabled:o||!l,onClick:l??Ne,children:"Odd/even"})]}):null,to.map(u=>xe("span",{role:"group","aria-label":u==="header"?"Header":"Footer",className:"flex items-center gap-0.5",children:[L(V,{ariaLabel:u==="header"?"Edit header":"Edit footer",title:u==="header"?"Edit header":"Edit footer",pressed:p&&e.target?.kind===u,disabled:o,onClick:()=>s(u,"default"),children:u==="header"?"H":"F"}),eo.filter(b=>b!=="default").map(b=>L(V,{ariaLabel:`${Te(u,b)}`,title:Te(u,b),pressed:p&&e.target?.kind===u&&e.target?.slot===b,disabled:o||!t[b],onClick:()=>s(u,b),children:b==="first"?"1":"2"},b))]},u)),p&&n&&n.available?L("span",{role:"group","aria-label":"Section link",className:"flex items-center gap-0.5",children:L(V,{ariaLabel:"Link to Previous",title:"Link to Previous",pressed:n.linked,disabled:o||!d,onClick:d??Ne,children:"Link"})}):null,p?xe("span",{className:se("ml-1 inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[11px] font-medium","bg-[var(--ald-accent-muted,#f0fdfa)] text-[var(--ald-accent,#0f766e)]"),"aria-live":"polite",children:[k,L("button",{type:"button",onClick:i,className:"rounded-full px-1 text-[11px] font-semibold underline","aria-label":"Close header or footer editing",children:"Close"})]}):null]})}import{useEffect as no,useRef as ao}from"react";import{jsx as io}from"react/jsx-runtime";function gt({mount:e,autoFocus:t=!0}){let r=ao(null);return no(()=>{let n=r.current;if(!(!n||!e))return e.removeAttribute("style"),n.appendChild(e),t&&e.querySelector('[contenteditable="true"]')?.focus(),()=>{e.parentElement===n&&e.remove()}},[t,e]),io("div",{ref:r,"data-begonia-header-footer-scratch":"true",style:{minHeight:24,width:"100%"}})}import{useCallback as z,useEffect as ve,useMemo as so,useRef as Ae,useState as te}from"react";import{createHeaderFooterEditingController as lo,EMPTY_HEADER_FOOTER_INLINE_FORMAT as we,initialHeaderFooterEditState as bt,resolveHeaderFooterPress as co}from"@datalking/begonia-browser-sdk";import{isInPaginatedUiSurface as uo,PAGINATED_BAND_DATA_ATTRIBUTE as ht,PAGINATED_BAND_ROOT_DATA_ATTRIBUTE as po}from"@datalking/begonia-layout-renderer";import{createEditorUiHost as mo}from"@datalking/begonia-engine";function vt({controller:e,onCommitted:t,readSectionIndex:r}){let[n,o]=te(bt),[s,i]=te(null),[a,l]=te(we),[d,p]=te(null),[k,u]=te(null),b=Ae(null),h=Ae(null),S=Ae(t);S.current=t,ve(()=>{if(!e){b.current=null,o(bt);return}let x=lo({readApi:()=>e.documentApi,createScratchSurface:F=>{let I=be(e.surface?.participant??fo,F);return h.current=I,i(I.element),I.surface}});b.current=x;let y=x.subscribe(()=>{o(x.getState())});return o(x.getState()),()=>{y(),x.destroy(),h.current?.destroy(),h.current=null,b.current=null,i(null)}},[e]);let c=z((x,y)=>{let F=b.current;F&&(F.openAtPage(x,y),o(F.getState()))},[]),f=z((x,y,F)=>{let I=b.current;if(!I||!e)return;let W=F?.sectionIndex??r?.()??0;I.openSlot(W,x,y,F?.pageNumber??null),o(I.getState())},[e,r]),m=z(()=>{let x=b.current;if(!x)return;let y=x.commit();o(x.getState()),y&&S.current?.()},[]),C=z((x={})=>{let y=b.current;if(!y)return;let F=x.restoreFocus!==!1,I=y.close();o(y.getState()),I&&S.current?.(),F&&queueMicrotask(()=>{let K=e?.surface?.view?.dom;if(K&&typeof K.focus=="function"){K.focus({preventScroll:!0});return}e?.surface?.focus()})},[e]);ve(()=>{if(!n.phase||n.phase==="idle")return;let x=y=>{y.key==="Escape"&&C()};return document.addEventListener("keydown",x),()=>{document.removeEventListener("keydown",x)}},[C,n.phase]),ve(()=>{if(n.phase!=="editing"&&n.phase!=="saving")return;let x=y=>{co({target:y.target,insideActiveBand:xt(y.target,!0),insideAnyBand:xt(y.target,!1),insideChrome:uo(y.target)})==="exit"&&C({restoreFocus:!1})};return document.addEventListener("pointerdown",x),()=>{document.removeEventListener("pointerdown",x)}},[C,n.phase]);let v=so(()=>mo(h.current?.runtime??null),[s]);ve(()=>{let x=h.current?.surface;if(!x?.readInlineFormat){l(we),p(null),u(null);return}let y=()=>{l(x.readInlineFormat?.()??we),p(x.readParagraphAlignment?.()??null),u(x.readTextColor?.()??null)};return y(),x.subscribe?.(y)},[s]);let N=z(x=>{let y=h.current?.surface;if(!y?.toggleInlineFormat)return!1;let F=y.toggleInlineFormat(x);return l(y.readInlineFormat?.()??we),F},[]),P=z(x=>{let y=h.current?.surface;if(!y?.applyTextColor)return!1;let F=y.applyTextColor(x);return u(y.readTextColor?.()??null),F},[]),T=z(x=>{let y=h.current?.surface;if(!y?.setParagraphAlignment)return!1;let F=y.setParagraphAlignment(x);return p(y.readParagraphAlignment?.()??null),F},[]);return{state:n,active:n.phase==="editing"||n.phase==="saving",openAtPage:c,openSlot:f,commit:m,close:C,editorMount:s,inlineFormat:a,toggleInlineFormat:N,textColor:k,applyTextColor:P,paragraphAlignment:d,setParagraphAlignment:T,toolbarHost:v,reason:n.error??b.current?.readLastReason()??null}}function xt(e,t){if(!e||typeof e!="object")return!1;let r=e.closest;if(typeof r!="function")return!1;let n=t?`[${ht}][data-begonia-header-footer-band-open="true"]`:`[${ht}], [${po}]`;return r.call(e,n)!=null}var fo={id:"header-footer-editor",name:"Header editor",color:"#0f766e"};import{useEffect as re,useLayoutEffect as wt,useMemo as yt,useReducer as go,useRef as U}from"react";import{createBrowserEditorMountController as bo}from"@datalking/begonia-browser/v1";var G=Symbol("browser-editor-callback-unset");function ho(e,t){return{...e,features:t}}function St({zoomPercent:e,zoomMode:t,fitWidthOptions:r,onControllerChange:n,onStateChange:o,...s}){let i=ue(s.features),a=yt(()=>ho({...s,zoomPercent:e,zoomMode:t,fitWidthOptions:r},i),[s.actor,s.collaborative,s.collaborationSession,s.documentMode,s.enableEmbeddedAdvancedOoxmlEditors,s.flowMode,r,s.initialContent,s.layoutMode,s.modules,s.onTransaction,s.onUpdate,s.participant,s.permissionResolver,s.room,s.schema,s.surfaceFactory,s.trackingEnabled,s.viewSelect,i,t,e]),l=U(null);l.current||(l.current=bo(a));let d=l.current,p=U(null),[k,u]=go(T=>T+1,0),b=yt(()=>({getSnapshot:()=>d.getSnapshot(),subscribe:T=>d.subscribe(T)}),[d,k]),h=ne(b)??d.getSnapshot(),S=h.controller,c=h.state,f=U(n),m=U(o),C=U(G),v=U(G),N=U(null),P=U(null);if(!P.current){let T=(x=>{N.current!==x&&(N.current=x,d.setHost(x),u())});Object.defineProperty(T,"current",{configurable:!0,enumerable:!0,get(){return N.current},set(x){T(x)}}),P.current=T}return wt(()=>{p.current!==null&&(clearTimeout(p.current),p.current=null)},[d]),re(()=>{f.current=n},[n]),re(()=>{m.current=o},[o]),wt(()=>{d.setInput(a)},[d,a]),re(()=>{if(C.current===S||C.current===G&&S==null){C.current=S;return}C.current=S,f.current?.(S)},[S]),re(()=>{if(v.current===c||v.current===G&&c==null){v.current=c;return}v.current=c,m.current?.(c)},[c]),re(()=>()=>{let T=setTimeout(()=>{p.current===T&&(p.current=null,C.current!==G&&C.current!==null&&f.current?.(null),v.current!==G&&v.current!==null&&m.current?.(null),C.current=null,v.current=null,d.destroy())},0);p.current=T},[d]),{hostRef:P.current,controller:S,state:c}}import{useSyncExternalStore as xo}from"react";import{readBrowserEditorDocument as vo}from"@datalking/begonia-browser/v1";function Bt(e){return xo(t=>e?.subscribe(t)??(()=>{}),()=>vo(e),()=>null)}import{useEffect as wo,useMemo as yo,useRef as So}from"react";import{resolveBrowserHistoryShortcut as Bo}from"@datalking/begonia-browser";function Pt({history:e,enabled:t=!0,ownerDocument:r,ownsFocus:n}){let o=yo(()=>e?i=>{let a=i==="undo"?e.undo:e.redo;return typeof a!="function"?!1:a.call(e)===!0}:null,[e]),s=So(null);s.current=n??null,wo(()=>{if(!t||!o)return;let i=r??(typeof document>"u"?null:document);if(!i)return;let a=l=>{let d=Bo(l);if(!d)return;let p=s.current;p&&!p(l)||o(d)&&l.preventDefault()};return i.addEventListener("keydown",a,!0),()=>{i.removeEventListener("keydown",a,!0)}},[t,r,o,s])}export{_t as BegoniaBrowserEditor,De as BegoniaPdfViewer,Se as BrowserAdvancedOoxmlInspector,tn as BrowserCommentsDisplayControls,sn as BrowserContextMenu,me as BrowserHeaderFooterBands,ft as BrowserHeaderFooterControls,mt as BrowserHeaderFooterFormatBar,ln as BrowserLinkPopover,rt as BrowserPaginatedEditorSurface,Ge as BrowserPaginatedPreview,dn as BrowserReviewDisplayControls,Gt as BrowserRichFormatControls,cn as BrowserViewControls,it as BrowserWhiteboardPdfPreview,st as BrowserWhiteboardPreview,rn as CommentsSidebar,ko as DEFAULT_VIRTUAL_PAGED_PREVIEW_SCALE,Co as DEFAULT_WEB_FLOW_PAGE_HEIGHT_PX,_e as DocumentReactMount,an as EditorToolbar,on as EditorToolbarBlockControls,nn as EditorToolbarInsertControls,gt as HeaderFooterScratchMount,Zo as PREVIEW_TABLE_CELL_HORIZONTAL_PADDING,en as PREVIEW_TABLE_CELL_VERTICAL_PADDING,Oo as PaginatedLayoutView,Ie as PaginatedPageOverlayView,un as ReviewPanel,pn as ReviewTimelinePanel,Do as VIRTUAL_PAGED_PREVIEW_FRAME_DATA_ATTRIBUTE,Re as VirtualPagedPreview,Eo as WEB_VIRTUAL_PAGED_PREVIEW_HORIZONTAL_PADDING_PX,Wo as applyVirtualPagedPreviewAutoscroll,Po as begoniaThemeRootProps,Mo as bindVirtualPagedPreviewWindowDragListeners,zo as cloneVirtualPagedPreviewMetrics,be as createHeaderFooterScratchSurface,mn as createPdfViewerController,Ko as createVirtualPagedPreviewAutoscrollController,To as createVirtualPagedPreviewDragSession,qo as createVirtualPagedPreviewSessionState,Ao as isVirtualPagedPreviewFrameTarget,Vo as normalizeVirtualPagedPreviewPinnedPageIndexes,_o as normalizeVirtualPagedPreviewRequestKey,Fo as resolvePaginatedLayoutViewOptions,Ho as resolvePaginatedPreviewFlowMode,No as resolveRequestedPaginatedLayoutFlowMode,Me as resolveSnapshotCommentState,$o as resolveVirtualPagedPreviewAutoscrollDelta,Go as resolveVirtualPagedPreviewHostMeasurement,Ro as resolveVirtualPagedPreviewPositionHit,Io as resolveVirtualPagedPreviewPositionHitInMountedFrames,jo as resolveVirtualPagedPreviewRenderState,Xo as resolveVirtualPagedPreviewResizeObserver,Jo as resolveVirtualPagedPreviewSessionCommit,Qo as resolveVirtualPagedPreviewSessionViewportEmission,Yo as sameVirtualPagedPreviewMetrics,St as useBrowserEditorController,Bt as useBrowserEditorDocument,Lo as useBrowserEditorUi,vt as useBrowserHeaderFooterEditing,ne as useControllerSnapshot,ae as useControllerSnapshotSignal,Uo as useEditorUiController,lt as useHeaderFooterScratchSurface,Pt as useUndoRedoHotkeys};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datalking/begonia-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "React editor for begonia: paginated view, comments/review panels, PDF viewer",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
6
|
"repository": {
|
|
@@ -34,18 +34,20 @@
|
|
|
34
34
|
"typecheck": "tsc --noEmit"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@datalking/begonia-browser": "0.
|
|
38
|
-
"@datalking/begonia-browser-sdk": "0.
|
|
39
|
-
"@datalking/begonia-doc-service": "0.
|
|
40
|
-
"@datalking/begonia-document-api": "0.
|
|
41
|
-
"@datalking/begonia-editor-adapters": "0.
|
|
42
|
-
"@datalking/begonia-editor-
|
|
43
|
-
"@datalking/begonia-
|
|
44
|
-
"@datalking/begonia-
|
|
45
|
-
"@datalking/begonia-layout-
|
|
46
|
-
"@datalking/begonia-layout-
|
|
47
|
-
"@datalking/begonia-
|
|
48
|
-
"@datalking/begonia-
|
|
37
|
+
"@datalking/begonia-browser": "0.3.0",
|
|
38
|
+
"@datalking/begonia-browser-sdk": "0.3.0",
|
|
39
|
+
"@datalking/begonia-doc-service": "0.3.0",
|
|
40
|
+
"@datalking/begonia-document-api": "0.3.0",
|
|
41
|
+
"@datalking/begonia-editor-adapters": "0.3.0",
|
|
42
|
+
"@datalking/begonia-editor-contracts": "0.3.0",
|
|
43
|
+
"@datalking/begonia-editor-ui": "0.3.0",
|
|
44
|
+
"@datalking/begonia-engine": "0.3.0",
|
|
45
|
+
"@datalking/begonia-layout-bridge": "0.3.0",
|
|
46
|
+
"@datalking/begonia-layout-contracts": "0.3.0",
|
|
47
|
+
"@datalking/begonia-layout-renderer": "0.3.0",
|
|
48
|
+
"@datalking/begonia-page-layout": "0.3.0",
|
|
49
|
+
"@datalking/begonia-pdf-viewer": "0.3.0",
|
|
50
|
+
"@datalking/begonia-table-render": "0.3.0",
|
|
49
51
|
"prosemirror-model": "^1.22.3"
|
|
50
52
|
},
|
|
51
53
|
"devDependencies": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { PREVIEW_TABLE_CELL_HORIZONTAL_PADDING, PREVIEW_TABLE_CELL_VERTICAL_PADDING, } from '@datalking/begonia-layout-renderer';
|
package/dist/chunk-ORLGCG23.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{useSyncExternalStore as En}from"react";import{useEffect as yr,useRef as Et}from"react";import{begoniaThemeVars as br,resolveBegoniaTheme as wr}from"@datalking/begonia-browser-sdk";function de(e,t){if(e==null)return{style:t??{}};let r=wr(e);return{style:{...t,...br(r)},"data-begonia-theme":r.id}}import{useCallback as xr,useRef as Ct,useSyncExternalStore as Pr}from"react";function Oe(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;for(let s=0;s<e.length;s+=1)if(!Oe(e[s],t[s]))return!1;return!0}if(Object.getPrototypeOf(e)!==Object.prototype||Object.getPrototypeOf(t)!==Object.prototype)return!1;let r=Object.keys(e),a=Object.keys(t);if(r.length!==a.length)return!1;let n=e,i=t;for(let s of r)if(!Object.prototype.hasOwnProperty.call(i,s)||!Oe(n[s],i[s]))return!1;return!0}function hr(e,t){let r=Ct(0),a=xr(n=>{if(!e)return()=>{};let i=!0,s=e.subscribe(p=>{if(i){t.current.controller===e&&t.current.token===r.current&&!Oe(t.current.snapshot,p)&&(r.current+=1,t.current={controller:e,token:r.current,snapshot:p},n());return}r.current+=1,t.current={controller:e,token:r.current,snapshot:p},n()});return i=!1,s},[t,e]);return Pr(a,()=>r.current,()=>r.current)}function N(e){let t=Ct({controller:null,token:-1,snapshot:null}),r=hr(e,t),a=t.current;if(a.controller===e&&a.token===r)return a.snapshot;let n=e?.getSnapshot()??null;return t.current={controller:e,token:r,snapshot:n},n}function He(e,t){let r=N(e);return r==null?null:t(r)}import{jsx as ue,jsxs as Ce}from"react/jsx-runtime";function Sr(e){return typeof e=="number"?`${e}px`:e}function kr(e,t){return{pageNumber:e.pageNumber,width:e.width,height:e.height,rotation:e.rotation,scale:t}}function Vt(e,t){return`${e??"pdf"}:${t}`}function Lt({controller:e,height:t=720,scale:r=1,pageGap:a=24,className:n,style:i,theme:s,emptyLabel:p="No PDF document loaded.",renderPageOverlay:m}){He(e,d=>[d.status,d.pageCount,d.fingerprint,d.error,d.textLayerEnabled,d.outputScale,d.renderVersion,...d.pages.map(v=>`${v.pageNumber}:${v.width}:${v.height}:${v.rotation}`)].join("|"));let u=e.getSnapshot(),c=Et(new Map),l=Et(new Map);yr(()=>{if(u.status!=="ready")return;let d=!1;return(async()=>{for(let y of u.pages){if(d)return;let w=Vt(u.fingerprint,y.pageNumber),f=c.current.get(w);f&&await e.renderPage(y.pageNumber,f,{scale:r,textLayer:l.current.get(w)??null})}})(),()=>{d=!0}},[e,r,u.fingerprint,u.pages,u.renderVersion,u.status]);let o=de(s);return Ce("div",{className:n,"data-begonia-theme":o["data-begonia-theme"],style:{overflow:"auto",height:Sr(t),background:"var(--ald-canvas, linear-gradient(180deg, #dbe4f0 0%, #eef2f7 100%))",borderRadius:"var(--ald-canvas-radius, 18px)",padding:20,...o.style,...i},children:[u.status==="error"?ue("div",{style:{color:"#991b1b",padding:16},children:u.error??"Failed to load PDF."}):null,u.status==="loading"?ue("div",{style:{color:"#334155",padding:16},children:"Loading PDF\u2026"}):null,u.status==="idle"&&u.pages.length===0?ue("div",{style:{color:"#475569",padding:16},children:p}):null,ue("div",{style:{display:"grid",gap:`${a}px`,justifyContent:"center"},children:u.pages.map(d=>{let v=Vt(u.fingerprint,d.pageNumber),y=d.width*r,w=d.height*r;return Ce("section",{"aria-label":`PDF page ${d.pageNumber}`,children:[Ce("div",{style:{color:"var(--ald-text-muted, #334155)",fontSize:12,margin:"0 0 8px 6px"},children:["Page ",d.pageNumber]}),Ce("div",{style:{position:"relative",width:y,height:w,background:"var(--ald-page-bg, #fff)",borderRadius:"var(--ald-page-radius, 14px)",overflow:"hidden",boxShadow:"var(--ald-page-shadow, 0 18px 40px rgba(15, 23, 42, 0.14))"},children:[ue("canvas",{ref:f=>{f?c.current.set(v,f):c.current.delete(v)},style:{display:"block",width:y,height:w}}),ue("div",{ref:f=>{f?l.current.set(v,f):l.current.delete(v)},style:{position:"absolute",inset:0,pointerEvents:u.textLayerEnabled?"auto":"none"}}),m?ue("div",{style:{position:"absolute",inset:0},children:m(kr(d,r))}):null]})]},v)})})]})}import{useEffect as ho,useLayoutEffect as at,useMemo as yo,useRef as it}from"react";import{createPaginatedLayoutPreviewController as So,createDefaultPaginatedLayoutMeasureText as ko}from"@datalking/begonia-layout-renderer";import{useEffect as vo,useRef as q}from"react";import{createDefaultPaginatedLayoutMeasureText as bo,normalizeRenderScale as wo,resolveVirtualPagedPreviewContentLayout as xo}from"@datalking/begonia-layout-renderer";import{DEFAULT_VIRTUAL_PAGED_PREVIEW_SCALE as _e,DEFAULT_WEB_FLOW_PAGE_HEIGHT_PX as Rr,WEB_VIRTUAL_PAGED_PREVIEW_HORIZONTAL_PADDING_PX as Fe,resolvePaginatedLayoutViewOptions as Tr,resolveVirtualPagedPreviewVirtualization as Kn}from"@datalking/begonia-layout-renderer";function Bt(e){return typeof e=="number"&&Number.isFinite(e)?Math.max(0,e):24}import{resolvePaginatedPreviewFlowMode as je,resolveRequestedPaginatedLayoutFlowMode as Cr}from"@datalking/begonia-layout-renderer";import{useEffect as It,useLayoutEffect as Nt,useRef as Mt}from"react";import{createVirtualPagedPreviewController as Er,resolveVirtualPagedPreviewObservedScrollHost as Vr}from"@datalking/begonia-layout-renderer";function Lr(e,t){return Vr(e,t)}function At(e){return{projection:e.projection,version:e.version??null,height:e.height,width:e.width,scale:e.scale,pageGap:e.pageGap,windowPages:e.windowPages,overscan:e.overscan,virtualize:e.virtualize,layoutMode:e.layoutMode,flowMode:e.flowMode,anchorPageNumber:e.anchorPageNumber,initialViewportAnchor:e.initialViewportAnchor,viewportRequestKey:e.viewportRequestKey,pinnedPageNumbers:e.pinnedPageNumbers}}function Dt({projection:e,version:t=null,height:r,width:a,scale:n,pageGap:i,windowPages:s,overscan:p,virtualize:m,layoutMode:u,flowMode:c,anchorPageNumber:l,initialViewportAnchor:o,viewportRequestKey:d,pinnedPageNumbers:v,scrollHost:y,onViewportChange:w}){let f=Mt(null),x=Mt(null);(!x.current||x.current.isDestroyed?.()===!0)&&(x.current=Er(At({projection:e,version:t,height:r,width:a,scale:n,pageGap:i,windowPages:s,overscan:p,virtualize:m,layoutMode:u,flowMode:c,anchorPageNumber:l,initialViewportAnchor:o,viewportRequestKey:d,pinnedPageNumbers:v,scrollHost:y,onViewportChange:w})));let b=x.current,R=N(b)??b.getSnapshot();return Nt(()=>{b.setInput(At({projection:e,version:t,height:r,width:a,scale:n,pageGap:i,windowPages:s,overscan:p,virtualize:m,layoutMode:u,flowMode:c,anchorPageNumber:l,initialViewportAnchor:o,viewportRequestKey:d,pinnedPageNumbers:v,scrollHost:y,onViewportChange:w}))},[b,e,t,r,a,n,i,s,p,m,u,c,l,o,d,v]),Nt(()=>{let g=b.bindViewport({getExplicitScrollHost:()=>y,getPreviewHost:()=>f.current});return()=>{g.cleanup()}},[b,y]),It(()=>w?b.subscribeViewport(w):()=>{},[b,w]),It(()=>()=>{b.destroy()},[b]),{hostRef:f,resolveObservedScrollHost(){return b.resolveObservedScrollHost()??Lr(y,f.current)},deferredProjection:R.deferredProjection,renderState:R.renderState}}import{drawingFragmentOffsetY as oo,drawingFragmentVisibleHeight as no,resolveRenderableTableRows as ao}from"@datalking/begonia-layout-contracts";import{listProjectionPageBlocks as io,resolvePageColumnSeparatorSegments as lo,resolvePaginatedPageContentLeftOrigin as so}from"@datalking/begonia-page-layout";import{drawingSceneTransform as Br}from"@datalking/begonia-layout-contracts";import{jsx as ce,jsxs as Ht}from"react/jsx-runtime";function Ir(e,t){return(t??e.label??"Shape").trim()||"Shape"}function Nr(e){return e.fill??e.fillColor??"none"}function Mr(e){return e==="butt"||e==="round"||e==="square"||e==="inherit"?e:void 0}function Ar(e){return e==="miter"||e==="round"||e==="bevel"||e==="inherit"?e:void 0}function Dr(e,t){let r={fill:Nr(e),fillOpacity:e.fillOpacity??void 0,stroke:e.stroke??"none",strokeOpacity:e.strokeOpacity??void 0,strokeWidth:e.strokeWidth??void 0,strokeDasharray:e.strokeDasharray??void 0,strokeLinecap:Mr(e.strokeLinecap),strokeLinejoin:Ar(e.strokeLinejoin),markerStart:e.markerStart??void 0,markerEnd:e.markerEnd??void 0,fillRule:e.fillRule??void 0,clipRule:e.clipRule??void 0,vectorEffect:e.stroke&&e.stroke!=="none"?"non-scaling-stroke":void 0};return e.kind==="rect"?ce("rect",{...r,x:e.x??0,y:e.y??0,width:e.width??0,height:e.height??0,rx:e.rx??void 0,ry:e.ry??void 0},t):e.kind==="ellipse"?ce("ellipse",{...r,cx:e.cx??0,cy:e.cy??0,rx:e.rx??0,ry:e.ry??0},t):ce("path",{...r,d:e.d??""},t)}function Or(e,t){return ce("text",{x:e.centerX,y:e.startY,fill:e.fill,fontSize:e.fontSize,fontFamily:e.fontFamily,fontWeight:e.fontWeight,textAnchor:"middle",dominantBaseline:"middle",paintOrder:"stroke",stroke:e.stroke??void 0,strokeWidth:e.strokeWidth??void 0,children:e.lines.map((r,a)=>ce("tspan",{x:e.centerX,y:e.startY+a*e.lineHeight,children:r},`${t}-${a}`))},t)}function Ot(e,t){let r=Br(e);return Ht("g",{transform:r||void 0,opacity:e.opacity??void 0,style:e.filter?{filter:e.filter}:void 0,children:[e.primitives.map((a,n)=>Dr(a,`${t}-primitive-${n}`)),e.children.map((a,n)=>Ot(a,`${t}-child-${n}`)),e.text?Or(e.text,`${t}-text`):null]},t)}function Ee({drawing:e,width:t,height:r,className:a,style:n,label:i}){let s=Math.max(1,Number(t??e.width??1)),p=Math.max(1,Number(r??e.height??1)),m=Ir(e,i);return Ht("svg",{xmlns:"http://www.w3.org/2000/svg",width:s,height:p,viewBox:e.viewBox,role:"img","aria-label":m,preserveAspectRatio:"xMidYMid meet",className:a||void 0,style:n,children:[ce("title",{children:m}),e.defs?.trim()?ce("defs",{dangerouslySetInnerHTML:{__html:e.defs}}):null,Ot(e.scene,"drawing-root")]})}import{createVirtualPagedPreviewDragSession as $e,isVirtualPagedPreviewFrameTarget as Ue,VIRTUAL_PAGED_PREVIEW_FRAME_DATA_ATTRIBUTE as We}from"@datalking/begonia-layout-renderer";import{PREVIEW_TABLE_CELL_HORIZONTAL_PADDING as ze,PREVIEW_TABLE_CELL_VERTICAL_PADDING as Ge}from"@datalking/begonia-layout-renderer";import{inlineRevisionSpanDisplayLayer as Gr,inlineRevisionSpanHasKind as Ze,resolveMeasuredLineSliceVisibleRange as Kr,resolveMeasuredLineSlicePaintSpans as qr,resolveMeasuredLineSlicePaintText as Zr,sliceInlineRevisionSpansByOffsets as Yr}from"@datalking/begonia-layout-contracts";import{createVirtualPagedPreviewInlineNodeAttributes as Xr}from"@datalking/begonia-layout-renderer";function Ve(e){return Number.isFinite(e)&&e>0?e:1}function K(e,t){return e*Ve(t)}function _t(e,t){let r=Ve(t);return{fontSize:typeof e.fontSize=="number"?`${e.fontSize*r}px`:void 0,letterSpacing:typeof e.letterSpacing=="number"?`${e.letterSpacing*r}px`:void 0}}import{jsx as Ke}from"react/jsx-runtime";function Le(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:null}function Pe(e,t,r){let a=e?.inlineObject?.kind==="image"?e.inlineObject:null;if(a){let p=Le(a.width),m=Le(a.height);return Ke("img",{className:"ald-inline-image",src:a.src,alt:a.alt??"",title:a.title??void 0,"data-image-id":a.objectId??void 0,width:p==null?void 0:K(p,r),height:m==null?void 0:K(m,r),style:{display:"inline-block",verticalAlign:"baseline",objectFit:"contain"}})}let n=e?.inlineObject?.kind==="drawing"?e.inlineObject:null;if(!n)return t;if(!n.drawing)return n.label||"Drawing";let i=K(Le(n.width)??n.drawing.width,r),s=K(Le(n.height)??n.drawing.height,r);return Ke("span",{className:`ald-inline-drawing ald-inline-${n.family}`,"data-family":n.family,"data-object-id":n.objectId??void 0,style:{display:"inline-block",width:i,height:s,verticalAlign:"baseline",lineHeight:0},children:Ke(Ee,{drawing:n.drawing,width:i,height:s,className:"ald-inline-drawing-svg",style:{display:"block",width:i,height:s}})})}import{resolveMeasuredLineSliceVisibleRange as Ft,resolveMeasuredLineSlicePaintSpans as Hr,resolveMeasuredLineSlicePaintText as _r,resolveTextLineAdvanceHeight as Fr,sliceInlineRevisionSpansByOffsets as jr}from"@datalking/begonia-layout-contracts";import{resolveProjectionLineMeasuredGeometry as $r,resolveTextLineFrame as jt}from"@datalking/begonia-page-layout";import{jsx as qe}from"react/jsx-runtime";function $t(e,t,r){if(!e.inlineSpans||e.inlineSpans.length===0||r<=t)return null;let a=e.lineSlices?.[0]?.fromOffset??0,n=Math.max(0,t-a),i=Math.max(n,r-a);return jr(e.inlineSpans,n,i)}function Ur(e,t,r,a){let n=Ft(a),i=jt(e,t),s=Number.isFinite(a.lineIndex)?a.lineIndex:t,p=Number.isFinite(a.lineCount)?a.lineCount:r;return{pageNumber:0,sectionIndex:0,sectionPageNumber:0,region:"body",blockIndex:0,fragmentIndex:e.fragmentIndex,columnIndex:e.columnIndex,lineIndex:s,lineCount:p,from:e.from+a.fromOffset,to:e.from+a.toOffset,left:0,top:0,width:Math.max(0,i.availableWidth),height:Math.max(1,e.lineHeight),text:n.text,logicalText:n.text,discretionaryHyphen:a.discretionaryHyphen===!0,nodeType:e.type,align:e.align??null,direction:e.direction??null,fontSize:e.fontSize??null,tabs:e.tabs??null,inlineSpans:$t(e,n.fromOffset,n.toOffset),continuesToNext:e.continuesToNext,label:n.text.trim()||e.text}}function Wr(e,t,r,a){let n=i=>i==="tab"||i==="space";return t.map((i,s)=>{let p=a+i.fromOffset,m=a+i.toOffset,u=i.span?e.interactiveInlineNodeSpanProps(i.span,p,m):null,c=i.leader==="dot"?".":i.leader==="hyphen"?"-":i.leader==="underscore"?"_":null,l=c?c.repeat(Math.max(1,Math.floor(i.width/Math.max(1,i.fontSize*.33)))):"\xA0";return qe("span",{style:{...i.span?e.inlineSpanStyle(e.block,i.span,e.scale):{fontWeight:i.bold?700:400,fontStyle:i.italic?"italic":"normal",fontVariantCaps:i.smallCaps?"small-caps":void 0,fontFamily:i.fontFamily??void 0,fontSize:`${K(i.fontSize,e.scale)}px`,letterSpacing:typeof i.letterSpacing=="number"?`${K(i.letterSpacing,e.scale)}px`:void 0},pointerEvents:u?"auto":void 0,display:n(i.kind)?"inline-block":void 0,width:n(i.kind)?K(i.width,e.scale):void 0,minWidth:n(i.kind)?K(i.width,e.scale):void 0,whiteSpace:i.kind==="tab"?"nowrap":i.kind==="space"?"pre":void 0,overflow:i.kind==="tab"?"hidden":void 0},...u??{},children:i.kind==="tab"?l:Pe(i.span,i.text,e.scale)},`${r}-${s}`)})}function zr(e,t,r,a){let n=r;return t.map((i,s)=>{let p=n;n+=i.text.length;let m=n,u=e.interactiveInlineNodeSpanProps(i,p,m);return qe("span",{style:{...e.inlineSpanStyle(e.block,i,e.scale),pointerEvents:u?"auto":void 0},...u??{},children:Pe(i,i.text,e.scale)},`${a}-${s}`)})}function Ut(e){let t=e.block.lineSlices??null;return!t||t.length===0?null:t.map((r,a)=>{let n=Ft(r),i=_r(r),s=jt(e.block,a),p=Fr(s,e.block.lineHeight,e.block.lineSpacingRule),m=s.leftInset*e.scale,u=Hr(r,$t(e.block,n.fromOffset,n.toOffset)??[]),c=n.text.length>0||(u?.length??0)>0,l=(e.block.textOffsetBase??0)+n.fromOffset,o=$r(Ur(e.block,a,t.length,r),e.measureText,e.measurementEpoch),d=o&&o.pieces.length>0?Wr(e,o.pieces,`${e.block.from}-${e.block.fragmentIndex}-line-${a}`,l):u&&u.length>0?zr(e,u,l,`${e.block.from}-${e.block.fragmentIndex}-line-${a}`):c?i:" ";return qe("span",{style:{display:"block",paddingLeft:Math.max(0,m),marginLeft:Math.min(0,m),paddingRight:s.rightInset*e.scale,minHeight:Math.max(1,p*e.scale),whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:d},`${e.block.from}-${e.block.fragmentIndex}-line-${a}`)})}import{jsx as et}from"react/jsx-runtime";function Xe(e){return e.type==="heading"?Math.max(13,Math.round(e.lineHeight*.9)):e.type==="footnote_reference"?Math.max(9,Math.round(e.lineHeight*.75)):Math.max(10,Math.round(e.lineHeight*.82))}function Jr(e){switch(e.align){case"left":case"right":case"center":case"justify":case"start":case"end":return e.align;case"both":return"justify";default:return}}function Qr(e){return e.direction==="ltr"||e.direction==="rtl"?e.direction:void 0}function eo(e){return e==="insert"?{background:"var(--ald-revision-insert-bg, rgba(15, 118, 110, 0.12))",textDecoration:"underline",textDecorationColor:"var(--ald-revision-insert-text, #0f766e)"}:e==="delete"?{background:"var(--ald-revision-delete-bg, rgba(185, 28, 28, 0.09))",textDecoration:"line-through",textDecorationColor:"var(--ald-revision-delete-text, #b91c1c)"}:e==="format"?{background:"var(--ald-revision-format-bg, rgba(217, 119, 6, 0.1))",textDecoration:"underline",textDecorationColor:"var(--ald-revision-format-text, #92400e)"}:null}function to(e){return[...new Set(e.filter(t=>typeof t=="string"&&t.length>0))].join(" ")}function Wt(e,t,r=1){let a=Ve(r),n=Gr(t),i=eo(n?.revisionKind??t.revisionKind??null)??{},s=typeof i=="object"&&i&&"textDecoration"in i?String(i.textDecoration):void 0,p=typeof i=="object"&&i&&"textDecorationColor"in i?String(i.textDecorationColor):void 0,m=Ze(t,"insert"),u=Ze(t,"delete"),c=Ze(t,"format"),l=t.smallCaps?"small-caps":void 0,o=t.textTransform&&t.textTransform!=="none"?t.textTransform:void 0,d=n?.revisionKind==="format"?"dotted":void 0;return{...i,fontWeight:t.bold||e.type==="heading"?700:400,fontStyle:t.italic?"italic":"normal",fontVariantCaps:l,textTransform:o,textDecoration:to([s,m||c?"underline":null,u?"line-through":null,t.underline?"underline":null,t.strike?"line-through":null,t.href?"underline":null]),textDecorationThickness:t.underline||t.href||m||c?"2px":void 0,textDecorationStyle:d,textDecorationColor:p??(t.href?"var(--ald-link, #155e75)":void 0),color:t.color??(t.href?"var(--ald-link, #155e75)":void 0),backgroundColor:t.highlight??void 0,fontFamily:t.fontFamily??void 0,..._t(t,a)}}function zt(e,t,r,a=null){let n=typeof e.sourceNodeType=="string"&&e.sourceNodeType.length>0?e.sourceNodeType:null;return!(n!=null&&e.sourceNodeSelectable===!0)||r<=t?null:Xr({nodeType:n,objectId:e.sourceObjectId??null,fromOffset:t,toOffset:r,tableOriginRow:a?.originRow??null,tableOriginColumn:a?.originColumn??null})}function Gt(e,t,r,a){let n=Ut({block:e,scale:t,measureText:r,measurementEpoch:a,inlineSpanStyle:Wt,interactiveInlineNodeSpanProps:zt});return n||(!e.inlineSpans||e.inlineSpans.length===0?e.renderedText:Ye(e,e.inlineSpans,`${e.from}-${e.to}`,e.textOffsetBase??0,null,t))}function ro(e,t,r){return Yr(e,t,r)}function Ye(e,t,r,a=0,n=null,i=1){if(!t||t.length===0)return null;let s=a;return t.map((p,m)=>{let u=s;s+=p.text.length;let l=zt(p,u,s,n);return et("span",{style:{...Wt(e,p,i),pointerEvents:l?"auto":void 0},...l??{},children:Pe(p,p.text,i)},`${r}-${m}`)})}function Kt(e,t,r,a){let{layout:n,text:i}=t,s=n?.lineSlices??null;if(s&&s.length>0)return s.map((m,u)=>{let c=Kr(m),l=Zr(m),o=qr(m,ro(n?.inlineSpans??null,c.fromOffset,c.toOffset)??[]);return et("span",{style:{display:"block"},children:o&&o.length>0?Ye(e,o,`${r}-line-${u}`,c.fromOffset,t,a):l||" "},`${r}-line-${u}`)});let p=Ye(e,n?.inlineSpans??null,r,0,t,a);return p||(n?.text??i)}function qt(e){let t=Array.isArray(e.tableColumnWidths)?e.tableColumnWidths:null;if(!t||t.length===0)return null;let r=t.reduce((a,n)=>a+Math.max(0,Number(n??0)),0);return r<=0?null:t.map((a,n)=>et("col",{style:{width:`${Math.max(0,Number(a??0))/r*100}%`}},`${e.from}-col-${n}`))}function Je(e,t,r){return(e-t)*r}function Qe(e,t,r){return(t+e)*r}function he(e,t,r=0,a=0){let n=!!(e.lineSlices&&e.lineSlices.length>0);return{position:"absolute",top:Je(e.top,r,t),left:Qe(e.left,a,t),width:Math.max(1,e.width*t),minHeight:Math.max(1,e.estimatedHeight*t),paddingBottom:Math.max(2,Math.round(t*4)),fontSize:(e.fontSize??Xe(e))*t,lineHeight:`${e.lineHeight*t}px`,fontFamily:'var(--ald-font-doc, "Times New Roman", serif)',whiteSpace:"pre-wrap",wordBreak:"break-word",color:e.type==="heading"?"var(--ald-doc-heading, #2f2417)":"var(--ald-doc-text, #1f2937)",fontWeight:e.type==="heading"?700:400,textAlign:Jr(e),direction:Qr(e),pointerEvents:"none",overflow:"hidden",paddingLeft:n?0:void 0,paddingRight:n?0:void 0}}import{jsx as L,jsxs as tt}from"react/jsx-runtime";function uo({block:e,scale:t,contentTop:r,contentLeft:a}){let n=he(e,t,r,a);return L("div",{style:n,children:e.assetSrc?L("img",{src:e.assetSrc,alt:"",style:{width:"100%",height:Math.max(32,(e.assetHeight??e.estimatedHeight)*t),objectFit:"contain",borderRadius:12,border:"var(--ald-image-border, 1px solid rgba(92, 70, 43, 0.14))",background:"#fff"}}):L("div",{style:{height:Math.max(32,(e.assetHeight??e.estimatedHeight)*t),borderRadius:12,border:"var(--ald-image-placeholder-border, 1px dashed rgba(92, 70, 43, 0.24))",background:"var(--ald-image-placeholder-bg, rgba(245, 158, 11, 0.08))",display:"grid",placeItems:"center",color:"var(--ald-image-placeholder-text, #8a5b12)",fontSize:12,letterSpacing:"0.08em",textTransform:"uppercase"},children:"Image"})},`${e.from}-${e.to}-${e.fragmentIndex}-${e.top}`)}function co({block:e,scale:t,contentTop:r,contentLeft:a}){let n=he(e,t,r,a),i=Math.max(0,Math.min(Number(e.tableHeaderRowCount??0),e.tableRows?.length??0)),s=qt(e),p=Ge*t,m=ze*t,u=ao(e);return L("div",{style:n,children:tt("table",{style:{width:"100%",borderCollapse:"collapse",tableLayout:"fixed",fontSize:Math.max(9,Xe(e)*t),background:"#fff"},children:[s?L("colgroup",{children:s}):null,L("tbody",{children:u.map(c=>L("tr",{children:c.cells.map(l=>{let o=c.fragmentRowIndex<i?"th":"td";return L(o,{colSpan:l.colSpan>1?l.colSpan:void 0,rowSpan:l.rowSpanInFragment>1?l.rowSpanInFragment:void 0,style:{border:"var(--ald-table-border, 1px solid rgba(92, 70, 43, 0.18))",padding:`${p}px ${m}px`,verticalAlign:"top",fontWeight:c.fragmentRowIndex<i?700:void 0,textAlign:"left",background:c.fragmentRowIndex<i?"var(--ald-table-header-bg, rgba(226, 232, 240, 0.65))":void 0},children:Kt(e,l,`${e.from}-${c.fragmentRowIndex}-${l.physicalIndex}`,t)},`${e.from}-${c.fragmentRowIndex}-${l.physicalIndex}-${l.originColumn}`)})},`${e.from}-${c.fragmentRowIndex}-${c.sourceRowIndex}`))})]})},`${e.from}-${e.to}-${e.fragmentIndex}-${e.top}`)}function po({block:e,scale:t,contentTop:r,contentLeft:a}){let n=Math.max(24,Number(e.drawing?.width??e.drawing?.intrinsicWidth??e.width??0))*t,i=Math.max(24,Number(e.drawing?.height??e.drawing?.intrinsicHeight??e.estimatedHeight??0))*t,s=oo(e)*t,p=Math.max(1,no(e)*t||i),m=s>0||p<i,u={...he(e,t,r,a),minHeight:p},c=e.drawing?.scene&&e.drawing.viewBox?L(Ee,{drawing:e.drawing,width:n,height:i,className:"ald-drawing-scene-svg",style:{display:"block",width:"100%",height:"100%"}}):L("div",{style:{width:"100%",height:"100%"},dangerouslySetInnerHTML:{__html:e.drawing?.svg??""}});return L("div",{style:u,children:e.drawing?L("div",{style:{width:n,height:p,maxWidth:"100%",overflow:m?"hidden":void 0},children:L("div",{style:{width:n,height:i,transform:m?`translateY(-${s}px)`:void 0,transformOrigin:m?"top left":void 0},children:c})}):L("div",{style:{width:n,height:i,borderRadius:12,border:"1px dashed rgba(92, 70, 43, 0.24)",background:"rgba(226, 232, 240, 0.58)",display:"grid",placeItems:"center",color:"#475569",fontSize:12,letterSpacing:"0.08em",textTransform:"uppercase"},children:"Shape"})},`${e.from}-${e.to}-${e.fragmentIndex}-${e.top}`)}function mo({block:e,scale:t,contentTop:r,contentLeft:a,measureText:n,measurementEpoch:i}){return e.drawing?L(po,{block:e,scale:t,contentTop:r,contentLeft:a}):e.type==="image"?L(uo,{block:e,scale:t,contentTop:r,contentLeft:a}):e.type==="table"&&e.tableRows?L(co,{block:e,scale:t,contentTop:r,contentLeft:a}):L("div",{style:he(e,t,r,a),children:Gt(e,t,n,i)},`${e.from}-${e.to}-${e.fragmentIndex}-${e.top}`)}function fo({page:e,scale:t,contentTop:r,contentLeft:a}){return lo(e).map(n=>L("div",{"data-ald-column-separator":"true",style:{position:"absolute",top:Je(n.top,r,t),left:Qe(n.left,a,t),height:Math.max(1,n.height*t),width:1,background:"var(--ald-column-separator, rgba(31, 41, 55, 0.7))",pointerEvents:"none"}},`separator-${n.regionIndex}-${n.separatorIndex}-${n.top}`))}function Be({frame:e,scale:t,measureText:r,measurementEpoch:a,offsetTop:n=0,offsetLeft:i=0,flowMode:s="paginated",renderPageOverlay:p,onProjectionPositionHit:m}){let u=e.page,c=s==="web"?e.contentTop:0,l=s==="web"?-e.contentLeft:so(u),o=io(u);return tt("article",{[We]:"true",style:{position:"absolute",top:e.top-n,left:e.left-i,width:e.width,height:e.height,boxSizing:"border-box",background:s==="web"?"transparent":"var(--ald-page-bg, #fffdfa)",border:s==="web"?"none":"var(--ald-page-border, 1px solid rgba(92, 70, 43, 0.14))",borderRadius:s==="web"?0:"var(--ald-page-radius, 20px)",boxShadow:s==="web"?"none":"var(--ald-page-shadow, 0 18px 40px rgba(69, 47, 16, 0.12))",overflow:"hidden",cursor:m?"text":void 0},children:[s==="paginated"?tt("div",{style:{display:"var(--ald-page-label-display, block)",position:"absolute",top:10,right:14,fontSize:12,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--ald-page-label-color, #8a5b12)"},children:["Page ",u.pageNumber]}):null,L(fo,{page:u,scale:t,contentTop:c,contentLeft:l}),o.map(d=>L(mo,{block:d,scale:t,contentTop:c,contentLeft:l,measureText:r,measurementEpoch:a},`${d.from}-${d.to}-${d.fragmentIndex}-${d.top}`)),p?L("div",{style:{position:"absolute",inset:0},children:p(e,t)}):null]})}import{bindVirtualPagedPreviewWindowDragListeners as rt}from"@datalking/begonia-layout-renderer";import{Fragment as Po,jsx as $,jsxs as ot}from"react/jsx-runtime";function nt({projection:e,version:t=null,measureText:r,measurementEpoch:a,height:n=720,width:i,scrollHost:s=null,scale:p=_e,pageGap:m=24,windowPages:u=5,overscan:c=2,virtualize:l=!0,layoutMode:o="vertical",flowMode:d,anchorPageNumber:v=null,initialViewportAnchor:y=null,viewportRequestKey:w=null,pinnedPageNumbers:f,theme:x,emptyLabel:b="No paginated preview available yet.",onViewportChange:R,renderPageOverlay:g,onProjectionPositionHit:E}){let k=wo(p),B=q(null);B.current===null&&(B.current=bo());let H=r??B.current??void 0,I=je(e,d),{hostRef:Q,resolveObservedScrollHost:oe,deferredProjection:z,renderState:M}=Dt({projection:e,version:t,height:n,width:i,scale:k,pageGap:m,windowPages:u,overscan:c,virtualize:l,layoutMode:o,flowMode:I,anchorPageNumber:v,initialViewportAnchor:y,viewportRequestKey:w,pinnedPageNumbers:f,scrollHost:s,onViewportChange:R}),G=q(null),le=q(H),Re=q(a),ve=q([]),be=q(k),S=q(I),ee=q(E),we=q(null),Te=q($e({getProjection:()=>G.current,getMountedFrames:()=>ve.current,getMeasureText:()=>le.current,getMeasurementEpoch:()=>Re.current,getScale:()=>be.current,getFlowMode:()=>S.current,getPaginatedHorizontalOrigin:()=>"frame",getInteractionRoot:()=>Q.current,getScrollHost:()=>oe(),dispatchPositionHit(h){return ee.current?.(h)}}));G.current=z,le.current=H,Re.current=a,ve.current=M.window.mountedFrames,be.current=k,S.current=I,ee.current=E,vo(()=>{let h=Te.current;return()=>{let j=we.current;we.current=null,j?.(),h.destroy()}},[]);let me=xo({renderState:M,flowMode:I}),cr=me.useSpacerWindow,se=me.spacerWindowLayout,pr=se.mountedWindowLayout,mr={height:s?void 0:n,width:s?void 0:i,overflow:s?"visible":"auto",borderRadius:"var(--ald-canvas-radius, 18px)",background:I==="web"?"var(--ald-web-canvas, linear-gradient(180deg, rgba(247, 248, 250, 0.92), rgba(241, 245, 249, 0.88)))":"var(--ald-canvas, linear-gradient(180deg, rgba(242, 236, 225, 0.92), rgba(235, 227, 214, 0.86)))",border:I==="web"?"var(--ald-web-canvas-border, 1px solid rgba(148, 163, 184, 0.18))":"var(--ald-canvas-border, 1px solid rgba(92, 70, 43, 0.12))"},fr={width:me.contentWidth,margin:"0 auto",padding:I==="web"?`20px ${Fe}px 28px`:"20px 0 28px"},gr={position:"relative",width:me.layoutSurfaceWidth>0?me.layoutSurfaceWidth:void 0,minHeight:me.layoutSurfaceHeight,margin:"0 auto"},vr=h=>{if(!E||h.button!==0||!Ue(h.target))return;let j=()=>{let ne=we.current;we.current=null,ne?.()},xe=()=>{Te.current.handleMouseUp(),j()};j();let De=Te.current.handleMouseDown({clientX:h.clientX,clientY:h.clientY,button:h.button,buttons:h.buttons,detail:h.detail,shiftKey:h.shiftKey,target:h.target});if(!De.started){De.handled&&h.preventDefault();return}let Tt=h.currentTarget.ownerDocument.defaultView;Tt&&(we.current=rt({view:Tt,onMouseMove(ne){if((ne.buttons&1)!==1){xe();return}Te.current.handleMouseMove({clientX:ne.clientX,clientY:ne.clientY,buttons:ne.buttons,target:ne.target})&&ne.preventDefault()},onStop(){xe()}}).cleanup),De.handled&&h.preventDefault()};return $("div",{...de(x,mr),children:!z||z.pages.length===0?$("div",{style:{minHeight:n,display:"grid",placeItems:"center",color:"var(--ald-text-muted, #6b5a46)",padding:24},children:b}):$("div",{style:fr,children:$("div",{ref:Q,onMouseDown:E?vr:void 0,style:gr,children:cr?ot(Po,{children:[$("div",{"data-begonia-virtual-spacer":"top",style:{height:se.topSpacerHeight,width:"100%",overflowAnchor:"none"}}),ot("div",{style:{display:"flex",width:"100%",direction:"ltr",overflowAnchor:"none"},children:[$("div",{"data-begonia-virtual-spacer":"left",style:{width:se.leftSpacerWidth,flex:"0 0 auto",overflowAnchor:"none"}}),$("div",{style:{position:"relative",height:se.mountedSurfaceHeight,width:se.mountedSurfaceWidth,flex:"0 0 auto"},children:pr.clusters.map(h=>{let j=h.leadingGap;return ot("div",{style:{position:"absolute",top:h.offsetTop,left:h.offsetLeft,width:h.width,height:h.height},children:[j?$("div",{"data-begonia-virtual-spacer":"gap","data-begonia-gap-from":String(j.fromPageIndex),"data-begonia-gap-to":String(j.toPageIndex),style:{position:"absolute",top:j.top,left:j.left,width:j.width,height:j.height,overflowAnchor:"none"}}):null,h.frames.map(xe=>$(Be,{frame:xe,scale:k,measureText:H,measurementEpoch:a,flowMode:I,offsetTop:h.top,offsetLeft:h.left,renderPageOverlay:g,onProjectionPositionHit:E},`page-${xe.page.pageNumber}`))]},`cluster-${h.startIndex}-${h.endIndex}`)})}),$("div",{"data-begonia-virtual-spacer":"right",style:{width:se.rightSpacerWidth,flex:"0 0 auto",overflowAnchor:"none"}})]}),$("div",{"data-begonia-virtual-spacer":"bottom",style:{height:se.bottomSpacerHeight,width:"100%",overflowAnchor:"none"}})]}):M.window.mountedFrames.map(h=>$(Be,{frame:h,scale:k,measureText:H,measurementEpoch:a,flowMode:I,renderPageOverlay:g,onProjectionPositionHit:E},`page-${h.page.pageNumber}`))})})})}import{jsx as Zt}from"react/jsx-runtime";function Ro(e){return{projection:e.projection??null,adapter:e.adapter,source:e.source??null,version:e.version??null,options:e.options,flowMode:e.flowMode,scale:e.scale,measureText:e.measureText}}function lt({projection:e=null,adapter:t,source:r=null,version:a,options:n,measureText:i,onLayoutChange:s,scrollHost:p,height:m,width:u,scale:c,pageGap:l,windowPages:o,overscan:d,virtualize:v,layoutMode:y,flowMode:w,anchorPageNumber:f,initialViewportAnchor:x,viewportRequestKey:b,pinnedPageNumbers:R,theme:g,emptyLabel:E,onViewportChange:k,onProjectionPositionHit:B}){let H=it(null),I=it(null);I.current===null&&(I.current=ko());let Q=i??I.current??void 0,oe=yo(()=>Ro({projection:e,adapter:t,source:r,version:a,options:n,flowMode:w,scale:c,measureText:Q}),[t,Q,w,n,e,c,r,a]),z=it(null);(!z.current||z.current.isDestroyed?.()===!0)&&(z.current=So(oe));let M=z.current,G=N(M)??M.getSnapshot();return at(()=>{M.setInput(oe)},[M,oe]),at(()=>{let le=M.bindHost({getHost:()=>H.current,getScrollHost:()=>p??null});return()=>{le.cleanup()}},[M,p]),at(()=>{s?.(G.resolvedLayout)},[s,G.resolvedLayout]),ho(()=>()=>{M.destroy()},[M]),Zt("div",{ref:H,style:{width:"100%"},children:Zt(nt,{projection:G.previewProjection,version:a??null,measureText:Q,scrollHost:p,height:m,width:u,scale:c,pageGap:l,windowPages:o,overscan:d,virtualize:v,layoutMode:y,flowMode:G.requestedFlowMode,anchorPageNumber:f,initialViewportAnchor:x,viewportRequestKey:b,pinnedPageNumbers:R,theme:g,emptyLabel:E,onViewportChange:k,onProjectionPositionHit:B})})}import{useEffect as pe,useLayoutEffect as Yt,useMemo as Xt,useReducer as To,useRef as Z}from"react";import{createBrowserEditorMount as Co}from"@datalking/begonia-browser-sdk";var te=Symbol("browser-editor-ui-callback-unset");function st({onEditorChange:e,onHostChange:t,onSnapshotChange:r,...a}){let n=Xt(()=>({backend:a.backend,backendInput:a.backendInput}),[a.backend,a.backendInput]),i=Z(null);i.current||(i.current=Co(n));let s=i.current,p=Z(null),[m,u]=To(k=>k+1,0),c=Xt(()=>({getSnapshot:()=>s.getSnapshot(),subscribe:k=>s.subscribe(k)}),[m,s]),l=N(c)??s.getSnapshot(),o=l.ui,d=l.host,v=l.snapshot,y=Z(e),w=Z(t),f=Z(r),x=Z(te),b=Z(te),R=Z(te),g=Z(null),E=Z(null);if(!E.current){let k=(B=>{g.current!==B&&(g.current=B,s.setHost(B),u())});Object.defineProperty(k,"current",{configurable:!0,enumerable:!0,get(){return g.current},set(B){k(B)}}),E.current=k}return Yt(()=>{p.current!==null&&(clearTimeout(p.current),p.current=null)},[s]),pe(()=>{y.current=e},[e]),pe(()=>{w.current=t},[t]),pe(()=>{f.current=r},[r]),Yt(()=>{s.setInput(n.backendInput)},[s,n]),pe(()=>{if(x.current===o||x.current===te&&o==null){x.current=o;return}x.current=o,y.current?.(o)},[o]),pe(()=>{if(b.current===d||b.current===te&&d==null){b.current=d;return}b.current=d,w.current?.(d)},[d]),pe(()=>{if(R.current===v||R.current===te&&v==null){R.current=v;return}R.current=v,f.current?.(v)},[v]),pe(()=>()=>{let k=setTimeout(()=>{p.current===k&&(p.current=null,x.current!==te&&x.current!==null&&y.current?.(null),b.current!==te&&b.current!==null&&w.current?.(null),R.current!==te&&R.current!==null&&f.current?.(null),x.current=null,b.current=null,R.current=null,s.destroy())},0);p.current=k},[s]),{hostRef:E.current,ui:o,host:d,snapshot:v}}import{createEditorUiController as Lo}from"@datalking/begonia-editor-ui";import{useEffect as Eo,useMemo as Vo}from"react";function Jt(e,t){let r=Vo(e,t);return Eo(()=>()=>{r?.destroy()},[r]),r}function dt(e,t=null){let r=Jt(()=>Lo(e),[e]),a=t??r,n=N(a)??a.getSnapshot();return{controller:a,snapshot:n}}import{resolveVirtualPagedPreviewPositionHit as Bo,resolveVirtualPagedPreviewPositionHitInMountedFrames as Io}from"@datalking/begonia-layout-renderer";import{applyVirtualPagedPreviewAutoscroll as No,createVirtualPagedPreviewAutoscrollController as Mo,resolveVirtualPagedPreviewAutoscrollDelta as Ao}from"@datalking/begonia-layout-renderer";import{resolveVirtualPagedPreviewRenderState as Do}from"@datalking/begonia-layout-renderer";import{cloneVirtualPagedPreviewAnchor as Pi,cloneVirtualPagedPreviewMetrics as Oo,cloneVirtualPagedPreviewSnapshot as hi,normalizeVirtualPagedPreviewPinnedPageIndexes as Ho,normalizeVirtualPagedPreviewRequestKey as _o,resolveVirtualPagedPreviewHostMeasurement as Fo,resolveVirtualPagedPreviewResizeObserver as jo,sameVirtualPagedPreviewAnchor as yi,sameVirtualPagedPreviewMetrics as $o,sameVirtualPagedPreviewSnapshot as Si}from"@datalking/begonia-layout-renderer";import{createVirtualPagedPreviewSessionState as Uo,resolveVirtualPagedPreviewSessionCommit as Wo,resolveVirtualPagedPreviewSessionViewportEmission as zo}from"@datalking/begonia-layout-renderer";import{useEffect as Qt,useLayoutEffect as Go,useMemo as ut,useRef as er}from"react";import{createBrowserPaginatedPreviewController as Ko,resolveBrowserPaginatedPreviewBindingProjection as qo}from"@datalking/begonia-browser-sdk/preview";import{resolveBrowserEditorPreviewBinding as Zo}from"@datalking/begonia-browser-sdk";import{createDefaultPaginatedLayoutMeasureText as Yo}from"@datalking/begonia-layout-renderer";import{jsx as Qo}from"react/jsx-runtime";function Xo(e){return{adapter:e.adapter??null,source:e.source??null,version:e.version??null,options:e.options??null}}function Jo(e){return{editor:e.editor,source:e.source,explicitProjection:e.projection??null,explicitScale:e.scale,pageGap:Bt(e.pageGap),explicitFlowMode:e.flowMode,explicitLayoutMode:e.layoutMode,explicitAnchorPageNumber:e.anchorPageNumber,controllerNavigationMode:e.controllerNavigationMode,syncViewportToEditor:e.syncViewportToEditor,pinnedPageNumbers:e.pinnedPageNumbers,layoutResolutionIdentity:e.layoutResolutionIdentity}}function tr({editor:e,scale:t,flowMode:r,anchorPageNumber:a,controllerNavigationMode:n="consume",syncViewportToEditor:i=!0,onViewportChange:s,onLayoutChange:p,onProjectionPositionHit:m,...u}){let c=ut(()=>Xo(u),[u.adapter,u.options,u.source,u.version]),l=ut(()=>Jo({...u,editor:e,scale:t,flowMode:r,anchorPageNumber:a,controllerNavigationMode:n,syncViewportToEditor:i,layoutResolutionIdentity:c}),[a,n,e,r,c,u.layoutMode,u.pageGap,u.pinnedPageNumbers,u.projection,t,i]),o=er(null);(!o.current||o.current.isDestroyed?.()===!0)&&(o.current=Ko(l));let d=o.current,v=N(d)??d.getSnapshot(),y=u.projection??null,w=ut(()=>Zo(e),[e]),f=er(null);f.current===null&&(f.current=Yo());let x=u.measureText??f.current??void 0;return Go(()=>{d.setInput(l)},[d,l]),Qt(()=>()=>{d.destroy()},[d]),Qt(()=>{if(w?.setResolvedProjection)return w.setResolvedProjection(qo({binding:w,source:u.source,explicitProjection:y,resolvedProjection:v.previewProjection}),{measureText:x,measurementEpoch:u.options?.measurementEpoch}),()=>{w.setResolvedProjection?.(null,null)}},[u.source,y,x,u.options?.measurementEpoch,w,v.previewProjection]),Qo(lt,{...u,projection:y,layoutMode:v.viewModel.layoutMode,flowMode:v.viewModel.flowMode,scale:v.viewModel.scale,anchorPageNumber:v.viewModel.anchorPageNumber,initialViewportAnchor:v.viewModel.initialViewportAnchor,viewportRequestKey:v.viewModel.viewportRequestKey,pinnedPageNumbers:v.pinnedPageNumbers,onLayoutChange:b=>{d.setResolvedProjection(b),p?.(b)},onViewportChange:b=>{d.observeViewport(b,v.viewportResetVersion),s?.(b)},onProjectionPositionHit:b=>{let R=d.resolvePositionHitEvent(b),g=d.handlePositionHit(R),E=m?.(R);return g||E===!0}},v.viewportResetVersion)}import{jsx as tn}from"react/jsx-runtime";function en(...e){return e.filter(Boolean).join(" ")}function T({active:e,mixed:t=!1,disabled:r=!1,label:a,onClick:n,title:i}){return tn("button",{type:"button","aria-pressed":t?"mixed":e,disabled:r,title:i,className:en("inline-flex h-7 min-w-7 items-center justify-center rounded-[var(--ald-control-radius,9999px)] px-2.5 text-xs font-semibold transition disabled:pointer-events-none disabled:opacity-40",t?"bg-[var(--ald-accent-muted,#f0fdfa)] text-[var(--ald-accent,#0f766e)] shadow-[inset_0_0_0_1px_var(--ald-accent,#0f766e)]":e?"bg-[var(--ald-toolbar-active-bg,#0f766e)] text-[var(--ald-toolbar-active-text,#ffffff)]":"text-[var(--ald-toolbar-text,#334155)] hover:bg-[var(--ald-toolbar-hover-bg,#f8fafc)]"),onClick:n,children:a})}import{jsx as fe,jsxs as rn}from"react/jsx-runtime";function Ie(...e){return e.filter(Boolean).join(" ")}function U({children:e,pressed:t=!1,disabled:r=!1,title:a,ariaLabel:n,onClick:i}){return fe("button",{type:"button","aria-pressed":t==="mixed"?"mixed":t,"aria-label":n,title:a,disabled:r,onClick:i,className:Ie("inline-flex h-8 min-w-8 items-center justify-center gap-1 rounded-[var(--ald-control-radius,9999px)] px-2 text-xs font-semibold transition disabled:pointer-events-none disabled:opacity-40",t==="mixed"?"bg-[var(--ald-accent-muted,#f0fdfa)] text-[var(--ald-accent,#0f766e)] shadow-[inset_0_0_0_1px_var(--ald-accent,#0f766e)]":t?"bg-[var(--ald-toolbar-active-bg,#0f766e)] text-[var(--ald-toolbar-active-text,#ffffff)]":"text-[var(--ald-toolbar-text,#334155)] hover:bg-[var(--ald-toolbar-hover-bg,#f8fafc)]"),children:e})}function _(){return fe("span",{"aria-hidden":"true",className:"mx-1 inline-block h-5 w-px shrink-0 self-center bg-[var(--ald-border,#e2e8f0)]"})}function ge({value:e,options:t,disabled:r=!1,title:a,ariaLabel:n,widthClass:i="min-w-0 max-w-40",onChange:s}){let p=t.find(m=>m.value===e);return rn("label",{className:Ie("inline-flex h-8 items-center gap-1.5 rounded-[var(--ald-control-radius,9999px)] border border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-surface,#ffffff)] px-2 text-xs text-[var(--ald-toolbar-text,#334155)] transition has-[select:disabled]:opacity-40 has-[select:focus-visible]:border-[var(--ald-accent,#0f766e)]",i),children:[p?.swatch?fe("span",{"aria-hidden":"true",className:"h-3 w-3 shrink-0 rounded-[2px] border border-[var(--ald-border,#e2e8f0)]",style:{background:p.swatch}}):null,fe("select",{"aria-label":n,title:a,disabled:r,value:e,onChange:m=>s(m.target.value),className:"w-full cursor-pointer appearance-none truncate bg-transparent text-xs font-medium outline-none",children:t.map(m=>fe("option",{value:m.value,children:m.label},m.value))}),fe("span",{"aria-hidden":"true",className:"pointer-events-none shrink-0 text-[8px] text-[var(--ald-text-muted,#64748b)]",children:"\u25BC"})]})}import{jsx as re,jsxs as on}from"react/jsx-runtime";function ct({controller:e}){let t=N(e);if(!e||!t?.enabled)return null;let r=t.suppressInternalExternal;return on("div",{className:"flex flex-wrap items-center gap-1 rounded-[var(--ald-control-group-radius,20px)] border border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-toolbar-bg,#f8fafc)] px-2 py-1.5",children:[re("span",{className:"px-1 text-[10px] font-bold uppercase tracking-[0.12em] text-[var(--ald-text-muted,#64748b)]",children:"Comments"}),re(T,{active:t.visible,label:"Show",onClick:()=>e.setCommentsVisible(!0)}),re(T,{active:!t.visible,label:"Hide",onClick:()=>e.setCommentsVisible(!1)}),re(T,{active:t.showResolved,label:"Resolved",onClick:()=>e.setCommentsShowResolved(!t.showResolved)}),re(_,{}),re("span",{className:"px-1 text-[10px] font-bold uppercase tracking-[0.12em] text-[var(--ald-text-muted,#64748b)]",children:"Scope"}),re(T,{active:t.visibility==="all",disabled:r,label:"All",onClick:()=>e.setCommentsVisibility("all")}),re(T,{active:t.visibility==="internal",disabled:r,label:"Internal",onClick:()=>e.setCommentsVisibility("internal")}),re(T,{active:t.visibility==="external",label:"External",onClick:()=>e.setCommentsVisibility("external")})]})}import{jsx as A,jsxs as F}from"react/jsx-runtime";function Ne(...e){return e.filter(Boolean).join(" ")}function pt({comments:e,permissionsByCommentId:t,activeCommentId:r=null,canCreateComment:a=!1,createCommentDisabledReason:n=null,onCreateComment:i,onSelectComment:s,onToggleCommentInternal:p,onReplyComment:m,onResolveComment:u,onReopenComment:c}){return F("aside",{className:"grid gap-3","aria-label":"Comments sidebar",children:[F("header",{className:"flex items-center justify-between",children:[F("div",{children:[A("h2",{className:"text-sm font-semibold text-[var(--ald-text,#0f172a)]",children:"Comments"}),F("p",{className:"text-xs text-[var(--ald-text-muted,#64748b)]",children:[e.length," thread",e.length===1?"":"s"]})]}),i?A("button",{type:"button",disabled:!a,title:n??void 0,className:"rounded-[var(--ald-control-radius,9999px)] border border-[var(--ald-border,#e2e8f0)] px-3 py-1.5 text-xs font-semibold text-[var(--ald-toolbar-text,#334155)] disabled:cursor-not-allowed disabled:opacity-45",onClick:()=>i(),children:"New Comment"}):null]}),F("div",{className:"grid gap-3",children:[e.length===0?A("div",{className:"rounded-[var(--ald-radius,28px)] border border-dashed border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-surface-muted,#f8fafc)] px-4 py-6 text-sm text-[var(--ald-text-muted,#64748b)]",children:"No comment threads."}):null,e.map(l=>{let o=t?.[l.id]??null;return F("section",{className:Ne("grid gap-3 rounded-3xl border px-4 py-4 shadow-sm transition",r===l.id?"border-[var(--ald-accent,#5eead4)] bg-[var(--ald-accent-muted,#f0fdfa)]":"border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-surface,#ffffff)]"),children:[F("button",{type:"button",className:"grid gap-1 text-left",onClick:()=>s?.(l.id),children:[F("div",{className:"flex items-center justify-between gap-3",children:[A("strong",{className:"text-sm text-[var(--ald-text,#0f172a)]",children:l.authorName??l.authorId??"Unknown author"}),F("div",{className:"flex items-center gap-2",children:[A("span",{className:Ne("rounded-full px-2 py-1 text-[11px] font-semibold",l.isInternal?"bg-slate-200 text-slate-700":"bg-sky-100 text-sky-700"),children:l.isInternal?"Internal":"External"}),A("span",{className:Ne("rounded-full px-2 py-1 text-[11px] font-semibold",l.resolved?"bg-emerald-100 text-emerald-700":"bg-amber-100 text-amber-700"),children:l.resolved?"Resolved":"Open"})]})]}),A("p",{className:"text-sm text-[var(--ald-text,#334155)]",children:l.text||"Empty comment"}),F("span",{className:"text-[11px] text-[var(--ald-text-muted,#94a3b8)]",children:[l.entries.length," message",l.entries.length===1?"":"s"]})]}),A("div",{className:"grid gap-2",children:l.entries.map(d=>F("article",{className:Ne("rounded-2xl px-3 py-2 text-sm",d.parentId==null?"bg-[var(--ald-surface-muted,#f8fafc)] text-[var(--ald-text,#334155)]":"bg-slate-100/80 text-slate-600"),children:[F("div",{className:"flex items-center justify-between gap-3",children:[A("strong",{className:"text-[11px] uppercase tracking-[0.12em] text-[var(--ald-text-muted,#94a3b8)]",children:d.parentId==null?"Thread":"Reply"}),A("span",{className:"text-[11px] text-[var(--ald-text-muted,#94a3b8)]",children:d.authorName??d.authorId??"Unknown"})]}),A("p",{children:d.text||"Empty entry"})]},d.id))}),F("div",{className:"flex flex-wrap gap-2",children:[p?A("button",{type:"button",disabled:o?!o.toggleInternal.allowed:!1,title:o?.toggleInternal.reason??void 0,className:"rounded-[var(--ald-control-radius,9999px)] border border-[var(--ald-border,#e2e8f0)] px-3 py-1.5 text-xs font-semibold text-[var(--ald-toolbar-text,#334155)] disabled:cursor-not-allowed disabled:opacity-45",onClick:()=>p(l.id,!l.isInternal),children:l.isInternal?"Mark External":"Mark Internal"}):null,A("button",{type:"button",disabled:o?!o.reply.allowed:!1,title:o?.reply.reason??void 0,className:"rounded-[var(--ald-control-radius,9999px)] border border-[var(--ald-border,#e2e8f0)] px-3 py-1.5 text-xs font-semibold text-[var(--ald-toolbar-text,#334155)] disabled:cursor-not-allowed disabled:opacity-45",onClick:()=>m?.(l.id),children:"Reply"}),l.resolved?A("button",{type:"button",disabled:o?!o.reopen.allowed:!1,title:o?.reopen.reason??void 0,className:"rounded-[var(--ald-control-radius,9999px)] border border-[var(--ald-border,#e2e8f0)] px-3 py-1.5 text-xs font-semibold text-[var(--ald-toolbar-text,#334155)] disabled:cursor-not-allowed disabled:opacity-45",onClick:()=>c?.(l.id),children:"Reopen"}):A("button",{type:"button",disabled:o?!o.resolve.allowed:!1,title:o?.resolve.reason??void 0,className:"rounded-[var(--ald-control-radius,9999px)] border border-[var(--ald-border,#e2e8f0)] px-3 py-1.5 text-xs font-semibold text-[var(--ald-toolbar-text,#334155)] disabled:cursor-not-allowed disabled:opacity-45",onClick:()=>u?.(l.id),children:"Resolve"})]})]},l.id)})]})]})}import{Fragment as Me,jsx as P,jsxs as W}from"react/jsx-runtime";var mt=[{value:"",label:"Theme font"},{value:"Aptos",label:"Aptos"},{value:"Calibri",label:"Calibri"},{value:"Arial",label:"Arial"},{value:"Helvetica",label:"Helvetica"},{value:"Segoe UI",label:"Segoe UI"},{value:"Times New Roman",label:"Times New Roman"},{value:"Georgia",label:"Georgia"},{value:"Garamond",label:"Garamond"},{value:"Courier New",label:"Courier New"},{value:"Verdana",label:"Verdana"}],nn=[8,9,10,11,12,14,16,18,20,24,28,32,36,48,72],ft=[{value:"",label:"Automatic",swatch:null},{value:"#000000",label:"Black",swatch:"#000000"},{value:"#404040",label:"Dark gray",swatch:"#404040"},{value:"#c00000",label:"Dark red",swatch:"#c00000"},{value:"#ed7d31",label:"Orange",swatch:"#ed7d31"},{value:"#ffc000",label:"Yellow",swatch:"#ffc000"},{value:"#538135",label:"Green",swatch:"#538135"},{value:"#0070c0",label:"Blue",swatch:"#0070c0"},{value:"#7030a0",label:"Purple",swatch:"#7030a0"}],gt=[{value:"",label:"No highlight",swatch:null},{value:"#ffff00",label:"Yellow",swatch:"#ffff00"},{value:"#00ff00",label:"Bright green",swatch:"#00ff00"},{value:"#00ffff",label:"Turquoise",swatch:"#00ffff"},{value:"#ff00ff",label:"Pink",swatch:"#ff00ff"},{value:"#92d0ff",label:"Blue",swatch:"#92d0ff"},{value:"#ffb3b3",label:"Light red",swatch:"#ffb3b3"}],rr=[{command:"paragraph",label:"Body text"},{command:"heading-1",label:"Heading 1"},{command:"heading-2",label:"Heading 2"},{command:"heading-3",label:"Heading 3"},{command:"bullet-list",label:"Bulleted list"},{command:"numbered-list",label:"Numbered list"}];function an(e){let t=rr.find(r=>e(r.command)?.active===!0);return t?t.command:""}function ln(e){let t=[...nn];return e!=null&&!t.includes(e)&&(t.push(e),t.sort((r,a)=>r-a)),t.map(r=>String(r))}function vt({editorHost:e,controller:t=null,linkActions:r=null,leadingActions:a=null,trailingActions:n=null,showTrackingToggle:i=!0,showSelectionReviewActions:s=!0,showRichFormatControls:p=!0}){let{controller:m,snapshot:u}=dt(e,t);function c(g,E){return m.execute(g,E)}function l(g){return u.commands[g]??null}function o(g,E){if(g==="link-set"||g==="link-clear"){if(!r){if(g==="link-set"){let B=l("link-set"),H=typeof B?.value=="string"?String(B.value):"",I=typeof window<"u"?window.prompt(E??"Enter link URL",H):null;if(!I)return;c(g,{href:I});return}c(g);return}let k=r.captureEffectiveSelectionHandle({includeText:!0});if(!k)return;try{if(g==="link-set"){let B=l("link-set"),H=typeof B?.value=="string"?String(B.value):"",I=typeof window<"u"?window.prompt(E??"Enter link URL",H):null;if(!I)return;r.setLinkFromHandle(k,I);return}r.clearLinkFromHandle(k)}finally{r.releaseSelectionHandle(k)}return}c(g)}let d=u.selection?.formatting??null,v=u.selection==null,y=v?"":an(l),w=mt.some(g=>g.value===d?.fontFamily)?mt:[...mt,...d?.fontFamily?[{value:d.fontFamily,label:d.fontFamily}]:[]],f=d?.fontSize!=null?String(d.fontSize):"",x=ln(d?.fontSize??null),b=d?.color?.toLowerCase()??"",R=d?.highlight?.toLowerCase()??"";return W("div",{className:"grid gap-3",role:"toolbar","aria-label":"Editor formatting toolbar",children:[a?P("div",{className:"flex flex-wrap gap-2",children:a}):null,W("div",{className:Ie("flex flex-wrap items-center gap-1 rounded-[var(--ald-control-group-radius,20px)] border border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-toolbar-bg,#f8fafc)] px-2 py-1.5"),children:[P(U,{pressed:!1,disabled:l("undo")?.disabled,title:"Undo (Ctrl+Z)",ariaLabel:"Undo",onClick:()=>o("undo"),children:W("svg",{viewBox:"0 0 16 16",className:"h-4 w-4","aria-hidden":"true",children:[P("path",{d:"M6.5 3 3 6.5 6.5 10",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"}),P("path",{d:"M3 6.5h6a4 4 0 0 1 0 8H6",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]})}),P(U,{pressed:!1,disabled:l("redo")?.disabled,title:"Redo (Ctrl+Y)",ariaLabel:"Redo",onClick:()=>o("redo"),children:W("svg",{viewBox:"0 0 16 16",className:"h-4 w-4","aria-hidden":"true",children:[P("path",{d:"M9.5 3 13 6.5 9.5 10",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"}),P("path",{d:"M13 6.5H7a4 4 0 0 0 0 8h3",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]})}),P(_,{}),P(ge,{ariaLabel:"Paragraph style",title:"Paragraph style",value:y,disabled:v,widthClass:"w-32",options:[{value:"",label:"Style"},...rr.map(g=>({value:g.command,label:g.label}))],onChange:g=>{g&&o(g)}}),p?W(Me,{children:[P(ge,{ariaLabel:"Font family",title:"Font family",value:d?.mixed?.fontFamily?"":d?.fontFamily??"",disabled:v,widthClass:"w-36",options:d?.mixed?.fontFamily?[{value:"",label:"Multiple fonts"},...w.slice(1)]:w,onChange:g=>c("font-family",g||null)}),P(ge,{ariaLabel:"Font size",title:"Font size (points)",value:d?.mixed?.fontSize?"":f,disabled:v,widthClass:"w-20",options:d?.mixed?.fontSize?["",...x].map(g=>({value:g,label:g||"Multiple"})):[{value:"",label:"Size"},...x.map(g=>({value:g,label:g}))],onChange:g=>c("font-size",g?Number(g):null)})]}):null,P(_,{}),P(U,{pressed:l("bold")?.mixed?"mixed":l("bold")?.active,disabled:l("bold")?.disabled,title:"Bold (Ctrl+B)",ariaLabel:"Bold",onClick:()=>o("bold"),children:P("span",{className:"font-bold",children:"B"})}),P(U,{pressed:l("italic")?.mixed?"mixed":l("italic")?.active,disabled:l("italic")?.disabled,title:"Italic (Ctrl+I)",ariaLabel:"Italic",onClick:()=>o("italic"),children:P("span",{className:"font-serif italic",children:"I"})}),P(U,{pressed:l("underline")?.mixed?"mixed":l("underline")?.active,disabled:l("underline")?.disabled,title:"Underline (Ctrl+U)",ariaLabel:"Underline",onClick:()=>o("underline"),children:P("span",{className:"underline",children:"U"})}),P(U,{pressed:l("strikethrough")?.mixed?"mixed":l("strikethrough")?.active,disabled:l("strikethrough")?.disabled,title:"Strikethrough",ariaLabel:"Strikethrough",onClick:()=>o("strikethrough"),children:P("span",{className:"line-through",children:"S"})}),p?W(Me,{children:[P(_,{}),P(ge,{ariaLabel:"Text color",title:"Text color",value:d?.mixed?.color?"":b,disabled:v,widthClass:"w-32",options:ft.some(g=>g.value===b)?ft:[{value:b,label:b,swatch:b},...ft],onChange:g=>c("text-color",g?g.toLowerCase():null)}),P(ge,{ariaLabel:"Highlight color",title:"Highlight color",value:d?.mixed?.highlight?"":R,disabled:v,widthClass:"w-36",options:gt.some(g=>g.value===R)?gt:[{value:R,label:R,swatch:R},...gt],onChange:g=>c("highlight-color",g?g.toLowerCase():null)})]}):null,P(_,{}),W(U,{pressed:l("link-set")?.active,disabled:l("link-set")?.disabled,title:"Insert or edit a link",ariaLabel:"Insert link",onClick:()=>o("link-set","Enter a URL or #bookmark target"),children:[W("svg",{viewBox:"0 0 16 16",className:"h-4 w-4","aria-hidden":"true",children:[P("path",{d:"M6 10a3 3 0 0 1 0-4.2l1.8-1.8a3 3 0 0 1 4.2 4.2l-.9.9",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),P("path",{d:"M10 6a3 3 0 0 1 0 4.2l-1.8 1.8a3 3 0 0 1-4.2-4.2l.9-.9",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]}),"Link"]}),P(U,{pressed:!1,disabled:l("link-clear")?.disabled,title:"Remove link",ariaLabel:"Remove link",onClick:()=>o("link-clear"),children:"Unlink"}),i?W(Me,{children:[P(_,{}),P(U,{pressed:u.trackingEnabled,title:"Toggle tracked changes",ariaLabel:"Track changes",onClick:()=>o("tracking-toggle"),children:"Tracking"}),s?W(Me,{children:[W(U,{pressed:!1,disabled:l("track-changes-accept-selection")?.disabled,title:"Accept tracked change in selection",ariaLabel:"Accept tracked change in selection",onClick:()=>o("track-changes-accept-selection"),children:[P("span",{className:"text-emerald-600",children:"\u2713"})," Accept"]}),W(U,{pressed:!1,disabled:l("track-changes-reject-selection")?.disabled,title:"Reject tracked change in selection",ariaLabel:"Reject tracked change in selection",onClick:()=>o("track-changes-reject-selection"),children:[P("span",{className:"text-rose-600",children:"\u2715"})," Reject"]})]}):null]}):null]}),n?P("div",{className:"flex flex-wrap gap-2",children:n}):null]})}import{useEffect as sn,useRef as dn}from"react";import{jsx as Ae,jsxs as cn}from"react/jsx-runtime";function un(e){return e==="success"?"text-emerald-700 hover:bg-emerald-50":e==="danger"?"text-rose-700 hover:bg-rose-50":"text-[var(--ald-toolbar-text,#334155)] hover:bg-[var(--ald-toolbar-hover-bg,#f8fafc)]"}function bt({state:e}){let t=dn(null),r=e.context.host.overlays.closeContextMenu;return sn(()=>{let a=i=>{t.current?.contains(i.target)||r?.()},n=i=>{i.key==="Escape"&&r?.()};return window.addEventListener("mousedown",a),window.addEventListener("keydown",n),()=>{window.removeEventListener("mousedown",a),window.removeEventListener("keydown",n)}},[r]),Ae("div",{ref:t,className:"fixed z-50 min-w-[240px] rounded-[var(--ald-radius,28px)] border border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-surface,#ffffff)] p-2 shadow-2xl",style:{left:e.context.position.left,top:e.context.position.top},children:Ae("div",{className:"grid gap-2",children:e.sections.map(a=>cn("section",{className:"grid gap-1 border-b border-[var(--ald-border,#e2e8f0)] pb-2 last:border-b-0 last:pb-0",children:[a.label?Ae("h3",{className:"px-2 text-[11px] font-semibold uppercase tracking-[0.14em] text-[var(--ald-text-muted,#64748b)]",children:a.label}):null,a.items.map(n=>Ae("button",{type:"button",disabled:!n.enabled,title:n.disabledReason??void 0,className:`rounded-2xl px-3 py-2 text-left text-sm transition disabled:cursor-not-allowed disabled:opacity-45 ${un(n.tone)}`,onClick:()=>{n.enabled&&(n.action(e.context),r?.())},children:n.label},n.id))]},a.id))})})}import{useEffect as or,useRef as pn}from"react";import{jsx as ae,jsxs as wt}from"react/jsx-runtime";function mn(e){if(!(typeof window>"u")){if(e.isAnchorLink){window.location.hash=e.href.slice(1);return}window.open(e.href,"_blank","noopener,noreferrer")}}async function fn(e){typeof navigator>"u"||!navigator.clipboard?.writeText||await navigator.clipboard.writeText(e)}function xt({state:e}){let t=pn(null),r=e.host.activeLink,a=e.host.overlays.closeLinkPopover;return or(()=>{let n=s=>{t.current?.contains(s.target)||a?.()},i=s=>{s.key==="Escape"&&a?.()};return window.addEventListener("mousedown",n),window.addEventListener("keydown",i),()=>{window.removeEventListener("mousedown",n),window.removeEventListener("keydown",i)}},[a]),or(()=>{if(e.resolution.type!=="external"||!t.current)return;let n=e.resolution.render({container:t.current,closePopover:()=>a?.(),controller:r,href:e.href,title:e.title})??{};return()=>{n.destroy?.()}},[a,r,e]),e.resolution.type==="external"?ae("div",{ref:t,className:"fixed z-50 min-w-[240px] rounded-[var(--ald-radius,28px)] border border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-surface,#ffffff)] p-3 shadow-2xl",style:{left:e.position.left,top:e.position.top}}):ae("div",{ref:t,className:"fixed z-50 min-w-[260px] rounded-[var(--ald-radius,28px)] border border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-surface,#ffffff)] p-4 shadow-2xl",style:{left:e.position.left,top:e.position.top},children:wt("div",{className:"grid gap-3",children:[wt("div",{className:"grid gap-1",children:[ae("span",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-[var(--ald-text-muted,#64748b)]",children:"Link"}),ae("code",{className:"break-all text-sm text-[var(--ald-text,#1e293b)]",children:e.href})]}),wt("div",{className:"flex flex-wrap gap-2",children:[ae("button",{type:"button",className:"rounded-[var(--ald-control-radius,9999px)] border border-[var(--ald-border,#e2e8f0)] px-3 py-1.5 text-xs font-semibold text-[var(--ald-toolbar-text,#334155)]",onClick:()=>mn(e),children:"Open"}),ae("button",{type:"button",className:"rounded-[var(--ald-control-radius,9999px)] border border-[var(--ald-border,#e2e8f0)] px-3 py-1.5 text-xs font-semibold text-[var(--ald-toolbar-text,#334155)]",onClick:()=>fn(e.href),children:"Copy"}),ae("button",{type:"button",className:"rounded-[var(--ald-control-radius,9999px)] border border-sky-200 bg-sky-50 px-3 py-1.5 text-xs font-semibold text-sky-700",onClick:()=>{let n=typeof window<"u"?window.prompt("Edit link URL",e.href):null;n&&r.updateActiveLink(n,e.title)},children:"Edit"}),ae("button",{type:"button",className:"rounded-[var(--ald-control-radius,9999px)] border border-rose-200 bg-rose-50 px-3 py-1.5 text-xs font-semibold text-rose-700",onClick:()=>r.clearActiveLink(),children:"Remove"})]})]})})}import{jsx as Y,jsxs as gn}from"react/jsx-runtime";function Pt({controller:e}){let t=N(e);if(!e||!t)return null;let{documentMode:r,trackChanges:a}=t,n=r==="viewing",i=a.enabled;return gn("div",{className:"flex flex-wrap items-center gap-1 rounded-[var(--ald-control-group-radius,20px)] border border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-toolbar-bg,#f8fafc)] px-2 py-1.5",children:[Y("span",{className:"px-1 text-[10px] font-bold uppercase tracking-[0.12em] text-[var(--ald-text-muted,#64748b)]",children:"Mode"}),Y(T,{active:r==="editing",label:"Edit",onClick:()=>e.setDocumentMode("editing")}),Y(T,{active:r==="suggesting",disabled:!i,label:"Suggest",onClick:()=>e.setDocumentMode("suggesting")}),Y(T,{active:n,label:"View",onClick:()=>e.setDocumentMode("viewing")}),Y(_,{}),Y("span",{className:"px-1 text-[10px] font-bold uppercase tracking-[0.12em] text-[var(--ald-text-muted,#64748b)]",children:"Markup"}),Y(T,{active:a.mode==="review",label:"Review",onClick:()=>e.setTrackChangesDisplayMode("review")}),Y(T,{active:a.mode==="original",disabled:!n,label:"Original",onClick:()=>e.setTrackChangesDisplayMode("original")}),Y(T,{active:a.mode==="final",disabled:!n,label:"Final",onClick:()=>e.setTrackChangesDisplayMode("final")}),Y(T,{active:a.mode==="off",label:"Hide",onClick:()=>e.setTrackChangesDisplayMode("off")})]})}import{resolveBrowserViewIntentPatch as ye,resolveBrowserViewIntentSnapshot as vn,resolveBrowserViewLayoutMode as bn,resolveBrowserViewZoomMode as wn,resolveBrowserZoomStep as ar}from"@datalking/begonia-browser-sdk/editor";function nr(e){return e==="web"?"Sets the paginated layout that will be restored when you switch back to paged view.":void 0}import{jsx as D,jsxs as ir}from"react/jsx-runtime";var Se=Object.freeze([50,75,100,125,150,200]);function ht({controller:e}){let t=N(e);if(!e||!t?.zoom)return null;let r=vn(t),{flowMode:a}=r,n=bn(r),i=nr(a),s=t.zoom.percent,p=t.zoom.mode,m=t.zoom.viewportMetrics?.fitZoom??null;return ir("div",{className:"flex flex-wrap items-center gap-1 rounded-[var(--ald-control-group-radius,20px)] border border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-toolbar-bg,#f8fafc)] px-2 py-1.5",children:[D("span",{className:"px-1 text-[10px] font-bold uppercase tracking-[0.12em] text-[var(--ald-text-muted,#64748b)]",children:"View"}),D(T,{active:a==="web",label:"Web",onClick:()=>e.setViewState(ye(r,{type:"flow",flowMode:"web"}))}),D(T,{active:a==="paginated",label:"Paged",onClick:()=>e.setViewState(ye(r,{type:"flow",flowMode:"paginated"}))}),D(_,{}),D("span",{className:"px-1 text-[10px] font-bold uppercase tracking-[0.12em] text-[var(--ald-text-muted,#64748b)]",children:"Layout"}),D(T,{active:n==="vertical",label:"Vertical",title:i,onClick:()=>e.setViewState(ye(r,{type:"layout",layoutMode:"vertical"}))}),D(T,{active:n==="horizontal",label:"Horizontal",title:i,onClick:()=>e.setViewState(ye(r,{type:"layout",layoutMode:"horizontal"}))}),D(T,{active:n==="book",label:"Book",title:i,onClick:()=>e.setViewState(ye(r,{type:"layout",layoutMode:"book"}))}),D(_,{}),D("span",{className:"px-1 text-[10px] font-bold uppercase tracking-[0.12em] text-[var(--ald-text-muted,#64748b)]",children:"Zoom"}),D(T,{active:p==="fit-width",label:m==null?"Fit":`Fit ${Math.round(m)}%`,onClick:()=>e.setZoomMode(wn({zoomMode:p})),title:m==null?"Fit to the measured preview width once the paginated preview is ready.":void 0}),D(T,{active:!1,disabled:s<=(Se[0]??s),label:"\u2212",onClick:()=>e.setViewState({zoomPercent:ar(s,Se,-1)})}),ir("span",{className:"min-w-11 text-center text-xs font-semibold text-[var(--ald-toolbar-text,#334155)]",children:[Math.round(s),"%"]}),D(T,{active:p==="manual"&&s===100,label:"100%",onClick:()=>e.setViewState({zoomPercent:100})}),D(T,{active:!1,disabled:s>=(Se[Se.length-1]??s),label:"+",onClick:()=>e.setViewState({zoomPercent:ar(s,Se,1)})})]})}import{jsx as X,jsxs as J}from"react/jsx-runtime";function lr(...e){return e.filter(Boolean).join(" ")}function xn(e){return e==="insert"?"Insert":e==="delete"?"Delete":"Format"}function sr(e){return!!(e.relatedKinds?.includes("insert")&&e.relatedKinds?.includes("delete"))}function yt({revisions:e,permissionsByRevisionId:t,activeRevisionId:r=null,onAcceptRevision:a,onRejectRevision:n,onRevealRevision:i,onAcceptAll:s,onRejectAll:p}){let m=e.every(c=>t?.[c.id]?.accept.allowed??!0),u=e.every(c=>t?.[c.id]?.reject.allowed??!0);return J("aside",{className:"grid gap-3","aria-label":"Review panel",children:[J("header",{className:"flex items-end justify-between gap-3",children:[J("div",{children:[X("h2",{className:"text-sm font-semibold text-[var(--ald-text,#0f172a)]",children:"Review"}),J("p",{className:"text-xs text-[var(--ald-text-muted,#64748b)]",children:[e.length," pending revision",e.length===1?"":"s"]})]}),e.length>0?J("div",{className:"flex gap-2",children:[X("button",{type:"button",disabled:!m,className:"rounded-full border border-emerald-200 bg-emerald-50 px-3 py-1.5 text-xs font-semibold text-emerald-700 disabled:cursor-not-allowed disabled:opacity-45",onClick:s,children:"Accept all"}),X("button",{type:"button",disabled:!u,className:"rounded-full border border-rose-200 bg-rose-50 px-3 py-1.5 text-xs font-semibold text-rose-700 disabled:cursor-not-allowed disabled:opacity-45",onClick:p,children:"Reject all"})]}):null]}),J("div",{className:"grid gap-3",children:[e.length===0?X("div",{className:"rounded-[var(--ald-radius,28px)] border border-dashed border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-surface-muted,#f8fafc)] px-4 py-6 text-sm text-[var(--ald-text-muted,#64748b)]",children:"No pending revisions."}):null,e.map(c=>{let l=t?.[c.id],o=r===c.id;return J("section",{className:lr("grid gap-3 rounded-3xl border px-4 py-4 shadow-sm transition",o?"border-[var(--ald-accent,#5eead4)] bg-[var(--ald-accent-muted,#f0fdfa)]":"border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-surface,#ffffff)]"),children:[J("div",{className:"flex items-center justify-between gap-3",children:[X("span",{className:lr("rounded-full px-2 py-1 text-[11px] font-semibold",sr(c)?"bg-amber-100 text-amber-700":c.kind==="insert"?"bg-emerald-100 text-emerald-700":c.kind==="delete"?"bg-rose-100 text-rose-700":"bg-sky-100 text-sky-700"),children:sr(c)?"Replace":xn(c.kind)}),X("span",{className:"text-[11px] text-[var(--ald-text-muted,#94a3b8)]",children:c.authorName||c.authorId})]}),X("p",{className:"text-sm text-[var(--ald-text,#334155)]",children:c.text||"Formatting change"}),c.prompt?J("p",{className:"text-[11px] text-[var(--ald-text-muted,#94a3b8)]",children:["Prompt: ",c.prompt]}):null,J("div",{className:"flex gap-2",children:[i?X("button",{type:"button",className:"rounded-[var(--ald-control-radius,9999px)] border border-[var(--ald-border,#e2e8f0)] px-3 py-1.5 text-xs font-semibold text-[var(--ald-toolbar-text,#334155)]",onClick:()=>i(c),children:"Reveal"}):null,X("button",{type:"button",disabled:l?!l.accept.allowed:!1,title:l?.accept.reason??void 0,className:"rounded-full border border-emerald-200 bg-emerald-50 px-3 py-1.5 text-xs font-semibold text-emerald-700 disabled:cursor-not-allowed disabled:opacity-45",onClick:()=>a?.(c.id),children:"Accept"}),X("button",{type:"button",disabled:l?!l.reject.allowed:!1,title:l?.reject.reason??void 0,className:"rounded-full border border-rose-200 bg-rose-50 px-3 py-1.5 text-xs font-semibold text-rose-700 disabled:cursor-not-allowed disabled:opacity-45",onClick:()=>n?.(c.id),children:"Reject"})]})]},c.id)})]})]})}import{jsx as V,jsxs as C}from"react/jsx-runtime";function ie(...e){return e.filter(Boolean).join(" ")}function Pn(e){return e==="insert"?"bg-emerald-100 text-emerald-700":e==="delete"?"bg-rose-100 text-rose-700":"bg-sky-100 text-sky-700"}function hn(e){return e==="insert"?"Insert":e==="delete"?"Delete":"Format"}function dr(e){return e.relatedKinds.includes("insert")&&e.relatedKinds.includes("delete")}function yn(e){return e.relatedKinds.includes("insert")&&e.relatedKinds.includes("delete")}function St(e,t){return e.relatedKinds.includes(t)||e.revision.kind===t}function kt(e){if(!e)return"Unknown time";let t=Date.parse(e);return Number.isNaN(t)?e:new Date(t).toLocaleString()}function Sn(e){return e.kind==="comment-thread"?"Comment":e.kind==="comment-reply"?"Reply":e.kind==="comment-status"?"Status":e.kind==="comment-visibility"?"Visibility":e.kind==="comment-removal"?"Removal":"Edit"}function kn(e){return e.kind==="comment-status"?"bg-sky-100 text-sky-700":e.kind==="comment-visibility"?"bg-cyan-100 text-cyan-700":e.kind==="comment-removal"?"bg-rose-100 text-rose-700":e.kind==="comment-edit"?"bg-violet-100 text-violet-700":e.kind==="comment-reply"?"bg-slate-100 text-slate-700":"bg-amber-100 text-amber-700"}function Rn(e){return e.deleted?"Deleted":e.resolved?"Resolved":"Open"}function Tn(e){return e.kind==="comment-status"?e.status==="resolved"?"Resolved":e.status==="open"?"Reopened":"Status":e.kind==="comment-visibility"?e.internalAfter?"Made Internal":"Made External":e.kind==="comment-removal"?e.activityKind==="thread-removed"?"Thread Removed":"Reply Removed":e.kind==="comment-edit"?e.parentEntryId==null?"Thread Edited":"Reply Edited":e.kind==="comment-reply"?"Reply Added":"Thread Created"}function Cn(e){return e.kind==="comment-status"?`${e.resolvedBefore?"Resolved":"Open"} -> ${e.resolvedAfter?"Resolved":"Open"}`:e.kind==="comment-visibility"?`${e.internalBefore?"Internal":"External"} -> ${e.internalAfter?"Internal":"External"}`:e.kind==="comment-removal"||e.kind==="comment-edit"||e.kind==="comment-reply"?`${e.entryCountBefore} -> ${e.entryCountAfter} message${e.entryCountAfter===1?"":"s"}`:`${e.entryCount} message${e.entryCount===1?"":"s"}`}function Rt({timeline:e,summary:t=null,activeCommentId:r=null,activeRevisionId:a=null,onSelectComment:n,onReplyComment:i,onResolveComment:s,onReopenComment:p,onAcceptRevision:m,onRejectRevision:u,onRevealRevision:c}){let l=t??{total:e.length,revisions:e.filter(o=>o.kind==="revision").length,insertions:e.filter(o=>o.kind==="revision"&&St(o,"insert")).length,deletions:e.filter(o=>o.kind==="revision"&&St(o,"delete")).length,formatting:e.filter(o=>o.kind==="revision"&&St(o,"format")).length,commentThreads:e.filter(o=>o.kind==="comment-thread").length,openCommentThreads:e.filter(o=>o.kind==="comment-thread"&&!o.resolved&&!o.deleted).length,resolvedCommentThreads:e.filter(o=>o.kind==="comment-thread"&&o.resolved&&!o.deleted).length,deletedCommentThreads:e.filter(o=>o.kind==="comment-thread"&&o.deleted).length,commentReplies:e.filter(o=>o.kind==="comment-reply").length,commentEdits:e.filter(o=>o.kind==="comment-edit").length,commentStatusChanges:e.filter(o=>o.kind==="comment-status").length,commentVisibilityChanges:e.filter(o=>o.kind==="comment-visibility").length,commentRemovals:e.filter(o=>o.kind==="comment-removal").length};return C("aside",{className:"grid gap-3","aria-label":"Review timeline panel",children:[V("header",{className:"grid gap-1",children:C("div",{className:"flex items-end justify-between gap-3",children:[C("div",{children:[V("h2",{className:"text-sm font-semibold text-[var(--ald-text,#0f172a)]",children:"Review Timeline"}),C("p",{className:"text-xs text-[var(--ald-text-muted,#64748b)]",children:[l.total," review item",l.total===1?"":"s"]})]}),C("div",{className:"flex flex-wrap justify-end gap-2 text-[11px] text-[var(--ald-text-muted,#64748b)]",children:[C("span",{children:[l.revisions," revision",l.revisions===1?"":"s"]}),C("span",{children:[l.openCommentThreads," open thread",l.openCommentThreads===1?"":"s"]}),C("span",{children:[l.commentReplies," repl",l.commentReplies===1?"y":"ies"]})]})]})}),C("div",{className:"grid gap-3",children:[e.length===0?V("div",{className:"rounded-[var(--ald-radius,28px)] border border-dashed border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-surface-muted,#f8fafc)] px-4 py-6 text-sm text-[var(--ald-text-muted,#64748b)]",children:"No review activity yet."}):null,e.map(o=>{if(o.kind==="revision"){let w=o.permissions,f=a===o.revisionId;return C("section",{className:ie("grid gap-3 rounded-3xl border px-4 py-4 shadow-sm transition",f?"border-[var(--ald-accent,#5eead4)] bg-[var(--ald-accent-muted,#f0fdfa)]":"border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-surface,#ffffff)]"),children:[C("div",{className:"flex items-center justify-between gap-3",children:[V("span",{className:ie("rounded-full px-2 py-1 text-[11px] font-semibold",dr(o)?"bg-amber-100 text-amber-700":Pn(o.revision.kind)),children:dr(o)?"Replace":hn(o.revision.kind)}),V("span",{className:"text-[11px] text-[var(--ald-text-muted,#94a3b8)]",children:o.authorName??o.authorId??"Unknown"})]}),V("p",{className:"text-sm text-[var(--ald-text,#334155)]",children:o.text||"Formatting change"}),o.excerpt?C("p",{className:"text-[11px] text-[var(--ald-text-muted,#64748b)]",children:["Target: ",o.excerpt]}):null,o.revision.prompt?C("p",{className:"text-[11px] text-[var(--ald-text-muted,#94a3b8)]",children:["Prompt: ",o.revision.prompt]}):null,V("p",{className:"text-[11px] text-[var(--ald-text-muted,#94a3b8)]",children:kt(o.sortAt)}),C("div",{className:"flex gap-2",children:[c?V("button",{type:"button",className:"rounded-[var(--ald-control-radius,9999px)] border border-[var(--ald-border,#e2e8f0)] px-3 py-1.5 text-xs font-semibold text-[var(--ald-toolbar-text,#334155)]",onClick:()=>c(o),children:"Reveal"}):null,V("button",{type:"button",disabled:w?!w.accept.allowed:!1,title:w?.accept.reason??void 0,className:"rounded-full border border-emerald-200 bg-emerald-50 px-3 py-1.5 text-xs font-semibold text-emerald-700 disabled:cursor-not-allowed disabled:opacity-45",onClick:()=>m?.(o.revisionId),children:"Accept"}),V("button",{type:"button",disabled:w?!w.reject.allowed:!1,title:w?.reject.reason??void 0,className:"rounded-full border border-rose-200 bg-rose-50 px-3 py-1.5 text-xs font-semibold text-rose-700 disabled:cursor-not-allowed disabled:opacity-45",onClick:()=>u?.(o.revisionId),children:"Reject"})]})]},o.id)}if(o.kind==="revision-decision"){let w=o.decision==="accept",f=yn(o),x=a===o.revisionId,b=f?`${w?"Accepted":"Rejected"} Replace`:o.relatedKinds.includes("format")?`${w?"Accepted":"Rejected"} Format`:`${w?"Accepted":"Rejected"} ${o.revisionKind==="delete"?"Delete":"Insert"}`;return C("section",{className:ie("grid gap-3 rounded-3xl border px-4 py-4 shadow-sm transition",x?"border-[var(--ald-accent,#5eead4)] bg-[var(--ald-accent-muted,#f0fdfa)]":"border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-surface,#ffffff)]"),children:[C("div",{className:"flex items-center justify-between gap-3",children:[V("span",{className:ie("rounded-full px-2 py-1 text-[11px] font-semibold",w?"bg-emerald-100 text-emerald-700":"bg-rose-100 text-rose-700"),children:b}),V("span",{className:"text-[11px] text-[var(--ald-text-muted,#94a3b8)]",children:o.authorName??o.authorId??"Unknown"})]}),V("p",{className:"text-sm text-[var(--ald-text,#334155)]",children:o.text}),o.excerpt?C("p",{className:"text-[11px] text-[var(--ald-text-muted,#64748b)]",children:["Target: ",o.excerpt]}):null,C("p",{className:"text-[11px] text-[var(--ald-text-muted,#94a3b8)]",children:[kt(o.sortAt)," \xB7 ",o.memberCount," member",o.memberCount===1?"":"s"]}),c?V("div",{className:"flex gap-2",children:V("button",{type:"button",className:"rounded-[var(--ald-control-radius,9999px)] border border-[var(--ald-border,#e2e8f0)] px-3 py-1.5 text-xs font-semibold text-[var(--ald-toolbar-text,#334155)]",onClick:()=>c(o),children:"Reveal"})}):null]},o.id)}let d=o.threadPermissions,v=r===o.commentId,y=!o.deleted;return C("section",{className:ie("grid gap-3 rounded-3xl border px-4 py-4 shadow-sm transition",v?"border-[var(--ald-accent,#5eead4)] bg-[var(--ald-accent-muted,#f0fdfa)]":"border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-surface,#ffffff)]"),children:[C("button",{type:"button",className:"grid gap-1 text-left",onClick:()=>n?.(o.commentId),children:[C("div",{className:"flex items-center justify-between gap-3",children:[C("div",{className:"flex items-center gap-2",children:[V("span",{className:ie("rounded-full px-2 py-1 text-[11px] font-semibold",kn(o)),children:Sn(o)}),V("span",{className:ie("rounded-full px-2 py-1 text-[11px] font-semibold",o.deleted?"bg-rose-100 text-rose-700":o.resolved?"bg-emerald-100 text-emerald-700":"bg-amber-100 text-amber-700"),children:Rn(o)}),V("span",{className:ie("rounded-full px-2 py-1 text-[11px] font-semibold",o.internal?"bg-slate-200 text-slate-700":"bg-sky-100 text-sky-700"),children:o.internal?"Internal":"External"})]}),V("span",{className:"text-[11px] text-[var(--ald-text-muted,#94a3b8)]",children:o.authorName??o.authorId??"Unknown"})]}),V("p",{className:"text-sm text-[var(--ald-text,#334155)]",children:o.text||"Empty comment"}),o.target?.text?C("p",{className:"text-[11px] text-[var(--ald-text-muted,#64748b)]",children:["Target: ",o.target.text]}):null,C("p",{className:"text-[11px] text-[var(--ald-text-muted,#94a3b8)]",children:[kt(o.sortAt)," \xB7 ",Tn(o)," \xB7"," ",Cn(o)]})]}),C("div",{className:"flex flex-wrap gap-2",children:[V("button",{type:"button",disabled:!y||(d?!d.reply.allowed:!1),title:d?.reply.reason??void 0,className:"rounded-[var(--ald-control-radius,9999px)] border border-[var(--ald-border,#e2e8f0)] px-3 py-1.5 text-xs font-semibold text-[var(--ald-toolbar-text,#334155)] disabled:cursor-not-allowed disabled:opacity-45",onClick:()=>i?.(o.commentId),children:"Reply"}),o.deleted?null:o.resolved?V("button",{type:"button",disabled:d?!d.reopen.allowed:!1,title:d?.reopen.reason??void 0,className:"rounded-[var(--ald-control-radius,9999px)] border border-[var(--ald-border,#e2e8f0)] px-3 py-1.5 text-xs font-semibold text-[var(--ald-toolbar-text,#334155)] disabled:cursor-not-allowed disabled:opacity-45",onClick:()=>p?.(o.commentId),children:"Reopen"}):V("button",{type:"button",disabled:d?!d.resolve.allowed:!1,title:d?.resolve.reason??void 0,className:"rounded-[var(--ald-control-radius,9999px)] border border-[var(--ald-border,#e2e8f0)] px-3 py-1.5 text-xs font-semibold text-[var(--ald-toolbar-text,#334155)] disabled:cursor-not-allowed disabled:opacity-45",onClick:()=>s?.(o.commentId),children:"Resolve"})]})]},o.id)})]})]})}import{Fragment as Mn,jsx as O,jsxs as ke}from"react/jsx-runtime";function Vn(...e){return e.filter(Boolean).join(" ")}var ur={linkPopover:null,contextMenu:null};function Ln(e){return En(t=>e?.overlayState.subscribe(t)??(()=>{}),()=>e?.overlayState.getSnapshot()??ur,()=>ur)}function Bn(e){return e?e===!0?{enabled:!0,projection:void 0}:{...e,enabled:e.enabled??!0}:null}function In(e){return e?e.editable?e.comments.enabled?e.comments.readOnly?"Comments are read-only in the current document mode.":e.selection?null:"Place the caret in text or select text before creating a comment.":"Comments are not enabled for the current editor session.":"Document is read-only in the current document mode.":"Editor is not ready."}function Nn({backend:e,backendInput:t,onEditorChange:r,onSnapshotChange:a,paginatedPreview:n,showToolbar:i=!0,showRichFormatControls:s=!0,showViewControls:p=!0,showReviewControls:m=!0,showComments:u=!0,showCommentDisplayControls:c=!0,showReview:l=!0,showReviewTimeline:o=!0,sidebarStart:d=null,theme:v,className:y}){let{hostRef:w,ui:f,snapshot:x}=st({backend:e,backendInput:t,onEditorChange:r,onSnapshotChange:a}),b=Ln(f),R=f?.preview.readLayoutAdapter()??null,g=f?.preview.readLayoutSource()??null,E=Bn(n),k=E?.enabled??!1,B=!!d||o||u||l,H=E?.projection??null,{enabled:I,...Q}=E??{},oe=x?.comments.activeCommentId??null,z=S=>{let ee=typeof window<"u"?window.prompt("Reply to comment"):null;!ee||!f||f.comments.reply(S,ee)},M=In(x),G=M==null,le=S=>{f&&f.comments.reveal(S)},Re=()=>{if(!f||!G)return;let S=typeof window<"u"?window.prompt("New comment"):null;if(!S)return;let ee=f.comments.create(S)},ve=S=>{f&&f.trackChanges.reveal(S)},be=de(v,{fontFamily:'var(--ald-font-ui, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif)'});return ke("div",{className:Vn("grid gap-4",y),"data-begonia-theme":be["data-begonia-theme"],style:be.style,children:[i?O(vt,{editorHost:f?.session??null,controller:f,showRichFormatControls:s,trailingActions:ke(Mn,{children:[p?O(ht,{controller:f?.view??null}):null,m?O(Pt,{controller:f?.documentMode??null}):null]})}):null,ke("div",{className:k?B?"grid gap-4 xl:grid-cols-[minmax(0,1fr)_minmax(320px,0.9fr)_320px]":"grid gap-4 xl:grid-cols-[minmax(0,1fr)_minmax(320px,0.9fr)]":B?"grid gap-4 lg:grid-cols-[minmax(0,1fr)_320px]":"grid gap-4",children:[O("div",{className:"rounded-[var(--ald-radius,28px)] border border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-surface,#ffffff)] p-4 shadow-[var(--ald-shadow,0_1px_3px_0_rgba(0,0,0,0.1),0_1px_2px_-1px_rgba(0,0,0,0.1))]",children:O("div",{className:"editor-frame",children:O("div",{ref:w,className:"editor-host"})})}),k?O("div",{className:"rounded-[var(--ald-radius,28px)] border border-[var(--ald-border,#e2e8f0)] bg-[var(--ald-surface,#ffffff)] p-4 shadow-[var(--ald-shadow,0_1px_3px_0_rgba(0,0,0,0.1),0_1px_2px_-1px_rgba(0,0,0,0.1))]",children:O(tr,{...Q,theme:Q.theme??v,editor:f,adapter:H?void 0:R??void 0,source:g})}):null,B?ke("div",{className:"grid gap-4",children:[d,o?O(Rt,{timeline:x?.review.timeline??[],summary:x?.review.summary??null,activeCommentId:oe,activeRevisionId:x?.review.activeRevisionId??null,onSelectComment:le,onReplyComment:z,onResolveComment:S=>f?.comments.resolve(S),onReopenComment:S=>f?.comments.reopen(S),onAcceptRevision:S=>f?.reviewActions.acceptRevision(S),onRejectRevision:S=>f?.reviewActions.rejectRevision(S),onRevealRevision:ve}):null,u?ke("div",{className:"grid gap-3",children:[c?O(ct,{controller:f?.commentsDisplay??null}):null,O(pt,{comments:x?.comments.items??[],permissionsByCommentId:x?.comments.permissions??{},activeCommentId:oe,canCreateComment:G,createCommentDisabledReason:M,onCreateComment:f?Re:void 0,onSelectComment:le,onToggleCommentInternal:(S,ee)=>f?.comments.setInternal(S,ee),onReplyComment:z,onResolveComment:S=>f?.comments.resolve(S),onReopenComment:S=>f?.comments.reopen(S)})]}):null,l?O(yt,{revisions:x?.review.revisions??[],permissionsByRevisionId:x?.review.permissions??{},activeRevisionId:x?.review.activeRevisionId??null,onAcceptRevision:S=>f?.reviewActions.acceptRevision(S),onRejectRevision:S=>f?.reviewActions.rejectRevision(S),onAcceptAll:()=>f?.reviewActions.acceptAll(),onRejectAll:()=>f?.reviewActions.rejectAll(),onRevealRevision:ve}):null]}):null]}),b.linkPopover?O(xt,{state:b.linkPopover}):null,b.contextMenu?O(bt,{state:b.contextMenu}):null]})}import{createPdfViewerController as fs}from"@datalking/begonia-pdf-viewer";export{de as a,N as b,He as c,Lt as d,_e as e,Rr as f,Fe as g,Tr as h,je as i,Cr as j,$e as k,Ue as l,We as m,ze as n,Ge as o,rt as p,nt as q,lt as r,st as s,Jt as t,dt as u,Bo as v,Io as w,No as x,Mo as y,Ao as z,Do as A,Oo as B,Ho as C,_o as D,Fo as E,jo as F,$o as G,Uo as H,Wo as I,zo as J,tr as K,T as L,ct as M,pt as N,vt as O,bt as P,xt as Q,Pt as R,ht as S,yt as T,Rt as U,Nn as V,fs as W};
|