@docx-editor.dev/pro 2.7.0 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-4LFF2FXG.cjs +1 -0
- package/dist/chunk-TH5PXU6L.js +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/react/index.cjs +2 -2
- package/dist/react/index.js +2 -2
- package/dist/vue/index.cjs +2 -2
- package/dist/vue/index.d.cts +1 -1
- package/dist/vue/index.d.ts +1 -1
- package/dist/vue/index.js +2 -2
- package/package.json +2 -2
- package/dist/chunk-QIMNGUJX.cjs +0 -1
- package/dist/chunk-TNUAAUFI.js +0 -1
package/dist/vue/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {customNodePayloadsByControl,parseNoteScopeId,findNode,revisionItemsOf,collectReviewItems,paragraphOrderOfPart,locateSites,contentControlPropertiesOf}from'@docx-editor.dev/core/store';import {reviewItemPositionRank}from'@docx-editor.dev/core/layout';import {computed,defineComponent,shallowRef,watchEffect,provide,onBeforeUnmount,h,Fragment,cloneVNode,onMounted,getCurrentInstance,ref,watch,onUnmounted,inject,isVNode,mergeProps,toValue}from'vue';import {Slot,useTranslation,useDocxEditor,useEditorState,ReviewRailContext,useReviewGutter,REVIEW_PANE_GUTTER,useReviewAuthors,useContextMenuTarget,ContextMenuItem}from'@docx-editor.dev/vue';import {jsx,jsxs,Fragment as Fragment$1}from'vue/jsx-runtime';function Zt(e){}var uo=new Set(["__proto__","constructor","prototype"]);function ze(e){if(e.length>64)return null;let t=e.indexOf(":");if(t<=0)return null;let r=e.slice(0,t),n=e.slice(t+1),o=n.indexOf("?"),i=o===-1?n:n.slice(0,o);if(i.length===0)return null;let s=Object.create(null);if(o!==-1)for(let[a,u]of new URLSearchParams(n.slice(o+1))){if(uo.has(a))return null;s[a]=u;}return {prefix:r,name:i,attrs:s}}function Xe(e,t){if(t.length===0)return {ok:false,reason:"malformed",issues:["the node carries no payload"]};if(t.length>262144)return {ok:false,reason:"malformed",issues:[`the payload is ${String(t.length)} characters; the cap is ${String(262144)}`]};let r;try{r=JSON.parse(t);}catch(i){return {ok:false,reason:"malformed",issues:[i instanceof Error?i.message:"the payload is not JSON"]}}let n=xt(r);if(!e)return {ok:true,value:n};let o=e["~standard"].validate(n);return co(o)?{ok:false,reason:"async",issues:["the schema validates asynchronously, which the read path cannot await"]}:o.issues?{ok:false,reason:"invalid",issues:o.issues.map(mo)}:{ok:true,value:o.value}}function co(e){return typeof e.then=="function"}function mo(e){let t=(e.path??[]).map(r=>String(typeof r=="object"?r.key:r)).join(".");return t.length>0?`${t}: ${e.message}`:e.message}var fo=new Set(["__proto__","constructor","prototype"]);function xt(e){if(Array.isArray(e))return e.map(xt);if(e===null||typeof e!="object")return e;let t=Object.create(null);for(let[r,n]of Object.entries(e))fo.has(r)||(t[r]=xt(n));return t}function Je(e){return typeof e=="object"&&e!==null&&typeof e.name=="string"&&typeof e.tagPrefix=="string"}var Nt=/^[A-Za-z0-9_.-]+$/;function po(e){for(let t of e.children)if(!(t.kind==="textValue"||t.localName!=="sdtPr")){for(let r of t.children)if(!(r.kind==="textValue"||r.localName!=="tag")){for(let n of r.attributes)if(n.localName==="val")return n.value}}}function Wt(e){if(e.kind==="textValue")return e.value;let t="";for(let r of e.children)t+=Wt(r);return t}function zt(e,t,r={}){if(t.length===0)return [];let n=new Map;for(let s of t){let a=`${s.tagPrefix}:${s.name}`;if(n.has(a))throw new Error(`recognizeCustomNodes: duplicate definition for ${JSON.stringify(a)}`);n.set(a,s);}let o=[],i=(s,a)=>{if(!(s.kind==="textValue"||a>64)){if(s.kind==="contentControl"){let u=po(s),d=u!==void 0?ze(u):null,l=d?n.get(`${d.prefix}:${d.name}`):void 0;if(d&&l&&u!==void 0){let c=Wt(s),f=yo(l,s.id,r.payloads?.get(s.id),contentControlPropertiesOf(s).dataBinding!==void 0,r.onDiagnostic),m=l.fromDocx?l.fromDocx({attrs:d.attrs,text:c,...f.present?{data:f.value}:{}}):d.attrs;if(m!==null){o.push({name:l.name,attrs:m,text:c,nodeId:s.id,tag:u,...f.present?{data:f.value}:{}});return}}}for(let u of s.children)i(u,a+1);}};return i(e.root,0),o}function yo(e,t,r,n,o){if(!r)return n&&o?.({code:"payload-missing",name:e.name,nodeId:t,issues:["the control binds a store node this document does not hold"]}),{present:false};let i=Xe(e.schema,r.data);return i.ok?{present:true,value:i.value}:(o?.({code:"payload-invalid",name:e.name,nodeId:t,issues:i.issues}),{present:false})}function Jt(e,t){let r=findNode(e,t);return !r||r.kind!=="paragraph"?[]:revisionItemsOf({id:e.id,name:e.name,contentType:e.contentType,root:r})}function No(e,t,r,n){if(t.length===0)return [];let o=zt(e,t,{...r===void 0?{}:{payloads:r},...n===void 0?{}:{onDiagnostic:n}});if(o.length===0)return [];let i=locateSites(e),s=[];for(let a of o){let u=t.find(c=>c.name===a.name&&a.tag.startsWith(`${c.tagPrefix}:`));if(!u)continue;let d=u.reviewCard?u.reviewCard({attrs:a.attrs,text:a.text,...a.data===void 0?{}:{data:a.data}}):null;if(u.reviewCard&&d===null)continue;let l=i.get(a.nodeId);s.push({kind:"custom",id:a.nodeId,name:a.name,tag:a.tag,attrs:a.attrs,text:a.text,...a.data===void 0?{}:{data:a.data},carded:u.reviewCard!==void 0&&d!==null,title:d?.title??"",...d?.detail!==void 0?{detail:d.detail}:{},...d?.icon!==void 0?{icon:d.icon}:{},range:l?{partName:e.name,start:{paragraphId:l.paragraphId,offset:l.start},end:{paragraphId:l.paragraphId,offset:l.end}}:null});}return s}function Qt(e){let t=collectReviewItems(e),r=(e.customNodes??[]).filter(Je);if(r.length===0)return t;let n=[e.storyPart],o=new Set([e.storyPart.name]);for(let u of e.furnitureParts??[])o.has(u.name)||(o.add(u.name),n.push(u));let i=[],s=new Map;for(let u of n){i.push(...No(u,r,u.name===e.storyPart.name?e.customNodePayloads:void 0,e.reportCustomNodeDiagnostic));let d=s.size;for(let[l,c]of paragraphOrderOfPart(u))s.has(l)||s.set(l,d+c);}return i.length===0?t:[...t,...i].sort((u,d)=>reviewItemPositionRank(u,s)-reviewItemPositionRank(d,s))}function Co(e={}){return Zt(e.licenseKey),{id:"review",review:{displayModes:["all-markup","proposed","original"],collectReviewItems:Qt,revisionItemsOfParagraph:Jt}}}var en=Symbol("proEditorRenderRevision");function tn(e){return provide(en,e),e}function fe(){let e=inject(en,null);if(e)return e;let t=useDocxEditor(),r=shallowRef("none");return watch(()=>t.value,(n,o,i)=>{if(!n){r.value="none";return}let s=n,a=`${s.getReviewRevision()}:${s.getEditingMode()}`;r.value=a;let u=false,d=null,l=()=>{u||d!==null||(d=setTimeout(()=>{if(d=null,u)return;let g=`${s.getReviewRevision()}:${s.getEditingMode()}`;g!==a&&(a=g,r.value=g);},0));},c=s.on("change",l),f=s.on("selectionChange",l),m=s.on("error",l);i(()=>{u=true,d!==null&&clearTimeout(d),c(),f(),m();});},{immediate:true,flush:"sync"}),r}function Qe(e){if(e!==void 0)return typeof e=="function"?e():typeof e=="object"&&e!==null&&"value"in e?e.value:e}function nn(e){return `${e.getReviewRevision()}:${e.getEditingMode()}`}function Oo(e){let t=useDocxEditor(),r=fe();return bt(t,e,r)}function Ct(e,t){let r=useDocxEditor();return bt(r,e,t)}function _o(e,t){return bt(e,t)}function bt(e,t,r){let n=r?null:shallowRef("none"),o=()=>{(r??n)?.value;};r||watch(()=>e.value,(w,x,P)=>{if(!w){n.value="none";return}let K=nn(w);n.value=K;let J=false,Y=null,ne=()=>{J||Y!==null||(Y=setTimeout(()=>{if(Y=null,J)return;let Ne=nn(w);Ne!==K&&(K=Ne,n.value=Ne);},0));},pt=w.on("change",ne),yt=w.on("selectionChange",ne),Fe=w.on("error",ne);P(()=>{J=true,Y!==null&&clearTimeout(Y),pt(),yt(),Fe();});},{immediate:true,flush:"sync"});let i=computed(()=>{o();let w=e.value,x=Qe(t);return w?w.getReviewItems(x).filter(P=>P.item.kind!=="custom"||P.item.carded):[]}),s=computed(()=>i.value.find(w=>w.isActive)?.key??null),a=(w,x)=>{let P=e.value;return P?P.setActiveReviewItem(w,x).ok:false},u=w=>{let x=e.value;return !x||w.kind!=="revision"||w.readOnly?false:x.acceptReviewItem(w.key).ok},d=w=>{let x=e.value;return !x||w.kind!=="revision"||w.readOnly?false:x.rejectReviewItem(w.key).ok},l=w=>{let x=e.value;return !x||w.kind!=="comment"?false:x.setCommentResolved(w.key,true).ok},c=w=>{let x=e.value;return !x||w.kind!=="comment"?false:x.setCommentResolved(w.key,false).ok},f=computed(()=>(o(),e.value?.getEditingMode()==="viewing"?"the document is open for viewing":null)),m=w=>{let x=e.value;return !x||w.kind==="custom"||w.kind==="revision"&&w.readOnly?false:x.deleteReviewItem(w.key).ok},g=(w,x,P)=>x.trim().length===0||!e.value?false:e.value.replyToReviewItem(w.key,x,P).ok,p=computed(()=>{o();let w=e.value;return w?w.getSelectionPlacement()?.anchorY??null:null}),N=(w,x)=>w.trim().length===0||!e.value?false:e.value.addComment(w,x).ok,I=computed(()=>{o();let w=e.value;return w?w.isReviewPaneOpen():true}),y=w=>{let x=e.value;!x||x.isReviewPaneOpen()===w||x.exec({type:"toggleReviewPane"});},E=computed(()=>{o();let w=e.value;if(w===null)return false;let x=w.snapshot();return !x.isLoading&&x.parseError===null});return {items:i,activeKey:s,setActive:a,accept:u,reject:d,resolve:l,reopen:c,commentResolutionDisabledReason:f,remove:m,reply:g,selectionAnchorY:p,comment:N,paneOpen:I,setPaneOpen:y,ready:E}}function Po(e,t,r={}){return computed(()=>{let n=Qe(e)??[],o=Qe(t)??new Map,i=Qe(r)??{},s=i.gap??8,a=i.scale??1,u=i.defaultHeight??0,d=new Map,l=Number.NEGATIVE_INFINITY;for(let c of n){let f=c.anchorY===null?Number.isFinite(l)?l:0:Math.max(c.anchorY,l);d.set(c.key,f),l=f+((o.get(c.key)??u)+s)/a;}return d})}var Lo=new Set(["List","Markers","AddComment","Draft","Balloon"]),$o=new Set(["Card","Empty"]);function Ko(e){return isVNode(e)}function Ee(e,t){let r=t==="root"?Lo:$o,n={},o=[],i=s=>{for(let a of s){if(!Ko(a))continue;if(a.type===Fragment){let d=Array.isArray(a.children)?a.children:[];i(d);continue}let u=a.type.docxReviewPart;u&&r.has(u)?n[u]=a:o.push(a);}};return i(e),{parts:n,rest:o}}function et(e,t){if(!t)return e;let r=e.props.class;return cloneVNode(e,{class:`${t}${r?` ${r}`:""}`})}var rn=e=>e.isLoading||e.parseError!==null||e.pageSetup==null,ke=e=>e.editingMode==="viewing",an={scale:96/72,top:0,left:null,compactCardLeft:null},sn=16,Te=300,ln=12,te="\0compose",tt=600,nt=8,dn=72,un=64,cn=480,mn=30,fn=Object.freeze({placement:false});function Ae(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 Oe(e){return new Set(e.map(t=>t.id))}function L(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function vn(e){let t=e.trim().split(/\s+/).filter(Boolean);return t.length===0?"?":t.slice(0,2).map(r=>r[0].toUpperCase()).join("")}var ot=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function pn(e){let t={},r=[],n=o=>{if(!o)return;let i=Array.isArray(o)?o:[o];for(let s of i){if(!isVNode(s))continue;if(s.type===Fragment){n(s.children);continue}let a=s.type.docxReviewPart;a?t[a]=s:r.push(s);}};return n(e),r.length>0&&(t.__extra=r),t}function A(e,t){return e.docxReviewPart=t,e}var St=Symbol("ReviewContext"),Et=Symbol("ReviewItemContext"),Yo={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},Go={t:void 0,cardClassName:void 0,readOnly:false,composeTop:null,review:Yo,allItems:[],authorSlots:new Map,authorInfo:new Map,draftAuthor:null,draftAuthorInfo:void 0,draftAuthorSlot:0,byId:new Map,measure:()=>{},beginDraft:()=>{},endDraft:()=>{},expandedResolvedKey:null,setExpandedResolvedKey:()=>{}};function O(){return inject(St,computed(()=>Go))}var Zo=computed(()=>null);function $(){return inject(Et,Zo)}function Wo(e){let t=O();return computed(()=>{let r=toValue(e);return r===void 0?void 0:t.value.authorInfo.get(r)})}function j(){let e=O(),{t}=useTranslation();return r=>e.value.t?.(r)??t(r)}function zo(e){return [e.key,e.isActive?"active":"idle",e.readOnly?"readonly":"editable",e.kind==="comment"&&e.resolved?"resolved":"open",e.text,...e.replyIds].join("\0")}var rt=defineComponent({name:"ReviewItemScope",props:{entry:{type:Object,required:true},measureKey:String,collapsed:Boolean,className:String,testId:String,style:{type:Object,default:void 0}},setup(e,{slots:t}){let r=O(),n=shallowRef(e.entry);watchEffect(()=>{let a=r.value.byId.get(e.entry.id)??e.entry;n.value={...a,replyIds:[...a.replyIds]};}),provide(Et,n);let o=null,i=null,s=a=>{let u=a instanceof HTMLElement?a:null,d=u&&e.measureKey?e.measureKey:null;o===u&&i===d||(i&&r.value.measure(null,i),o=u,i=d,o&&i&&r.value.measure(o,i));};return onBeforeUnmount(()=>{s(null);}),()=>h("div",{onVnodeMounted:a=>{s(a.el instanceof Element?a.el:null);},onVnodeUpdated:a=>{s(a.el instanceof Element?a.el:null);},onVnodeBeforeUnmount:()=>{s(null);},class:`docx-review__slot${e.className?` ${e.className}`:""}`,...e.testId?{"data-testid":e.testId}:{},style:e.style,...e.collapsed?{"data-collapsed":""}:{}},[h(Fragment,{key:zo(n.value)},t.default?.())])}}),at=defineComponent({name:"ReviewReplyScope",props:{entry:{type:Object,required:true}},setup(e,{slots:t}){let r=O(),n=shallowRef(e.entry);return watchEffect(()=>{let o=r.value.byId.get(e.entry.id)??e.entry;n.value={...o,replyIds:[...o.replyIds]};}),provide(Et,n),()=>t.default?.()}});function Nn(e){let t=ref(new WeakMap),r=ref(new Map),n=ref(null),o=(i,s)=>{let a=r.value.get(s);if(!i){a&&(n.value?.unobserve(a),t.value.delete(a),r.value.delete(s));return}typeof ResizeObserver>"u"||(e(s,i.offsetHeight),n.value??=new ResizeObserver(u=>{for(let d of u){let l=t.value.get(d.target);l&&e(l,d.target.offsetHeight);}}),!(a===i&&t.value.get(i)===s)&&(a&&(n.value.unobserve(a),t.value.delete(a)),t.value.set(i,s),r.value.set(s,i),n.value.observe(i)));};return onUnmounted(()=>{n.value?.disconnect(),r.value.clear();}),o}function Tt(e,t){return e?.color??`var(--doc-review-author-${t%nt})`}function se(e,t,r){return e?{"--doc-review-author-current":Tt(t,r)}:{}}function ve(e,t){return (e?.slot??t)%nt}function Cn(e,t,r,n,o){let i=new Map;for(let a of e)i.set(a.author,a);let s=[...t.map(a=>a.author),n?.getConfiguredAuthor()];for(let a of s){if(!a||i.has(a))continue;let u=r.get(a)??0,d=n?.getReviewAuthorStyle(a),l=d?.color??`var(--doc-review-author-${u%nt})`,c=o.get(a),f=c?.slot===u&&c.color===l&&c.style===d?c:{author:a,slot:u,color:l,...d?{style:d}:{}};o.set(a,f),i.set(a,f);}return i}var F=e=>h("svg",{viewBox:"0 -960 960 960",width:16,height:16,ariaHidden:true,focusable:false},[h("path",{d:e,fill:"currentColor"})]),In="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",bn="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",Jo="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",Pe="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z",it=()=>h("span",{class:"docx-review__resolved-icon"},[h("span",{class:"docx-review__resolved-comment"},[F(Jo)]),h("span",{class:"docx-review__resolved-tick"},[F(Pe)])]),Sn="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",En="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",kn="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",Qo="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",er="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",tr="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",nr="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 Tn(e){if(e.kind==="comment")return bn;if(e.kind==="custom")return e.item.icon??nr;switch(e.revisionKind){case "insert":case "moveTo":return Qo;case "delete":case "moveFrom":return er;case "format":return tr;default:return bn}}function st(e,t){if(e==="paragraphMark")return t==="delete"?"revisions.paragraphMarkDeleted":t==="moveFrom"?"revisions.paragraphMarkMovedFrom":t==="moveTo"?"revisions.paragraphMarkMovedTo":"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 ar(e,t){return typeof t!="function"?e:typeof e!="function"?t:r=>{e(r),r.defaultPrevented||t(r);}}function ir(e,t){let r=mergeProps(e,t);for(let n of Object.keys(e))/^on[A-Z]/.test(n)?r[n]=ar(t[n],e[n]):n==="class"?r[n]=[e[n],t[n]].filter(Boolean).join(" "):n==="style"&&(r[n]={...e[n],...t[n]});return r}function Pn(e){return e==="Enter"||e===" "}function sr(e){return Pn(e.key)?(e.preventDefault(),e.stopPropagation(),true):false}function On(e){return e==="button"}function _n(e,t){return e==="a"||t.href!=null}var pe=defineComponent({name:"ReviewActionSlot",props:{engineDisabled:{type:Boolean,required:true},disabledReason:{type:String,default:null},slotProps:{type:Object,required:true}},setup(e,{slots:t}){return ()=>{let r=t.default?.()??[];if(r.length!==1)return null;let n=r[0];if(!n||typeof n!="object")return null;let o=n.props??{},i=ir(e.slotProps,o);if(!e.engineDisabled){if(!On(n.type)){let s={onClick:a=>{typeof o.onClick=="function"&&o.onClick(a),!a.defaultPrevented&&typeof e.slotProps.onClick=="function"&&e.slotProps.onClick(a),_n(n.type,o)&&a.preventDefault();},onKeydown:a=>{typeof o.onKeydown=="function"&&o.onKeydown(a),Pn(a.key)&&(!a.defaultPrevented&&typeof e.slotProps.onClick=="function"&&e.slotProps.onClick(a),_n(n.type,o)&&a.preventDefault());}};i.onClick=s.onClick,i.onKeydown=s.onKeydown;}return cloneVNode(n,i)}if(On(n.type))i.disabled=true,delete i["aria-disabled"];else {delete i.disabled,i["aria-disabled"]=true,i["data-disabled"]="",i.tabIndex=-1,i.href=void 0,i.role===void 0&&(i.role="button");let s=i.onKeydown;i.onKeydown=a=>{sr(a)||typeof s=="function"&&s(a);};}return e.disabledReason&&(i.title=e.disabledReason),i.onClick=s=>{s.preventDefault(),s.stopPropagation();},cloneVNode(n,i)}}});function Vn(e){let t=A(defineComponent({name:"ReviewResolve",props:{className:String,asChild:Boolean,hidden:Boolean,icon:{type:[Object,String],default:void 0}},setup(n,{slots:o}){let i=e.useRail(),s=e.useItem(),a=e.useLabel(),u=useEditorState(ke);return ()=>{let d=s.value;if(n.hidden||!d||d.kind!=="comment"||d.resolved)return null;let l=i.value.review,c=a("comments.resolve"),f=u.value||l.commentResolutionDisabledReason!==null,m=f?a("editingMode.viewingHint"):null,g={type:"button",class:`docx-review__action${n.className?` ${n.className}`:""}`,"data-testid":"review-resolve","aria-label":c,title:m??c,disabled:f,onMousedown:L,onClick:p=>{p.stopPropagation(),!f&&l.resolve(d);}};return n.asChild?h(pe,{engineDisabled:f,disabledReason:m,slotProps:g},o.default):h("button",g,n.icon??o.default?.()??F(Pe))}}}),"Resolve"),r=A(defineComponent({name:"ReviewReopen",props:{className:String,asChild:Boolean,hidden:Boolean,icon:{type:[Object,String],default:void 0}},setup(n,{slots:o}){let i=e.useRail(),s=e.useItem(),a=e.useLabel(),u=useEditorState(ke);return ()=>{let d=s.value;if(n.hidden||!d||d.kind!=="comment"||!d.resolved)return null;let l=i.value.review,c=a("comments.reopen"),f=u.value||l.commentResolutionDisabledReason!==null,m=f?a("editingMode.viewingHint"):null,g={type:"button",class:`docx-review__action${n.className?` ${n.className}`:""}`,"data-testid":"review-reopen","aria-label":c,title:m??c,disabled:f,onMousedown:L,onClick:p=>{p.stopPropagation(),!f&&l.reopen(d);}};return n.asChild?h(pe,{engineDisabled:f,disabledReason:m,slotProps:g},o.default):h("button",g,n.icon??o.default?.()??F(Sn))}}}),"Reopen");return {ReviewResolve:t,ReviewReopen:r}}var Ln=new WeakMap;function Me(e){let t=getCurrentInstance();if(!t)throw new Error("useReviewStableId must run during component setup");let r=t.appContext,n=Ln.get(r)??0;return Ln.set(r,n+1),`docx-review-${n}-${e}`}function Hn(e){let t=A(defineComponent({name:"ReviewDraft",props:{top:{type:Number,default:0},left:{type:Number,default:null},className:String,hidden:Boolean},setup(n){let o=e.useRail(),i=e.useLabel(),s=ref(""),a=ref(false),u=Me("draft"),d=null;onMounted(()=>{let c=getCurrentInstance()?.proxy?.$el;if(c instanceof HTMLElement&&(d=o.value.measure,d(c,te)),o.value.readOnly)return;(c instanceof HTMLElement?c.querySelector('[data-testid="review-draft-input"]'):null)?.focus({preventScroll:true});}),onBeforeUnmount(()=>{d?.(null,te);});let l=()=>{let{review:c,endDraft:f,readOnly:m}=o.value;if(m||s.value.trim().length===0)return;let g=c.comment(s.value.trim());a.value=!g,g&&(s.value="",f());};return ()=>{if(n.hidden)return null;let{readOnly:c,draftAuthor:f,draftAuthorInfo:m,draftAuthorSlot:g}=o.value;return h("div",{class:`docx-review__slot${n.left===null?"":" docx-review__slot--compact"}${n.className?` ${n.className}`:""}`,style:{position:"absolute",top:`${n.top}px`,...n.left===null?{}:{left:`${n.left}px`,width:`${Te}px`}}},[h("div",{class:"docx-review__card","data-testid":"review-draft","data-draft":"",...f?{"data-review-author":f,"data-review-author-slot":g}:{},style:se(f??void 0,m,g)},[h("form",{class:"docx-review__reply-box",onSubmit:p=>{p.preventDefault(),l();}},[h("label",{class:"docx-editor-sr-only",for:u},i("comments.addComment")),h("input",{id:u,"data-testid":"review-draft-input",class:"docx-review__input",value:s.value,placeholder:i("comments.addComment"),readonly:c,...a.value?{"aria-invalid":true}:{},onInput:p=>{c||(a.value=false,s.value=p.target.value);},onKeydown:p=>{if(p.key==="Escape"){p.preventDefault(),o.value.endDraft();return}c||p.key!=="Enter"||(p.preventDefault(),l());}}),h("div",{class:"docx-review__reply-actions"},[h("button",{type:"button","data-testid":"review-draft-cancel",class:"docx-review__text-button",onMousedown:L,onClick:()=>o.value.endDraft()},i("common.cancel")),h("button",{type:"submit","data-testid":"review-draft-submit",class:"docx-review__submit",disabled:c||s.value.trim().length===0,title:c?i("editingMode.viewingHint"):void 0},i("common.comment"))]),a.value?h("span",{class:"docx-review__refused",role:"alert"},i("review.commentRefused")):null])])])}}}),"Draft"),r=A(defineComponent({name:"ReviewReply",props:{className:String,hidden:Boolean},setup(n,{slots:o}){let i=e.useRail(),s=e.useItem(),a=e.useLabel(),u=ref(""),d=ref(false),l=Me("reply"),c=fe(),f=useDocxEditor(),m=g=>{let p=s.value,{review:N,readOnly:I,byId:y}=i.value,E=g?.querySelector('[data-testid="review-reply-input"]'),w=(E?.value??u.value).trim(),x=p?y.get(p.id)??p:null;if(!x||I||w.length===0)return;let P=f.value?.replyToReviewItem(x.key,w).ok??N.reply(x,w);d.value=!P,P&&(u.value="",E&&(E.value=""));};return ()=>{c.value;let g=s.value;if(n.hidden||!g||!g.isActive||g.kind==="comment"&&g.resolved)return null;let{review:p,readOnly:N}=i.value,I=o.default?.();return I?.length?I:jsxs("div",{class:`docx-review__reply-box${n.className?` ${n.className}`:""}`,children:[jsx("label",{class:"docx-editor-sr-only",for:l,children:a("comments.replyPlaceholder")}),jsx("input",{id:l,"data-testid":"review-reply-input",class:"docx-review__input",placeholder:a("comments.replyPlaceholder"),readonly:N,...d.value?{"aria-invalid":true,"data-refused":""}:{},onInput:y=>{N||(d.value=false,u.value=y.target.value);},onClick:y=>y.stopPropagation(),onKeydown:y=>{N||y.key!=="Enter"||(y.preventDefault(),m(y.currentTarget.closest(".docx-review__reply-box")));}}),jsxs("div",{class:"docx-review__reply-actions",children:[jsx("button",{type:"button","data-testid":"review-reply-cancel",class:"docx-review__text-button",onMousedown:L,onClick:y=>{y.stopPropagation(),u.value="",d.value=false,p.setActive(null);},children:a("common.cancel")}),jsx("button",{type:"button","data-testid":"review-reply-submit",class:"docx-review__submit",disabled:N,title:N?a("editingMode.viewingHint"):void 0,onClick:y=>{y.preventDefault(),y.stopPropagation(),m(y.currentTarget.closest(".docx-review__reply-box"));},children:a("review.reply")})]}),d.value?jsx("span",{class:"docx-review__refused",role:"alert","data-testid":"review-reply-refused",children:a("review.replyRefused")}):null]})}}}),"Reply");return {ReviewDraft:t,ReviewReply:r}}var{ReviewResolve:Ot,ReviewReopen:_t}=Vn({useRail:O,useItem:$,useLabel:j}),{ReviewDraft:Pt,ReviewReply:Mt}=Hn({useRail:O,useItem:$,useLabel:j});var ut=A(defineComponent({name:"ReviewEmpty",props:{className:String,hidden:Boolean,asChild:Boolean},setup(e,{slots:t}){let r=j();return ()=>e.hidden?null:jsx("div",{class:`docx-review__empty${e.className?` ${e.className}`:""}`,"data-testid":"review-empty",children:t.default?.()??r("review.empty")})}}),"Empty"),ye=A(defineComponent({name:"ReviewAvatar",props:{className:String,hidden:Boolean,asChild:Boolean},setup(e,{slots:t}){let r=$(),n=O();return ()=>{let o=r.value;if(e.hidden||!o)return null;let i=t.default?.();if(i===void 0&&!o.initials)return null;let s={class:`docx-review__avatar${e.className?` ${e.className}`:""}`,"data-testid":"review-avatar","aria-hidden":true};if(e.asChild)return jsx(Slot,{...s,children:i});let a=n.value.authorInfo.get(o.author)?.style?.avatarUrl,u=i??(a?jsx("img",{class:"docx-review__avatar-img",src:a,alt:"",loading:"lazy",decoding:"async",referrerpolicy:"no-referrer"}):void 0)??o.initials;return jsx("span",{...s,children:u})}}}),"Avatar"),we=A(defineComponent({name:"ReviewAuthor",props:{className:String,hidden:Boolean,asChild:Boolean},setup(e,{slots:t}){let r=$(),n=j();return ()=>{let o=r.value;if(e.hidden||!o)return null;let i=o.author||n("comments.unknown"),s={class:`docx-review__author${e.className?` ${e.className}`:""}`,"data-testid":"review-author"};return e.asChild?jsx(Slot,{...s,children:t.default?.()}):jsx("span",{...s,children:t.default?.()??i})}}}),"Author"),Re=A(defineComponent({name:"ReviewTime",props:{className:String,hidden:Boolean,asChild:Boolean},setup(e,{slots:t}){let r=$();return ()=>{let n=r.value;if(e.hidden||!n)return null;let o=n.date;if(!o)return null;let i=new Date(o);if(Number.isNaN(i.getTime()))return null;let s={class:`docx-review__time${e.className?` ${e.className}`:""}`,"data-testid":"review-time",datetime:o};return e.asChild?jsx(Slot,{...s,children:t.default?.()}):jsx("time",{...s,children:t.default?.()??ot.format(i)})}}}),"Time"),ge=A(defineComponent({name:"ReviewSummary",props:{className:String,hidden:Boolean,asChild:Boolean},setup(e,{slots:t}){let r=$(),n=j();return ()=>{let o=r.value;if(e.hidden||!o)return null;let i=o.text,s=o.kind!=="revision"?null:n(st(o.revisionKind,o.item.markDirection)),a=o.kind==="revision"&&o.revisionKind==="replace",u={class:`docx-review__summary${e.className?` ${e.className}`:""}`,"data-testid":"review-summary","data-review-selectable":""};if(e.asChild)return jsx(Slot,{...u,children:t.default?.()});let d=t.default?.();return d?jsx("div",{...u,children:d}):jsx("div",{...u,children:a?jsxs("span",{class:"docx-review__text",children:[n("review.replaced")," ",jsxs("span",{class:"docx-review__removed",children:['"',o.replacedText,'"']})," ",n("review.replacedWith")," ",jsxs("span",{class:"docx-review__added",children:['"',i,'"']})]}):jsxs(Fragment$1,{children:[s?jsx("span",{class:"docx-review__label","data-kind":o.kind==="revision"?o.revisionKind:"revision",children:s}):null,i?jsx("span",{class:"docx-review__text",children:i}):null]})})}}}),"Summary");function Bn(e,t,r,n,o,i,s){return A(defineComponent({name:e,props:{className:String,asChild:Boolean,hidden:Boolean,icon:{type:[Object,String],default:void 0}},setup(a,{slots:u}){let d=O(),l=$(),c=j();return ()=>{let f=l.value,{readOnly:m,review:g}=d.value;if(a.hidden||!f||!s(f))return null;let p=c(n),N=m?c("editingMode.viewingHint"):null,I={type:"button",class:`docx-review__action${a.className?` ${a.className}`:""}`,"data-testid":r,"aria-label":p,title:N??p,disabled:m,onMousedown:L,onClick:y=>{y.stopPropagation(),!m&&i(g,f);}};return a.asChild?jsx(pe,{engineDisabled:m,disabledReason:N,slotProps:I,children:u.default?.()}):jsx("button",{...I,children:a.icon??u.default?.()??F(o)})}}}),t)}var $e=Bn("ReviewAccept","Accept","review-accept","review.accept",Pe,(e,t)=>e.accept(t),e=>e.kind==="revision"&&!e.readOnly),Ke=Bn("ReviewReject","Reject","review-reject","review.reject",En,(e,t)=>e.reject(t),e=>e.kind==="revision"&&!e.readOnly),ct=A(defineComponent({name:"ReviewDelete",props:{className:String,asChild:Boolean,hidden:Boolean,icon:{type:[Object,String],default:void 0}},setup(e,{slots:t}){let r=O(),n=$(),{t:o}=useTranslation();return ()=>{let i=n.value,{readOnly:s,review:a}=r.value;if(e.hidden||!i||i.kind==="custom"||i.kind==="revision"&&i.readOnly)return null;let u=i.kind==="comment"?o("review.deleteComment"):o("review.discardChange"),d=s?o("editingMode.viewingHint"):null,l={type:"button",class:`docx-review__action${e.className?` ${e.className}`:""}`,"data-testid":"review-delete","aria-label":u,title:d??u,disabled:s,onMousedown:L,onClick:c=>{c.stopPropagation(),!s&&a.remove(i);}};return e.asChild?jsx(pe,{engineDisabled:s,disabledReason:d,slotProps:l,children:t.default?.()}):jsx("button",{...l,children:e.icon??t.default?.()??F(kn)})}}}),"Delete"),Dt=A(defineComponent({name:"ReviewReplies",props:{className:String,hidden:Boolean},setup(e){let t=O(),r=$();return ()=>{let n=r.value;if(e.hidden||!n||n.kind==="custom")return null;let i=(t.value.byId.get(n.id)??n).replyIds.map(s=>t.value.byId.get(s)).filter(s=>s!==void 0);return i.length===0?null:jsx("ol",{class:`docx-review__replies${e.className?` ${e.className}`:""}`,children:i.map(s=>jsx(at,{entry:s,children:jsxs("li",{class:"docx-review__reply","data-testid":"review-reply",children:[jsxs("div",{class:"docx-review__head",children:[jsx(ye,{}),jsxs("div",{class:"docx-review__meta",children:[jsx(we,{}),jsx(Re,{})]}),jsx("div",{class:"docx-review__actions",children:jsx(ct,{})})]}),jsx(ge,{})]})},s.key))})}}}),"Replies"),qn=defineComponent({name:"ReviewCardPreset",setup(e,{slots:t}){let r=$(),n=computed(()=>pn(t.default?.()));return ()=>{let o=r.value;if(!o)return null;let i=(a,u)=>a in n.value?n.value[a]:u;if(o.kind==="custom"&&o.item.kind==="custom"){let a=o.item;return jsxs(Fragment$1,{children:[jsxs("div",{class:"docx-review__head",children:[i("Avatar",null),jsx("div",{class:"docx-review__meta",children:i("Author",jsx("span",{class:"docx-review__author","data-testid":"review-custom-title",children:a.title}))})]}),i("Summary",a.detail?jsx("div",{class:"docx-review__summary","data-testid":"review-summary","data-review-selectable":"",children:jsx("span",{class:"docx-review__text",children:a.detail})}):null),n.value.__extra]})}let s=o.kind==="revision"&&!o.readOnly;return jsxs(Fragment$1,{children:[jsxs("div",{class:"docx-review__head",children:[i("Avatar",jsx(ye,{})),jsxs("div",{class:"docx-review__meta",children:[i("Author",jsx(we,{})),i("Time",jsx(Re,{}))]}),s||o.kind==="comment"?jsxs("div",{class:"docx-review__actions",children:[i("Accept",jsx($e,{})),i("Reject",jsx(Ke,{})),i("Resolve",jsx(Ot,{})),i("Reopen",jsx(_t,{})),i("Delete",jsx(ct,{}))]}):null]}),i("Summary",jsx(ge,{})),i("Replies",jsx(Dt,{})),i("Reply",jsx(Mt,{})),n.value.__extra]})}}}),He=A(defineComponent({name:"ReviewCard",props:{className:String,hidden:Boolean,asChild:Boolean},setup(e,{slots:t}){let r=O(),n=$(),o=Me("card"),i=j(),s=null,a=d=>{s=d.el instanceof HTMLDetailsElement?d.el:s;},u=d=>{s?.open&&d.target instanceof Node&&!s.contains(d.target)&&(r.value.setExpandedResolvedKey(null),r.value.review.setActive(null),s.open=false);};return onMounted(()=>document.addEventListener("pointerdown",u,true)),onBeforeUnmount(()=>document.removeEventListener("pointerdown",u,true)),()=>{let d=n.value;if(e.hidden||!d)return null;let{review:l,authorSlots:c,authorInfo:f,expandedResolvedKey:m,setExpandedResolvedKey:g}=r.value,p=c.get(d.author)??0,N=!e.asChild&&d.kind==="comment"&&d.resolved,I={class:`docx-review__card${e.className?` ${e.className}`:""}`,"data-testid":"review-card",...N?{}:{"aria-labelledby":`${o}-author ${o}-summary`},"data-kind":d.kind==="revision"?d.revisionKind??"revision":d.kind,...d.author?{"data-review-author":d.author,"data-review-author-slot":ve(f.get(d.author),p)}:{},...d.kind==="custom"&&d.item.kind==="custom"?{"data-node-name":d.item.name}:{},...d.isActive?{"data-active":""}:{},...d.kind==="comment"&&d.resolved?{"data-resolved":""}:{},...N?{"data-resolved-miniature":""}:{},style:se(d.author,f.get(d.author),p),...N?{}:{tabIndex:0,role:"button"},id:o,...N?{}:{onMousedown:y=>{y.target?.closest("[data-review-selectable]")||y.currentTarget.focus({preventScroll:true});},onClick:y=>{y.target?.closest("button, input, textarea, .docx-review__reply-box, [data-review-selectable]")||d.isActive||l.setActive(d.key);},onKeydown:y=>{y.target===y.currentTarget&&(y.key!=="Enter"&&y.key!==" "||(y.preventDefault(),l.setActive(d.key)));}}};return e.asChild?jsx(Slot,{...I,children:t.default?.()}):N?h("details",{...I,open:m===d.key,onVnodeMounted:a,onVnodeUpdated:a,onVnodeBeforeUnmount:()=>{s=null;},onToggle:y=>{let E=y.currentTarget.open;g(E?d.key:null),l.setActive(E?d.key:null);}},[h("summary",{class:"docx-review__resolved-toggle","aria-label":i("review.showResolvedComment")},[h("span",{class:"docx-review__resolved-status"},i("review.resolved")),it()]),h(qn,null,{default:()=>t.default?.()})]):jsx("div",{...I,children:h(qn,null,{default:()=>t.default?.()})})}}}),"Card");var $t=A(defineComponent({name:"ReviewList",props:{stack:{type:Boolean,default:true},positions:{type:Object,default:void 0},collapsed:{type:Object,default:void 0},scale:{type:Number,default:1},offset:{type:Number,default:0},window:{type:Object,default:null},className:String,hidden:Boolean},setup(e,{slots:t}){let r=O();return ()=>{if(e.hidden)return null;let{review:n,cardClassName:o}=r.value,i=t.default?.()??[],s=t.item,a=s?null:Ee(i,"list"),u=Oe(n.items),d=n.items.filter(l=>!Ae(l,u));return d.length===0?s?null:a?.parts.Empty??jsx(ut,{}):h("div",{class:`docx-review__list${e.className?` ${e.className}`:""}`},d.map(l=>{let c=e.stack?e.positions?.get(l.key)??l.anchorY:l.anchorY,f=c==null?null:e.offset+c*e.scale;if(f!==null&&e.window&&(f<e.window.top||f>e.window.bottom))return null;let m=f===null?{}:{position:"absolute",top:`${f}px`};return h(rt,{key:l.key,entry:l,measureKey:l.key,collapsed:e.collapsed?.has(l.key),style:m},()=>s?s({item:l}):a?.parts.Card?et(a.parts.Card,o):h(He,o?{className:o}:{},()=>a?.rest))}))}}}),"List"),Kt=A(defineComponent({name:"ReviewMarkers",props:{scale:{type:Number,default:1},offset:{type:Number,default:0},window:{type:Object,default:null},className:String,hidden:Boolean,icon:{type:[Object,Function],default:void 0}},setup(e){let t=O(),r=j(),n=computed(()=>{let{review:o}=t.value,i=Oe(o.items),s=o.items.filter(d=>!Ae(d,i)),a=new Map,u=Number.NEGATIVE_INFINITY;for(let d of s){if(d.anchorY===null)continue;let l=Math.max(e.offset+d.anchorY*e.scale,u);a.set(d.key,l),u=l+mn;}return {roots:s,stackedTops:a}});return ()=>{if(e.hidden)return null;let{review:o,authorSlots:i,authorInfo:s,setExpandedResolvedKey:a}=t.value,{roots:u,stackedTops:d}=n.value;return jsx("div",{class:`docx-review__markers${e.className?` ${e.className}`:""}`,children:u.map(l=>{let c=d.get(l.key);return c===void 0||e.window&&(c<e.window.top||c>e.window.bottom)?null:jsx("button",{type:"button",class:"docx-review__marker","data-testid":"review-marker","data-kind":l.kind==="revision"?l.revisionKind:l.kind,...l.author?{"data-review-author":l.author,"data-review-author-slot":ve(s.get(l.author),i.get(l.author)??0)}:{},style:{position:"absolute",top:`${c}px`,...l.author?{"--doc-review-author-current":Tt(s.get(l.author),i.get(l.author)??0)}:{}},title:l.author?`${l.author}: ${l.text}`:l.text,"aria-label":`${r("review.showPane")}: ${l.author?`${l.author}. `:""}${l.text}`,onMousedown:L,onClick:()=>{l.kind==="comment"&&l.resolved&&a(l.key),o.setPaneOpen(true),o.setActive(l.key);},children:(typeof e.icon=="function"?e.icon(l):e.icon)??(l.kind==="comment"&&l.resolved?it():F(Tn(l)))},l.key)})})}}}),"Markers"),Ht=A(defineComponent({name:"ReviewAddComment",props:{top:{type:Number,default:null},drafting:{type:Boolean,default:false},className:String,hidden:Boolean},setup(e,{slots:t}){let r=O(),n=j();return ()=>{let{beginDraft:o,composeTop:i,readOnly:s}=r.value;if(e.hidden||e.drafting||i===null||s)return null;let a={type:"button",class:`docx-review__add${e.className?` ${e.className}`:""}`,"data-testid":"review-add-comment",style:{position:"absolute",top:`${i}px`},"aria-label":n("common.comment"),title:n("common.comment"),onMousedown:L,onClick:o},u=t.default?.();return u?.length?h(Slot,a,()=>u):h("button",a,F(In))}}}),"AddComment"),hr=defineComponent({name:"BalloonTime",props:{raw:{type:String,required:true}},setup(e){return ()=>{let t=new Date(e.raw);return Number.isNaN(t.getTime())?null:jsx("time",{class:"docx-review__time",datetime:e.raw,children:ot.format(t)})}}}),qt=A(defineComponent({name:"ReviewBalloon",props:{className:String,hidden:Boolean},setup(e){let t=getCurrentInstance(),r=O(),n=j(),o=ref(null),i=ref(false),s=ref(false);watch(o,l=>{i.value=l!==null;});let a;onMounted(()=>{let l=getCurrentInstance()?.proxy?.$el,c=l?.closest(".docx-review"),f=c?.closest(".docx-editor__scroll-container")??c?.offsetParent;if(!l||!c||!f)return;let m=(p,N)=>{let I=c.getBoundingClientRect(),y=p.getBoundingClientRect(),E=p.ownerDocument.defaultView?.innerHeight??1/0,w=Number(p.dataset.start),x=Number(p.dataset.end);o.value={revisionId:p.dataset.revisionId,author:p.dataset.reviewAuthor??"",...p.dataset.revisionDate!==void 0?{date:p.dataset.revisionDate}:{},...p.dataset.revisionKind!==void 0?{kind:p.dataset.revisionKind}:{},structuralSite:N,...p.dataset.paragraphId!==void 0?{paragraphId:p.dataset.paragraphId}:{},...Number.isFinite(w)?{start:w}:{},...Number.isFinite(x)?{end:x}:{},left:y.left-I.left,top:y.top-I.top,bottom:y.bottom-I.top,above:y.bottom+220>E},t?.proxy?.$forceUpdate();},g=p=>{let N=p.target;if(!(N instanceof Element)||l.contains(N))return;let I=N.closest("[data-revision-id]");if(I instanceof HTMLElement&&f.contains(I)){let y=I.classList.contains("docx-table-row--revision");if(I.dataset.revisionKind==="format"||y){m(I,y);return}}i.value&&(o.value=null,t?.proxy?.$forceUpdate());};f.addEventListener("pointerdown",g,true),f.addEventListener("mousedown",g,true),a=()=>{f.removeEventListener("pointerdown",g,true),f.removeEventListener("mousedown",g,true);};}),onUnmounted(()=>a?.());let u=computed(()=>{let l=o.value;if(!l)return null;let{allItems:c}=r.value,f=null,m=false,g=null,p=false,N=null,I=false;for(let y of c)if(!(y.kind!=="revision"||y.item.kind!=="revision")){for(let E of y.item.addresses)if(E.id===l.revisionId){if(E.author===l.author){if(E.date===l.date)return y;f===null?f=y:f!==y&&(m=true);}g===null?g=y:g!==y&&(p=true);}if(l.paragraphId!==void 0&&l.start!==void 0&&l.end!==void 0&&(y.revisionKind==="format"||y.revisionKind==="structural")){for(let E of y.item.ranges)if(E.start.paragraphId===l.paragraphId&&E.start.offset<l.end&&E.end.offset>l.start){N===null?N=y:N!==y&&(I=true);break}}}return f!==null&&!m?f:g!==null&&!p?g:N!==null&&!I?N:null}),d=computed(()=>{let l=u.value;return l&&(l.revisionKind==="format"||l.revisionKind==="structural")?l:null});return watch(d,l=>{if(l){s.value=true;return}s.value&&(s.value=false,o.value=null);}),()=>{if(e.hidden)return null;let{review:l,authorSlots:c,authorInfo:f}=r.value,m=o.value,g=m?.kind==="format"?"format":"structural",p=d.value,N=m===null?null:h("div",{class:"docx-review__balloon","data-testid":"review-balloon",style:{left:`${m.left}px`,top:`${m.above?m.top-6:m.bottom+6}px`,transform:m.above?"translateY(-100%)":void 0},onMousedown:L},p?h(at,{entry:p},()=>h("div",{class:"docx-review__card","data-testid":"review-balloon-card","data-kind":p.revisionKind??"revision",...p.author?{"data-review-author":p.author,"data-review-author-slot":ve(f.get(p.author),c.get(p.author)??0)}:{},style:se(p.author,f.get(p.author),c.get(p.author)??0),onClick:()=>l.setActive(p.key)},[h("div",{class:"docx-review__head"},[h(ye),h("div",{class:"docx-review__meta"},[h(we),h(Re)]),p.kind==="revision"&&!p.readOnly?h("div",{class:"docx-review__actions"},[h($e),h(Ke)]):null]),h(ge)])):h("div",{class:"docx-review__card","data-testid":"review-balloon-card","data-kind":g,...m.author?{"data-review-author":m.author,"data-review-author-slot":ve(f.get(m.author),c.get(m.author)??0)}:{},style:se(m.author,f.get(m.author),c.get(m.author)??0)},[h("div",{class:"docx-review__head"},[h("span",{class:"docx-review__avatar","aria-hidden":true},vn(m.author)),h("div",{class:"docx-review__meta"},[h("span",{class:"docx-review__author"},m.author||n("comments.unknown")),m.date?h(hr,{raw:m.date}):null])]),h("div",{class:"docx-review__summary"},[h("span",{class:"docx-review__label","data-kind":g},n(st(g)))])]));return h("div",{class:`docx-review__balloon-root${e.className?` ${e.className}`:""}`},N===null?void 0:[N])}}}),"Balloon");function Be(e,t,r){if(!(e in r))return t;let n=r[e];return !isVNode(n)||!isVNode(t)?n:cloneVNode(n,mergeProps(t.props??{},n.props??{}))}var Pr=defineComponent({name:"ReviewDraftMount",props:{top:{type:Number,required:true},left:{type:Number,default:null}},setup(e){return ()=>h(Pt,{top:e.top,left:e.left})}});function Mr(e,t){return {items:t,activeKey:e.activeKey.value,setActive:e.setActive,accept:e.accept,reject:e.reject,resolve:e.resolve,reopen:e.reopen,commentResolutionDisabledReason:e.commentResolutionDisabledReason.value,remove:e.remove,reply:e.reply,selectionAnchorY:e.selectionAnchorY.value,comment:e.comment,paneOpen:e.paneOpen.value,setPaneOpen:e.setPaneOpen,ready:e.ready.value}}var Dr=defineComponent({name:"DocxEditorReview",props:{className:String,asChild:Boolean,hidden:Boolean,t:{type:Function,default:void 0},card:{type:Object,default:void 0},furniture:{type:[Object,Array],default:void 0},preset:{type:Boolean,default:true},stack:{type:Boolean,default:true},gap:{type:Number,default:8},filter:{type:Function,default:void 0},structural:{type:Boolean,default:false},formatting:{type:Boolean,default:false}},setup(e,{slots:t}){let r=getCurrentInstance(),n=useDocxEditor(),o=useEditorState(rn),i=useEditorState(ke),s=fe(),a=computed(()=>{let v=[];return e.structural||v.push("structural"),e.formatting||v.push("format"),v.length>0?v:void 0}),u=computed(()=>a.value?{excludeRevisionKinds:a.value}:void 0);watch([n,a],()=>{n.value?.setReviewActivationExclusions(a.value??null);},{immediate:true}),onUnmounted(()=>{n.value?.setReviewActivationExclusions(null);}),tn(s);let d=Ct(fn,s),l=Ct(()=>u.value,s),{t:c}=useTranslation(),f=(v,R)=>e.t?.(v,R)??c(v,R),m=shallowRef(null),g=inject(ReviewRailContext,shallowRef({mounted:0,register:()=>()=>{},registerCommentDraft:()=>()=>{},requestCommentDraft:()=>false})),p=ref(false),N,I=()=>{if(!p.value||e.hidden){N?.(),N=void 0;return}N??=g.value.register();};onMounted(()=>{p.value=true,I();}),watch(()=>e.hidden,I);let y=computed(()=>l.paneOpen.value),E=useReviewGutter(),w=ref(null),x=computed(()=>y.value&&(w.value??E.value.inlineEnd)>0&&(w.value??E.value.inlineEnd)<REVIEW_PANE_GUTTER),P=computed(()=>y.value&&!x.value),K=computed(()=>e.filter?l.items.value.filter(v=>e.filter(v)):l.items.value),J=ref(null);watch(K,v=>{let R=J.value;R!==null&&!v.some(h=>h.key===R&&h.kind==="comment"&&h.resolved)&&(J.value=null);},{flush:"sync"});let Y=computed(()=>n.value?.getConfiguredAuthor()??null),ne=computed(()=>{let v=new Map;for(let R of K.value)R.author&&!v.has(R.author)&&v.set(R.author,v.size);return Y.value&&!v.has(Y.value)&&v.set(Y.value,v.size),v}),pt=useReviewAuthors(),yt=new Map,Fe=computed(()=>Cn(pt.value,K.value,ne.value,n.value,yt)),Ne=computed(()=>{let v=new Map;for(let R of d.items.value)v.set(R.id,R);return v}),Ye=ref(new Map),no=Nn((v,R)=>{if(R<=0||Ye.value.get(v)===R)return;let h=new Map(Ye.value);h.set(v,R),Ye.value=h;}),M=ref(an),Ce;watch([n,K,o,()=>e.hidden,m,x],()=>{Ce?.(),Ce=void 0;let v=m.value,R=n.value;if(!R||!v||o.value||e.hidden)return;let h=v.offsetParent,k=h?.querySelector(".docx-paginated-surface")??null,b=()=>{if(h){let me=Number.parseFloat(getComputedStyle(h).getPropertyValue("--docx-review-gutter"));w.value=Number.isFinite(me)?me:null;}else w.value=null;let V=k&&h?k.getBoundingClientRect():null,ee=V&&h?h.getBoundingClientRect():null,ue=V&&ee&&h?V.right-ee.left-h.clientLeft+h.scrollLeft+sn:null,re={scale:R.getRenderScale(),top:V&&ee&&h?V.top-ee.top-h.clientTop+h.scrollTop:0,left:ue,compactCardLeft:ue===null||!h?null:h.scrollLeft+h.clientWidth-ue-Te-ln},ce=M.value;(ce.scale!==re.scale||ce.top!==re.top||ce.left!==re.left||ce.compactCardLeft!==re.compactCardLeft)&&(M.value=re);};b();let T=new ResizeObserver(b);h&&T.observe(h),k&&T.observe(k);let U=h&&typeof MutationObserver<"u"?new MutationObserver(b):null;if(U?.observe(h,{attributes:true,attributeFilter:["style"]}),!x.value||!h){Ce=()=>{U?.disconnect(),T.disconnect();};return}let B=0,D=()=>{B===0&&(B=requestAnimationFrame(()=>{B=0,b();}));};h.addEventListener("scroll",D,{passive:true}),Ce=()=>{B!==0&&cancelAnimationFrame(B),h.removeEventListener("scroll",D),U?.disconnect(),T.disconnect();};},{flush:"post"}),onUnmounted(()=>Ce?.());let Ge;watch([n,o,()=>e.hidden,m],()=>{Ge?.(),Ge=void 0;let v=m.value,R=n.value;if(!R||!v||o.value||e.hidden)return;let h=k=>{let b=k.target;if(!(b instanceof Node)||v.contains(b))return;let T=v.offsetParent;!T||!T.contains(b)||T.querySelector(".docx-paginated-surface")?.contains(b)||R.setActiveReviewItem(null);};document.addEventListener("mousedown",h,true),Ge=()=>document.removeEventListener("mousedown",h,true);},{flush:"post"}),onUnmounted(()=>Ge?.());let de=ref(null),Ze;watch([n,o,()=>e.hidden,m],()=>{Ze?.(),Ze=void 0;let v=m.value,R=v?.offsetParent;if(!R||o.value||e.hidden)return;let h=0,k=()=>{h=0;let B=R.scrollTop-tt,D=R.scrollTop+R.clientHeight+tt,V=de.value;de.value=V&&V.top===B&&V.bottom===D?V:{top:B,bottom:D};},b=0,T=()=>{h===0&&(h=requestAnimationFrame(k)),v?.setAttribute("data-scrolling",""),window.clearTimeout(b),b=window.setTimeout(()=>v?.removeAttribute("data-scrolling"),150);};k(),R.addEventListener("scroll",T,{passive:true});let U=new ResizeObserver(T);U.observe(R),Ze=()=>{h!==0&&cancelAnimationFrame(h),window.clearTimeout(b),R.removeEventListener("scroll",T),U.disconnect();};},{flush:"post"}),onUnmounted(()=>Ze?.());let Q=ref(null),We=shallowRef(null),be=()=>{let v=We.value;v&&v.editor.releaseSelection(v.pin),We.value=null,Q.value=null;};watch(()=>n.value,(v,R)=>{R&&R!==v&&We.value?.editor===R&&be();});let Ft=()=>{let v=n.value;if(!v||i.value)return;let R=v.getSelectionPlacement()?.anchorY??null;if(R===null)return;be();let h=v.retainSelection();h&&(We.value={editor:v,pin:h},l.setPaneOpen(true),Q.value=R,r?.proxy?.$forceUpdate());},Ie,Yt=()=>{if(!p.value||e.hidden){Ie?.(),Ie=void 0;return}Ie??=g.value.registerCommentDraft(Ft);};onMounted(Yt),watch(()=>e.hidden,Yt);let oo=()=>{be(),n.value?.focus(),r?.proxy?.$forceUpdate();};watch(y,v=>{v||Q.value===null||be();}),onBeforeUnmount(()=>{p.value=false,N?.(),N=void 0,Ie?.(),Ie=void 0,be();});let wt=computed(()=>Q.value??l.selectionAnchorY.value),oe=computed(()=>{let v=Oe(K.value);return K.value.filter(R=>!Ae(R,v))}),ro=computed(()=>{let v=Q.value;if(v===null)return oe.value;let R=oe.value.findIndex(k=>k.anchorY!==null&&k.anchorY>v),h={key:te,anchorY:v};return R===-1?[...oe.value,h]:[...oe.value.slice(0,R),h,...oe.value.slice(R)]}),ao=computed(()=>{let v=new Map(Ye.value);for(let R of oe.value){if(v.has(R.key))continue;let h=R.text.length+(R.kind==="revision"?R.replacedText?.length??0:0),k=Math.min(6,Math.max(1,Math.ceil(h/36)));v.set(R.key,64+k*20);}return v}),Rt=computed(()=>{let v=M.value.scale,R=new Map,h=new Set,k=Number.NEGATIVE_INFINITY;for(let b of ro.value){let T=b.anchorY===null?Number.isFinite(k)?k:0:Math.max(b.anchorY,k);R.set(b.key,T);let U=b.anchorY===null?0:(T-b.anchorY)*v,B="isActive"in b&&b.isActive,D=U>cn&&!B&&b.key!==te;D&&h.add(b.key);let V=D?un:ao.value.get(b.key)??dn;k=T+(V+e.gap)/v;}return {stacked:R,collapsedKeys:h}}),Se=computed(()=>wt.value===null?null:M.value.top+(x.value?wt.value:Rt.value.stacked.get(te)??wt.value)*M.value.scale),io=computed(()=>(l.commentResolutionDisabledReason.value,l.selectionAnchorY.value,l.paneOpen.value,l.items.value.length,Mr(l,K.value))),gt=()=>{let v=Y.value,R=v?ne.value.get(v)??0:0;return {t:e.t,cardClassName:e.card?.className,readOnly:i.value,composeTop:Se.value,review:io.value,allItems:d.items.value,authorSlots:ne.value,authorInfo:Fe.value,draftAuthor:v,draftAuthorInfo:v?Fe.value.get(v):void 0,draftAuthorSlot:R,byId:Ne.value,measure:no,beginDraft:Ft,endDraft:oo,expandedResolvedKey:J.value,setExpandedResolvedKey:h=>{J.value=h;}}},ht=shallowRef(gt());return watchEffect(()=>{ht.value=gt();}),watch(()=>s.value,()=>{ht.value=gt(),r?.proxy?.$forceUpdate();},{flush:"sync"}),provide(St,ht),()=>{if(e.hidden||o.value)return null;s.value,d.items.value,Q.value,K.value.length,l.selectionAnchorY.value,l.paneOpen.value,l.commentResolutionDisabledReason.value,Se.value;let v=z=>{m.value=z.el instanceof HTMLElement?z.el:null;},R={onVnodeMounted:v,onVnodeUpdated:v,onVnodeBeforeUnmount:()=>{m.value=null;},class:`docx-review${e.className?` ${e.className}`:""}`,"data-testid":"review-rail","data-count":K.value.length,"data-open":P.value?"":void 0,"data-compact":x.value?"":void 0,role:"complementary","aria-label":f("review.ariaLabel"),onMousedown:L,style:M.value.left===null?void 0:{left:`${M.value.left}px`,right:"auto"}},h$1=t.default?.()??[],k=e.asChild&&h$1.length===1&&isVNode(h$1[0])?h$1[0]:null,{parts:b,rest:T}=Ee(k?[]:h$1,"root"),U={stack:e.stack,positions:Rt.value.stacked,collapsed:Rt.value.collapsedKeys,scale:M.value.scale,offset:M.value.top,window:de.value},B=h(Kt,{scale:M.value.scale,offset:M.value.top,window:de.value}),D=x.value?oe.value.find(z=>z.key===l.activeKey.value)??null:null,V=D===null?null:D.anchorY!==null?M.value.top+D.anchorY*M.value.scale:de.value!==null?de.value.top+tt+24:null,ee=Ee(T,"list"),ue=D&&t.item?t.item({item:D}):ee.parts.Card?et(ee.parts.Card,e.card?.className):e.preset?h(He,e.card?.className?{className:e.card.className}:{},()=>ee.rest):null,re=D&&V!==null&&M.value.compactCardLeft!==null&&ue?h(rt,{entry:D,className:"docx-review__slot--compact",testId:"review-compact-card",style:{position:"absolute",top:`${V}px`,left:`${M.value.compactCardLeft}px`,width:`${Te}px`}},()=>ue):null,ce=P.value?e.preset||"List"in b?Be("List",h($t,U,{...T.length>0?{default:()=>T}:{},...t.item?{item:t.item}:{}}),b):T:e.preset||"Markers"in b?[Be("Markers",B,b),re]:T,me=[P.value&&e.furniture!==void 0?h("div",{class:"docx-review__furniture","data-testid":"review-furniture"},[e.furniture]):null,ce,...e.preset||"AddComment"in b?[Be("AddComment",h(Ht,{top:Se.value,drafting:Q.value!==null}),b)]:[],...Q.value===null||Se.value===null||!y.value||!e.preset&&!("Draft"in b)?[]:[Be("Draft",h(Pr,{top:Se.value??0,left:x.value?M.value.compactCardLeft:null}),b)],...e.preset||"Balloon"in b?[Be("Balloon",h(qt),b)]:[]],H=k;if(!H)return h("aside",R,me);let ae=cloneVNode(H,R,true);if(typeof H.type=="string"){let z=Array.isArray(H.children)?H.children:H.children==null?[]:typeof H.children=="string"||typeof H.children=="number"?[H.children]:[];ae.children=[...z,...me],ae.shapeFlag=ae.shapeFlag&-9|16;}else {let z=H.children&&!Array.isArray(H.children)&&typeof H.children=="object"?H.children:{},Gt=z.default;ae.children={...z,default:(...so)=>[...Gt?[Gt(...so)]:[],...me]},ae.shapeFlag=ae.shapeFlag&-25|32;}return ae}}});var Vr=Object.assign(Dr,{List:$t,Empty:ut,Card:He,Avatar:ye,Author:we,Time:Re,Summary:ge,Accept:$e,Reject:Ke,Resolve:Ot,Reopen:_t,Delete:ct,Replies:Dt,Reply:Mt,Markers:Kt,AddComment:Ht,Draft:Pt,Balloon:qt});function je(e){let t=useDocxEditor();return computed(()=>{let r=toValue(e);return r||(t.value?.getCustomNodeDefinitions()??[]).filter(Je)})}var qr=".docx-content-control-boundary";function he(e,t){let{node:r,definition:n,controlId:o}=e,i=o?t?.getReviewItems().find(u=>u.kind==="custom"&&u.item.id===o):void 0;if(i?.kind==="custom"){let u=i.item;return {...r,attrs:u.attrs,text:u.text,...u.data===void 0?{}:{data:u.data},...o?{nodeId:o}:{}}}let s=o?Br(t,o,n):void 0,a=n.fromDocx?n.fromDocx({attrs:r.attrs,text:"",...s===void 0?{}:{data:s}}):r.attrs;return a===null?null:{...r,attrs:a,...s===void 0?{}:{data:s},...o?{nodeId:o}:{}}}function Br(e,t,r){let n=e?.surface;if(!n)return;let o=n.session.part(),i=customNodePayloadsByControl(n.session.currentPackage(),o.name).get(t);if(!i)return;let s=Xe(r.schema,i.data);return s.ok?s.value:void 0}function xe(e,t){let r=e?.closest?.(qr),n=r?.closest(".docx-content-control-chrome"),o=n?.getAttribute("data-tag"),i=o?ze(o):null;if(!r||!i||!o)return null;let s=t.find(a=>a.tagPrefix===i.prefix&&a.name===i.name);return s?{node:{name:i.name,attrs:i.attrs,tag:o,rect:r.getBoundingClientRect()},definition:s,controlId:n?.getAttribute("data-docx-content-control")??null}:null}var jt=".docx-content-control-boundary";function Zr(e){if(!Nt.test(e.tagPrefix)||!Nt.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}?"]`]}var Wr=defineComponent({name:"CustomNodeChrome",props:{nodes:{type:Array,default:void 0},onNodeClick:{type:Function,default:void 0},onNodeHover:{type:Function,default:void 0}},setup(e){let t=useDocxEditor(),r=je(()=>e.nodes),n,o=null,i=null,s=l=>xe(document.elementFromPoint(l.clientX,l.clientY),r.value),a=l=>{let c=l.button===0?s(l):null;o=c?.controlId??null,i=c?.node.tag??null;},u=l=>{let c=o,f=i;if(o=null,i=null,f===null)return;let m=s(l);if(!m||m.node.tag!==f||c!==null&&m.controlId!==c)return;let g=he(m,t.value);g&&(m.definition.onClick?.(g),e.onNodeClick?.(g));},d=l=>{let c=xe(l.target,r.value);if(!c||l.relatedTarget?.closest?.(jt)===l.target.closest(jt))return;let m=he(c,t.value);m&&(c.definition.onHover?.(m),e.onNodeHover?.(m));};return onMounted(()=>{n=watch(r,(l,c,f)=>{let m=document.createElement("style"),g=[];for(let p of l){let N=Zr(p);if(N.length===0)continue;let I=p.chrome?.color,y=I!==void 0&&typeof CSS<"u"&&CSS.supports("color",I)?I:"var(--doc-accent)";g.push(`${N.map(E=>`${E} ${jt}`).join(", ")} {`," pointer-events: auto !important;"," opacity: 1;"," border: none;",` background: color-mix(in srgb, ${y} 12%, transparent);`," border-radius: 6px;"," cursor: default;","}");}m.textContent=g.join(`
|
|
2
|
-
`),document.head.append(m),f(()=>m.remove());},{immediate:true}),document.addEventListener("pointerdown",a,true),document.addEventListener("pointerup",u,true),document.addEventListener("mouseover",d);}),onBeforeUnmount(()=>{n?.(),document.removeEventListener("pointerdown",a,true),document.removeEventListener("pointerup",u,true),document.removeEventListener("mouseover",d);}),()=>null}});function
|
|
1
|
+
import {customNodePayloadsByControl,parseNoteScopeId,findNode,revisionItemsOf,collectReviewItems,paragraphOrderOfPart,locateSites,contentControlPropertiesOf}from'@docx-editor.dev/core/store';import {reviewItemPositionRank}from'@docx-editor.dev/core/layout';import {computed,defineComponent,shallowRef,watchEffect,provide,onBeforeUnmount,h,Fragment,cloneVNode,onMounted,getCurrentInstance,ref,watch,onUnmounted,inject,isVNode,mergeProps,toValue}from'vue';import {Slot,useTranslation,useDocxEditor,useEditorState,ReviewRailContext,useReviewGutter,REVIEW_PANE_GUTTER,useReviewAuthors,useContextMenuTarget,ContextMenuItem}from'@docx-editor.dev/vue';import {jsx,jsxs,Fragment as Fragment$1}from'vue/jsx-runtime';import {partOfNodeId}from'@docx-editor.dev/core/editor';function Zt(e){}var uo=new Set(["__proto__","constructor","prototype"]);function ze(e){if(e.length>64)return null;let t=e.indexOf(":");if(t<=0)return null;let r=e.slice(0,t),n=e.slice(t+1),o=n.indexOf("?"),i=o===-1?n:n.slice(0,o);if(i.length===0)return null;let s=Object.create(null);if(o!==-1)for(let[a,u]of new URLSearchParams(n.slice(o+1))){if(uo.has(a))return null;s[a]=u;}return {prefix:r,name:i,attrs:s}}function Xe(e,t){if(t.length===0)return {ok:false,reason:"malformed",issues:["the node carries no payload"]};if(t.length>262144)return {ok:false,reason:"malformed",issues:[`the payload is ${String(t.length)} characters; the cap is ${String(262144)}`]};let r;try{r=JSON.parse(t);}catch(i){return {ok:false,reason:"malformed",issues:[i instanceof Error?i.message:"the payload is not JSON"]}}let n=xt(r);if(!e)return {ok:true,value:n};let o=e["~standard"].validate(n);return co(o)?{ok:false,reason:"async",issues:["the schema validates asynchronously, which the read path cannot await"]}:o.issues?{ok:false,reason:"invalid",issues:o.issues.map(mo)}:{ok:true,value:o.value}}function co(e){return typeof e.then=="function"}function mo(e){let t=(e.path??[]).map(r=>String(typeof r=="object"?r.key:r)).join(".");return t.length>0?`${t}: ${e.message}`:e.message}var fo=new Set(["__proto__","constructor","prototype"]);function xt(e){if(Array.isArray(e))return e.map(xt);if(e===null||typeof e!="object")return e;let t=Object.create(null);for(let[r,n]of Object.entries(e))fo.has(r)||(t[r]=xt(n));return t}function Je(e){return typeof e=="object"&&e!==null&&typeof e.name=="string"&&typeof e.tagPrefix=="string"}var Nt=/^[A-Za-z0-9_.-]+$/;function po(e){for(let t of e.children)if(!(t.kind==="textValue"||t.localName!=="sdtPr")){for(let r of t.children)if(!(r.kind==="textValue"||r.localName!=="tag")){for(let n of r.attributes)if(n.localName==="val")return n.value}}}function Wt(e){if(e.kind==="textValue")return e.value;let t="";for(let r of e.children)t+=Wt(r);return t}function zt(e,t,r={}){if(t.length===0)return [];let n=new Map;for(let s of t){let a=`${s.tagPrefix}:${s.name}`;if(n.has(a))throw new Error(`recognizeCustomNodes: duplicate definition for ${JSON.stringify(a)}`);n.set(a,s);}let o=[],i=(s,a)=>{if(!(s.kind==="textValue"||a>64)){if(s.kind==="contentControl"){let u=po(s),d=u!==void 0?ze(u):null,l=d?n.get(`${d.prefix}:${d.name}`):void 0;if(d&&l&&u!==void 0){let c=Wt(s),f=yo(l,s.id,r.payloads?.get(s.id),contentControlPropertiesOf(s).dataBinding!==void 0,r.onDiagnostic),m=l.fromDocx?l.fromDocx({attrs:d.attrs,text:c,...f.present?{data:f.value}:{}}):d.attrs;if(m!==null){o.push({name:l.name,attrs:m,text:c,nodeId:s.id,tag:u,...f.present?{data:f.value}:{}});return}}}for(let u of s.children)i(u,a+1);}};return i(e.root,0),o}function yo(e,t,r,n,o){if(!r)return n&&o?.({code:"payload-missing",name:e.name,nodeId:t,issues:["the control binds a store node this document does not hold"]}),{present:false};let i=Xe(e.schema,r.data);return i.ok?{present:true,value:i.value}:(o?.({code:"payload-invalid",name:e.name,nodeId:t,issues:i.issues}),{present:false})}function Jt(e,t){let r=findNode(e,t);return !r||r.kind!=="paragraph"?[]:revisionItemsOf({id:e.id,name:e.name,contentType:e.contentType,root:r})}function No(e,t,r,n){if(t.length===0)return [];let o=zt(e,t,{...r===void 0?{}:{payloads:r},...n===void 0?{}:{onDiagnostic:n}});if(o.length===0)return [];let i=locateSites(e),s=[];for(let a of o){let u=t.find(c=>c.name===a.name&&a.tag.startsWith(`${c.tagPrefix}:`));if(!u)continue;let d=u.reviewCard?u.reviewCard({attrs:a.attrs,text:a.text,...a.data===void 0?{}:{data:a.data}}):null;if(u.reviewCard&&d===null)continue;let l=i.get(a.nodeId);s.push({kind:"custom",id:a.nodeId,name:a.name,tag:a.tag,attrs:a.attrs,text:a.text,...a.data===void 0?{}:{data:a.data},carded:u.reviewCard!==void 0&&d!==null,title:d?.title??"",...d?.detail!==void 0?{detail:d.detail}:{},...d?.icon!==void 0?{icon:d.icon}:{},range:l?{partName:e.name,start:{paragraphId:l.paragraphId,offset:l.start},end:{paragraphId:l.paragraphId,offset:l.end}}:null});}return s}function Qt(e){let t=collectReviewItems(e),r=(e.customNodes??[]).filter(Je);if(r.length===0)return t;let n=[e.storyPart],o=new Set([e.storyPart.name]);for(let u of e.furnitureParts??[])o.has(u.name)||(o.add(u.name),n.push(u));let i=[],s=new Map;for(let u of n){i.push(...No(u,r,e.customNodePayloads,e.reportCustomNodeDiagnostic));let d=s.size;for(let[l,c]of paragraphOrderOfPart(u))s.has(l)||s.set(l,d+c);}return i.length===0?t:[...t,...i].sort((u,d)=>reviewItemPositionRank(u,s)-reviewItemPositionRank(d,s))}function Co(e={}){return Zt(e.licenseKey),{id:"review",review:{displayModes:["all-markup","proposed","original"],collectReviewItems:Qt,revisionItemsOfParagraph:Jt}}}var en=Symbol("proEditorRenderRevision");function tn(e){return provide(en,e),e}function fe(){let e=inject(en,null);if(e)return e;let t=useDocxEditor(),r=shallowRef("none");return watch(()=>t.value,(n,o,i)=>{if(!n){r.value="none";return}let s=n,a=`${s.getReviewRevision()}:${s.getEditingMode()}`;r.value=a;let u=false,d=null,l=()=>{u||d!==null||(d=setTimeout(()=>{if(d=null,u)return;let g=`${s.getReviewRevision()}:${s.getEditingMode()}`;g!==a&&(a=g,r.value=g);},0));},c=s.on("change",l),f=s.on("selectionChange",l),m=s.on("error",l);i(()=>{u=true,d!==null&&clearTimeout(d),c(),f(),m();});},{immediate:true,flush:"sync"}),r}function Qe(e){if(e!==void 0)return typeof e=="function"?e():typeof e=="object"&&e!==null&&"value"in e?e.value:e}function nn(e){return `${e.getReviewRevision()}:${e.getEditingMode()}`}function Oo(e){let t=useDocxEditor(),r=fe();return bt(t,e,r)}function Ct(e,t){let r=useDocxEditor();return bt(r,e,t)}function _o(e,t){return bt(e,t)}function bt(e,t,r){let n=r?null:shallowRef("none"),o=()=>{(r??n)?.value;};r||watch(()=>e.value,(w,x,P)=>{if(!w){n.value="none";return}let K=nn(w);n.value=K;let J=false,Y=null,ne=()=>{J||Y!==null||(Y=setTimeout(()=>{if(Y=null,J)return;let Ne=nn(w);Ne!==K&&(K=Ne,n.value=Ne);},0));},pt=w.on("change",ne),yt=w.on("selectionChange",ne),Fe=w.on("error",ne);P(()=>{J=true,Y!==null&&clearTimeout(Y),pt(),yt(),Fe();});},{immediate:true,flush:"sync"});let i=computed(()=>{o();let w=e.value,x=Qe(t);return w?w.getReviewItems(x).filter(P=>P.item.kind!=="custom"||P.item.carded):[]}),s=computed(()=>i.value.find(w=>w.isActive)?.key??null),a=(w,x)=>{let P=e.value;return P?P.setActiveReviewItem(w,x).ok:false},u=w=>{let x=e.value;return !x||w.kind!=="revision"||w.readOnly?false:x.acceptReviewItem(w.key).ok},d=w=>{let x=e.value;return !x||w.kind!=="revision"||w.readOnly?false:x.rejectReviewItem(w.key).ok},l=w=>{let x=e.value;return !x||w.kind!=="comment"?false:x.setCommentResolved(w.key,true).ok},c=w=>{let x=e.value;return !x||w.kind!=="comment"?false:x.setCommentResolved(w.key,false).ok},f=computed(()=>(o(),e.value?.getEditingMode()==="viewing"?"the document is open for viewing":null)),m=w=>{let x=e.value;return !x||w.kind==="custom"||w.kind==="revision"&&w.readOnly?false:x.deleteReviewItem(w.key).ok},g=(w,x,P)=>x.trim().length===0||!e.value?false:e.value.replyToReviewItem(w.key,x,P).ok,p=computed(()=>{o();let w=e.value;return w?w.getSelectionPlacement()?.anchorY??null:null}),N=(w,x)=>w.trim().length===0||!e.value?false:e.value.addComment(w,x).ok,I=computed(()=>{o();let w=e.value;return w?w.isReviewPaneOpen():true}),y=w=>{let x=e.value;!x||x.isReviewPaneOpen()===w||x.exec({type:"toggleReviewPane"});},E=computed(()=>{o();let w=e.value;if(w===null)return false;let x=w.snapshot();return !x.isLoading&&x.parseError===null});return {items:i,activeKey:s,setActive:a,accept:u,reject:d,resolve:l,reopen:c,commentResolutionDisabledReason:f,remove:m,reply:g,selectionAnchorY:p,comment:N,paneOpen:I,setPaneOpen:y,ready:E}}function Po(e,t,r={}){return computed(()=>{let n=Qe(e)??[],o=Qe(t)??new Map,i=Qe(r)??{},s=i.gap??8,a=i.scale??1,u=i.defaultHeight??0,d=new Map,l=Number.NEGATIVE_INFINITY;for(let c of n){let f=c.anchorY===null?Number.isFinite(l)?l:0:Math.max(c.anchorY,l);d.set(c.key,f),l=f+((o.get(c.key)??u)+s)/a;}return d})}var Lo=new Set(["List","Markers","AddComment","Draft","Balloon"]),$o=new Set(["Card","Empty"]);function Ko(e){return isVNode(e)}function Ee(e,t){let r=t==="root"?Lo:$o,n={},o=[],i=s=>{for(let a of s){if(!Ko(a))continue;if(a.type===Fragment){let d=Array.isArray(a.children)?a.children:[];i(d);continue}let u=a.type.docxReviewPart;u&&r.has(u)?n[u]=a:o.push(a);}};return i(e),{parts:n,rest:o}}function et(e,t){if(!t)return e;let r=e.props.class;return cloneVNode(e,{class:`${t}${r?` ${r}`:""}`})}var rn=e=>e.isLoading||e.parseError!==null||e.pageSetup==null,ke=e=>e.editingMode==="viewing",an={scale:96/72,top:0,left:null,compactCardLeft:null},sn=16,Te=300,ln=12,te="\0compose",tt=600,nt=8,dn=72,un=64,cn=480,mn=30,fn=Object.freeze({placement:false});function Ae(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 Oe(e){return new Set(e.map(t=>t.id))}function L(e){let t=e.target?.tagName;t==="INPUT"||t==="SELECT"||t==="TEXTAREA"||e.preventDefault();}function vn(e){let t=e.trim().split(/\s+/).filter(Boolean);return t.length===0?"?":t.slice(0,2).map(r=>r[0].toUpperCase()).join("")}var ot=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function pn(e){let t={},r=[],n=o=>{if(!o)return;let i=Array.isArray(o)?o:[o];for(let s of i){if(!isVNode(s))continue;if(s.type===Fragment){n(s.children);continue}let a=s.type.docxReviewPart;a?t[a]=s:r.push(s);}};return n(e),r.length>0&&(t.__extra=r),t}function A(e,t){return e.docxReviewPart=t,e}var St=Symbol("ReviewContext"),Et=Symbol("ReviewItemContext"),Yo={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},Go={t:void 0,cardClassName:void 0,readOnly:false,composeTop:null,review:Yo,allItems:[],authorSlots:new Map,authorInfo:new Map,draftAuthor:null,draftAuthorInfo:void 0,draftAuthorSlot:0,byId:new Map,measure:()=>{},beginDraft:()=>{},endDraft:()=>{},expandedResolvedKey:null,setExpandedResolvedKey:()=>{}};function O(){return inject(St,computed(()=>Go))}var Zo=computed(()=>null);function $(){return inject(Et,Zo)}function Wo(e){let t=O();return computed(()=>{let r=toValue(e);return r===void 0?void 0:t.value.authorInfo.get(r)})}function j(){let e=O(),{t}=useTranslation();return r=>e.value.t?.(r)??t(r)}function zo(e){return [e.key,e.isActive?"active":"idle",e.readOnly?"readonly":"editable",e.kind==="comment"&&e.resolved?"resolved":"open",e.text,...e.replyIds].join("\0")}var rt=defineComponent({name:"ReviewItemScope",props:{entry:{type:Object,required:true},measureKey:String,collapsed:Boolean,className:String,testId:String,style:{type:Object,default:void 0}},setup(e,{slots:t}){let r=O(),n=shallowRef(e.entry);watchEffect(()=>{let a=r.value.byId.get(e.entry.id)??e.entry;n.value={...a,replyIds:[...a.replyIds]};}),provide(Et,n);let o=null,i=null,s=a=>{let u=a instanceof HTMLElement?a:null,d=u&&e.measureKey?e.measureKey:null;o===u&&i===d||(i&&r.value.measure(null,i),o=u,i=d,o&&i&&r.value.measure(o,i));};return onBeforeUnmount(()=>{s(null);}),()=>h("div",{onVnodeMounted:a=>{s(a.el instanceof Element?a.el:null);},onVnodeUpdated:a=>{s(a.el instanceof Element?a.el:null);},onVnodeBeforeUnmount:()=>{s(null);},class:`docx-review__slot${e.className?` ${e.className}`:""}`,...e.testId?{"data-testid":e.testId}:{},style:e.style,...e.collapsed?{"data-collapsed":""}:{}},[h(Fragment,{key:zo(n.value)},t.default?.())])}}),at=defineComponent({name:"ReviewReplyScope",props:{entry:{type:Object,required:true}},setup(e,{slots:t}){let r=O(),n=shallowRef(e.entry);return watchEffect(()=>{let o=r.value.byId.get(e.entry.id)??e.entry;n.value={...o,replyIds:[...o.replyIds]};}),provide(Et,n),()=>t.default?.()}});function Nn(e){let t=ref(new WeakMap),r=ref(new Map),n=ref(null),o=(i,s)=>{let a=r.value.get(s);if(!i){a&&(n.value?.unobserve(a),t.value.delete(a),r.value.delete(s));return}typeof ResizeObserver>"u"||(e(s,i.offsetHeight),n.value??=new ResizeObserver(u=>{for(let d of u){let l=t.value.get(d.target);l&&e(l,d.target.offsetHeight);}}),!(a===i&&t.value.get(i)===s)&&(a&&(n.value.unobserve(a),t.value.delete(a)),t.value.set(i,s),r.value.set(s,i),n.value.observe(i)));};return onUnmounted(()=>{n.value?.disconnect(),r.value.clear();}),o}function Tt(e,t){return e?.color??`var(--doc-review-author-${t%nt})`}function se(e,t,r){return e?{"--doc-review-author-current":Tt(t,r)}:{}}function ve(e,t){return (e?.slot??t)%nt}function Cn(e,t,r,n,o){let i=new Map;for(let a of e)i.set(a.author,a);let s=[...t.map(a=>a.author),n?.getConfiguredAuthor()];for(let a of s){if(!a||i.has(a))continue;let u=r.get(a)??0,d=n?.getReviewAuthorStyle(a),l=d?.color??`var(--doc-review-author-${u%nt})`,c=o.get(a),f=c?.slot===u&&c.color===l&&c.style===d?c:{author:a,slot:u,color:l,...d?{style:d}:{}};o.set(a,f),i.set(a,f);}return i}var F=e=>h("svg",{viewBox:"0 -960 960 960",width:16,height:16,ariaHidden:true,focusable:false},[h("path",{d:e,fill:"currentColor"})]),In="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",bn="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",Jo="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",Pe="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z",it=()=>h("span",{class:"docx-review__resolved-icon"},[h("span",{class:"docx-review__resolved-comment"},[F(Jo)]),h("span",{class:"docx-review__resolved-tick"},[F(Pe)])]),Sn="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",En="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",kn="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",Qo="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",er="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",tr="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",nr="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 Tn(e){if(e.kind==="comment")return bn;if(e.kind==="custom")return e.item.icon??nr;switch(e.revisionKind){case "insert":case "moveTo":return Qo;case "delete":case "moveFrom":return er;case "format":return tr;default:return bn}}function st(e,t){if(e==="paragraphMark")return t==="delete"?"revisions.paragraphMarkDeleted":t==="moveFrom"?"revisions.paragraphMarkMovedFrom":t==="moveTo"?"revisions.paragraphMarkMovedTo":"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 ar(e,t){return typeof t!="function"?e:typeof e!="function"?t:r=>{e(r),r.defaultPrevented||t(r);}}function ir(e,t){let r=mergeProps(e,t);for(let n of Object.keys(e))/^on[A-Z]/.test(n)?r[n]=ar(t[n],e[n]):n==="class"?r[n]=[e[n],t[n]].filter(Boolean).join(" "):n==="style"&&(r[n]={...e[n],...t[n]});return r}function Pn(e){return e==="Enter"||e===" "}function sr(e){return Pn(e.key)?(e.preventDefault(),e.stopPropagation(),true):false}function On(e){return e==="button"}function _n(e,t){return e==="a"||t.href!=null}var pe=defineComponent({name:"ReviewActionSlot",props:{engineDisabled:{type:Boolean,required:true},disabledReason:{type:String,default:null},slotProps:{type:Object,required:true}},setup(e,{slots:t}){return ()=>{let r=t.default?.()??[];if(r.length!==1)return null;let n=r[0];if(!n||typeof n!="object")return null;let o=n.props??{},i=ir(e.slotProps,o);if(!e.engineDisabled){if(!On(n.type)){let s={onClick:a=>{typeof o.onClick=="function"&&o.onClick(a),!a.defaultPrevented&&typeof e.slotProps.onClick=="function"&&e.slotProps.onClick(a),_n(n.type,o)&&a.preventDefault();},onKeydown:a=>{typeof o.onKeydown=="function"&&o.onKeydown(a),Pn(a.key)&&(!a.defaultPrevented&&typeof e.slotProps.onClick=="function"&&e.slotProps.onClick(a),_n(n.type,o)&&a.preventDefault());}};i.onClick=s.onClick,i.onKeydown=s.onKeydown;}return cloneVNode(n,i)}if(On(n.type))i.disabled=true,delete i["aria-disabled"];else {delete i.disabled,i["aria-disabled"]=true,i["data-disabled"]="",i.tabIndex=-1,i.href=void 0,i.role===void 0&&(i.role="button");let s=i.onKeydown;i.onKeydown=a=>{sr(a)||typeof s=="function"&&s(a);};}return e.disabledReason&&(i.title=e.disabledReason),i.onClick=s=>{s.preventDefault(),s.stopPropagation();},cloneVNode(n,i)}}});function Vn(e){let t=A(defineComponent({name:"ReviewResolve",props:{className:String,asChild:Boolean,hidden:Boolean,icon:{type:[Object,String],default:void 0}},setup(n,{slots:o}){let i=e.useRail(),s=e.useItem(),a=e.useLabel(),u=useEditorState(ke);return ()=>{let d=s.value;if(n.hidden||!d||d.kind!=="comment"||d.resolved)return null;let l=i.value.review,c=a("comments.resolve"),f=u.value||l.commentResolutionDisabledReason!==null,m=f?a("editingMode.viewingHint"):null,g={type:"button",class:`docx-review__action${n.className?` ${n.className}`:""}`,"data-testid":"review-resolve","aria-label":c,title:m??c,disabled:f,onMousedown:L,onClick:p=>{p.stopPropagation(),!f&&l.resolve(d);}};return n.asChild?h(pe,{engineDisabled:f,disabledReason:m,slotProps:g},o.default):h("button",g,n.icon??o.default?.()??F(Pe))}}}),"Resolve"),r=A(defineComponent({name:"ReviewReopen",props:{className:String,asChild:Boolean,hidden:Boolean,icon:{type:[Object,String],default:void 0}},setup(n,{slots:o}){let i=e.useRail(),s=e.useItem(),a=e.useLabel(),u=useEditorState(ke);return ()=>{let d=s.value;if(n.hidden||!d||d.kind!=="comment"||!d.resolved)return null;let l=i.value.review,c=a("comments.reopen"),f=u.value||l.commentResolutionDisabledReason!==null,m=f?a("editingMode.viewingHint"):null,g={type:"button",class:`docx-review__action${n.className?` ${n.className}`:""}`,"data-testid":"review-reopen","aria-label":c,title:m??c,disabled:f,onMousedown:L,onClick:p=>{p.stopPropagation(),!f&&l.reopen(d);}};return n.asChild?h(pe,{engineDisabled:f,disabledReason:m,slotProps:g},o.default):h("button",g,n.icon??o.default?.()??F(Sn))}}}),"Reopen");return {ReviewResolve:t,ReviewReopen:r}}var Ln=new WeakMap;function Me(e){let t=getCurrentInstance();if(!t)throw new Error("useReviewStableId must run during component setup");let r=t.appContext,n=Ln.get(r)??0;return Ln.set(r,n+1),`docx-review-${n}-${e}`}function Hn(e){let t=A(defineComponent({name:"ReviewDraft",props:{top:{type:Number,default:0},left:{type:Number,default:null},className:String,hidden:Boolean},setup(n){let o=e.useRail(),i=e.useLabel(),s=ref(""),a=ref(false),u=Me("draft"),d=null;onMounted(()=>{let c=getCurrentInstance()?.proxy?.$el;if(c instanceof HTMLElement&&(d=o.value.measure,d(c,te)),o.value.readOnly)return;(c instanceof HTMLElement?c.querySelector('[data-testid="review-draft-input"]'):null)?.focus({preventScroll:true});}),onBeforeUnmount(()=>{d?.(null,te);});let l=()=>{let{review:c,endDraft:f,readOnly:m}=o.value;if(m||s.value.trim().length===0)return;let g=c.comment(s.value.trim());a.value=!g,g&&(s.value="",f());};return ()=>{if(n.hidden)return null;let{readOnly:c,draftAuthor:f,draftAuthorInfo:m,draftAuthorSlot:g}=o.value;return h("div",{class:`docx-review__slot${n.left===null?"":" docx-review__slot--compact"}${n.className?` ${n.className}`:""}`,style:{position:"absolute",top:`${n.top}px`,...n.left===null?{}:{left:`${n.left}px`,width:`${Te}px`}}},[h("div",{class:"docx-review__card","data-testid":"review-draft","data-draft":"",...f?{"data-review-author":f,"data-review-author-slot":g}:{},style:se(f??void 0,m,g)},[h("form",{class:"docx-review__reply-box",onSubmit:p=>{p.preventDefault(),l();}},[h("label",{class:"docx-editor-sr-only",for:u},i("comments.addComment")),h("input",{id:u,"data-testid":"review-draft-input",class:"docx-review__input",value:s.value,placeholder:i("comments.addComment"),readonly:c,...a.value?{"aria-invalid":true}:{},onInput:p=>{c||(a.value=false,s.value=p.target.value);},onKeydown:p=>{if(p.key==="Escape"){p.preventDefault(),o.value.endDraft();return}c||p.key!=="Enter"||(p.preventDefault(),l());}}),h("div",{class:"docx-review__reply-actions"},[h("button",{type:"button","data-testid":"review-draft-cancel",class:"docx-review__text-button",onMousedown:L,onClick:()=>o.value.endDraft()},i("common.cancel")),h("button",{type:"submit","data-testid":"review-draft-submit",class:"docx-review__submit",disabled:c||s.value.trim().length===0,title:c?i("editingMode.viewingHint"):void 0},i("common.comment"))]),a.value?h("span",{class:"docx-review__refused",role:"alert"},i("review.commentRefused")):null])])])}}}),"Draft"),r=A(defineComponent({name:"ReviewReply",props:{className:String,hidden:Boolean},setup(n,{slots:o}){let i=e.useRail(),s=e.useItem(),a=e.useLabel(),u=ref(""),d=ref(false),l=Me("reply"),c=fe(),f=useDocxEditor(),m=g=>{let p=s.value,{review:N,readOnly:I,byId:y}=i.value,E=g?.querySelector('[data-testid="review-reply-input"]'),w=(E?.value??u.value).trim(),x=p?y.get(p.id)??p:null;if(!x||I||w.length===0)return;let P=f.value?.replyToReviewItem(x.key,w).ok??N.reply(x,w);d.value=!P,P&&(u.value="",E&&(E.value=""));};return ()=>{c.value;let g=s.value;if(n.hidden||!g||!g.isActive||g.kind==="comment"&&g.resolved)return null;let{review:p,readOnly:N}=i.value,I=o.default?.();return I?.length?I:jsxs("div",{class:`docx-review__reply-box${n.className?` ${n.className}`:""}`,children:[jsx("label",{class:"docx-editor-sr-only",for:l,children:a("comments.replyPlaceholder")}),jsx("input",{id:l,"data-testid":"review-reply-input",class:"docx-review__input",placeholder:a("comments.replyPlaceholder"),readonly:N,...d.value?{"aria-invalid":true,"data-refused":""}:{},onInput:y=>{N||(d.value=false,u.value=y.target.value);},onClick:y=>y.stopPropagation(),onKeydown:y=>{N||y.key!=="Enter"||(y.preventDefault(),m(y.currentTarget.closest(".docx-review__reply-box")));}}),jsxs("div",{class:"docx-review__reply-actions",children:[jsx("button",{type:"button","data-testid":"review-reply-cancel",class:"docx-review__text-button",onMousedown:L,onClick:y=>{y.stopPropagation(),u.value="",d.value=false,p.setActive(null);},children:a("common.cancel")}),jsx("button",{type:"button","data-testid":"review-reply-submit",class:"docx-review__submit",disabled:N,title:N?a("editingMode.viewingHint"):void 0,onClick:y=>{y.preventDefault(),y.stopPropagation(),m(y.currentTarget.closest(".docx-review__reply-box"));},children:a("review.reply")})]}),d.value?jsx("span",{class:"docx-review__refused",role:"alert","data-testid":"review-reply-refused",children:a("review.replyRefused")}):null]})}}}),"Reply");return {ReviewDraft:t,ReviewReply:r}}var{ReviewResolve:Ot,ReviewReopen:_t}=Vn({useRail:O,useItem:$,useLabel:j}),{ReviewDraft:Pt,ReviewReply:Mt}=Hn({useRail:O,useItem:$,useLabel:j});var ut=A(defineComponent({name:"ReviewEmpty",props:{className:String,hidden:Boolean,asChild:Boolean},setup(e,{slots:t}){let r=j();return ()=>e.hidden?null:jsx("div",{class:`docx-review__empty${e.className?` ${e.className}`:""}`,"data-testid":"review-empty",children:t.default?.()??r("review.empty")})}}),"Empty"),ye=A(defineComponent({name:"ReviewAvatar",props:{className:String,hidden:Boolean,asChild:Boolean},setup(e,{slots:t}){let r=$(),n=O();return ()=>{let o=r.value;if(e.hidden||!o)return null;let i=t.default?.();if(i===void 0&&!o.initials)return null;let s={class:`docx-review__avatar${e.className?` ${e.className}`:""}`,"data-testid":"review-avatar","aria-hidden":true};if(e.asChild)return jsx(Slot,{...s,children:i});let a=n.value.authorInfo.get(o.author)?.style?.avatarUrl,u=i??(a?jsx("img",{class:"docx-review__avatar-img",src:a,alt:"",loading:"lazy",decoding:"async",referrerpolicy:"no-referrer"}):void 0)??o.initials;return jsx("span",{...s,children:u})}}}),"Avatar"),we=A(defineComponent({name:"ReviewAuthor",props:{className:String,hidden:Boolean,asChild:Boolean},setup(e,{slots:t}){let r=$(),n=j();return ()=>{let o=r.value;if(e.hidden||!o)return null;let i=o.author||n("comments.unknown"),s={class:`docx-review__author${e.className?` ${e.className}`:""}`,"data-testid":"review-author"};return e.asChild?jsx(Slot,{...s,children:t.default?.()}):jsx("span",{...s,children:t.default?.()??i})}}}),"Author"),Re=A(defineComponent({name:"ReviewTime",props:{className:String,hidden:Boolean,asChild:Boolean},setup(e,{slots:t}){let r=$();return ()=>{let n=r.value;if(e.hidden||!n)return null;let o=n.date;if(!o)return null;let i=new Date(o);if(Number.isNaN(i.getTime()))return null;let s={class:`docx-review__time${e.className?` ${e.className}`:""}`,"data-testid":"review-time",datetime:o};return e.asChild?jsx(Slot,{...s,children:t.default?.()}):jsx("time",{...s,children:t.default?.()??ot.format(i)})}}}),"Time"),ge=A(defineComponent({name:"ReviewSummary",props:{className:String,hidden:Boolean,asChild:Boolean},setup(e,{slots:t}){let r=$(),n=j();return ()=>{let o=r.value;if(e.hidden||!o)return null;let i=o.text,s=o.kind!=="revision"?null:n(st(o.revisionKind,o.item.markDirection)),a=o.kind==="revision"&&o.revisionKind==="replace",u={class:`docx-review__summary${e.className?` ${e.className}`:""}`,"data-testid":"review-summary","data-review-selectable":""};if(e.asChild)return jsx(Slot,{...u,children:t.default?.()});let d=t.default?.();return d?jsx("div",{...u,children:d}):jsx("div",{...u,children:a?jsxs("span",{class:"docx-review__text",children:[n("review.replaced")," ",jsxs("span",{class:"docx-review__removed",children:['"',o.replacedText,'"']})," ",n("review.replacedWith")," ",jsxs("span",{class:"docx-review__added",children:['"',i,'"']})]}):jsxs(Fragment$1,{children:[s?jsx("span",{class:"docx-review__label","data-kind":o.kind==="revision"?o.revisionKind:"revision",children:s}):null,i?jsx("span",{class:"docx-review__text",children:i}):null]})})}}}),"Summary");function Bn(e,t,r,n,o,i,s){return A(defineComponent({name:e,props:{className:String,asChild:Boolean,hidden:Boolean,icon:{type:[Object,String],default:void 0}},setup(a,{slots:u}){let d=O(),l=$(),c=j();return ()=>{let f=l.value,{readOnly:m,review:g}=d.value;if(a.hidden||!f||!s(f))return null;let p=c(n),N=m?c("editingMode.viewingHint"):null,I={type:"button",class:`docx-review__action${a.className?` ${a.className}`:""}`,"data-testid":r,"aria-label":p,title:N??p,disabled:m,onMousedown:L,onClick:y=>{y.stopPropagation(),!m&&i(g,f);}};return a.asChild?jsx(pe,{engineDisabled:m,disabledReason:N,slotProps:I,children:u.default?.()}):jsx("button",{...I,children:a.icon??u.default?.()??F(o)})}}}),t)}var $e=Bn("ReviewAccept","Accept","review-accept","review.accept",Pe,(e,t)=>e.accept(t),e=>e.kind==="revision"&&!e.readOnly),Ke=Bn("ReviewReject","Reject","review-reject","review.reject",En,(e,t)=>e.reject(t),e=>e.kind==="revision"&&!e.readOnly),ct=A(defineComponent({name:"ReviewDelete",props:{className:String,asChild:Boolean,hidden:Boolean,icon:{type:[Object,String],default:void 0}},setup(e,{slots:t}){let r=O(),n=$(),{t:o}=useTranslation();return ()=>{let i=n.value,{readOnly:s,review:a}=r.value;if(e.hidden||!i||i.kind==="custom"||i.kind==="revision"&&i.readOnly)return null;let u=i.kind==="comment"?o("review.deleteComment"):o("review.discardChange"),d=s?o("editingMode.viewingHint"):null,l={type:"button",class:`docx-review__action${e.className?` ${e.className}`:""}`,"data-testid":"review-delete","aria-label":u,title:d??u,disabled:s,onMousedown:L,onClick:c=>{c.stopPropagation(),!s&&a.remove(i);}};return e.asChild?jsx(pe,{engineDisabled:s,disabledReason:d,slotProps:l,children:t.default?.()}):jsx("button",{...l,children:e.icon??t.default?.()??F(kn)})}}}),"Delete"),Dt=A(defineComponent({name:"ReviewReplies",props:{className:String,hidden:Boolean},setup(e){let t=O(),r=$();return ()=>{let n=r.value;if(e.hidden||!n||n.kind==="custom")return null;let i=(t.value.byId.get(n.id)??n).replyIds.map(s=>t.value.byId.get(s)).filter(s=>s!==void 0);return i.length===0?null:jsx("ol",{class:`docx-review__replies${e.className?` ${e.className}`:""}`,children:i.map(s=>jsx(at,{entry:s,children:jsxs("li",{class:"docx-review__reply","data-testid":"review-reply",children:[jsxs("div",{class:"docx-review__head",children:[jsx(ye,{}),jsxs("div",{class:"docx-review__meta",children:[jsx(we,{}),jsx(Re,{})]}),jsx("div",{class:"docx-review__actions",children:jsx(ct,{})})]}),jsx(ge,{})]})},s.key))})}}}),"Replies"),qn=defineComponent({name:"ReviewCardPreset",setup(e,{slots:t}){let r=$(),n=computed(()=>pn(t.default?.()));return ()=>{let o=r.value;if(!o)return null;let i=(a,u)=>a in n.value?n.value[a]:u;if(o.kind==="custom"&&o.item.kind==="custom"){let a=o.item;return jsxs(Fragment$1,{children:[jsxs("div",{class:"docx-review__head",children:[i("Avatar",null),jsx("div",{class:"docx-review__meta",children:i("Author",jsx("span",{class:"docx-review__author","data-testid":"review-custom-title",children:a.title}))})]}),i("Summary",a.detail?jsx("div",{class:"docx-review__summary","data-testid":"review-summary","data-review-selectable":"",children:jsx("span",{class:"docx-review__text",children:a.detail})}):null),n.value.__extra]})}let s=o.kind==="revision"&&!o.readOnly;return jsxs(Fragment$1,{children:[jsxs("div",{class:"docx-review__head",children:[i("Avatar",jsx(ye,{})),jsxs("div",{class:"docx-review__meta",children:[i("Author",jsx(we,{})),i("Time",jsx(Re,{}))]}),s||o.kind==="comment"?jsxs("div",{class:"docx-review__actions",children:[i("Accept",jsx($e,{})),i("Reject",jsx(Ke,{})),i("Resolve",jsx(Ot,{})),i("Reopen",jsx(_t,{})),i("Delete",jsx(ct,{}))]}):null]}),i("Summary",jsx(ge,{})),i("Replies",jsx(Dt,{})),i("Reply",jsx(Mt,{})),n.value.__extra]})}}}),He=A(defineComponent({name:"ReviewCard",props:{className:String,hidden:Boolean,asChild:Boolean},setup(e,{slots:t}){let r=O(),n=$(),o=Me("card"),i=j(),s=null,a=d=>{s=d.el instanceof HTMLDetailsElement?d.el:s;},u=d=>{s?.open&&d.target instanceof Node&&!s.contains(d.target)&&(r.value.setExpandedResolvedKey(null),r.value.review.setActive(null),s.open=false);};return onMounted(()=>document.addEventListener("pointerdown",u,true)),onBeforeUnmount(()=>document.removeEventListener("pointerdown",u,true)),()=>{let d=n.value;if(e.hidden||!d)return null;let{review:l,authorSlots:c,authorInfo:f,expandedResolvedKey:m,setExpandedResolvedKey:g}=r.value,p=c.get(d.author)??0,N=!e.asChild&&d.kind==="comment"&&d.resolved,I={class:`docx-review__card${e.className?` ${e.className}`:""}`,"data-testid":"review-card",...N?{}:{"aria-labelledby":`${o}-author ${o}-summary`},"data-kind":d.kind==="revision"?d.revisionKind??"revision":d.kind,...d.author?{"data-review-author":d.author,"data-review-author-slot":ve(f.get(d.author),p)}:{},...d.kind==="custom"&&d.item.kind==="custom"?{"data-node-name":d.item.name}:{},...d.isActive?{"data-active":""}:{},...d.kind==="comment"&&d.resolved?{"data-resolved":""}:{},...N?{"data-resolved-miniature":""}:{},style:se(d.author,f.get(d.author),p),...N?{}:{tabIndex:0,role:"button"},id:o,...N?{}:{onMousedown:y=>{y.target?.closest("[data-review-selectable]")||y.currentTarget.focus({preventScroll:true});},onClick:y=>{y.target?.closest("button, input, textarea, .docx-review__reply-box, [data-review-selectable]")||d.isActive||l.setActive(d.key);},onKeydown:y=>{y.target===y.currentTarget&&(y.key!=="Enter"&&y.key!==" "||(y.preventDefault(),l.setActive(d.key)));}}};return e.asChild?jsx(Slot,{...I,children:t.default?.()}):N?h("details",{...I,open:m===d.key,onVnodeMounted:a,onVnodeUpdated:a,onVnodeBeforeUnmount:()=>{s=null;},onToggle:y=>{let E=y.currentTarget.open;g(E?d.key:null),l.setActive(E?d.key:null);}},[h("summary",{class:"docx-review__resolved-toggle","aria-label":i("review.showResolvedComment")},[h("span",{class:"docx-review__resolved-status"},i("review.resolved")),it()]),h(qn,null,{default:()=>t.default?.()})]):jsx("div",{...I,children:h(qn,null,{default:()=>t.default?.()})})}}}),"Card");var $t=A(defineComponent({name:"ReviewList",props:{stack:{type:Boolean,default:true},positions:{type:Object,default:void 0},collapsed:{type:Object,default:void 0},scale:{type:Number,default:1},offset:{type:Number,default:0},window:{type:Object,default:null},className:String,hidden:Boolean},setup(e,{slots:t}){let r=O();return ()=>{if(e.hidden)return null;let{review:n,cardClassName:o}=r.value,i=t.default?.()??[],s=t.item,a=s?null:Ee(i,"list"),u=Oe(n.items),d=n.items.filter(l=>!Ae(l,u));return d.length===0?s?null:a?.parts.Empty??jsx(ut,{}):h("div",{class:`docx-review__list${e.className?` ${e.className}`:""}`},d.map(l=>{let c=e.stack?e.positions?.get(l.key)??l.anchorY:l.anchorY,f=c==null?null:e.offset+c*e.scale;if(f!==null&&e.window&&(f<e.window.top||f>e.window.bottom))return null;let m=f===null?{}:{position:"absolute",top:`${f}px`};return h(rt,{key:l.key,entry:l,measureKey:l.key,collapsed:e.collapsed?.has(l.key),style:m},()=>s?s({item:l}):a?.parts.Card?et(a.parts.Card,o):h(He,o?{className:o}:{},()=>a?.rest))}))}}}),"List"),Kt=A(defineComponent({name:"ReviewMarkers",props:{scale:{type:Number,default:1},offset:{type:Number,default:0},window:{type:Object,default:null},className:String,hidden:Boolean,icon:{type:[Object,Function],default:void 0}},setup(e){let t=O(),r=j(),n=computed(()=>{let{review:o}=t.value,i=Oe(o.items),s=o.items.filter(d=>!Ae(d,i)),a=new Map,u=Number.NEGATIVE_INFINITY;for(let d of s){if(d.anchorY===null)continue;let l=Math.max(e.offset+d.anchorY*e.scale,u);a.set(d.key,l),u=l+mn;}return {roots:s,stackedTops:a}});return ()=>{if(e.hidden)return null;let{review:o,authorSlots:i,authorInfo:s,setExpandedResolvedKey:a}=t.value,{roots:u,stackedTops:d}=n.value;return jsx("div",{class:`docx-review__markers${e.className?` ${e.className}`:""}`,children:u.map(l=>{let c=d.get(l.key);return c===void 0||e.window&&(c<e.window.top||c>e.window.bottom)?null:jsx("button",{type:"button",class:"docx-review__marker","data-testid":"review-marker","data-kind":l.kind==="revision"?l.revisionKind:l.kind,...l.author?{"data-review-author":l.author,"data-review-author-slot":ve(s.get(l.author),i.get(l.author)??0)}:{},style:{position:"absolute",top:`${c}px`,...l.author?{"--doc-review-author-current":Tt(s.get(l.author),i.get(l.author)??0)}:{}},title:l.author?`${l.author}: ${l.text}`:l.text,"aria-label":`${r("review.showPane")}: ${l.author?`${l.author}. `:""}${l.text}`,onMousedown:L,onClick:()=>{l.kind==="comment"&&l.resolved&&a(l.key),o.setPaneOpen(true),o.setActive(l.key);},children:(typeof e.icon=="function"?e.icon(l):e.icon)??(l.kind==="comment"&&l.resolved?it():F(Tn(l)))},l.key)})})}}}),"Markers"),Ht=A(defineComponent({name:"ReviewAddComment",props:{top:{type:Number,default:null},drafting:{type:Boolean,default:false},className:String,hidden:Boolean},setup(e,{slots:t}){let r=O(),n=j();return ()=>{let{beginDraft:o,composeTop:i,readOnly:s}=r.value;if(e.hidden||e.drafting||i===null||s)return null;let a={type:"button",class:`docx-review__add${e.className?` ${e.className}`:""}`,"data-testid":"review-add-comment",style:{position:"absolute",top:`${i}px`},"aria-label":n("common.comment"),title:n("common.comment"),onMousedown:L,onClick:o},u=t.default?.();return u?.length?h(Slot,a,()=>u):h("button",a,F(In))}}}),"AddComment"),hr=defineComponent({name:"BalloonTime",props:{raw:{type:String,required:true}},setup(e){return ()=>{let t=new Date(e.raw);return Number.isNaN(t.getTime())?null:jsx("time",{class:"docx-review__time",datetime:e.raw,children:ot.format(t)})}}}),qt=A(defineComponent({name:"ReviewBalloon",props:{className:String,hidden:Boolean},setup(e){let t=getCurrentInstance(),r=O(),n=j(),o=ref(null),i=ref(false),s=ref(false);watch(o,l=>{i.value=l!==null;});let a;onMounted(()=>{let l=getCurrentInstance()?.proxy?.$el,c=l?.closest(".docx-review"),f=c?.closest(".docx-editor__scroll-container")??c?.offsetParent;if(!l||!c||!f)return;let m=(p,N)=>{let I=c.getBoundingClientRect(),y=p.getBoundingClientRect(),E=p.ownerDocument.defaultView?.innerHeight??1/0,w=Number(p.dataset.start),x=Number(p.dataset.end);o.value={revisionId:p.dataset.revisionId,author:p.dataset.reviewAuthor??"",...p.dataset.revisionDate!==void 0?{date:p.dataset.revisionDate}:{},...p.dataset.revisionKind!==void 0?{kind:p.dataset.revisionKind}:{},structuralSite:N,...p.dataset.paragraphId!==void 0?{paragraphId:p.dataset.paragraphId}:{},...Number.isFinite(w)?{start:w}:{},...Number.isFinite(x)?{end:x}:{},left:y.left-I.left,top:y.top-I.top,bottom:y.bottom-I.top,above:y.bottom+220>E},t?.proxy?.$forceUpdate();},g=p=>{let N=p.target;if(!(N instanceof Element)||l.contains(N))return;let I=N.closest("[data-revision-id]");if(I instanceof HTMLElement&&f.contains(I)){let y=I.classList.contains("docx-table-row--revision");if(I.dataset.revisionKind==="format"||y){m(I,y);return}}i.value&&(o.value=null,t?.proxy?.$forceUpdate());};f.addEventListener("pointerdown",g,true),f.addEventListener("mousedown",g,true),a=()=>{f.removeEventListener("pointerdown",g,true),f.removeEventListener("mousedown",g,true);};}),onUnmounted(()=>a?.());let u=computed(()=>{let l=o.value;if(!l)return null;let{allItems:c}=r.value,f=null,m=false,g=null,p=false,N=null,I=false;for(let y of c)if(!(y.kind!=="revision"||y.item.kind!=="revision")){for(let E of y.item.addresses)if(E.id===l.revisionId){if(E.author===l.author){if(E.date===l.date)return y;f===null?f=y:f!==y&&(m=true);}g===null?g=y:g!==y&&(p=true);}if(l.paragraphId!==void 0&&l.start!==void 0&&l.end!==void 0&&(y.revisionKind==="format"||y.revisionKind==="structural")){for(let E of y.item.ranges)if(E.start.paragraphId===l.paragraphId&&E.start.offset<l.end&&E.end.offset>l.start){N===null?N=y:N!==y&&(I=true);break}}}return f!==null&&!m?f:g!==null&&!p?g:N!==null&&!I?N:null}),d=computed(()=>{let l=u.value;return l&&(l.revisionKind==="format"||l.revisionKind==="structural")?l:null});return watch(d,l=>{if(l){s.value=true;return}s.value&&(s.value=false,o.value=null);}),()=>{if(e.hidden)return null;let{review:l,authorSlots:c,authorInfo:f}=r.value,m=o.value,g=m?.kind==="format"?"format":"structural",p=d.value,N=m===null?null:h("div",{class:"docx-review__balloon","data-testid":"review-balloon",style:{left:`${m.left}px`,top:`${m.above?m.top-6:m.bottom+6}px`,transform:m.above?"translateY(-100%)":void 0},onMousedown:L},p?h(at,{entry:p},()=>h("div",{class:"docx-review__card","data-testid":"review-balloon-card","data-kind":p.revisionKind??"revision",...p.author?{"data-review-author":p.author,"data-review-author-slot":ve(f.get(p.author),c.get(p.author)??0)}:{},style:se(p.author,f.get(p.author),c.get(p.author)??0),onClick:()=>l.setActive(p.key)},[h("div",{class:"docx-review__head"},[h(ye),h("div",{class:"docx-review__meta"},[h(we),h(Re)]),p.kind==="revision"&&!p.readOnly?h("div",{class:"docx-review__actions"},[h($e),h(Ke)]):null]),h(ge)])):h("div",{class:"docx-review__card","data-testid":"review-balloon-card","data-kind":g,...m.author?{"data-review-author":m.author,"data-review-author-slot":ve(f.get(m.author),c.get(m.author)??0)}:{},style:se(m.author,f.get(m.author),c.get(m.author)??0)},[h("div",{class:"docx-review__head"},[h("span",{class:"docx-review__avatar","aria-hidden":true},vn(m.author)),h("div",{class:"docx-review__meta"},[h("span",{class:"docx-review__author"},m.author||n("comments.unknown")),m.date?h(hr,{raw:m.date}):null])]),h("div",{class:"docx-review__summary"},[h("span",{class:"docx-review__label","data-kind":g},n(st(g)))])]));return h("div",{class:`docx-review__balloon-root${e.className?` ${e.className}`:""}`},N===null?void 0:[N])}}}),"Balloon");function Be(e,t,r){if(!(e in r))return t;let n=r[e];return !isVNode(n)||!isVNode(t)?n:cloneVNode(n,mergeProps(t.props??{},n.props??{}))}var Pr=defineComponent({name:"ReviewDraftMount",props:{top:{type:Number,required:true},left:{type:Number,default:null}},setup(e){return ()=>h(Pt,{top:e.top,left:e.left})}});function Mr(e,t){return {items:t,activeKey:e.activeKey.value,setActive:e.setActive,accept:e.accept,reject:e.reject,resolve:e.resolve,reopen:e.reopen,commentResolutionDisabledReason:e.commentResolutionDisabledReason.value,remove:e.remove,reply:e.reply,selectionAnchorY:e.selectionAnchorY.value,comment:e.comment,paneOpen:e.paneOpen.value,setPaneOpen:e.setPaneOpen,ready:e.ready.value}}var Dr=defineComponent({name:"DocxEditorReview",props:{className:String,asChild:Boolean,hidden:Boolean,t:{type:Function,default:void 0},card:{type:Object,default:void 0},furniture:{type:[Object,Array],default:void 0},preset:{type:Boolean,default:true},stack:{type:Boolean,default:true},gap:{type:Number,default:8},filter:{type:Function,default:void 0},structural:{type:Boolean,default:false},formatting:{type:Boolean,default:false}},setup(e,{slots:t}){let r=getCurrentInstance(),n=useDocxEditor(),o=useEditorState(rn),i=useEditorState(ke),s=fe(),a=computed(()=>{let v=[];return e.structural||v.push("structural"),e.formatting||v.push("format"),v.length>0?v:void 0}),u=computed(()=>a.value?{excludeRevisionKinds:a.value}:void 0);watch([n,a],()=>{n.value?.setReviewActivationExclusions(a.value??null);},{immediate:true}),onUnmounted(()=>{n.value?.setReviewActivationExclusions(null);}),tn(s);let d=Ct(fn,s),l=Ct(()=>u.value,s),{t:c}=useTranslation(),f=(v,R)=>e.t?.(v,R)??c(v,R),m=shallowRef(null),g=inject(ReviewRailContext,shallowRef({mounted:0,register:()=>()=>{},registerCommentDraft:()=>()=>{},requestCommentDraft:()=>false})),p=ref(false),N,I=()=>{if(!p.value||e.hidden){N?.(),N=void 0;return}N??=g.value.register();};onMounted(()=>{p.value=true,I();}),watch(()=>e.hidden,I);let y=computed(()=>l.paneOpen.value),E=useReviewGutter(),w=ref(null),x=computed(()=>y.value&&(w.value??E.value.inlineEnd)>0&&(w.value??E.value.inlineEnd)<REVIEW_PANE_GUTTER),P=computed(()=>y.value&&!x.value),K=computed(()=>e.filter?l.items.value.filter(v=>e.filter(v)):l.items.value),J=ref(null);watch(K,v=>{let R=J.value;R!==null&&!v.some(h=>h.key===R&&h.kind==="comment"&&h.resolved)&&(J.value=null);},{flush:"sync"});let Y=computed(()=>n.value?.getConfiguredAuthor()??null),ne=computed(()=>{let v=new Map;for(let R of K.value)R.author&&!v.has(R.author)&&v.set(R.author,v.size);return Y.value&&!v.has(Y.value)&&v.set(Y.value,v.size),v}),pt=useReviewAuthors(),yt=new Map,Fe=computed(()=>Cn(pt.value,K.value,ne.value,n.value,yt)),Ne=computed(()=>{let v=new Map;for(let R of d.items.value)v.set(R.id,R);return v}),Ye=ref(new Map),no=Nn((v,R)=>{if(R<=0||Ye.value.get(v)===R)return;let h=new Map(Ye.value);h.set(v,R),Ye.value=h;}),M=ref(an),Ce;watch([n,K,o,()=>e.hidden,m,x],()=>{Ce?.(),Ce=void 0;let v=m.value,R=n.value;if(!R||!v||o.value||e.hidden)return;let h=v.offsetParent,k=h?.querySelector(".docx-paginated-surface")??null,b=()=>{if(h){let me=Number.parseFloat(getComputedStyle(h).getPropertyValue("--docx-review-gutter"));w.value=Number.isFinite(me)?me:null;}else w.value=null;let V=k&&h?k.getBoundingClientRect():null,ee=V&&h?h.getBoundingClientRect():null,ue=V&&ee&&h?V.right-ee.left-h.clientLeft+h.scrollLeft+sn:null,re={scale:R.getRenderScale(),top:V&&ee&&h?V.top-ee.top-h.clientTop+h.scrollTop:0,left:ue,compactCardLeft:ue===null||!h?null:h.scrollLeft+h.clientWidth-ue-Te-ln},ce=M.value;(ce.scale!==re.scale||ce.top!==re.top||ce.left!==re.left||ce.compactCardLeft!==re.compactCardLeft)&&(M.value=re);};b();let T=new ResizeObserver(b);h&&T.observe(h),k&&T.observe(k);let U=h&&typeof MutationObserver<"u"?new MutationObserver(b):null;if(U?.observe(h,{attributes:true,attributeFilter:["style"]}),!x.value||!h){Ce=()=>{U?.disconnect(),T.disconnect();};return}let B=0,D=()=>{B===0&&(B=requestAnimationFrame(()=>{B=0,b();}));};h.addEventListener("scroll",D,{passive:true}),Ce=()=>{B!==0&&cancelAnimationFrame(B),h.removeEventListener("scroll",D),U?.disconnect(),T.disconnect();};},{flush:"post"}),onUnmounted(()=>Ce?.());let Ge;watch([n,o,()=>e.hidden,m],()=>{Ge?.(),Ge=void 0;let v=m.value,R=n.value;if(!R||!v||o.value||e.hidden)return;let h=k=>{let b=k.target;if(!(b instanceof Node)||v.contains(b))return;let T=v.offsetParent;!T||!T.contains(b)||T.querySelector(".docx-paginated-surface")?.contains(b)||R.setActiveReviewItem(null);};document.addEventListener("mousedown",h,true),Ge=()=>document.removeEventListener("mousedown",h,true);},{flush:"post"}),onUnmounted(()=>Ge?.());let de=ref(null),Ze;watch([n,o,()=>e.hidden,m],()=>{Ze?.(),Ze=void 0;let v=m.value,R=v?.offsetParent;if(!R||o.value||e.hidden)return;let h=0,k=()=>{h=0;let B=R.scrollTop-tt,D=R.scrollTop+R.clientHeight+tt,V=de.value;de.value=V&&V.top===B&&V.bottom===D?V:{top:B,bottom:D};},b=0,T=()=>{h===0&&(h=requestAnimationFrame(k)),v?.setAttribute("data-scrolling",""),window.clearTimeout(b),b=window.setTimeout(()=>v?.removeAttribute("data-scrolling"),150);};k(),R.addEventListener("scroll",T,{passive:true});let U=new ResizeObserver(T);U.observe(R),Ze=()=>{h!==0&&cancelAnimationFrame(h),window.clearTimeout(b),R.removeEventListener("scroll",T),U.disconnect();};},{flush:"post"}),onUnmounted(()=>Ze?.());let Q=ref(null),We=shallowRef(null),be=()=>{let v=We.value;v&&v.editor.releaseSelection(v.pin),We.value=null,Q.value=null;};watch(()=>n.value,(v,R)=>{R&&R!==v&&We.value?.editor===R&&be();});let Ft=()=>{let v=n.value;if(!v||i.value)return;let R=v.getSelectionPlacement()?.anchorY??null;if(R===null)return;be();let h=v.retainSelection();h&&(We.value={editor:v,pin:h},l.setPaneOpen(true),Q.value=R,r?.proxy?.$forceUpdate());},Ie,Yt=()=>{if(!p.value||e.hidden){Ie?.(),Ie=void 0;return}Ie??=g.value.registerCommentDraft(Ft);};onMounted(Yt),watch(()=>e.hidden,Yt);let oo=()=>{be(),n.value?.focus(),r?.proxy?.$forceUpdate();};watch(y,v=>{v||Q.value===null||be();}),onBeforeUnmount(()=>{p.value=false,N?.(),N=void 0,Ie?.(),Ie=void 0,be();});let wt=computed(()=>Q.value??l.selectionAnchorY.value),oe=computed(()=>{let v=Oe(K.value);return K.value.filter(R=>!Ae(R,v))}),ro=computed(()=>{let v=Q.value;if(v===null)return oe.value;let R=oe.value.findIndex(k=>k.anchorY!==null&&k.anchorY>v),h={key:te,anchorY:v};return R===-1?[...oe.value,h]:[...oe.value.slice(0,R),h,...oe.value.slice(R)]}),ao=computed(()=>{let v=new Map(Ye.value);for(let R of oe.value){if(v.has(R.key))continue;let h=R.text.length+(R.kind==="revision"?R.replacedText?.length??0:0),k=Math.min(6,Math.max(1,Math.ceil(h/36)));v.set(R.key,64+k*20);}return v}),Rt=computed(()=>{let v=M.value.scale,R=new Map,h=new Set,k=Number.NEGATIVE_INFINITY;for(let b of ro.value){let T=b.anchorY===null?Number.isFinite(k)?k:0:Math.max(b.anchorY,k);R.set(b.key,T);let U=b.anchorY===null?0:(T-b.anchorY)*v,B="isActive"in b&&b.isActive,D=U>cn&&!B&&b.key!==te;D&&h.add(b.key);let V=D?un:ao.value.get(b.key)??dn;k=T+(V+e.gap)/v;}return {stacked:R,collapsedKeys:h}}),Se=computed(()=>wt.value===null?null:M.value.top+(x.value?wt.value:Rt.value.stacked.get(te)??wt.value)*M.value.scale),io=computed(()=>(l.commentResolutionDisabledReason.value,l.selectionAnchorY.value,l.paneOpen.value,l.items.value.length,Mr(l,K.value))),gt=()=>{let v=Y.value,R=v?ne.value.get(v)??0:0;return {t:e.t,cardClassName:e.card?.className,readOnly:i.value,composeTop:Se.value,review:io.value,allItems:d.items.value,authorSlots:ne.value,authorInfo:Fe.value,draftAuthor:v,draftAuthorInfo:v?Fe.value.get(v):void 0,draftAuthorSlot:R,byId:Ne.value,measure:no,beginDraft:Ft,endDraft:oo,expandedResolvedKey:J.value,setExpandedResolvedKey:h=>{J.value=h;}}},ht=shallowRef(gt());return watchEffect(()=>{ht.value=gt();}),watch(()=>s.value,()=>{ht.value=gt(),r?.proxy?.$forceUpdate();},{flush:"sync"}),provide(St,ht),()=>{if(e.hidden||o.value)return null;s.value,d.items.value,Q.value,K.value.length,l.selectionAnchorY.value,l.paneOpen.value,l.commentResolutionDisabledReason.value,Se.value;let v=z=>{m.value=z.el instanceof HTMLElement?z.el:null;},R={onVnodeMounted:v,onVnodeUpdated:v,onVnodeBeforeUnmount:()=>{m.value=null;},class:`docx-review${e.className?` ${e.className}`:""}`,"data-testid":"review-rail","data-count":K.value.length,"data-open":P.value?"":void 0,"data-compact":x.value?"":void 0,role:"complementary","aria-label":f("review.ariaLabel"),onMousedown:L,style:M.value.left===null?void 0:{left:`${M.value.left}px`,right:"auto"}},h$1=t.default?.()??[],k=e.asChild&&h$1.length===1&&isVNode(h$1[0])?h$1[0]:null,{parts:b,rest:T}=Ee(k?[]:h$1,"root"),U={stack:e.stack,positions:Rt.value.stacked,collapsed:Rt.value.collapsedKeys,scale:M.value.scale,offset:M.value.top,window:de.value},B=h(Kt,{scale:M.value.scale,offset:M.value.top,window:de.value}),D=x.value?oe.value.find(z=>z.key===l.activeKey.value)??null:null,V=D===null?null:D.anchorY!==null?M.value.top+D.anchorY*M.value.scale:de.value!==null?de.value.top+tt+24:null,ee=Ee(T,"list"),ue=D&&t.item?t.item({item:D}):ee.parts.Card?et(ee.parts.Card,e.card?.className):e.preset?h(He,e.card?.className?{className:e.card.className}:{},()=>ee.rest):null,re=D&&V!==null&&M.value.compactCardLeft!==null&&ue?h(rt,{entry:D,className:"docx-review__slot--compact",testId:"review-compact-card",style:{position:"absolute",top:`${V}px`,left:`${M.value.compactCardLeft}px`,width:`${Te}px`}},()=>ue):null,ce=P.value?e.preset||"List"in b?Be("List",h($t,U,{...T.length>0?{default:()=>T}:{},...t.item?{item:t.item}:{}}),b):T:e.preset||"Markers"in b?[Be("Markers",B,b),re]:T,me=[P.value&&e.furniture!==void 0?h("div",{class:"docx-review__furniture","data-testid":"review-furniture"},[e.furniture]):null,ce,...e.preset||"AddComment"in b?[Be("AddComment",h(Ht,{top:Se.value,drafting:Q.value!==null}),b)]:[],...Q.value===null||Se.value===null||!y.value||!e.preset&&!("Draft"in b)?[]:[Be("Draft",h(Pr,{top:Se.value??0,left:x.value?M.value.compactCardLeft:null}),b)],...e.preset||"Balloon"in b?[Be("Balloon",h(qt),b)]:[]],H=k;if(!H)return h("aside",R,me);let ae=cloneVNode(H,R,true);if(typeof H.type=="string"){let z=Array.isArray(H.children)?H.children:H.children==null?[]:typeof H.children=="string"||typeof H.children=="number"?[H.children]:[];ae.children=[...z,...me],ae.shapeFlag=ae.shapeFlag&-9|16;}else {let z=H.children&&!Array.isArray(H.children)&&typeof H.children=="object"?H.children:{},Gt=z.default;ae.children={...z,default:(...so)=>[...Gt?[Gt(...so)]:[],...me]},ae.shapeFlag=ae.shapeFlag&-25|32;}return ae}}});var Vr=Object.assign(Dr,{List:$t,Empty:ut,Card:He,Avatar:ye,Author:we,Time:Re,Summary:ge,Accept:$e,Reject:Ke,Resolve:Ot,Reopen:_t,Delete:ct,Replies:Dt,Reply:Mt,Markers:Kt,AddComment:Ht,Draft:Pt,Balloon:qt});function je(e){let t=useDocxEditor();return computed(()=>{let r=toValue(e);return r||(t.value?.getCustomNodeDefinitions()??[]).filter(Je)})}var Br=".docx-content-control-boundary";function he(e,t){let{node:r,definition:n,controlId:o}=e,i=o?t?.getReviewItems().find(u=>u.kind==="custom"&&u.item.id===o):void 0;if(i?.kind==="custom"){let u=i.item;return {...r,attrs:u.attrs,text:u.text,...u.data===void 0?{}:{data:u.data},...o?{nodeId:o}:{}}}let s=o?jr(t,o,n):void 0,a=n.fromDocx?n.fromDocx({attrs:r.attrs,text:"",...s===void 0?{}:{data:s}}):r.attrs;return a===null?null:{...r,attrs:a,...s===void 0?{}:{data:s},...o?{nodeId:o}:{}}}function jr(e,t,r){let n=e?.surface;if(!n)return;let o=partOfNodeId(n.session,t),i=customNodePayloadsByControl(n.session.currentPackage(),(o??n.session.part()).name,n.session.part().name).get(t);if(!i)return;let s=Xe(r.schema,i.data);return s.ok?s.value:void 0}function xe(e,t){let r=e?.closest?.(Br),n=r?.closest(".docx-content-control-chrome"),o=n?.getAttribute("data-tag"),i=o?ze(o):null;if(!r||!i||!o)return null;let s=t.find(a=>a.tagPrefix===i.prefix&&a.name===i.name);return s?{node:{name:i.name,attrs:i.attrs,tag:o,rect:r.getBoundingClientRect()},definition:s,controlId:n?.getAttribute("data-docx-content-control")??null}:null}var jt=".docx-content-control-boundary";function Wr(e){if(!Nt.test(e.tagPrefix)||!Nt.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}?"]`]}var zr=defineComponent({name:"CustomNodeChrome",props:{nodes:{type:Array,default:void 0},onNodeClick:{type:Function,default:void 0},onNodeHover:{type:Function,default:void 0}},setup(e){let t=useDocxEditor(),r=je(()=>e.nodes),n,o=null,i=null,s=l=>xe(document.elementFromPoint(l.clientX,l.clientY),r.value),a=l=>{let c=l.button===0?s(l):null;o=c?.controlId??null,i=c?.node.tag??null;},u=l=>{let c=o,f=i;if(o=null,i=null,f===null)return;let m=s(l);if(!m||m.node.tag!==f||c!==null&&m.controlId!==c)return;let g=he(m,t.value);g&&(m.definition.onClick?.(g),e.onNodeClick?.(g));},d=l=>{let c=xe(l.target,r.value);if(!c||l.relatedTarget?.closest?.(jt)===l.target.closest(jt))return;let m=he(c,t.value);m&&(c.definition.onHover?.(m),e.onNodeHover?.(m));};return onMounted(()=>{n=watch(r,(l,c,f)=>{let m=document.createElement("style"),g=[];for(let p of l){let N=Wr(p);if(N.length===0)continue;let I=p.chrome?.color,y=I!==void 0&&typeof CSS<"u"&&CSS.supports("color",I)?I:"var(--doc-accent)";g.push(`${N.map(E=>`${E} ${jt}`).join(", ")} {`," pointer-events: auto !important;"," opacity: 1;"," border: none;",` background: color-mix(in srgb, ${y} 12%, transparent);`," border-radius: 6px;"," cursor: default;","}");}m.textContent=g.join(`
|
|
2
|
+
`),document.head.append(m),f(()=>m.remove());},{immediate:true}),document.addEventListener("pointerdown",a,true),document.addEventListener("pointerup",u,true),document.addEventListener("mouseover",d);}),onBeforeUnmount(()=>{n?.(),document.removeEventListener("pointerdown",a,true),document.removeEventListener("pointerup",u,true),document.removeEventListener("mouseover",d);}),()=>null}});function Jr(e){return e.surface??null}function zn(e){let t=e.detail?`${e.reason}: ${e.detail}`:e.reason;return {ok:false,code:Qr.has(e.reason)?"invalidArgs":"unsupported",reason:t}}var Qr=new Set(["payload-too-large","unaddressable-payload","store-not-authored","offset-out-of-range","invalid-range","invalid-property-value","splits-surrogate-pair"]);function Xn(e){return e.getEditingMode()==="viewing"?{ok:false,code:"locked",reason:"the document is open for viewing"}:null}function Wn(e){let t=e.getActiveScope();if(t.kind==="headerFooter")return {kind:"headerFooter",rId:t.rId};if(t.kind==="note"){let r=parseNoteScopeId(t.id);if(r)return {kind:"notesPart",noteKind:r.noteKind}}return {kind:"body"}}function Jn(e,t){let r=Jr(e),n=t===void 0?"":t.slice(0,t.indexOf("#"));if(!r||n.length===0)return Wn(e);if(n===r.session.part().name)return {kind:"body"};for(let o of r.session.headerFooterResolutionBySection())for(let i of [o.headers,o.footers])for(let s of i.values())if(s.partName===n)return {kind:"headerFooter",rId:s.rId};for(let o of ["footnote","endnote"])if(r.session.partFor({kind:"notesPart",noteKind:o})?.name===n)return {kind:"notesPart",noteKind:o};return Wn(e)}function ea(e){return e.surface??null}function Qn(e,t){let r=ea(e);if(!r)return {ok:false,code:"notFound",reason:"no document is mounted"};let n=Xn(e);if(n)return n;r.flushPendingInput();let o=r.session.removeCustomNode(t,Jn(e,t));return o.ok?{ok:true,changed:true}:zn(o)}var ia=Object.assign(defineComponent({name:"CustomNodeContextMenu",props:{nodes:{type:Array,default:void 0},onEditNode:{type:Function,default:void 0},remove:{type:Boolean,default:true},onRemoveRefused:{type:Function,default:void 0}},setup(e){let t=je(()=>e.nodes),r=useContextMenuTarget(),n=useDocxEditor(),{t:o}=useTranslation(),i=computed(()=>xe(r,t.value)),s=computed(()=>{let u=i.value;return u?he(u,n.value):null}),a=computed(()=>{let u=i.value,d=s.value;return !u?.definition.reviewCard||!d?null:u.definition.reviewCard({attrs:d.attrs,text:d.text??"",...d.data===void 0?{}:{data:d.data}})});return ()=>{let u=i.value,d=s.value;if(!u||!d)return null;let{definition:l}=u,c=l.label??l.name,f=l.onEdit!==void 0||e.onEditNode!==void 0,m=e.remove&&d.nodeId!==void 0&&n.value!==null;return !a.value&&!f&&!m?null:jsxs(Fragment,{children:[a.value?jsxs("div",{class:"docx-contextmenu__custom-info","data-testid":"custom-node-info",children:[jsx("span",{class:"docx-contextmenu__custom-title",children:a.value.title}),a.value.detail?jsx("span",{class:"docx-contextmenu__custom-detail",children:a.value.detail}):null]}):null,f?jsx(ContextMenuItem,{label:o("contextMenu.editCustomNode",{label:c}),className:"docx-contextmenu__custom-edit",onSelect:()=>{l.onEdit?.(d),e.onEditNode?.(d,l);}}):null,m?jsx(ContextMenuItem,{label:o("contextMenu.removeCustomNode",{label:c}),className:"docx-contextmenu__custom-remove",onSelect:()=>{let g=Qn(n.value,d.nodeId);g.ok||e.onRemoveRefused?.(d,g.reason);}}):null,jsx("div",{role:"separator",class:"docx-toolbar__menu-separator"})]})}}}),{docxRowPlacement:"start"});export{zr as CustomNodeChrome,ia as CustomNodeContextMenu,Vr as DocxEditorReview,he as activatedCustomNodeOf,xe as resolveCustomNodeActivation,Co as reviewModule,je as useCustomNodeDefinitions,Oo as useReview,Wo as useReviewAuthor,$ as useReviewItem,_o as useReviewOf,Po as useStackedReviewPositions};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docx-editor.dev/pro",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"description": "Commercial capabilities for @docx-editor.dev: the review module (comments, tracked changes, markup rendering) and custom inline nodes over content controls.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"THIRD_PARTY_NOTICES.md"
|
|
30
30
|
],
|
|
31
31
|
"scripts": {
|
|
32
|
-
"build": "tsup",
|
|
32
|
+
"build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsup",
|
|
33
33
|
"typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.vue.json",
|
|
34
34
|
"license:check": "license-check-and-add check -f license-check.json",
|
|
35
35
|
"license:add": "license-check-and-add add -f license-check.json"
|
package/dist/chunk-QIMNGUJX.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'use strict';var store=require('@docx-editor.dev/core/store'),layout=require('@docx-editor.dev/core/layout');function g(e){}var Oe=64,H=new Set(["__proto__","constructor","prototype"]);function h(e,t,o){let n=new URLSearchParams;for(let[s,d]of Object.entries(o))n.set(s,d);let r=n.toString(),a=r.length>0?`${e}:${t}?${r}`:`${e}:${t}`;return a.length>64?{ok:false,reason:"tag-overflow",length:a.length}:{ok:true,tag:a}}function N(e){if(e.length>64)return null;let t=e.indexOf(":");if(t<=0)return null;let o=e.slice(0,t),n=e.slice(t+1),r=n.indexOf("?"),a=r===-1?n:n.slice(0,r);if(a.length===0)return null;let s=Object.create(null);if(r!==-1)for(let[d,i]of new URLSearchParams(n.slice(r+1))){if(H.has(d))return null;s[d]=i;}return {prefix:o,name:a,attrs:s}}var Ie=262144;function x(e,t){if(t.length===0)return {ok:false,reason:"malformed",issues:["the node carries no payload"]};if(t.length>262144)return {ok:false,reason:"malformed",issues:[`the payload is ${String(t.length)} characters; the cap is ${String(262144)}`]};let o;try{o=JSON.parse(t);}catch(a){return {ok:false,reason:"malformed",issues:[a instanceof Error?a.message:"the payload is not JSON"]}}let n=I(o);if(!e)return {ok:true,value:n};let r=e["~standard"].validate(n);return B(r)?{ok:false,reason:"async",issues:["the schema validates asynchronously, which the read path cannot await"]}:r.issues?{ok:false,reason:"invalid",issues:r.issues.map(q)}:{ok:true,value:r.value}}function R(e){let t;try{t=JSON.stringify(e)??"";}catch(o){return {ok:false,reason:"malformed",issues:[o instanceof Error?o.message:"the value cannot be serialized"]}}return t.length===0?{ok:false,reason:"malformed",issues:["the value serializes to nothing"]}:t.length>262144?{ok:false,reason:"malformed",issues:[`the payload is ${String(t.length)} characters; the cap is ${String(262144)}`]}:{ok:true,value:t}}function B(e){return typeof e.then=="function"}function q(e){let t=(e.path??[]).map(o=>String(typeof o=="object"?o.key:o)).join(".");return t.length>0?`${t}: ${e.message}`:e.message}var Y=new Set(["__proto__","constructor","prototype"]);function I(e){if(Array.isArray(e))return e.map(I);if(e===null||typeof e!="object")return e;let t=Object.create(null);for(let[o,n]of Object.entries(e))Y.has(o)||(t[o]=I(n));return t}function _(e){let t=(e.path??[]).map(o=>{let n=typeof o=="object"?o.key:o;return typeof n=="number"?n:String(n)});return {message:e.message,path:t,pointer:t.join(".")}}function S(e,t){return {ok:false,code:"invalidArgs",reason:e,issues:t}}var b="docxEditor";function v(e){return e.payloadNamespace??`urn:docx-editor.dev:custom-node:${e.tagPrefix}`}function M(e,t,o){let n=0;for(let r of store.customNodePayloadsOf(e,t,o).keys()){let a=/^cx(\d{1,9})$/.exec(r);if(!a)continue;let s=Number(a[1]);s>n&&(n=s);}return `cx${String(n+1)}`}function L(e,t){let o=R(t);if(!o.ok)return {ok:false,reason:`the payload cannot be serialized: ${o.issues.join(", ")}`,issues:[]};if(!e.schema)return {ok:true,data:o.value,value:t};let r=e.schema["~standard"].validate(JSON.parse(o.value));if(Q(r))return {ok:false,reason:`${e.name}'s schema validates asynchronously, which a write cannot await`,issues:[]};if(r.issues){let s=r.issues.map(_);return {ok:false,reason:`the payload does not match ${e.name}'s schema: `+s.map(d=>(d.pointer?`${d.pointer}: `:"")+d.message).join(", "),issues:s}}let a=R(r.value);return a.ok?{ok:true,data:a.value,value:r.value}:{ok:false,reason:`the payload cannot be serialized: ${a.issues.join(", ")}`,issues:[]}}function Q(e){return typeof e.then=="function"}function z(e){return typeof e=="object"&&e!==null&&typeof e.name=="string"&&typeof e.tagPrefix=="string"}var V=/^[A-Za-z0-9_.-]+$/,te=/['"<>&]|[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/;function oe(e){return e.length>0&&!te.test(e)}function Ve(e){if(!V.test(e.name??""))throw new Error(`defineCustomNode: invalid name ${JSON.stringify(e.name)}`);if(!V.test(e.tagPrefix??""))throw new Error(`defineCustomNode: invalid tagPrefix ${JSON.stringify(e.tagPrefix)}`);let t=e.schema;if(t!==void 0&&typeof t?.["~standard"]?.validate!="function")throw new Error(`defineCustomNode: ${JSON.stringify(e.name)} has a schema that does not implement Standard Schema`);if(e.payloadNamespace!==void 0&&!oe(e.payloadNamespace))throw new Error(`defineCustomNode: ${JSON.stringify(e.name)} has a payloadNamespace that cannot be written into an XPath \u2014 no quotes, angle brackets, ampersands or control characters: ${JSON.stringify(e.payloadNamespace)}`);if(e.preserveOnExport!==void 0&&e.preserveOnExport!==true&&e.preserveOnExport!==false&&e.preserveOnExport!=="text")throw new Error(`defineCustomNode: ${JSON.stringify(e.name)} has an unknown preserveOnExport ${JSON.stringify(e.preserveOnExport)}`);return Object.freeze({...e,dataOf:n=>{if(!n||n.data===void 0||n.name!==void 0&&n.name!==e.name)return;if(!e.schema)return n.data;let r=e.schema["~standard"].validate(n.data);if(typeof r.then=="function")return;let a=r;return a.issues?void 0:a.value}})}function ze(e){g(e.licenseKey);let t=new Set;for(let o of e.nodes){let n=`${o.tagPrefix}:${o.name}`;if(t.has(n))throw new Error(`customNodesModule: two definitions claim ${JSON.stringify(n)}`);t.add(n);}return {id:"custom-nodes",customNodes:e.nodes,...e.onDiagnostic?{onCustomNodeDiagnostic:o=>{e.onDiagnostic?.(o);}}:{},customNodePayloadNamespaces:[...new Set(e.nodes.map(v))]}}function ne(e){for(let t of e.children)if(!(t.kind==="textValue"||t.localName!=="sdtPr")){for(let o of t.children)if(!(o.kind==="textValue"||o.localName!=="tag")){for(let n of o.attributes)if(n.localName==="val")return n.value}}}function j(e){if(e.kind==="textValue")return e.value;let t="";for(let o of e.children)t+=j(o);return t}function W(e,t,o={}){if(t.length===0)return [];let n=new Map;for(let s of t){let d=`${s.tagPrefix}:${s.name}`;if(n.has(d))throw new Error(`recognizeCustomNodes: duplicate definition for ${JSON.stringify(d)}`);n.set(d,s);}let r=[],a=(s,d)=>{if(!(s.kind==="textValue"||d>64)){if(s.kind==="contentControl"){let i=ne(s),u=i!==void 0?N(i):null,c=u?n.get(`${u.prefix}:${u.name}`):void 0;if(u&&c&&i!==void 0){let l=j(s),f=re(c,s.id,o.payloads?.get(s.id),store.contentControlPropertiesOf(s).dataBinding!==void 0,o.onDiagnostic),m=c.fromDocx?c.fromDocx({attrs:u.attrs,text:l,...f.present?{data:f.value}:{}}):u.attrs;if(m!==null){r.push({name:c.name,attrs:m,text:l,nodeId:s.id,tag:i,...f.present?{data:f.value}:{}});return}}}for(let i of s.children)a(i,d+1);}};return a(e.root,0),r}function re(e,t,o,n,r){if(!o)return n&&r?.({code:"payload-missing",name:e.name,nodeId:t,issues:["the control binds a store node this document does not hold"]}),{present:false};let a=x(e.schema,o.data);return a.ok?{present:true,value:a.value}:(r?.({code:"payload-invalid",name:e.name,nodeId:t,issues:a.issues}),{present:false})}function K(e,t){let o=store.findNode(e,t);return !o||o.kind!=="paragraph"?[]:store.revisionItemsOf({id:e.id,name:e.name,contentType:e.contentType,root:o})}function ce(e,t,o,n){if(t.length===0)return [];let r=W(e,t,{...o===void 0?{}:{payloads:o},...n===void 0?{}:{onDiagnostic:n}});if(r.length===0)return [];let a=store.locateSites(e),s=[];for(let d of r){let i=t.find(l=>l.name===d.name&&d.tag.startsWith(`${l.tagPrefix}:`));if(!i)continue;let u=i.reviewCard?i.reviewCard({attrs:d.attrs,text:d.text,...d.data===void 0?{}:{data:d.data}}):null;if(i.reviewCard&&u===null)continue;let c=a.get(d.nodeId);s.push({kind:"custom",id:d.nodeId,name:d.name,tag:d.tag,attrs:d.attrs,text:d.text,...d.data===void 0?{}:{data:d.data},carded:i.reviewCard!==void 0&&u!==null,title:u?.title??"",...u?.detail!==void 0?{detail:u.detail}:{},...u?.icon!==void 0?{icon:u.icon}:{},range:c?{partName:e.name,start:{paragraphId:c.paragraphId,offset:c.start},end:{paragraphId:c.paragraphId,offset:c.end}}:null});}return s}function U(e){let t=store.collectReviewItems(e),o=(e.customNodes??[]).filter(z);if(o.length===0)return t;let n=[e.storyPart],r=new Set([e.storyPart.name]);for(let i of e.furnitureParts??[])r.has(i.name)||(r.add(i.name),n.push(i));let a=[],s=new Map;for(let i of n){a.push(...ce(i,o,i.name===e.storyPart.name?e.customNodePayloads:void 0,e.reportCustomNodeDiagnostic));let u=s.size;for(let[c,l]of store.paragraphOrderOfPart(i))s.has(c)||s.set(c,u+l);}return a.length===0?t:[...t,...a].sort((i,u)=>layout.reviewItemPositionRank(i,s)-layout.reviewItemPositionRank(u,s))}function ot(e={}){return g(e.licenseKey),{id:"review",review:{displayModes:["all-markup","proposed","original"],collectReviewItems:U,revisionItemsOfParagraph:K}}}function G(e){return e.surface??null}function E(e,t){if(t==null)return null;let o=L(e,t);return o.ok?{ok:true,serialized:o.data,value:o.value}:{ok:false,reason:o.reason,issues:o.issues}}function D(e,t,o,n,r){let a=v(t),s=e.session.part().name;return {namespaceUri:a,rootLocalName:b,nodeId:r??M(e.session.currentPackage(),s,a),label:n,data:o}}function k(e){let t=e.detail?`${e.reason}: ${e.detail}`:e.reason;return {ok:false,code:me.has(e.reason)?"invalidArgs":"unsupported",reason:t}}var me=new Set(["payload-too-large","unaddressable-payload","store-not-authored","offset-out-of-range","invalid-range","invalid-property-value","splits-surrogate-pair"]);function A(e,t,o){let n,r;if(o!==void 0)try{n=e.text?.(o),r=e.tagAttrs?.(o);}catch(s){return {reason:`${e.name} could not describe this payload: ${s instanceof Error?s.message:String(s)}`}}let a=t.text??n;return a===void 0?{reason:e.text?`${e.name} derives its text from \`data\`, so pass one \u2014 or pass \`text\` directly`:`${e.name} declares no \`text\`, so \`text\` is required`}:t.attrs===void 0&&e.tagAttrs&&r===void 0?{reason:`${e.name} derives its tag attrs from \`data\`, so pass one \u2014 or pass \`attrs\` directly`}:{attrs:t.attrs??r??{},text:a}}function C(e){return e.getEditingMode()==="viewing"?{ok:false,code:"locked",reason:"the document is open for viewing"}:null}function P(e){let t=e.getActiveScope();if(t.kind==="headerFooter")return {kind:"headerFooter",rId:t.rId};if(t.kind==="note"){let o=store.parseNoteScopeId(t.id);if(o)return {kind:"notesPart",noteKind:o.noteKind}}return {kind:"body"}}function T(e,t){let o=G(e),n=t===void 0?"":t.slice(0,t.indexOf("#"));if(!o||n.length===0)return P(e);if(n===o.session.part().name)return {kind:"body"};for(let r of o.session.headerFooterResolutionBySection())for(let a of [r.headers,r.footers])for(let s of a.values())if(s.partName===n)return {kind:"headerFooter",rId:s.rId};for(let r of ["footnote","endnote"])if(o.session.partFor({kind:"notesPart",noteKind:r})?.name===n)return {kind:"notesPart",noteKind:r};return P(e)}function it(e,t,o={}){let n=G(e);if(!n)return {ok:false,code:"notFound",reason:"no document is mounted"};let r=E(t,o.data);if(r&&!r.ok)return S(r.reason,r.issues);let a=A(t,o,r?.value);if("reason"in a)return {ok:false,code:"invalidArgs",reason:a.reason};let s=h(t.tagPrefix,t.name,a.attrs);if(!s.ok)return {ok:false,code:"invalidArgs",reason:`the encoded tag is ${s.length} characters; Word caps w:tag at 64 \u2014 move what does not fit into the payload (\`data\`), or shorten the attrs`};let d=C(e);if(d)return d;n.flushPendingInput();let i=o.at??n.state().selection.head,u=o.lock===void 0?"contentLocked":o.lock,c=P(e),l=n.session.insertCustomNode({paragraphId:i.paragraphId,offset:i.offset,tag:s.tag,text:a.text,...o.alias===void 0?{}:{alias:o.alias},...u===false?{}:{lock:u},...r?{payload:D(n,t,r.serialized,a.text)}:{}},c);return l.ok?{ok:true,changed:true,...l.nodeId===void 0?{}:{nodeId:l.nodeId}}:k(l)}function J(e){return e.surface??null}function Ne(e,t){let o=null,n=a=>a.id===t?true:a.kind==="textValue"?false:a.children.some(n),r=(a,s)=>{if(!(o||a.kind==="textValue"||s>64)){if(a.kind==="paragraph"){n(a)&&(o=a);return}for(let d of a.children)r(d,s+1);}};return r(e.root,0),o}function xe(e,t){let o=new Set,n=i=>{if(o.add(i.id),i.kind!=="textValue")for(let u of i.children)n(u);},r=i=>{if(i.id===t)return i;if(i.kind==="textValue")return null;for(let u of i.children){let c=r(u);if(c)return c}return null},a=r(e);if(!a)return null;n(a);let s=Number.MAX_SAFE_INTEGER,d=-1;for(let i of store.segmentsOf(e))o.has(i.runId)&&(i.start<s&&(s=i.start),i.end>d&&(d=i.end));return d<0?null:{start:s,end:d}}function gt(e,t){let o=J(e);if(!o)return {ok:false,code:"notFound",reason:"no document is mounted"};let n=C(e);if(n)return n;o.flushPendingInput();let r=o.session.removeCustomNode(t,T(e,t));return r.ok?{ok:true,changed:true}:k(r)}function ht(e,t,o,n={}){let r=J(e);if(!r)return {ok:false,code:"notFound",reason:"no document is mounted"};let a=C(e);if(a)return a;r.flushPendingInput();let s=T(e,o),d=r.session.partFor(s)??r.session.part(),i=Ne(d,o),u=i?xe(i,o):null,c=Se(r,o,s);if(!i||!u||!c)return {ok:false,code:"notFound",reason:"no custom node with that id"};let l=`${t.tagPrefix}:${t.name}`;if(c.identity!==null&&c.identity!==l)return {ok:false,code:"invalidArgs",reason:`node ${o} is a ${c.identity}, not a ${l}`};let f=ke(r,o),m=n.data===null?null:n.data===void 0?ve(f):E(t,n.data);if(m&&!m.ok)return S(m.reason,m.issues);let p=A(t,{attrs:n.attrs??(n.data===void 0?c.attrs:void 0),text:n.text??(m===null&&n.data===null?c.text:void 0)},m?.value);if("reason"in p)return {ok:false,code:"invalidArgs",reason:p.reason};let O=h(t.tagPrefix,t.name,p.attrs);if(!O.ok)return {ok:false,code:"invalidArgs",reason:`the encoded tag is ${O.length} characters; Word caps w:tag at 64 \u2014 move what does not fit into the payload (\`data\`), or shorten the attrs`};let $=n.alias??c.alias,w=n.lock??c.lock,y=r.session.insertCustomNode({replaceControlId:o,paragraphId:i.id,offset:u.start,tag:O.tag,text:p.text,...$===void 0?{}:{alias:$},...w===false||w===void 0?{}:{lock:w},...m?{payload:D(r,t,m.serialized,p.text,f?.nodeId)}:{}},s);return y.ok?{ok:true,changed:true,...y.nodeId===void 0?{}:{nodeId:y.nodeId}}:k(y)}function Se(e,t,o){let n=e.session.partFor(o)??e.session.part(),r=store.contentControlsIn(n.root).find(i=>i.node.id===t);if(!r)return null;let a=store.contentControlPropertiesOf(r.node),s=a.tag===void 0?null:N(a.tag),d=a.lock;return {identity:s?`${s.prefix}:${s.name}`:null,attrs:s?.attrs??{},text:store.contentControlTextOf(r.node),alias:a.alias,lock:d==="sdtLocked"||d==="sdtContentLocked"||d==="contentLocked"?d:d==="unlocked"?false:void 0}}function ve(e){if(!e)return null;let t=x(void 0,e.data);return t.ok?{ok:true,serialized:e.data,value:t.value}:{ok:false,reason:`the stored payload is not readable: ${t.issues.join(", ")}`,issues:[]}}function ke(e,t){let o=e.session.part();return store.customNodePayloadsByControl(e.session.currentPackage(),o.name).get(t)}exports.a=Oe;exports.b=h;exports.c=N;exports.d=Ie;exports.e=x;exports.f=R;exports.g=b;exports.h=v;exports.i=L;exports.j=z;exports.k=V;exports.l=Ve;exports.m=ze;exports.n=W;exports.o=ot;exports.p=it;exports.q=gt;exports.r=ht;
|
package/dist/chunk-TNUAAUFI.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {contentControlsIn,contentControlPropertiesOf,contentControlTextOf,findNode,revisionItemsOf,collectReviewItems,paragraphOrderOfPart,parseNoteScopeId,locateSites,customNodePayloadsOf,customNodePayloadsByControl,segmentsOf}from'@docx-editor.dev/core/store';import {reviewItemPositionRank}from'@docx-editor.dev/core/layout';function g(e){}var Oe=64,H=new Set(["__proto__","constructor","prototype"]);function h(e,t,o){let n=new URLSearchParams;for(let[s,d]of Object.entries(o))n.set(s,d);let r=n.toString(),a=r.length>0?`${e}:${t}?${r}`:`${e}:${t}`;return a.length>64?{ok:false,reason:"tag-overflow",length:a.length}:{ok:true,tag:a}}function N(e){if(e.length>64)return null;let t=e.indexOf(":");if(t<=0)return null;let o=e.slice(0,t),n=e.slice(t+1),r=n.indexOf("?"),a=r===-1?n:n.slice(0,r);if(a.length===0)return null;let s=Object.create(null);if(r!==-1)for(let[d,i]of new URLSearchParams(n.slice(r+1))){if(H.has(d))return null;s[d]=i;}return {prefix:o,name:a,attrs:s}}var Ie=262144;function x(e,t){if(t.length===0)return {ok:false,reason:"malformed",issues:["the node carries no payload"]};if(t.length>262144)return {ok:false,reason:"malformed",issues:[`the payload is ${String(t.length)} characters; the cap is ${String(262144)}`]};let o;try{o=JSON.parse(t);}catch(a){return {ok:false,reason:"malformed",issues:[a instanceof Error?a.message:"the payload is not JSON"]}}let n=I(o);if(!e)return {ok:true,value:n};let r=e["~standard"].validate(n);return B(r)?{ok:false,reason:"async",issues:["the schema validates asynchronously, which the read path cannot await"]}:r.issues?{ok:false,reason:"invalid",issues:r.issues.map(q)}:{ok:true,value:r.value}}function R(e){let t;try{t=JSON.stringify(e)??"";}catch(o){return {ok:false,reason:"malformed",issues:[o instanceof Error?o.message:"the value cannot be serialized"]}}return t.length===0?{ok:false,reason:"malformed",issues:["the value serializes to nothing"]}:t.length>262144?{ok:false,reason:"malformed",issues:[`the payload is ${String(t.length)} characters; the cap is ${String(262144)}`]}:{ok:true,value:t}}function B(e){return typeof e.then=="function"}function q(e){let t=(e.path??[]).map(o=>String(typeof o=="object"?o.key:o)).join(".");return t.length>0?`${t}: ${e.message}`:e.message}var Y=new Set(["__proto__","constructor","prototype"]);function I(e){if(Array.isArray(e))return e.map(I);if(e===null||typeof e!="object")return e;let t=Object.create(null);for(let[o,n]of Object.entries(e))Y.has(o)||(t[o]=I(n));return t}function _(e){let t=(e.path??[]).map(o=>{let n=typeof o=="object"?o.key:o;return typeof n=="number"?n:String(n)});return {message:e.message,path:t,pointer:t.join(".")}}function S(e,t){return {ok:false,code:"invalidArgs",reason:e,issues:t}}var b="docxEditor";function v(e){return e.payloadNamespace??`urn:docx-editor.dev:custom-node:${e.tagPrefix}`}function M(e,t,o){let n=0;for(let r of customNodePayloadsOf(e,t,o).keys()){let a=/^cx(\d{1,9})$/.exec(r);if(!a)continue;let s=Number(a[1]);s>n&&(n=s);}return `cx${String(n+1)}`}function L(e,t){let o=R(t);if(!o.ok)return {ok:false,reason:`the payload cannot be serialized: ${o.issues.join(", ")}`,issues:[]};if(!e.schema)return {ok:true,data:o.value,value:t};let r=e.schema["~standard"].validate(JSON.parse(o.value));if(Q(r))return {ok:false,reason:`${e.name}'s schema validates asynchronously, which a write cannot await`,issues:[]};if(r.issues){let s=r.issues.map(_);return {ok:false,reason:`the payload does not match ${e.name}'s schema: `+s.map(d=>(d.pointer?`${d.pointer}: `:"")+d.message).join(", "),issues:s}}let a=R(r.value);return a.ok?{ok:true,data:a.value,value:r.value}:{ok:false,reason:`the payload cannot be serialized: ${a.issues.join(", ")}`,issues:[]}}function Q(e){return typeof e.then=="function"}function z(e){return typeof e=="object"&&e!==null&&typeof e.name=="string"&&typeof e.tagPrefix=="string"}var V=/^[A-Za-z0-9_.-]+$/,te=/['"<>&]|[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/;function oe(e){return e.length>0&&!te.test(e)}function Ve(e){if(!V.test(e.name??""))throw new Error(`defineCustomNode: invalid name ${JSON.stringify(e.name)}`);if(!V.test(e.tagPrefix??""))throw new Error(`defineCustomNode: invalid tagPrefix ${JSON.stringify(e.tagPrefix)}`);let t=e.schema;if(t!==void 0&&typeof t?.["~standard"]?.validate!="function")throw new Error(`defineCustomNode: ${JSON.stringify(e.name)} has a schema that does not implement Standard Schema`);if(e.payloadNamespace!==void 0&&!oe(e.payloadNamespace))throw new Error(`defineCustomNode: ${JSON.stringify(e.name)} has a payloadNamespace that cannot be written into an XPath \u2014 no quotes, angle brackets, ampersands or control characters: ${JSON.stringify(e.payloadNamespace)}`);if(e.preserveOnExport!==void 0&&e.preserveOnExport!==true&&e.preserveOnExport!==false&&e.preserveOnExport!=="text")throw new Error(`defineCustomNode: ${JSON.stringify(e.name)} has an unknown preserveOnExport ${JSON.stringify(e.preserveOnExport)}`);return Object.freeze({...e,dataOf:n=>{if(!n||n.data===void 0||n.name!==void 0&&n.name!==e.name)return;if(!e.schema)return n.data;let r=e.schema["~standard"].validate(n.data);if(typeof r.then=="function")return;let a=r;return a.issues?void 0:a.value}})}function ze(e){g(e.licenseKey);let t=new Set;for(let o of e.nodes){let n=`${o.tagPrefix}:${o.name}`;if(t.has(n))throw new Error(`customNodesModule: two definitions claim ${JSON.stringify(n)}`);t.add(n);}return {id:"custom-nodes",customNodes:e.nodes,...e.onDiagnostic?{onCustomNodeDiagnostic:o=>{e.onDiagnostic?.(o);}}:{},customNodePayloadNamespaces:[...new Set(e.nodes.map(v))]}}function ne(e){for(let t of e.children)if(!(t.kind==="textValue"||t.localName!=="sdtPr")){for(let o of t.children)if(!(o.kind==="textValue"||o.localName!=="tag")){for(let n of o.attributes)if(n.localName==="val")return n.value}}}function j(e){if(e.kind==="textValue")return e.value;let t="";for(let o of e.children)t+=j(o);return t}function W(e,t,o={}){if(t.length===0)return [];let n=new Map;for(let s of t){let d=`${s.tagPrefix}:${s.name}`;if(n.has(d))throw new Error(`recognizeCustomNodes: duplicate definition for ${JSON.stringify(d)}`);n.set(d,s);}let r=[],a=(s,d)=>{if(!(s.kind==="textValue"||d>64)){if(s.kind==="contentControl"){let i=ne(s),u=i!==void 0?N(i):null,c=u?n.get(`${u.prefix}:${u.name}`):void 0;if(u&&c&&i!==void 0){let l=j(s),f=re(c,s.id,o.payloads?.get(s.id),contentControlPropertiesOf(s).dataBinding!==void 0,o.onDiagnostic),m=c.fromDocx?c.fromDocx({attrs:u.attrs,text:l,...f.present?{data:f.value}:{}}):u.attrs;if(m!==null){r.push({name:c.name,attrs:m,text:l,nodeId:s.id,tag:i,...f.present?{data:f.value}:{}});return}}}for(let i of s.children)a(i,d+1);}};return a(e.root,0),r}function re(e,t,o,n,r){if(!o)return n&&r?.({code:"payload-missing",name:e.name,nodeId:t,issues:["the control binds a store node this document does not hold"]}),{present:false};let a=x(e.schema,o.data);return a.ok?{present:true,value:a.value}:(r?.({code:"payload-invalid",name:e.name,nodeId:t,issues:a.issues}),{present:false})}function K(e,t){let o=findNode(e,t);return !o||o.kind!=="paragraph"?[]:revisionItemsOf({id:e.id,name:e.name,contentType:e.contentType,root:o})}function ce(e,t,o,n){if(t.length===0)return [];let r=W(e,t,{...o===void 0?{}:{payloads:o},...n===void 0?{}:{onDiagnostic:n}});if(r.length===0)return [];let a=locateSites(e),s=[];for(let d of r){let i=t.find(l=>l.name===d.name&&d.tag.startsWith(`${l.tagPrefix}:`));if(!i)continue;let u=i.reviewCard?i.reviewCard({attrs:d.attrs,text:d.text,...d.data===void 0?{}:{data:d.data}}):null;if(i.reviewCard&&u===null)continue;let c=a.get(d.nodeId);s.push({kind:"custom",id:d.nodeId,name:d.name,tag:d.tag,attrs:d.attrs,text:d.text,...d.data===void 0?{}:{data:d.data},carded:i.reviewCard!==void 0&&u!==null,title:u?.title??"",...u?.detail!==void 0?{detail:u.detail}:{},...u?.icon!==void 0?{icon:u.icon}:{},range:c?{partName:e.name,start:{paragraphId:c.paragraphId,offset:c.start},end:{paragraphId:c.paragraphId,offset:c.end}}:null});}return s}function U(e){let t=collectReviewItems(e),o=(e.customNodes??[]).filter(z);if(o.length===0)return t;let n=[e.storyPart],r=new Set([e.storyPart.name]);for(let i of e.furnitureParts??[])r.has(i.name)||(r.add(i.name),n.push(i));let a=[],s=new Map;for(let i of n){a.push(...ce(i,o,i.name===e.storyPart.name?e.customNodePayloads:void 0,e.reportCustomNodeDiagnostic));let u=s.size;for(let[c,l]of paragraphOrderOfPart(i))s.has(c)||s.set(c,u+l);}return a.length===0?t:[...t,...a].sort((i,u)=>reviewItemPositionRank(i,s)-reviewItemPositionRank(u,s))}function ot(e={}){return g(e.licenseKey),{id:"review",review:{displayModes:["all-markup","proposed","original"],collectReviewItems:U,revisionItemsOfParagraph:K}}}function G(e){return e.surface??null}function E(e,t){if(t==null)return null;let o=L(e,t);return o.ok?{ok:true,serialized:o.data,value:o.value}:{ok:false,reason:o.reason,issues:o.issues}}function D(e,t,o,n,r){let a=v(t),s=e.session.part().name;return {namespaceUri:a,rootLocalName:b,nodeId:r??M(e.session.currentPackage(),s,a),label:n,data:o}}function k(e){let t=e.detail?`${e.reason}: ${e.detail}`:e.reason;return {ok:false,code:me.has(e.reason)?"invalidArgs":"unsupported",reason:t}}var me=new Set(["payload-too-large","unaddressable-payload","store-not-authored","offset-out-of-range","invalid-range","invalid-property-value","splits-surrogate-pair"]);function A(e,t,o){let n,r;if(o!==void 0)try{n=e.text?.(o),r=e.tagAttrs?.(o);}catch(s){return {reason:`${e.name} could not describe this payload: ${s instanceof Error?s.message:String(s)}`}}let a=t.text??n;return a===void 0?{reason:e.text?`${e.name} derives its text from \`data\`, so pass one \u2014 or pass \`text\` directly`:`${e.name} declares no \`text\`, so \`text\` is required`}:t.attrs===void 0&&e.tagAttrs&&r===void 0?{reason:`${e.name} derives its tag attrs from \`data\`, so pass one \u2014 or pass \`attrs\` directly`}:{attrs:t.attrs??r??{},text:a}}function C(e){return e.getEditingMode()==="viewing"?{ok:false,code:"locked",reason:"the document is open for viewing"}:null}function P(e){let t=e.getActiveScope();if(t.kind==="headerFooter")return {kind:"headerFooter",rId:t.rId};if(t.kind==="note"){let o=parseNoteScopeId(t.id);if(o)return {kind:"notesPart",noteKind:o.noteKind}}return {kind:"body"}}function T(e,t){let o=G(e),n=t===void 0?"":t.slice(0,t.indexOf("#"));if(!o||n.length===0)return P(e);if(n===o.session.part().name)return {kind:"body"};for(let r of o.session.headerFooterResolutionBySection())for(let a of [r.headers,r.footers])for(let s of a.values())if(s.partName===n)return {kind:"headerFooter",rId:s.rId};for(let r of ["footnote","endnote"])if(o.session.partFor({kind:"notesPart",noteKind:r})?.name===n)return {kind:"notesPart",noteKind:r};return P(e)}function it(e,t,o={}){let n=G(e);if(!n)return {ok:false,code:"notFound",reason:"no document is mounted"};let r=E(t,o.data);if(r&&!r.ok)return S(r.reason,r.issues);let a=A(t,o,r?.value);if("reason"in a)return {ok:false,code:"invalidArgs",reason:a.reason};let s=h(t.tagPrefix,t.name,a.attrs);if(!s.ok)return {ok:false,code:"invalidArgs",reason:`the encoded tag is ${s.length} characters; Word caps w:tag at 64 \u2014 move what does not fit into the payload (\`data\`), or shorten the attrs`};let d=C(e);if(d)return d;n.flushPendingInput();let i=o.at??n.state().selection.head,u=o.lock===void 0?"contentLocked":o.lock,c=P(e),l=n.session.insertCustomNode({paragraphId:i.paragraphId,offset:i.offset,tag:s.tag,text:a.text,...o.alias===void 0?{}:{alias:o.alias},...u===false?{}:{lock:u},...r?{payload:D(n,t,r.serialized,a.text)}:{}},c);return l.ok?{ok:true,changed:true,...l.nodeId===void 0?{}:{nodeId:l.nodeId}}:k(l)}function J(e){return e.surface??null}function Ne(e,t){let o=null,n=a=>a.id===t?true:a.kind==="textValue"?false:a.children.some(n),r=(a,s)=>{if(!(o||a.kind==="textValue"||s>64)){if(a.kind==="paragraph"){n(a)&&(o=a);return}for(let d of a.children)r(d,s+1);}};return r(e.root,0),o}function xe(e,t){let o=new Set,n=i=>{if(o.add(i.id),i.kind!=="textValue")for(let u of i.children)n(u);},r=i=>{if(i.id===t)return i;if(i.kind==="textValue")return null;for(let u of i.children){let c=r(u);if(c)return c}return null},a=r(e);if(!a)return null;n(a);let s=Number.MAX_SAFE_INTEGER,d=-1;for(let i of segmentsOf(e))o.has(i.runId)&&(i.start<s&&(s=i.start),i.end>d&&(d=i.end));return d<0?null:{start:s,end:d}}function gt(e,t){let o=J(e);if(!o)return {ok:false,code:"notFound",reason:"no document is mounted"};let n=C(e);if(n)return n;o.flushPendingInput();let r=o.session.removeCustomNode(t,T(e,t));return r.ok?{ok:true,changed:true}:k(r)}function ht(e,t,o,n={}){let r=J(e);if(!r)return {ok:false,code:"notFound",reason:"no document is mounted"};let a=C(e);if(a)return a;r.flushPendingInput();let s=T(e,o),d=r.session.partFor(s)??r.session.part(),i=Ne(d,o),u=i?xe(i,o):null,c=Se(r,o,s);if(!i||!u||!c)return {ok:false,code:"notFound",reason:"no custom node with that id"};let l=`${t.tagPrefix}:${t.name}`;if(c.identity!==null&&c.identity!==l)return {ok:false,code:"invalidArgs",reason:`node ${o} is a ${c.identity}, not a ${l}`};let f=ke(r,o),m=n.data===null?null:n.data===void 0?ve(f):E(t,n.data);if(m&&!m.ok)return S(m.reason,m.issues);let p=A(t,{attrs:n.attrs??(n.data===void 0?c.attrs:void 0),text:n.text??(m===null&&n.data===null?c.text:void 0)},m?.value);if("reason"in p)return {ok:false,code:"invalidArgs",reason:p.reason};let O=h(t.tagPrefix,t.name,p.attrs);if(!O.ok)return {ok:false,code:"invalidArgs",reason:`the encoded tag is ${O.length} characters; Word caps w:tag at 64 \u2014 move what does not fit into the payload (\`data\`), or shorten the attrs`};let $=n.alias??c.alias,w=n.lock??c.lock,y=r.session.insertCustomNode({replaceControlId:o,paragraphId:i.id,offset:u.start,tag:O.tag,text:p.text,...$===void 0?{}:{alias:$},...w===false||w===void 0?{}:{lock:w},...m?{payload:D(r,t,m.serialized,p.text,f?.nodeId)}:{}},s);return y.ok?{ok:true,changed:true,...y.nodeId===void 0?{}:{nodeId:y.nodeId}}:k(y)}function Se(e,t,o){let n=e.session.partFor(o)??e.session.part(),r=contentControlsIn(n.root).find(i=>i.node.id===t);if(!r)return null;let a=contentControlPropertiesOf(r.node),s=a.tag===void 0?null:N(a.tag),d=a.lock;return {identity:s?`${s.prefix}:${s.name}`:null,attrs:s?.attrs??{},text:contentControlTextOf(r.node),alias:a.alias,lock:d==="sdtLocked"||d==="sdtContentLocked"||d==="contentLocked"?d:d==="unlocked"?false:void 0}}function ve(e){if(!e)return null;let t=x(void 0,e.data);return t.ok?{ok:true,serialized:e.data,value:t.value}:{ok:false,reason:`the stored payload is not readable: ${t.issues.join(", ")}`,issues:[]}}function ke(e,t){let o=e.session.part();return customNodePayloadsByControl(e.session.currentPackage(),o.name).get(t)}export{Oe as a,h as b,N as c,Ie as d,x as e,R as f,b as g,v as h,L as i,z as j,V as k,Ve as l,ze as m,W as n,ot as o,it as p,gt as q,ht as r};
|