@docx-editor.dev/pro 2.21.0 → 2.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,29 +6,29 @@
6
6
 
7
7
  <p align="center">
8
8
  <a href="https://www.npmjs.com/package/@docx-editor.dev/pro"><img src="https://img.shields.io/npm/v/@docx-editor.dev/pro.svg?style=flat-square&color=3B5BDB" alt="npm version" /></a>
9
- <a href="https://github.com/eigenpal/docx-editor/blob/main/packages/pro/LICENSE.md"><img src="https://img.shields.io/badge/license-EigenPal_Pro_Evaluation_1.0-blue.svg?style=flat-square&color=3B5BDB" alt="license" /></a>
9
+ <a href="https://github.com/eigenpal/docx-editor/blob/main/packages/pro/LICENSE.md"><img src="https://img.shields.io/badge/license-EigenPal_Pro_License-blue.svg?style=flat-square&color=3B5BDB" alt="EigenPal Pro License" /></a>
10
10
  <a href="https://docx-editor.dev/editor"><img src="https://img.shields.io/badge/Live_Demo-3B5BDB?style=flat-square&logo=vercel&logoColor=white" alt="Demo" /></a>
11
11
  <a href="https://www.docx-editor.dev/docs/2.x/pro"><img src="https://img.shields.io/badge/Docs-3B5BDB?style=flat-square&logo=readthedocs&logoColor=white" alt="Documentation" /></a>
12
12
  </p>
13
13
 
14
14
  # @docx-editor.dev/pro
15
15
 
16
- Four capabilities for the [docx-editor.dev](https://docx-editor.dev) React and Vue editors:
16
+ Add review, collaboration, and custom content to the [docx-editor.dev](https://docx-editor.dev) React and Vue editors. The package provides these capabilities:
17
17
 
18
- - **Tracked changes**: Suggesting mode, markup rendering, accept, and reject.
19
- - **Comments**: Threads anchored to a range, with replies.
20
- - **Collaboration**: Provider-neutral sessions with WebRTC and Hocuspocus helpers.
21
- - **Custom nodes**: Inline node types stored as Word content controls.
18
+ - Tracked changes: Suggesting mode, markup rendering, accept, and reject.
19
+ - Comments: Threads anchored to a range, with replies.
20
+ - Collaboration: Provider-neutral sessions with WebRTC and Hocuspocus helpers.
21
+ - Custom nodes: Inline node types stored as Word content controls.
22
22
 
23
23
  ```bash
24
- npm install @docx-editor.dev/react @docx-editor.dev/pro
24
+ npm install @docx-editor.dev/react @docx-editor.dev/core @docx-editor.dev/pro
25
25
  ```
26
26
 
27
27
  The framework-neutral entry is `@docx-editor.dev/pro`. Framework chrome lives at `@docx-editor.dev/pro/react` and `@docx-editor.dev/pro/vue`.
28
28
 
29
29
  ## Register a module
30
30
 
31
- Capabilities are modules passed to the editor root. Registration happens at construction, so the array identity must be stable. Build it outside render, or the editor rebuilds every time.
31
+ Pass capability modules to the editor root. Keep the module array stable across renders to avoid rebuilding the editor.
32
32
 
33
33
  ```tsx
34
34
  import { DocxEditor } from '@docx-editor.dev/react';
@@ -50,9 +50,9 @@ export function Reviewer({ bytes }: { bytes: Uint8Array }) {
50
50
  }
51
51
  ```
52
52
 
53
- `author` is what lands in `w:author`. OOXML requires it, so the engine refuses a comment or reply with no author rather than writing an empty attribute.
53
+ Set `author` to the name stored in `w:author`. The engine requires an author to create comments or replies.
54
54
 
55
- Without a review module the editor still opens a document containing revisions and comments and still saves them back untouched. It renders revisions in their final state and offers no review UI; the module is what makes them visible and actionable.
55
+ Without a review module, the editor preserves revisions and comments when saving. It displays final revision content. Add the review module to display markup and review controls.
56
56
 
57
57
  ## Collaboration
58
58
 
@@ -69,7 +69,7 @@ Start with the [real-time collaboration quickstart](https://www.docx-editor.dev/
69
69
 
70
70
  ## Chrome or hooks
71
71
 
72
- Everything the packaged sidebar renders is reachable from `useReview()`. Use the sidebar for Word-like cards out of the box, or the hook to render your own markup.
72
+ Use the packaged sidebar to display review cards. Use `useReview()` to build your own review interface.
73
73
 
74
74
  ```tsx
75
75
  import { useReview } from '@docx-editor.dev/pro/react';
@@ -102,11 +102,11 @@ function ChangeList() {
102
102
  }
103
103
  ```
104
104
 
105
- Items come from the document tree rather than from what is currently painted, and each anchor comes from layout records rather than measured DOM, so a sidebar built on this does not lag a repaint behind the page or break during pagination.
105
+ Items come from the document tree. Anchors come from layout records. These sources keep your sidebar aligned with the document during pagination.
106
106
 
107
107
  ## Custom nodes
108
108
 
109
- An inline node type you define (a citation, a mention, a merge field) stored as a Word content control whose `w:tag` carries your identity and attributes. Word opens the document, shows the node's text, and gives it back unchanged.
109
+ Define inline nodes such as citations, mentions, and merge fields. Each node uses a Word content control with its identity and attributes in `w:tag`. Word displays the node's text and preserves the control.
110
110
 
111
111
  ```ts
112
112
  import { defineCustomNode, customNodesModule } from '@docx-editor.dev/pro';
@@ -128,9 +128,9 @@ Every value reaching `fromDocx` came out of a `.docx`, so treat `attrs` and `tex
128
128
 
129
129
  ## Licensing
130
130
 
131
- This package is licensed under the [EigenPal Pro License](https://github.com/eigenpal/docx-editor/blob/main/packages/pro/LICENSE.md), and you can compare and buy license and support levels on the [pricing page](https://www.docx-editor.dev/pricing).
131
+ This package uses the [EigenPal Pro License](https://github.com/eigenpal/docx-editor/blob/main/packages/pro/LICENSE.md). See [pricing](https://www.docx-editor.dev/pricing) for license and support options.
132
132
 
133
- Both module factories accept an optional `licenseKey`. Construction never validates it and never touches the network.
133
+ `reviewModule`, `customNodesModule`, and `collaborationModule` accept an optional `licenseKey`. Construction never validates it and never touches the network.
134
134
 
135
135
  ## Documentation
136
136
 
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkOMUXC73J_cjs=require('../chunk-OMUXC73J.cjs'),chunkGDTCNTK7_cjs=require('../chunk-GDTCNTK7.cjs'),chunkQLZH2Q2C_cjs=require('../chunk-QLZH2Q2C.cjs'),react=require('react'),react$1=require('@docx-editor.dev/react'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom'),collaboration=require('@docx-editor.dev/core/collaboration'),store=require('@docx-editor.dev/core/store'),editor=require('@docx-editor.dev/core/editor');var un=new Set(["List","Markers","AddComment","Draft","Balloon"]),dn=new Set(["Card","Empty"]);function ke(e,t){let n=t==="root"?un:dn,o={},a=[],r=s=>{if(Array.isArray(s)){for(let l of s)r(l);return}if(!react.isValidElement(s)){s!=null&&s!==false&&a.push(s);return}if(s.type===react.Fragment){r(s.props.children);return}let i=s.type.docxReviewPart;i&&n.has(i)?o[i]=s:a.push(s);};return r(e),{parts:o,rest:a}}function at(e,t){if(!t)return e;let n=e.props.className;return react.cloneElement(e,{className:`${t}${n?` ${n}`:""}`})}var mn={scale:96/72,top:0,left:null,compactCardLeft:null},fn=16,we=300,vn=12,De=600;function eo(e,t,n,o,a=false){let[r,s]=react.useState(mn);return react.useEffect(()=>{let i=t.current;if(!e||!i)return;let l=i.offsetParent,c=l?.querySelector(".docx-paginated-surface")??null,m=()=>{s(p=>{let y=c&&l?c.getBoundingClientRect():null,b=y&&l?l.getBoundingClientRect():null,C=y&&b&&l?y.right-b.left-l.clientLeft+l.scrollLeft+fn:null,w={scale:e.getRenderScale(),top:y&&b&&l?y.top-b.top-l.clientTop+l.scrollTop:0,left:C,compactCardLeft:C===null||!l?null:l.scrollLeft+l.clientWidth-C-we-vn};return p.scale===w.scale&&p.top===w.top&&p.left===w.left&&p.compactCardLeft===w.compactCardLeft?p:w});};m();let d=new ResizeObserver(m);if(l&&d.observe(l),c&&d.observe(c),!a||!l)return ()=>d.disconnect();let f=0,u=()=>{f===0&&(f=requestAnimationFrame(()=>{f=0,m();}));};return l.addEventListener("scroll",u,{passive:true}),()=>{f!==0&&cancelAnimationFrame(f),l.removeEventListener("scroll",u),d.disconnect();}},[e,t,n,o,a]),r}function to(e,t,n){let[o,a]=react.useState(null);return react.useEffect(()=>{let r=t.current,s=r?.offsetParent;if(!s)return;let i=0,l=()=>{i=0,a(f=>{let u=s.scrollTop-De,p=s.scrollTop+s.clientHeight+De;return f&&f.top===u&&f.bottom===p?f:{top:u,bottom:p}});},c=0,m=()=>{i===0&&(i=requestAnimationFrame(l)),r?.setAttribute("data-scrolling",""),window.clearTimeout(c),c=window.setTimeout(()=>r?.removeAttribute("data-scrolling"),150);};l(),s.addEventListener("scroll",m,{passive:true});let d=new ResizeObserver(m);return d.observe(s),()=>{i!==0&&cancelAnimationFrame(i),window.clearTimeout(c),s.removeEventListener("scroll",m),d.disconnect();}},[e,t,n]),o}function oo(e){let t=react.useRef(new WeakMap),n=react.useRef(new Map),o=react.useRef(null),a=react.useCallback((r,s)=>{let i=n.current.get(s);if(!r){i&&(o.current?.unobserve(i),t.current.delete(i),n.current.delete(s));return}typeof ResizeObserver>"u"||(e(s,r.offsetHeight),o.current??=new ResizeObserver(l=>{for(let c of l){let m=t.current.get(c.target);m&&e(m,c.target.offsetHeight);}}),!(i===r&&t.current.get(r)===s)&&(i&&(o.current.unobserve(i),t.current.delete(i)),t.current.set(r,s),n.current.set(s,r),o.current.observe(r)));},[e]);return react.useEffect(()=>()=>{o.current?.disconnect(),n.current.clear();},[]),a}function gn(e){let t=false;return ()=>{if(!t){if(!react$1.notificationYieldsToTask()){e();return}t=true,setTimeout(()=>{t=false,e();},0);}}}function Cn(e){let t=e.snapshot?.();return JSON.stringify(t?.hiddenReviewAuthors??[])}function Te(e){let t=react$1.useDocxEditor();return no(t,e)}function no(e,t){let n=react.useCallback(w=>{if(!e)return ()=>{};let h=false,D=gn(()=>{h||w();}),E=e.on("change",D),x=e.on("selectionChange",D),_=e.on("error",D);return ()=>{h=true,E(),x(),_();}},[e]),o=react.useSyncExternalStore(n,()=>e?`${e.getReviewRevision()}:${e.getEditingMode()}:${Cn(e)}`:"none",()=>"none"),a=react.useMemo(()=>e?e.getReviewItems(t).filter(w=>w.item.kind!=="custom"||w.item.carded):[],[e,o,t]),r=react.useMemo(()=>a.find(w=>w.isActive)?.key??null,[a]),s=react.useCallback((w,h)=>e?e.setActiveReviewItem(w,h).ok:false,[e]),i=react.useCallback(w=>!e||w.kind!=="revision"||w.readOnly?false:e.acceptReviewItem(w.key).ok,[e]),l=react.useCallback(w=>!e||w.kind!=="revision"||w.readOnly?false:e.rejectReviewItem(w.key).ok,[e]),c=react.useCallback(w=>!e||w.kind!=="comment"?false:e.setCommentResolved(w.key,true).ok,[e]),m=react.useCallback(w=>!e||w.kind!=="comment"?false:e.setCommentResolved(w.key,false).ok,[e]),d=e?.getEditingMode()==="viewing"?"the document is open for viewing":null,f=react.useCallback(w=>!e||w.kind==="custom"||w.kind==="revision"&&w.readOnly?false:e.deleteReviewItem(w.key).ok,[e]),u=react.useCallback((w,h,D)=>h.trim().length===0||!e?false:e.replyToReviewItem(w.key,h,D).ok,[e]),p=react.useMemo(()=>e?e.getSelectionPlacement()?.anchorY??null:null,[e,o]),y=react.useCallback((w,h)=>w.trim().length===0||!e?false:e.addComment(w,h).ok,[e]),b=react.useMemo(()=>e?e.isReviewPaneOpen():true,[e,o]),C=react.useCallback(w=>{!e||e.isReviewPaneOpen()===w||e.exec({type:"toggleReviewPane"});},[e]);return react.useMemo(()=>({items:a,activeKey:r,setActive:s,accept:i,reject:l,resolve:c,reopen:m,commentResolutionDisabledReason:d,remove:f,reply:u,selectionAnchorY:p,comment:y,paneOpen:b,setPaneOpen:C,ready:e!==null&&!e.snapshot().isLoading&&e.snapshot().parseError===null}),[a,r,s,i,l,c,m,d,f,u,p,y,b,C,e])}function hn(e,t,n={}){let o=n.gap??8,a=n.scale??1,r=n.defaultHeight??0;return react.useMemo(()=>{let s=new Map,i=Number.NEGATIVE_INFINITY;for(let l of e){let c=l.anchorY===null?Number.isFinite(i)?i:0:Math.max(l.anchorY,i);s.set(l.key,c),i=c+((t.get(l.key)??r)+o)/a;}return s},[e,t,o,a,r])}var st=8;function lt(e,t){return e?.color??`var(--doc-review-author-${t%st})`}function le(e,t,n){return e?{"--doc-review-author-current":lt(t,n)}:{}}function ye(e,t){return (e?.slot??t)%st}function ro(e,t,n,o){let a=react.useRef(new Map);return react.useMemo(()=>{let r=new Map;for(let i of e)r.set(i.author,i);let s=[...t.map(i=>i.author),o?.getConfiguredAuthor()];for(let i of s){if(!i||r.has(i))continue;let l=n.get(i)??0,c=o?.getReviewAuthorStyle(i),m=c?.color??`var(--doc-review-author-${l%st})`,d=a.current.get(i),f=d!==void 0&&d.slot===l&&d.color===m&&d.style===c?d:{author:i,slot:l,color:m,...c?{style:c}:{}};a.current.set(i,f),r.set(i,f);}return r},[e,t,n,o])}var q=e=>jsxRuntime.jsx("svg",{viewBox:"0 -960 960 960",width:16,height:16,"aria-hidden":"true",focusable:"false",children:jsxRuntime.jsx("path",{d:e,fill:"currentColor"})}),io="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",ao="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",En="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",Re="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z",Le=()=>jsxRuntime.jsxs("span",{className:"docx-review__resolved-icon",children:[jsxRuntime.jsx("span",{className:"docx-review__resolved-comment",children:q(En)}),jsxRuntime.jsx("span",{className:"docx-review__resolved-tick",children:q(Re)})]}),so="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",lo="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",co="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",In="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",Nn="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",Pn="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",_n="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 uo(e){if(e.kind==="comment")return ao;if(e.kind==="custom")return e.item.icon??_n;switch(e.revisionKind){case "insert":case "moveTo":return In;case "delete":case "moveFrom":return Nn;case "format":return Pn;default:return ao}}function Dn(e,t){return typeof t!="function"?e:typeof e!="function"?t:n=>{e(n),n.defaultPrevented||t(n);}}function Tn(e,t){let n={...e,...t};for(let o of Object.keys(e))/^on[A-Z]/.test(o)?n[o]=Dn(t[o],e[o]):o==="className"?n[o]=[e[o],t[o]].filter(Boolean).join(" "):o==="style"&&(n[o]={...e[o],...t[o]});return n}function vo(e){return e==="Enter"||e===" "}function On(e){return vo(e.key)?(e.preventDefault(),e.stopPropagation(),true):false}function fo(e){return e.type==="button"}function Ln(e,t){return e.type==="a"||t.href!=null}function Kn(e,t,n,o){let a=r=>{typeof n=="function"&&n(r);};return {onClick:r=>{typeof e=="function"&&e(r),r.defaultPrevented||a(r),o&&r.preventDefault();},onKeyDown:r=>{if(typeof t=="function"&&t(r),!vo(r.key))return;r.defaultPrevented||a(r),o&&r.preventDefault();}}}function te({engineDisabled:e,disabledReason:t,slotProps:n,children:o}){let a=react.Children.only(o);if(!react.isValidElement(a))return null;let r=a.props,s=Tn(n,r);if(!e){if(!fo(a)){let i=Kn(r.onClick,r.onKeyDown,n.onClick,Ln(a,r));s.onClick=i.onClick,s.onKeyDown=i.onKeyDown;}return react.cloneElement(a,s)}if(fo(a))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 i=s.onKeyDown;s.onKeyDown=l=>{On(l)||typeof i=="function"&&i(l);};}return t&&(s.title=t),s.onClick=i=>{i.preventDefault(),i.stopPropagation();},react.cloneElement(a,s)}var yo=react.createContext({key:null,open:()=>{},close:()=>{}});function Ro({items:e,children:t}){let[n,o]=react.useState(null);react.useEffect(()=>{n!==null&&!e.some(r=>r.key===n&&r.kind==="comment"&&r.resolved)&&o(null);},[e,n]);let a=react.useMemo(()=>({key:n,open:r=>o(r),close:()=>o(null)}),[n]);return jsxRuntime.jsx(yo.Provider,{value:a,children:t})}function ct(){return react.useContext(yo)}function bo({label:e,statusLabel:t,entryKey:n,onActivate:o,onDeactivate:a,children:r,...s}){let i=ct(),l=react.useRef(null);return react.useEffect(()=>{let c=m=>{let d=l.current;d?.open&&m.target instanceof Node&&!d.contains(m.target)&&(i.close(),a());};return document.addEventListener("pointerdown",c,true),()=>document.removeEventListener("pointerdown",c,true)},[i,a]),jsxRuntime.jsxs("details",{ref:l,...s,open:i.key===n,onToggle:c=>{c.currentTarget.open?(i.open(n),o()):(i.close(),a());},children:[jsxRuntime.jsxs("summary",{className:"docx-review__resolved-toggle","aria-label":e,children:[jsxRuntime.jsx("span",{className:"docx-review__resolved-status",children:t}),Le()]}),r]})}function go(e){function t({className:o,asChild:a,hidden:r,children:s,icon:i}){let l=e.useReview(),c=e.useItem(),m=e.useLabel();if(r||!c||c.kind!=="comment"||c.resolved)return null;let d=m("comments.resolve"),f=l.commentResolutionDisabledReason!==null,u=f?m("editingMode.viewingHint"):null,p={type:"button",className:`docx-review__action${o?` ${o}`:""}`,"data-testid":"review-resolve","aria-label":d,title:u??d,disabled:f,onMouseDown:e.guardMousedown,onClick:y=>{y.stopPropagation(),!f&&l.resolve(c);}};return a?jsxRuntime.jsx(te,{engineDisabled:f,disabledReason:u,slotProps:p,children:s}):jsxRuntime.jsx("button",{...p,children:i??s??q(Re)})}t.docxReviewPart="Resolve";function n({className:o,asChild:a,hidden:r,children:s,icon:i}){let l=e.useReview(),c=e.useItem(),m=e.useLabel();if(r||!c||c.kind!=="comment"||!c.resolved)return null;let d=m("comments.reopen"),f=l.commentResolutionDisabledReason!==null,u=f?m("editingMode.viewingHint"):null,p={type:"button",className:`docx-review__action${o?` ${o}`:""}`,"data-testid":"review-reopen","aria-label":d,title:u??d,disabled:f,onMouseDown:e.guardMousedown,onClick:y=>{y.stopPropagation(),!f&&l.reopen(c);}};return a?jsxRuntime.jsx(te,{engineDisabled:f,disabledReason:u,slotProps:p,children:s}):jsxRuntime.jsx("button",{...p,children:i??s??q(so)})}return n.docxReviewPart="Reopen",{ReviewResolve:t,ReviewReopen:n}}function xo(e){function t({top:o=0,left:a=null,className:r,hidden:s}){let{review:i,endDraft:l,measure:c,readOnly:m,draftAuthor:d,draftAuthorInfo:f,draftAuthorSlot:u}=e.useRail(),p=e.useLabel(),[y,b]=react.useState(""),[C,w]=react.useState(false),h=react.useRef(null),D=react.useId();react.useEffect(()=>{m||h.current?.focus({preventScroll:true});},[]);let E=react.useCallback(()=>{if(m||y.trim().length===0)return;let x=i.comment(y.trim());w(!x),x&&(b(""),l());},[m,y,i,l]);return s?null:jsxRuntime.jsx("div",{className:`docx-review__slot${r?` ${r}`:""}${a===null?"":" docx-review__slot--compact"}`,style:{position:"absolute",top:o,...a===null?{}:{left:a,width:we}},ref:x=>{c(x,e.composeKey);},children:jsxRuntime.jsx("div",{className:"docx-review__card","data-testid":"review-draft","data-draft":"",...d?{"data-review-author":d,"data-review-author-slot":u}:{},style:le(d??void 0,f,u),children:jsxRuntime.jsxs("form",{className:"docx-review__reply-box",onSubmit:x=>{x.preventDefault(),E();},children:[jsxRuntime.jsx("label",{className:"docx-editor-sr-only",htmlFor:D,children:p("comments.addComment")}),jsxRuntime.jsx("input",{id:D,ref:h,"data-testid":"review-draft-input",className:"docx-review__input",value:y,placeholder:p("comments.addComment"),readOnly:m,...C?{"aria-invalid":true}:{},onChange:x=>{m||(w(false),b(x.target.value));},onKeyDown:x=>{if(x.key==="Escape"){x.preventDefault(),l();return}m||x.key!=="Enter"||(x.preventDefault(),E());}}),jsxRuntime.jsxs("div",{className:"docx-review__reply-actions",children:[jsxRuntime.jsx("button",{type:"button","data-testid":"review-draft-cancel",className:"docx-review__text-button",onMouseDown:e.guardMousedown,onClick:l,children:p("common.cancel")}),jsxRuntime.jsx("button",{type:"submit","data-testid":"review-draft-submit",className:"docx-review__submit",disabled:m||y.trim().length===0,title:m?p("editingMode.viewingHint"):void 0,children:p("common.comment")})]}),C?jsxRuntime.jsx("span",{className:"docx-review__refused",role:"alert",children:p("review.commentRefused")}):null]})})})}t.docxReviewPart="Draft";function n({className:o,hidden:a,children:r}){let{review:s,readOnly:i}=e.useRail(),l=e.useItem(),c=e.useLabel(),[m,d]=react.useState(""),[f,u]=react.useState(false),p=react.useId(),y=react.useCallback(()=>{if(!l||i||m.trim().length===0)return;let b=s.reply(l,m.trim());u(!b),b&&d("");},[l,i,m,s]);return a||!l||!l.isActive||l.kind==="comment"&&l.resolved?null:r?jsxRuntime.jsx(jsxRuntime.Fragment,{children:r}):jsxRuntime.jsxs("form",{className:`docx-review__reply-box${o?` ${o}`:""}`,onSubmit:b=>{b.preventDefault(),y();},children:[jsxRuntime.jsx("label",{className:"docx-editor-sr-only",htmlFor:p,children:c("comments.replyPlaceholder")}),jsxRuntime.jsx("input",{id:p,"data-testid":"review-reply-input",className:"docx-review__input",value:m,placeholder:c("comments.replyPlaceholder"),readOnly:i,...f?{"aria-invalid":true,"data-refused":""}:{},onChange:b=>{i||(u(false),d(b.target.value));},onClick:b=>b.stopPropagation(),onKeyDown:b=>{i||b.key!=="Enter"||(b.preventDefault(),y());}}),jsxRuntime.jsxs("div",{className:"docx-review__reply-actions",children:[jsxRuntime.jsx("button",{type:"button","data-testid":"review-reply-cancel",className:"docx-review__text-button",onMouseDown:e.guardMousedown,onClick:b=>{b.stopPropagation(),d(""),u(false),s.setActive(null);},children:c("common.cancel")}),jsxRuntime.jsx("button",{type:"submit","data-testid":"review-reply-submit",className:"docx-review__submit",disabled:i||m.trim().length===0,title:i?c("editingMode.viewingHint"):void 0,children:c("review.reply")})]}),f?jsxRuntime.jsx("span",{className:"docx-review__refused",role:"alert","data-testid":"review-reply-refused",children:c("review.replyRefused")}):null]})}return n.docxReviewPart="Reply",{ReviewDraft:t,ReviewReply:n}}function ut(e,t,n=1){if(e==="paragraphMark"){let o=n>1;return t==="delete"?o?"revisions.paragraphMarksDeleted":"revisions.paragraphMarkDeleted":t==="moveFrom"?o?"revisions.paragraphMarksMovedFrom":"revisions.paragraphMarkMovedFrom":t==="moveTo"?o?"revisions.paragraphMarksMovedTo":"revisions.paragraphMarkMovedTo":o?"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 Zn(e){return ut(e.revisionKind,e.markDirection,e.ranges.length)}function jn(e){return e.revisionKind==="paragraphMark"&&e.ranges.length>1?` (${e.ranges.length})`:""}function Ao(e,t){let n=`${t(Zn(e))}${jn(e)}`;if(e.revisionKind!=="format")return n;let a=[...(e.formattingLanguages??[]).map(r=>{try{return new Intl.DisplayNames([t("_lang")],{type:"language"}).of(new Intl.Locale(r).minimize().toString())??r}catch{return r}}),...(e.formattingChanges??[]).map(r=>zn(r,t))];return a.length?`${n}: ${a.join(", ")}`:n}function zn(e,t){let{property:n,value:o}=e;if(o!==null&&(n==="bold"||n==="italic"||n==="strike"))return t(`revisions.formattingDetails.${o==="true"?n:{bold:"notBold",italic:"notItalic",strike:"notStrike"}[n]}`);let a=o??t("revisions.formattingDetails.default");return o!==null&&(["fontSize","leftIndent","rightIndent","firstLineIndent","hangingIndent","spaceBefore","spaceAfter"].includes(n)?a=`${o} ${t("revisions.formattingDetails.points")}`:/^(left|center|right|both|start|end|none|single|double|auto)$/.test(o)?a=t(`revisions.formattingDetails.${o}`):n==="color"&&/^[0-9a-f]{6}$/i.test(o)&&(a=`#${o.toUpperCase()}`)),`${t(`revisions.formattingDetails.${n}`)}: ${a}`}function dt(e,t,n){let o=t.getBoundingClientRect(),a=e.getBoundingClientRect(),r=e.ownerDocument.defaultView?.innerHeight??1/0,s=Number(e.dataset.reviewStart??e.dataset.start),i=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:n,...e.dataset.paragraphId!==void 0?{paragraphId:e.dataset.paragraphId}:{},...Number.isFinite(s)?{start:s}:{},...Number.isFinite(i)?{end:i}:{},left:a.left-o.left,top:a.top-o.top,bottom:a.bottom-o.top,above:a.bottom+220>r}}function Wn(e){return e==="format"||e==="structural"}function Eo(e,t,n){return e.kind!=="revision"||!Wn(e.revisionKind)?false:!(n&&t.some(o=>o.id===e.id))}function Io(e,t){if(t.kind!=="revision"||t.item.kind!=="revision")return null;let n=t.item.addresses;if(n.length===0)return null;let o=new Set(n.map(r=>r.id)),a=t.item.formattingKind;for(let r of e.querySelectorAll("[data-revision-id]")){if(!(r instanceof HTMLElement))continue;let s=r.dataset.revisionId;if(!s||!o.has(s)||!n.some(c=>c.id===s&&c.author===(r.dataset.reviewAuthor??"")&&(c.date??"")===(r.dataset.revisionDate??"")))continue;let l=r.classList.contains("docx-table-row--revision");if(t.revisionKind==="structural"&&l||t.revisionKind==="format"&&r.dataset.revisionKind==="format"&&r.dataset.formattingKind===a)return r}return null}function No(e,t){let n=null,o=false,a=null,r=false,s=null,i=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;n===null?n=l:n!==l&&(o=true);}a===null?a=l:a!==l&&(r=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){s===null?s=l:s!==l&&(i=true);break}}}return n!==null&&!o?n:a!==null&&!r?a:s!==null&&!i?s:null}var rr=e=>e.isLoading||e.parseError!==null||e.pageSetup==null,ar=e=>e.editingMode==="viewing",pt=react.createContext(null),P=react.createContext(null);function ir(){return react.useContext(P)}function sr(e){let{authorInfo:t}=H();return e===void 0?void 0:t.get(e)}var He="\0compose",lr=72,cr=64,ur=480,dr=30,mr=Object.freeze({placement:false});function wt(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 yt(e){return new Set(e.map(t=>t.id))}function W(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function H(){let e=react.useContext(pt);return e||fr}function U(){let{t:e}=react.useContext(pt)??{},{t}=react$1.useTranslation();return react.useCallback(n=>e?.(n)??t(n),[e,t])}var{ReviewResolve:Mo,ReviewReopen:ko}=go({useReview:()=>H().review,useItem:()=>react.useContext(P),useLabel:U,guardMousedown:W}),{ReviewDraft:Do,ReviewReply:To}=xo({useRail:H,useItem:()=>react.useContext(P),useLabel:U,guardMousedown:W,composeKey:He}),fr={t:void 0,cardClassName:void 0,readOnly:false,review:{items:[],activeKey:null,setActive:()=>false,accept:()=>false,reject:()=>false,resolve:()=>false,reopen:()=>false,commentResolutionDisabledReason:null,remove:()=>false,reply:()=>false,selectionAnchorY:null,comment:()=>false,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:()=>{}};function vr({className:e,furniture:t,asChild:n,hidden:o,children:a,t:r,card:s,preset:i=true,stack:l=true,gap:c=8,filter:m,structural:d=false,formatting:f=false}){let u=react$1.useDocxEditor(),p=react$1.useEditorState(rr),y=react$1.useEditorState(ar),b=react.useMemo(()=>{let R=[];return d||R.push("structural"),f||R.push("format"),R.length>0?R:void 0},[d,f]),C=react.useMemo(()=>b?{excludeRevisionKinds:b}:void 0,[b]);react.useEffect(()=>(u?.setReviewActivationExclusions(b??null),()=>u?.setReviewActivationExclusions(null)),[u,b]);let w=Te(mr),h=Te(C),D=h.setPaneOpen,{t:E}=react$1.useTranslation(),x=react.useCallback(R=>r?.(R)??E(R),[r,E]),_=react.useRef(null),V=react.useContext(react$1.ReviewRailContext);react.useEffect(()=>V?.register(),[V]);let L=h.paneOpen,G=react$1.useReviewGutter(),S=L&&G.inlineEnd>0&&G.inlineEnd<react$1.REVIEW_PANE_GUTTER,F=L&&!S,M=react.useMemo(()=>m?h.items.filter(R=>m(R)):h.items,[h.items,m]),B=react.useSyncExternalStore(react.useCallback(R=>u?.on("selectionChange",R)??(()=>{}),[u]),()=>u?.getConfiguredAuthor()??null,()=>null),Ne=react.useMemo(()=>{let R=new Map;for(let g of M)g.author&&!R.has(g.author)&&R.set(g.author,R.size);return B&&!R.has(B)&&R.set(B,R.size),R},[M,B]),St=react.useMemo(()=>{let R=new Map;for(let g of M)R.set(g.id,g);return R},[M]),[Mt,Wo]=react.useState(()=>new Map),Go=react.useCallback((R,g)=>{g<=0||Wo(I=>{if(I.get(R)===g)return I;let T=new Map(I);return T.set(R,g),T});},[]),kt=oo(Go),N=eo(u,_,M,!p&&!o,S),fe=to(u,_,!p&&!o);react.useEffect(()=>{let R=_.current;if(!u||!R)return;let g=I=>{let T=I.target;if(!(T instanceof Node)||R.contains(T))return;let O=R.offsetParent;!O||!O.contains(T)||O.querySelector(".docx-paginated-surface")?.contains(T)||u.setActiveReviewItem(null);};return document.addEventListener("mousedown",g,true),()=>document.removeEventListener("mousedown",g,true)},[u,p,o]);let[j,Je]=react.useState(null),Xe=react.useRef(null),Q=react.useCallback(()=>{let R=Xe.current;R&&(R.editor.releaseSelection(R.pin),Xe.current=null);},[]),Pe=react.useCallback(()=>{if(!u||y)return;let R=u.getSelectionPlacement()?.anchorY??null;if(R===null)return;Q();let g=u.retainSelection();g&&(Xe.current={editor:u,pin:g},D(true),Je(R));},[u,y,Q,D]);react.useEffect(()=>{if(!(o||y))return V?.registerCommentDraft(Pe)},[Pe,o,y,V]);let Dt=react.useCallback(()=>{Q(),Je(null),u?.focus();},[u,Q]);react.useEffect(()=>Q,[Q]),react.useEffect(()=>{L||j===null||(Q(),Je(null));},[L,j,Q]);let et=j??h.selectionAnchorY,z=react.useMemo(()=>{let R=yt(M);return M.filter(g=>!wt(g,R))},[M]),Tt=react.useMemo(()=>{if(j===null)return z;let R=z.findIndex(I=>I.anchorY!==null&&I.anchorY>j),g={key:He,anchorY:j};return R===-1?[...z,g]:[...z.slice(0,R),g,...z.slice(R)]},[z,j]),Ot=react.useMemo(()=>{let R=new Map(Mt);for(let g of z){if(R.has(g.key))continue;let I=g.text.length+(g.kind==="revision"?g.replacedText?.length??0:0),T=Math.min(6,Math.max(1,Math.ceil(I/36)));R.set(g.key,64+T*20);}return R},[Mt,z]),{stacked:tt,collapsedKeys:Lt}=react.useMemo(()=>{let R=N.scale,g=new Map,I=new Set,T=Number.NEGATIVE_INFINITY;for(let O of Tt){let Me=O.anchorY===null?Number.isFinite(T)?T:0:Math.max(O.anchorY,T);g.set(O.key,Me);let tn=O.anchorY===null?0:(Me-O.anchorY)*R,on="isActive"in O&&O.isActive,Yt=tn>ur&&!on&&O.key!==He;Yt&&I.add(O.key);let nn=Yt?cr:Ot.get(O.key)??lr;T=Me+(nn+c)/R;}return {stacked:g,collapsedKeys:I}},[Tt,Ot,c,N.scale]),ot=et===null?null:N.top+(S?et:tt.get(He)??et)*N.scale,ve=s?.className,Qo=react$1.useReviewAuthors(),nt=ro(Qo,M,Ne,u),Kt=B?Ne.get(B)??0:0,$t=B?nt.get(B):void 0,Jo=react.useMemo(()=>({t:r,cardClassName:ve,readOnly:y,review:{...h,items:M},allItems:w.items,authorSlots:Ne,authorInfo:nt,draftAuthor:B,draftAuthorInfo:$t,draftAuthorSlot:Kt,byId:St,measure:kt,beginDraft:Pe,endDraft:Dt}),[r,ve,y,h,w.items,M,Ne,nt,B,$t,Kt,St,kt,Pe,Dt]);if(o||p)return null;let Ht={ref:_,className:`docx-review${e?` ${e}`:""}`,"data-testid":"review-rail","data-count":M.length,"data-open":F?"":void 0,"data-compact":S?"":void 0,role:"complementary","aria-label":x("review.ariaLabel"),onMouseDown:W,style:N.left===null?void 0:{left:N.left,right:"auto"}},J=typeof a=="function"?{parts:{},rest:a}:ke(a,"root"),X=J.parts,pe=(R,g)=>{if(!(R in X))return g;let I=X[R];return !react.isValidElement(I)||!react.isValidElement(g)?I:react.cloneElement(I,{...g.props,...I.props})},qt=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[i||"AddComment"in X?pe("AddComment",jsxRuntime.jsx(bt,{top:ot,drafting:j!==null})):null,!L||j===null||ot===null||!i&&!("Draft"in X)?null:pe("Draft",jsxRuntime.jsx(Do,{top:ot,left:S?N.compactCardLeft:null})),i||"Balloon"in X?pe("Balloon",jsxRuntime.jsx(gt,{})):null]}),Xo=jsxRuntime.jsx(qe,{stack:l,positions:tt,collapsed:Lt,scale:N.scale,offset:N.top,window:fe,children:J.rest}),Ut=jsxRuntime.jsx(Rt,{scale:N.scale,offset:N.top,window:fe}),ee=S?z.find(R=>R.key===h.activeKey)??null:null,Vt=ee===null?null:ee.anchorY!==null?N.top+ee.anchorY*N.scale:fe!==null?fe.top+De+24:null,_e=n?null:J.rest,Se=typeof _e=="function"?null:ke(_e,"list"),Ft=typeof _e=="function"?ee&&_e(ee):Se?.parts.Card&&react.isValidElement(Se.parts.Card)?at(Se.parts.Card,ve):i?jsxRuntime.jsx(Ue,{...ve?{className:ve}:{},children:Se?.rest}):null,Bt=ee&&Vt!==null&&N.compactCardLeft!==null&&Ft?jsxRuntime.jsx(P.Provider,{value:ee,children:jsxRuntime.jsx("div",{className:"docx-review__slot docx-review__slot--compact","data-testid":"review-compact-card",style:{position:"absolute",top:Vt,left:N.compactCardLeft,width:we},children:Ft})}):null,en=F?i||"List"in X?pe("List",Xo):typeof J.rest=="function"?null:J.rest:i||"Markers"in X?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[pe("Markers",Ut),Bt]}):typeof J.rest=="function"?null:J.rest;return jsxRuntime.jsx(Ro,{items:M,children:jsxRuntime.jsx(pt.Provider,{value:Jo,children:n&&react.isValidElement(a)?jsxRuntime.jsx(react$1.Slot,{...Ht,children:react.cloneElement(a,void 0,a.props.children,i?F?jsxRuntime.jsx(qe,{stack:l,positions:tt,collapsed:Lt,scale:N.scale,offset:N.top,window:fe}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[Ut,Bt]}):null,qt)}):jsxRuntime.jsxs("aside",{...Ht,children:[F&&t!==void 0?jsxRuntime.jsx("div",{className:"docx-review__furniture","data-testid":"review-furniture",children:t}):null,en,qt]})})})}function qe({stack:e=true,positions:t,collapsed:n,scale:o=1,offset:a=0,window:r=null,children:s,className:i,hidden:l}){let{review:c,measure:m,cardClassName:d}=H();if(l)return null;let f=typeof s=="function"?null:ke(s,"list"),u=yt(c.items),p=c.items.filter(y=>!wt(y,u));return p.length===0?typeof s=="function"?null:f?.parts.Empty??jsxRuntime.jsx(Ct,{}):jsxRuntime.jsx("div",{className:`docx-review__list${i?` ${i}`:""}`,children:p.map(y=>{let b=e?t?.get(y.key)??y.anchorY:y.anchorY,C=b==null?null:a+b*o;if(C!==null&&r&&(C<r.top||C>r.bottom))return null;let w=C===null?{}:{position:"absolute",top:C};return jsxRuntime.jsx(P.Provider,{value:y,children:jsxRuntime.jsx("div",{className:"docx-review__slot",style:w,...n?.has(y.key)?{"data-collapsed":""}:{},ref:h=>{m(h,y.key);},children:typeof s=="function"?s(y):f?.parts.Card&&react.isValidElement(f.parts.Card)?at(f.parts.Card,d):jsxRuntime.jsx(Ue,{...d?{className:d}:{},children:f?.rest})})},y.key)})})}qe.docxReviewPart="List";function Rt({scale:e=1,offset:t=0,window:n=null,className:o,hidden:a,icon:r}){let{review:s,authorSlots:i,authorInfo:l}=H(),c=ct(),m=U(),{roots:d,stackedTops:f}=react.useMemo(()=>{let u=yt(s.items),p=s.items.filter(C=>!wt(C,u)),y=new Map,b=Number.NEGATIVE_INFINITY;for(let C of p){if(C.anchorY===null)continue;let w=Math.max(t+C.anchorY*e,b);y.set(C.key,w),b=w+dr;}return {roots:p,stackedTops:y}},[s.items,t,e]);return a?null:jsxRuntime.jsx("div",{className:`docx-review__markers${o?` ${o}`:""}`,children:d.map(u=>{let p=f.get(u.key);return p===void 0||n&&(p<n.top||p>n.bottom)?null:jsxRuntime.jsx("button",{type:"button",className:"docx-review__marker","data-testid":"review-marker","data-kind":u.kind==="revision"?u.revisionKind:u.kind,...u.author?{"data-review-author":u.author,"data-review-author-slot":ye(l.get(u.author),i.get(u.author)??0)}:{},style:{position:"absolute",top:p,...u.author?{"--doc-review-author-current":lt(l.get(u.author),i.get(u.author)??0)}:{}},title:u.author?`${u.author}: ${u.text}`:u.text,"aria-label":`${m("review.showPane")}: ${u.author?`${u.author}. `:""}${u.text}`,onMouseDown:W,onClick:()=>{u.kind==="comment"&&u.resolved&&c.open(u.key),s.setPaneOpen(true),s.setActive(u.key);},children:(typeof r=="function"?r(u):r)??(u.kind==="comment"&&u.resolved?Le():q(uo(u)))},u.key)})})}Rt.docxReviewPart="Markers";function bt({top:e=null,drafting:t=false,className:n,hidden:o,children:a}){let{beginDraft:r,readOnly:s}=H(),i=U();if(o||t||e===null||s)return null;let l={type:"button",className:`docx-review__add${n?` ${n}`:""}`,"data-testid":"review-add-comment",style:{position:"absolute",top:e},"aria-label":i("common.comment"),title:i("common.comment"),onMouseDown:W,onClick:r};return a?jsxRuntime.jsx(react$1.Slot,{...l,children:a}):jsxRuntime.jsx("button",{...l,children:q(io)})}bt.docxReviewPart="AddComment";function gt({className:e,hidden:t}){let{review:n,allItems:o,authorSlots:a,authorInfo:r}=H(),s=U(),i=react.useRef(null),[l,c]=react.useState(null),m=react.useRef(null),d=react$1.useEditorState(E=>E.reviewDisplayMode??"all-markup");react.useEffect(()=>{m.current=null,c(null);},[d]);let f=o.find(E=>E.isActive)??null,u=react.useRef(f);u.current=f;let p=f?.key??null,y=f!==null&&Eo(f,n.items,n.paneOpen),b=react.useRef(false);b.current=l!==null,react.useEffect(()=>{let E=i.current,x=E?.closest(".docx-review"),_=x?.closest(".docx-editor__scroll-container")??x?.offsetParent;if(!E||!x||!_)return;let V=(G,S)=>{m.current=null,c(dt(G,x,S));},L=G=>{let S=G.target;if(!(S instanceof Element)||E.contains(S))return;let F=S.closest("[data-revision-id]");if(F instanceof HTMLElement&&_.contains(F)){let M=F.classList.contains("docx-table-row--revision");if(F.dataset.revisionKind==="format"||M){V(F,M);return}}b.current&&(m.current=null,c(null));};return _.addEventListener("pointerdown",L,true),_.addEventListener("mousedown",L,true),()=>{_.removeEventListener("pointerdown",L,true),_.removeEventListener("mousedown",L,true);}},[]),react.useEffect(()=>{let E=i.current,x=E?.closest(".docx-review"),_=x?.closest(".docx-editor__scroll-container")??x?.offsetParent;if(!E||!x||!_)return;let V=u.current;if(!V){m.current!==null&&(m.current=null,c(null));return}if(!y){m.current=null,c(null);return}m.current=V.key,c(null);let L=false,G=requestAnimationFrame(()=>{if(L)return;let S=Io(_,V);if(!S){c(null);return}c(dt(S,x,S.classList.contains("docx-table-row--revision")));});return ()=>{L=true,cancelAnimationFrame(G);}},[d,p,y]);let C=react.useMemo(()=>l?No(l,o):null,[o,l]),w=C&&(C.revisionKind==="format"||C.revisionKind==="structural")?C:null,h=react.useRef(false);if(react.useEffect(()=>{if(w){h.current=true;return}h.current&&(h.current=false,c(null));},[w]),t)return null;let D=l?.kind==="format"?"format":"structural";return jsxRuntime.jsx("div",{ref:i,className:`docx-review__balloon-root${e?` ${e}`:""}`,children:l===null||d!=="all-markup"||w&&n.items.some(E=>E.id===w.id)&&n.paneOpen?null:jsxRuntime.jsx("div",{className:"docx-review__balloon","data-testid":"review-balloon",style:{left:l.left,top:l.above?l.top-6:l.bottom+6,transform:l.above?"translateY(-100%)":void 0},onMouseDown:W,children:w?jsxRuntime.jsx(P.Provider,{value:w,children:jsxRuntime.jsxs("div",{className:"docx-review__card","data-testid":"review-balloon-card","data-kind":w.revisionKind??"revision",...w.author?{"data-review-author":w.author,"data-review-author-slot":ye(r.get(w.author),a.get(w.author)??0)}:{},style:le(w.author,r.get(w.author),a.get(w.author)??0),onClick:()=>n.setActive(w.key),children:[jsxRuntime.jsxs("div",{className:"docx-review__head",children:[jsxRuntime.jsx(ge,{}),jsxRuntime.jsxs("div",{className:"docx-review__meta",children:[jsxRuntime.jsx(Ce,{}),jsxRuntime.jsx(he,{})]}),w.kind==="revision"&&!w.readOnly?jsxRuntime.jsxs("div",{className:"docx-review__actions",children:[jsxRuntime.jsx(Ve,{}),jsxRuntime.jsx(Fe,{})]}):null]}),jsxRuntime.jsx(xe,{})]})}):jsxRuntime.jsxs("div",{className:"docx-review__card","data-testid":"review-balloon-card","data-kind":D,...l.author?{"data-review-author":l.author,"data-review-author-slot":ye(r.get(l.author),a.get(l.author)??0)}:{},style:le(l.author,r.get(l.author),a.get(l.author)??0),children:[jsxRuntime.jsxs("div",{className:"docx-review__head",children:[jsxRuntime.jsx("span",{className:"docx-review__avatar","aria-hidden":"true",children:pr(l.author)}),jsxRuntime.jsxs("div",{className:"docx-review__meta",children:[jsxRuntime.jsx("span",{className:"docx-review__author",children:l.author||s("comments.unknown")}),l.date?jsxRuntime.jsx(wr,{raw:l.date}):null]})]}),jsxRuntime.jsx("div",{className:"docx-review__summary",children:jsxRuntime.jsx("span",{className:"docx-review__label","data-kind":D,children:s(ut(D))})})]})})})}gt.docxReviewPart="Balloon";function pr(e){let t=e.trim().split(/\s+/).filter(Boolean);return t.length===0?"?":t.slice(0,2).map(n=>n[0].toUpperCase()).join("")}function wr({raw:e}){let t=new Date(e);return Number.isNaN(t.getTime())?null:jsxRuntime.jsx("time",{className:"docx-review__time",dateTime:e,children:Oo.format(t)})}function Ct({className:e,hidden:t,children:n}){let o=U();return t?null:jsxRuntime.jsx("div",{className:`docx-review__empty${e?` ${e}`:""}`,"data-testid":"review-empty",children:n??o("review.empty")})}Ct.docxReviewPart="Empty";function Ue({className:e,asChild:t,hidden:n,children:o}){let{review:a,authorSlots:r,authorInfo:s}=H(),i=react.useContext(P),l=react.useId(),c=U();if(n||!i)return null;let m=r.get(i.author)??0,d=!t&&i.kind==="comment"&&i.resolved,f={className:`docx-review__card${e?` ${e}`:""}`,"data-testid":"review-card",...d?{}:{"aria-labelledby":`${l}-author ${l}-summary`},"data-kind":i.kind==="revision"?i.revisionKind??"revision":i.kind,...i.author?{"data-review-author":i.author,"data-review-author-slot":ye(s.get(i.author),m)}:{},...i.kind==="custom"&&i.item.kind==="custom"?{"data-node-name":i.item.name}:{},...i.isActive?{"data-active":""}:{},...i.kind==="comment"&&i.resolved?{"data-resolved":""}:{},...d?{"data-resolved-miniature":""}:{},style:le(i.author,s.get(i.author),m),...d?{}:{tabIndex:0,role:"button"},id:l,...d?{}:{onMouseDown:u=>{u.target?.closest("[data-review-selectable]")||u.currentTarget.focus({preventScroll:true});},onClick:()=>a.setActive(i.key),onKeyDown:u=>{u.target===u.currentTarget&&(u.key!=="Enter"&&u.key!==" "||(u.preventDefault(),a.setActive(i.key)));}}};return t?jsxRuntime.jsx(react$1.Slot,{...f,children:o}):d?jsxRuntime.jsx(bo,{...f,label:c("review.showResolvedComment"),statusLabel:c("review.resolved"),entryKey:i.key,onActivate:()=>a.setActive(i.key),onDeactivate:()=>a.setActive(null),children:jsxRuntime.jsx(_o,{children:o})}):jsxRuntime.jsx("div",{...f,children:jsxRuntime.jsx(_o,{children:o})})}Ue.docxReviewPart="Card";function _o({children:e}){let t=react.useContext(P),n=react.useMemo(()=>yr(e),[e]),o=(r,s)=>r in n?n[r]:s;if(!t)return null;if(t.kind==="custom"&&t.item.kind==="custom"){let r=t.item;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"docx-review__head",children:[o("Avatar",null),jsxRuntime.jsx("div",{className:"docx-review__meta",children:o("Author",jsxRuntime.jsx("span",{className:"docx-review__author","data-testid":"review-custom-title",children:r.title}))})]}),o("Summary",r.detail?jsxRuntime.jsx("div",{className:"docx-review__summary","data-testid":"review-summary","data-review-selectable":"",children:jsxRuntime.jsx("span",{className:"docx-review__text",children:r.detail})}):null),n.__extra]})}let a=t.kind==="revision"&&!t.readOnly;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"docx-review__head",children:[o("Avatar",jsxRuntime.jsx(ge,{})),jsxRuntime.jsxs("div",{className:"docx-review__meta",children:[o("Author",jsxRuntime.jsx(Ce,{})),o("Time",jsxRuntime.jsx(he,{}))]}),a||t.kind==="comment"?jsxRuntime.jsxs("div",{className:"docx-review__actions",children:[o("Accept",jsxRuntime.jsx(Ve,{})),o("Reject",jsxRuntime.jsx(Fe,{})),o("Resolve",jsxRuntime.jsx(Mo,{})),o("Reopen",jsxRuntime.jsx(ko,{})),o("Delete",t.kind==="comment"?jsxRuntime.jsx(Be,{}):null)]}):null]}),o("Summary",jsxRuntime.jsx(xe,{})),o("Replies",jsxRuntime.jsx(ht,{})),o("Reply",jsxRuntime.jsx(To,{})),n.__extra]})}function yr(e){let t={},n=[],o=a=>{if(Array.isArray(a)){a.forEach(o);return}if(!a||typeof a!="object"||!("type"in a)){a&&n.push(a);return}if(a.type===react.Fragment){o(a.props.children);return}let r=a.type.docxReviewPart;r?t[r]=a:n.push(a);};return o(e),n.length>0&&(t.__extra=n),t}function ge({className:e,asChild:t,hidden:n,children:o}){let{authorInfo:a}=H(),r=react.useContext(P);if(n||!r||o===void 0&&!r.initials)return null;let s={className:`docx-review__avatar${e?` ${e}`:""}`,"data-testid":"review-avatar","aria-hidden":true};if(t)return jsxRuntime.jsx(react$1.Slot,{...s,children:o});let i=a.get(r.author)?.style?.avatarUrl,l=o??(i?jsxRuntime.jsx("img",{className:"docx-review__avatar-img",src:i,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer"}):void 0)??r.initials;return jsxRuntime.jsx("span",{...s,children:l})}ge.docxReviewPart="Avatar";function Ce({className:e,asChild:t,hidden:n,children:o}){let a=react.useContext(P),r=U();if(n||!a)return null;let s=a.author||r("comments.unknown"),i={className:`docx-review__author${e?` ${e}`:""}`,"data-testid":"review-author"};return t?jsxRuntime.jsx(react$1.Slot,{...i,children:o}):jsxRuntime.jsx("span",{...i,children:o??s})}Ce.docxReviewPart="Author";function he({className:e,asChild:t,hidden:n,children:o}){let a=react.useContext(P);if(n||!a)return null;let r=a.date;if(!r)return null;let s=new Date(r);if(Number.isNaN(s.getTime()))return null;let i={className:`docx-review__time${e?` ${e}`:""}`,"data-testid":"review-time",dateTime:r};return t?jsxRuntime.jsx(react$1.Slot,{...i,children:o}):jsxRuntime.jsx("time",{...i,children:o??Oo.format(s)})}he.docxReviewPart="Time";var Oo=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function xe({className:e,asChild:t,hidden:n,children:o}){let a=react.useContext(P),r=U();if(n||!a)return null;let s=a.text,i=a.kind!=="revision"?null:Ao(a.item,r),l=a.kind==="revision"&&a.revisionKind==="replace",c={className:`docx-review__summary${e?` ${e}`:""}`,"data-testid":"review-summary","data-review-selectable":""};return t?jsxRuntime.jsx(react$1.Slot,{...c,children:o}):jsxRuntime.jsx("div",{...c,children:o??(l?jsxRuntime.jsxs("span",{className:"docx-review__text",children:[r("review.replaced")," ",jsxRuntime.jsxs("span",{className:"docx-review__removed",children:['"',a.replacedText,'"']})," ",r("review.replacedWith")," ",jsxRuntime.jsxs("span",{className:"docx-review__added",children:['"',s,'"']})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[i?jsxRuntime.jsx("span",{className:"docx-review__label","data-kind":a.kind==="revision"?a.revisionKind:"revision",children:i}):null,s?jsxRuntime.jsx("span",{className:"docx-review__text",children:s}):null]}))})}xe.docxReviewPart="Summary";function Ve({className:e,asChild:t,hidden:n,children:o,icon:a}){let{readOnly:r,review:s}=H(),i=react.useContext(P),l=U();if(n||!i||i.kind!=="revision"||i.readOnly)return null;let c=l("review.accept"),m=r?l("editingMode.viewingHint"):null,d={type:"button",className:`docx-review__action${e?` ${e}`:""}`,"data-testid":"review-accept","aria-label":c,title:m??c,disabled:r,onMouseDown:W,onClick:f=>{f.stopPropagation(),!r&&s.accept(i);}};return t?jsxRuntime.jsx(te,{engineDisabled:r,disabledReason:m,slotProps:d,children:o}):jsxRuntime.jsx("button",{...d,children:a??o??q(Re)})}Ve.docxReviewPart="Accept";function Fe({className:e,asChild:t,hidden:n,children:o,icon:a}){let{readOnly:r,review:s}=H(),i=react.useContext(P),l=U();if(n||!i||i.kind!=="revision"||i.readOnly)return null;let c=l("review.reject"),m=r?l("editingMode.viewingHint"):null,d={type:"button",className:`docx-review__action${e?` ${e}`:""}`,"data-testid":"review-reject","aria-label":c,title:m??c,disabled:r,onMouseDown:W,onClick:f=>{f.stopPropagation(),!r&&s.reject(i);}};return t?jsxRuntime.jsx(te,{engineDisabled:r,disabledReason:m,slotProps:d,children:o}):jsxRuntime.jsx("button",{...d,children:a??o??q(lo)})}Fe.docxReviewPart="Reject";function Be({className:e,asChild:t,hidden:n,children:o,icon:a}){let{readOnly:r,review:s}=H(),i=react.useContext(P),{t:l}=react$1.useTranslation();if(n||!i||i.kind==="custom"||i.kind==="revision"&&i.readOnly)return null;let c=i.kind==="comment"?l("review.deleteComment"):l("review.discardChange"),m=r?l("editingMode.viewingHint"):null,d={type:"button",className:`docx-review__action${e?` ${e}`:""}`,"data-testid":"review-delete","aria-label":c,title:m??c,disabled:r,onMouseDown:W,onClick:f=>{f.stopPropagation(),!r&&s.remove(i);}};return t?jsxRuntime.jsx(te,{engineDisabled:r,disabledReason:m,slotProps:d,children:o}):jsxRuntime.jsx("button",{...d,children:a??o??q(co)})}Be.docxReviewPart="Delete";function ht({className:e,hidden:t}){let{byId:n}=H(),o=react.useContext(P);if(t||!o||o.kind==="custom")return null;let a=o.replyIds.map(r=>n.get(r)).filter(r=>r!==void 0);return a.length===0?null:jsxRuntime.jsx("ol",{className:`docx-review__replies${e?` ${e}`:""}`,children:a.map(r=>jsxRuntime.jsx(P.Provider,{value:r,children:jsxRuntime.jsxs("li",{className:"docx-review__reply","data-testid":"review-reply",children:[jsxRuntime.jsxs("div",{className:"docx-review__head",children:[jsxRuntime.jsx(ge,{}),jsxRuntime.jsxs("div",{className:"docx-review__meta",children:[jsxRuntime.jsx(Ce,{}),jsxRuntime.jsx(he,{})]}),jsxRuntime.jsx("div",{className:"docx-review__actions",children:jsxRuntime.jsx(Be,{})})]}),jsxRuntime.jsx(xe,{})]})},r.key))})}ht.docxReviewPart="Replies";var Rr=Object.assign(vr,{List:qe,Empty:Ct,Card:Ue,Avatar:ge,Author:Ce,Time:he,Summary:xe,Accept:Ve,Reject:Fe,Resolve:Mo,Reopen:ko,Delete:Be,Replies:ht,Reply:To,Markers:Rt,AddComment:bt,Draft:Do,Balloon:gt});var Ae=8;function Lo(e){let t=/^var\(--doc-review-author-(\d{1,2})\)$/.exec(e);return t?Number(t[1])%Ae:null}function Ze(e,t,n,o){let a=new Map(e.map(i=>[i.author,i])),r=new Map,s=new Map;for(let i of t){if(s.has(i.actorId))continue;let l=collaboration.safeParticipantColor(o?.(i.name));if(l!==void 0){s.set(i.actorId,{color:l,slot:Lo(l)});continue}let c=collaboration.safeParticipantColor(i.color);if(c!==void 0){s.set(i.actorId,{color:c,slot:null});continue}let m=a.get(i.name),d=collaboration.safeParticipantColor(n?.(i.name));if(d!==void 0){s.set(i.actorId,{color:d,slot:Lo(d)??(m?m.slot%Ae:null)});continue}if(m!==void 0){let u=m.slot%Ae;s.set(i.actorId,{color:collaboration.safeParticipantColor(m.color)??`var(--doc-review-author-${u})`,slot:u});continue}let f=r.get(i.name);f===void 0&&(f=e.length+r.size,r.set(i.name,f)),s.set(i.actorId,{color:`var(--doc-review-author-${f%Ae})`,slot:f%Ae});}return s}function xt(e,t,n,o){return Ze(e,[t],n,o).get(t.actorId)}function At(e){let t=e.trim().split(/\s+/,2),n="";for(let o of t){let a=[...o][0];a!==void 0&&(n+=a.toUpperCase());}return n}function Ko(e){return [...e].sort((t,n)=>{if(t.isLocal!==n.isLocal)return t.isLocal?-1:1;let o=t.name.localeCompare(n.name);return o!==0?o:t.actorId<n.actorId?-1:t.actorId>n.actorId?1:0})}function je(e,t,n){for(let o of e)if(o.author===t)return o.style?.avatarUrl;return n?.(t)?.avatarUrl}var Cr=e=>e.collaborationStatus;function ae(){let e=react$1.useDocxEditor();return react$1.useEditorState(Cr),e?.collaborationSession()??null}var Et=Object.freeze([]);function Ar(e,t){if(e===t)return true;if(e.length!==t.length)return false;for(let n=0;n<e.length;n+=1){let o=e[n],a=t[n];if(o.actorId!==a.actorId||o.name!==a.name||o.color!==a.color||o.role!==a.role||o.isLocal!==a.isLocal)return false}return true}function $o(e,t){if(!e)return t.current=Et,Et;let n=e.participants();return Ar(t.current,n)?t.current:(t.current=n,n)}function ze(e){let t=ae(),n=e===void 0?t:e,o=react.useRef(Et);return react.useSyncExternalStore(a=>n?.subscribeParticipants(()=>a())??(()=>{}),()=>$o(n,o),()=>$o(n,o))}var Ho=react.createContext(null);function Dr(e){return {"--doc-collaboration-accent":e.color}}function qo(e){return e!==void 0?{avatarUrl:e}:{}}function Uo({participant:e,className:t,children:n}){let o=react$1.useDocxEditor(),a=react$1.useReviewAuthors(),s=react.useContext(Ho)?.get(e.actorId)??xt(a,e,o?l=>o.presenceColorFor(l):void 0,o?l=>o.getReviewAuthorStyle(l)?.color:void 0),i=Tr(e.name);return jsxRuntime.jsx("span",{className:`docx-collaboration-avatar${t?` ${t}`:""}`,"data-collaboration-avatar":"",...e.isLocal?{"data-local":""}:{},...s.slot!==null?{"data-collaboration-author-slot":s.slot}:{},title:e.name,role:"img","aria-label":e.name,style:Dr(s),children:n??(i!==void 0?jsxRuntime.jsx("img",{className:"docx-collaboration-avatar__image",src:i,alt:""}):At(e.name))})}function Tr(e){let t=react$1.useDocxEditor(),n=react$1.useReviewAuthors();return je(n,e,t?o=>t.getReviewAuthorStyle(o):void 0)}function Or({session:e,max:t,className:n,children:o}){let a=react$1.useDocxEditor(),r=ze(e),s=react$1.useReviewAuthors(),{t:i}=react$1.useTranslation(),l=react.useMemo(()=>Ze(s,r,a?p=>a.presenceColorFor(p):void 0,a?p=>a.getReviewAuthorStyle(p)?.color:void 0),[s,r,a]),c=react.useMemo(()=>{let p=a?b=>a.getReviewAuthorStyle(b):void 0,y=new Map;for(let b of r){if(y.has(b.name))continue;let C=je(s,b.name,p);C!==void 0&&y.set(b.name,C);}return y},[a,r,s]),m=react.useMemo(()=>Ko(r),[r]);if(m.length===0)return null;let d=t===void 0?m:m.slice(0,Math.max(0,t)),f=m.length-d.length,u=i("collaboration.moreParticipants",{count:f});return jsxRuntime.jsxs("span",{className:`docx-collaboration-avatars${n?` ${n}`:""}`,"data-collaboration-avatars":"",role:"group","aria-label":i("collaboration.participants"),children:[jsxRuntime.jsx(Ho.Provider,{value:l,children:d.map(p=>o?jsxRuntime.jsx(react.Fragment,{children:o({participant:p,color:l.get(p.actorId).color,initials:At(p.name),...qo(c.get(p.name))})},p.actorId):jsxRuntime.jsx(Uo,{participant:p},p.actorId))}),f>0?jsxRuntime.jsx("span",{className:"docx-collaboration-avatar","data-collaboration-avatar":"","data-overflow":"",title:u,role:"img","aria-label":u,children:`+${f}`}):null]})}var We=Object.freeze([]);function Lr(){return We}function Kr(){let e=react.useRef(null);if(e.current===null){let t=We,n=false,o=new Set;e.current={subscribe:a=>(o.add(a),()=>o.delete(a)),read:()=>t,write:a=>{t=a.length===0?We:a,!n&&(n=true,queueMicrotask(()=>{n=false;for(let r of [...o])r();}));}};}return e.current}function $r({session:e,children:t}){let n=react$1.useDocxEditor(),o=ae(),a=e===void 0?o:e,r=ze(a),s=react$1.useReviewAuthors(),i=Kr(),l=react.useSyncExternalStore(i.subscribe,i.read,Lr);if(react.useEffect(()=>{if(!(!n||!a))return n.setRemoteCaretLabelHost({publish:i.write}),()=>{n.setRemoteCaretLabelHost(null),i.write(We);}},[n,a,i]),l.length===0)return null;let c=Ze(s,r);return jsxRuntime.jsx(jsxRuntime.Fragment,{children:l.map(m=>{let{selection:d}=m,f=r.find(y=>y.actorId===d.actorId)??null,u=m.element.style.getPropertyValue("--doc-remote-color"),p=u!==""?u:c.get(d.actorId)?.color??xt(s,{actorId:d.actorId,name:d.name,...d.color!==void 0?{color:d.color}:{},isLocal:false}).color;return reactDom.createPortal(t?t({selection:d,participant:f,color:p,...qo(je(s,d.name,n?y=>n.getReviewAuthorStyle(y):void 0))}):d.name,m.element,d.actorId)})})}var Hr=Object.freeze({CaretLabels:$r,Avatars:Or,Avatar:Uo});function Ee(e){let t=react$1.useDocxEditor();return react.useMemo(()=>e||(t?.getCustomNodeDefinitions()??[]).filter(chunkOMUXC73J_cjs.j),[e,t])}var Zr=".docx-content-control-boundary";function de(e,t){let{node:n,definition:o,controlId:a}=e,r=a?t?.getReviewItems().find(l=>l.kind==="custom"&&l.item.id===a):void 0;if(r&&r.kind==="custom"){let l=r.item;return {...n,attrs:l.attrs,text:l.text,...l.data===void 0?{}:{data:l.data},...a?{nodeId:a}:{}}}let s=a?jr(t,a,o):void 0,i=o.fromDocx?o.fromDocx({attrs:n.attrs,text:"",...s===void 0?{}:{data:s}}):n.attrs;return i===null?null:{...n,attrs:i,...s===void 0?{}:{data:s},...a?{nodeId:a}:{}}}function jr(e,t,n){let o=e?.surface;if(!o)return;let a=editor.partOfNodeId(o.session,t),r=store.customNodePayloadsByControl(o.session.currentPackage(),(a??o.session.part()).name,o.session.part().name).get(t);if(!r)return;let s=chunkOMUXC73J_cjs.e(n.schema,r.data);return s.ok?s.value:void 0}function me(e,t){let n=e?.closest?.(Zr),o=n?.closest(".docx-content-control-chrome"),a=o?.getAttribute("data-tag"),r=a?chunkOMUXC73J_cjs.c(a):null;if(!n||!r||!a)return null;let s=t.find(i=>i.tagPrefix===r.prefix&&i.name===r.name);return s?{node:{name:r.name,attrs:r.attrs,tag:a,rect:n.getBoundingClientRect()},definition:s,controlId:o?.getAttribute("data-docx-content-control")??null}:null}var Nt=".docx-content-control-boundary",Wr=e=>{if(!chunkOMUXC73J_cjs.k.test(e.tagPrefix)||!chunkOMUXC73J_cjs.k.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 Gr(e){let{onNodeClick:t,onNodeHover:n}=e,o=react$1.useDocxEditor(),a=Ee(e.nodes);return react.useEffect(()=>{let r=document.createElement("style"),s=[];for(let i of a){let l=Wr(i);if(l.length===0)continue;let c=i.chrome?.color!==void 0&&CSS.supports("color",i.chrome.color)?i.chrome.color:"var(--doc-accent)";s.push(`${l.map(m=>`${m} ${Nt}`).join(", ")} {`," pointer-events: auto !important;"," opacity: 1;"," border: none;",` background: color-mix(in srgb, ${c} 12%, transparent);`," border-radius: 6px;"," cursor: default;","}");}return r.textContent=s.join(`
2
- `),document.head.append(r),()=>r.remove()},[a]),react.useEffect(()=>{let r=null,s=null,i=d=>me(document.elementFromPoint(d.clientX,d.clientY),a),l=d=>{let f=d.button===0?i(d):null;r=f?.controlId??null,s=f?.node.tag??null;},c=d=>{let f=r,u=s;if(r=null,s=null,u===null)return;let p=i(d);if(!p||p.node.tag!==u||f!==null&&p.controlId!==f)return;let y=de(p,o);y&&(p.definition.onClick?.(y),t?.(y));},m=d=>{let f=me(d.target,a);if(!f||d.relatedTarget?.closest?.(Nt)===d.target.closest(Nt))return;let p=de(f,o);p&&(f.definition.onHover?.(p),n?.(p));};return document.addEventListener("pointerdown",l,true),document.addEventListener("pointerup",c,true),document.addEventListener("mouseover",m),()=>{document.removeEventListener("pointerdown",l,true),document.removeEventListener("pointerup",c,true),document.removeEventListener("mouseover",m);}},[a,o,t,n]),null}var ta=e=>e.editingMode==="viewing";function Yo(e){let{onEditNode:t,onRemoveRefused:n,remove:o=true}=e,a=Ee(e.nodes),r=react$1.useContextMenuTarget(),s=react$1.useDocxEditor(),{t:i}=react$1.useTranslation(),l=react.useMemo(()=>r?me(r,a):null,[r,a]),c=react.useMemo(()=>l?de(l,s):null,[l,s]),m=react$1.useEditorState(ta),d=react.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,u=f.label??f.name,p=!m&&(f.onEdit!==void 0||t!==void 0),y=!m&&o&&c.nodeId!==void 0&&s!==null;return !d&&!p&&!y?null:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[d?jsxRuntime.jsxs("div",{className:"docx-contextmenu__custom-info","data-testid":"custom-node-info",children:[jsxRuntime.jsx("span",{className:"docx-contextmenu__custom-title",children:d.title}),d.detail?jsxRuntime.jsx("span",{className:"docx-contextmenu__custom-detail",children:d.detail}):null]}):null,p?jsxRuntime.jsx(react$1.ContextMenuItem,{label:i("contextMenu.editCustomNode",{label:u}),className:"docx-contextmenu__custom-edit",onSelect:()=>{f.onEdit?.(c),t?.(c,f);}}):null,y?jsxRuntime.jsx(react$1.ContextMenuItem,{label:i("contextMenu.removeCustomNode",{label:u}),className:"docx-contextmenu__custom-remove",onSelect:()=>{let b=chunkOMUXC73J_cjs.q(s,c.nodeId);b.ok||n?.(c,b.reason);}}):null,jsxRuntime.jsx("div",{role:"separator",className:"docx-toolbar__menu-separator"})]})}Yo.docxRowPlacement="start";var _t=Object.freeze({status:"inactive",reason:void 0,lastFailure:void 0,live:false,diverged:false,attached:false});function Zo(e,t){return e===t?true:!e||!t?false:e.code===t.code&&e.detail===t.detail}function aa(e,t){return e.status===t.status&&Zo(e.reason,t.reason)&&Zo(e.lastFailure,t.lastFailure)}function ia(e){return e.attached??false}function jo(e,t){if(!e)return t.current=_t,_t;let n=e.statusSnapshot(),o=ia(e);if(aa(t.current,n)&&t.current.attached===o)return t.current;let a=Object.freeze({status:n.status,reason:n.reason,lastFailure:n.lastFailure,live:n.status==="ready",diverged:n.status==="error"||n.status==="destroyed",attached:o});return t.current=a,a}function sa(e){let t=ae(),n=e===void 0?t:e,o=react.useRef(_t);return react.useSyncExternalStore(a=>n?.subscribeStatus(()=>a())??(()=>{}),()=>jo(n,o),()=>jo(n,o))}function ca({collaboration:e,fallback:t=null,author:n,children:o,...a}){let{document:r,modules:s,session:i}=e;if(!r)return jsxRuntime.jsx(jsxRuntime.Fragment,{children:t});let l=n??i?.identity.name;return jsxRuntime.jsx(react$1.DocxEditorRoot,{document:r,modules:s,...l!==void 0?{author:l}:{},...a,children:o},i?.sessionId??"local")}var fa=Symbol("useDocumentCollaboration.createRoom");async function va(e){let{createDocumentCollaboration:t}=await import('../document-session-YZRHVYCK.cjs');return t(e)}function pa(e){return e[fa]??va}function wa(e){return e?`${e.documentId}:${e.bootstrap.kind}:${e.identity.actorId}`:""}function ya(e={}){let t=react.useId(),n=chunkGDTCNTK7_cjs.b({ownerKey:`react-document:${t}`,hookName:"useDocumentCollaboration",createRoom:pa(e),hostModules:e.modules??chunkGDTCNTK7_cjs.a,autoRoom:e.room??null,autoKey:wa(e.room??null),rejoinOptionsOf:o=>({...o,bootstrap:{kind:"join"}}),identityOf:o=>o.identity});return react.useMemo(()=>({document:n.document,modules:n.modules,session:n.session,pending:n.pending,error:n.error,connect:n.connect,leave:n.leave}),[n])}Object.defineProperty(exports,"reviewModule",{enumerable:true,get:function(){return chunkOMUXC73J_cjs.o}});Object.defineProperty(exports,"collaborationModule",{enumerable:true,get:function(){return chunkQLZH2Q2C_cjs.b}});exports.CustomNodeChrome=Gr;exports.CustomNodeContextMenu=Yo;exports.DocxEditorCollaboration=Hr;exports.DocxEditorCollaborationRoot=ca;exports.DocxEditorReview=Rr;exports.activatedCustomNodeOf=de;exports.resolveCustomNodeActivation=me;exports.useCollaborationParticipants=ze;exports.useCollaborationSession=ae;exports.useCollaborationStatus=sa;exports.useCustomNodeDefinitions=Ee;exports.useDocumentCollaboration=ya;exports.useReview=Te;exports.useReviewAuthor=sr;exports.useReviewItem=ir;exports.useReviewOf=no;exports.useStackedReviewPositions=hn;
1
+ 'use strict';var chunkOMUXC73J_cjs=require('../chunk-OMUXC73J.cjs'),chunkGDTCNTK7_cjs=require('../chunk-GDTCNTK7.cjs'),chunkQLZH2Q2C_cjs=require('../chunk-QLZH2Q2C.cjs'),react=require('react'),react$1=require('@docx-editor.dev/react'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom'),collaboration=require('@docx-editor.dev/core/collaboration'),store=require('@docx-editor.dev/core/store'),editor=require('@docx-editor.dev/core/editor');var dn=new Set(["List","Markers","AddComment","Draft","Balloon"]),mn=new Set(["Card","Empty"]);function ke(e,t){let n=t==="root"?dn:mn,o={},a=[],r=s=>{if(Array.isArray(s)){for(let l of s)r(l);return}if(!react.isValidElement(s)){s!=null&&s!==false&&a.push(s);return}if(s.type===react.Fragment){r(s.props.children);return}let i=s.type.docxReviewPart;i&&n.has(i)?o[i]=s:a.push(s);};return r(e),{parts:o,rest:a}}function at(e,t){if(!t)return e;let n=e.props.className;return react.cloneElement(e,{className:`${t}${n?` ${n}`:""}`})}var fn={scale:96/72,top:0,left:null,compactCardLeft:null},vn=16,we=300,pn=12,De=600;function eo(e,t,n,o,a=false){let[r,s]=react.useState(fn);return react.useEffect(()=>{let i=t.current;if(!e||!i)return;let l=i.offsetParent,c=l?.querySelector(".docx-paginated-surface")??null,m=()=>{s(p=>{let y=c&&l?c.getBoundingClientRect():null,b=y&&l?l.getBoundingClientRect():null,C=y&&b&&l?y.right-b.left-l.clientLeft+l.scrollLeft+vn:null,w={scale:e.getRenderScale(),top:y&&b&&l?y.top-b.top-l.clientTop+l.scrollTop:0,left:C,compactCardLeft:C===null||!l?null:l.scrollLeft+l.clientWidth-C-we-pn};return p.scale===w.scale&&p.top===w.top&&p.left===w.left&&p.compactCardLeft===w.compactCardLeft?p:w});};m();let d=new ResizeObserver(m);if(l&&d.observe(l),c&&d.observe(c),!a||!l)return ()=>d.disconnect();let f=0,u=()=>{f===0&&(f=requestAnimationFrame(()=>{f=0,m();}));};return l.addEventListener("scroll",u,{passive:true}),()=>{f!==0&&cancelAnimationFrame(f),l.removeEventListener("scroll",u),d.disconnect();}},[e,t,n,o,a]),r}function to(e,t,n){let[o,a]=react.useState(null);return react.useEffect(()=>{let r=t.current,s=r?.offsetParent;if(!s)return;let i=0,l=()=>{i=0,a(f=>{let u=s.scrollTop-De,p=s.scrollTop+s.clientHeight+De;return f&&f.top===u&&f.bottom===p?f:{top:u,bottom:p}});},c=0,m=()=>{i===0&&(i=requestAnimationFrame(l)),r?.setAttribute("data-scrolling",""),window.clearTimeout(c),c=window.setTimeout(()=>r?.removeAttribute("data-scrolling"),150);};l(),s.addEventListener("scroll",m,{passive:true});let d=new ResizeObserver(m);return d.observe(s),()=>{i!==0&&cancelAnimationFrame(i),window.clearTimeout(c),s.removeEventListener("scroll",m),d.disconnect();}},[e,t,n]),o}function oo(e){let t=react.useRef(new WeakMap),n=react.useRef(new Map),o=react.useRef(null),a=react.useCallback((r,s)=>{let i=n.current.get(s);if(!r){i&&(o.current?.unobserve(i),t.current.delete(i),n.current.delete(s));return}typeof ResizeObserver>"u"||(e(s,r.offsetHeight),o.current??=new ResizeObserver(l=>{for(let c of l){let m=t.current.get(c.target);m&&e(m,c.target.offsetHeight);}}),!(i===r&&t.current.get(r)===s)&&(i&&(o.current.unobserve(i),t.current.delete(i)),t.current.set(r,s),n.current.set(s,r),o.current.observe(r)));},[e]);return react.useEffect(()=>()=>{o.current?.disconnect(),n.current.clear();},[]),a}function Cn(e){let t=false;return ()=>{if(!t){if(!react$1.notificationYieldsToTask()){e();return}t=true,setTimeout(()=>{t=false,e();},0);}}}function hn(e){let t=e.snapshot?.();return JSON.stringify(t?.hiddenReviewAuthors??[])}function Te(e){let t=react$1.useDocxEditor();return no(t,e)}function no(e,t){let n=react.useCallback(w=>{if(!e)return ()=>{};let h=false,D=Cn(()=>{h||w();}),E=e.on("change",D),x=e.on("selectionChange",D),_=e.on("error",D);return ()=>{h=true,E(),x(),_();}},[e]),o=react.useSyncExternalStore(n,()=>e?`${e.getReviewRevision()}:${e.getEditingMode()}:${hn(e)}`:"none",()=>"none"),a=react.useMemo(()=>e?e.getReviewItems(t).filter(w=>w.item.kind!=="custom"||w.item.carded):[],[e,o,t]),r=react.useMemo(()=>a.find(w=>w.isActive)?.key??null,[a]),s=react.useCallback((w,h)=>e?e.setActiveReviewItem(w,h).ok:false,[e]),i=react.useCallback(w=>!e||w.kind!=="revision"||w.readOnly?false:e.acceptReviewItem(w.key).ok,[e]),l=react.useCallback(w=>!e||w.kind!=="revision"||w.readOnly?false:e.rejectReviewItem(w.key).ok,[e]),c=react.useCallback(w=>!e||w.kind!=="comment"?false:e.setCommentResolved(w.key,true).ok,[e]),m=react.useCallback(w=>!e||w.kind!=="comment"?false:e.setCommentResolved(w.key,false).ok,[e]),d=e?.getEditingMode()==="viewing"?"the document is open for viewing":null,f=react.useCallback(w=>!e||w.kind==="custom"||w.kind==="revision"&&w.readOnly?false:e.deleteReviewItem(w.key).ok,[e]),u=react.useCallback((w,h,D)=>h.trim().length===0||!e?false:e.replyToReviewItem(w.key,h,D).ok,[e]),p=react.useMemo(()=>e?e.getSelectionPlacement()?.anchorY??null:null,[e,o]),y=react.useCallback((w,h)=>w.trim().length===0||!e?false:e.addComment(w,h).ok,[e]),b=react.useMemo(()=>e?e.isReviewPaneOpen():true,[e,o]),C=react.useCallback(w=>{!e||e.isReviewPaneOpen()===w||e.exec({type:"toggleReviewPane"});},[e]);return react.useMemo(()=>({items:a,activeKey:r,setActive:s,accept:i,reject:l,resolve:c,reopen:m,commentResolutionDisabledReason:d,remove:f,reply:u,selectionAnchorY:p,comment:y,paneOpen:b,setPaneOpen:C,ready:e!==null&&!e.snapshot().isLoading&&e.snapshot().parseError===null}),[a,r,s,i,l,c,m,d,f,u,p,y,b,C,e])}function xn(e,t,n={}){let o=n.gap??8,a=n.scale??1,r=n.defaultHeight??0;return react.useMemo(()=>{let s=new Map,i=Number.NEGATIVE_INFINITY;for(let l of e){let c=l.anchorY===null?Number.isFinite(i)?i:0:Math.max(l.anchorY,i);s.set(l.key,c),i=c+((t.get(l.key)??r)+o)/a;}return s},[e,t,o,a,r])}var st=8;function lt(e,t){return e?.color??`var(--doc-review-author-${t%st})`}function le(e,t,n){return e?{"--doc-review-author-current":lt(t,n)}:{}}function ye(e,t){return (e?.slot??t)%st}function ro(e,t,n,o){let a=react.useRef(new Map);return react.useMemo(()=>{let r=new Map;for(let i of e)r.set(i.author,i);let s=[...t.map(i=>i.author),o?.getConfiguredAuthor()];for(let i of s){if(!i||r.has(i))continue;let l=n.get(i)??0,c=o?.getReviewAuthorStyle(i),m=c?.color??`var(--doc-review-author-${l%st})`,d=a.current.get(i),f=d!==void 0&&d.slot===l&&d.color===m&&d.style===c?d:{author:i,slot:l,color:m,...c?{style:c}:{}};a.current.set(i,f),r.set(i,f);}return r},[e,t,n,o])}var q=e=>jsxRuntime.jsx("svg",{viewBox:"0 -960 960 960",width:16,height:16,"aria-hidden":"true",focusable:"false",children:jsxRuntime.jsx("path",{d:e,fill:"currentColor"})}),io="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",ao="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",In="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",Re="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z",Le=()=>jsxRuntime.jsxs("span",{className:"docx-review__resolved-icon",children:[jsxRuntime.jsx("span",{className:"docx-review__resolved-comment",children:q(In)}),jsxRuntime.jsx("span",{className:"docx-review__resolved-tick",children:q(Re)})]}),so="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",lo="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",co="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",Nn="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",Pn="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",_n="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",Sn="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 uo(e){if(e.kind==="comment")return ao;if(e.kind==="custom")return e.item.icon??Sn;switch(e.revisionKind){case "insert":case "moveTo":return Nn;case "delete":case "moveFrom":return Pn;case "format":return _n;default:return ao}}function Tn(e,t){return typeof t!="function"?e:typeof e!="function"?t:n=>{e(n),n.defaultPrevented||t(n);}}function On(e,t){let n={...e,...t};for(let o of Object.keys(e))/^on[A-Z]/.test(o)?n[o]=Tn(t[o],e[o]):o==="className"?n[o]=[e[o],t[o]].filter(Boolean).join(" "):o==="style"&&(n[o]={...e[o],...t[o]});return n}function vo(e){return e==="Enter"||e===" "}function Ln(e){return vo(e.key)?(e.preventDefault(),e.stopPropagation(),true):false}function fo(e){return e.type==="button"}function Kn(e,t){return e.type==="a"||t.href!=null}function $n(e,t,n,o){let a=r=>{typeof n=="function"&&n(r);};return {onClick:r=>{typeof e=="function"&&e(r),r.defaultPrevented||a(r),o&&r.preventDefault();},onKeyDown:r=>{if(typeof t=="function"&&t(r),!vo(r.key))return;r.defaultPrevented||a(r),o&&r.preventDefault();}}}function te({engineDisabled:e,disabledReason:t,slotProps:n,children:o}){let a=react.Children.only(o);if(!react.isValidElement(a))return null;let r=a.props,s=On(n,r);if(!e){if(!fo(a)){let i=$n(r.onClick,r.onKeyDown,n.onClick,Kn(a,r));s.onClick=i.onClick,s.onKeyDown=i.onKeyDown;}return react.cloneElement(a,s)}if(fo(a))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 i=s.onKeyDown;s.onKeyDown=l=>{Ln(l)||typeof i=="function"&&i(l);};}return t&&(s.title=t),s.onClick=i=>{i.preventDefault(),i.stopPropagation();},react.cloneElement(a,s)}var yo=react.createContext({key:null,open:()=>{},close:()=>{}});function Ro({items:e,children:t}){let[n,o]=react.useState(null);react.useEffect(()=>{n!==null&&!e.some(r=>r.key===n&&r.kind==="comment"&&r.resolved)&&o(null);},[e,n]);let a=react.useMemo(()=>({key:n,open:r=>o(r),close:()=>o(null)}),[n]);return jsxRuntime.jsx(yo.Provider,{value:a,children:t})}function ct(){return react.useContext(yo)}function bo({label:e,statusLabel:t,entryKey:n,onActivate:o,onDeactivate:a,children:r,...s}){let i=ct(),l=react.useRef(null);return react.useEffect(()=>{let c=m=>{let d=l.current;d?.open&&m.target instanceof Node&&!d.contains(m.target)&&(i.close(),a());};return document.addEventListener("pointerdown",c,true),()=>document.removeEventListener("pointerdown",c,true)},[i,a]),jsxRuntime.jsxs("details",{ref:l,...s,open:i.key===n,onToggle:c=>{c.currentTarget.open?(i.open(n),o()):(i.close(),a());},children:[jsxRuntime.jsxs("summary",{className:"docx-review__resolved-toggle","aria-label":e,children:[jsxRuntime.jsx("span",{className:"docx-review__resolved-status",children:t}),Le()]}),r]})}function go(e){function t({className:o,asChild:a,hidden:r,children:s,icon:i}){let l=e.useReview(),c=e.useItem(),m=e.useLabel();if(r||!c||c.kind!=="comment"||c.resolved)return null;let d=m("comments.resolve"),f=l.commentResolutionDisabledReason!==null,u=f?m("editingMode.viewingHint"):null,p={type:"button",className:`docx-review__action${o?` ${o}`:""}`,"data-testid":"review-resolve","aria-label":d,title:u??d,disabled:f,onMouseDown:e.guardMousedown,onClick:y=>{y.stopPropagation(),!f&&l.resolve(c);}};return a?jsxRuntime.jsx(te,{engineDisabled:f,disabledReason:u,slotProps:p,children:s}):jsxRuntime.jsx("button",{...p,children:i??s??q(Re)})}t.docxReviewPart="Resolve";function n({className:o,asChild:a,hidden:r,children:s,icon:i}){let l=e.useReview(),c=e.useItem(),m=e.useLabel();if(r||!c||c.kind!=="comment"||!c.resolved)return null;let d=m("comments.reopen"),f=l.commentResolutionDisabledReason!==null,u=f?m("editingMode.viewingHint"):null,p={type:"button",className:`docx-review__action${o?` ${o}`:""}`,"data-testid":"review-reopen","aria-label":d,title:u??d,disabled:f,onMouseDown:e.guardMousedown,onClick:y=>{y.stopPropagation(),!f&&l.reopen(c);}};return a?jsxRuntime.jsx(te,{engineDisabled:f,disabledReason:u,slotProps:p,children:s}):jsxRuntime.jsx("button",{...p,children:i??s??q(so)})}return n.docxReviewPart="Reopen",{ReviewResolve:t,ReviewReopen:n}}function xo(e){function t({top:o=0,left:a=null,className:r,hidden:s}){let{review:i,endDraft:l,measure:c,readOnly:m,draftAuthor:d,draftAuthorInfo:f,draftAuthorSlot:u}=e.useRail(),p=e.useLabel(),[y,b]=react.useState(""),[C,w]=react.useState(false),h=react.useRef(null),D=react.useId();react.useEffect(()=>{m||h.current?.focus({preventScroll:true});},[]);let E=react.useCallback(()=>{if(m||y.trim().length===0)return;let x=i.comment(y.trim());w(!x),x&&(b(""),l());},[m,y,i,l]);return s?null:jsxRuntime.jsx("div",{className:`docx-review__slot${r?` ${r}`:""}${a===null?"":" docx-review__slot--compact"}`,style:{position:"absolute",top:o,...a===null?{}:{left:a,width:we}},ref:x=>{c(x,e.composeKey);},children:jsxRuntime.jsx("div",{className:"docx-review__card","data-testid":"review-draft","data-draft":"",...d?{"data-review-author":d,"data-review-author-slot":u}:{},style:le(d??void 0,f,u),children:jsxRuntime.jsxs("form",{className:"docx-review__reply-box",onSubmit:x=>{x.preventDefault(),E();},children:[jsxRuntime.jsx("label",{className:"docx-editor-sr-only",htmlFor:D,children:p("comments.addComment")}),jsxRuntime.jsx("input",{id:D,ref:h,"data-testid":"review-draft-input",className:"docx-review__input",value:y,placeholder:p("comments.addComment"),readOnly:m,...C?{"aria-invalid":true}:{},onChange:x=>{m||(w(false),b(x.target.value));},onKeyDown:x=>{if(x.key==="Escape"){x.preventDefault(),l();return}m||x.key!=="Enter"||(x.preventDefault(),E());}}),jsxRuntime.jsxs("div",{className:"docx-review__reply-actions",children:[jsxRuntime.jsx("button",{type:"button","data-testid":"review-draft-cancel",className:"docx-review__text-button",onMouseDown:e.guardMousedown,onClick:l,children:p("common.cancel")}),jsxRuntime.jsx("button",{type:"submit","data-testid":"review-draft-submit",className:"docx-review__submit",disabled:m||y.trim().length===0,title:m?p("editingMode.viewingHint"):void 0,children:p("common.comment")})]}),C?jsxRuntime.jsx("span",{className:"docx-review__refused",role:"alert",children:p("review.commentRefused")}):null]})})})}t.docxReviewPart="Draft";function n({className:o,hidden:a,children:r}){let{review:s,readOnly:i}=e.useRail(),l=e.useItem(),c=e.useLabel(),[m,d]=react.useState(""),[f,u]=react.useState(false),p=react.useId(),y=react.useCallback(()=>{if(!l||i||m.trim().length===0)return;let b=s.reply(l,m.trim());u(!b),b&&d("");},[l,i,m,s]);return a||!l||!l.isActive||l.kind==="comment"&&l.resolved?null:r?jsxRuntime.jsx(jsxRuntime.Fragment,{children:r}):jsxRuntime.jsxs("form",{className:`docx-review__reply-box${o?` ${o}`:""}`,onSubmit:b=>{b.preventDefault(),y();},children:[jsxRuntime.jsx("label",{className:"docx-editor-sr-only",htmlFor:p,children:c("comments.replyPlaceholder")}),jsxRuntime.jsx("input",{id:p,"data-testid":"review-reply-input",className:"docx-review__input",value:m,placeholder:c("comments.replyPlaceholder"),readOnly:i,...f?{"aria-invalid":true,"data-refused":""}:{},onChange:b=>{i||(u(false),d(b.target.value));},onClick:b=>b.stopPropagation(),onKeyDown:b=>{i||b.key!=="Enter"||(b.preventDefault(),y());}}),jsxRuntime.jsxs("div",{className:"docx-review__reply-actions",children:[jsxRuntime.jsx("button",{type:"button","data-testid":"review-reply-cancel",className:"docx-review__text-button",onMouseDown:e.guardMousedown,onClick:b=>{b.stopPropagation(),d(""),u(false),s.setActive(null);},children:c("common.cancel")}),jsxRuntime.jsx("button",{type:"submit","data-testid":"review-reply-submit",className:"docx-review__submit",disabled:i||m.trim().length===0,title:i?c("editingMode.viewingHint"):void 0,children:c("review.reply")})]}),f?jsxRuntime.jsx("span",{className:"docx-review__refused",role:"alert","data-testid":"review-reply-refused",children:c("review.replyRefused")}):null]})}return n.docxReviewPart="Reply",{ReviewDraft:t,ReviewReply:n}}function ut(e,t,n=1){if(e==="paragraphMark"){let o=n>1;return t==="delete"?o?"revisions.paragraphMarksDeleted":"revisions.paragraphMarkDeleted":t==="moveFrom"?o?"revisions.paragraphMarksMovedFrom":"revisions.paragraphMarkMovedFrom":t==="moveTo"?o?"revisions.paragraphMarksMovedTo":"revisions.paragraphMarkMovedTo":o?"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 jn(e){return ut(e.revisionKind,e.markDirection,e.ranges.length)}function zn(e){return e.revisionKind==="paragraphMark"&&e.ranges.length>1?` (${e.ranges.length})`:""}function Ao(e,t){if(e.revisionKind==="structural"&&e.structuralChanges?.length)return e.structuralChanges.map(r=>t(`revisions.structuralDetails.${r}`)).join(", ");let n=`${t(jn(e))}${zn(e)}`;if(e.revisionKind!=="format")return n;let a=[...(e.formattingLanguages??[]).map(r=>{try{return new Intl.DisplayNames([t("_lang")],{type:"language"}).of(new Intl.Locale(r).minimize().toString())??r}catch{return r}}),...(e.formattingChanges??[]).map(r=>Wn(r,t))];return a.length?`${n}: ${a.join(", ")}`:n}function Wn(e,t){let{property:n,value:o}=e;if(o!==null&&(n==="bold"||n==="italic"||n==="strike"))return t(`revisions.formattingDetails.${o==="true"?n:{bold:"notBold",italic:"notItalic",strike:"notStrike"}[n]}`);let a=o??t("revisions.formattingDetails.default");return o!==null&&(["fontSize","leftIndent","rightIndent","firstLineIndent","hangingIndent","spaceBefore","spaceAfter"].includes(n)?a=`${o} ${t("revisions.formattingDetails.points")}`:/^(left|center|right|both|start|end|none|single|double|auto)$/.test(o)?a=t(`revisions.formattingDetails.${o}`):n==="color"&&/^[0-9a-f]{6}$/i.test(o)&&(a=`#${o.toUpperCase()}`)),`${t(`revisions.formattingDetails.${n}`)}: ${a}`}function dt(e,t,n){let o=t.getBoundingClientRect(),a=e.getBoundingClientRect(),r=e.ownerDocument.defaultView?.innerHeight??1/0,s=Number(e.dataset.reviewStart??e.dataset.start),i=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:n,...e.dataset.paragraphId!==void 0?{paragraphId:e.dataset.paragraphId}:{},...Number.isFinite(s)?{start:s}:{},...Number.isFinite(i)?{end:i}:{},left:a.left-o.left,top:a.top-o.top,bottom:a.bottom-o.top,above:a.bottom+220>r}}function Gn(e){return e==="format"||e==="structural"}function Eo(e,t,n){return e.kind!=="revision"||!Gn(e.revisionKind)?false:!(n&&t.some(o=>o.id===e.id))}function Io(e,t){if(t.kind!=="revision"||t.item.kind!=="revision")return null;let n=t.item.addresses;if(n.length===0)return null;let o=new Set(n.map(r=>r.id)),a=t.item.formattingKind;for(let r of e.querySelectorAll("[data-revision-id]")){if(!(r instanceof HTMLElement))continue;let s=r.dataset.revisionId;if(!s||!o.has(s)||!n.some(c=>c.id===s&&c.author===(r.dataset.reviewAuthor??"")&&(c.date??"")===(r.dataset.revisionDate??"")))continue;let l=r.classList.contains("docx-table-row--revision");if(t.revisionKind==="structural"&&l||t.revisionKind==="format"&&r.dataset.revisionKind==="format"&&r.dataset.formattingKind===a)return r}return null}function No(e,t){let n=null,o=false,a=null,r=false,s=null,i=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;n===null?n=l:n!==l&&(o=true);}a===null?a=l:a!==l&&(r=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){s===null?s=l:s!==l&&(i=true);break}}}return n!==null&&!o?n:a!==null&&!r?a:s!==null&&!i?s:null}function Po(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 ar=e=>e.isLoading||e.parseError!==null||e.pageSetup==null,ir=e=>e.editingMode==="viewing",pt=react.createContext(null),P=react.createContext(null);function sr(){return react.useContext(P)}function lr(e){let{authorInfo:t}=H();return e===void 0?void 0:t.get(e)}var He="\0compose",cr=72,ur=64,dr=480,mr=30,fr=Object.freeze({placement:false});function wt(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 yt(e){return new Set(e.map(t=>t.id))}function W(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function H(){let e=react.useContext(pt);return e||vr}function V(){let{t:e}=react.useContext(pt)??{},{t}=react$1.useTranslation();return react.useCallback(n=>e?.(n)??t(n),[e,t])}var{ReviewResolve:ko,ReviewReopen:Do}=go({useReview:()=>H().review,useItem:()=>react.useContext(P),useLabel:V,guardMousedown:W}),{ReviewDraft:To,ReviewReply:Oo}=xo({useRail:H,useItem:()=>react.useContext(P),useLabel:V,guardMousedown:W,composeKey:He}),vr={t:void 0,cardClassName:void 0,readOnly:false,review:{items:[],activeKey:null,setActive:()=>false,accept:()=>false,reject:()=>false,resolve:()=>false,reopen:()=>false,commentResolutionDisabledReason:null,remove:()=>false,reply:()=>false,selectionAnchorY:null,comment:()=>false,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:()=>{}};function pr({className:e,furniture:t,asChild:n,hidden:o,children:a,t:r,card:s,preset:i=true,stack:l=true,gap:c=8,filter:m,structural:d=true,formatting:f=false}){let u=react$1.useDocxEditor(),p=react$1.useEditorState(ar),y=react$1.useEditorState(ir),b=react.useMemo(()=>{let R=[];return d||R.push("structural"),f||R.push("format"),R.length>0?R:void 0},[d,f]),C=react.useMemo(()=>({excludeRevisionKinds:b?.filter(R=>R!=="format")}),[b]);react.useEffect(()=>(u?.setReviewActivationExclusions(b??null,{formattingKinds:["rPrChange","pPrChange"]}),()=>u?.setReviewActivationExclusions(null)),[u,b]);let w=Te(fr),h=Te(C),D=h.setPaneOpen,{t:E}=react$1.useTranslation(),x=react.useCallback(R=>r?.(R)??E(R),[r,E]),_=react.useRef(null),U=react.useContext(react$1.ReviewRailContext);react.useEffect(()=>U?.register(),[U]);let L=h.paneOpen,G=react$1.useReviewGutter(),S=L&&G.inlineEnd>0&&G.inlineEnd<react$1.REVIEW_PANE_GUTTER,F=L&&!S,M=react.useMemo(()=>h.items.filter(R=>(f||!Po(R))&&(!m||m(R))),[h.items,m,f]),B=react.useSyncExternalStore(react.useCallback(R=>u?.on("selectionChange",R)??(()=>{}),[u]),()=>u?.getConfiguredAuthor()??null,()=>null),Ne=react.useMemo(()=>{let R=new Map;for(let g of M)g.author&&!R.has(g.author)&&R.set(g.author,R.size);return B&&!R.has(B)&&R.set(B,R.size),R},[M,B]),St=react.useMemo(()=>{let R=new Map;for(let g of M)R.set(g.id,g);return R},[M]),[Mt,Go]=react.useState(()=>new Map),Qo=react.useCallback((R,g)=>{g<=0||Go(I=>{if(I.get(R)===g)return I;let T=new Map(I);return T.set(R,g),T});},[]),kt=oo(Qo),N=eo(u,_,M,!p&&!o,S),fe=to(u,_,!p&&!o);react.useEffect(()=>{let R=_.current;if(!u||!R)return;let g=I=>{let T=I.target;if(!(T instanceof Node)||R.contains(T))return;let O=R.offsetParent;!O||!O.contains(T)||O.querySelector(".docx-paginated-surface")?.contains(T)||u.setActiveReviewItem(null);};return document.addEventListener("mousedown",g,true),()=>document.removeEventListener("mousedown",g,true)},[u,p,o]);let[j,Je]=react.useState(null),Xe=react.useRef(null),Q=react.useCallback(()=>{let R=Xe.current;R&&(R.editor.releaseSelection(R.pin),Xe.current=null);},[]),Pe=react.useCallback(()=>{if(!u||y)return;let R=u.getSelectionPlacement()?.anchorY??null;if(R===null)return;Q();let g=u.retainSelection();g&&(Xe.current={editor:u,pin:g},D(true),Je(R));},[u,y,Q,D]);react.useEffect(()=>{if(!(o||y))return U?.registerCommentDraft(Pe)},[Pe,o,y,U]);let Dt=react.useCallback(()=>{Q(),Je(null),u?.focus();},[u,Q]);react.useEffect(()=>Q,[Q]),react.useEffect(()=>{L||j===null||(Q(),Je(null));},[L,j,Q]);let et=j??h.selectionAnchorY,z=react.useMemo(()=>{let R=yt(M);return M.filter(g=>!wt(g,R))},[M]),Tt=react.useMemo(()=>{if(j===null)return z;let R=z.findIndex(I=>I.anchorY!==null&&I.anchorY>j),g={key:He,anchorY:j};return R===-1?[...z,g]:[...z.slice(0,R),g,...z.slice(R)]},[z,j]),Ot=react.useMemo(()=>{let R=new Map(Mt);for(let g of z){if(R.has(g.key))continue;let I=g.text.length+(g.kind==="revision"?g.replacedText?.length??0:0),T=Math.min(6,Math.max(1,Math.ceil(I/36)));R.set(g.key,64+T*20);}return R},[Mt,z]),{stacked:tt,collapsedKeys:Lt}=react.useMemo(()=>{let R=N.scale,g=new Map,I=new Set,T=Number.NEGATIVE_INFINITY;for(let O of Tt){let Me=O.anchorY===null?Number.isFinite(T)?T:0:Math.max(O.anchorY,T);g.set(O.key,Me);let on=O.anchorY===null?0:(Me-O.anchorY)*R,nn="isActive"in O&&O.isActive,Yt=on>dr&&!nn&&O.key!==He;Yt&&I.add(O.key);let rn=Yt?ur:Ot.get(O.key)??cr;T=Me+(rn+c)/R;}return {stacked:g,collapsedKeys:I}},[Tt,Ot,c,N.scale]),ot=et===null?null:N.top+(S?et:tt.get(He)??et)*N.scale,ve=s?.className,Jo=react$1.useReviewAuthors(),nt=ro(Jo,M,Ne,u),Kt=B?Ne.get(B)??0:0,$t=B?nt.get(B):void 0,Xo=react.useMemo(()=>({t:r,cardClassName:ve,readOnly:y,review:{...h,items:M},allItems:w.items,authorSlots:Ne,authorInfo:nt,draftAuthor:B,draftAuthorInfo:$t,draftAuthorSlot:Kt,byId:St,measure:kt,beginDraft:Pe,endDraft:Dt}),[r,ve,y,h,w.items,M,Ne,nt,B,$t,Kt,St,kt,Pe,Dt]);if(o||p)return null;let Ht={ref:_,className:`docx-review${e?` ${e}`:""}`,"data-testid":"review-rail","data-count":M.length,"data-open":F?"":void 0,"data-compact":S?"":void 0,role:"region","aria-label":x("review.ariaLabel"),onMouseDown:W,style:N.left===null?void 0:{left:N.left,right:"auto"}},J=typeof a=="function"?{parts:{},rest:a}:ke(a,"root"),X=J.parts,pe=(R,g)=>{if(!(R in X))return g;let I=X[R];return !react.isValidElement(I)||!react.isValidElement(g)?I:react.cloneElement(I,{...g.props,...I.props})},qt=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[i||"AddComment"in X?pe("AddComment",jsxRuntime.jsx(bt,{top:ot,drafting:j!==null})):null,!L||j===null||ot===null||!i&&!("Draft"in X)?null:pe("Draft",jsxRuntime.jsx(To,{top:ot,left:S?N.compactCardLeft:null})),i||"Balloon"in X?pe("Balloon",jsxRuntime.jsx(gt,{})):null]}),en=jsxRuntime.jsx(qe,{stack:l,positions:tt,collapsed:Lt,scale:N.scale,offset:N.top,window:fe,children:J.rest}),Vt=jsxRuntime.jsx(Rt,{scale:N.scale,offset:N.top,window:fe}),ee=S?z.find(R=>R.key===h.activeKey)??null:null,Ut=ee===null?null:ee.anchorY!==null?N.top+ee.anchorY*N.scale:fe!==null?fe.top+De+24:null,_e=n?null:J.rest,Se=typeof _e=="function"?null:ke(_e,"list"),Ft=typeof _e=="function"?ee&&_e(ee):Se?.parts.Card&&react.isValidElement(Se.parts.Card)?at(Se.parts.Card,ve):i?jsxRuntime.jsx(Ve,{...ve?{className:ve}:{},children:Se?.rest}):null,Bt=ee&&Ut!==null&&N.compactCardLeft!==null&&Ft?jsxRuntime.jsx(P.Provider,{value:ee,children:jsxRuntime.jsx("div",{className:"docx-review__slot docx-review__slot--compact","data-testid":"review-compact-card",style:{position:"absolute",top:Ut,left:N.compactCardLeft,width:we},children:Ft})}):null,tn=F?i||"List"in X?pe("List",en):typeof J.rest=="function"?null:J.rest:i||"Markers"in X?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[pe("Markers",Vt),Bt]}):typeof J.rest=="function"?null:J.rest;return jsxRuntime.jsx(Ro,{items:M,children:jsxRuntime.jsx(pt.Provider,{value:Xo,children:n&&react.isValidElement(a)?jsxRuntime.jsx(react$1.Slot,{...Ht,children:react.cloneElement(a,void 0,a.props.children,i?F?jsxRuntime.jsx(qe,{stack:l,positions:tt,collapsed:Lt,scale:N.scale,offset:N.top,window:fe}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[Vt,Bt]}):null,qt)}):jsxRuntime.jsxs("aside",{...Ht,children:[F&&t!==void 0?jsxRuntime.jsx("div",{className:"docx-review__furniture","data-testid":"review-furniture",children:t}):null,tn,qt]})})})}function qe({stack:e=true,positions:t,collapsed:n,scale:o=1,offset:a=0,window:r=null,children:s,className:i,hidden:l}){let{review:c,measure:m,cardClassName:d}=H();if(l)return null;let f=typeof s=="function"?null:ke(s,"list"),u=yt(c.items),p=c.items.filter(y=>!wt(y,u));return p.length===0?typeof s=="function"?null:f?.parts.Empty??jsxRuntime.jsx(Ct,{}):jsxRuntime.jsx("div",{className:`docx-review__list${i?` ${i}`:""}`,children:p.map(y=>{let b=e?t?.get(y.key)??y.anchorY:y.anchorY,C=b==null?null:a+b*o;if(C!==null&&r&&(C<r.top||C>r.bottom))return null;let w=C===null?{}:{position:"absolute",top:C};return jsxRuntime.jsx(P.Provider,{value:y,children:jsxRuntime.jsx("div",{className:"docx-review__slot",style:w,...n?.has(y.key)?{"data-collapsed":""}:{},ref:h=>{m(h,y.key);},children:typeof s=="function"?s(y):f?.parts.Card&&react.isValidElement(f.parts.Card)?at(f.parts.Card,d):jsxRuntime.jsx(Ve,{...d?{className:d}:{},children:f?.rest})})},y.key)})})}qe.docxReviewPart="List";function Rt({scale:e=1,offset:t=0,window:n=null,className:o,hidden:a,icon:r}){let{review:s,authorSlots:i,authorInfo:l}=H(),c=ct(),m=V(),{roots:d,stackedTops:f}=react.useMemo(()=>{let u=yt(s.items),p=s.items.filter(C=>!wt(C,u)),y=new Map,b=Number.NEGATIVE_INFINITY;for(let C of p){if(C.anchorY===null)continue;let w=Math.max(t+C.anchorY*e,b);y.set(C.key,w),b=w+mr;}return {roots:p,stackedTops:y}},[s.items,t,e]);return a?null:jsxRuntime.jsx("div",{className:`docx-review__markers${o?` ${o}`:""}`,children:d.map(u=>{let p=f.get(u.key);return p===void 0||n&&(p<n.top||p>n.bottom)?null:jsxRuntime.jsx("button",{type:"button",className:"docx-review__marker","data-testid":"review-marker","data-kind":u.kind==="revision"?u.revisionKind:u.kind,...u.author?{"data-review-author":u.author,"data-review-author-slot":ye(l.get(u.author),i.get(u.author)??0)}:{},style:{position:"absolute",top:p,...u.author?{"--doc-review-author-current":lt(l.get(u.author),i.get(u.author)??0)}:{}},title:u.author?`${u.author}: ${u.text}`:u.text,"aria-label":`${m("review.showPane")}: ${u.author?`${u.author}. `:""}${u.text}`,onMouseDown:W,onClick:()=>{u.kind==="comment"&&u.resolved&&c.open(u.key),s.setPaneOpen(true),s.setActive(u.key);},children:(typeof r=="function"?r(u):r)??(u.kind==="comment"&&u.resolved?Le():q(uo(u)))},u.key)})})}Rt.docxReviewPart="Markers";function bt({top:e=null,drafting:t=false,className:n,hidden:o,children:a}){let{beginDraft:r,readOnly:s}=H(),i=V();if(o||t||e===null||s)return null;let l={type:"button",className:`docx-review__add${n?` ${n}`:""}`,"data-testid":"review-add-comment",style:{position:"absolute",top:e},"aria-label":i("common.comment"),title:i("common.comment"),onMouseDown:W,onClick:r};return a?jsxRuntime.jsx(react$1.Slot,{...l,children:a}):jsxRuntime.jsx("button",{...l,children:q(io)})}bt.docxReviewPart="AddComment";function gt({className:e,hidden:t}){let{review:n,allItems:o,authorSlots:a,authorInfo:r}=H(),s=V(),i=react.useRef(null),[l,c]=react.useState(null),m=react.useRef(null),d=react$1.useEditorState(E=>E.reviewDisplayMode??"all-markup");react.useEffect(()=>{m.current=null,c(null);},[d]);let f=o.find(E=>E.isActive)??null,u=react.useRef(f);u.current=f;let p=f?.key??null,y=f!==null&&Eo(f,n.items,n.paneOpen),b=react.useRef(false);b.current=l!==null,react.useEffect(()=>{let E=i.current,x=E?.closest(".docx-review"),_=x?.closest(".docx-editor__scroll-container")??x?.offsetParent;if(!E||!x||!_)return;let U=(G,S)=>{m.current=null,c(dt(G,x,S));},L=G=>{let S=G.target;if(!(S instanceof Element)||E.contains(S))return;let F=S.closest("[data-revision-id]");if(F instanceof HTMLElement&&_.contains(F)){let M=F.classList.contains("docx-table-row--revision");if(F.dataset.revisionKind==="format"||M){U(F,M);return}}b.current&&(m.current=null,c(null));};return _.addEventListener("pointerdown",L,true),_.addEventListener("mousedown",L,true),()=>{_.removeEventListener("pointerdown",L,true),_.removeEventListener("mousedown",L,true);}},[]),react.useEffect(()=>{let E=i.current,x=E?.closest(".docx-review"),_=x?.closest(".docx-editor__scroll-container")??x?.offsetParent;if(!E||!x||!_)return;let U=u.current;if(!U){m.current!==null&&(m.current=null,c(null));return}if(!y){m.current=null,c(null);return}m.current=U.key,c(null);let L=false,G=requestAnimationFrame(()=>{if(L)return;let S=Io(_,U);if(!S){c(null);return}c(dt(S,x,S.classList.contains("docx-table-row--revision")));});return ()=>{L=true,cancelAnimationFrame(G);}},[d,p,y]);let C=react.useMemo(()=>l?No(l,o):null,[o,l]),w=C&&(C.revisionKind==="format"||C.revisionKind==="structural")?C:null,h=react.useRef(false);if(react.useEffect(()=>{if(w){h.current=true;return}h.current&&(h.current=false,c(null));},[w]),t)return null;let D=l?.kind==="format"?"format":"structural";return jsxRuntime.jsx("div",{ref:i,className:`docx-review__balloon-root${e?` ${e}`:""}`,children:l===null||d!=="all-markup"||w&&n.items.some(E=>E.id===w.id)&&n.paneOpen?null:jsxRuntime.jsx("div",{className:"docx-review__balloon","data-testid":"review-balloon",style:{left:l.left,top:l.above?l.top-6:l.bottom+6,transform:l.above?"translateY(-100%)":void 0},onMouseDown:W,children:w?jsxRuntime.jsx(P.Provider,{value:w,children:jsxRuntime.jsxs("div",{className:"docx-review__card","data-testid":"review-balloon-card","data-kind":w.revisionKind??"revision",...w.author?{"data-review-author":w.author,"data-review-author-slot":ye(r.get(w.author),a.get(w.author)??0)}:{},style:le(w.author,r.get(w.author),a.get(w.author)??0),onClick:()=>n.setActive(w.key),children:[jsxRuntime.jsxs("div",{className:"docx-review__head",children:[jsxRuntime.jsx(ge,{}),jsxRuntime.jsxs("div",{className:"docx-review__meta",children:[jsxRuntime.jsx(Ce,{}),jsxRuntime.jsx(he,{})]}),w.kind==="revision"&&!w.readOnly?jsxRuntime.jsxs("div",{className:"docx-review__actions",children:[jsxRuntime.jsx(Ue,{}),jsxRuntime.jsx(Fe,{})]}):null]}),jsxRuntime.jsx(xe,{})]})}):jsxRuntime.jsxs("div",{className:"docx-review__card","data-testid":"review-balloon-card","data-kind":D,...l.author?{"data-review-author":l.author,"data-review-author-slot":ye(r.get(l.author),a.get(l.author)??0)}:{},style:le(l.author,r.get(l.author),a.get(l.author)??0),children:[jsxRuntime.jsxs("div",{className:"docx-review__head",children:[jsxRuntime.jsx("span",{className:"docx-review__avatar","aria-hidden":"true",children:wr(l.author)}),jsxRuntime.jsxs("div",{className:"docx-review__meta",children:[jsxRuntime.jsx("span",{className:"docx-review__author",children:l.author||s("comments.unknown")}),l.date?jsxRuntime.jsx(yr,{raw:l.date}):null]})]}),jsxRuntime.jsx("div",{className:"docx-review__summary",children:jsxRuntime.jsx("span",{className:"docx-review__label","data-kind":D,children:s(ut(D))})})]})})})}gt.docxReviewPart="Balloon";function wr(e){let t=e.trim().split(/\s+/).filter(Boolean);return t.length===0?"?":t.slice(0,2).map(n=>n[0].toUpperCase()).join("")}function yr({raw:e}){let t=new Date(e);return Number.isNaN(t.getTime())?null:jsxRuntime.jsx("time",{className:"docx-review__time",dateTime:e,children:Lo.format(t)})}function Ct({className:e,hidden:t,children:n}){let o=V();return t?null:jsxRuntime.jsx("div",{className:`docx-review__empty${e?` ${e}`:""}`,"data-testid":"review-empty",children:n??o("review.empty")})}Ct.docxReviewPart="Empty";function Ve({className:e,asChild:t,hidden:n,children:o}){let{review:a,authorSlots:r,authorInfo:s}=H(),i=react.useContext(P),l=react.useId(),c=V();if(n||!i)return null;let m=r.get(i.author)??0,d=!t&&i.kind==="comment"&&i.resolved,f={className:`docx-review__card${e?` ${e}`:""}`,"data-testid":"review-card",...d?{}:{"aria-labelledby":`${l}-author ${l}-summary`},"data-kind":i.kind==="revision"?i.revisionKind??"revision":i.kind,...i.author?{"data-review-author":i.author,"data-review-author-slot":ye(s.get(i.author),m)}:{},...i.kind==="custom"&&i.item.kind==="custom"?{"data-node-name":i.item.name}:{},...i.isActive?{"data-active":""}:{},...i.kind==="comment"&&i.resolved?{"data-resolved":""}:{},...d?{"data-resolved-miniature":""}:{},style:le(i.author,s.get(i.author),m),...d?{}:{tabIndex:0,role:"button"},id:l,...d?{}:{onMouseDown:u=>{u.target?.closest("[data-review-selectable]")||u.currentTarget.focus({preventScroll:true});},onClick:()=>a.setActive(i.key),onKeyDown:u=>{u.target===u.currentTarget&&(u.key!=="Enter"&&u.key!==" "||(u.preventDefault(),a.setActive(i.key)));}}};return t?jsxRuntime.jsx(react$1.Slot,{...f,children:o}):d?jsxRuntime.jsx(bo,{...f,label:c("review.showResolvedComment"),statusLabel:c("review.resolved"),entryKey:i.key,onActivate:()=>a.setActive(i.key),onDeactivate:()=>a.setActive(null),children:jsxRuntime.jsx(So,{children:o})}):jsxRuntime.jsx("div",{...f,children:jsxRuntime.jsx(So,{children:o})})}Ve.docxReviewPart="Card";function So({children:e}){let t=react.useContext(P),n=react.useMemo(()=>Rr(e),[e]),o=(r,s)=>r in n?n[r]:s;if(!t)return null;if(t.kind==="custom"&&t.item.kind==="custom"){let r=t.item;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"docx-review__head",children:[o("Avatar",null),jsxRuntime.jsx("div",{className:"docx-review__meta",children:o("Author",jsxRuntime.jsx("span",{className:"docx-review__author","data-testid":"review-custom-title",children:r.title}))})]}),o("Summary",r.detail?jsxRuntime.jsx("div",{className:"docx-review__summary","data-testid":"review-summary","data-review-selectable":"",children:jsxRuntime.jsx("span",{className:"docx-review__text",children:r.detail})}):null),n.__extra]})}let a=t.kind==="revision"&&!t.readOnly;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"docx-review__head",children:[o("Avatar",jsxRuntime.jsx(ge,{})),jsxRuntime.jsxs("div",{className:"docx-review__meta",children:[o("Author",jsxRuntime.jsx(Ce,{})),o("Time",jsxRuntime.jsx(he,{}))]}),a||t.kind==="comment"?jsxRuntime.jsxs("div",{className:"docx-review__actions",children:[o("Accept",jsxRuntime.jsx(Ue,{})),o("Reject",jsxRuntime.jsx(Fe,{})),o("Resolve",jsxRuntime.jsx(ko,{})),o("Reopen",jsxRuntime.jsx(Do,{})),o("Delete",t.kind==="comment"?jsxRuntime.jsx(Be,{}):null)]}):null]}),o("Summary",jsxRuntime.jsx(xe,{})),o("Replies",jsxRuntime.jsx(ht,{})),o("Reply",jsxRuntime.jsx(Oo,{})),n.__extra]})}function Rr(e){let t={},n=[],o=a=>{if(Array.isArray(a)){a.forEach(o);return}if(!a||typeof a!="object"||!("type"in a)){a&&n.push(a);return}if(a.type===react.Fragment){o(a.props.children);return}let r=a.type.docxReviewPart;r?t[r]=a:n.push(a);};return o(e),n.length>0&&(t.__extra=n),t}function ge({className:e,asChild:t,hidden:n,children:o}){let{authorInfo:a}=H(),r=react.useContext(P);if(n||!r||o===void 0&&!r.initials)return null;let s={className:`docx-review__avatar${e?` ${e}`:""}`,"data-testid":"review-avatar","aria-hidden":true};if(t)return jsxRuntime.jsx(react$1.Slot,{...s,children:o});let i=a.get(r.author)?.style?.avatarUrl,l=o??(i?jsxRuntime.jsx("img",{className:"docx-review__avatar-img",src:i,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer"}):void 0)??r.initials;return jsxRuntime.jsx("span",{...s,children:l})}ge.docxReviewPart="Avatar";function Ce({className:e,asChild:t,hidden:n,children:o}){let a=react.useContext(P),r=V();if(n||!a)return null;let s=a.author||r("comments.unknown"),i={className:`docx-review__author${e?` ${e}`:""}`,"data-testid":"review-author"};return t?jsxRuntime.jsx(react$1.Slot,{...i,children:o}):jsxRuntime.jsx("span",{...i,children:o??s})}Ce.docxReviewPart="Author";function he({className:e,asChild:t,hidden:n,children:o}){let a=react.useContext(P);if(n||!a)return null;let r=a.date;if(!r)return null;let s=new Date(r);if(Number.isNaN(s.getTime()))return null;let i={className:`docx-review__time${e?` ${e}`:""}`,"data-testid":"review-time",dateTime:r};return t?jsxRuntime.jsx(react$1.Slot,{...i,children:o}):jsxRuntime.jsx("time",{...i,children:o??Lo.format(s)})}he.docxReviewPart="Time";var Lo=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function xe({className:e,asChild:t,hidden:n,children:o}){let a=react.useContext(P),r=V();if(n||!a)return null;let s=a.text,i=a.kind!=="revision"?null:Ao(a.item,r),l=a.kind==="revision"&&a.revisionKind==="replace",c={className:`docx-review__summary${e?` ${e}`:""}`,"data-testid":"review-summary","data-review-selectable":""};return t?jsxRuntime.jsx(react$1.Slot,{...c,children:o}):jsxRuntime.jsx("div",{...c,children:o??(l?jsxRuntime.jsxs("span",{className:"docx-review__text",children:[r("review.replaced")," ",jsxRuntime.jsxs("span",{className:"docx-review__removed",children:['"',a.replacedText,'"']})," ",r("review.replacedWith")," ",jsxRuntime.jsxs("span",{className:"docx-review__added",children:['"',s,'"']})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[i?jsxRuntime.jsx("span",{className:"docx-review__label","data-kind":a.kind==="revision"?a.revisionKind:"revision",children:i}):null,s?jsxRuntime.jsx("span",{className:"docx-review__text",children:s}):null]}))})}xe.docxReviewPart="Summary";function Ue({className:e,asChild:t,hidden:n,children:o,icon:a}){let{readOnly:r,review:s}=H(),i=react.useContext(P),l=V();if(n||!i||i.kind!=="revision"||i.readOnly)return null;let c=l("review.accept"),m=r?l("editingMode.viewingHint"):null,d={type:"button",className:`docx-review__action${e?` ${e}`:""}`,"data-testid":"review-accept","aria-label":c,title:m??c,disabled:r,onMouseDown:W,onClick:f=>{f.stopPropagation(),!r&&s.accept(i);}};return t?jsxRuntime.jsx(te,{engineDisabled:r,disabledReason:m,slotProps:d,children:o}):jsxRuntime.jsx("button",{...d,children:a??o??q(Re)})}Ue.docxReviewPart="Accept";function Fe({className:e,asChild:t,hidden:n,children:o,icon:a}){let{readOnly:r,review:s}=H(),i=react.useContext(P),l=V();if(n||!i||i.kind!=="revision"||i.readOnly)return null;let c=l("review.reject"),m=r?l("editingMode.viewingHint"):null,d={type:"button",className:`docx-review__action${e?` ${e}`:""}`,"data-testid":"review-reject","aria-label":c,title:m??c,disabled:r,onMouseDown:W,onClick:f=>{f.stopPropagation(),!r&&s.reject(i);}};return t?jsxRuntime.jsx(te,{engineDisabled:r,disabledReason:m,slotProps:d,children:o}):jsxRuntime.jsx("button",{...d,children:a??o??q(lo)})}Fe.docxReviewPart="Reject";function Be({className:e,asChild:t,hidden:n,children:o,icon:a}){let{readOnly:r,review:s}=H(),i=react.useContext(P),{t:l}=react$1.useTranslation();if(n||!i||i.kind==="custom"||i.kind==="revision"&&i.readOnly)return null;let c=i.kind==="comment"?l("review.deleteComment"):l("review.discardChange"),m=r?l("editingMode.viewingHint"):null,d={type:"button",className:`docx-review__action${e?` ${e}`:""}`,"data-testid":"review-delete","aria-label":c,title:m??c,disabled:r,onMouseDown:W,onClick:f=>{f.stopPropagation(),!r&&s.remove(i);}};return t?jsxRuntime.jsx(te,{engineDisabled:r,disabledReason:m,slotProps:d,children:o}):jsxRuntime.jsx("button",{...d,children:a??o??q(co)})}Be.docxReviewPart="Delete";function ht({className:e,hidden:t}){let{byId:n}=H(),o=react.useContext(P);if(t||!o||o.kind==="custom")return null;let a=o.replyIds.map(r=>n.get(r)).filter(r=>r!==void 0);return a.length===0?null:jsxRuntime.jsx("ol",{className:`docx-review__replies${e?` ${e}`:""}`,children:a.map(r=>jsxRuntime.jsx(P.Provider,{value:r,children:jsxRuntime.jsxs("li",{className:"docx-review__reply","data-testid":"review-reply",children:[jsxRuntime.jsxs("div",{className:"docx-review__head",children:[jsxRuntime.jsx(ge,{}),jsxRuntime.jsxs("div",{className:"docx-review__meta",children:[jsxRuntime.jsx(Ce,{}),jsxRuntime.jsx(he,{})]}),jsxRuntime.jsx("div",{className:"docx-review__actions",children:jsxRuntime.jsx(Be,{})})]}),jsxRuntime.jsx(xe,{})]})},r.key))})}ht.docxReviewPart="Replies";var br=Object.assign(pr,{List:qe,Empty:Ct,Card:Ve,Avatar:ge,Author:Ce,Time:he,Summary:xe,Accept:Ue,Reject:Fe,Resolve:ko,Reopen:Do,Delete:Be,Replies:ht,Reply:Oo,Markers:Rt,AddComment:bt,Draft:To,Balloon:gt});var Ae=8;function Ko(e){let t=/^var\(--doc-review-author-(\d{1,2})\)$/.exec(e);return t?Number(t[1])%Ae:null}function Ze(e,t,n,o){let a=new Map(e.map(i=>[i.author,i])),r=new Map,s=new Map;for(let i of t){if(s.has(i.actorId))continue;let l=collaboration.safeParticipantColor(o?.(i.name));if(l!==void 0){s.set(i.actorId,{color:l,slot:Ko(l)});continue}let c=collaboration.safeParticipantColor(i.color);if(c!==void 0){s.set(i.actorId,{color:c,slot:null});continue}let m=a.get(i.name),d=collaboration.safeParticipantColor(n?.(i.name));if(d!==void 0){s.set(i.actorId,{color:d,slot:Ko(d)??(m?m.slot%Ae:null)});continue}if(m!==void 0){let u=m.slot%Ae;s.set(i.actorId,{color:collaboration.safeParticipantColor(m.color)??`var(--doc-review-author-${u})`,slot:u});continue}let f=r.get(i.name);f===void 0&&(f=e.length+r.size,r.set(i.name,f)),s.set(i.actorId,{color:`var(--doc-review-author-${f%Ae})`,slot:f%Ae});}return s}function xt(e,t,n,o){return Ze(e,[t],n,o).get(t.actorId)}function At(e){let t=e.trim().split(/\s+/,2),n="";for(let o of t){let a=[...o][0];a!==void 0&&(n+=a.toUpperCase());}return n}function $o(e){return [...e].sort((t,n)=>{if(t.isLocal!==n.isLocal)return t.isLocal?-1:1;let o=t.name.localeCompare(n.name);return o!==0?o:t.actorId<n.actorId?-1:t.actorId>n.actorId?1:0})}function je(e,t,n){for(let o of e)if(o.author===t)return o.style?.avatarUrl;return n?.(t)?.avatarUrl}var hr=e=>e.collaborationStatus;function ae(){let e=react$1.useDocxEditor();return react$1.useEditorState(hr),e?.collaborationSession()??null}var Et=Object.freeze([]);function Er(e,t){if(e===t)return true;if(e.length!==t.length)return false;for(let n=0;n<e.length;n+=1){let o=e[n],a=t[n];if(o.actorId!==a.actorId||o.name!==a.name||o.color!==a.color||o.role!==a.role||o.isLocal!==a.isLocal)return false}return true}function Ho(e,t){if(!e)return t.current=Et,Et;let n=e.participants();return Er(t.current,n)?t.current:(t.current=n,n)}function ze(e){let t=ae(),n=e===void 0?t:e,o=react.useRef(Et);return react.useSyncExternalStore(a=>n?.subscribeParticipants(()=>a())??(()=>{}),()=>Ho(n,o),()=>Ho(n,o))}var qo=react.createContext(null);function Tr(e){return {"--doc-collaboration-accent":e.color}}function Vo(e){return e!==void 0?{avatarUrl:e}:{}}function Uo({participant:e,className:t,children:n}){let o=react$1.useDocxEditor(),a=react$1.useReviewAuthors(),s=react.useContext(qo)?.get(e.actorId)??xt(a,e,o?l=>o.presenceColorFor(l):void 0,o?l=>o.getReviewAuthorStyle(l)?.color:void 0),i=Or(e.name);return jsxRuntime.jsx("span",{className:`docx-collaboration-avatar${t?` ${t}`:""}`,"data-collaboration-avatar":"",...e.isLocal?{"data-local":""}:{},...s.slot!==null?{"data-collaboration-author-slot":s.slot}:{},title:e.name,role:"img","aria-label":e.name,style:Tr(s),children:n??(i!==void 0?jsxRuntime.jsx("img",{className:"docx-collaboration-avatar__image",src:i,alt:""}):At(e.name))})}function Or(e){let t=react$1.useDocxEditor(),n=react$1.useReviewAuthors();return je(n,e,t?o=>t.getReviewAuthorStyle(o):void 0)}function Lr({session:e,max:t,className:n,children:o}){let a=react$1.useDocxEditor(),r=ze(e),s=react$1.useReviewAuthors(),{t:i}=react$1.useTranslation(),l=react.useMemo(()=>Ze(s,r,a?p=>a.presenceColorFor(p):void 0,a?p=>a.getReviewAuthorStyle(p)?.color:void 0),[s,r,a]),c=react.useMemo(()=>{let p=a?b=>a.getReviewAuthorStyle(b):void 0,y=new Map;for(let b of r){if(y.has(b.name))continue;let C=je(s,b.name,p);C!==void 0&&y.set(b.name,C);}return y},[a,r,s]),m=react.useMemo(()=>$o(r),[r]);if(m.length===0)return null;let d=t===void 0?m:m.slice(0,Math.max(0,t)),f=m.length-d.length,u=i("collaboration.moreParticipants",{count:f});return jsxRuntime.jsxs("span",{className:`docx-collaboration-avatars${n?` ${n}`:""}`,"data-collaboration-avatars":"",role:"group","aria-label":i("collaboration.participants"),children:[jsxRuntime.jsx(qo.Provider,{value:l,children:d.map(p=>o?jsxRuntime.jsx(react.Fragment,{children:o({participant:p,color:l.get(p.actorId).color,initials:At(p.name),...Vo(c.get(p.name))})},p.actorId):jsxRuntime.jsx(Uo,{participant:p},p.actorId))}),f>0?jsxRuntime.jsx("span",{className:"docx-collaboration-avatar","data-collaboration-avatar":"","data-overflow":"",title:u,role:"img","aria-label":u,children:`+${f}`}):null]})}var We=Object.freeze([]);function Kr(){return We}function $r(){let e=react.useRef(null);if(e.current===null){let t=We,n=false,o=new Set;e.current={subscribe:a=>(o.add(a),()=>o.delete(a)),read:()=>t,write:a=>{t=a.length===0?We:a,!n&&(n=true,queueMicrotask(()=>{n=false;for(let r of [...o])r();}));}};}return e.current}function Hr({session:e,children:t}){let n=react$1.useDocxEditor(),o=ae(),a=e===void 0?o:e,r=ze(a),s=react$1.useReviewAuthors(),i=$r(),l=react.useSyncExternalStore(i.subscribe,i.read,Kr);if(react.useEffect(()=>{if(!(!n||!a))return n.setRemoteCaretLabelHost({publish:i.write}),()=>{n.setRemoteCaretLabelHost(null),i.write(We);}},[n,a,i]),l.length===0)return null;let c=Ze(s,r);return jsxRuntime.jsx(jsxRuntime.Fragment,{children:l.map(m=>{let{selection:d}=m,f=r.find(y=>y.actorId===d.actorId)??null,u=m.element.style.getPropertyValue("--doc-remote-color"),p=u!==""?u:c.get(d.actorId)?.color??xt(s,{actorId:d.actorId,name:d.name,...d.color!==void 0?{color:d.color}:{},isLocal:false}).color;return reactDom.createPortal(t?t({selection:d,participant:f,color:p,...Vo(je(s,d.name,n?y=>n.getReviewAuthorStyle(y):void 0))}):d.name,m.element,d.actorId)})})}var qr=Object.freeze({CaretLabels:Hr,Avatars:Lr,Avatar:Uo});function Ee(e){let t=react$1.useDocxEditor();return react.useMemo(()=>e||(t?.getCustomNodeDefinitions()??[]).filter(chunkOMUXC73J_cjs.j),[e,t])}var jr=".docx-content-control-boundary";function de(e,t){let{node:n,definition:o,controlId:a}=e,r=a?t?.getReviewItems().find(l=>l.kind==="custom"&&l.item.id===a):void 0;if(r&&r.kind==="custom"){let l=r.item;return {...n,attrs:l.attrs,text:l.text,...l.data===void 0?{}:{data:l.data},...a?{nodeId:a}:{}}}let s=a?zr(t,a,o):void 0,i=o.fromDocx?o.fromDocx({attrs:n.attrs,text:"",...s===void 0?{}:{data:s}}):n.attrs;return i===null?null:{...n,attrs:i,...s===void 0?{}:{data:s},...a?{nodeId:a}:{}}}function zr(e,t,n){let o=e?.surface;if(!o)return;let a=editor.partOfNodeId(o.session,t),r=store.customNodePayloadsByControl(o.session.currentPackage(),(a??o.session.part()).name,o.session.part().name).get(t);if(!r)return;let s=chunkOMUXC73J_cjs.e(n.schema,r.data);return s.ok?s.value:void 0}function me(e,t){let n=e?.closest?.(jr),o=n?.closest(".docx-content-control-chrome"),a=o?.getAttribute("data-tag"),r=a?chunkOMUXC73J_cjs.c(a):null;if(!n||!r||!a)return null;let s=t.find(i=>i.tagPrefix===r.prefix&&i.name===r.name);return s?{node:{name:r.name,attrs:r.attrs,tag:a,rect:n.getBoundingClientRect()},definition:s,controlId:o?.getAttribute("data-docx-content-control")??null}:null}var Nt=".docx-content-control-boundary",Gr=e=>{if(!chunkOMUXC73J_cjs.k.test(e.tagPrefix)||!chunkOMUXC73J_cjs.k.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 Qr(e){let{onNodeClick:t,onNodeHover:n}=e,o=react$1.useDocxEditor(),a=Ee(e.nodes);return react.useEffect(()=>{let r=document.createElement("style"),s=[];for(let i of a){let l=Gr(i);if(l.length===0)continue;let c=i.chrome?.color!==void 0&&CSS.supports("color",i.chrome.color)?i.chrome.color:"var(--doc-accent)";s.push(`${l.map(m=>`${m} ${Nt}`).join(", ")} {`," pointer-events: auto !important;"," opacity: 1;"," border: none;",` background: color-mix(in srgb, ${c} 12%, transparent);`," border-radius: 6px;"," cursor: default;","}");}return r.textContent=s.join(`
2
+ `),document.head.append(r),()=>r.remove()},[a]),react.useEffect(()=>{let r=null,s=null,i=d=>me(document.elementFromPoint(d.clientX,d.clientY),a),l=d=>{let f=d.button===0?i(d):null;r=f?.controlId??null,s=f?.node.tag??null;},c=d=>{let f=r,u=s;if(r=null,s=null,u===null)return;let p=i(d);if(!p||p.node.tag!==u||f!==null&&p.controlId!==f)return;let y=de(p,o);y&&(p.definition.onClick?.(y),t?.(y));},m=d=>{let f=me(d.target,a);if(!f||d.relatedTarget?.closest?.(Nt)===d.target.closest(Nt))return;let p=de(f,o);p&&(f.definition.onHover?.(p),n?.(p));};return document.addEventListener("pointerdown",l,true),document.addEventListener("pointerup",c,true),document.addEventListener("mouseover",m),()=>{document.removeEventListener("pointerdown",l,true),document.removeEventListener("pointerup",c,true),document.removeEventListener("mouseover",m);}},[a,o,t,n]),null}var oa=e=>e.editingMode==="viewing";function Zo(e){let{onEditNode:t,onRemoveRefused:n,remove:o=true}=e,a=Ee(e.nodes),r=react$1.useContextMenuTarget(),s=react$1.useDocxEditor(),{t:i}=react$1.useTranslation(),l=react.useMemo(()=>r?me(r,a):null,[r,a]),c=react.useMemo(()=>l?de(l,s):null,[l,s]),m=react$1.useEditorState(oa),d=react.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,u=f.label??f.name,p=!m&&(f.onEdit!==void 0||t!==void 0),y=!m&&o&&c.nodeId!==void 0&&s!==null;return !d&&!p&&!y?null:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[d?jsxRuntime.jsxs("div",{className:"docx-contextmenu__custom-info","data-testid":"custom-node-info",children:[jsxRuntime.jsx("span",{className:"docx-contextmenu__custom-title",children:d.title}),d.detail?jsxRuntime.jsx("span",{className:"docx-contextmenu__custom-detail",children:d.detail}):null]}):null,p?jsxRuntime.jsx(react$1.ContextMenuItem,{label:i("contextMenu.editCustomNode",{label:u}),className:"docx-contextmenu__custom-edit",onSelect:()=>{f.onEdit?.(c),t?.(c,f);}}):null,y?jsxRuntime.jsx(react$1.ContextMenuItem,{label:i("contextMenu.removeCustomNode",{label:u}),className:"docx-contextmenu__custom-remove",onSelect:()=>{let b=chunkOMUXC73J_cjs.q(s,c.nodeId);b.ok||n?.(c,b.reason);}}):null,jsxRuntime.jsx("div",{role:"separator",className:"docx-toolbar__menu-separator"})]})}Zo.docxRowPlacement="start";var _t=Object.freeze({status:"inactive",reason:void 0,lastFailure:void 0,live:false,diverged:false,attached:false});function jo(e,t){return e===t?true:!e||!t?false:e.code===t.code&&e.detail===t.detail}function ia(e,t){return e.status===t.status&&jo(e.reason,t.reason)&&jo(e.lastFailure,t.lastFailure)}function sa(e){return e.attached??false}function zo(e,t){if(!e)return t.current=_t,_t;let n=e.statusSnapshot(),o=sa(e);if(ia(t.current,n)&&t.current.attached===o)return t.current;let a=Object.freeze({status:n.status,reason:n.reason,lastFailure:n.lastFailure,live:n.status==="ready",diverged:n.status==="error"||n.status==="destroyed",attached:o});return t.current=a,a}function la(e){let t=ae(),n=e===void 0?t:e,o=react.useRef(_t);return react.useSyncExternalStore(a=>n?.subscribeStatus(()=>a())??(()=>{}),()=>zo(n,o),()=>zo(n,o))}function ua({collaboration:e,fallback:t=null,author:n,children:o,...a}){let{document:r,modules:s,session:i}=e;if(!r)return jsxRuntime.jsx(jsxRuntime.Fragment,{children:t});let l=n??i?.identity.name;return jsxRuntime.jsx(react$1.DocxEditorRoot,{document:r,modules:s,...l!==void 0?{author:l}:{},...a,children:o},i?.sessionId??"local")}var va=Symbol("useDocumentCollaboration.createRoom");async function pa(e){let{createDocumentCollaboration:t}=await import('../document-session-YZRHVYCK.cjs');return t(e)}function wa(e){return e[va]??pa}function ya(e){return e?`${e.documentId}:${e.bootstrap.kind}:${e.identity.actorId}`:""}function Ra(e={}){let t=react.useId(),n=chunkGDTCNTK7_cjs.b({ownerKey:`react-document:${t}`,hookName:"useDocumentCollaboration",createRoom:wa(e),hostModules:e.modules??chunkGDTCNTK7_cjs.a,autoRoom:e.room??null,autoKey:ya(e.room??null),rejoinOptionsOf:o=>({...o,bootstrap:{kind:"join"}}),identityOf:o=>o.identity});return react.useMemo(()=>({document:n.document,modules:n.modules,session:n.session,pending:n.pending,error:n.error,connect:n.connect,leave:n.leave}),[n])}Object.defineProperty(exports,"reviewModule",{enumerable:true,get:function(){return chunkOMUXC73J_cjs.o}});Object.defineProperty(exports,"collaborationModule",{enumerable:true,get:function(){return chunkQLZH2Q2C_cjs.b}});exports.CustomNodeChrome=Qr;exports.CustomNodeContextMenu=Zo;exports.DocxEditorCollaboration=qr;exports.DocxEditorCollaborationRoot=ua;exports.DocxEditorReview=br;exports.activatedCustomNodeOf=de;exports.resolveCustomNodeActivation=me;exports.useCollaborationParticipants=ze;exports.useCollaborationSession=ae;exports.useCollaborationStatus=la;exports.useCustomNodeDefinitions=Ee;exports.useDocumentCollaboration=Ra;exports.useReview=Te;exports.useReviewAuthor=lr;exports.useReviewItem=sr;exports.useReviewOf=no;exports.useStackedReviewPositions=xn;
@@ -255,15 +255,15 @@ interface ReviewProps extends Omit<ReviewPartProps, 'children'> {
255
255
  /** Show only some of the queue — comments in one rail, revisions in another. */
256
256
  filter?: (item: ReviewItemView) => boolean;
257
257
  /**
258
- * Show the "changed the document structure" cards. Default `false`: a heavily revised
259
- * document carries one per structural site and together they crowd out the cards a
260
- * reviewer can act on. The revisions stay marked in the document, where clicking one
261
- * opens its balloon — this hides only their rail cards.
258
+ * Show structural changes in the sidebar. Default `true`: row, cell, merge, and
259
+ * numbering decisions must remain discoverable even without a clickable page marker.
260
+ * Set `false` to hide their cards; painted row markers still open a balloon.
262
261
  */
263
262
  structural?: boolean;
264
263
  /**
265
264
  * Show formatting changes in the rail. Default `false`: inspect formatting in the
266
- * page balloon. Set `true` to also include its decisions in the sidebar.
265
+ * page balloon. Changes without a painted formatting anchor stay in the sidebar.
266
+ * Set `true` to include all formatting decisions in the sidebar.
267
267
  */
268
268
  formatting?: boolean;
269
269
  }
@@ -255,15 +255,15 @@ interface ReviewProps extends Omit<ReviewPartProps, 'children'> {
255
255
  /** Show only some of the queue — comments in one rail, revisions in another. */
256
256
  filter?: (item: ReviewItemView) => boolean;
257
257
  /**
258
- * Show the "changed the document structure" cards. Default `false`: a heavily revised
259
- * document carries one per structural site and together they crowd out the cards a
260
- * reviewer can act on. The revisions stay marked in the document, where clicking one
261
- * opens its balloon — this hides only their rail cards.
258
+ * Show structural changes in the sidebar. Default `true`: row, cell, merge, and
259
+ * numbering decisions must remain discoverable even without a clickable page marker.
260
+ * Set `false` to hide their cards; painted row markers still open a balloon.
262
261
  */
263
262
  structural?: boolean;
264
263
  /**
265
264
  * Show formatting changes in the rail. Default `false`: inspect formatting in the
266
- * page balloon. Set `true` to also include its decisions in the sidebar.
265
+ * page balloon. Changes without a painted formatting anchor stay in the sidebar.
266
+ * Set `true` to include all formatting decisions in the sidebar.
267
267
  */
268
268
  formatting?: boolean;
269
269
  }