@docx-editor.dev/pro 2.31.0 → 2.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/README.md +24 -0
  2. package/dist/chunk-3WTOHPAB.js +1 -0
  3. package/dist/chunk-AVZO5ZHZ.js +1 -0
  4. package/dist/chunk-GAGYRL3L.js +5 -0
  5. package/dist/chunk-HMSOWKXT.js +1 -0
  6. package/dist/chunk-I6HVINA4.cjs +1 -0
  7. package/dist/chunk-MHB6ID2P.cjs +1 -0
  8. package/dist/chunk-PMS3PGOE.cjs +1 -0
  9. package/dist/chunk-YOWEY5F3.cjs +5 -0
  10. package/dist/collaboration/hocuspocus.cjs +1 -1
  11. package/dist/collaboration/hocuspocus.d.cts +3 -3
  12. package/dist/collaboration/hocuspocus.d.ts +3 -3
  13. package/dist/collaboration/hocuspocus.js +1 -1
  14. package/dist/collaboration/index.cjs +2 -2
  15. package/dist/collaboration/index.d.cts +63 -7
  16. package/dist/collaboration/index.d.ts +63 -7
  17. package/dist/collaboration/index.js +2 -2
  18. package/dist/collaboration/webrtc.cjs +1 -1
  19. package/dist/collaboration/webrtc.d.cts +3 -3
  20. package/dist/collaboration/webrtc.d.ts +3 -3
  21. package/dist/collaboration/webrtc.js +1 -1
  22. package/dist/{document-session-_v9vqiSX.d.cts → document-session-B-MlORjE.d.cts} +105 -9
  23. package/dist/{document-session-Bxs4_GgX.d.ts → document-session-B-iH-YCU.d.ts} +105 -9
  24. package/dist/document-session-B35ZX2W4.js +1 -0
  25. package/dist/document-session-V3O7XBJY.cjs +1 -0
  26. package/dist/{document-session-options-DelOC7PX.d.ts → document-session-options-CdOH-TNn.d.ts} +1 -1
  27. package/dist/{document-session-options-CfKypp9c.d.cts → document-session-options-CxR0F5xT.d.cts} +1 -1
  28. package/dist/index.cjs +1 -1
  29. package/dist/index.js +1 -1
  30. package/dist/react/hocuspocus.d.cts +2 -2
  31. package/dist/react/hocuspocus.d.ts +2 -2
  32. package/dist/react/index.cjs +2 -2
  33. package/dist/react/index.d.cts +95 -12
  34. package/dist/react/index.d.ts +95 -12
  35. package/dist/react/index.js +2 -2
  36. package/dist/react/webrtc.d.cts +2 -2
  37. package/dist/react/webrtc.d.ts +2 -2
  38. package/dist/{types-BQ1vBt5Q.d.ts → types-DvGpDOcZ.d.cts} +9 -1
  39. package/dist/{types-BQ1vBt5Q.d.cts → types-DvGpDOcZ.d.ts} +9 -1
  40. package/dist/{types-6EmrEn4n.d.cts → types-bt2k1VO0.d.cts} +9 -1
  41. package/dist/{types-6EmrEn4n.d.ts → types-bt2k1VO0.d.ts} +9 -1
  42. package/dist/vue/hocuspocus.d.cts +2 -2
  43. package/dist/vue/hocuspocus.d.ts +2 -2
  44. package/dist/vue/index.cjs +2 -2
  45. package/dist/vue/index.d.cts +89 -13
  46. package/dist/vue/index.d.ts +89 -13
  47. package/dist/vue/index.js +2 -2
  48. package/dist/vue/webrtc.d.cts +2 -2
  49. package/dist/vue/webrtc.d.ts +2 -2
  50. package/docs/accept-reject-without-scrolling.md +95 -0
  51. package/docs/comment-on-found-text.md +72 -0
  52. package/docs/custom-review-cards.md +178 -0
  53. package/docs/highlight-ranges.md +48 -0
  54. package/docs/index.md +36 -0
  55. package/docs/propose-rewrite.md +247 -0
  56. package/docs/tracked-replacement.md +68 -0
  57. package/package.json +5 -4
  58. package/dist/chunk-32WEH2XH.cjs +0 -1
  59. package/dist/chunk-FD2KDBHX.cjs +0 -1
  60. package/dist/chunk-L567WP3J.js +0 -5
  61. package/dist/chunk-MJECUVHQ.cjs +0 -5
  62. package/dist/chunk-Q5JTCGJI.js +0 -1
  63. package/dist/chunk-SNQCYZLT.js +0 -1
  64. package/dist/chunk-UOAEJRVX.js +0 -1
  65. package/dist/chunk-ZSAAX6HV.cjs +0 -1
  66. package/dist/document-session-3VC43WNI.cjs +0 -1
  67. package/dist/document-session-J2YKWERI.js +0 -1
@@ -37,11 +37,11 @@ import { EditDiagnosticCode, ReviewItemPlacement, ReviewActivationOptions, Revie
37
37
  export { ReviewActivationOptions, ReviewItemRevealEvent, ReviewItemRevealSource, ScrollPlacement } from '@docx-editor.dev/core/contracts/editor';
38
38
  import { CollaborationParticipant, CollaborationRemoteSelection, CollaborationStatus, CollaborationFailure } from '@docx-editor.dev/core/collaboration';
39
39
  export { CollaborationFailure, CollaborationFailureCode, CollaborationIdentity, CollaborationParticipant, CollaborationRemoteSelection, CollaborationRemoteSelectionAddress, CollaborationSelectionKind, CollaborationStatus, CollaborationStatusSnapshot } from '@docx-editor.dev/core/collaboration';
40
- import { C as CollaborationSession } from '../types-BQ1vBt5Q.js';
41
- export { a as CollaborationBootstrap, b as CollaborationIdentityUpdate } from '../types-BQ1vBt5Q.js';
40
+ import { C as CollaborationSession } from '../types-DvGpDOcZ.js';
41
+ export { a as CollaborationBootstrap, b as CollaborationIdentityUpdate } from '../types-DvGpDOcZ.js';
42
42
  import { EditorModule } from '@docx-editor.dev/core/editor';
43
43
  export { CommentMarkerStyle, ResolvedReviewPane, ReviewPaneOpening, ReviewPaneOptions, ReviewPaneOverflow, RevisionDisplay } from '@docx-editor.dev/core/editor';
44
- import { C as CreateDocumentCollaborationOptions } from '../document-session-options-DelOC7PX.js';
44
+ import { C as CreateDocumentCollaborationOptions } from '../document-session-options-CdOH-TNn.js';
45
45
  import '@docx-editor.dev/core/store';
46
46
  import 'yjs';
47
47
  import 'y-protocols/awareness';
@@ -141,7 +141,10 @@ interface UseReviewReturn {
141
141
  * useEditorEvent('reviewItemReveal', ({ key, source }) => openMyCard(key, source));
142
142
  * setActive(key); // fires nothing
143
143
  * setActive(key, { announce: true }); // fires 'reviewItemReveal'
144
+ * setActive(key, { reveal: false }); // opens the item without scrolling
144
145
  * ```
146
+ *
147
+ * @see {@link https://www.docx-editor.dev/docs/2.x/recipes/accept-reject-without-scrolling | Accept or reject without scrolling}
145
148
  */
146
149
  readonly setActive: (key: string | null, options?: ReviewActivationOptions) => boolean;
147
150
  /**
@@ -150,9 +153,17 @@ interface UseReviewReturn {
150
153
  * False for an item whose `readOnly` is true, and equally for a resolution the engine
151
154
  * refuses on other grounds — a document open for viewing refuses every one. A caller
152
155
  * that assumed success drew a live button that did nothing.
156
+ *
157
+ * For headless or server use, see `Revision.accept()` in `@docx-editor.dev/editor-api`.
158
+ *
159
+ * @see {@link https://www.docx-editor.dev/docs/2.x/recipes/accept-reject-without-scrolling | Accept or reject without scrolling}
153
160
  */
154
161
  readonly accept: (item: ReviewItemView) => boolean;
155
- /** Reject a revision. Reports whether it landed, on the same terms as {@link accept}. */
162
+ /**
163
+ * Reject a revision. Reports whether it landed, on the same terms as {@link accept}.
164
+ *
165
+ * For headless or server use, see `Revision.reject()` in `@docx-editor.dev/editor-api`.
166
+ */
156
167
  readonly reject: (item: ReviewItemView) => boolean;
157
168
  /**
158
169
  * Adopt tracked changes as the reviewer's own: they record the reviewer as their author
@@ -192,6 +203,8 @@ interface UseReviewReturn {
192
203
  * neither rather than writing an empty attribute — which is why this REPORTS whether the
193
204
  * reply landed. A box that cleared itself on a refusal would throw the text away and show
194
205
  * nothing, and the writer would not learn their reply never existed.
206
+ *
207
+ * For headless or server use, see `Comment.reply` in `@docx-editor.dev/editor-api`.
195
208
  */
196
209
  readonly reply: (item: ReviewItemView, text: string, author?: string) => boolean;
197
210
  /**
@@ -200,7 +213,21 @@ interface UseReviewReturn {
200
213
  * From the engine, not from the DOM — the same rule the card anchors follow.
201
214
  */
202
215
  readonly selectionAnchorY: number | null;
203
- /** Comment on the current selection. Reports whether it landed, like {@link reply}. */
216
+ /**
217
+ * Comment on the current selection. Reports whether it landed, like {@link reply}.
218
+ *
219
+ * To comment on found text, select it first with `editor.findMatches` and
220
+ * `editor.selectMatch`. For headless or server use, see `Range.insertComment` in
221
+ * `@docx-editor.dev/editor-api`.
222
+ *
223
+ * @example
224
+ * ```tsx
225
+ * const [match] = editor.findMatches('Effective Date', { wholeWord: true });
226
+ * if (match && editor.selectMatch(match).ok) comment('Define this term.');
227
+ * ```
228
+ *
229
+ * @see {@link https://www.docx-editor.dev/docs/2.x/recipes/comment-on-found-text | Comment on found text}
230
+ */
204
231
  readonly comment: (text: string, author?: string) => boolean;
205
232
  /**
206
233
  * Why the last accept, reject, resolve, reopen, remove, reply or comment did not land, or null.
@@ -231,6 +258,11 @@ interface UseReviewReturn {
231
258
  *
232
259
  * Subscribes to the editor's own change stream, so the list re-derives when the document does
233
260
  * and not on every render.
261
+ *
262
+ * This is the browser review API: comment, reply, accept, reject, and open items from your own
263
+ * UI. For headless, server, or agent pipelines, use `@docx-editor.dev/editor-api` instead.
264
+ *
265
+ * @see {@link https://www.docx-editor.dev/docs/2.x/recipes | Which API for which job}
234
266
  */
235
267
  declare function useReview(query?: ReviewItemQuery): UseReviewReturn;
236
268
  /** The same hook against an explicit editor, for hosts that hold their own. */
@@ -258,10 +290,14 @@ declare function useReviewOf(editor: Editor | null, query?: ReviewItemQuery): Us
258
290
  *
259
291
  * Returns each card's top in layout points. `useReviewRailMetrics` supplies `scale` and the
260
292
  * pixel offset of the first page: a card's CSS `top` is `metrics.top + position * metrics.scale`.
293
+ *
294
+ * @see {@link https://www.docx-editor.dev/docs/2.x/recipes/custom-review-cards | Custom cards in the review rail}
261
295
  */
262
296
  declare function useStackedReviewPositions(items: readonly {
263
297
  readonly key: string;
264
298
  readonly anchorY: number | null;
299
+ /** Keep this entry at its own anchor; the entries before it move up. */
300
+ readonly isActive?: boolean;
265
301
  }[], heights: ReadonlyMap<string, number>, options?: {
266
302
  readonly gap?: number;
267
303
  readonly scale?: number;
@@ -383,6 +419,26 @@ interface ReviewMarkersProps {
383
419
  icon?: ReactNode | ((item: ReviewItemView) => ReactNode);
384
420
  }
385
421
 
422
+ /**
423
+ * Props of `DocxEditorReview.Draft`.
424
+ *
425
+ * @public
426
+ */
427
+ interface ReviewDraftProps extends ReviewPartProps {
428
+ /**
429
+ * Rail-local `top` in CSS pixels. Omit it to use the packaged card stack's position. Pass
430
+ * your own when you render your own cards, so the box stacks with them.
431
+ */
432
+ top?: number;
433
+ /**
434
+ * Rail-local `left` for the COMPACT rail, where the strip is 32px wide and a box laid
435
+ * out at column width would be cut by the viewport's edge. Omit it to use the compact
436
+ * card's position in the compact rail and the rail's own column otherwise. Null keeps the
437
+ * box in the rail's own column.
438
+ */
439
+ left?: number | null;
440
+ }
441
+
386
442
  declare const ReviewResolve: {
387
443
  ({ className, asChild, hidden, children, icon: glyph }: ReviewActionProps): react.JSX.Element | null;
388
444
  docxReviewPart: "Resolve";
@@ -392,10 +448,7 @@ declare const ReviewReopen: {
392
448
  docxReviewPart: "Reopen";
393
449
  };
394
450
  declare const ReviewDraft: {
395
- ({ top, left, className, hidden, }: ReviewPartProps & {
396
- top?: number;
397
- left?: number | null;
398
- }): react.JSX.Element | null;
451
+ (props: ReviewDraftProps): react.JSX.Element | null;
399
452
  docxReviewPart: "Draft";
400
453
  };
401
454
  declare const ReviewReply: {
@@ -743,6 +796,7 @@ interface UseReviewRailMetricsOptions {
743
796
  * }
744
797
  * ```
745
798
  *
799
+ * @see {@link https://www.docx-editor.dev/docs/2.x/recipes/custom-review-cards | Custom cards in the review rail}
746
800
  * @public
747
801
  */
748
802
  declare function useReviewRailMetrics(railRef?: RefObject<HTMLElement | null> | null, options?: UseReviewRailMetricsOptions): ReviewRailMetrics;
@@ -783,9 +837,15 @@ interface DocxEditorReviewNamespace {
783
837
  readonly Reply: typeof ReviewReply;
784
838
  /** The collapsed rail: one marker per item, shown when the pane is closed. */
785
839
  readonly Markers: typeof ReviewMarkers;
786
- /** The "comment on this" button beside a selected range. */
840
+ /**
841
+ * The "comment on this" button beside a selected range. A root part: put it as a direct
842
+ * child of `DocxEditorReview` so the rail positions it.
843
+ */
787
844
  readonly AddComment: typeof ReviewAddComment;
788
- /** The compose box a new comment is written in. */
845
+ /**
846
+ * The compose box a new comment is written in. It renders only while a draft is open. Pass
847
+ * `top` when you render your own cards; without it, the box uses the packaged card stack.
848
+ */
789
849
  readonly Draft: typeof ReviewDraft;
790
850
  /**
791
851
  * The decision balloon opened by clicking a tracked change in the page: format and
@@ -801,6 +861,29 @@ interface DocxEditorReviewNamespace {
801
861
  * via `createDocxEditor({ modules: [reviewModule()] })` — without it there is nothing to derive
802
862
  * cards from.
803
863
  *
864
+ * PARTS AND SCOPES. The rail reads its parts from its own children, by element type. There are
865
+ * two scopes:
866
+ *
867
+ * - Root parts: `List`, `Markers`, `AddComment`, `Draft`, and `Balloon`. Put them as DIRECT
868
+ * children of `DocxEditorReview` (fragments are transparent). The rail gives them the geometry
869
+ * only it can compute: the comment button's and the compose box's `top`, and the markers'
870
+ * scale and window. A root part inside a wrapper component is not seen as a part. It renders
871
+ * as ordinary content, without that wiring.
872
+ * - Card parts: `Card`, `Empty`, and the parts inside a card (`Author`, `Summary`, `Accept`,
873
+ * `Reject`, `Reply`, and the others). Put them inside `DocxEditorReview.List`, or as other
874
+ * direct children, which become the card template.
875
+ *
876
+ * `preset={false}` drops the packaged defaults. Root parts you pass still get their wiring, and
877
+ * every other child renders as is inside the rail, where `useReviewRailMetrics()` reads the
878
+ * rail's own measurement. To render your own cards, use `useReview().items`,
879
+ * `useStackedReviewPositions`, and `useReviewRailMetrics`. `Draft` without `top` sits where the
880
+ * packaged card stack puts it, so pass `top` from your own stack.
881
+ *
882
+ * In a browser host, this rail and `useReview()` are the way to build a review UI. For headless,
883
+ * server, or agent pipelines, use `@docx-editor.dev/editor-api`.
884
+ *
885
+ * @see {@link https://www.docx-editor.dev/docs/2.x/recipes/custom-review-cards | Custom cards in the review rail}
886
+ *
804
887
  * @example
805
888
  * ```tsx
806
889
  * <DocxEditorReview>
@@ -1360,4 +1443,4 @@ interface UseDocumentCollaborationReturn {
1360
1443
  declare function useDocumentCollaboration(options?: UseDocumentCollaborationOptions): UseDocumentCollaborationReturn;
1361
1444
 
1362
1445
  export { CollaborationSession, CreateDocumentCollaborationOptions, CustomNodeChrome, CustomNodeContextMenu, DocxEditorCollaboration, DocxEditorCollaborationRoot, DocxEditorReview, activatedCustomNodeOf, resolveCustomNodeActivation, useCollaborationParticipants, useCollaborationSession, useCollaborationStatus, useCustomNodeDefinitions, useDocumentCollaboration, useReview, useReviewAuthor, useReviewItem, useReviewOf, useReviewRailMetrics, useStackedReviewPositions };
1363
- export type { CollaborationAvatarProps, CollaborationAvatarRenderProps, CollaborationAvatarsProps, CollaborationCaretLabelRenderProps, CollaborationCaretLabelsProps, CollaborationNoticeKind, CollaborationRootSource, CollaborationStatusNoticeProps, CollaborationStatusNoticeRenderProps, CustomNodeChromeProps, CustomNodeContextMenuProps, DocxEditorCollaborationNamespace, DocxEditorCollaborationRootProps, DocxEditorReviewNamespace, ResolvedCustomNodeActivation, ReviewActionProps, ReviewAdoptOptions, ReviewBalloonProps, ReviewItemView, ReviewMarkersProps, ReviewPartProps, ReviewProps, ReviewRailMetrics, ReviewWriteAction, ReviewWriteRefusal, UseCollaborationStatusReturn, UseDocumentCollaborationConnectOptions, UseDocumentCollaborationOptions, UseDocumentCollaborationReturn, UseReviewRailMetricsOptions, UseReviewReturn };
1446
+ export type { CollaborationAvatarProps, CollaborationAvatarRenderProps, CollaborationAvatarsProps, CollaborationCaretLabelRenderProps, CollaborationCaretLabelsProps, CollaborationNoticeKind, CollaborationRootSource, CollaborationStatusNoticeProps, CollaborationStatusNoticeRenderProps, CustomNodeChromeProps, CustomNodeContextMenuProps, DocxEditorCollaborationNamespace, DocxEditorCollaborationRootProps, DocxEditorReviewNamespace, ResolvedCustomNodeActivation, ReviewActionProps, ReviewAdoptOptions, ReviewBalloonProps, ReviewDraftProps, ReviewItemView, ReviewMarkersProps, ReviewPartProps, ReviewProps, ReviewRailMetrics, ReviewWriteAction, ReviewWriteRefusal, UseCollaborationStatusReturn, UseDocumentCollaborationConnectOptions, UseDocumentCollaborationOptions, UseDocumentCollaborationReturn, UseReviewRailMetricsOptions, UseReviewReturn };
@@ -1,2 +1,2 @@
1
- import {b as b$1,a as a$1}from'../chunk-MWO2ZUEJ.js';import {c,o,i,b,l,a,e,d,m,p,q,n,h,k,j as j$1,g,f,x,w,s,t,r,v,u}from'../chunk-UOAEJRVX.js';import {j as j$2,e as e$1,c as c$1,q as q$1,k as k$1}from'../chunk-Q5JTCGJI.js';export{o as reviewModule}from'../chunk-Q5JTCGJI.js';export{b as collaborationModule}from'../chunk-Q2VBO66F.js';import {createContext,useMemo,useEffect,useCallback,useRef,useContext,useSyncExternalStore,useState,isValidElement,cloneElement,useId,Children,Fragment as Fragment$1}from'react';import {reviewPaneListsItem,hostDocumentOf,hostWindowOf,isDomNode,isElementNode,isHTMLElementNode,partOfNodeId}from'@docx-editor.dev/core/editor';import {useDocxEditor,useEditorState,useTranslation,ReviewRailContext,useReviewGutter,REVIEW_PANE_GUTTER,useEditorEvent,useReviewAuthors,Slot,notificationYieldsToTask,useEditorHostDocument,useContextMenuTarget,ContextMenuItem,DocxEditorRoot}from'@docx-editor.dev/react';import {jsxs,Fragment,jsx}from'react/jsx-runtime';import {createPortal}from'react-dom';import {customNodePayloadsByControl}from'@docx-editor.dev/core/store';var kr=new Set(["List","Markers","AddComment","Draft","Balloon"]),Dr=new Set(["Card","Empty"]);function tt(e,t){let o=t==="root"?kr:Dr,n={},r=[],i=a=>{if(Array.isArray(a)){for(let l of a)i(l);return}if(!isValidElement(a)){a!=null&&a!==false&&r.push(a);return}if(a.type===Fragment$1){i(a.props.children);return}let s=a.type.docxReviewPart;s&&o.has(s)?n[s]=a:r.push(a);};return i(e),{parts:n,rest:r}}function xt(e,t){if(!t)return e;let o=e.props.className;return cloneElement(e,{className:`${t}${o?` ${o}`:""}`})}function ln(e,t){if(!isValidElement(t))return {template:e,fromList:false,hidden:false};let{children:o,hidden:n}=t.props;return {template:o===void 0?e:o,fromList:o!==void 0,hidden:n===true}}var Et=600;function At(e$1,t,o,n,r=false){let[i,a$1]=useState(a);return useEffect(()=>{let s=t.current;if(!(!e$1||!s))return e(s,e$1,l=>a$1(c=>d(c,l)?c:l),{trackScroll:r})},[e$1,t,o,n,r]),i}function dn(e,t,o){let[n,r]=useState(null);return useEffect(()=>{let i=t.current,a=i?.offsetParent;if(!a)return;let s=hostWindowOf(a),l=0,c=()=>({top:a.scrollTop-Et,bottom:a.scrollTop+a.clientHeight+Et}),d=null,u=()=>{l=0;let p=d??c();d=null,r(y=>y&&y.top===p.top&&y.bottom===p.bottom?y:p);},f=0,v=()=>{d=c(),l===0&&(l=s.requestAnimationFrame(u)),i?.setAttribute("data-scrolling",""),s.clearTimeout(f),f=s.setTimeout(()=>i?.removeAttribute("data-scrolling"),150);};u(),a.addEventListener("scroll",v,{passive:true});let m=new s.ResizeObserver(v);return m.observe(a),()=>{l!==0&&s.cancelAnimationFrame(l),s.clearTimeout(f),a.removeEventListener("scroll",v),m.disconnect();}},[e,t,o]),n}function fn(e){let t=useRef(new WeakMap),o=useRef(new Map),n=useRef(new Map),r=useCallback(a=>{let s=hostWindowOf(a),l=n.current.get(s);if(l)return l;if(typeof s.ResizeObserver>"u")return null;let c=new s.ResizeObserver(d=>{for(let u of d){let f=t.current.get(u.target);f&&e(f,u.target.offsetHeight);}});return n.current.set(s,c),c},[e]),i=useCallback((a,s)=>{let l=o.current.get(s);if(!a){l&&(n.current.get(hostWindowOf(l))?.unobserve(l),t.current.delete(l),o.current.delete(s));return}let c=r(a);c&&(e(s,a.offsetHeight),!(l===a&&t.current.get(a)===s)&&(l&&(n.current.get(hostWindowOf(l))?.unobserve(l),t.current.delete(l)),t.current.set(a,s),o.current.set(s,a),c.observe(a)));},[e,r]);return useEffect(()=>()=>{for(let a of n.current.values())a.disconnect();n.current.clear(),o.current.clear();},[]),i}var It=[],Nt=null;function Hr(e){if(typeof MessageChannel!="function"){globalThis.setTimeout(e,0);return}Nt||(Nt=new MessageChannel,Nt.port1.onmessage=()=>{let t=It;It=[];for(let o of t)try{o();}catch(n){queueMicrotask(()=>{throw n});}}),It.push(e),It.length===1&&Nt.port2.postMessage(null);}function $r(e){let t=false;return ()=>{if(!t){if(!notificationYieldsToTask()){e();return}t=true,Hr(()=>{t=false,e();});}}}function Vr(e){return `${e.getReviewRevision()}:${e.getEditingMode()}:${k(e)}`}function Pt(e){let t=useDocxEditor();return vn(t,e)}function vn(e,t){let o=useCallback(w=>{if(!e)return ()=>{};let A=false,k=$r(()=>{A||w();}),N=e.on("change",k),T=e.on("selectionChange",k),ee=e.on("error",k);return ()=>{A=true,N(),T(),ee();}},[e]),n$1=useSyncExternalStore(o,()=>e?Vr(e):"none",()=>"none"),r=useCallback(w=>e?n(e).subscribe(w):()=>{},[e]),i=useSyncExternalStore(r,()=>e?n(e).get():null,()=>null),a=useCallback((w,A,k)=>(e&&n(e).record(w,A,k),k.ok),[e]),s=useMemo(()=>e?e.getReviewItems(t).filter(w=>w.item.kind!=="custom"||w.item.carded):[],[e,n$1,t]),l=useMemo(()=>s.find(w=>w.isActive)?.key??null,[s]),c=useCallback(w=>{if(!e)return ()=>{};let A=e.on("selectionChange",w),k=e.on("change",w);return ()=>{A(),k();}},[e]),d=useSyncExternalStore(c,()=>e?e.getActivatedReviewItemKey(t):null,()=>null),u=useCallback((w,A)=>e?e.setActiveReviewItem(w,A).ok:false,[e]),f=useCallback(w=>!e||w.kind!=="revision"||w.readOnly?false:a("accept",w.key,e.acceptReviewItem(w.key)),[e,a]),v=useCallback(w=>!e||w.kind!=="revision"||w.readOnly?false:a("reject",w.key,e.rejectReviewItem(w.key)),[e,a]),m=useCallback((w,A)=>h(e,w,A),[e]),p=useCallback(w=>!e||w.kind!=="comment"?false:a("resolve",w.key,e.setCommentResolved(w.key,true)),[e,a]),y=useCallback(w=>!e||w.kind!=="comment"?false:a("reopen",w.key,e.setCommentResolved(w.key,false)),[e,a]),g=e?.getEditingMode()==="viewing"?"the document is open for viewing":null,E=useCallback(w=>!e||w.kind==="custom"||w.kind==="revision"&&w.readOnly?false:a("remove",w.key,e.deleteReviewItem(w.key)),[e,a]),$=useCallback((w,A,k)=>A.trim().length===0||!e?false:a("reply",w.key,e.replyToReviewItem(w.key,A,k)),[e,a]),K=useMemo(()=>e?e.getSelectionPlacement()?.anchorY??null:null,[e,n$1]),D=useCallback((w,A)=>w.trim().length===0||!e?false:a("comment",null,e.addComment(w,A)),[e,a]),I=useMemo(()=>e?e.isReviewPaneOpen():true,[e,n$1]),re=useCallback(w=>{!e||e.isReviewPaneOpen()===w||e.exec({type:"toggleReviewPane"});},[e]);return useMemo(()=>({items:s,activeKey:l,activatedKey:d,setActive:u,accept:f,reject:v,adopt:m,resolve:p,reopen:y,commentResolutionDisabledReason:g,remove:E,reply:$,selectionAnchorY:K,comment:D,lastRefusal:i,paneOpen:I,setPaneOpen:re,ready:e!==null&&!e.snapshot().isLoading&&e.snapshot().parseError===null}),[s,l,d,u,f,v,m,p,y,g,E,$,K,D,i,I,re,e])}function qr(e,t,o={}){let n=o.gap??8,r=o.scale??1,i=o.defaultHeight??0;return useMemo(()=>j$1(e,t,{gap:n,scale:r,defaultHeight:i}),[e,t,n,r,i])}var ro=8;function io(e,t){return e?.color??`var(--doc-review-author-${t%ro})`}function ce(e,t,o){return e?{"--doc-review-author-current":io(t,o)}:{}}function ge(e,t){return (e?.slot??t)%ro}function pn(e,t,o,n){let r=useRef(new Map);return useMemo(()=>{let i=new Map;for(let s of e)i.set(s.author,s);let a=[...t.map(s=>s.author),n?.getConfiguredAuthor()];for(let s of a){if(!s||i.has(s))continue;let l=o.get(s)??0,c=n?.getReviewAuthorStyle(s),d=c?.color??`var(--doc-review-author-${l%ro})`,u=r.current.get(s),f=u!==void 0&&u.slot===l&&u.color===d&&u.style===c?u:{author:s,slot:l,color:d,...c?{style:c}:{}};r.current.set(s,f),i.set(s,f);}return i},[e,t,o,n])}var F=e=>jsx("svg",{viewBox:"0 -960 960 960",width:16,height:16,"aria-hidden":"true",focusable:"false",children:jsx("path",{d:e,fill:"currentColor"})}),wn="M440-400h80v-120h120v-80H520v-120h-80v120H320v80h120v120ZM80-80v-720q0-33 23.5-56.5T160-880h640q33 0 56.5 23.5T880-800v480q0 33-23.5 56.5T800-240H240L80-80Zm126-240h594v-480H160v525l46-45Zm-46 0v-480 480Z",Rn="M240-400h480v-80H240v80Zm0-120h480v-80H240v80Zm0-120h480v-80H240v80ZM880-80 720-240H160q-33 0-56.5-23.5T80-320v-480q0-33 23.5-56.5T160-880h640q33 0 56.5 23.5T880-800v720ZM160-320h594l46 45v-525H160v480Zm0 0v-480 480Z",Fr="M880-80 720-240H160q-33 0-56.5-23.5T80-320v-480q0-33 23.5-56.5T160-880h640q33 0 56.5 23.5T880-800v720ZM160-320h594l46 45v-525H160v480Zm0 0v-480 480Z",Te="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z",St=()=>jsxs("span",{className:"docx-review__resolved-icon",children:[jsx("span",{className:"docx-review__resolved-comment",children:F(Fr)}),jsx("span",{className:"docx-review__resolved-tick",children:F(Te)})]}),yn="M120-160v-640l760 320-760 320Zm80-120 474-200-474-200v140l240 60-240 60v140Zm0 0v-400 400Z",_t=(e,t,o)=>jsxs("span",{className:"docx-review__badge","data-testid":"review-badge",...o?{"data-resolved":""}:{},"aria-hidden":"true",children:[o?F(Te):jsx("span",{className:"docx-review__badge-initials",children:e||"?"}),t>0?jsx("span",{className:"docx-review__badge-count","data-testid":"review-badge-count",children:t>9?"9+":t}):null]}),bn="M480-160q-134 0-227-93t-93-227q0-134 93-227t227-93q69 0 132 28.5T720-690v-110h80v280H520v-80h168q-32-56-87.5-88T480-720q-100 0-170 70t-70 170q0 100 70 170t170 70q77 0 139-44t87-116h84q-28 106-114 173t-196 67Z",gn="m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z",Cn="M280-120q-33 0-56.5-23.5T200-200v-520h-40v-80h200v-40h240v40h200v80h-40v520q0 33-23.5 56.5T680-120H280Zm400-600H280v520h400v-520ZM360-280h80v-360h-80v360Zm160 0h80v-360h-80v360ZM280-720v520-520Z",Yr="M200-200h57l391-391-57-57-391 391v57Zm-80 80v-170l528-527q12-11 26.5-17t30.5-6q16 0 31 6t26 18l55 56q12 11 17.5 26t5.5 30q0 16-5.5 30.5T817-647L290-120H120Zm640-584-56-56 56 56Zm-141 85-28-29 57 57-29-28Z",jr="M486-160q-76 0-135-45t-85-123l88-38q14 48 48.5 78t85.5 30q42 0 76-20t34-64q0-18-7-33t-19-27h112q5 14 7.5 28.5T694-341q0 86-61.5 133.5T486-160ZM80-520v-80h800v80H80Zm402-360q66 0 116 30t74 84l-88 38q-11-28-38.5-47T480-794q-42 0-72 19t-30 51q0 15 6 27t18 22H272q-6-13-9-27t-3-30q0-70 55-114t167-44Z",Zr="M360-160q-83 0-141.5-58.5T160-360v-360q0-83 58.5-141.5T360-920q83 0 141.5 58.5T560-720v360q0 83-58.5 141.5T360-160Zm0-80q50 0 85-35t35-85v-360q0-50-35-85t-85-35q-50 0-85 35t-35 85v360q0 50 35 85t85 35Zm300 80q29 0 49.5-20.5T730-230q0-22-12.5-40T684-296l-64-32v-232l100 100q23 23 51.5 35.5T832-412v-80q-17 0-32-6.5T773-517L633-657q-12-12-27.5-17.5T573-680h-13v520h100ZM360-720Z",Wr="M580-360q-25 0-42.5-17.5T520-420v-160q0-25 17.5-42.5T580-640h160q25 0 42.5 17.5T800-580v260q0 66-47 113t-113 47v-80q33 0 56.5-23.5T720-320v-40H580Zm-360 0q-25 0-42.5-17.5T160-420v-160q0-25 17.5-42.5T220-640h160q25 0 42.5 17.5T440-580v260q0 66-47 113t-113 47v-80q33 0 56.5-23.5T360-320v-40H220Z";function ao(e){if(e.kind==="comment")return Rn;if(e.kind==="custom")return e.item.icon??Wr;switch(e.revisionKind){case "insert":case "moveTo":return Yr;case "delete":case "moveFrom":return jr;case "format":return Zr;default:return Rn}}function Qr(e,t){return typeof t!="function"?e:typeof e!="function"?t:o=>{e(o),o.defaultPrevented||t(o);}}function Xr(e,t){let o={...e,...t};for(let n of Object.keys(e))/^on[A-Z]/.test(n)?o[n]=Qr(t[n],e[n]):n==="className"?o[n]=[e[n],t[n]].filter(Boolean).join(" "):n==="style"&&(o[n]={...e[n],...t[n]});return o}function An(e){return e==="Enter"||e===" "}function Jr(e){return An(e.key)?(e.preventDefault(),e.stopPropagation(),true):false}function En(e){return e.type==="button"}function ei(e,t){return e.type==="a"||t.href!=null}function ti(e,t,o,n){let r=i=>{typeof o=="function"&&o(i);};return {onClick:i=>{typeof e=="function"&&e(i),i.defaultPrevented||r(i),n&&i.preventDefault();},onKeyDown:i=>{if(typeof t=="function"&&t(i),!An(i.key))return;i.defaultPrevented||r(i),n&&i.preventDefault();}}}function Ce({engineDisabled:e,disabledReason:t,slotProps:o,children:n}){let r=Children.only(n);if(!isValidElement(r))return null;let i=r.props,a=Xr(o,i);if(!e){if(!En(r)){let s=ti(i.onClick,i.onKeyDown,o.onClick,ei(r,i));a.onClick=s.onClick,a.onKeyDown=s.onKeyDown;}return cloneElement(r,a)}if(En(r))a.disabled=true,delete a["aria-disabled"];else {delete a.disabled,a["aria-disabled"]=true,a["data-disabled"]="",a.tabIndex=-1,a.href=void 0,a.role===void 0&&(a.role="button");let s=a.onKeyDown;a.onKeyDown=l=>{Jr(l)||typeof s=="function"&&s(l);};}return t&&(a.title=t),a.onClick=s=>{s.preventDefault(),s.stopPropagation();},cloneElement(r,a)}var Pn=createContext({key:null,open:()=>{},close:()=>{}});function Sn({items:e,children:t}){let[o,n]=useState(null);useEffect(()=>{o!==null&&!e.some(i=>i.key===o&&i.kind==="comment"&&i.resolved)&&n(null);},[e,o]);let r=useMemo(()=>({key:o,open:i=>n(i),close:()=>n(null)}),[o]);return jsx(Pn.Provider,{value:r,children:t})}function so(){return useContext(Pn)}function _n({label:e,statusLabel:t,entryKey:o,badge:n=false,onActivate:r,onDeactivate:i,children:a,...s}){let l=so(),c=useRef(null);return useEffect(()=>{let d=f=>{let v=c.current;v?.open&&isDomNode(f.target)&&!v.contains(f.target)&&(l.close(),i());},u=hostDocumentOf(c.current);return u.addEventListener("pointerdown",d,true),()=>u.removeEventListener("pointerdown",d,true)},[l,i]),jsxs("details",{ref:c,...s,open:l.key===o,onToggle:d=>{d.currentTarget.open?(l.open(o),r()):(l.close(),i());},children:[jsxs("summary",{className:"docx-review__resolved-toggle","aria-label":e,children:[jsx("span",{className:"docx-review__resolved-status",children:t}),n?_t("",0,true):St()]}),a]})}function Mn(e){function t({className:n,asChild:r,hidden:i,children:a,icon:s}){let l=e.useReview(),c=e.useItem(),d=e.useLabel();if(i||!c||c.kind!=="comment"||c.resolved)return null;let u=d("comments.resolve"),f=l.commentResolutionDisabledReason!==null,v=f?d("editingMode.viewingHint"):null,m={type:"button",className:`docx-review__action${n?` ${n}`:""}`,"data-testid":"review-resolve","aria-label":u,title:v??u,disabled:f,onMouseDown:e.guardMousedown,onClick:p=>{p.stopPropagation(),!f&&l.resolve(c);}};return r?jsx(Ce,{engineDisabled:f,disabledReason:v,slotProps:m,children:a}):jsx("button",{...m,children:s??a??F(Te)})}t.docxReviewPart="Resolve";function o({className:n,asChild:r,hidden:i,children:a,icon:s}){let l=e.useReview(),c=e.useItem(),d=e.useLabel();if(i||!c||c.kind!=="comment"||!c.resolved)return null;let u=d("comments.reopen"),f=l.commentResolutionDisabledReason!==null,v=f?d("editingMode.viewingHint"):null,m={type:"button",className:`docx-review__action${n?` ${n}`:""}`,"data-testid":"review-reopen","aria-label":u,title:v??u,disabled:f,onMouseDown:e.guardMousedown,onClick:p=>{p.stopPropagation(),!f&&l.reopen(c);}};return r?jsx(Ce,{engineDisabled:f,disabledReason:v,slotProps:m,children:a}):jsx("button",{...m,children:s??a??F(bn)})}return o.docxReviewPart="Reopen",{ReviewResolve:t,ReviewReopen:o}}var lo=8;function Mt(e,t,o){let n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),i=e.closest(".docx-editor__scroll-container"),a=i?.getBoundingClientRect(),s=(a?.left??n.left)-n.left,l=i&&i.clientWidth>0?i.clientWidth:a?.width??0,c=e.ownerDocument.defaultView?.innerHeight??1/0,d=Number(e.dataset.reviewStart??e.dataset.start),u=Number(e.dataset.reviewEnd??e.dataset.end);return {revisionId:e.dataset.revisionId,...e.dataset.formattingKind?{formattingKind:e.dataset.formattingKind}:{},author:e.dataset.reviewAuthor??"",...e.dataset.revisionDate!==void 0?{date:e.dataset.revisionDate}:{},...e.dataset.revisionKind!==void 0?{kind:e.dataset.revisionKind}:{},structuralSite:o,...e.dataset.paragraphId!==void 0?{paragraphId:e.dataset.paragraphId}:{},...Number.isFinite(d)?{start:d}:{},...Number.isFinite(u)?{end:u}:{},left:r.left-n.left,right:r.right-n.left,top:r.top-n.top,bottom:r.bottom-n.top,above:r.bottom+220>c,rtl:e.ownerDocument.defaultView?.getComputedStyle(e).direction==="rtl",visibleLeft:s,visibleRight:l>0?s+l:Number.POSITIVE_INFINITY}}function kn(e,t){let o=e.visibleRight-e.visibleLeft-2*lo,n=Number.isFinite(o)&&o>0?Math.min(t,o):t,r=e.rtl?e.right-n:e.left,i=e.visibleLeft+lo,a=e.visibleRight-lo-n;return {left:Math.min(Math.max(r,i),Math.max(a,i)),width:n}}function ci(e,t,o){let n=null;for(let r of e.querySelectorAll("[data-revision-id]")){if(!isHTMLElementNode(r)||r.dataset.revisionId!==t.revisionId||r.closest("[data-docx-preview]")||(r.dataset.reviewAuthor??"")!==t.author||r.dataset.formattingKind!==t.formattingKind||r.classList.contains("docx-table-row--revision")!==t.structuralSite)continue;let i=Number(r.dataset.reviewStart??r.dataset.start);if(r.dataset.paragraphId===t.paragraphId&&i===t.start)return r;n??=r;}return n??(o?uo(e,o):null)}var ui=["left","right","top","bottom","above","rtl","visibleLeft","visibleRight"];function Dn(e,t,o,n){let r=ci(t,e,n);if(!r)return e;let i=Mt(r,o,e.structuralSite);return ui.every(a=>i[a]===e[a])?e:{...e,...i}}function Tn(e,t){let o=[];for(let n of e.querySelectorAll("[data-revision-id]"))!isHTMLElementNode(n)||n.dataset.revisionId!==t.revisionId||(n.dataset.reviewAuthor??"")===t.author&&n.dataset.formattingKind===t.formattingKind&&(t.date!==void 0&&n.dataset.revisionDate!==t.date||(n.dataset.reviewBalloonOpen="",o.push(n)));return ()=>{for(let n of o)delete n.dataset.reviewBalloonOpen;}}function kt(e,t="pane"){return e===void 0?false:t==="balloons"||e==="format"||e==="structural"}function On(e,t,o,n="pane",r=false){return e.kind!=="revision"||!kt(e.revisionKind,n)?false:n==="balloons"?r:!(o&&t.some(i=>i.id===e.id))}function di(e){return e.dataset.revisionKind!=="format"&&!e.classList.contains("docx-table-row--revision")}function uo(e,t){if(t.kind!=="revision"||t.item.kind!=="revision")return null;let o=t.item.addresses;if(o.length===0)return null;let n=new Set(o.map(i=>i.id)),r=t.item.formattingKind;for(let i of e.querySelectorAll("[data-revision-id]")){if(!isHTMLElementNode(i)||i.closest("[data-docx-preview]"))continue;let a=i.dataset.revisionId;if(!a||!n.has(a)||!o.some(c=>c.id===a&&c.author===(i.dataset.reviewAuthor??"")&&(c.date??"")===(i.dataset.revisionDate??"")))continue;let l=i.classList.contains("docx-table-row--revision");if(t.revisionKind==="structural"&&l||t.revisionKind==="format"&&i.dataset.revisionKind==="format"&&i.dataset.formattingKind===r||!kt(t.revisionKind)&&di(i))return i}return null}function Ln(e,t){let o=null,n=false,r=null,i=false,a=null,s=false;for(let l of t)if(!(l.kind!=="revision"||l.item.kind!=="revision")&&!(e.formattingKind&&l.item.formattingKind!==e.formattingKind)){for(let c of l.item.addresses)if(c.id===e.revisionId){if(c.author===e.author){if(c.date===e.date)return l;o===null?o=l:o!==l&&(n=true);}r===null?r=l:r!==l&&(i=true);}if(!(e.paragraphId===void 0||e.start===void 0||e.end===void 0||l.revisionKind!=="format"&&l.revisionKind!=="structural")){for(let c of l.item.ranges)if(c.start.paragraphId===e.paragraphId&&c.start.offset<e.end&&c.end.offset>e.start){a===null?a=l:a!==l&&(s=true);break}}}return o!==null&&!n?o:r!==null&&!i?r:a!==null&&!s?a:null}function Kn(e){return e.kind==="revision"&&e.item.kind==="revision"&&e.revisionKind==="format"&&e.item.ranges.length>0&&(e.item.formattingKind==="rPrChange"||e.item.formattingKind==="pPrChange")}var ot=createContext(null),L=createContext(null);function $n(){return useContext(L)}function Vn(e){let t=useContext(ot),o=useReviewAuthors();if(e!==void 0)return t?t.authorInfo.get(e):o.find(n=>n.author===e)}function Y(){let e=useContext(ot);return e||Ri}function pi(e,t){return t?e.replace(/\{(\w+)\}/g,(o,n)=>Object.hasOwn(t,n)?String(t[n]):o):e}function j(){let{t:e}=useContext(ot)??{},{t}=useTranslation();return useCallback((o,n)=>{let r=e?.(o);return r!==void 0?pi(r,n):t(o,n)},[e,t])}var Ri={t:void 0,cardClassName:void 0,readOnly:false,review:{items:[],activeKey:null,setActive:()=>false,accept:()=>false,reject:()=>false,adopt:()=>false,resolve:()=>false,reopen:()=>false,commentResolutionDisabledReason:null,remove:()=>false,reply:()=>false,selectionAnchorY:null,comment:()=>false,lastRefusal:null,activatedKey:null,paneOpen:true,setPaneOpen:()=>{},ready:false},allItems:[],authorSlots:new Map,authorInfo:new Map,draftAuthor:null,draftAuthorInfo:void 0,draftAuthorSlot:0,byId:new Map,measure:()=>{},beginDraft:()=>{},endDraft:()=>{},commentMarkers:"icon",revisionsIn:"pane"};var vo=createContext(null),xi=e=>`${e.zoom}|${e.isLoading}|${e.isOpening??false}`,Ei=e=>!e.isLoading&&!e.isOpening&&e.parseError===null,Ai=e=>e.reviewPaneOpen??true;function Un(e,t){let o=useContext(vo),n=useContext(ReviewRailContext),r=useDocxEditor(),i=useEditorState(xi),a$1=useEditorState(Ei),s=useEditorState(Ai),l=useReviewGutter(),c$1=e!=null,[d,u]=useState(null);useEffect(()=>{let g=e?.current??null;u(E=>E===g?E:g);});let f$1=useMemo(()=>({current:d}),[d]),v=c$1&&d!==null&&(t?.reserveGutter??true);useEffect(()=>v?n?.reserveGutter?.():void 0,[n,v]);let m=At(c$1?r:null,f$1,i,d!==null,t?.trackScroll??false);useEffect(()=>{if(!c$1){o||g("called without a railRef outside DocxEditorReview, so it returns the initial value. Pass a ref to your column element, or call it inside DocxEditorReview.");return}if(!d||!a$1)return;let g$1=f(d);g$1&&g(g$1);},[c$1,o,d,a$1]);let p=c(s,l.inlineEnd,REVIEW_PANE_GUTTER),y=useMemo(()=>({...m,compact:p}),[m,p]);return c$1?d?y:a:o??a}var Fn=e=>e.isLoading||e.parseError!==null||e.pageSetup==null,Yn=e=>e.reviewPane.opening,jn=e=>e.reviewPane.revisionsIn,Zn=e=>e.reviewPane.commentMarkers,Wn=e=>e.editingMode==="viewing",Le="\0compose";var zn=Object.freeze({placement:false,pairReplacements:false}),Gn=Object.freeze({placement:false,pairReplacements:true});function nt(e,t){return e.kind!=="comment"?false:e.parentId!==void 0?t.has(e.parentId):e.parentRevisionId!==void 0?t.has(e.parentRevisionId):false}function rt(e){return new Set(e.map(t=>t.id))}function oe(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function Tt(e){let t=e.trim().split(/\s+/).filter(Boolean);return t.length===0?"?":t.slice(0,2).map(o=>o[0].toUpperCase()).join("")}var Ot=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function tr(e){function t({top:a=0,left:s=null,className:l$1,hidden:c}){let{review:d,endDraft:u,measure:f,readOnly:v,draftAuthor:m,draftAuthorInfo:p,draftAuthorSlot:y}=e.useRail(),g=e.useLabel(),[E,$]=useState(""),[K,D]=useState(false),[I,re]=useState(void 0),w=useDocxEditor(),A=useRef(null),k=useId();useEffect(()=>{v||A.current?.focus({preventScroll:true});},[]);let N=useCallback(()=>{if(v||E.trim().length===0)return;let T=d.comment(E.trim());D(!T),re(T||!w?void 0:n(w).get()?.code),T&&($(""),u());},[v,E,d,u,w]);return useEffect(()=>{d.lastRefusal||I===void 0||(D(false),re(void 0));},[d.lastRefusal,I]),c?null:jsx("div",{className:`docx-review__slot${l$1?` ${l$1}`:""}${s===null?"":" docx-review__slot--compact"}`,style:{position:"absolute",top:a,...s===null?{}:{left:s,width:b}},ref:T=>{f(T,e.composeKey);},children:jsx("div",{className:"docx-review__card","data-testid":"review-draft","data-draft":"",...m?{"data-review-author":m,"data-review-author-slot":y}:{},style:ce(m??void 0,p,y),children:jsxs("form",{className:"docx-review__reply-box",onSubmit:T=>{T.preventDefault(),N();},children:[jsx("label",{className:"docx-editor-sr-only",htmlFor:k,children:g("comments.addComment")}),jsx("input",{id:k,ref:A,"data-testid":"review-draft-input",className:"docx-review__input",value:E,placeholder:g("comments.addComment"),readOnly:v,...K?{"aria-invalid":true}:{},onChange:T=>{v||(D(false),$(T.target.value));},onKeyDown:T=>{if(T.key==="Escape"){T.preventDefault(),u();return}v||T.key!=="Enter"||(T.preventDefault(),N());}}),jsxs("div",{className:"docx-review__reply-actions",children:[jsx("button",{type:"button","data-testid":"review-draft-cancel",className:"docx-review__text-button",onMouseDown:e.guardMousedown,onClick:u,children:g("common.cancel")}),jsx("button",{type:"submit","data-testid":"review-draft-submit",className:"docx-review__submit",disabled:v||E.trim().length===0,title:v?g("editingMode.viewingHint"):void 0,children:g("common.comment")})]}),K?jsx("span",{className:"docx-review__refused",children:g(l(I,"review.commentRefused"))}):null]})})})}t.docxReviewPart="Draft";function o(a){let{review:s,readOnly:l}=e.useRail(),[c,d]=useState(""),[u,f]=useState(false),[v,m]=useState(void 0),p=useDocxEditor(),y=useCallback(()=>{if(!a||l||c.trim().length===0)return;let g=s.reply(a,c.trim());f(!g),m(g||!p?void 0:n(p).get()?.code),g&&d("");},[a,l,c,s,p]);return useEffect(()=>{s.lastRefusal||v===void 0||(f(false),m(void 0));},[s.lastRefusal,v]),{draft:c,setDraft:d,refused:u,setRefused:f,refusedCode:v,submit:y}}function n$1({state:a,className:s,onCancel:l$1}){let{readOnly:c,draftAuthor:d,draftAuthorInfo:u,draftAuthorSlot:f}=e.useRail(),v=e.useLabel(),m=useId(),{draft:p,setDraft:y,refused:g,setRefused:E,submit:$}=a,K=l(a.refusedCode,"review.replyRefused"),D=u?.style?.avatarUrl;return jsxs("form",{className:`docx-review__reply-box${s?` ${s}`:""}`,"data-reply-line":"",onSubmit:I=>{I.preventDefault(),$();},children:[jsx("label",{className:"docx-editor-sr-only",htmlFor:m,children:v("comments.replyPlaceholder")}),d?jsx("span",{className:"docx-review__avatar docx-review__reply-avatar","data-testid":"review-reply-avatar","aria-hidden":"true",style:ce(d,u,f),children:D?jsx("img",{className:"docx-review__avatar-img",src:D,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer"}):Tt(d)}):null,jsx("input",{id:m,"data-testid":"review-reply-input",className:"docx-review__input",value:p,placeholder:v("comments.replyPlaceholder"),readOnly:c,...g?{"aria-invalid":true,"data-refused":""}:{},onChange:I=>{c||(E(false),y(I.target.value));},onClick:I=>I.stopPropagation(),onKeyDown:I=>{if(I.key==="Escape"&&!I.nativeEvent.isComposing){if(p.length>0){I.preventDefault(),y(""),E(false);return}if(l$1){I.preventDefault(),l$1();return}}c||I.key!=="Enter"||(I.preventDefault(),$());}}),p.length>0?jsx("button",{type:"button","data-testid":"review-reply-cancel",className:"docx-review__text-button",onMouseDown:e.guardMousedown,onClick:I=>{I.stopPropagation(),y(""),E(false),l$1?.();},children:v("common.cancel")}):null,jsx("button",{type:"submit","data-testid":"review-reply-submit",className:"docx-review__send","aria-label":v("review.reply"),disabled:c||p.trim().length===0,title:v(c?"editingMode.viewingHint":"review.reply"),children:F(yn)}),g?jsx("span",{className:"docx-review__refused","data-testid":"review-reply-refused",children:v(K)}):null]})}function r({className:a,hidden:s,children:l}){let{review:c}=e.useRail(),d=e.useItem(),u=o(d);return s||!d||!d.isActive||d.kind==="comment"&&d.resolved?null:l?jsx(Fragment,{children:l}):jsx(n$1,{state:u,className:a,onCancel:()=>c.setActive(null)})}r.docxReviewPart="Reply";function i({entry:a,orphaned:s=false,onDraft:l}){let c=e.useLabel(),d=o(s?null:a),u=d.draft.trim().length>0;return useEffect(()=>l?.(u),[u,l]),jsxs(Fragment,{children:[jsx(n$1,{state:d}),s?jsx("span",{className:"docx-review__refused",role:"alert","data-testid":"review-reply-orphaned",children:c("review.replyTargetResolved")}):null]})}return {ReviewDraft:t,ReviewReply:r,ReviewBalloonReply:i}}function po(e,t,o=1){if(e==="paragraphMark"){let n=o>1;return t==="delete"?n?"revisions.paragraphMarksDeleted":"revisions.paragraphMarkDeleted":t==="moveFrom"?n?"revisions.paragraphMarksMovedFrom":"revisions.paragraphMarkMovedFrom":t==="moveTo"?n?"revisions.paragraphMarksMovedTo":"revisions.paragraphMarkMovedTo":n?"revisions.paragraphMarksInserted":"revisions.paragraphMarkInserted"}switch(e){case "insert":return "review.inserted";case "delete":return "review.deleted";case "replace":return "review.replaced";case "moveFrom":return "review.movedFrom";case "moveTo":return "review.movedTo";case "format":return "revisions.runPropertiesChanged";default:return "review.structural"}}function Ni(e){return po(e.revisionKind,e.markDirection,e.ranges.length)}function Pi(e){return e.revisionKind==="paragraphMark"&&e.ranges.length>1?` (${e.ranges.length})`:""}function it(e,t){if(e.revisionKind==="structural"&&e.structuralChanges?.length)return e.structuralChanges.map(i=>t(`revisions.structuralDetails.${i}`)).join(", ");let o=`${t(Ni(e))}${Pi(e)}`;if(e.revisionKind!=="format")return o;let r=[...(e.formattingLanguages??[]).map(i=>{try{return new Intl.DisplayNames([t("_lang")],{type:"language"}).of(new Intl.Locale(i).minimize().toString())??i}catch{return i}}),...(e.formattingChanges??[]).map(i=>Si(i,t))];return r.length?`${o}: ${r.join(", ")}`:o}function Si(e,t){let{property:o,value:n}=e;if(n!==null&&(o==="bold"||o==="italic"||o==="strike"))return t(`revisions.formattingDetails.${n==="true"?o:{bold:"notBold",italic:"notItalic",strike:"notStrike"}[o]}`);let r=n??t("revisions.formattingDetails.default");return n!==null&&(["fontSize","leftIndent","rightIndent","firstLineIndent","hangingIndent","spaceBefore","spaceAfter"].includes(o)?r=`${n} ${t("revisions.formattingDetails.points")}`:(o==="direction"?n==="rtl"||n==="ltr":/^(left|center|right|both|start|end|none|single|double|auto)$/.test(n))?r=t(`revisions.formattingDetails.${n}`):o==="color"&&/^[0-9a-f]{6}$/i.test(n)&&(r=`#${n.toUpperCase()}`)),`${t(`revisions.formattingDetails.${o}`)}: ${r}`}var{ReviewResolve:wo,ReviewReopen:yo}=Mn({useReview:()=>Y().review,useItem:()=>useContext(L),useLabel:j,guardMousedown:oe}),{ReviewDraft:bo,ReviewReply:go,ReviewBalloonReply:nr}=tr({useRail:Y,useItem:()=>useContext(L),useLabel:j,guardMousedown:oe,composeKey:Le});function at({className:e,hidden:t,children:o}){let n=j();return t?null:jsx("div",{className:`docx-review__empty${e?` ${e}`:""}`,"data-testid":"review-empty",children:o??n("review.empty")})}at.docxReviewPart="Empty";function $e({className:e,asChild:t,hidden:o,children:n}){let{review:r,authorSlots:i,authorInfo:a,commentMarkers:s}=Y(),l=useContext(L),c=useId(),d=j();if(o||!l)return null;let u=i.get(l.author)??0,f=!t&&l.kind==="comment"&&l.resolved,v={className:`docx-review__card${e?` ${e}`:""}`,"data-testid":"review-card",...f?{}:{"aria-labelledby":`${c}-author ${c}-summary`},"data-kind":l.kind==="revision"?l.revisionKind??"revision":l.kind,...l.author?{"data-review-author":l.author,"data-review-author-slot":ge(a.get(l.author),u)}:{},...l.kind==="custom"&&l.item.kind==="custom"?{"data-node-name":l.item.name}:{},...l.isActive?{"data-active":""}:{},...l.kind==="comment"&&l.resolved?{"data-resolved":""}:{},...f?{"data-resolved-miniature":""}:{},style:ce(l.author,a.get(l.author),u),...f?{}:{tabIndex:0,role:"button"},id:c,...f?{}:{onMouseDown:m=>{q(m.target)||m.currentTarget.focus({preventScroll:true});},onClick:m=>{!p(m.target)&&!l.isActive&&r.setActive(l.key);},onKeyDown:m=>{m.target===m.currentTarget&&(m.key!=="Enter"&&m.key!==" "||(m.preventDefault(),r.setActive(l.key)));}}};return t?jsx(Slot,{...v,children:n}):f?jsx(_n,{...v,label:d("review.showResolvedComment"),statusLabel:d("review.resolved"),entryKey:l.key,badge:s==="initials",onActivate:()=>r.setActive(l.key),onDeactivate:()=>r.setActive(null),children:jsx(or,{children:n})}):jsx("div",{...v,children:jsx(or,{children:n})})}$e.docxReviewPart="Card";function or({children:e}){let t=useContext(L),o=useMemo(()=>Ti(e),[e]),n=(i,a)=>i in o?o[i]:a;if(!t)return null;if(t.kind==="custom"&&t.item.kind==="custom"){let i=t.item;return jsxs(Fragment,{children:[jsxs("div",{className:"docx-review__head",children:[n("Avatar",null),jsx("div",{className:"docx-review__meta",children:n("Author",jsx("span",{className:"docx-review__author","data-testid":"review-custom-title",children:i.title}))})]}),n("Summary",i.detail?jsx("div",{className:"docx-review__summary","data-testid":"review-summary","data-review-selectable":"",children:jsx("span",{className:"docx-review__text",children:i.detail})}):null),o.__extra]})}let r=t.kind==="revision"&&!t.readOnly;return jsxs(Fragment,{children:[jsxs("div",{className:"docx-review__head",children:[n("Avatar",jsx(he,{})),jsxs("div",{className:"docx-review__meta",children:[n("Author",jsx(xe,{})),n("Time",jsx(Ee,{}))]}),r||t.kind==="comment"?jsxs("div",{className:"docx-review__actions",children:[n("Accept",jsx(qe,{})),n("Reject",jsx(Be,{})),n("Resolve",jsx(wo,{})),n("Reopen",jsx(yo,{})),n("Delete",t.kind==="comment"?jsx(st,{}):null)]}):null]}),n("Summary",jsx(pe,{})),n("Refusal",jsx(Ve,{})),n("Replies",jsx(Ue,{})),n("Reply",jsx(go,{})),o.__extra]})}function Ti(e){let t={},o=[],n=r=>{if(Array.isArray(r)){r.forEach(n);return}if(!r||typeof r!="object"||!("type"in r)){r&&o.push(r);return}if(r.type===Fragment$1){n(r.props.children);return}let i=r.type.docxReviewPart;i?t[i]=r:o.push(r);};return n(e),o.length>0&&(t.__extra=o),t}function Ve({className:e,asChild:t,hidden:o,children:n}){let{review:r}=Y(),i=useContext(L),a=j(),s=r.lastRefusal;if(o||!i||!s||s.key!==i.key||s.action==="reply")return null;let l$1={className:`docx-review__refused${e?` ${e}`:""}`,"data-testid":"review-refusal","data-refusal-code":s.code};return t?jsx(Slot,{...l$1,children:n}):jsx("p",{...l$1,children:n??a(l(s.code,"review.actionRefused",s.final))})}Ve.docxReviewPart="Refusal";function Co(){let{review:e}=Y(),t=j(),o=e.lastRefusal;return jsx("span",{className:"docx-editor-sr-only","aria-live":"polite","data-testid":"review-refusal-live",children:o?jsx("span",{children:t(l(o.code,m(o.action),o.final))},o.sequence):null})}function he({className:e,asChild:t,hidden:o,children:n}){let{authorInfo:r}=Y(),i=useContext(L);if(o||!i||n===void 0&&!i.initials)return null;let a={className:`docx-review__avatar${e?` ${e}`:""}`,"data-testid":"review-avatar","aria-hidden":true};if(t)return jsx(Slot,{...a,children:n});let s=r.get(i.author)?.style?.avatarUrl,l=n??(s?jsx("img",{className:"docx-review__avatar-img",src:s,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer"}):void 0)??i.initials;return jsx("span",{...a,children:l})}he.docxReviewPart="Avatar";function xe({className:e,asChild:t,hidden:o,children:n}){let r=useContext(L),i=j();if(o||!r)return null;let a=r.author||i("comments.unknown"),s={className:`docx-review__author${e?` ${e}`:""}`,"data-testid":"review-author"};return t?jsx(Slot,{...s,children:n}):jsx("span",{...s,children:n??a})}xe.docxReviewPart="Author";function Ee({className:e,asChild:t,hidden:o,children:n}){let r=useContext(L);if(o||!r)return null;let i=r.date;if(!i)return null;let a=new Date(i);if(Number.isNaN(a.getTime()))return null;let s={className:`docx-review__time${e?` ${e}`:""}`,"data-testid":"review-time",dateTime:i};return t?jsx(Slot,{...s,children:n}):jsx("time",{...s,children:n??Ot.format(a)})}Ee.docxReviewPart="Time";function pe({className:e,asChild:t,hidden:o,children:n}){let r=useContext(L),i=j();if(o||!r)return null;let a=r.text,s=r.kind!=="revision"?null:it(r.item,i),l=r.kind==="revision"&&r.revisionKind==="replace",c={className:`docx-review__summary${e?` ${e}`:""}`,"data-testid":"review-summary","data-review-selectable":""};return t?jsx(Slot,{...c,children:n}):jsx("div",{...c,children:n??(l?jsxs("span",{className:"docx-review__text",children:[i("review.replaced")," ",jsxs("span",{className:"docx-review__removed",children:['"',r.replacedText,'"']})," ",i("review.replacedWith")," ",jsxs("span",{className:"docx-review__added",children:['"',a,'"']})]}):jsxs(Fragment,{children:[s?jsx("span",{className:"docx-review__label","data-kind":r.kind==="revision"?r.revisionKind:"revision",children:s}):null,a?jsx("span",{className:"docx-review__text",children:a}):null]}))})}pe.docxReviewPart="Summary";function qe({className:e,asChild:t,hidden:o,children:n,icon:r}){let{readOnly:i,review:a}=Y(),s=useContext(L),l=j();if(o||!s||s.kind!=="revision"||s.readOnly)return null;let c=l("review.accept"),d=i?l("editingMode.viewingHint"):null,u={type:"button",className:`docx-review__action${e?` ${e}`:""}`,"data-testid":"review-accept","aria-label":c,title:d??c,disabled:i,onMouseDown:oe,onClick:f=>{f.stopPropagation(),!i&&a.accept(s);}};return t?jsx(Ce,{engineDisabled:i,disabledReason:d,slotProps:u,children:n}):jsx("button",{...u,children:r??n??F(Te)})}qe.docxReviewPart="Accept";function Be({className:e,asChild:t,hidden:o,children:n,icon:r}){let{readOnly:i,review:a}=Y(),s=useContext(L),l=j();if(o||!s||s.kind!=="revision"||s.readOnly)return null;let c=l("review.reject"),d=i?l("editingMode.viewingHint"):null,u={type:"button",className:`docx-review__action${e?` ${e}`:""}`,"data-testid":"review-reject","aria-label":c,title:d??c,disabled:i,onMouseDown:oe,onClick:f=>{f.stopPropagation(),!i&&a.reject(s);}};return t?jsx(Ce,{engineDisabled:i,disabledReason:d,slotProps:u,children:n}):jsx("button",{...u,children:r??n??F(gn)})}Be.docxReviewPart="Reject";function st({className:e,asChild:t,hidden:o,children:n,icon:r}){let{readOnly:i,review:a}=Y(),s=useContext(L),{t:l}=useTranslation();if(o||!s||s.kind==="custom"||s.kind==="revision"&&s.readOnly)return null;let c=s.kind==="comment"?l("review.deleteComment"):l("review.discardChange"),d=i?l("editingMode.viewingHint"):null,u={type:"button",className:`docx-review__action${e?` ${e}`:""}`,"data-testid":"review-delete","aria-label":c,title:d??c,disabled:i,onMouseDown:oe,onClick:f=>{f.stopPropagation(),!i&&a.remove(s);}};return t?jsx(Ce,{engineDisabled:i,disabledReason:d,slotProps:u,children:n}):jsx("button",{...u,children:r??n??F(Cn)})}st.docxReviewPart="Delete";function Ue({className:e,hidden:t}){let{byId:o,authorSlots:n,authorInfo:r}=Y(),i=useContext(L);if(t||!i||i.kind==="custom")return null;let a=i.replyIds.map(s=>o.get(s)).filter(s=>s!==void 0);return a.length===0?null:jsx("ol",{className:`docx-review__replies${e?` ${e}`:""}`,children:a.map(s=>jsx(L.Provider,{value:s,children:jsxs("li",{className:"docx-review__reply","data-testid":"review-reply",...s.author?{"data-review-author":s.author,"data-review-author-slot":ge(r.get(s.author),n.get(s.author)??0)}:{},style:ce(s.author,r.get(s.author),n.get(s.author)??0),children:[jsxs("div",{className:"docx-review__head",children:[jsx(he,{}),jsxs("div",{className:"docx-review__meta",children:[jsx(xe,{}),jsx(Ee,{})]}),jsx("div",{className:"docx-review__actions",children:jsx(st,{})})]}),jsx(pe,{})]})},s.key))})}Ue.docxReviewPart="Replies";function lt({stack:e=true,positions:t,collapsed:o,scale:n=1,offset:r=0,window:i=null,children:a,className:s,hidden:l}){let{review:c,measure:d,cardClassName:u}=Y();if(l)return null;let f=typeof a=="function"?null:tt(a,"list"),v=rt(c.items),m=c.items.filter(p=>!nt(p,v));return m.length===0?typeof a=="function"?null:f?.parts.Empty??jsx(at,{}):jsx("div",{className:`docx-review__list${s?` ${s}`:""}`,children:m.map(p=>{let y=e?t?.get(p.key)??p.anchorY:p.anchorY,g=y==null?null:r+y*n;if(g!==null&&i&&(g<i.top||g>i.bottom))return null;let E=g===null?{}:{position:"absolute",top:g};return jsx(L.Provider,{value:p,children:jsx("div",{className:"docx-review__slot",style:E,...o?.has(p.key)?{"data-collapsed":""}:{},ref:$=>{d($,p.key);},children:typeof a=="function"?a(p):f?.parts.Card&&isValidElement(f.parts.Card)?xt(f.parts.Card,u):jsx($e,{...u?{className:u}:{},children:f?.rest})})},p.key)})})}lt.docxReviewPart="List";function Ht({scale:e=1,offset:t=0,window:o=null,className:n,hidden:r,icon:i}){let{review:a,authorSlots:s,authorInfo:l,commentMarkers:c}=Y(),d=so(),u=j(),{roots:f,stackedTops:v}=useMemo(()=>{let m=rt(a.items),p=a.items.filter(E=>!nt(E,m)),y=new Map,g=Number.NEGATIVE_INFINITY;for(let E of p){if(E.anchorY===null)continue;let $=Math.max(t+E.anchorY*e,g);y.set(E.key,$),g=$+30;}return {roots:p,stackedTops:y}},[a.items,t,e]);return r?null:jsx("div",{className:`docx-review__markers${n?` ${n}`:""}`,children:f.map(m=>{let p=v.get(m.key);if(p===void 0||o&&(p<o.top||p>o.bottom))return null;let y=typeof i=="function"?i(m):i,g=y==null&&c==="initials"&&m.kind==="comment";return jsx("button",{type:"button",className:"docx-review__marker","data-testid":"review-marker","data-kind":m.kind==="revision"?m.revisionKind:m.kind,...g?{"data-marker":"initials"}:{},...m.author?{"data-review-author":m.author,"data-review-author-slot":ge(l.get(m.author),s.get(m.author)??0)}:{},style:{position:"absolute",top:p,...m.author?{"--doc-review-author-current":io(l.get(m.author),s.get(m.author)??0)}:{}},title:m.author?`${m.author}: ${m.text}`:m.text,"aria-label":Bi(m,u),onMouseDown:oe,onClick:()=>{m.kind==="comment"&&m.resolved&&d.open(m.key),a.setPaneOpen(true),a.setActive(m.key);},children:y??(m.kind!=="comment"?F(ao(m)):g?_t(m.initials,m.replyIds.length,m.resolved):m.resolved?St():F(ao(m)))},m.key)})})}Ht.docxReviewPart="Markers";function Bi(e,t){let o=[`${t("review.showPane")}: ${e.author?`${e.author}. `:""}${e.text}`];return e.kind==="comment"&&e.resolved&&o.push(t("review.resolved")),e.kind==="comment"&&e.replyIds.length>0&&o.push(t("review.replyCount",{count:e.replyIds.length})),o.join(". ")}function $t({top:e=null,drafting:t=false,className:o,hidden:n,children:r}){let{beginDraft:i,readOnly:a}=Y(),s=j();if(n||t||e===null||a)return null;let l={type:"button",className:`docx-review__add${o?` ${o}`:""}`,"data-testid":"review-add-comment",style:{position:"absolute",top:e},"aria-label":s("common.comment"),title:s("common.comment"),onMouseDown:oe,onClick:i};return r?jsx(Slot,{...l,children:r}):jsx("button",{...l,children:F(wn)})}$t.docxReviewPart="AddComment";function Vt({className:e,hidden:t}){let o=useDocxEditor(),n=useRef(o);n.current=o;let{review:r,allItems:i,authorSlots:a,authorInfo:s,revisionsIn:l}=Y(),c=j(),d=useRef(null),[u,f]=useState(null),v=useRef(null),m=useEditorState(h=>h.reviewDisplayMode??"all-markup"),p=r.activatedKey!==null;useEffect(()=>{v.current=null,f(null);},[m]);let[y,g]=useState(0),E=useRef(false),$=useRef(null);useEditorEvent("reviewItemReveal",()=>{E.current=A.current==="balloons",g(h=>h+1);});let K=i.find(h=>h.isActive)??null,D=useRef(K);D.current=K;let I=K?.key??null,re=K!==null&&On(K,r.items,r.paneOpen,l,p),w=useRef(false);w.current=u!==null;let A=useRef(l);A.current=l;let k=useMemo(()=>u?Ln(u,i):null,[i,u]),N=k&&kt(k.revisionKind,l)?k:null,T=useRef(null);T.current=N?.key??null,useEffect(()=>{let h=d.current,_=h?.closest(".docx-review"),O=_?.closest(".docx-editor__scroll-container")??_?.offsetParent;if(!h||!_||!O)return;let H=()=>{v.current=null,f(null);},z=U=>{let le=U.target;if(!isElementNode(le)||h.contains(le))return;E.current=false;let me=le.closest("[data-revision-id]");if(isHTMLElementNode(me)&&O.contains(me)){let _e=me.classList.contains("docx-table-row--revision");if(me.dataset.revisionKind==="format"||_e||A.current==="balloons"){v.current=null,f(Mt(me,_,_e));return}}w.current&&H();},q=U=>{A.current!=="balloons"||!w.current||isDomNode(U.target)&&h.contains(U.target)||H();},ie=U=>{if(U.key!=="Escape"||U.defaultPrevented||U.isComposing||A.current!=="balloons"||!w.current||!isDomNode(U.target)||!O.contains(U.target))return;let le=h.contains(h.ownerDocument.activeElement);H(),le&&n.current?.focus();};return O.addEventListener("pointerdown",z,true),O.addEventListener("mousedown",z,true),O.addEventListener("beforeinput",q,true),h.ownerDocument.addEventListener("keydown",ie),()=>{O.removeEventListener("pointerdown",z,true),O.removeEventListener("mousedown",z,true),O.removeEventListener("beforeinput",q,true),h.ownerDocument.removeEventListener("keydown",ie);}},[]),useEffect(()=>{let h=d.current,_=h?.closest(".docx-review"),O=_?.closest(".docx-editor__scroll-container")??_?.offsetParent;if(!h||!_||!O)return;let H=D.current;if(!H){v.current!==null&&(v.current=null,f(null));return}if(!re){if(l==="balloons"&&T.current===H.key)return;v.current=null,f(null);return}if(w.current&&v.current===H.key)return;v.current=H.key,f(null);let z=false,q=hostWindowOf(O),ie=q.requestAnimationFrame(()=>{if(z)return;let U=uo(O,H);if(!U){f(null);return}f(Mt(U,_,U.classList.contains("docx-table-row--revision")));});return ()=>{z=true,q.cancelAnimationFrame(ie);}},[m,I,re,l,y]);let ee=useEditorState(h=>h.zoom),[Re,ft]=useState(0);useEditorEvent("change",()=>ft(h=>h+1));let V=useRef(N);V.current=N;let Pe=u!==null;useEffect(()=>{if(!Pe)return;let h=d.current?.closest(".docx-review"),_=h?.closest(".docx-editor__scroll-container")??h?.offsetParent;if(!h||!_)return;let O=()=>f(ie=>ie&&Dn(ie,_,h,V.current)),H=hostWindowOf(_),z=H.requestAnimationFrame(O),q=typeof H.ResizeObserver>"u"?null:new H.ResizeObserver(()=>{H.cancelAnimationFrame(z),z=H.requestAnimationFrame(O);});return q?.observe(_),()=>{H.cancelAnimationFrame(z),q?.disconnect();}},[Pe,ee,Re]),useEffect(()=>{if(!u)return;let h=d.current?.closest(".docx-review"),_=h?.closest(".docx-editor__scroll-container")??h?.offsetParent;return _?Tn(_,u):void 0},[u,Re]);let Se=useRef(false),Ze=useRef(null);N&&(Ze.current=N);let We=useRef(false),W=!N&&u!==null&&l==="balloons"&&We.current?Ze.current:null,de=useRef(W);de.current=W;let vt=useCallback(h=>{We.current=h,!h&&de.current!==null&&f(null);},[]);useEffect(()=>{if(N){Se.current=true;return}Se.current&&(Se.current=false,de.current===null&&f(null));},[N]);let M=N??W,pt=u!==null&&l==="balloons"?N?.key:void 0;if(useEffect(()=>{pt===void 0||!E.current||(E.current=false,$.current?.focus({preventScroll:true}));},[pt,y]),t)return null;let ze=u?.kind==="format"?"format":"structural",Rt=u!==null&&!M&&u.kind!=="format"&&!u.structuralSite,P=l==="balloons"&&M!==null,se=N===null&&W!==null,wt=u?kn(u,P?300:280):null,te=!(u===null||m!=="all-markup"||Rt||M&&r.items.some(h=>h.id===M.id)&&r.paneOpen),Ge=te&&P&&N&&N.item.kind==="revision"?c("review.changeAnnouncement",{change:it(N.item,c),author:N.author||c("comments.unknown"),text:N.text}):"";return jsxs("div",{ref:d,className:`docx-review__balloon-root${e?` ${e}`:""}`,children:[jsx("span",{className:"docx-editor-sr-only","aria-live":"polite","data-testid":"review-balloon-live",children:Ge}),!te||u===null?null:jsx("div",{className:"docx-review__balloon","data-testid":"review-balloon",...P?{"data-variant":"change"}:{},style:{left:wt.left,width:wt.width,top:u.above?u.top-6:u.bottom+6,transform:u.above?"translateY(-100%)":void 0},onMouseDown:oe,children:M?jsx(L.Provider,{value:M,children:jsxs("div",{className:"docx-review__card","data-testid":"review-balloon-card","data-kind":M.revisionKind??"revision",...M.author?{"data-review-author":M.author,"data-review-author-slot":ge(s.get(M.author),a.get(M.author)??0)}:{},...P?{ref:$,role:"dialog",tabIndex:-1,"aria-label":c("review.trackedChange")}:{},style:ce(M.author,s.get(M.author),a.get(M.author)??0),onClick:P||se?void 0:()=>r.setActive(M.key),children:[jsxs("div",{className:"docx-review__head",children:[jsx(he,{}),jsxs("div",{className:"docx-review__meta",children:[jsx(xe,{}),jsx(Ee,{})]}),M.kind==="revision"&&!M.readOnly&&!se?jsxs("div",{className:"docx-review__actions",children:[jsx(qe,{}),jsx(Be,{})]}):null]}),P?jsx(Ui,{entry:M}):jsx(pe,{}),jsx(Ve,{}),P?jsxs(Fragment,{children:[jsx(Ue,{}),jsx(nr,{entry:M,orphaned:se,onDraft:vt},M.key)]}):null]})}):jsxs("div",{className:"docx-review__card","data-testid":"review-balloon-card","data-kind":ze,...u.author?{"data-review-author":u.author,"data-review-author-slot":ge(s.get(u.author),a.get(u.author)??0)}:{},style:ce(u.author,s.get(u.author),a.get(u.author)??0),children:[jsxs("div",{className:"docx-review__head",children:[jsx("span",{className:"docx-review__avatar","aria-hidden":"true",children:Tt(u.author)}),jsxs("div",{className:"docx-review__meta",children:[jsx("span",{className:"docx-review__author",children:u.author||c("comments.unknown")}),u.date?jsx(Fi,{raw:u.date}):null]})]}),jsx("div",{className:"docx-review__summary",children:jsx("span",{className:"docx-review__label","data-kind":ze,children:c(po(ze))})})]})})]})}Vt.docxReviewPart="Balloon";function Ui({entry:e}){let t=j(),o=e.revisionKind;if(o==="replace")return jsxs("div",{className:"docx-review__summary","data-testid":"review-summary","data-review-selectable":"",children:[jsx("span",{className:"docx-review__label","data-kind":"replace",children:t("review.replaced")})," ",jsx("del",{className:"docx-review__removed",children:e.replacedText})," ",jsx("ins",{className:"docx-review__added",children:e.text})]});let n=o==="insert"||o==="moveTo";return !n&&o!=="delete"&&o!=="moveFrom"?jsx(pe,{}):jsxs("div",{className:"docx-review__summary","data-testid":"review-summary","data-review-selectable":"",children:[jsx("span",{className:"docx-review__label","data-kind":o,children:it(e.item,t)})," ",n?jsx("ins",{className:"docx-review__added",children:e.text}):jsx("del",{className:"docx-review__removed",children:e.text})]})}function Fi({raw:e}){let t=new Date(e);return Number.isNaN(t.getTime())?null:jsx("time",{className:"docx-review__time",dateTime:e,children:Ot.format(t)})}function la({className:e,furniture:t,asChild:o$1,hidden:n,children:r,t:i$1,card:a,preset:s=true,stack:l=true,gap:c$1=8,filter:d,structural:u=true,formatting:f=false}){let v=useDocxEditor(),m=useEditorState(Fn),p=useEditorState(Wn),y=useEditorState(jn),g=useEditorState(Zn),E=useMemo(()=>{let R=[];return u||R.push("structural"),f||R.push("format"),R.length>0?R:void 0},[u,f]),$=useMemo(()=>({excludeRevisionKinds:E?.filter(R=>R!=="format"),pairReplacements:false}),[E]);useEffect(()=>(v?.setReviewActivationExclusions(E??null,{formattingKinds:["rPrChange","pPrChange"]}),()=>v?.setReviewActivationExclusions(null)),[v,E]);let K=Pt(y==="balloons"?Gn:zn),D=Pt($),I=D.setPaneOpen,{t:re}=useTranslation(),w=useCallback(R=>i$1?.(R)??re(R),[i$1,re]),A=useRef(null),k=useContext(ReviewRailContext);useEffect(()=>k?.register(),[k]);let N=D.paneOpen,T=useReviewGutter(),ee=c(N,T.inlineEnd,REVIEW_PANE_GUTTER),Re=N&&!ee,ft=useMemo(()=>y==="balloons"?new Map(K.items.map(R=>[R.id,R])):null,[K.items,y]),V=useMemo(()=>D.items.filter(R=>reviewPaneListsItem(y,ft?.get(R.id)??R)&&(f||!Kn(R))&&(!d||d(R))),[D.items,d,f,y,ft]),Pe=useRef(V);Pe.current=V;let Se=useEditorState(Yn),Ze=useRef(Se);Ze.current=Se,useEditorEvent("reviewItemReveal",({key:R})=>{n||Ze.current==="manual"||Pe.current.some(C=>C.key===R)&&I(true);});let We=useRef(N);We.current=N,useEffect(()=>{let R=A.current;if(!(!v||!R||m||n))return o(R,v,C=>{We.current||Pe.current.some(S=>S.key===C)&&I(true);})},[v,m,n,I]);let W=useSyncExternalStore(useCallback(R=>v?.on("selectionChange",R)??(()=>{}),[v]),()=>v?.getConfiguredAuthor()??null,()=>null),de=useMemo(()=>{let R=new Map;for(let C of V)C.author&&!R.has(C.author)&&R.set(C.author,R.size);return W&&!R.has(W)&&R.set(W,R.size),R},[V,W]),vt=useMemo(()=>{let R=new Map;for(let C of V)R.set(C.id,C);if(y==="balloons")for(let C of K.items)R.has(C.id)||R.set(C.id,C);return R},[V,y,K.items]),[M,pt]=useState(()=>new Map),ze=useCallback((R,C)=>{C<=0||pt(S=>{if(S.get(R)===C)return S;let ve=new Map(S);return ve.set(R,C),ve});},[]),Rt=fn(ze),P=At(v,A,V,!m&&!n,ee),se=dn(v,A,!m&&!n),wt=useMemo(()=>({...P,compact:ee}),[P,ee]);useEffect(()=>{let R=A.current;if(!v||!R)return;let C=ve=>{let gt=ve.target;if(!isDomNode(gt)||R.contains(gt))return;let zt=R.offsetParent;!zt||!zt.contains(gt)||zt.querySelector(".docx-paginated-surface")?.contains(gt)||v.setActiveReviewItem(null);},S=hostDocumentOf(R);return S.addEventListener("mousedown",C,true),()=>S.removeEventListener("mousedown",C,true)},[v,m,n]);let[te,Ge]=useState(null),h=useRef(null),_=useCallback(()=>{let R=h.current;R&&(R.editor.releaseSelection(R.pin),h.current=null);},[]),O=useCallback(()=>{if(!v||p)return;let R=v.getSelectionPlacement()?.anchorY??null;if(R===null)return;_();let C=v.retainSelection();C&&(h.current={editor:v,pin:C},I(true),Ge(R));},[v,p,_,I]);useEffect(()=>{if(!(n||p))return k?.registerCommentDraft(O)},[O,n,p,k]);let H=useCallback(()=>{_(),Ge(null),v?.focus();},[v,_]);useEffect(()=>_,[_]),useEffect(()=>{N||te===null||(_(),Ge(null));},[N,te,_]);let z=te??D.selectionAnchorY,q=useMemo(()=>{let R=rt(V);return V.filter(C=>!nt(C,R))},[V]),ie=useMemo(()=>{if(te===null)return q;let R=q.findIndex(S=>S.anchorY!==null&&S.anchorY>te),C={key:Le,anchorY:te};return R===-1?[...q,C]:[...q.slice(0,R),C,...q.slice(R)]},[q,te]),U=useMemo(()=>{let R=new Map(M);for(let C of q){if(R.has(C.key))continue;let S=C.text.length+(C.kind==="revision"?C.replacedText?.length??0:0),ve=Math.min(6,Math.max(1,Math.ceil(S/36)));R.set(C.key,64+ve*20);}return R},[M,q]),{stacked:le,collapsedKeys:me}=useMemo(()=>{let{positions:R,collapsed:C}=i(ie.map(S=>({key:S.key,anchorY:S.anchorY,isActive:"isActive"in S&&S.isActive})),{gap:c$1,scale:P.scale,collapseAfterPx:480,heightOf:(S,ve)=>ve?64:U.get(S)??72,collapsible:S=>S.key!==Le});return {stacked:R,collapsedKeys:C}},[ie,U,c$1,P.scale]),_e=z===null?null:P.top+(ee?z:le.get(Le)??z)*P.scale,Qe=a?.className,Er=useReviewAuthors(),Zt=pn(Er,V,de,v),ko=W?de.get(W)??0:0,Do=W?Zt.get(W):void 0,Ar=useMemo(()=>({t:i$1,cardClassName:Qe,readOnly:p,review:{...D,items:V},allItems:K.items,authorSlots:de,authorInfo:Zt,draftAuthor:W,draftAuthorInfo:Do,draftAuthorSlot:ko,byId:vt,measure:Rt,beginDraft:O,endDraft:H,commentMarkers:g,revisionsIn:y}),[i$1,Qe,p,D,K.items,V,de,Zt,W,Do,ko,vt,Rt,O,H,g,y]);if(n||m)return null;let To={ref:A,className:`docx-review${e?` ${e}`:""}`,"data-testid":"review-rail","data-count":V.length,"data-open":Re?"":void 0,"data-compact":ee?"":void 0,role:"region","aria-label":w("review.ariaLabel"),onMouseDown:oe,style:P.left===null?void 0:{left:P.left,right:"auto"}},we=typeof r=="function"?{parts:{},rest:r}:tt(r,"root"),fe=we.parts,Xe=(R,C)=>{if(!(R in fe))return C;let S=fe[R];return !isValidElement(S)||!isValidElement(C)?S:cloneElement(S,{...C.props,...S.props})},Oo=jsxs(Fragment,{children:[s||"AddComment"in fe?Xe("AddComment",jsx($t,{top:_e,drafting:te!==null})):null,!N||te===null||_e===null||!s&&!("Draft"in fe)?null:Xe("Draft",jsx(bo,{top:_e,left:ee?P.compactCardLeft:null})),s||"Balloon"in fe?Xe("Balloon",jsx(Vt,{})):null]}),Ir=jsx(lt,{stack:l,positions:le,collapsed:me,scale:P.scale,offset:P.top,window:se,children:we.rest}),Lo=jsx(Ht,{scale:P.scale,offset:P.top,window:se}),ye=ee?q.find(R=>R.key===D.activeKey)??null:null,Ko=ye===null?null:ye.anchorY!==null?P.top+ye.anchorY*P.scale:se!==null?se.top+Et+24:null,Wt=ln(we.rest,fe.List),yt=o$1?null:Wt.template,bt=typeof yt=="function"?null:tt(yt,"list"),Ho=Wt.hidden?null:typeof yt=="function"?ye&&yt(ye):bt?.parts.Card&&isValidElement(bt.parts.Card)?xt(bt.parts.Card,Qe):s||Wt.fromList?jsx($e,{...Qe?{className:Qe}:{},children:bt?.rest}):null,$o=ye&&Ko!==null&&P.compactCardLeft!==null&&Ho?jsx(L.Provider,{value:ye,children:jsx("div",{className:"docx-review__slot docx-review__slot--compact","data-testid":"review-compact-card",style:{position:"absolute",top:Ko,left:P.compactCardLeft,width:b},children:Ho})}):null,Nr=Re?s||"List"in fe?Xe("List",Ir):typeof we.rest=="function"?null:we.rest:s||"Markers"in fe?jsxs(Fragment,{children:[Xe("Markers",Lo),$o]}):typeof we.rest=="function"?null:we.rest;return jsx(Sn,{items:V,children:jsx(ot.Provider,{value:Ar,children:jsx(vo.Provider,{value:wt,children:o$1&&isValidElement(r)?jsx(Slot,{...To,children:cloneElement(r,void 0,r.props.children,s?Re?jsx(lt,{stack:l,positions:le,collapsed:me,scale:P.scale,offset:P.top,window:se}):jsxs(Fragment,{children:[Lo,$o]}):null,Oo,jsx(Co,{},"refusal-live"))}):jsxs("aside",{...To,children:[Re&&t!==void 0?jsx("div",{className:"docx-review__furniture","data-testid":"review-furniture",children:t}):null,Nr,Oo,jsx(Co,{})]})})})})}var ca=Object.assign(la,{List:lt,Empty:at,Card:$e,Avatar:he,Author:xe,Time:Ee,Summary:pe,Accept:qe,Reject:Be,Resolve:wo,Reopen:yo,Delete:st,Refusal:Ve,Replies:Ue,Reply:go,Markers:Ht,AddComment:$t,Draft:bo,Balloon:Vt});var ma=e=>e.collaborationStatus;function ue(){let e=useDocxEditor();return useEditorState(ma),e?.collaborationSession()??null}var Eo=Object.freeze({status:"inactive",reason:void 0,lastFailure:void 0,live:false,diverged:false,recovering:false,waiting:false,failureCount:0,attached:false});function dr(e,t){return e===t?true:!e||!t?false:e.code===t.code&&e.detail===t.detail}function pa(e,t){return e.status===t.status&&dr(e.reason,t.reason)&&dr(e.lastFailure,t.lastFailure)&&e.failureCount===(t.failureCount??0)&&e.recovering===(t.recovering??false)&&e.waiting===(t.waiting??false)}function Ra(e){return e.attached??false}function mr(e,t){if(!e)return t.current=Eo,Eo;let o=e.statusSnapshot(),n=Ra(e);if(pa(t.current,o)&&t.current.attached===n)return t.current;let r=Object.freeze({status:o.status,reason:o.reason,lastFailure:o.lastFailure,live:o.status==="ready",diverged:o.status==="destroyed"||o.status==="error"&&o.recovering!==true,recovering:o.status==="error"&&o.recovering===true,waiting:o.waiting===true,failureCount:o.failureCount??0,attached:n});return t.current=r,r}function Ao(e){let t=ue(),o=e===void 0?t:e,n=useRef(Eo);return useSyncExternalStore(r=>o?.subscribeStatus(()=>r())??(()=>{}),()=>mr(o,n),()=>mr(o,n))}function vr({session:e,onRejoin:t,className:o,children:n}){let{t:r}=useTranslation(),i=ue(),a=e===void 0?i:e,s=Ao(a),l=ha(a?.sessionId??null,s.failureCount,s.status),c=Ca(s.waiting);if(!a||s.status==="inactive")return null;let d=x({status:s.status,reasonCode:(s.reason??s.lastFailure)?.code,recovering:s.recovering,waiting:s.waiting,stalled:c,refusedRecently:l,offlineEditing:a.offlineEditing!==false}),u=d?r(w[d]):"",f=d==="outOfSync"||d==="stalled"?t:void 0,v=null;return d&&n?v=n({kind:d,message:u,...f?{rejoin:f}:{}}):d&&(v=jsxs(Fragment,{children:[jsx("span",{className:"docx-collaboration-status__message",children:u}),f?jsx("button",{type:"button",className:"docx-collaboration-status__action",onClick:f,children:r("collaboration.status.rejoin")}):null]})),jsx("div",{className:`docx-collaboration-status${o?` ${o}`:""}`,...d?{"data-collaboration-status":d}:{},role:"status",children:v})}function Ca(e){let[t,o]=useState(false);return useEffect(()=>{if(o(false),!e)return;let n=globalThis.setTimeout(()=>o(true),1e4);return ()=>globalThis.clearTimeout(n)},[e]),e&&t}function ha(e,t,o){let n=useRef({sessionId:e,failureCount:t}),[r,i]=useState(0);return useEffect(()=>{let a=n.current;if(n.current={sessionId:e,failureCount:t},a.sessionId!==e){i(0);return}t<=a.failureCount||(o==="ready"||o==="disconnected")&&i(t);},[e,t,o]),useEffect(()=>{if(r===0)return;let a=globalThis.setTimeout(()=>i(0),6e3);return ()=>globalThis.clearTimeout(a)},[r]),r!==0}var Po=Object.freeze([]);function Na(e,t){if(e===t)return true;if(e.length!==t.length)return false;for(let o=0;o<e.length;o+=1){let n=e[o],r=t[o];if(n.actorId!==r.actorId||n.name!==r.name||n.color!==r.color||n.role!==r.role||n.isLocal!==r.isLocal)return false}return true}function pr(e,t){if(!e)return t.current=Po,Po;let o=e.participants();return Na(t.current,o)?t.current:(t.current=o,o)}function Ut(e){let t=ue(),o=e===void 0?t:e,n=useRef(Po);return useSyncExternalStore(r=>o?.subscribeParticipants(()=>r())??(()=>{}),()=>pr(o,n),()=>pr(o,n))}var Rr=createContext(null);function La(e){return {"--doc-collaboration-accent":e.color}}function wr(e){return e!==void 0?{avatarUrl:e}:{}}function yr({participant:e,className:t$1,children:o}){let n=useDocxEditor(),r=useReviewAuthors(),a=useContext(Rr)?.get(e.actorId)??s(r,e,n?l=>n.presenceColorFor(l):void 0,n?l=>n.getReviewAuthorStyle(l)?.color:void 0),s$1=Ka(e.name);return jsx("span",{className:`docx-collaboration-avatar${t$1?` ${t$1}`:""}`,"data-collaboration-avatar":"",...e.isLocal?{"data-local":""}:{},...a.slot!==null?{"data-collaboration-author-slot":a.slot}:{},title:e.name,role:"img","aria-label":e.name,style:La(a),children:o??(s$1!==void 0?jsx("img",{className:"docx-collaboration-avatar__image",src:s$1,alt:""}):t(e.name))})}function Ka(e){let t=useDocxEditor(),o=useReviewAuthors();return v(o,e,t?n=>t.getReviewAuthorStyle(n):void 0)}function Ha({session:e,max:t$1,className:o,children:n}){let r$1=useDocxEditor(),i=Ut(e),a=useReviewAuthors(),{t:s}=useTranslation(),l=useMemo(()=>r(a,i,r$1?m=>r$1.presenceColorFor(m):void 0,r$1?m=>r$1.getReviewAuthorStyle(m)?.color:void 0),[a,i,r$1]),c=useMemo(()=>{let m=r$1?y=>r$1.getReviewAuthorStyle(y):void 0,p=new Map;for(let y of i){if(p.has(y.name))continue;let g=v(a,y.name,m);g!==void 0&&p.set(y.name,g);}return p},[r$1,i,a]),d=useMemo(()=>u(i),[i]);if(d.length===0)return null;let u$1=t$1===void 0?d:d.slice(0,Math.max(0,t$1)),f=d.length-u$1.length,v$1=s("collaboration.moreParticipants",{count:f});return jsxs("span",{className:`docx-collaboration-avatars${o?` ${o}`:""}`,"data-collaboration-avatars":"",role:"group","aria-label":s("collaboration.participants"),children:[jsx(Rr.Provider,{value:l,children:u$1.map(m=>n?jsx(Fragment$1,{children:n({participant:m,color:l.get(m.actorId).color,initials:t(m.name),...wr(c.get(m.name))})},m.actorId):jsx(yr,{participant:m},m.actorId))}),f>0?jsx("span",{className:"docx-collaboration-avatar","data-collaboration-avatar":"","data-overflow":"",title:v$1,role:"img","aria-label":v$1,children:`+${f}`}):null]})}var Ft=Object.freeze([]);function $a(){return Ft}function Va(){let e=useRef(null);if(e.current===null){let t=Ft,o=false,n=new Set;e.current={subscribe:r=>(n.add(r),()=>n.delete(r)),read:()=>t,write:r=>{t=r.length===0?Ft:r,!o&&(o=true,queueMicrotask(()=>{o=false;for(let i of [...n])i();}));}};}return e.current}function qa({session:e,children:t}){let o=useDocxEditor(),n=ue(),r$1=e===void 0?n:e,i=Ut(r$1),a=useReviewAuthors(),s$1=Va(),l=useSyncExternalStore(s$1.subscribe,s$1.read,$a);if(useEffect(()=>{if(!(!o||!r$1))return o.setRemoteCaretLabelHost({publish:s$1.write}),()=>{o.setRemoteCaretLabelHost(null),s$1.write(Ft);}},[o,r$1,s$1]),l.length===0)return null;let c=r(a,i);return jsx(Fragment,{children:l.map(d=>{let{selection:u}=d,f=i.find(p=>p.actorId===u.actorId)??null,v$1=d.element.style.getPropertyValue("--doc-remote-color"),m=v$1!==""?v$1:c.get(u.actorId)?.color??s(a,{actorId:u.actorId,name:u.name,...u.color!==void 0?{color:u.color}:{},isLocal:false}).color;return createPortal(t?t({selection:u,participant:f,color:m,...wr(v(a,u.name,o?p=>o.getReviewAuthorStyle(p):void 0))}):u.name,d.element,u.actorId)})})}var Ba=Object.freeze({CaretLabels:qa,Avatars:Ha,Avatar:yr,Status:vr});function dt(e){let t=useDocxEditor();return useMemo(()=>e||(t?.getCustomNodeDefinitions()??[]).filter(j$2),[e,t])}var za=".docx-content-control-boundary";function Ye(e,t){let{node:o,definition:n,controlId:r}=e,i=r?t?.getReviewItems().find(l=>l.kind==="custom"&&l.item.id===r):void 0;if(i&&i.kind==="custom"){let l=i.item;return {...o,attrs:l.attrs,text:l.text,...l.data===void 0?{}:{data:l.data},...r?{nodeId:r}:{}}}let a=r?Ga(t,r,n):void 0,s=n.fromDocx?n.fromDocx({attrs:o.attrs,text:"",...a===void 0?{}:{data:a}}):o.attrs;return s===null?null:{...o,attrs:s,...a===void 0?{}:{data:a},...r?{nodeId:r}:{}}}function Ga(e,t,o){let n=e?.surface;if(!n)return;let r=partOfNodeId(n.session,t),i=customNodePayloadsByControl(n.session.currentPackage(),(r??n.session.part()).name,n.session.part().name).get(t);if(!i)return;let a=e$1(o.schema,i.data);return a.ok?a.value:void 0}function je(e,t){let o=e?.closest?.(za),n=o?.closest(".docx-content-control-chrome"),r=n?.getAttribute("data-tag"),i=r?c$1(r):null;if(!o||!i||!r)return null;let a=t.find(s=>s.tagPrefix===i.prefix&&s.name===i.name);return a?{node:{name:i.name,attrs:i.attrs,tag:r,rect:o.getBoundingClientRect()},definition:a,controlId:n?.getAttribute("data-docx-content-control")??null}:null}var _o=".docx-content-control-boundary",Ja=e=>{if(!k$1.test(e.tagPrefix)||!k$1.test(e.name))return [];let t=`${e.tagPrefix}:${e.name}`;return [`.docx-content-control-chrome[data-tag="${t}"]`,`.docx-content-control-chrome[data-tag^="${t}?"]`]};function es(e){let{onNodeClick:t,onNodeHover:o}=e,n=useDocxEditor(),r=dt(e.nodes),i=useEditorHostDocument();return useEffect(()=>{if(!i)return;let a=i.defaultView?.CSS??CSS,s=i.createElement("style"),l=[];for(let c of r){let d=Ja(c);if(d.length===0)continue;let u=c.chrome?.color!==void 0&&a.supports("color",c.chrome.color)?c.chrome.color:"var(--doc-accent)";l.push(`${d.map(f=>`${f} ${_o}`).join(", ")} {`," pointer-events: auto !important;"," opacity: 1;"," border: none;",` background: color-mix(in srgb, ${u} 12%, transparent);`," border-radius: 6px;"," cursor: default;","}");}return s.textContent=l.join(`
2
- `),i.head.append(s),()=>s.remove()},[r,i]),useEffect(()=>{if(!i)return;let a=null,s=null,l=f=>je(i.elementFromPoint(f.clientX,f.clientY),r),c=f=>{let v=f.button===0?l(f):null;a=v?.controlId??null,s=v?.node.tag??null;},d=f=>{let v=a,m=s;if(a=null,s=null,m===null)return;let p=l(f);if(!p||p.node.tag!==m||v!==null&&p.controlId!==v)return;let y=Ye(p,n);y&&(p.definition.onClick?.(y),t?.(y));},u=f=>{let v=je(f.target,r);if(!v||f.relatedTarget?.closest?.(_o)===f.target.closest(_o))return;let p=Ye(v,n);p&&(v.definition.onHover?.(p),o?.(p));};return i.addEventListener("pointerdown",c,true),i.addEventListener("pointerup",d,true),i.addEventListener("mouseover",u),()=>{i.removeEventListener("pointerdown",c,true),i.removeEventListener("pointerup",d,true),i.removeEventListener("mouseover",u);}},[r,n,t,o,i]),null}var is=e=>e.editingMode==="viewing";function hr(e){let{onEditNode:t,onRemoveRefused:o,remove:n=true}=e,r=dt(e.nodes),i=useContextMenuTarget(),a=useDocxEditor(),{t:s}=useTranslation(),l=useMemo(()=>i?je(i,r):null,[i,r]),c=useMemo(()=>l?Ye(l,a):null,[l,a]),d=useEditorState(is),u=useMemo(()=>!l?.definition.reviewCard||!c?null:l.definition.reviewCard({attrs:c.attrs,text:c.text??"",...c.data===void 0?{}:{data:c.data}}),[l,c]);if(!l||!c)return null;let{definition:f}=l,v=f.label??f.name,m=!d&&(f.onEdit!==void 0||t!==void 0),p=!d&&n&&c.nodeId!==void 0&&a!==null;return !u&&!m&&!p?null:jsxs(Fragment,{children:[u?jsxs("div",{className:"docx-contextmenu__custom-info","data-testid":"custom-node-info",children:[jsx("span",{className:"docx-contextmenu__custom-title",children:u.title}),u.detail?jsx("span",{className:"docx-contextmenu__custom-detail",children:u.detail}):null]}):null,m?jsx(ContextMenuItem,{label:s("contextMenu.editCustomNode",{label:v}),className:"docx-contextmenu__custom-edit",onSelect:()=>{f.onEdit?.(c),t?.(c,f);}}):null,p?jsx(ContextMenuItem,{label:s("contextMenu.removeCustomNode",{label:v}),className:"docx-contextmenu__custom-remove",onSelect:()=>{let y=q$1(a,c.nodeId);y.ok||o?.(c,y.reason);}}):null,jsx("div",{role:"separator",className:"docx-toolbar__menu-separator"})]})}hr.docxRowPlacement="start";function ls({collaboration:e,fallback:t=null,author:o,children:n,...r}){let{document:i,modules:a,session:s}=e;if(!i)return jsx(Fragment,{children:t});let l=o??s?.identity.name;return jsx(DocxEditorRoot,{document:i,modules:a,...l!==void 0?{author:l}:{},...r,children:n},s?.sessionId??"local")}var ms=Symbol("useDocumentCollaboration.createRoom");async function fs(e){let{createDocumentCollaboration:t}=await import('../document-session-J2YKWERI.js');return t(e)}function vs(e){return e[ms]??fs}function ps(e){return e?`${e.documentId}:${e.bootstrap.kind}:${e.identity.actorId}`:""}function Rs(e={}){let t=useId(),o=b$1({ownerKey:`react-document:${t}`,hookName:"useDocumentCollaboration",createRoom:vs(e),hostModules:e.modules??a$1,autoRoom:e.room??null,autoKey:ps(e.room??null),rejoinOptionsOf:n=>({...n,bootstrap:{kind:"join"}}),identityOf:n=>n.identity});return useMemo(()=>({document:o.document,modules:o.modules,session:o.session,pending:o.pending,error:o.error,connect:o.connect,leave:o.leave}),[o])}export{es as CustomNodeChrome,hr as CustomNodeContextMenu,Ba as DocxEditorCollaboration,ls as DocxEditorCollaborationRoot,ca as DocxEditorReview,Ye as activatedCustomNodeOf,je as resolveCustomNodeActivation,Ut as useCollaborationParticipants,ue as useCollaborationSession,Ao as useCollaborationStatus,dt as useCustomNodeDefinitions,Rs as useDocumentCollaboration,Pt as useReview,Vn as useReviewAuthor,$n as useReviewItem,vn as useReviewOf,Un as useReviewRailMetrics,qr as useStackedReviewPositions};
1
+ import {b as b$1,a as a$1}from'../chunk-MWO2ZUEJ.js';import {c,o,i,b,l,a,e,d,m,p,q,n,h,k,j as j$1,g,f,x,w,s,t,r,v,u}from'../chunk-HMSOWKXT.js';import {j as j$2,e as e$1,c as c$1,q as q$1,k as k$1}from'../chunk-AVZO5ZHZ.js';export{o as reviewModule}from'../chunk-AVZO5ZHZ.js';export{b as collaborationModule}from'../chunk-Q2VBO66F.js';import {createContext,useMemo,useEffect,useCallback,useRef,useContext,useSyncExternalStore,useState,isValidElement,cloneElement,useId,Children,Fragment as Fragment$1}from'react';import {reviewPaneListsItem,hostDocumentOf,hostWindowOf,isDomNode,isElementNode,isHTMLElementNode,partOfNodeId}from'@docx-editor.dev/core/editor';import {useDocxEditor,useEditorState,useTranslation,ReviewRailContext,useReviewGutter,REVIEW_PANE_GUTTER,useEditorEvent,useReviewAuthors,Slot,notificationYieldsToTask,useEditorHostDocument,useContextMenuTarget,ContextMenuItem,DocxEditorRoot}from'@docx-editor.dev/react';import {jsxs,Fragment,jsx}from'react/jsx-runtime';import {createPortal}from'react-dom';import {customNodePayloadsByControl}from'@docx-editor.dev/core/store';var kr=new Set(["List","Markers","AddComment","Draft","Balloon"]),Dr=new Set(["Card","Empty"]);function tt(e,t){let o=t==="root"?kr:Dr,n={},r=[],i=s=>{if(Array.isArray(s)){for(let l of s)i(l);return}if(!isValidElement(s)){s!=null&&s!==false&&r.push(s);return}if(s.type===Fragment$1){i(s.props.children);return}let a=s.type.docxReviewPart;a&&o.has(a)?n[a]=s:r.push(s);};return i(e),{parts:n,rest:r}}function xt(e,t){if(!t)return e;let o=e.props.className;return cloneElement(e,{className:`${t}${o?` ${o}`:""}`})}function ln(e,t){if(!isValidElement(t))return {template:e,fromList:false,hidden:false};let{children:o,hidden:n}=t.props;return {template:o===void 0?e:o,fromList:o!==void 0,hidden:n===true}}var Et=600;function At(e$1,t,o,n,r=false){let[i,s]=useState(a);return useEffect(()=>{let a=t.current;if(!(!e$1||!a))return e(a,e$1,l=>s(u=>d(u,l)?u:l),{trackScroll:r})},[e$1,t,o,n,r]),i}function dn(e,t,o){let[n,r]=useState(null);return useEffect(()=>{let i=t.current,s=i?.offsetParent;if(!s)return;let a=hostWindowOf(s),l=0,u=()=>({top:s.scrollTop-Et,bottom:s.scrollTop+s.clientHeight+Et}),m=null,c=()=>{l=0;let p=m??u();m=null,r(y=>y&&y.top===p.top&&y.bottom===p.bottom?y:p);},f=0,v=()=>{m=u(),l===0&&(l=a.requestAnimationFrame(c)),i?.setAttribute("data-scrolling",""),a.clearTimeout(f),f=a.setTimeout(()=>i?.removeAttribute("data-scrolling"),150);};c(),s.addEventListener("scroll",v,{passive:true});let d=new a.ResizeObserver(v);return d.observe(s),()=>{l!==0&&a.cancelAnimationFrame(l),a.clearTimeout(f),s.removeEventListener("scroll",v),d.disconnect();}},[e,t,o]),n}function fn(e){let t=useRef(new WeakMap),o=useRef(new Map),n=useRef(new Map),r=useCallback(s=>{let a=hostWindowOf(s),l=n.current.get(a);if(l)return l;if(typeof a.ResizeObserver>"u")return null;let u=new a.ResizeObserver(m=>{for(let c of m){let f=t.current.get(c.target);f&&e(f,c.target.offsetHeight);}});return n.current.set(a,u),u},[e]),i=useCallback((s,a)=>{let l=o.current.get(a);if(!s){l&&(n.current.get(hostWindowOf(l))?.unobserve(l),t.current.delete(l),o.current.delete(a));return}let u=r(s);u&&(e(a,s.offsetHeight),!(l===s&&t.current.get(s)===a)&&(l&&(n.current.get(hostWindowOf(l))?.unobserve(l),t.current.delete(l)),t.current.set(s,a),o.current.set(a,s),u.observe(s)));},[e,r]);return useEffect(()=>()=>{for(let s of n.current.values())s.disconnect();n.current.clear(),o.current.clear();},[]),i}var It=[],Pt=null;function Hr(e){if(typeof MessageChannel!="function"){globalThis.setTimeout(e,0);return}Pt||(Pt=new MessageChannel,Pt.port1.onmessage=()=>{let t=It;It=[];for(let o of t)try{o();}catch(n){queueMicrotask(()=>{throw n});}}),It.push(e),It.length===1&&Pt.port2.postMessage(null);}function $r(e){let t=false;return ()=>{if(!t){if(!notificationYieldsToTask()){e();return}t=true,Hr(()=>{t=false,e();});}}}function Vr(e){return `${e.getReviewRevision()}:${e.getEditingMode()}:${k(e)}`}function Nt(e){let t=useDocxEditor();return vn(t,e)}function vn(e,t){let o=useCallback(w=>{if(!e)return ()=>{};let A=false,k=$r(()=>{A||w();}),I=e.on("change",k),T=e.on("selectionChange",k),Q=e.on("error",k);return ()=>{A=true,I(),T(),Q();}},[e]),n$1=useSyncExternalStore(o,()=>e?Vr(e):"none",()=>"none"),r=useCallback(w=>e?n(e).subscribe(w):()=>{},[e]),i=useSyncExternalStore(r,()=>e?n(e).get():null,()=>null),s=useCallback((w,A,k)=>(e&&n(e).record(w,A,k),k.ok),[e]),a=useMemo(()=>e?e.getReviewItems(t).filter(w=>w.item.kind!=="custom"||w.item.carded):[],[e,n$1,t]),l=useMemo(()=>a.find(w=>w.isActive)?.key??null,[a]),u=useCallback(w=>{if(!e)return ()=>{};let A=e.on("selectionChange",w),k=e.on("change",w);return ()=>{A(),k();}},[e]),m=useSyncExternalStore(u,()=>e?e.getActivatedReviewItemKey(t):null,()=>null),c=useCallback((w,A)=>e?e.setActiveReviewItem(w,A).ok:false,[e]),f=useCallback(w=>!e||w.kind!=="revision"||w.readOnly?false:s("accept",w.key,e.acceptReviewItem(w.key)),[e,s]),v=useCallback(w=>!e||w.kind!=="revision"||w.readOnly?false:s("reject",w.key,e.rejectReviewItem(w.key)),[e,s]),d=useCallback((w,A)=>h(e,w,A),[e]),p=useCallback(w=>!e||w.kind!=="comment"?false:s("resolve",w.key,e.setCommentResolved(w.key,true)),[e,s]),y=useCallback(w=>!e||w.kind!=="comment"?false:s("reopen",w.key,e.setCommentResolved(w.key,false)),[e,s]),g=e?.getEditingMode()==="viewing"?"the document is open for viewing":null,x=useCallback(w=>!e||w.kind==="custom"||w.kind==="revision"&&w.readOnly?false:s("remove",w.key,e.deleteReviewItem(w.key)),[e,s]),H=useCallback((w,A,k)=>A.trim().length===0||!e?false:s("reply",w.key,e.replyToReviewItem(w.key,A,k)),[e,s]),D=useMemo(()=>e?e.getSelectionPlacement()?.anchorY??null:null,[e,n$1]),K=useCallback((w,A)=>w.trim().length===0||!e?false:s("comment",null,e.addComment(w,A)),[e,s]),U=useMemo(()=>e?e.isReviewPaneOpen():true,[e,n$1]),S=useCallback(w=>{!e||e.isReviewPaneOpen()===w||e.exec({type:"toggleReviewPane"});},[e]);return useMemo(()=>({items:a,activeKey:l,activatedKey:m,setActive:c,accept:f,reject:v,adopt:d,resolve:p,reopen:y,commentResolutionDisabledReason:g,remove:x,reply:H,selectionAnchorY:D,comment:K,lastRefusal:i,paneOpen:U,setPaneOpen:S,ready:e!==null&&!e.snapshot().isLoading&&e.snapshot().parseError===null}),[a,l,m,c,f,v,d,p,y,g,x,H,D,K,i,U,S,e])}function qr(e,t,o={}){let n=o.gap??8,r=o.scale??1,i=o.defaultHeight??0;return useMemo(()=>j$1(e,t,{gap:n,scale:r,defaultHeight:i}),[e,t,n,r,i])}var ro=8;function io(e,t){return e?.color??`var(--doc-review-author-${t%ro})`}function ce(e,t,o){return e?{"--doc-review-author-current":io(t,o)}:{}}function Ce(e,t){return (e?.slot??t)%ro}function pn(e,t,o,n){let r=useRef(new Map);return useMemo(()=>{let i=new Map;for(let a of e)i.set(a.author,a);let s=[...t.map(a=>a.author),n?.getConfiguredAuthor()];for(let a of s){if(!a||i.has(a))continue;let l=o.get(a)??0,u=n?.getReviewAuthorStyle(a),m=u?.color??`var(--doc-review-author-${l%ro})`,c=r.current.get(a),f=c!==void 0&&c.slot===l&&c.color===m&&c.style===u?c:{author:a,slot:l,color:m,...u?{style:u}:{}};r.current.set(a,f),i.set(a,f);}return i},[e,t,o,n])}var Y=e=>jsx("svg",{viewBox:"0 -960 960 960",width:16,height:16,"aria-hidden":"true",focusable:"false",children:jsx("path",{d:e,fill:"currentColor"})}),wn="M440-400h80v-120h120v-80H520v-120h-80v120H320v80h120v120ZM80-80v-720q0-33 23.5-56.5T160-880h640q33 0 56.5 23.5T880-800v480q0 33-23.5 56.5T800-240H240L80-80Zm126-240h594v-480H160v525l46-45Zm-46 0v-480 480Z",Rn="M240-400h480v-80H240v80Zm0-120h480v-80H240v80Zm0-120h480v-80H240v80ZM880-80 720-240H160q-33 0-56.5-23.5T80-320v-480q0-33 23.5-56.5T160-880h640q33 0 56.5 23.5T880-800v720ZM160-320h594l46 45v-525H160v480Zm0 0v-480 480Z",Fr="M880-80 720-240H160q-33 0-56.5-23.5T80-320v-480q0-33 23.5-56.5T160-880h640q33 0 56.5 23.5T880-800v720ZM160-320h594l46 45v-525H160v480Zm0 0v-480 480Z",Te="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z",St=()=>jsxs("span",{className:"docx-review__resolved-icon",children:[jsx("span",{className:"docx-review__resolved-comment",children:Y(Fr)}),jsx("span",{className:"docx-review__resolved-tick",children:Y(Te)})]}),yn="M120-160v-640l760 320-760 320Zm80-120 474-200-474-200v140l240 60-240 60v140Zm0 0v-400 400Z",_t=(e,t,o)=>jsxs("span",{className:"docx-review__badge","data-testid":"review-badge",...o?{"data-resolved":""}:{},"aria-hidden":"true",children:[o?Y(Te):jsx("span",{className:"docx-review__badge-initials",children:e||"?"}),t>0?jsx("span",{className:"docx-review__badge-count","data-testid":"review-badge-count",children:t>9?"9+":t}):null]}),bn="M480-160q-134 0-227-93t-93-227q0-134 93-227t227-93q69 0 132 28.5T720-690v-110h80v280H520v-80h168q-32-56-87.5-88T480-720q-100 0-170 70t-70 170q0 100 70 170t170 70q77 0 139-44t87-116h84q-28 106-114 173t-196 67Z",gn="m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z",Cn="M280-120q-33 0-56.5-23.5T200-200v-520h-40v-80h200v-40h240v40h200v80h-40v520q0 33-23.5 56.5T680-120H280Zm400-600H280v520h400v-520ZM360-280h80v-360h-80v360Zm160 0h80v-360h-80v360ZM280-720v520-520Z",Yr="M200-200h57l391-391-57-57-391 391v57Zm-80 80v-170l528-527q12-11 26.5-17t30.5-6q16 0 31 6t26 18l55 56q12 11 17.5 26t5.5 30q0 16-5.5 30.5T817-647L290-120H120Zm640-584-56-56 56 56Zm-141 85-28-29 57 57-29-28Z",jr="M486-160q-76 0-135-45t-85-123l88-38q14 48 48.5 78t85.5 30q42 0 76-20t34-64q0-18-7-33t-19-27h112q5 14 7.5 28.5T694-341q0 86-61.5 133.5T486-160ZM80-520v-80h800v80H80Zm402-360q66 0 116 30t74 84l-88 38q-11-28-38.5-47T480-794q-42 0-72 19t-30 51q0 15 6 27t18 22H272q-6-13-9-27t-3-30q0-70 55-114t167-44Z",Zr="M360-160q-83 0-141.5-58.5T160-360v-360q0-83 58.5-141.5T360-920q83 0 141.5 58.5T560-720v360q0 83-58.5 141.5T360-160Zm0-80q50 0 85-35t35-85v-360q0-50-35-85t-85-35q-50 0-85 35t-35 85v360q0 50 35 85t85 35Zm300 80q29 0 49.5-20.5T730-230q0-22-12.5-40T684-296l-64-32v-232l100 100q23 23 51.5 35.5T832-412v-80q-17 0-32-6.5T773-517L633-657q-12-12-27.5-17.5T573-680h-13v520h100ZM360-720Z",Wr="M580-360q-25 0-42.5-17.5T520-420v-160q0-25 17.5-42.5T580-640h160q25 0 42.5 17.5T800-580v260q0 66-47 113t-113 47v-80q33 0 56.5-23.5T720-320v-40H580Zm-360 0q-25 0-42.5-17.5T160-420v-160q0-25 17.5-42.5T220-640h160q25 0 42.5 17.5T440-580v260q0 66-47 113t-113 47v-80q33 0 56.5-23.5T360-320v-40H220Z";function ao(e){if(e.kind==="comment")return Rn;if(e.kind==="custom")return e.item.icon??Wr;switch(e.revisionKind){case "insert":case "moveTo":return Yr;case "delete":case "moveFrom":return jr;case "format":return Zr;default:return Rn}}function Qr(e,t){return typeof t!="function"?e:typeof e!="function"?t:o=>{e(o),o.defaultPrevented||t(o);}}function Xr(e,t){let o={...e,...t};for(let n of Object.keys(e))/^on[A-Z]/.test(n)?o[n]=Qr(t[n],e[n]):n==="className"?o[n]=[e[n],t[n]].filter(Boolean).join(" "):n==="style"&&(o[n]={...e[n],...t[n]});return o}function An(e){return e==="Enter"||e===" "}function Jr(e){return An(e.key)?(e.preventDefault(),e.stopPropagation(),true):false}function En(e){return e.type==="button"}function ei(e,t){return e.type==="a"||t.href!=null}function ti(e,t,o,n){let r=i=>{typeof o=="function"&&o(i);};return {onClick:i=>{typeof e=="function"&&e(i),i.defaultPrevented||r(i),n&&i.preventDefault();},onKeyDown:i=>{if(typeof t=="function"&&t(i),!An(i.key))return;i.defaultPrevented||r(i),n&&i.preventDefault();}}}function he({engineDisabled:e,disabledReason:t,slotProps:o,children:n}){let r=Children.only(n);if(!isValidElement(r))return null;let i=r.props,s=Xr(o,i);if(!e){if(!En(r)){let a=ti(i.onClick,i.onKeyDown,o.onClick,ei(r,i));s.onClick=a.onClick,s.onKeyDown=a.onKeyDown;}return cloneElement(r,s)}if(En(r))s.disabled=true,delete s["aria-disabled"];else {delete s.disabled,s["aria-disabled"]=true,s["data-disabled"]="",s.tabIndex=-1,s.href=void 0,s.role===void 0&&(s.role="button");let a=s.onKeyDown;s.onKeyDown=l=>{Jr(l)||typeof a=="function"&&a(l);};}return t&&(s.title=t),s.onClick=a=>{a.preventDefault(),a.stopPropagation();},cloneElement(r,s)}var Nn=createContext({key:null,open:()=>{},close:()=>{}});function Sn({items:e,children:t}){let[o,n]=useState(null);useEffect(()=>{o!==null&&!e.some(i=>i.key===o&&i.kind==="comment"&&i.resolved)&&n(null);},[e,o]);let r=useMemo(()=>({key:o,open:i=>n(i),close:()=>n(null)}),[o]);return jsx(Nn.Provider,{value:r,children:t})}function so(){return useContext(Nn)}function _n({label:e,statusLabel:t,entryKey:o,badge:n=false,onActivate:r,onDeactivate:i,children:s,...a}){let l=so(),u=useRef(null);return useEffect(()=>{let m=f=>{let v=u.current;v?.open&&isDomNode(f.target)&&!v.contains(f.target)&&(l.close(),i());},c=hostDocumentOf(u.current);return c.addEventListener("pointerdown",m,true),()=>c.removeEventListener("pointerdown",m,true)},[l,i]),jsxs("details",{ref:u,...a,open:l.key===o,onToggle:m=>{m.currentTarget.open?(l.open(o),r()):(l.close(),i());},children:[jsxs("summary",{className:"docx-review__resolved-toggle","aria-label":e,children:[jsx("span",{className:"docx-review__resolved-status",children:t}),n?_t("",0,true):St()]}),s]})}function Mn(e){function t({className:n,asChild:r,hidden:i,children:s,icon:a}){let l=e.useReview(),u=e.useItem(),m=e.useLabel();if(i||!u||u.kind!=="comment"||u.resolved)return null;let c=m("comments.resolve"),f=l.commentResolutionDisabledReason!==null,v=f?m("editingMode.viewingHint"):null,d={type:"button",className:`docx-review__action${n?` ${n}`:""}`,"data-testid":"review-resolve","aria-label":c,title:v??c,disabled:f,onMouseDown:e.guardMousedown,onClick:p=>{p.stopPropagation(),!f&&l.resolve(u);}};return r?jsx(he,{engineDisabled:f,disabledReason:v,slotProps:d,children:s}):jsx("button",{...d,children:a??s??Y(Te)})}t.docxReviewPart="Resolve";function o({className:n,asChild:r,hidden:i,children:s,icon:a}){let l=e.useReview(),u=e.useItem(),m=e.useLabel();if(i||!u||u.kind!=="comment"||!u.resolved)return null;let c=m("comments.reopen"),f=l.commentResolutionDisabledReason!==null,v=f?m("editingMode.viewingHint"):null,d={type:"button",className:`docx-review__action${n?` ${n}`:""}`,"data-testid":"review-reopen","aria-label":c,title:v??c,disabled:f,onMouseDown:e.guardMousedown,onClick:p=>{p.stopPropagation(),!f&&l.reopen(u);}};return r?jsx(he,{engineDisabled:f,disabledReason:v,slotProps:d,children:s}):jsx("button",{...d,children:a??s??Y(bn)})}return o.docxReviewPart="Reopen",{ReviewResolve:t,ReviewReopen:o}}var lo=8;function Mt(e,t,o){let n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),i=e.closest(".docx-editor__scroll-container"),s=i?.getBoundingClientRect(),a=(s?.left??n.left)-n.left,l=i&&i.clientWidth>0?i.clientWidth:s?.width??0,u=e.ownerDocument.defaultView?.innerHeight??1/0,m=Number(e.dataset.reviewStart??e.dataset.start),c=Number(e.dataset.reviewEnd??e.dataset.end);return {revisionId:e.dataset.revisionId,...e.dataset.formattingKind?{formattingKind:e.dataset.formattingKind}:{},author:e.dataset.reviewAuthor??"",...e.dataset.revisionDate!==void 0?{date:e.dataset.revisionDate}:{},...e.dataset.revisionKind!==void 0?{kind:e.dataset.revisionKind}:{},structuralSite:o,...e.dataset.paragraphId!==void 0?{paragraphId:e.dataset.paragraphId}:{},...Number.isFinite(m)?{start:m}:{},...Number.isFinite(c)?{end:c}:{},left:r.left-n.left,right:r.right-n.left,top:r.top-n.top,bottom:r.bottom-n.top,above:r.bottom+220>u,rtl:e.ownerDocument.defaultView?.getComputedStyle(e).direction==="rtl",visibleLeft:a,visibleRight:l>0?a+l:Number.POSITIVE_INFINITY}}function kn(e,t){let o=e.visibleRight-e.visibleLeft-2*lo,n=Number.isFinite(o)&&o>0?Math.min(t,o):t,r=e.rtl?e.right-n:e.left,i=e.visibleLeft+lo,s=e.visibleRight-lo-n;return {left:Math.min(Math.max(r,i),Math.max(s,i)),width:n}}function ci(e,t,o){let n=null;for(let r of e.querySelectorAll("[data-revision-id]")){if(!isHTMLElementNode(r)||r.dataset.revisionId!==t.revisionId||r.closest("[data-docx-preview]")||(r.dataset.reviewAuthor??"")!==t.author||r.dataset.formattingKind!==t.formattingKind||r.classList.contains("docx-table-row--revision")!==t.structuralSite)continue;let i=Number(r.dataset.reviewStart??r.dataset.start);if(r.dataset.paragraphId===t.paragraphId&&i===t.start)return r;n??=r;}return n??(o?uo(e,o):null)}var ui=["left","right","top","bottom","above","rtl","visibleLeft","visibleRight"];function Dn(e,t,o,n){let r=ci(t,e,n);if(!r)return e;let i=Mt(r,o,e.structuralSite);return ui.every(s=>i[s]===e[s])?e:{...e,...i}}function Tn(e,t){let o=[];for(let n of e.querySelectorAll("[data-revision-id]"))!isHTMLElementNode(n)||n.dataset.revisionId!==t.revisionId||(n.dataset.reviewAuthor??"")===t.author&&n.dataset.formattingKind===t.formattingKind&&(t.date!==void 0&&n.dataset.revisionDate!==t.date||(n.dataset.reviewBalloonOpen="",o.push(n)));return ()=>{for(let n of o)delete n.dataset.reviewBalloonOpen;}}function kt(e,t="pane"){return e===void 0?false:t==="balloons"||e==="format"||e==="structural"}function On(e,t,o,n="pane",r=false){return e.kind!=="revision"||!kt(e.revisionKind,n)?false:n==="balloons"?r:!(o&&t.some(i=>i.id===e.id))}function di(e){return e.dataset.revisionKind!=="format"&&!e.classList.contains("docx-table-row--revision")}function uo(e,t){if(t.kind!=="revision"||t.item.kind!=="revision")return null;let o=t.item.addresses;if(o.length===0)return null;let n=new Set(o.map(i=>i.id)),r=t.item.formattingKind;for(let i of e.querySelectorAll("[data-revision-id]")){if(!isHTMLElementNode(i)||i.closest("[data-docx-preview]"))continue;let s=i.dataset.revisionId;if(!s||!n.has(s)||!o.some(u=>u.id===s&&u.author===(i.dataset.reviewAuthor??"")&&(u.date??"")===(i.dataset.revisionDate??"")))continue;let l=i.classList.contains("docx-table-row--revision");if(t.revisionKind==="structural"&&l||t.revisionKind==="format"&&i.dataset.revisionKind==="format"&&i.dataset.formattingKind===r||!kt(t.revisionKind)&&di(i))return i}return null}function Ln(e,t){let o=null,n=false,r=null,i=false,s=null,a=false;for(let l of t)if(!(l.kind!=="revision"||l.item.kind!=="revision")&&!(e.formattingKind&&l.item.formattingKind!==e.formattingKind)){for(let u of l.item.addresses)if(u.id===e.revisionId){if(u.author===e.author){if(u.date===e.date)return l;o===null?o=l:o!==l&&(n=true);}r===null?r=l:r!==l&&(i=true);}if(!(e.paragraphId===void 0||e.start===void 0||e.end===void 0||l.revisionKind!=="format"&&l.revisionKind!=="structural")){for(let u of l.item.ranges)if(u.start.paragraphId===e.paragraphId&&u.start.offset<e.end&&u.end.offset>e.start){s===null?s=l:s!==l&&(a=true);break}}}return o!==null&&!n?o:r!==null&&!i?r:s!==null&&!a?s:null}function Kn(e){return e.kind==="revision"&&e.item.kind==="revision"&&e.revisionKind==="format"&&e.item.ranges.length>0&&(e.item.formattingKind==="rPrChange"||e.item.formattingKind==="pPrChange")}var ot=createContext(null),L=createContext(null);function $n(){return useContext(L)}function Vn(e){let t=useContext(ot),o=useReviewAuthors();if(e!==void 0)return t?t.authorInfo.get(e):o.find(n=>n.author===e)}function j(){let e=useContext(ot);return e||Ri}function pi(e,t){return t?e.replace(/\{(\w+)\}/g,(o,n)=>Object.hasOwn(t,n)?String(t[n]):o):e}function Z(){let{t:e}=useContext(ot)??{},{t}=useTranslation();return useCallback((o,n)=>{let r=e?.(o);return r!==void 0?pi(r,n):t(o,n)},[e,t])}var Ri={t:void 0,cardClassName:void 0,readOnly:false,review:{items:[],activeKey:null,setActive:()=>false,accept:()=>false,reject:()=>false,adopt:()=>false,resolve:()=>false,reopen:()=>false,commentResolutionDisabledReason:null,remove:()=>false,reply:()=>false,selectionAnchorY:null,comment:()=>false,lastRefusal:null,activatedKey:null,paneOpen:true,setPaneOpen:()=>{},ready:false},allItems:[],authorSlots:new Map,authorInfo:new Map,draftAuthor:null,draftAuthorInfo:void 0,draftAuthorSlot:0,byId:new Map,measure:()=>{},beginDraft:()=>{},endDraft:()=>{},drafting:false,composeTop:null,composeLeft:null,commentMarkers:"icon",revisionsIn:"pane"};var vo=createContext(null),xi=e=>`${e.zoom}|${e.isLoading}|${e.isOpening??false}`,Ei=e=>!e.isLoading&&!e.isOpening&&e.parseError===null,Ai=e=>e.reviewPaneOpen??true;function Un(e,t){let o=useContext(vo),n=useContext(ReviewRailContext),r=useDocxEditor(),i=useEditorState(xi),s=useEditorState(Ei),a$1=useEditorState(Ai),l=useReviewGutter(),u=e!=null,[m,c$1]=useState(null);useEffect(()=>{let g=e?.current??null;c$1(x=>x===g?x:g);});let f$1=useMemo(()=>({current:m}),[m]),v=u&&m!==null&&(t?.reserveGutter??true);useEffect(()=>v?n?.reserveGutter?.():void 0,[n,v]);let d=At(u?r:null,f$1,i,m!==null,t?.trackScroll??false);useEffect(()=>{if(!u){o||g("called without a railRef outside DocxEditorReview, so it returns the initial value. Pass a ref to your column element, or call it inside DocxEditorReview.");return}if(!m||!s)return;let g$1=f(m);g$1&&g(g$1);},[u,o,m,s]);let p=c(a$1,l.inlineEnd,REVIEW_PANE_GUTTER),y=useMemo(()=>({...d,compact:p}),[d,p]);return u?m?y:a:o??a}var Fn=e=>e.isLoading||e.parseError!==null||e.pageSetup==null,Yn=e=>e.reviewPane.opening,jn=e=>e.reviewPane.revisionsIn,Zn=e=>e.reviewPane.commentMarkers,Wn=e=>e.editingMode==="viewing",Le="\0compose";var zn=Object.freeze({placement:false,pairReplacements:false}),Gn=Object.freeze({placement:false,pairReplacements:true});function nt(e,t){return e.kind!=="comment"?false:e.parentId!==void 0?t.has(e.parentId):e.parentRevisionId!==void 0?t.has(e.parentRevisionId):false}function rt(e){return new Set(e.map(t=>t.id))}function ne(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function Tt(e){let t=e.trim().split(/\s+/).filter(Boolean);return t.length===0?"?":t.slice(0,2).map(o=>o[0].toUpperCase()).join("")}var Ot=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function tr(e){function t(a){let{drafting:l,composeTop:u,composeLeft:m}=e.useRail();return a.hidden||!l?null:jsx(o,{...a,top:a.top??u??0,left:a.left===void 0?m:a.left})}t.docxReviewPart="Draft";function o({top:a,left:l$1=null,className:u}){let{review:m,endDraft:c,measure:f,readOnly:v,draftAuthor:d,draftAuthorInfo:p,draftAuthorSlot:y}=e.useRail(),g=e.useLabel(),[x,H]=useState(""),[D,K]=useState(false),[U,S]=useState(void 0),w=useDocxEditor(),A=useRef(null),k=useId();useEffect(()=>{v||A.current?.focus({preventScroll:true});},[]);let I=useCallback(()=>{if(v||x.trim().length===0)return;let T=m.comment(x.trim());K(!T),S(T||!w?void 0:n(w).get()?.code),T&&(H(""),c());},[v,x,m,c,w]);return useEffect(()=>{m.lastRefusal||U===void 0||(K(false),S(void 0));},[m.lastRefusal,U]),jsx("div",{className:`docx-review__slot${u?` ${u}`:""}${l$1===null?"":" docx-review__slot--compact"}`,style:{position:"absolute",top:a,...l$1===null?{}:{left:l$1,width:b}},ref:T=>{f(T,e.composeKey);},children:jsx("div",{className:"docx-review__card","data-testid":"review-draft","data-draft":"",...d?{"data-review-author":d,"data-review-author-slot":y}:{},style:ce(d??void 0,p,y),children:jsxs("form",{className:"docx-review__reply-box",onSubmit:T=>{T.preventDefault(),I();},children:[jsx("label",{className:"docx-editor-sr-only",htmlFor:k,children:g("comments.addComment")}),jsx("input",{id:k,ref:A,"data-testid":"review-draft-input",className:"docx-review__input",value:x,placeholder:g("comments.addComment"),readOnly:v,...D?{"aria-invalid":true}:{},onChange:T=>{v||(K(false),H(T.target.value));},onKeyDown:T=>{if(T.key==="Escape"){T.preventDefault(),c();return}v||T.key!=="Enter"||(T.preventDefault(),I());}}),jsxs("div",{className:"docx-review__reply-actions",children:[jsx("button",{type:"button","data-testid":"review-draft-cancel",className:"docx-review__text-button",onMouseDown:e.guardMousedown,onClick:c,children:g("common.cancel")}),jsx("button",{type:"submit","data-testid":"review-draft-submit",className:"docx-review__submit",disabled:v||x.trim().length===0,title:v?g("editingMode.viewingHint"):void 0,children:g("common.comment")})]}),D?jsx("span",{className:"docx-review__refused",children:g(l(U,"review.commentRefused"))}):null]})})})}function n$1(a){let{review:l,readOnly:u}=e.useRail(),[m,c]=useState(""),[f,v]=useState(false),[d,p]=useState(void 0),y=useDocxEditor(),g=useCallback(()=>{if(!a||u||m.trim().length===0)return;let x=l.reply(a,m.trim());v(!x),p(x||!y?void 0:n(y).get()?.code),x&&c("");},[a,u,m,l,y]);return useEffect(()=>{l.lastRefusal||d===void 0||(v(false),p(void 0));},[l.lastRefusal,d]),{draft:m,setDraft:c,refused:f,setRefused:v,refusedCode:d,submit:g}}function r({state:a,className:l$1,onCancel:u}){let{readOnly:m,draftAuthor:c,draftAuthorInfo:f,draftAuthorSlot:v}=e.useRail(),d=e.useLabel(),p=useId(),{draft:y,setDraft:g,refused:x,setRefused:H,submit:D}=a,K=l(a.refusedCode,"review.replyRefused"),U=f?.style?.avatarUrl;return jsxs("form",{className:`docx-review__reply-box${l$1?` ${l$1}`:""}`,"data-reply-line":"",onSubmit:S=>{S.preventDefault(),D();},children:[jsx("label",{className:"docx-editor-sr-only",htmlFor:p,children:d("comments.replyPlaceholder")}),c?jsx("span",{className:"docx-review__avatar docx-review__reply-avatar","data-testid":"review-reply-avatar","aria-hidden":"true",style:ce(c,f,v),children:U?jsx("img",{className:"docx-review__avatar-img",src:U,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer"}):Tt(c)}):null,jsx("input",{id:p,"data-testid":"review-reply-input",className:"docx-review__input",value:y,placeholder:d("comments.replyPlaceholder"),readOnly:m,...x?{"aria-invalid":true,"data-refused":""}:{},onChange:S=>{m||(H(false),g(S.target.value));},onClick:S=>S.stopPropagation(),onKeyDown:S=>{if(S.key==="Escape"&&!S.nativeEvent.isComposing){if(y.length>0){S.preventDefault(),g(""),H(false);return}if(u){S.preventDefault(),u();return}}m||S.key!=="Enter"||(S.preventDefault(),D());}}),y.length>0?jsx("button",{type:"button","data-testid":"review-reply-cancel",className:"docx-review__text-button",onMouseDown:e.guardMousedown,onClick:S=>{S.stopPropagation(),g(""),H(false),u?.();},children:d("common.cancel")}):null,jsx("button",{type:"submit","data-testid":"review-reply-submit",className:"docx-review__send","aria-label":d("review.reply"),disabled:m||y.trim().length===0,title:d(m?"editingMode.viewingHint":"review.reply"),children:Y(yn)}),x?jsx("span",{className:"docx-review__refused","data-testid":"review-reply-refused",children:d(K)}):null]})}function i({className:a,hidden:l,children:u}){let{review:m}=e.useRail(),c=e.useItem(),f=n$1(c);return l||!c||!c.isActive||c.kind==="comment"&&c.resolved?null:u?jsx(Fragment,{children:u}):jsx(r,{state:f,className:a,onCancel:()=>m.setActive(null)})}i.docxReviewPart="Reply";function s({entry:a,orphaned:l=false,onDraft:u}){let m=e.useLabel(),c=n$1(l?null:a),f=c.draft.trim().length>0;return useEffect(()=>u?.(f),[f,u]),jsxs(Fragment,{children:[jsx(r,{state:c}),l?jsx("span",{className:"docx-review__refused",role:"alert","data-testid":"review-reply-orphaned",children:m("review.replyTargetResolved")}):null]})}return {ReviewDraft:t,ReviewReply:i,ReviewBalloonReply:s}}function po(e,t,o=1){if(e==="paragraphMark"){let n=o>1;return t==="delete"?n?"revisions.paragraphMarksDeleted":"revisions.paragraphMarkDeleted":t==="moveFrom"?n?"revisions.paragraphMarksMovedFrom":"revisions.paragraphMarkMovedFrom":t==="moveTo"?n?"revisions.paragraphMarksMovedTo":"revisions.paragraphMarkMovedTo":n?"revisions.paragraphMarksInserted":"revisions.paragraphMarkInserted"}switch(e){case "insert":return "review.inserted";case "delete":return "review.deleted";case "replace":return "review.replaced";case "moveFrom":return "review.movedFrom";case "moveTo":return "review.movedTo";case "format":return "revisions.runPropertiesChanged";default:return "review.structural"}}function Pi(e){return po(e.revisionKind,e.markDirection,e.ranges.length)}function Ni(e){return e.revisionKind==="paragraphMark"&&e.ranges.length>1?` (${e.ranges.length})`:""}function it(e,t){if(e.revisionKind==="structural"&&e.structuralChanges?.length)return e.structuralChanges.map(i=>t(`revisions.structuralDetails.${i}`)).join(", ");let o=`${t(Pi(e))}${Ni(e)}`;if(e.revisionKind!=="format")return o;let r=[...(e.formattingLanguages??[]).map(i=>{try{return new Intl.DisplayNames([t("_lang")],{type:"language"}).of(new Intl.Locale(i).minimize().toString())??i}catch{return i}}),...(e.formattingChanges??[]).map(i=>Si(i,t))];return r.length?`${o}: ${r.join(", ")}`:o}function Si(e,t){let{property:o,value:n}=e;if(n!==null&&(o==="bold"||o==="italic"||o==="strike"))return t(`revisions.formattingDetails.${n==="true"?o:{bold:"notBold",italic:"notItalic",strike:"notStrike"}[o]}`);let r=n??t("revisions.formattingDetails.default");return n!==null&&(["fontSize","leftIndent","rightIndent","firstLineIndent","hangingIndent","spaceBefore","spaceAfter"].includes(o)?r=`${n} ${t("revisions.formattingDetails.points")}`:(o==="direction"?n==="rtl"||n==="ltr":/^(left|center|right|both|start|end|none|single|double|auto)$/.test(n))?r=t(`revisions.formattingDetails.${n}`):o==="color"&&/^[0-9a-f]{6}$/i.test(n)&&(r=`#${n.toUpperCase()}`)),`${t(`revisions.formattingDetails.${o}`)}: ${r}`}var{ReviewResolve:wo,ReviewReopen:yo}=Mn({useReview:()=>j().review,useItem:()=>useContext(L),useLabel:Z,guardMousedown:ne}),{ReviewDraft:bo,ReviewReply:go,ReviewBalloonReply:nr}=tr({useRail:j,useItem:()=>useContext(L),useLabel:Z,guardMousedown:ne,composeKey:Le});function at({className:e,hidden:t,children:o}){let n=Z();return t?null:jsx("div",{className:`docx-review__empty${e?` ${e}`:""}`,"data-testid":"review-empty",children:o??n("review.empty")})}at.docxReviewPart="Empty";function $e({className:e,asChild:t,hidden:o,children:n}){let{review:r,authorSlots:i,authorInfo:s,commentMarkers:a}=j(),l=useContext(L),u=useId(),m=Z();if(o||!l)return null;let c=i.get(l.author)??0,f=!t&&l.kind==="comment"&&l.resolved,v={className:`docx-review__card${e?` ${e}`:""}`,"data-testid":"review-card",...f?{}:{"aria-labelledby":`${u}-author ${u}-summary`},"data-kind":l.kind==="revision"?l.revisionKind??"revision":l.kind,...l.author?{"data-review-author":l.author,"data-review-author-slot":Ce(s.get(l.author),c)}:{},...l.kind==="custom"&&l.item.kind==="custom"?{"data-node-name":l.item.name}:{},...l.isActive?{"data-active":""}:{},...l.kind==="comment"&&l.resolved?{"data-resolved":""}:{},...f?{"data-resolved-miniature":""}:{},style:ce(l.author,s.get(l.author),c),...f?{}:{tabIndex:0,role:"button"},id:u,...f?{}:{onMouseDown:d=>{q(d.target)||d.currentTarget.focus({preventScroll:true});},onClick:d=>{!p(d.target)&&!l.isActive&&r.setActive(l.key);},onKeyDown:d=>{d.target===d.currentTarget&&(d.key!=="Enter"&&d.key!==" "||(d.preventDefault(),r.setActive(l.key)));}}};return t?jsx(Slot,{...v,children:n}):f?jsx(_n,{...v,label:m("review.showResolvedComment"),statusLabel:m("review.resolved"),entryKey:l.key,badge:a==="initials",onActivate:()=>r.setActive(l.key),onDeactivate:()=>r.setActive(null),children:jsx(or,{children:n})}):jsx("div",{...v,children:jsx(or,{children:n})})}$e.docxReviewPart="Card";function or({children:e}){let t=useContext(L),o=useMemo(()=>Ti(e),[e]),n=(i,s)=>i in o?o[i]:s;if(!t)return null;if(t.kind==="custom"&&t.item.kind==="custom"){let i=t.item;return jsxs(Fragment,{children:[jsxs("div",{className:"docx-review__head",children:[n("Avatar",null),jsx("div",{className:"docx-review__meta",children:n("Author",jsx("span",{className:"docx-review__author","data-testid":"review-custom-title",children:i.title}))})]}),n("Summary",i.detail?jsx("div",{className:"docx-review__summary","data-testid":"review-summary","data-review-selectable":"",children:jsx("span",{className:"docx-review__text",children:i.detail})}):null),o.__extra]})}let r=t.kind==="revision"&&!t.readOnly;return jsxs(Fragment,{children:[jsxs("div",{className:"docx-review__head",children:[n("Avatar",jsx(xe,{})),jsxs("div",{className:"docx-review__meta",children:[n("Author",jsx(Ee,{})),n("Time",jsx(Ae,{}))]}),r||t.kind==="comment"?jsxs("div",{className:"docx-review__actions",children:[n("Accept",jsx(qe,{})),n("Reject",jsx(Be,{})),n("Resolve",jsx(wo,{})),n("Reopen",jsx(yo,{})),n("Delete",t.kind==="comment"?jsx(st,{}):null)]}):null]}),n("Summary",jsx(Re,{})),n("Refusal",jsx(Ve,{})),n("Replies",jsx(Ue,{})),n("Reply",jsx(go,{})),o.__extra]})}function Ti(e){let t={},o=[],n=r=>{if(Array.isArray(r)){r.forEach(n);return}if(!r||typeof r!="object"||!("type"in r)){r&&o.push(r);return}if(r.type===Fragment$1){n(r.props.children);return}let i=r.type.docxReviewPart;i?t[i]=r:o.push(r);};return n(e),o.length>0&&(t.__extra=o),t}function Ve({className:e,asChild:t,hidden:o,children:n}){let{review:r}=j(),i=useContext(L),s=Z(),a=r.lastRefusal;if(o||!i||!a||a.key!==i.key||a.action==="reply")return null;let l$1={className:`docx-review__refused${e?` ${e}`:""}`,"data-testid":"review-refusal","data-refusal-code":a.code};return t?jsx(Slot,{...l$1,children:n}):jsx("p",{...l$1,children:n??s(l(a.code,"review.actionRefused",a.final))})}Ve.docxReviewPart="Refusal";function Co(){let{review:e}=j(),t=Z(),o=e.lastRefusal;return jsx("span",{className:"docx-editor-sr-only","aria-live":"polite","data-testid":"review-refusal-live",children:o?jsx("span",{children:t(l(o.code,m(o.action),o.final))},o.sequence):null})}function xe({className:e,asChild:t,hidden:o,children:n}){let{authorInfo:r}=j(),i=useContext(L);if(o||!i||n===void 0&&!i.initials)return null;let s={className:`docx-review__avatar${e?` ${e}`:""}`,"data-testid":"review-avatar","aria-hidden":true};if(t)return jsx(Slot,{...s,children:n});let a=r.get(i.author)?.style?.avatarUrl,l=n??(a?jsx("img",{className:"docx-review__avatar-img",src:a,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer"}):void 0)??i.initials;return jsx("span",{...s,children:l})}xe.docxReviewPart="Avatar";function Ee({className:e,asChild:t,hidden:o,children:n}){let r=useContext(L),i=Z();if(o||!r)return null;let s=r.author||i("comments.unknown"),a={className:`docx-review__author${e?` ${e}`:""}`,"data-testid":"review-author"};return t?jsx(Slot,{...a,children:n}):jsx("span",{...a,children:n??s})}Ee.docxReviewPart="Author";function Ae({className:e,asChild:t,hidden:o,children:n}){let r=useContext(L);if(o||!r)return null;let i=r.date;if(!i)return null;let s=new Date(i);if(Number.isNaN(s.getTime()))return null;let a={className:`docx-review__time${e?` ${e}`:""}`,"data-testid":"review-time",dateTime:i};return t?jsx(Slot,{...a,children:n}):jsx("time",{...a,children:n??Ot.format(s)})}Ae.docxReviewPart="Time";function Re({className:e,asChild:t,hidden:o,children:n}){let r=useContext(L),i=Z();if(o||!r)return null;let s=r.text,a=r.kind!=="revision"?null:it(r.item,i),l=r.kind==="revision"&&r.revisionKind==="replace",u={className:`docx-review__summary${e?` ${e}`:""}`,"data-testid":"review-summary","data-review-selectable":""};return t?jsx(Slot,{...u,children:n}):jsx("div",{...u,children:n??(l?jsxs("span",{className:"docx-review__text",children:[i("review.replaced")," ",jsxs("span",{className:"docx-review__removed",children:['"',r.replacedText,'"']})," ",i("review.replacedWith")," ",jsxs("span",{className:"docx-review__added",children:['"',s,'"']})]}):jsxs(Fragment,{children:[a?jsx("span",{className:"docx-review__label","data-kind":r.kind==="revision"?r.revisionKind:"revision",children:a}):null,s?jsx("span",{className:"docx-review__text",children:s}):null]}))})}Re.docxReviewPart="Summary";function qe({className:e,asChild:t,hidden:o,children:n,icon:r}){let{readOnly:i,review:s}=j(),a=useContext(L),l=Z();if(o||!a||a.kind!=="revision"||a.readOnly)return null;let u=l("review.accept"),m=i?l("editingMode.viewingHint"):null,c={type:"button",className:`docx-review__action${e?` ${e}`:""}`,"data-testid":"review-accept","aria-label":u,title:m??u,disabled:i,onMouseDown:ne,onClick:f=>{f.stopPropagation(),!i&&s.accept(a);}};return t?jsx(he,{engineDisabled:i,disabledReason:m,slotProps:c,children:n}):jsx("button",{...c,children:r??n??Y(Te)})}qe.docxReviewPart="Accept";function Be({className:e,asChild:t,hidden:o,children:n,icon:r}){let{readOnly:i,review:s}=j(),a=useContext(L),l=Z();if(o||!a||a.kind!=="revision"||a.readOnly)return null;let u=l("review.reject"),m=i?l("editingMode.viewingHint"):null,c={type:"button",className:`docx-review__action${e?` ${e}`:""}`,"data-testid":"review-reject","aria-label":u,title:m??u,disabled:i,onMouseDown:ne,onClick:f=>{f.stopPropagation(),!i&&s.reject(a);}};return t?jsx(he,{engineDisabled:i,disabledReason:m,slotProps:c,children:n}):jsx("button",{...c,children:r??n??Y(gn)})}Be.docxReviewPart="Reject";function st({className:e,asChild:t,hidden:o,children:n,icon:r}){let{readOnly:i,review:s}=j(),a=useContext(L),{t:l}=useTranslation();if(o||!a||a.kind==="custom"||a.kind==="revision"&&a.readOnly)return null;let u=a.kind==="comment"?l("review.deleteComment"):l("review.discardChange"),m=i?l("editingMode.viewingHint"):null,c={type:"button",className:`docx-review__action${e?` ${e}`:""}`,"data-testid":"review-delete","aria-label":u,title:m??u,disabled:i,onMouseDown:ne,onClick:f=>{f.stopPropagation(),!i&&s.remove(a);}};return t?jsx(he,{engineDisabled:i,disabledReason:m,slotProps:c,children:n}):jsx("button",{...c,children:r??n??Y(Cn)})}st.docxReviewPart="Delete";function Ue({className:e,hidden:t}){let{byId:o,authorSlots:n,authorInfo:r}=j(),i=useContext(L);if(t||!i||i.kind==="custom")return null;let s=i.replyIds.map(a=>o.get(a)).filter(a=>a!==void 0);return s.length===0?null:jsx("ol",{className:`docx-review__replies${e?` ${e}`:""}`,children:s.map(a=>jsx(L.Provider,{value:a,children:jsxs("li",{className:"docx-review__reply","data-testid":"review-reply",...a.author?{"data-review-author":a.author,"data-review-author-slot":Ce(r.get(a.author),n.get(a.author)??0)}:{},style:ce(a.author,r.get(a.author),n.get(a.author)??0),children:[jsxs("div",{className:"docx-review__head",children:[jsx(xe,{}),jsxs("div",{className:"docx-review__meta",children:[jsx(Ee,{}),jsx(Ae,{})]}),jsx("div",{className:"docx-review__actions",children:jsx(st,{})})]}),jsx(Re,{})]})},a.key))})}Ue.docxReviewPart="Replies";function lt({stack:e=true,positions:t,collapsed:o,scale:n=1,offset:r=0,window:i=null,children:s,className:a,hidden:l}){let{review:u,measure:m,cardClassName:c}=j();if(l)return null;let f=typeof s=="function"?null:tt(s,"list"),v=rt(u.items),d=u.items.filter(p=>!nt(p,v));return d.length===0?typeof s=="function"?null:f?.parts.Empty??jsx(at,{}):jsx("div",{className:`docx-review__list${a?` ${a}`:""}`,children:d.map(p=>{let y=e?t?.get(p.key)??p.anchorY:p.anchorY,g=y==null?null:r+y*n;if(g!==null&&i&&(g<i.top||g>i.bottom))return null;let x=g===null?{}:{position:"absolute",top:g};return jsx(L.Provider,{value:p,children:jsx("div",{className:"docx-review__slot",style:x,...o?.has(p.key)?{"data-collapsed":""}:{},ref:H=>{m(H,p.key);},children:typeof s=="function"?s(p):f?.parts.Card&&isValidElement(f.parts.Card)?xt(f.parts.Card,c):jsx($e,{...c?{className:c}:{},children:f?.rest})})},p.key)})})}lt.docxReviewPart="List";function Ht({scale:e=1,offset:t=0,window:o=null,className:n,hidden:r,icon:i}){let{review:s,authorSlots:a,authorInfo:l,commentMarkers:u}=j(),m=so(),c=Z(),{roots:f,stackedTops:v}=useMemo(()=>{let d=rt(s.items),p=s.items.filter(x=>!nt(x,d)),y=new Map,g=Number.NEGATIVE_INFINITY;for(let x of p){if(x.anchorY===null)continue;let H=Math.max(t+x.anchorY*e,g);y.set(x.key,H),g=H+30;}return {roots:p,stackedTops:y}},[s.items,t,e]);return r?null:jsx("div",{className:`docx-review__markers${n?` ${n}`:""}`,children:f.map(d=>{let p=v.get(d.key);if(p===void 0||o&&(p<o.top||p>o.bottom))return null;let y=typeof i=="function"?i(d):i,g=y==null&&u==="initials"&&d.kind==="comment";return jsx("button",{type:"button",className:"docx-review__marker","data-testid":"review-marker","data-kind":d.kind==="revision"?d.revisionKind:d.kind,...g?{"data-marker":"initials"}:{},...d.author?{"data-review-author":d.author,"data-review-author-slot":Ce(l.get(d.author),a.get(d.author)??0)}:{},style:{position:"absolute",top:p,...d.author?{"--doc-review-author-current":io(l.get(d.author),a.get(d.author)??0)}:{}},title:d.author?`${d.author}: ${d.text}`:d.text,"aria-label":Bi(d,c),onMouseDown:ne,onClick:()=>{d.kind==="comment"&&d.resolved&&m.open(d.key),s.setPaneOpen(true),s.setActive(d.key);},children:y??(d.kind!=="comment"?Y(ao(d)):g?_t(d.initials,d.replyIds.length,d.resolved):d.resolved?St():Y(ao(d)))},d.key)})})}Ht.docxReviewPart="Markers";function Bi(e,t){let o=[`${t("review.showPane")}: ${e.author?`${e.author}. `:""}${e.text}`];return e.kind==="comment"&&e.resolved&&o.push(t("review.resolved")),e.kind==="comment"&&e.replyIds.length>0&&o.push(t("review.replyCount",{count:e.replyIds.length})),o.join(". ")}function $t({top:e=null,drafting:t=false,className:o,hidden:n,children:r}){let{beginDraft:i,readOnly:s}=j(),a=Z();if(n||t||e===null||s)return null;let l={type:"button",className:`docx-review__add${o?` ${o}`:""}`,"data-testid":"review-add-comment",style:{position:"absolute",top:e},"aria-label":a("common.comment"),title:a("common.comment"),onMouseDown:ne,onClick:i};return r?jsx(Slot,{...l,children:r}):jsx("button",{...l,children:Y(wn)})}$t.docxReviewPart="AddComment";function Vt({className:e,hidden:t}){let o=useDocxEditor(),n=useRef(o);n.current=o;let{review:r,allItems:i,authorSlots:s,authorInfo:a,revisionsIn:l}=j(),u=Z(),m=useRef(null),[c,f]=useState(null),v=useRef(null),d=useEditorState(h=>h.reviewDisplayMode??"all-markup"),p=r.activatedKey!==null;useEffect(()=>{v.current=null,f(null);},[d]);let[y,g]=useState(0),x=useRef(false),H=useRef(null);useEditorEvent("reviewItemReveal",()=>{x.current=A.current==="balloons",g(h=>h+1);});let D=i.find(h=>h.isActive)??null,K=useRef(D);K.current=D;let U=D?.key??null,S=D!==null&&On(D,r.items,r.paneOpen,l,p),w=useRef(false);w.current=c!==null;let A=useRef(l);A.current=l;let k=useMemo(()=>c?Ln(c,i):null,[i,c]),I=k&&kt(k.revisionKind,l)?k:null,T=useRef(null);T.current=I?.key??null,useEffect(()=>{let h=m.current,_=h?.closest(".docx-review"),O=_?.closest(".docx-editor__scroll-container")??_?.offsetParent;if(!h||!_||!O)return;let $=()=>{v.current=null,f(null);},G=F=>{let le=F.target;if(!isElementNode(le)||h.contains(le))return;x.current=false;let me=le.closest("[data-revision-id]");if(isHTMLElementNode(me)&&O.contains(me)){let fe=me.classList.contains("docx-table-row--revision");if(me.dataset.revisionKind==="format"||fe||A.current==="balloons"){v.current=null,f(Mt(me,_,fe));return}}w.current&&$();},B=F=>{A.current!=="balloons"||!w.current||isDomNode(F.target)&&h.contains(F.target)||$();},ie=F=>{if(F.key!=="Escape"||F.defaultPrevented||F.isComposing||A.current!=="balloons"||!w.current||!isDomNode(F.target)||!O.contains(F.target))return;let le=h.contains(h.ownerDocument.activeElement);$(),le&&n.current?.focus();};return O.addEventListener("pointerdown",G,true),O.addEventListener("mousedown",G,true),O.addEventListener("beforeinput",B,true),h.ownerDocument.addEventListener("keydown",ie),()=>{O.removeEventListener("pointerdown",G,true),O.removeEventListener("mousedown",G,true),O.removeEventListener("beforeinput",B,true),h.ownerDocument.removeEventListener("keydown",ie);}},[]),useEffect(()=>{let h=m.current,_=h?.closest(".docx-review"),O=_?.closest(".docx-editor__scroll-container")??_?.offsetParent;if(!h||!_||!O)return;let $=K.current;if(!$){v.current!==null&&(v.current=null,f(null));return}if(!S){if(l==="balloons"&&T.current===$.key)return;v.current=null,f(null);return}if(w.current&&v.current===$.key)return;v.current=$.key,f(null);let G=false,B=hostWindowOf(O),ie=B.requestAnimationFrame(()=>{if(G)return;let F=uo(O,$);if(!F){f(null);return}f(Mt(F,_,F.classList.contains("docx-table-row--revision")));});return ()=>{G=true,B.cancelAnimationFrame(ie);}},[d,U,S,l,y]);let Q=useEditorState(h=>h.zoom),[we,ft]=useState(0);useEditorEvent("change",()=>ft(h=>h+1));let q=useRef(I);q.current=I;let Se=c!==null;useEffect(()=>{if(!Se)return;let h=m.current?.closest(".docx-review"),_=h?.closest(".docx-editor__scroll-container")??h?.offsetParent;if(!h||!_)return;let O=()=>f(ie=>ie&&Dn(ie,_,h,q.current)),$=hostWindowOf(_),G=$.requestAnimationFrame(O),B=typeof $.ResizeObserver>"u"?null:new $.ResizeObserver(()=>{$.cancelAnimationFrame(G),G=$.requestAnimationFrame(O);});return B?.observe(_),()=>{$.cancelAnimationFrame(G),B?.disconnect();}},[Se,Q,we]),useEffect(()=>{if(!c)return;let h=m.current?.closest(".docx-review"),_=h?.closest(".docx-editor__scroll-container")??h?.offsetParent;return _?Tn(_,c):void 0},[c,we]);let _e=useRef(false),Ze=useRef(null);I&&(Ze.current=I);let We=useRef(false),z=!I&&c!==null&&l==="balloons"&&We.current?Ze.current:null,de=useRef(z);de.current=z;let vt=useCallback(h=>{We.current=h,!h&&de.current!==null&&f(null);},[]);useEffect(()=>{if(I){_e.current=true;return}_e.current&&(_e.current=false,de.current===null&&f(null));},[I]);let M=I??z,pt=c!==null&&l==="balloons"?I?.key:void 0;if(useEffect(()=>{pt===void 0||!x.current||(x.current=false,H.current?.focus({preventScroll:true}));},[pt,y]),t)return null;let ze=c?.kind==="format"?"format":"structural",Rt=c!==null&&!M&&c.kind!=="format"&&!c.structuralSite,P=l==="balloons"&&M!==null,se=I===null&&z!==null,wt=c?kn(c,P?300:280):null,X=!(c===null||d!=="all-markup"||Rt||M&&r.items.some(h=>h.id===M.id)&&r.paneOpen),Ge=X&&P&&I&&I.item.kind==="revision"?u("review.changeAnnouncement",{change:it(I.item,u),author:I.author||u("comments.unknown"),text:I.text}):"";return jsxs("div",{ref:m,className:`docx-review__balloon-root${e?` ${e}`:""}`,children:[jsx("span",{className:"docx-editor-sr-only","aria-live":"polite","data-testid":"review-balloon-live",children:Ge}),!X||c===null?null:jsx("div",{className:"docx-review__balloon","data-testid":"review-balloon",...P?{"data-variant":"change"}:{},style:{left:wt.left,width:wt.width,top:c.above?c.top-6:c.bottom+6,transform:c.above?"translateY(-100%)":void 0},onMouseDown:ne,children:M?jsx(L.Provider,{value:M,children:jsxs("div",{className:"docx-review__card","data-testid":"review-balloon-card","data-kind":M.revisionKind??"revision",...M.author?{"data-review-author":M.author,"data-review-author-slot":Ce(a.get(M.author),s.get(M.author)??0)}:{},...P?{ref:H,role:"dialog",tabIndex:-1,"aria-label":u("review.trackedChange")}:{},style:ce(M.author,a.get(M.author),s.get(M.author)??0),onClick:P||se?void 0:()=>r.setActive(M.key),children:[jsxs("div",{className:"docx-review__head",children:[jsx(xe,{}),jsxs("div",{className:"docx-review__meta",children:[jsx(Ee,{}),jsx(Ae,{})]}),M.kind==="revision"&&!M.readOnly&&!se?jsxs("div",{className:"docx-review__actions",children:[jsx(qe,{}),jsx(Be,{})]}):null]}),P?jsx(Ui,{entry:M}):jsx(Re,{}),jsx(Ve,{}),P?jsxs(Fragment,{children:[jsx(Ue,{}),jsx(nr,{entry:M,orphaned:se,onDraft:vt},M.key)]}):null]})}):jsxs("div",{className:"docx-review__card","data-testid":"review-balloon-card","data-kind":ze,...c.author?{"data-review-author":c.author,"data-review-author-slot":Ce(a.get(c.author),s.get(c.author)??0)}:{},style:ce(c.author,a.get(c.author),s.get(c.author)??0),children:[jsxs("div",{className:"docx-review__head",children:[jsx("span",{className:"docx-review__avatar","aria-hidden":"true",children:Tt(c.author)}),jsxs("div",{className:"docx-review__meta",children:[jsx("span",{className:"docx-review__author",children:c.author||u("comments.unknown")}),c.date?jsx(Fi,{raw:c.date}):null]})]}),jsx("div",{className:"docx-review__summary",children:jsx("span",{className:"docx-review__label","data-kind":ze,children:u(po(ze))})})]})})]})}Vt.docxReviewPart="Balloon";function Ui({entry:e}){let t=Z(),o=e.revisionKind;if(o==="replace")return jsxs("div",{className:"docx-review__summary","data-testid":"review-summary","data-review-selectable":"",children:[jsx("span",{className:"docx-review__label","data-kind":"replace",children:t("review.replaced")})," ",jsx("del",{className:"docx-review__removed",children:e.replacedText})," ",jsx("ins",{className:"docx-review__added",children:e.text})]});let n=o==="insert"||o==="moveTo";return !n&&o!=="delete"&&o!=="moveFrom"?jsx(Re,{}):jsxs("div",{className:"docx-review__summary","data-testid":"review-summary","data-review-selectable":"",children:[jsx("span",{className:"docx-review__label","data-kind":o,children:it(e.item,t)})," ",n?jsx("ins",{className:"docx-review__added",children:e.text}):jsx("del",{className:"docx-review__removed",children:e.text})]})}function Fi({raw:e}){let t=new Date(e);return Number.isNaN(t.getTime())?null:jsx("time",{className:"docx-review__time",dateTime:e,children:Ot.format(t)})}function la({className:e,furniture:t,asChild:o$1,hidden:n,children:r,t:i$1,card:s,preset:a=true,stack:l=true,gap:u=8,filter:m,structural:c$1=true,formatting:f=false}){let v=useDocxEditor(),d=useEditorState(Fn),p=useEditorState(Wn),y=useEditorState(jn),g=useEditorState(Zn),x=useMemo(()=>{let R=[];return c$1||R.push("structural"),f||R.push("format"),R.length>0?R:void 0},[c$1,f]),H=useMemo(()=>({excludeRevisionKinds:x?.filter(R=>R!=="format"),pairReplacements:false}),[x]);useEffect(()=>(v?.setReviewActivationExclusions(x??null,{formattingKinds:["rPrChange","pPrChange"]}),()=>v?.setReviewActivationExclusions(null)),[v,x]);let D=Nt(y==="balloons"?Gn:zn),K=Nt(H),U=K.setPaneOpen,{t:S}=useTranslation(),w=useCallback(R=>i$1?.(R)??S(R),[i$1,S]),A=useRef(null),k=useContext(ReviewRailContext);useEffect(()=>k?.register(),[k]);let I=K.paneOpen,T=useReviewGutter(),Q=c(I,T.inlineEnd,REVIEW_PANE_GUTTER),we=I&&!Q,ft=useMemo(()=>y==="balloons"?new Map(D.items.map(R=>[R.id,R])):null,[D.items,y]),q=useMemo(()=>K.items.filter(R=>reviewPaneListsItem(y,ft?.get(R.id)??R)&&(f||!Kn(R))&&(!m||m(R))),[K.items,m,f,y,ft]),Se=useRef(q);Se.current=q;let _e=useEditorState(Yn),Ze=useRef(_e);Ze.current=_e,useEditorEvent("reviewItemReveal",({key:R})=>{n||Ze.current==="manual"||Se.current.some(C=>C.key===R)&&U(true);});let We=useRef(I);We.current=I,useEffect(()=>{let R=A.current;if(!(!v||!R||d||n))return o(R,v,C=>{We.current||Se.current.some(N=>N.key===C)&&U(true);})},[v,d,n,U]);let z=useSyncExternalStore(useCallback(R=>v?.on("selectionChange",R)??(()=>{}),[v]),()=>v?.getConfiguredAuthor()??null,()=>null),de=useMemo(()=>{let R=new Map;for(let C of q)C.author&&!R.has(C.author)&&R.set(C.author,R.size);return z&&!R.has(z)&&R.set(z,R.size),R},[q,z]),vt=useMemo(()=>{let R=new Map;for(let C of q)R.set(C.id,C);if(y==="balloons")for(let C of D.items)R.has(C.id)||R.set(C.id,C);return R},[q,y,D.items]),[M,pt]=useState(()=>new Map),ze=useCallback((R,C)=>{C<=0||pt(N=>{if(N.get(R)===C)return N;let pe=new Map(N);return pe.set(R,C),pe});},[]),Rt=fn(ze),P=At(v,A,q,!d&&!n,Q),se=dn(v,A,!d&&!n),wt=useMemo(()=>({...P,compact:Q}),[P,Q]);useEffect(()=>{let R=A.current;if(!v||!R)return;let C=pe=>{let gt=pe.target;if(!isDomNode(gt)||R.contains(gt))return;let zt=R.offsetParent;!zt||!zt.contains(gt)||zt.querySelector(".docx-paginated-surface")?.contains(gt)||v.setActiveReviewItem(null);},N=hostDocumentOf(R);return N.addEventListener("mousedown",C,true),()=>N.removeEventListener("mousedown",C,true)},[v,d,n]);let[X,Ge]=useState(null),h=useRef(null),_=useCallback(()=>{let R=h.current;R&&(R.editor.releaseSelection(R.pin),h.current=null);},[]),O=useCallback(()=>{if(!v||p)return;let R=v.getSelectionPlacement()?.anchorY??null;if(R===null)return;_();let C=v.retainSelection();C&&(h.current={editor:v,pin:C},U(true),Ge(R));},[v,p,_,U]);useEffect(()=>{if(!(n||p))return k?.registerCommentDraft(O)},[O,n,p,k]);let $=useCallback(()=>{_(),Ge(null),v?.focus();},[v,_]);useEffect(()=>_,[_]),useEffect(()=>{I||X===null||(_(),Ge(null));},[I,X,_]);let G=X??K.selectionAnchorY,B=useMemo(()=>{let R=rt(q);return q.filter(C=>!nt(C,R))},[q]),ie=useMemo(()=>{if(X===null)return B;let R=B.findIndex(N=>N.anchorY!==null&&N.anchorY>X),C={key:Le,anchorY:X};return R===-1?[...B,C]:[...B.slice(0,R),C,...B.slice(R)]},[B,X]),F=useMemo(()=>{let R=new Map(M);for(let C of B){if(R.has(C.key))continue;let N=C.text.length+(C.kind==="revision"?C.replacedText?.length??0:0),pe=Math.min(6,Math.max(1,Math.ceil(N/36)));R.set(C.key,64+pe*20);}return R},[M,B]),{stacked:le,collapsedKeys:me}=useMemo(()=>{let{positions:R,collapsed:C}=i(ie.map(N=>({key:N.key,anchorY:N.anchorY,isActive:"isActive"in N&&N.isActive})),{gap:u,scale:P.scale,collapseAfterPx:480,heightOf:(N,pe)=>pe?64:F.get(N)??72,collapsible:N=>N.key!==Le});return {stacked:R,collapsedKeys:C}},[ie,F,u,P.scale]),fe=G===null?null:P.top+(Q?G:le.get(Le)??G)*P.scale,Qe=s?.className,Er=useReviewAuthors(),Zt=pn(Er,q,de,v),ko=z?de.get(z)??0:0,Do=z?Zt.get(z):void 0,Ar=useMemo(()=>({t:i$1,cardClassName:Qe,readOnly:p,review:{...K,items:q},allItems:D.items,authorSlots:de,authorInfo:Zt,draftAuthor:z,draftAuthorInfo:Do,draftAuthorSlot:ko,byId:vt,measure:Rt,beginDraft:O,endDraft:$,drafting:X!==null,composeTop:fe,composeLeft:Q?P.compactCardLeft:null,commentMarkers:g,revisionsIn:y}),[i$1,Qe,p,K,D.items,q,de,Zt,z,Do,ko,vt,Rt,O,$,X,fe,Q,P.compactCardLeft,g,y]);if(n||d)return null;let To={ref:A,className:`docx-review${e?` ${e}`:""}`,"data-testid":"review-rail","data-count":q.length,"data-open":we?"":void 0,"data-compact":Q?"":void 0,role:"region","aria-label":w("review.ariaLabel"),onMouseDown:ne,style:P.left===null?void 0:{left:P.left,right:"auto"}},ye=typeof r=="function"?{parts:{},rest:r}:tt(r,"root"),ve=ye.parts,Xe=(R,C)=>{if(!(R in ve))return C;let N=ve[R];return !isValidElement(N)||!isValidElement(C)?N:cloneElement(N,{...C.props,...N.props})},Oo=jsxs(Fragment,{children:[a||"AddComment"in ve?Xe("AddComment",jsx($t,{top:fe,drafting:X!==null})):null,!I||X===null||fe===null||!a&&!("Draft"in ve)?null:Xe("Draft",jsx(bo,{top:fe,left:Q?P.compactCardLeft:null})),a||"Balloon"in ve?Xe("Balloon",jsx(Vt,{})):null]}),Ir=jsx(lt,{stack:l,positions:le,collapsed:me,scale:P.scale,offset:P.top,window:se,children:ye.rest}),Lo=jsx(Ht,{scale:P.scale,offset:P.top,window:se}),be=Q?B.find(R=>R.key===K.activeKey)??null:null,Ko=be===null?null:be.anchorY!==null?P.top+be.anchorY*P.scale:se!==null?se.top+Et+24:null,Wt=ln(ye.rest,ve.List),yt=o$1?null:Wt.template,bt=typeof yt=="function"?null:tt(yt,"list"),Ho=Wt.hidden?null:typeof yt=="function"?be&&yt(be):bt?.parts.Card&&isValidElement(bt.parts.Card)?xt(bt.parts.Card,Qe):a||Wt.fromList?jsx($e,{...Qe?{className:Qe}:{},children:bt?.rest}):null,$o=be&&Ko!==null&&P.compactCardLeft!==null&&Ho?jsx(L.Provider,{value:be,children:jsx("div",{className:"docx-review__slot docx-review__slot--compact","data-testid":"review-compact-card",style:{position:"absolute",top:Ko,left:P.compactCardLeft,width:b},children:Ho})}):null,Pr=we?a||"List"in ve?Xe("List",Ir):typeof ye.rest=="function"?null:ye.rest:a||"Markers"in ve?jsxs(Fragment,{children:[Xe("Markers",Lo),$o]}):typeof ye.rest=="function"?null:ye.rest;return jsx(Sn,{items:q,children:jsx(ot.Provider,{value:Ar,children:jsx(vo.Provider,{value:wt,children:o$1&&isValidElement(r)?jsx(Slot,{...To,children:cloneElement(r,void 0,r.props.children,a?we?jsx(lt,{stack:l,positions:le,collapsed:me,scale:P.scale,offset:P.top,window:se}):jsxs(Fragment,{children:[Lo,$o]}):null,Oo,jsx(Co,{},"refusal-live"))}):jsxs("aside",{...To,children:[we&&t!==void 0?jsx("div",{className:"docx-review__furniture","data-testid":"review-furniture",children:t}):null,Pr,Oo,jsx(Co,{})]})})})})}var ca=Object.assign(la,{List:lt,Empty:at,Card:$e,Avatar:xe,Author:Ee,Time:Ae,Summary:Re,Accept:qe,Reject:Be,Resolve:wo,Reopen:yo,Delete:st,Refusal:Ve,Replies:Ue,Reply:go,Markers:Ht,AddComment:$t,Draft:bo,Balloon:Vt});var ma=e=>e.collaborationStatus;function ue(){let e=useDocxEditor();return useEditorState(ma),e?.collaborationSession()??null}var Eo=Object.freeze({status:"inactive",reason:void 0,lastFailure:void 0,live:false,diverged:false,recovering:false,waiting:false,failureCount:0,attached:false});function dr(e,t){return e===t?true:!e||!t?false:e.code===t.code&&e.detail===t.detail}function pa(e,t){return e.status===t.status&&dr(e.reason,t.reason)&&dr(e.lastFailure,t.lastFailure)&&e.failureCount===(t.failureCount??0)&&e.recovering===(t.recovering??false)&&e.waiting===(t.waiting??false)}function Ra(e){return e.attached??false}function mr(e,t){if(!e)return t.current=Eo,Eo;let o=e.statusSnapshot(),n=Ra(e);if(pa(t.current,o)&&t.current.attached===n)return t.current;let r=Object.freeze({status:o.status,reason:o.reason,lastFailure:o.lastFailure,live:o.status==="ready",diverged:o.status==="destroyed"||o.status==="error"&&o.recovering!==true,recovering:o.status==="error"&&o.recovering===true,waiting:o.waiting===true,failureCount:o.failureCount??0,attached:n});return t.current=r,r}function Ao(e){let t=ue(),o=e===void 0?t:e,n=useRef(Eo);return useSyncExternalStore(r=>o?.subscribeStatus(()=>r())??(()=>{}),()=>mr(o,n),()=>mr(o,n))}function vr({session:e,onRejoin:t,className:o,children:n}){let{t:r}=useTranslation(),i=ue(),s=e===void 0?i:e,a=Ao(s),l=ha(s?.sessionId??null,a.failureCount,a.status),u=Ca(a.waiting);if(!s||a.status==="inactive")return null;let m=x({status:a.status,reasonCode:(a.reason??a.lastFailure)?.code,recovering:a.recovering,waiting:a.waiting,stalled:u,refusedRecently:l,offlineEditing:s.offlineEditing!==false}),c=m?r(w[m]):"",f=m==="outOfSync"||m==="stalled"?t:void 0,v=null;return m&&n?v=n({kind:m,message:c,...f?{rejoin:f}:{}}):m&&(v=jsxs(Fragment,{children:[jsx("span",{className:"docx-collaboration-status__message",children:c}),f?jsx("button",{type:"button",className:"docx-collaboration-status__action",onClick:f,children:r("collaboration.status.rejoin")}):null]})),jsx("div",{className:`docx-collaboration-status${o?` ${o}`:""}`,...m?{"data-collaboration-status":m}:{},role:"status",children:v})}function Ca(e){let[t,o]=useState(false);return useEffect(()=>{if(o(false),!e)return;let n=globalThis.setTimeout(()=>o(true),1e4);return ()=>globalThis.clearTimeout(n)},[e]),e&&t}function ha(e,t,o){let n=useRef({sessionId:e,failureCount:t}),[r,i]=useState(0);return useEffect(()=>{let s=n.current;if(n.current={sessionId:e,failureCount:t},s.sessionId!==e){i(0);return}t<=s.failureCount||(o==="ready"||o==="disconnected")&&i(t);},[e,t,o]),useEffect(()=>{if(r===0)return;let s=globalThis.setTimeout(()=>i(0),6e3);return ()=>globalThis.clearTimeout(s)},[r]),r!==0}var No=Object.freeze([]);function Pa(e,t){if(e===t)return true;if(e.length!==t.length)return false;for(let o=0;o<e.length;o+=1){let n=e[o],r=t[o];if(n.actorId!==r.actorId||n.name!==r.name||n.color!==r.color||n.role!==r.role||n.isLocal!==r.isLocal)return false}return true}function pr(e,t){if(!e)return t.current=No,No;let o=e.participants();return Pa(t.current,o)?t.current:(t.current=o,o)}function Ut(e){let t=ue(),o=e===void 0?t:e,n=useRef(No);return useSyncExternalStore(r=>o?.subscribeParticipants(()=>r())??(()=>{}),()=>pr(o,n),()=>pr(o,n))}var Rr=createContext(null);function La(e){return {"--doc-collaboration-accent":e.color}}function wr(e){return e!==void 0?{avatarUrl:e}:{}}function yr({participant:e,className:t$1,children:o}){let n=useDocxEditor(),r=useReviewAuthors(),s$1=useContext(Rr)?.get(e.actorId)??s(r,e,n?l=>n.presenceColorFor(l):void 0,n?l=>n.getReviewAuthorStyle(l)?.color:void 0),a=Ka(e.name);return jsx("span",{className:`docx-collaboration-avatar${t$1?` ${t$1}`:""}`,"data-collaboration-avatar":"",...e.isLocal?{"data-local":""}:{},...s$1.slot!==null?{"data-collaboration-author-slot":s$1.slot}:{},title:e.name,role:"img","aria-label":e.name,style:La(s$1),children:o??(a!==void 0?jsx("img",{className:"docx-collaboration-avatar__image",src:a,alt:""}):t(e.name))})}function Ka(e){let t=useDocxEditor(),o=useReviewAuthors();return v(o,e,t?n=>t.getReviewAuthorStyle(n):void 0)}function Ha({session:e,max:t$1,className:o,children:n}){let r$1=useDocxEditor(),i=Ut(e),s=useReviewAuthors(),{t:a}=useTranslation(),l=useMemo(()=>r(s,i,r$1?d=>r$1.presenceColorFor(d):void 0,r$1?d=>r$1.getReviewAuthorStyle(d)?.color:void 0),[s,i,r$1]),u$1=useMemo(()=>{let d=r$1?y=>r$1.getReviewAuthorStyle(y):void 0,p=new Map;for(let y of i){if(p.has(y.name))continue;let g=v(s,y.name,d);g!==void 0&&p.set(y.name,g);}return p},[r$1,i,s]),m=useMemo(()=>u(i),[i]);if(m.length===0)return null;let c=t$1===void 0?m:m.slice(0,Math.max(0,t$1)),f=m.length-c.length,v$1=a("collaboration.moreParticipants",{count:f});return jsxs("span",{className:`docx-collaboration-avatars${o?` ${o}`:""}`,"data-collaboration-avatars":"",role:"group","aria-label":a("collaboration.participants"),children:[jsx(Rr.Provider,{value:l,children:c.map(d=>n?jsx(Fragment$1,{children:n({participant:d,color:l.get(d.actorId).color,initials:t(d.name),...wr(u$1.get(d.name))})},d.actorId):jsx(yr,{participant:d},d.actorId))}),f>0?jsx("span",{className:"docx-collaboration-avatar","data-collaboration-avatar":"","data-overflow":"",title:v$1,role:"img","aria-label":v$1,children:`+${f}`}):null]})}var Ft=Object.freeze([]);function $a(){return Ft}function Va(){let e=useRef(null);if(e.current===null){let t=Ft,o=false,n=new Set;e.current={subscribe:r=>(n.add(r),()=>n.delete(r)),read:()=>t,write:r=>{t=r.length===0?Ft:r,!o&&(o=true,queueMicrotask(()=>{o=false;for(let i of [...n])i();}));}};}return e.current}function qa({session:e,children:t}){let o=useDocxEditor(),n=ue(),r$1=e===void 0?n:e,i=Ut(r$1),s$1=useReviewAuthors(),a=Va(),l=useSyncExternalStore(a.subscribe,a.read,$a);if(useEffect(()=>{if(!(!o||!r$1))return o.setRemoteCaretLabelHost({publish:a.write}),()=>{o.setRemoteCaretLabelHost(null),a.write(Ft);}},[o,r$1,a]),l.length===0)return null;let u=r(s$1,i);return jsx(Fragment,{children:l.map(m=>{let{selection:c}=m,f=i.find(p=>p.actorId===c.actorId)??null,v$1=m.element.style.getPropertyValue("--doc-remote-color"),d=v$1!==""?v$1:u.get(c.actorId)?.color??s(s$1,{actorId:c.actorId,name:c.name,...c.color!==void 0?{color:c.color}:{},isLocal:false}).color;return createPortal(t?t({selection:c,participant:f,color:d,...wr(v(s$1,c.name,o?p=>o.getReviewAuthorStyle(p):void 0))}):c.name,m.element,c.actorId)})})}var Ba=Object.freeze({CaretLabels:qa,Avatars:Ha,Avatar:yr,Status:vr});function dt(e){let t=useDocxEditor();return useMemo(()=>e||(t?.getCustomNodeDefinitions()??[]).filter(j$2),[e,t])}var za=".docx-content-control-boundary";function Ye(e,t){let{node:o,definition:n,controlId:r}=e,i=r?t?.getReviewItems().find(l=>l.kind==="custom"&&l.item.id===r):void 0;if(i&&i.kind==="custom"){let l=i.item;return {...o,attrs:l.attrs,text:l.text,...l.data===void 0?{}:{data:l.data},...r?{nodeId:r}:{}}}let s=r?Ga(t,r,n):void 0,a=n.fromDocx?n.fromDocx({attrs:o.attrs,text:"",...s===void 0?{}:{data:s}}):o.attrs;return a===null?null:{...o,attrs:a,...s===void 0?{}:{data:s},...r?{nodeId:r}:{}}}function Ga(e,t,o){let n=e?.surface;if(!n)return;let r=partOfNodeId(n.session,t),i=customNodePayloadsByControl(n.session.currentPackage(),(r??n.session.part()).name,n.session.part().name).get(t);if(!i)return;let s=e$1(o.schema,i.data);return s.ok?s.value:void 0}function je(e,t){let o=e?.closest?.(za),n=o?.closest(".docx-content-control-chrome"),r=n?.getAttribute("data-tag"),i=r?c$1(r):null;if(!o||!i||!r)return null;let s=t.find(a=>a.tagPrefix===i.prefix&&a.name===i.name);return s?{node:{name:i.name,attrs:i.attrs,tag:r,rect:o.getBoundingClientRect()},definition:s,controlId:n?.getAttribute("data-docx-content-control")??null}:null}var _o=".docx-content-control-boundary",Ja=e=>{if(!k$1.test(e.tagPrefix)||!k$1.test(e.name))return [];let t=`${e.tagPrefix}:${e.name}`;return [`.docx-content-control-chrome[data-tag="${t}"]`,`.docx-content-control-chrome[data-tag^="${t}?"]`]};function es(e){let{onNodeClick:t,onNodeHover:o}=e,n=useDocxEditor(),r=dt(e.nodes),i=useEditorHostDocument();return useEffect(()=>{if(!i)return;let s=i.defaultView?.CSS??CSS,a=i.createElement("style"),l=[];for(let u of r){let m=Ja(u);if(m.length===0)continue;let c=u.chrome?.color!==void 0&&s.supports("color",u.chrome.color)?u.chrome.color:"var(--doc-accent)";l.push(`${m.map(f=>`${f} ${_o}`).join(", ")} {`," pointer-events: auto !important;"," opacity: 1;"," border: none;",` background: color-mix(in srgb, ${c} 12%, transparent);`," border-radius: 6px;"," cursor: default;","}");}return a.textContent=l.join(`
2
+ `),i.head.append(a),()=>a.remove()},[r,i]),useEffect(()=>{if(!i)return;let s=null,a=null,l=f=>je(i.elementFromPoint(f.clientX,f.clientY),r),u=f=>{let v=f.button===0?l(f):null;s=v?.controlId??null,a=v?.node.tag??null;},m=f=>{let v=s,d=a;if(s=null,a=null,d===null)return;let p=l(f);if(!p||p.node.tag!==d||v!==null&&p.controlId!==v)return;let y=Ye(p,n);y&&(p.definition.onClick?.(y),t?.(y));},c=f=>{let v=je(f.target,r);if(!v||f.relatedTarget?.closest?.(_o)===f.target.closest(_o))return;let p=Ye(v,n);p&&(v.definition.onHover?.(p),o?.(p));};return i.addEventListener("pointerdown",u,true),i.addEventListener("pointerup",m,true),i.addEventListener("mouseover",c),()=>{i.removeEventListener("pointerdown",u,true),i.removeEventListener("pointerup",m,true),i.removeEventListener("mouseover",c);}},[r,n,t,o,i]),null}var is=e=>e.editingMode==="viewing";function hr(e){let{onEditNode:t,onRemoveRefused:o,remove:n=true}=e,r=dt(e.nodes),i=useContextMenuTarget(),s=useDocxEditor(),{t:a}=useTranslation(),l=useMemo(()=>i?je(i,r):null,[i,r]),u=useMemo(()=>l?Ye(l,s):null,[l,s]),m=useEditorState(is),c=useMemo(()=>!l?.definition.reviewCard||!u?null:l.definition.reviewCard({attrs:u.attrs,text:u.text??"",...u.data===void 0?{}:{data:u.data}}),[l,u]);if(!l||!u)return null;let{definition:f}=l,v=f.label??f.name,d=!m&&(f.onEdit!==void 0||t!==void 0),p=!m&&n&&u.nodeId!==void 0&&s!==null;return !c&&!d&&!p?null:jsxs(Fragment,{children:[c?jsxs("div",{className:"docx-contextmenu__custom-info","data-testid":"custom-node-info",children:[jsx("span",{className:"docx-contextmenu__custom-title",children:c.title}),c.detail?jsx("span",{className:"docx-contextmenu__custom-detail",children:c.detail}):null]}):null,d?jsx(ContextMenuItem,{label:a("contextMenu.editCustomNode",{label:v}),className:"docx-contextmenu__custom-edit",onSelect:()=>{f.onEdit?.(u),t?.(u,f);}}):null,p?jsx(ContextMenuItem,{label:a("contextMenu.removeCustomNode",{label:v}),className:"docx-contextmenu__custom-remove",onSelect:()=>{let y=q$1(s,u.nodeId);y.ok||o?.(u,y.reason);}}):null,jsx("div",{role:"separator",className:"docx-toolbar__menu-separator"})]})}hr.docxRowPlacement="start";function ls({collaboration:e,fallback:t=null,author:o,children:n,...r}){let{document:i,modules:s,session:a}=e;if(!i)return jsx(Fragment,{children:t});let l=o??a?.identity.name;return jsx(DocxEditorRoot,{document:i,modules:s,...l!==void 0?{author:l}:{},...r,children:n},a?.sessionId??"local")}var ms=Symbol("useDocumentCollaboration.createRoom");async function fs(e){let{createDocumentCollaboration:t}=await import('../document-session-B35ZX2W4.js');return t(e)}function vs(e){return e[ms]??fs}function ps(e){return e?`${e.documentId}:${e.bootstrap.kind}:${e.identity.actorId}`:""}function Rs(e={}){let t=useId(),o=b$1({ownerKey:`react-document:${t}`,hookName:"useDocumentCollaboration",createRoom:vs(e),hostModules:e.modules??a$1,autoRoom:e.room??null,autoKey:ps(e.room??null),rejoinOptionsOf:n=>({...n,bootstrap:{kind:"join"}}),identityOf:n=>n.identity});return useMemo(()=>({document:o.document,modules:o.modules,session:o.session,pending:o.pending,error:o.error,connect:o.connect,leave:o.leave}),[o])}export{es as CustomNodeChrome,hr as CustomNodeContextMenu,Ba as DocxEditorCollaboration,ls as DocxEditorCollaborationRoot,ca as DocxEditorReview,Ye as activatedCustomNodeOf,je as resolveCustomNodeActivation,Ut as useCollaborationParticipants,ue as useCollaborationSession,Ao as useCollaborationStatus,dt as useCustomNodeDefinitions,Rs as useDocumentCollaboration,Nt as useReview,Vn as useReviewAuthor,$n as useReviewItem,vn as useReviewOf,Un as useReviewRailMetrics,qr as useStackedReviewPositions};
@@ -11,8 +11,8 @@ import * as Y from 'yjs';
11
11
  import { WebrtcProvider } from 'y-webrtc';
12
12
  import { CollaborationIdentity, CollaborationFailure } from '@docx-editor.dev/core/collaboration';
13
13
  import { EditorModule } from '@docx-editor.dev/core/editor';
14
- import { a as CollaborationBootstrap, C as CollaborationSession } from '../types-BQ1vBt5Q.cjs';
15
- export { b as CollaborationIdentityUpdate } from '../types-BQ1vBt5Q.cjs';
14
+ import { a as CollaborationBootstrap, C as CollaborationSession } from '../types-DvGpDOcZ.cjs';
15
+ export { b as CollaborationIdentityUpdate } from '../types-DvGpDOcZ.cjs';
16
16
 
17
17
  /** Bootstrap for one WebRTC room. @public */
18
18
  type UseWebrtcCollaborationBootstrap = CollaborationBootstrap;
@@ -11,8 +11,8 @@ import * as Y from 'yjs';
11
11
  import { WebrtcProvider } from 'y-webrtc';
12
12
  import { CollaborationIdentity, CollaborationFailure } from '@docx-editor.dev/core/collaboration';
13
13
  import { EditorModule } from '@docx-editor.dev/core/editor';
14
- import { a as CollaborationBootstrap, C as CollaborationSession } from '../types-BQ1vBt5Q.js';
15
- export { b as CollaborationIdentityUpdate } from '../types-BQ1vBt5Q.js';
14
+ import { a as CollaborationBootstrap, C as CollaborationSession } from '../types-DvGpDOcZ.js';
15
+ export { b as CollaborationIdentityUpdate } from '../types-DvGpDOcZ.js';
16
16
 
17
17
  /** Bootstrap for one WebRTC room. @public */
18
18
  type UseWebrtcCollaborationBootstrap = CollaborationBootstrap;